Skip to content

Instantly share code, notes, and snippets.

@gregmajor
gregmajor / IsElseStateMachine.cs
Created August 25, 2012 19:53
If-Else State Machine
/*
* INTRO
* - Review a classic If/Else implementation
* - The myth of reducing cyclomatic complexity
*/
using System;
class Program
{
@gregmajor
gregmajor / IterationStateMachine.cs
Created August 25, 2012 19:56
Iteration State Machine
/*
* ITERATION AND STATE MACHINES
* - Review an iteration-based approach
* - Deterministic vs non-deterministic finite machines
* - What's up with that infinite loop?
*/
using System;
using System.Collections.Generic;
@gregmajor
gregmajor / CombinationLockIterationStateMachine.cs
Created August 25, 2012 19:57
Combination Lock using the Iteration State Machine
/*
* REVISITING THE COMBINATION LOCK
* - We can make our machine non-deterministic
*/
using System;
using System.Collections.Generic;
class Program
{
@gregmajor
gregmajor / StatePatternExample.cs
Created August 25, 2012 19:58
State Pattern Example
/*
* THE STATE PATTERN
* - Allows an object to alter its behavior when its internal state changes
* - The object "transforms" and appears to be completely different
*/
using System;
class Program
{
@gregmajor
gregmajor / DogStatePatternExample.cs
Created August 25, 2012 19:59
Dog State Pattern Example
/*
* HERE BOY!
* - Notice how behavior changes based on state.
*/
using System;
class Program
{
static void Main(string[] args)
@gregmajor
gregmajor / StateVsStrategy.cs
Created August 25, 2012 19:59
State vs Strategy
/*
* STATE VS STRATEGY
* - Strategy lets the algorithm vary independently from clients that use it
* - The difference is internal vs external
*/
using System;
class Program
{
@gregmajor
gregmajor / StateDerivedStatus.cs
Created August 25, 2012 20:00
State Derived Status
/*
* STATE DERIVED STATUS
* - What is status?
*/
using System;
class Program
{
static void Main(string[] args)
@gregmajor
gregmajor / get-fileversion.ps1
Last active August 29, 2015 14:18
Get File Versions with Powershell
# Credit to https://jtruher3.wordpress.com/2006/05/14/powershell-and-file-version-information/
param ( [string[]]$paths )
begin {
# I want to do some stuff with relative paths.
# create a variable that I can use later
$P = [string](get-location)
# the workhorse of the script
function GetVersionInfo
@gregmajor
gregmajor / keybase.md
Created April 19, 2015 04:15
Keybase Proof

Keybase proof

I hereby claim:

  • I am gregmajor on github.
  • I am gregmajor (https://keybase.io/gregmajor) on keybase.
  • I have a public key whose fingerprint is 9C47 D565 A9F4 BBE7 EB19 CFB2 B7D1 F23A 5405 60EF

To claim this, I am signing this object:

@gregmajor
gregmajor / boxstarter.ps1
Last active August 2, 2017 16:12
Boxstarter Script
# http://boxstarter.org/Learn/WebLauncher
# To use, run this command and fill in the RAW_FILE_URL
# Install-BoxstarterPackage -PackageName RAW_FILE_URL -DisableReboots
# See http://boxstarter.org/WinConfig for all the Boxstarter extras
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
Enable-RemoteDesktop
Install-WindowsUpdate
Disable-InternetExplorerESC