Skip to content

Instantly share code, notes, and snippets.

@aht
aht / index.html
Created August 12, 2013 05:27
Scatterplot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://polychart.com/s/third_party/polychart2.standalone.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
@aht
aht / index.html
Created August 12, 2013 05:21
Scatterplot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://polychart.com/s/third_party/polychart2.standalone.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
@aht
aht / gist:5097702
Created March 6, 2013 08:45
ansible postgres playbook with PostGIS on Ubuntu, setting up postgis_template and creating databases from this postgis_template
# Based on https://github.com/ansible/ansible/blob/devel/examples/playbooks/postgresql.yml
---
- hosts: postgres.vm
sudo: yes
tasks:
- name: ensure latest postgres & postgis packages are latest
action: apt pkg=$item update_cache=yes state=latest
with_items:
"""
Automated installation of ejabberd with a postgresql backend inspired by this
article: http://www.planeterlang.org/en/planet/article/How_to_install_ejabberd_2.0.0_with_PostgreSQL_support/
"""
from fabric.api import run, sudo
EJABBERD_VERSION = '2.0.5'
EJABBERD_SOURCE_HOME = '~/dev/xmpp/oss'
POSTGRES_PSQL_PASSWORD = 'user'
@aht
aht / collection size and indexes
Created January 17, 2013 10:34
$centerSphere query hangs mongodb
> db['similar_items.tanhxdiv5ratings_cosinesimilarities.6'].count()
27745186
> db['similar_items.tanhxdiv5ratings_cosinesimilarities.6'].getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "osapi_int.similar_items.tanhxdiv5ratings_cosinesimilarities.6",
@aht
aht / gist:1251197
Created September 29, 2011 16:39 — forked from trrichard/gist:1226966
Bookmarklet to uncripple Kindle Cloud Reader
javascript:(function(){
var importJs=function(jsUrl){
var s=document.createElement("script");
s.setAttribute("src",jsUrl);
document.body.appendChild(s);
};
importJs("http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js");
})();
$('iframe').contents().find('iframe').each(function() {
this.contentWindow.onclick = null;
@aht
aht / LICENSE.txt
Created August 4, 2011 15:28 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
package main
import (
"rand"
"time"
"flag"
"fmt"
)
func getCoord(rg *rand.Rand) float64 {
import "container/ring"
// Use a goroutine to receive values from `out` and store them
// in an auto-expanding buffer, so that sending to `out` never blocks.
// Return a channel which serves as a sending proxy to to `out`.
func sendproxy(out chan<- int) chan<- int {
in := make(chan int, 100)
go func() {
n := 1000 // the allocated length of the circular queue
first := ring.New(n)
#!/usr/bin/env python2.6
"""
Usage: python ./rsa_tuples [-s] n
Generate `n` RSA tuples using 200-digit primes.
Requires:
ent.py <http://modular.fas.harvard.edu/ent/ent_py>
stream.py <http//github.com/aht/stream.py>