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
--- text.c 2012-02-28 21:29:19.000000000 +0700 | |
+++ text.bak.c 2012-02-28 20:51:03.000000000 +0700 | |
@@ -745,12 +745,10 @@ | |
q0++; | |
textshow(t, q0, q0, TRUE); | |
return; | |
- case 0x03: /* ^C: copy FIX */ | |
case Kcmd+'c': /* %C: copy */ | |
typecommit(t); | |
cut(t, t, nil, TRUE, FALSE, nil, 0); |
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
# Amb was first proposed by John McCarthy, the inventor of LISP, in 1963. | |
show = console.log | |
copy = (array) -> array.slice() | |
pick = (v) -> v[Math.floor Math.random() * v.length] | |
remove = (array, value) -> array.filter (v,i,o) -> v isnt value | |
fail = -> throw fail |
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 'underscore' | |
cs = require('coffee-script').CoffeeScript | |
fs = require 'fs' | |
read = (f) -> if fs.statSync(f).isFile() then fs.readFileSync f, 'utf8' | |
tokens = cs.tokens read _.last process.argv | |
ids = _.uniq (token[1] for token in tokens when token[0] is 'IDENTIFIER') | |
console.log 'Identifiers that contain non-ASCII characters:' | |
console.log (id for id in ids when id.match /[^\w]/) |
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
show = console.log | |
Y = (f) -> ((g) -> g g) (h) -> (args...) -> f(h(h)) args... | |
factorial = Y (recurse) -> (x) -> if x is 0 then 1 else x * recurse x-1 | |
show factorial 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
Sam command helpers for acme-sac to avoid some manual | |
editing when converting Python to CoffeeScript. | |
Imperfect and incomplete, check manually after use. | |
1. Reduce indentation to half (4->2) | |
2. Remove colons at the end of common statements | |
3. Rename elif to else if | |
4. Change function definitions to arrow declarations | |
5. Change python ranges to array ranges |
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
# How do you add 's' to a word when there is more than one of something? | |
# It is often seen in JavaScript to use the ternary operator but that is coding | |
# like it was PHP at the expense of future maintenance and internationalization. | |
# Only case 2 handles negative numbers. | |
show = console.log # console.debug # alert | |
test = (points) -> |
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
# Template for CoffeeKup HTML5 document with canvas | |
kup = require 'coffeekup' | |
webpage = kup.render -> | |
doctype 5 | |
html -> | |
head -> | |
meta charset: 'utf-8' | |
title 'WEBPAGE' | |
style ''' |
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
# CoffeeScript samples for Functional from Oliver Steele | |
# ------------------------------------------------------------------- | |
# Documentation: http://osteele.com/sources/javascript/functional/ | |
# Repository: https://github.com/osteele/functional-javascript | |
# ------------------------------------------------------------------- | |
# Directly import the Functional library since it is not CommonJS enabled |
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
#!/usr/local/bin/node /Users/eh/bin/coffee | |
# Adjust according to install and chmod +x script | |
# Compatibility with both node.js and browsers | |
show = if exports? then console.log else alert | |
# Step-by-step derivation of a short version of | |
# partial function application with free vars. | |
# Inspired by http://blog.mirotin.net/tag/coffeescript |