Skip to content

Instantly share code, notes, and snippets.

View sleepyfox's full-sized avatar
:shipit:

@sleepyfox sleepyfox

:shipit:
  • TypeError
  • The Midlands
View GitHub Profile
@sleepyfox
sleepyfox / fizzbuzz.coffee
Created December 26, 2011 15:33
Fizz Buzz implementation in Coffeescript
rules = [
{ divisor: 3, word: "fizz" }
{ divisor: 5, word: "buzz" }
]
fizzBuzz = (n) ->
say = ""
say += i.word for i in rules when n % i.divisor is 0
say || n
@sleepyfox
sleepyfox / example-code.java
Created February 19, 2012 11:44
Some Java code for Code Dojo 4
// This file contains 3 lines of code
public interface Dave {
/**
* count the number of lines in a file
*/
int countLines(File inFile); // not the real signature!
}
@sleepyfox
sleepyfox / example-code2.java
Created February 19, 2012 11:46
Some more complex Java code for Code Dojo 4
/*****
* This is a test program with 5 lines of code
* \/* no nesting allowed!
//*****//***/// Slightly pathological comment ending...
public class Hello {
public static final void main(String [] args) { // gotta love Java
// Say hello
System./*wait*/out./*for*/println/*it*/("Hello/*");
}
@sleepyfox
sleepyfox / gist:1879125
Created February 21, 2012 21:37
Deck of cards - hand of 5 random cards sorted by Black->Red, Spades->Clubs, Diamonds->Hearts, A high
suits = ["Hearts", "Diamonds", "Clubs", "Spades"]
cards = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]
class Card
constructor: (value, suit) ->
@suit ?= suits[random(4)]
@value ?= cards[random(13)]
toString: ->
"#{@value} of #{@suit}"
@sleepyfox
sleepyfox / nested-comprehension.coffee
Created February 21, 2012 23:37
Nested array comprehension in CoffeeScript
cards = ["2", "3", "4"] # etc...
suits = ["hearts", "spades"] # etc...
array = (a+b for a in cards for b in suits)
alert array
@sleepyfox
sleepyfox / webdriver-test.py
Created May 16, 2012 10:10
Simple Selenium example in Python
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
import time
# Create a new instance of the Firefox driver
driver = webdriver.Firefox()
# go to the google home page
driver.get("http://www.google.com")
@sleepyfox
sleepyfox / dropbox
Created June 11, 2012 15:12
Ubuntu Linux init.d startup script for DropBox
#!/bin/sh
#dropbox service
DROPBOX_USERS="user1 user2"
DAEMON=.dropbox-dist/dropbox
start() {
echo "Starting dropbox..."
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
@sleepyfox
sleepyfox / gist:5578023
Created May 14, 2013 17:54
Ruby day 3 code
rubycsv.txt
===
first, last, country
Yukihiro, Matsumoto, Japan
Bruce, Tate, USA
animals.txt
===
one, two
lions, tigers
@sleepyfox
sleepyfox / invisible-deficit.txt
Created July 31, 2013 11:40
Explanation of the invisible deficit
The term 'invisible deficit' comes from the introduction to Taylor's
"Principles of Scientific Management":
"We can see and feel the waste of material things. Awkward, inefficient, or
ill-directed movements of men, however, leave nothing visible or tangible
behind them. Their appreciation calls for an act of memory, an effort of the
imagination. And for this reason, even though our daily loss from this source
is greater than from our waste of material things, the one has stirred us
deeply, while the other has moved us but little."
@sleepyfox
sleepyfox / human-capabilities
Last active December 21, 2015 15:29
What should a human be able to do?
"A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet,
balance accounts, build a wall, set a bone, comfort the dying,
take orders, give orders, cooperate, act alone, solve equations,
analyze a new problem, pitch manure, program a computer, cook a tasty meal,
fight efficiently, die gallantly. Specialization is for insects."
-- Robert Heinlein, 'Time Enough for Love', 1973.