Skip to content

Instantly share code, notes, and snippets.

View roryf's full-sized avatar

Rory Fitzpatrick roryf

  • Edinburgh, Scotland
View GitHub Profile
# clones foo.notes into bar.notes
foo.notes.each do |note|
new_note = bar.notes.build(note.attributes)
new_note.save
end
@roryf
roryf / DeliminatorSeparatedPropertyNamesContractResolver.cs
Created June 23, 2011 13:09
Snake case (underscore separated) property name resolver for Newtonsoft.Json library
public class DeliminatorSeparatedPropertyNamesContractResolver : DefaultContractResolver
{
private readonly string _separator;
protected DeliminatorSeparatedPropertyNamesContractResolver(char separator) : base(true)
{
_separator = separator.ToString();
}
protected override string ResolvePropertyName(string propertyName)
@roryf
roryf / ie8.txt
Created July 14, 2011 09:22
An IE8 user agent string, as seen in the wild
Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+5.1;+Trident/4.0;+FunWebProducts;+.NET+CLR+2.0.50727;+eSobiSubscriber+2.0.4.16;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729;+OfficeLiveConnector.1.3;+OfficeLivePatch.0.0)
@roryf
roryf / rewrite
Created July 15, 2011 12:55
Zeus rewrite rule from .html to .php
match URL into $ with ^(.*)\.html$
if matched then
set URL = $1.php
endif
@roryf
roryf / Flash.cs
Created July 27, 2011 15:19
Flash message implementation for ASP.NET MVC
public class Flash : DynamicObject
{
private readonly TempDataDictionary _store;
private const string KeyPrefix = "Flash";
public Flash(TempDataDictionary store)
{
_store = store;
}
@roryf
roryf / movie.pde
Created September 9, 2011 12:39
Processing code I used to generate http://vimeo.com/28706322
import org.json.*;
import java.net.*;
import java.util.Iterator;
import processing.video.*;
PImage bg;
MovieMaker mm;
JSONObject data;
double west = -3.414001;
@roryf
roryf / wireframe.mrules
Created September 9, 2011 12:50
Maperitive rules for creating white-on-black maps of primary roads
// Wireframe rules
// Created by Igor Brejc
// Edited by Rory Fitzpatrick
// Released under the Creative Commons Attribution-ShareAlike 3.0 License (http://creativecommons.org/licenses/by-sa/3.0/)
features
lines
line : highway=primary OR highway=tertiary OR highway=motorway OR highway=trunk OR highway=secondary
coastline : natural=coastline
import org.json.*;
import java.net.*;
import java.util.Iterator;
PImage bg;
JSONObject data;
double west = -3.414001;
double east = -3.017120;
@roryf
roryf / gist:1848769
Created February 16, 2012 23:33
brew install git
==> Downloading http://git-core.googlecode.com/files/git-1.7.9.1.tar.gz
File already downloaded in /Users/rory/Library/Caches/Homebrew
/usr/bin/tar xf /Users/rory/Library/Caches/Homebrew/git-1.7.9.1.tar.gz
==> make prefix=/usr/local/Cellar/git/1.7.9.1 CC=/Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc CFLAGS=-Os -w -pipe -march=core2 -msse4.1 LDFLAGS= install
make prefix=/usr/local/Cellar/git/1.7.9.1 CC=/Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc CFLAGS=-Os -w -pipe -march=core2 -msse4.1 LDFLAGS= install
GIT_VERSION = 1.7.9.1
* new build flags or prefix
* new link flags
./generate-cmdlist.sh > common-cmds.h+ && mv common-cmds.h+ common-cmds.h
/Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc -o hex.o -c -MF ./.depend/hex.o.d -MMD -MP -Os -w -pipe -march=core2 -msse4.1 -I. -DUSE_ST_TIMESPEC -DNO_GETTEXT -DHAVE_DEV_TTY -DSHA1_HEADER='<openssl/sha.h>' -DNO_MEMMEM hex.c
@roryf
roryf / gist:2214167
Created March 27, 2012 09:00
Umbraco SQL query for AncestorContentOrSelf
SELECT this_.Id as Id16_9_,
this_.DateCreated as DateCrea2_16_9_,
this_.DefaultName as DefaultN3_16_9_,
this_.AttributeSchemaDefinition_id as Attribut4_16_9_,
this_.NodeId as NodeId16_9_,
attribalia3_.NodeVersionId as NodeVers3_11_,
attribalia3_.Id as Id11_,
attribalia3_.Id as Id5_0_,
attribalia3_.AttributeDefinitionId as Attribut2_5_0_,
attribalia3_.NodeVersionId as NodeVers3_5_0_,