Skip to content

Instantly share code, notes, and snippets.

@aedoran
aedoran / gist:2512048
Created April 27, 2012 19:25
node redis example
for (var i in people) {
var id = i;
client.hmset(id,people[i],function() {});
client.sadd("proc", id);
}
client.multi()
.smembers("proc", function(err,res) {
_.each(res, function(r) {
client.hgetall(r,function(err,res) {
@aedoran
aedoran / gist:2846406
Created May 31, 2012 21:23
linear hotness
article = {
meta : {
white_click_count : 38,
unknown_click_count : 399,
white_saved_count : 299
}
};
//weights from 0 to 1 of how important the attribute is
//sum of weights should add to 1
@aedoran
aedoran / gist:2870581
Created June 4, 2012 20:10
normally distribute data nd split them into 0-100 buckets
var data = [2,3,4,5,3,2,3,4,5,6,9,9,100,-100];
var avg = 0;
data.forEach(function(a) {
avg+= a;
});
avg = avg / data.length;
console.log("avg",avg);
@aedoran
aedoran / gist:2875932
Created June 5, 2012 16:00
normal distribution thrown into scores from 0 - 100
var scores = [0,2,3,2,24,24,2,2];
//get the mean
var avg = 0;
scores.forEach(function(a) {
avg+= a;
});
avg = avg / scores.length;
@aedoran
aedoran / test.js
Created September 24, 2012 22:43
zombie concurrency test script
var Browser = require("zombie"),
program = require("commander");
program
.version('0.0.1')
.option('-l, --location <string>', 'location:port')
.option('-u, --username <string>', 'username')
.option('-p, --password <string>', 'password')
.option('-c, --concurrencies <integer>', 'number of browsers you want')
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v2.min.js?2.9.7"></script>
<script>
var width = 960,
height = 500;
var nodes = d3.range(200).map(function() { return {radius: Math.random() * 12 + 4}; }),
@aedoran
aedoran / index.html
Created October 8, 2012 16:03
Experminents with squiggles
<!DOCTYPE html>
<head>
<style>
@font-face {
font-family: 'xkcd';
src: url('http://dl.dropbox.com/u/12305244/Humor-Sans.ttf');
}
body {
font-size: 14px;
@aedoran
aedoran / index.html
Created October 22, 2012 19:47
Diff square tree
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<style>
path {
stroke-width:1px;
fill:red;
stroke:red;
}
@aedoran
aedoran / Idone this git commit message hook
Created March 29, 2013 04:03
git commit hook for use with idone this this command line client. Just copy this in your .git/hooks/commit-msg. and whenever your commit message has an "IDT" in it, it will send the message to your idonethis account
idt=$(grep IDT $1)
msg=$(cat $1)
if [ -z "$idt" ]; then
echo "not for idonethis"
else
idone "$msg"
fi
@aedoran
aedoran / impeach.csv
Last active November 12, 2016 04:28
impeach who?
Month obama impeach trump impeach
2008-10 14 14
2008-11 82 0
2008-12 21 0
2009-01 21 0
2009-02 21 0
2009-03 31 0
2009-04 13 0
2009-05 25 0
2009-06 13 0