This file contains hidden or 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
# Find element's top-left position, cross-browser | |
# via http://www.kirupa.com/html5/get_element_position_using_javascript.htm | |
topLeft = (e)-> | |
x = y = 0 | |
This file contains hidden or 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! VimColorTest(outfile, fgend, bgend) | |
let result = [] | |
for fg in range(a:fgend) | |
for bg in range(a:bgend) | |
let kw = printf('%-7s', printf('c_%d_%d', fg, bg)) | |
let h = printf('hi %s ctermfg=%d ctermbg=%d', kw, fg, bg) | |
let s = printf('syn keyword %s %s', kw, kw) | |
call add(result, printf('%-32s | %s', h, s)) | |
endfor | |
endfor |
This file contains hidden or 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
# | |
# Visualize random data on a canvas element | |
# | |
$ -> | |
canvas = $ "#canvas" | |
ctxt = canvas[0].getContext "2d" |
This file contains hidden or 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
# Random hex color value in CoffeeScript | |
randomHexColor = (len=3)-> | |
pattern = '0123456789ABCDEF'.split '' | |
str = '#' | |
for i in [1..len] | |
str += pattern[Math.round(Math.random() * pattern.length)] |
This file contains hidden or 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
$ -> | |
$.ajax | |
url : 'path/file.xml' | |
dataType : 'xml' | |
success : (doc)-> | |
$(doc).find('element').each -> | |
element = $ this |
This file contains hidden or 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
_bez1 = (pct)-> | |
Math.pow pct, 3 | |
_bez2 = (pct)-> | |
3 * Math.pow(pct, 2) * (1-pct) | |
_bez3 = (pct)-> | |
3 * pct * Math.pow (1-pct), 2 | |
_bez4 = (pct)-> |
This file contains hidden or 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
package main | |
import ( | |
"log" | |
"io" | |
"os" | |
"crypto/tls" | |
"strings" | |
"net" | |
"flag" |
This file contains hidden or 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
sort = (objs, attrs) -> | |
dojo.map( | |
(dojo.map objs, (obj) -> | |
arr = [obj] | |
dojo.forEach attrs, (attr) -> | |
arr.push obj.get(attr) | |
arr | |
).sort( | |
(attrsA, attrsB) -> | |
i = 1 |
This file contains hidden or 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
// | |
// Ex. sort on attrs = [ | |
// ["Name", "asc"], | |
// ["Description, "desc"] | |
// ] | |
// | |
// This is how we do just one column, | |
// | |
// function sortOn(objs, attr, order) { | |
// return objs.sort( |
This file contains hidden or 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
# | |
# Wide-open CORS config for nginx | |
# | |
location / { | |
if ($request_method = 'OPTIONS') { | |
add_header 'Access-Control-Allow-Origin' '*'; | |
# |