$.widget('ui.mywidget',{}); $(':ui-mywidget') //find all ui.mywidget instances
Thursday, November 22, 2012
jQuery UI widget pseudo-selectors
I stumbled across a very handy feature from jQuery UI today - widget pseudo-selectors.
This page describes the feature well, but I have copied a common scenario here:
Saturday, November 17, 2012
Configuring a Git server
To publish an HTTP server, I use WebGitNet and the following system configuration:
receive.denynonfastforwards=true gc.auto=0 core.logallrefupdates=true
receive.denynonfastforwards=true
Prevents people from accidentally pushing (using -force) a non-fast-forward update. This happened to me when I wanted to push a non-fast-forward update, but did not specify the single branch i.e. I usedgit push -f
, which by default pushes all branches using the force flag.
gc.auto=0
There can be a lot of useful information in the 'garbage' of a git repository. My policy is to never delete that garbage.core.logallrefupdates=true
The reflog is useful, but unfortunately it is not kept for remote bare repositories. This re-enables the reflog.Thursday, November 15, 2012
Launching a PowerShell script in 64 bit mode on a 64 bit machine
If a 32-bit process launches PowerShell on a 64 bit machine, it will launch powershell.exe from the 32 bit system32 folder rather than the 64 bit one. Some scripts need to run in 64 bit mode, so the solution is to have the script relaunch itself in 64 bit mode if it detects that it has been run in 32 bit mode. This is one way to do it:
$powerShellExe = join-path $env:WINDIR SysNative\WindowsPowerShell\v1.0\powershell.exe if(test-path ($powerShellExe)) { if([System.Runtime.InterOpServices.Marshal]::SizeOf([System.IntPtr]) -eq 4) { write-host "Re-launching script in native 64 bit mode..." & $powerShellExe $MyInvocation.MyCommand.Definition $PSBoundParameters.Values $host.SetShouldExit($LASTEXITCODE) exit } }
Wednesday, November 14, 2012
Getting an accurate list of dependencies from SSMS
The dependency dialog in SQL Server Management Studio does not appear to be particularly reliable, not returning some dependencies.
The solution is to use the sys.dm_sql_referenced_entities table function:
select * from sys.dm_sql_referenced_entities (<ENTITY>, 'object')
Tuesday, November 13, 2012
Correctly Executing a PowerShell script from MSBuild
It took me a while to find out how to execute a PowerShell script from within an MSBuild script while propagating errors to MSBUILD. I tried several approaches, including the usual -File argument, but this is what I came up with in the end:
<Exec Command="powershell -Command "&{ .\Deploy.ps1 scriptArg1 scriptArg2 }"" />
Tuesday, November 6, 2012
Configuring a new Windows Server 2012 instance using PowerShell
- Join the domain (prompt for user name and password of domain administrator):
Add-Computer -DomainName {Domain Name}
- Add a domain user as an administrator:
net localgroup administrators {Domain Name}\{User Name} /add
- Name the computer:
Rename-Computer {New Name}
- Enable PowerShell remoting (note: no double hops):
Enable-PSRemoting
- Restart the computer:
Restart-Computer
Subscribe to:
Posts (Atom)