Skip to content

Instantly share code, notes, and snippets.

(defun unmantle-next-parens () (interactive)
(skip-syntax-spec-forward "^(")
(save-excursion (goto-matched-parenthesis) (delete-char))
(delete-char)
(unless (eolp) (insert " ")))
// 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 / nullobject.wsh.js
Created May 9, 2011 14:52
`Object.create(null)` for JScript
// `Object.create(null)` for JScript.
// Based on @bga_'s SafeJS.
NullObject = (function(){
var doc = new ActiveXObject('htmlfile')
doc.write('<script><\/script>')
doc.close()
var Obj = doc.parentWindow.Object
if(!Obj || Obj === Object) return
var name, names =
[ 'constructor', 'hasOwnProperty', 'isPrototypeOf'
@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'
@satyr
satyr / tv_yahoo_adjuster.user.js
Created April 10, 2011 06:18
document.querySelector('.internalBlock').scrollIntoView()
// ==UserScript==
// @name tv.yahoo adjuster
// @namespace http://satyr.github.com
// @include http://tv.yahoo.co.jp/listings/*
// ==/UserScript==
setTimeout(function(){
document.querySelector('.internalBlock').scrollIntoView()
})
#!coco
require(\http)createServer (req, res) ->
res.end JSON.stringify req.headers, 0 1
.listen 80
@satyr
satyr / kc2ks.co
Created March 7, 2011 15:09
keyconfig to KeySnail
#!coco
`#!node`
PREFIX = \keyconfig.main.xxx_key__
user_pref = (name, pref) ->
return if name.lastIndexOf PREFIX, 0
[mods, k, vk, code, win] = pref.split \][
return if mods is \! or not code
switch win
case '' then type = \Global
case \chrome://browser/content/browser.xul then type = \View

"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