Skip to content

Instantly share code, notes, and snippets.

@jjhamshaw
jjhamshaw / gist:8931729
Created February 11, 2014 09:25
remove deleted remote branches
# Option 1) remove deleted branches on fetch
git fetch --prune
# Option 2) create an alias. Open your config file...
git config -e
# ...and add the following section
[alias]
[
{ "keys": ["ctrl+shift+l"], "command": "reveal_in_side_bar"},
// dependent on plugins
{ "keys": ["ctrl+k", "ctrl+f"], "command": "xml_prettify" }
]
@jjhamshaw
jjhamshaw / AppCache.cs
Created April 22, 2015 02:11
A simple System.Runtime.Caching.MemoryCache wrapper
public class AppCache : ICache
{
public object GetValue(string key)
{
MemoryCache memoryCache = MemoryCache.Default;
return memoryCache.Get(key);
}
public bool Add(string key, object value, DateTimeOffset absExpiration)
{
@jjhamshaw
jjhamshaw / gist:1199032
Created September 6, 2011 21:31
example of a cucumber feature file
Feature: User accounts
Scenario: A user can log in to the site
Given: I am on the log in page
When: I fill in user details
And: click "Sign in"
Then: I should be redirected to the "my account" page
@jjhamshaw
jjhamshaw / debug_output.ps1
Created March 26, 2012 18:03
powershell pscx module example: 'write-zip'
C:\Windows\System32\WindowsPowerShell\v1.0
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest AppLocker {}
Manifest BitsTransfer {}
Manifest PSDiagnostics {}
Manifest TroubleshootingPack {}
Manifest WebAdministration {}
@jjhamshaw
jjhamshaw / ListFile.cs
Created June 10, 2012 12:56
exception handling example - reads a file and writes contents to the console
class ListFile
{
static void Main(string[] args)
{
var arg0 = args[0];
try
{
var counter = 0;
if (args.Length <= 0)
@jjhamshaw
jjhamshaw / ExceptionThrowingExample.cs
Created June 10, 2012 13:20
how to throw an exception
class ExceptionThrowingExample
{
public void DoSomething()
{
Console.WriteLine("Starting to do something...");
throw new Exception();
//Will never be called. The throw command terminates the program...
Console.WriteLine("...finished doing something.");
@jjhamshaw
jjhamshaw / TryCatchFinally.cs
Created June 10, 2012 14:46
try, catch, finally
try
{
// code which can cause an exception
}
catch (exception_type e)
{
// code for handling the exception
}
finally
{
@jjhamshaw
jjhamshaw / gist:3305817
Created August 9, 2012 16:49
powershell db copy
task BackupTestToQaDatabase {
try {
Invoke-Sqlcmd -InputFile $copySqlDatabase -ServerInstance $sqlserver -Database $databaseToBackUp -Username $databaseUsername -Password $databasePassword -QueryTimeout 240 -ErrorAction 'Stop'
} catch {
'##teamcity[buildStatus status='FAILURE' text='Build Failed']'
}
}
@jjhamshaw
jjhamshaw / open_xamarin.sh
Created February 1, 2016 16:13
open multiple instances of xamarin studio
open -n /Applications/Xamarin\ Studio.app