Skip to content

Instantly share code, notes, and snippets.

View robotlolita's full-sized avatar
🐴
everything happens so much oh no

Quil robotlolita

🐴
everything happens so much oh no
View GitHub Profile
@robotlolita
robotlolita / gist:823778
Created February 12, 2011 13:49
Current syntax for Elegance...
uses html ;; imports html tags
define text-processor "markdown" ;; filters all text literals through markdown
;; Defines some abstract blocks for DRY
block site-header
title "Elegance"
subtitle "makes writing webpages less painful"
when rendered
var multiline_str = "some \
string \
spanning \
across \
lots \
of \
lines"
var multiline_str2 = "some "
+ "string "
do slow_loop = ->
(setTimeout slow_loop, 1000)
do ->
(setTimeout arguments.callee, 1000)
do slow_loop = ->
setTimeout slow_loop, 500 unless confirm 'Stop looping?'
#
# Is compiled to
# \/
`
(function() {
var slow_loop;
listener ((x) -> (do_stuff x))
, ((y) -> (do_stuff y))
, ((z) -> (do_stuff z))
function try_me (str) {
switch (str) {
case "foo": console.log("buu~"); break
case "bar": console.log("baz~"); break
default: console.log("bad, bad argument, no cookies for you.") }
}
try_me("foo") // "buu~"
try_me("bar") // "baz~"
try_me("nou") // "bad, bad argument, no cookies for you."
# Pair stepper generator
(defun pair_stepper: (seq) ->
(letb (slen = (len seq)) ->
(stepper seq, (idx) ->
(if idx + 1 >= slen
((list idx, $break))
else
(list idx + 1, (nth idx, seq, 2))))))
stuff = ->
## I instinctively skip those when I'm reading the code
surround_left = -> .59 * surround + .525 * (1 - surround)
surround_right = -> .69 * (surround - 1) + .59 * (2 - surround)
## And go straight here
c = if surround < 1 then surround_left else surround_right
###############################################################################
# Compares a list using the given function. #
# #
# This is a general comparison function, that takes a sequence as the first #
# argument and a function as the second. #
# #
# The sequence is iterated using `all`. For each pair of items in the #
# sequence the callback function is called and expected to return whether the #
# comparison for the given pair succeeds or fails. #
# #
$ emacs24
Warning: arch-dependent data dir (/usr/local/libexec/emacs/24.0.50/i686-pc-linux-gnu/) does not exist.
Warning: Lisp directory `/usr/local/share/emacs/24.0.50/site-lisp' does not exist.
Warning: Lisp directory `/usr/local/share/emacs/24.0.50/lisp' does not exist.
Warning: Lisp directory `/usr/local/share/emacs/24.0.50/leim' does not exist.
Warning: Could not find simple.el nor simple.elc