This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(dorun (apply map | |
(concat [(fn [n & fizzbuzz] (prn n (apply str fizzbuzz))) (range 1 101)] | |
(map #(replace {true %2 false nil} (map zero? (take 100 (next (cycle (range %)))))) [3 5] '[Fizz Buzz])))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; the binding macro ought to be handy for implementing something like fakeweb or timecop in Clojure | |
(def x 9) | |
(defn printx [] (println x)) | |
(printx) ; prints 9 | |
(binding [x 5] (printx)) ; prints 5 | |
(printx) ; prints 9 | |
(defn say-hi [] (println "Hi!")) | |
(defn say-hi-twice [] (dotimes [n 2] (say-hi))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prompts for a password five times, and starting with the second password, | |
# prints whether the each password matches the first password given. | |
require 'highline' | |
firstpass = nil | |
5.times do | |
pass = HighLine.new.ask('enter password: ') { |q| q.echo = false } | |
puts firstpass == pass if firstpass | |
firstpass ||= pass | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
digraph G { | |
brightkite [color=red] | |
twitter [color=red] | |
brightkite -> twitter -> friendfeed -> facebook; | |
brightkite -> flickr; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Simple Line Art</title> | |
<script type="text/javascript" src="jquery.js"></script> | |
<!--[if IE]><script type="text/javascript" src="excanvas.js"></script><![endif]--> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
canvas = document.getElementById("cv"); | |
ctx = canvas.getContext("2d"); | |
draw(ctx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn factor [n] | |
(let [max (int (/ n 2))] | |
(loop [x 2] | |
(if (zero? (rem n x)) | |
(conj (factor (/ n x)) x) | |
(if (< x max) | |
(recur (+ x 1)) | |
(if (= n 1) [] [n])))))) | |
(println (factor 5)) ; 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$(document).ready(function() { | |
// adds support for setting multiple css attributes with one call to css() | |
// Example: $('.foo').css('background', 'black', 'color', 'white') | |
$.fn.css_orig = $.fn.css; | |
$.fn.css = function() { | |
var sel = this; | |
if (arguments.length > 2) { | |
for (var i = 0; i < arguments.length; i += 2) { | |
sel = sel.css_orig(arguments[i], arguments[i + 1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
benatkin:oauth-python-twitter ben$ file ../../lib/python2.6/site-packages/easy-install.pth | |
../../lib/python2.6/site-packages/easy-install.pth: ASCII Java program text | |
benatkin:oauth-python-twitter ben$ cat ../../lib/python2.6/site-packages/easy-install.pth | |
import sys; sys.__plen = len(sys.path) | |
./setuptools-0.6c9-py2.6.egg | |
./twitter-1.2.1-py2.6.egg | |
./python_dateutil-1.4.1-py2.6.egg | |
./simplejson-2.0.9-py2.6-macosx-10.5-i386.egg | |
./oauth-1.0-py2.6.egg | |
./python_twitter-0.7_devel-py2.6.egg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
#require 'wirble' | |
#require 'pp' | |
#Wirble.init | |
#Wirble.colorize | |
alias q exit | |
class Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'diff/lcs' | |
def wordiff(w1, w2); Diff::LCS.diff(w1.split(//), w2.split(//)); end | |
def simple_diff(d); d.flatten.map {|c| "#{c.position}#{c.action}#{c.element}"}.join(' '); end | |
p simple_diff(wordiff('interesting', 'informative')) | |
# => "2-t 3-e 2+f 3+o 5-e 6-s 5+m 6+a 9-n 10-g 9+v 10+e" |