Skip to content

Instantly share code, notes, and snippets.

@satyr
satyr / gist:1080268
Created July 13, 2011 13:11 — forked from zakki/gist:1080130
FizzBuzz Scala 70B
for(n<-0 to 99)println(Seq(n+1,"Buzz","Fizz","FizzBuzz")(n%3&2|n%5/4))
@satyr
satyr / README.md
Created May 20, 2011 17:37 — forked from yuya-takeyama/README.md
quick sleep sort

quick sleep sort

example usage:

$ coffee quicksleepsort.coffee 3701 45 292 9 324 45 23 123 1343
9
23

45

// Coco compiler wrapper for WSH
// (must be placed in the same directory as coco.js)
// Usage: cscript cowsh.js [--watch] file
// inspired by http://kennyj-jp.blogspot.com/2011/01/coffeescriptwindows.html
var fs = WScript.CreateObject("Scripting.FileSystemObject");
var scriptPath = WScript.ScriptFullName.slice(
0, -WScript.ScriptName.length);
var Coco = new new Function(
fs.OpenTextFile(scriptPath + "coco.js", 1).ReadAll()
@satyr
satyr / fib.coffee
Created April 30, 2011 14:04 — forked from hakobe/fib.coffee
crypto = require 'crypto'
key = (values) ->
crypto.createHash('sha1').update(values.join '-').digest 'hex'
memoize = (f, memo = {}) ->
-> memo[key [this, arguments...]] ||= f.apply this, arguments
fib = memoize (n) -> if n < 2 then n else fib(n-1) + fib(n-2)
@satyr
satyr / state-monad.co
Created April 22, 2011 13:09 — forked from igstan/state-monad.coffee
State Monad in Co{co,ffeeScript}
push = (value) -> (stack) -> {value, stack: [value]concat stack}
pop = (stack) -> value: stack.0, stack: stack.slice 1
bind = (stackOperation, continuation) -> (stack) ->
result = stackOperation stack
continuation(result.value) result.stack
result = (value) -> (stack) -> {value, stack}
@satyr
satyr / sudoku.co
Created April 20, 2011 17:26 — forked from jonelf/gist:927782
# Sudoku solver in Coco based on the Python solution by Peter Norvig
# http://norvig.com/sudoku.html
# 2011-04-19 jonelf@gmail.com
# 2011-04-21 satyr
#
# Throughout this program we have:
# r is a row, e.g. 'A'
# c is a column, e.g. '3'
# s is a square, e.g. 'A3'
# d is a digit, e.g. '9'

"In our study of program design, we have seen that expert programmers control the complexity of their designs with the same general techniques used by designers of all complex systems. They combine primitive elements to form compound objects, they abstract compound objects to form higher-level building blocks, and they preserve modularity by adopting appropriate large-scale views of system structure. In illustrating these techniques, we have used Lisp as a language for describing processes and for constructing computational data objects and processes to model complex phenomena in the real world.

However, as we confront increasingly complex problems, we will find that Lisp, or indeed any fixed programming language, is not sufficient for our needs. *We must constantly turn

@satyr
satyr / update.coffee
Created December 30, 2010 00:44 — forked from cj/update.coffee
name= if previous_keys.length > 0
then "#{main_key}[#{_.implode('][', previous_keys)}][#{key}]"
else "#{main_key}[#{key}]"
function StickamLargeChat_old (id) {
var start = "<object width='820' height='490' codebase='http:\/\/fpdownload.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,0,0' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'>\n" +
"<embed src='http:\/\/player.stickam.com\/flash\/stickam\/stickam_player.swf?app=stickam_chat_open.swf&userID=";
var end="' width='820' height='490' type='application/x-shockwave-flash' quality='high' allowscriptaccess='always' allowfullscreen='true' flashvars='webID=84634C6CDD408CA62D5DBD086DF5E196&webSeq=&userType=205&skinName=open&app=stickam_chat_open.swf&userIP=127.0.0.1&skinType=open&sessionType=115&userSiteID=1015547&autoplay=1&playerID=7334381&langID=en&'>\n" +
"<\/embed><\/object>";
return (start+id+end);
}
function StickamLargeChat(id){
var start = "<object width='320' height='240' codebase='http:\/\/fpdownload.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,0,0' classid='clsid:D27CDB6E-AE6D-11cf-96B8-4445535
@satyr
satyr / twitter-oauth-caution.user.css
Created June 2, 2010 04:29 — forked from mooz/twitter-oauth-caution.user.js
Twitter OAuth Caution (CSS only)
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document
url-prefix(https://twitter.com/oauth/authenticate?),
url-prefix(https://twitter.com/oauth/authorize?),
url-prefix(https://api.twitter.com/oauth/authenticate?),
url-prefix(https://api.twitter.com/oauth/authorize?),
url-prefix(http://twitter.com/oauth/authenticate?),
url-prefix(http://twitter.com/oauth/authorize?),
url-prefix(http://api.twitter.com/oauth/authenticate?),
url-prefix(http://api.twitter.com/oauth/authorize?) {