Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / gist:901902
Created April 4, 2011 16:20
FizzBuzz Quiz: Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “
# First version
def fizzbuzz num
answer = []
answer.push 'fizz' if num % 3 == 0
answer.push 'buzz' if num % 5 == 0
answer.push num if num % 3 != 0 and num % 5 != 0