Skip to content

Instantly share code, notes, and snippets.

@DveMac
DveMac / Lion class
Created April 3, 2011 17:18
base class
class Lion extends Animal
eat: (food, cb)->
cb()
@DveMac
DveMac / gist:902185
Created April 4, 2011 18:57
timeouttest
sys = require 'sys'
class timeouttest
_interval = null
constructor: () ->
@callback()
@_interval = setInterval @callback, 2000
#@_interval = setInterval (=>@callback), 2000
@DveMac
DveMac / gist:939895
Created April 24, 2011 21:30
regex loop
result = []
while m = imagesPattern.exec(bod)
result.push(m[1])
ds = {}
ds['pet'] = 'dog'
ds['food'] = 'meat'
ds2 = {
'pet':'dog',
'food':'meat'
}
result = {}
replies.forEach (k) ->
client.hgetall k, (err, obj) ->
console.dir obj
result[obj.ref] = obj
#wait until done...
cb(null, result)
var result;
result = {};
client.keys('article:*', function(err, replies) {
replies.forEach(function(k) {
client.hgetall(k, function(err, obj) {
result[obj.ref] = obj;
});
});
});
@DveMac
DveMac / hack.sh
Created March 31, 2012 17:57 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@DveMac
DveMac / 2.js
Created April 10, 2012 15:40 — forked from mxriverlynn/1.js
template cache
TemplateCache = {
get: function(selector){
if (!this.templates){ this.templates = {}; }
var template = this.templates[selector];
if (!template){
template = $(selector).html();
// precompile the template, for underscore.js templates
template = _.template(template);
@DveMac
DveMac / CS
Created April 27, 2012 14:40
JS
class Str
constructor: (@str) ->
@DveMac
DveMac / gist:2575308
Created May 2, 2012 08:58
Chrome table-layout rendering
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">