Skip to content

Instantly share code, notes, and snippets.

View jasonporritt's full-sized avatar

Jason Porritt jasonporritt

View GitHub Profile
PS1d1='$( ret=$? ; dol="\$ \[\e[0m\]" ; test $ret -gt 0 && dol="\[\e[1;91m\]\$ \[\e[0m\]" ; echo $dol)'
PS1='[\u@\h \[\033[01;34m\]\W\[\033[00m\]]'$PS1d1
set guifont=Monospace\ 10
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set shiftround " Shift to the next round tab stop
set wrap
set linebreak
set autoindent
" local syntax file - set colors on a per-machine basis:
" vim: tw=0 ts=4 sw=4
" Vim color file
" Maintainer: Jason Porritt
" Last Change: Jan. 24, 2008
hi clear
set background=dark
if exists("syntax_on")
syntax reset
@jasonporritt
jasonporritt / gist:676364
Created November 15, 2010 02:56
File upload testing
[When("I choose a photo to upload")]
public void UploadImageFor()
{
// Where Browser is your current Browser object
var fileUpload = Browser.FileUpload(x => x.Name == "Photo");
var assembly = Assembly.GetExecutingAssembly();
var fileStream = assembly.GetManifestResourceStream(assembly.GetName().Name + ".TestData.image.jpg");
var fileData = new byte[fileStream.Length];
fileStream.Read(fileData, 0, fileData.Length);
@jasonporritt
jasonporritt / naive_todos.coffee
Created May 6, 2011 12:31
Naive translation of Backbone.js example app
initialize: ->
_.bindAll(this, 'render', 'close')
this.model.bind('change', this.render)
this.model.view = this
render: ->
$(this.el).html(this.template(this.model.toJSON()))
this.setContent()
return this
@jasonporritt
jasonporritt / better_todos.coffee
Created May 6, 2011 12:32
Use the fat arrow -- translation of Backbone.js example app
initialize: ->
this.model.bind('change', this.render)
this.model.view = this
render: =>
$(this.el).html(this.template(this.model.toJSON()))
this.setContent()
return this
@jasonporritt
jasonporritt / best_todos.coffee
Created May 6, 2011 12:33
Use @vars -- translation of Backbone.js example app
initialize: ->
@model.bind('change', this.render)
@model.view = this
render: =>
$(@el).html(this.template(@model.toJSON()))
this.setContent()
return this
@jasonporritt
jasonporritt / backbone_class.coffee
Created May 6, 2011 20:45
Backbone class declaration
window.TodoView = Backbone.View.extend
tagName: "li"
template: _.template($('#item-template').html())
events:
"click .check" : "toggleDone",
"dblclick div.todo-content" : "edit",
"click span.todo-destroy" : "clear",
"keypress .todo-input" : "updateOnEnter"
@jasonporritt
jasonporritt / coffeescript_subclass.coffee
Created May 6, 2011 20:46
CoffeeScript declaration of Backbone.View subclass
class window.TodoView extends Backbone.View
tagName: "li"
template: _.template($('#item-template').html())
events:
"click .check" : "toggleDone"
"dblclick div.todo-content" : "edit"
"click span.todo-destroy" : "clear"
"keypress .todo-input" : "updateOnEnter"
@jasonporritt
jasonporritt / FirstOr404.cs
Created August 26, 2011 11:11
First or 404
using System.Linq;
public static class EnumerableUtils {
// First item, or throw 404 exception
public static TSource FirstOr404<TSource>(this IEnumerable<TSource> source)
{
try
{
return source.First();