Skip to content

Instantly share code, notes, and snippets.

@deanmalmgren
deanmalmgren / gist:1790480
Created February 10, 2012 16:01
merge work from mercurial repository ./X/path/to/dir into repository ./Y/path/to/dir
# from the bash prompt...
# starting from the directory that contains repositories X and Y, use 'hg convert --filemap' to find
# extract the content from path/to/dir in repository X and put it into a temporary repository TMP
echo 'include "path/to/dir"' > filemap.txt
hg convert --filemap.txt ./X ./TMP
# enter repository Y and do a "force pull" to pull in the changes from the temporary repository TMP
cd ./Y
hg pull -f ../TMP
@deanmalmgren
deanmalmgren / facebook_post_rate_example.py
Created April 19, 2012 14:07
How to count number of Posts shared by Facebook Page.
"""This gist demonstrates how to automatically authenticate with Facebook's OAuth2
using fbconsole --- programmatically, without a browser --- and then count the number
of Posts, for example, on a Facebook Page.
"""
import fbconsole
import datetime
import time
# set up fbconsole

This is a simple gist to illustrate the peculiar behavior with django 1.5 and DEBUG=False when running locally (and in production?...haven't gotten that far yet).

@deanmalmgren
deanmalmgren / 01.make
Last active December 18, 2015 18:39
brew install meld does not work
python tools/install_paths \
libdir=/usr/local/Cellar/meld/1.7.2/lib/meld \
localedir=/usr/local/Cellar/meld/1.7.2/share/locale \
helpdir=/usr/local/Cellar/meld/1.7.2/share/gnome/help/meld \
sharedir=/usr/local/Cellar/meld/1.7.2/share/meld \
< bin/meld > bin/meld.install
python tools/install_paths \
libdir=/usr/local/Cellar/meld/1.7.2/lib/meld \
localedir=/usr/local/Cellar/meld/1.7.2/share/locale \
helpdir=/usr/local/Cellar/meld/1.7.2/share/gnome/help/meld \
@deanmalmgren
deanmalmgren / index.html
Last active December 23, 2015 12:59
Example stylings for d3-tip
<!DOCTYPE html>
<html>
<head>
<title>d3.tip.js - Tooltips for D3</title>
<meta charset="utf-8" />
<title>Example styles</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" src="https://rawgithub.com/Caged/d3-tip/master/d3.tip.min.js"></script>
<style type="text/css">
body {
@deanmalmgren
deanmalmgren / README.md
Last active December 26, 2015 13:49
curved intersection of divs

This demo demonstrates how to connect two adjascent <div>s with something that mimicks border-radius behavior. The key is using the :before and :after selectors to add a svg background image that has the rounded corners.

@deanmalmgren
deanmalmgren / sync_hg_mod_times.sh
Last active December 31, 2015 20:29
Change the timestamps of all files managed in a mercurial repository to the last modified time recorded in the repository. This is useful, for example, when multiple people are using the same Makefile to run a data workflow
#!/bin/bash
cd $(hg root)
for f in $(hg st -A | awk '{if($1!="I") print $2}'); do
# http://stackoverflow.com/a/4039466/564709
t=$(hg log -l1 --template '{date|isodate}' $f | awk '{d=$1; gsub(/-/,"",d); t=$2; sub(/:/,"",t); printf("%s%s", d, t)}')
# http://stackoverflow.com/a/6839855/564709
@deanmalmgren
deanmalmgren / random_numbers.py
Created July 14, 2014 19:49
random numbers in python distributions
"""Pipe the output of this script to another program to look at the CDF of the values. For example,
python random_numbers.py 1000 | sort -n | awk '{print $1, 1-(NR-1)/1000}' | xmgrace -
"""
import sys
import random
n = int(sys.argv[1])
for i in xrange(n):
@deanmalmgren
deanmalmgren / .gitignore
Last active August 29, 2015 14:03
bootstrapping: comparing sample means
sample_a.dat
sample_b.dat