Skip to content

Instantly share code, notes, and snippets.

@jacobk
jacobk / process_tornado_bm.py
Created December 9, 2010 20:04
Simple script to process raw data from Tornado BM
#!/usr/bin/env python
# encoding: utf-8
#
# Requires statlib http://code.google.com/p/python-statlib/
"""
process_tornado_bm.py
Created by Jacob Kristhammar on 2010-12-09.
"""
$(function() {
$("div.content").live("showoff:show", function(evt) {
var bg_img = $("img[alt=background]", evt.target);
if (bg_img.size() > 0) {
var src = bg_img.attr("src");
bg_img.hide();
// Set new background on body
$("body").css("background", "url(" + src + ") no-repeat center center fixed")
.css("-webkit-background-size", "cover")
var hp = "<html xmlns=\x22http://www.w3.org/1999/xhtml\x22><head><link href=\x22css/style.css\x22 type=\x22text/css\x22 rel=\x22stylesheet\x22><link href=\x22css/fontstyle.css\x22 type=\x22text/css\x22 rel=\x22stylesheet\x22><title>Meny</title><meta name=\x22robots\x22 content=\x22index,follow\x22><meta name=\x22googlebot\x22 content=\x22index, follow\x22><meta http-equiv=\x22Content-Language\x22 content=\x22SE\x22><meta name=\x22description\x22 content=\x22\x22><meta name=\x22keywords\x22 content=\x22\x22><meta name=\x22distribution\x22 content=\x22Global\x22><meta name=\x22rating\x22 content=\x22general\x22><meta name=\x22copyright\x22 content=\x224D Profile\x22><meta name=\x22author\x22 content=\x22Marks & Bleeds\x22><script src=\x22jscripts/AC_RunActiveContent.js\x22 language=\x22javascript\x22></script><script type=\x22text/javascript\x22 src=\x22jscripts/prototype.js\x22></script><script type=\x22text/javascript\x22 src=\x22jscripts/scriptaculous.js?load=effects,builder\x22></script><script type=\x22tex
import random as r;_,N=range,1e6;l=_(13)*4
print sum([r.shuffle(l)or 0in[x-y for x,y in zip(l[1:],l)]for i in _(N)])/N
@jacobk
jacobk / old.coffee
Created October 31, 2011 19:59
Make sure people know who saw it first!
# Make sure people know who saw it first!
#
# TODO
# * Figure out how to properly check content (hash)
# - perhaps only usable for images
# * Make it possible to post link you know is old
# * List last links
# * List most posed links
# * Test if a link has been posted before
# Get money donated to musikhjälpen 2011
#
# show me the money - returns how much money that has been donated
#
module.exports = (robot) ->
robot.respond /(show me the money|mh)/i, (msg) ->
msg.http("http://sverigesradio.se/p3/musikhjalpen/xml/ticker.htm")
.get() (err, res, body) ->
if res.statusCode is 200
@jacobk
jacobk / panic.sh
Created March 11, 2012 18:52
Perform an exorcism and rid your systems of foul daemons...
#!/usr/bin/env bash
FORCE=false
while getopts f o; do
case $o in
f) FORCE=true;;
esac
done
# Flip things!!!
#
# flip <something> - Flips something
# flip <something>, <something else>, ... - Flips all the things
# FLIP!?|flip! <something> - Really flips something
module.exports = (robot) ->
robot.respond /FLIP( ME)? (.*)/, (msg) ->
msg.send flip_angry(msg.match[2])
# Metadata lookup for youtube links
#
# <youtube link> - returns info about the link
#
module.exports = (robot) ->
robot.hear youtube.link, (msg) ->
msg.http(youtube.uri msg.match[1]).get() (err, res, body) ->
if res.statusCode is 200
data = JSON.parse(body)
├ app/config.js
├ app/em.js
│ ├─ jquery
│ ├─ use!underscore
│ ├─ use!backbone
│ ├─ use!handlebars
│ └─ use!plugins/backbone.layoutmanager
├ app/main.js