Skip to content

Instantly share code, notes, and snippets.

@Ch00by
Ch00by / autocomplete.coffee
Created October 15, 2011 16:47
Rails + Coffee + Mongoid + jQuery UI Autocomplete
$ ->
autocomplete_cache = {}
lastXhr = ''
$("#tags").autocomplete({
minLength: 2,
source: (req, res) ->
console.log autocomplete_cache
term = req.term
if autocomplete_cache[term]?
@Ch00by
Ch00by / triangle.scss
Created August 16, 2011 15:32
Triangle Shape Mixin for Scss
@mixin triangle($direction-h, $direction-w, $color, $width, $height) {
width: 0;
height: 0;
@if $direction-h == top {
border-top: $height solid $color;
border-bottom: $height solid transparent;
} @else {
border-bottom: $height solid $color;
border-top: $height solid transparent;
}
@Ch00by
Ch00by / msgpack.coffee
Created August 16, 2011 01:42
alternative code
calc = (buf,idx,i) ->
if i != 2 then buf[idx++] * Number("0x1" + [1..i].map(j) -> "0") + calc(buf,idx, i - 2) else buf[idx++]
return num * 0x100000000000000 + calc(buf,idx,i)
## Original, lines 343 - 350 ##
return num * 0x100000000000000 +
buf[idx++] * 0x1000000000000 +
buf[idx++] * 0x10000000000 +
buf[idx++] * 0x100000000 +
buf[idx++] * 0x1000000 +