Skip to content

Instantly share code, notes, and snippets.

@thinkjson
thinkjson / gist:2874892
Created June 5, 2012 13:14
YouVersion Twitter search
YouVersion -bible.us -Download -finished -bit.ly -ow.ly -RT -App -read.ly -buff.ly -po.st -ping.fm
@thinkjson
thinkjson / dotjs.js
Created June 9, 2012 02:06
Visit http://www.dotjs.eu/ and run this in the JavaScript console :-)
function update(){vertices[0]=d3.mouse(this);svg.selectAll("path").data(d3.geom.voronoi(vertices).map(function(a){return"M"+a.join("L")+"Z"})).filter(function(a){return this.getAttribute("d")!=a}).attr("d",function(a){return a})}$(".page").remove();$(".header").remove();$(".footer").height(window.innerHeight).children().remove();var width=window.innerWidth,height=window.innerHeight;var vertices=d3.range(100).map(function(a){return[Math.random()*width,Math.random()*height]});var svg=d3.select(".footer").append("svg").attr("width",width).attr("height",height).attr("class","PiYG").on("mousemove",update);svg.selectAll("path").data(d3.geom.voronoi(vertices)).enter().append("path").attr("class",function(a,b){return b?"q"+b%9+"-9":null}).attr("d",function(a){return"M"+a.join("L")+"Z"});svg.selectAll("circle").data(vertices.slice(1)).enter().append("circle").attr("transform",function(a){return"translate("+a+")"}).attr("r",2)
@thinkjson
thinkjson / S3_regex.pl
Created June 11, 2012 15:50
Parse S3 log files using Perl regular expressions
#!/usr/bin/perl -w
use strict;
while (my $line=<>) {
my ($date, $host, $url_with_method, $status, $size, $referrer, $agent) = $line =~
m/^\S+\s+\S+\s+\[(\S+\s+[\-|\+]\d{4})\]\s+(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+"(\S+\s+\S+\s+[^"]+)"\s+(\d{3})\s+\S+\s+(\d+|-)\s+\d+\s+\d+\s+\d+\s+"(.*?)"\s+"(.*?)"/;
# Print relevant bits
}
@thinkjson
thinkjson / peiwei.js
Created June 22, 2012 15:12
Fix Pei Wei's web site
create a new bookmark, and use this for the url:
javascript:$("a").each(function(i, item) { if ($(item).attr('href')) $(item).attr({ href: $(item).attr('href').replace("javascript:location.href = 'http://' + hostname + '", "").replace("'","")}); });
@thinkjson
thinkjson / etc_hosts
Created August 1, 2012 03:46
I just made Facebook awesome
# Append this to your /etc/hosts
64.30.139.196 sphotos-a.xx.fbcdn.net
64.30.139.196 sphotos-b.xx.fbcdn.net
@thinkjson
thinkjson / bookmarklet.md
Created August 13, 2012 12:47
Visit Pandora.com and run this bookmarklet to select a random saved station

Create a new bookmark with this as the url:

javascript:stations=$(".stationNameText");stations[Math.floor(Math.random()*stations.length)].click();

@thinkjson
thinkjson / gist:3354182
Created August 15, 2012 00:20
Filter redbox list by rating (http://www.redbox.com/movies)
javascript:r=prompt("rating?");$(".box-wrapper").each(function(a,b){rb.api.product.getDetail(0+$(b).attr("key"),200,function(a){if(a.data.rating!=r){$(".box-wrapper[key='"+a.data.productRef+"']").remove()}else{console.log(a.data.name)}})})
@thinkjson
thinkjson / evolving_music.js
Created September 2, 2012 18:45
evolving music
var baudio = require('baudio');
var b = baudio();
b.push((function () {
// randomly evolving melody
var freqs = [
0, 0, 1600, 1600,
0, 0, 2000, 2000,
0, 1400, 0, 1400,
@thinkjson
thinkjson / mysql.php
Created September 10, 2012 12:22
Getting double the ammount I should on value $v
$new_array = array();
$ret_html = "<table><tr><th>DMA</th><th>Leads</th></tr>";
while ($row = mysql_fetch_array($result))
foreach ($row as $key => $value) {
if (isset($new_array["$value"]))
$new_array["$value"]++;
else
$new_array["$value"]++;
@thinkjson
thinkjson / checksum_per_line.py
Created October 25, 2012 12:43
Check for duplicate lines in a group of files
#!/usr/bin/python
# Invocation:
# cat [files] | python checksum_per_line.py | sort | uniq -c | sort -nr | awk '{ if ($1 > 1) print $0 }'
import sys
import hashlib
for line in sys.stdin:
print hashlib.md5(line).hexdigest()