Skip to content

Instantly share code, notes, and snippets.

@jrmoran
jrmoran / mongo_wrapper.coffee
Created October 28, 2011 22:38
little mongo wrapper for node.js
mongodb = require 'mongodb'
db = {}
options = {}
check_for_errors = (err)->
if err then console.log "#{err}"
# configurate and connect to the database, `options` must be an object
# literal
#
@jrmoran
jrmoran / roll.js
Created November 4, 2011 00:09
Roll
(function(){
var styleObj=document.createElement("style");
styleObj.setAttribute("type","text/css");
document.getElementsByTagName("head")[0].appendChild(styleObj);
var style = "@-webkit-keyframes roll { from { -webkit-transform: rotate(0deg) } to { -webkit-transform: rotate(360deg) } } @-moz-keyframes roll { from { -moz-transform: rotate(0deg) } to { -moz-transform: rotate(360deg) } } @keyframes roll { from { transform: rotate(0deg) } to { transform: rotate(360deg) } } body { -moz-animation-name: roll; -moz-animation-duration: 4s; -moz-animation-iteration-count: 1; -webkit-animation-name: roll; -webkit-animation-duration: 4s; -webkit-animation-iteration-count: 1; }";
styleObj.appendChild(document.createTextNode(style));
}());
@jrmoran
jrmoran / radios.js
Created November 11, 2011 22:06
adding radios elements
// This takes ~35ms
console.time('Virguilla radios');
for(var x=0; x<500; x++){
var radios=document.createElement("input");
radios.type = "radio";
radios.id = "nombreRadio"; // NOOOOOOOOOOO!
radios.name = "nombreRadio";
radios.value = x;
document.getElementById("test-form").appendChild(radios); // NOOOO!
@jrmoran
jrmoran / privileged_methods.coffee
Created November 21, 2011 01:34
Privileged methods CoffeeScript
class Person
constructor: (name)->
@name = name
# private method
greet_p = (person = {}) ->
msg = if person.hasOwnProperty 'name'
"Hi #{person.name}"
else
@jrmoran
jrmoran / Custom.css
Created November 24, 2011 06:01 — forked from star-szr/Custom.css
IR_Black Theme (with sidebar and view-source colors) for Chrome Developer Tools
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@jrmoran
jrmoran / annotations.sass
Created November 26, 2011 04:56
Annotation Maker
@import compass/css3, compass/utilities
#annotation-tooltip
border: 2px solid #999999
display: none
font-size: 11px
left: 160px
padding: 10px
position: absolute
text-align: center
@jrmoran
jrmoran / assets.yml
Created December 7, 2011 07:10
minify js and css files
# These files will be minified ...
javascripts:
- build/js/ga.js
- build/js/jquery-1.7.1.js
- build/js/portfolio.js
styles:
- build/style/screen_v3.css
# And combined into single files
@jrmoran
jrmoran / truthy.js
Created December 9, 2011 03:48
Weird JS
p = console.log;
// # objects are truthy
var b = new Boolean(); // Never use the Boolean constructor
p( b.toString() ); // 'false'
p( b == false ); // true, use strict equality comparison with ===
p( b === false ); // false
p( b ? 'yeah' : 'nope' ); // yeah
@jrmoran
jrmoran / standard_deviation.py
Created December 18, 2011 02:20
standard deviation
def std(nums): return math.sqrt(sum([pow(n - sum(nums)/len(nums),2) for n in nums])/len(nums))
@jrmoran
jrmoran / buzzify.clj
Created December 18, 2011 10:16
fizzbuzz
(defn buzziffy [a b x]
(cond (and (zero? (mod x a)) (zero? (mod x b))) "FizzBuzz"
(zero? (mod x a)) "Fizz"
(zero? (mod x b)) "Buzz"
:else x))
(println (apply str (map #(str (buzziffy 3 5 %) "\n")
(range 1 100))))