Mats codemix

Mats codemix

A little c#, a litte .NET and throw in some c++ and you get a nice Spaghetti

Mats codemix RSS Feed
 
 
 
 

Posts tagged tips

Powershell tips - Filter files modified the last n days

I wanted to list files modified the last n days. Here is a filter function i wrote to help me.
1 function FilterLast([int] $nDays)
2 {
3 begin {
4 $DateToCompare = (Get-date).AddDays(-1 * $nDays)
5 }
6
[...]

Powershelll tips - Filter on container

Say you want to recurse a diretory tree and show just the directories.
Yo can write
ls C:\ -rec | %{if ($_.PSIsContainer) { $_ }} | %{$_.Fullname}
Add a little filter function
1 function FilterContainer()
2 {
3 process
4 {
5 %{if ($_.PSIsContainer) { $_ }}
6 [...]

SQL - Show tables containing a column

When digging through database tables i use this little select-sctatement to find out which tables that contain a scertain column name.
1 — Show tables containing a column
2 select sysobj.name + ‘.’ + syscol.name
3 , ’sp_help ‘ + sysobj.name as sptext
4 , ’select * from ‘ + sysobj.name as selall
5 , [...]