Skip to content

Instantly share code, notes, and snippets.

View spearson's full-sized avatar
🎯
Focusing

Sam Pearson spearson

🎯
Focusing
View GitHub Profile
namespace xofz.Root.Commands
{
using System;
using System.Threading;
using xofz.Framework;
public class SampleActionActionCommand
: Command
{
public SampleActionActionCommand(
@spearson
spearson / string-asurl.st
Created March 15, 2011 09:37
convert a string to a URL
String>>asUrl
^ String streamContents: [ :stream |
self do: [ :char |
char isSeparator ifTrue: [ stream nextPut: $- ].
char isAlphaNumeric ifTrue: [ stream nextPut: char asLowercase ] ] ]
@spearson
spearson / new-cookies.js
Created March 3, 2011 01:56
refactoring of w3schools cookie functions ( http://www.w3schools.com/js/js_cookies.asp )
function cookieValueFor(cookieName)
{
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++)
{
var currentCookie = cookies[i];
var currentCookieName = currentCookie.substr(0 , currentCookie.indexOf("=")).replace(/^\s+|\s+$/g,"");
if (currentCookieName == cookieName)
@spearson
spearson / SetCookie
Created March 3, 2011 01:55
refactoring of w3schools functions
function getCookie(nameOfCookieToGet)
{
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++)
{
var currentCookie = cookies[i];
var currentCookieName = currentCookie.substr(0 , currentCookie.indexOf("=")).replace(/^\s+|\s+$/g,"");
if (currentCookieName == nameOfCookieToGet)
var quotes = [
"A deadline a day keeps the programmers at bay."
, "The horn on the bus goes beep beep beep."
, "Words are filthy."
, "Silly hats only."
, "This is a quote."
, "Meow do you know how fast you were going?"
];
function changeQuote() {
var quotes = new Array();
quotes[0]="A good one man";
quotes[1]="Different stuffz";
quotes[2]="1119999";
quotes[3]="ALL CAPS IS FREE";
quotes[4]="no reali";
quotes[5]="KeKBeePrz";
function changeQuote() {
var newQuote = quotes[Math.round(Math.random() * quotes.length - 1)];
@spearson
spearson / RedundantFactories.cs
Created October 15, 2010 23:26
Use one implementation for all those pointless factories!
namespace xofz.Playground.Tests
{
using System;
using Xunit;
public class RedundantFactories
{
[Fact]
public void Are_used_like_this()
{