Skip to content

Instantly share code, notes, and snippets.

View BlakeWilliams's full-sized avatar
💭
building things, probably

Blake Williams BlakeWilliams

💭
building things, probably
View GitHub Profile
@BlakeWilliams
BlakeWilliams / gist:1046029
Created June 25, 2011 02:16
XKCD Downloader
require 'httparty'
1.upto(916) {|x| File.open('./xkcd2/'+x.to_s+'.jpg','w') {|f| f.write(HTTParty.get('http://imgs.xkcd.com/comics/' + HTTParty.get('http://xkcd.com/'+x.to_s).body.match(/(?<=src\="http:\/\/imgs\.xkcd\.com\/comics\/).*?(?=")/).to_s))}}
@BlakeWilliams
BlakeWilliams / inputdefault.coffee
Created August 9, 2011 00:35
Form Default Text in Coffeescript
jQuery ($) ->
jQuery.fn.defaultValue = (text) ->
this.each ->
return if this.value != "" or this.value == text
this.value = text
jQuery(this).toggleClass "inactive"
$(this).focus ->
if this.value == text or this.value == ""
this.value = ""
jQuery(this).toggleClass "inactive"
nav#top {
height: 38px;
width: 100%;
background: url(/assets/header.png);
border: 1px solid #000;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-bottom-radius: 5px;
ul {
height: 100%;
@mixin inheritance {
font-style: inherit;
line-height: inherit;
}
p {
font-size: $basefont -2;
font-weight: normal;
line-height: 18px;
margin-bottom: $baseline / 2;
small {
@BlakeWilliams
BlakeWilliams / brainfuck.clj
Created September 11, 2011 04:07
Brainfuck interpreter in clojure!
(ns brain.fuck
(:gen-class))
(def ptr (atom 0)) ; Initialize the pointer to 0
(def cells (atom (vec (repeat 30000 0)))) ; Plenty of room!
(defn start [place commands]
(loop [brackets 1]
(when-not (== brackets 0)
(swap! place inc)
@BlakeWilliams
BlakeWilliams / gist:1230575
Created September 20, 2011 22:13
Project Euler #1 in one line
(1..999).select { |x| (x % 3) == 0 || (x % 5) == 0 }.reduce(:+)
@BlakeWilliams
BlakeWilliams / install.sh
Created October 8, 2011 03:54
Installing Clojure via homebrew
brew update
brew install clojure
brew install leiningen
@BlakeWilliams
BlakeWilliams / clj
Created October 8, 2011 03:59
Modified CLJ script
#!/bin/sh
breakchars="(){}[],^%$#@\"\";:''|\\"
CLOJURE=$CLASSPATH:/usr/local/Cellar/clojure/1.3.0/clojure-1.3.0.jar:${PWD}
if [ "$#" -eq 0 ]; then
exec rlwrap --remember -c -b "$breakchars" \
java -cp $CLOJURE clojure.main --repl
else
java -cp $CLOJURE clojure.main "$@"
fi
@BlakeWilliams
BlakeWilliams / brainfuck.go
Created November 14, 2011 09:55
Brainfuck interpreter in Go
package main
import (
"strings"
"fmt"
)
var cells [30000]int
var commands []string
var ptr = 0
var pos = 0
// Replace lines 119 and 120 in Game.java with the following code
// Also import java.io.File
screen = new Screen(WIDTH, HEIGHT, new SpriteSheet(ImageIO.read(new File("res/icons.png"))));
lightScreen = new Screen(WIDTH, HEIGHT, new SpriteSheet(ImageIO.read((new File("res/icons.png")))));