Skip to content

Instantly share code, notes, and snippets.

@roban
roban / AI_policy_panel_IAS.md
Last active June 7, 2023 06:31
Notes on "Steering AI for the Public Good: A Dialogue for the Future" panel (2023-06-06 at IAS)

"Steering AI for the Public Good: A Dialogue for the Future"

2023-06-06 at IAS

Youtube Recording

panel flyer

Panel

@roban
roban / keybase.md
Created March 16, 2016 14:43
keybase.md

Keybase proof

I hereby claim:

  • I am roban on github.
  • I am robanhk (https://keybase.io/robanhk) on keybase.
  • I have a public key whose fingerprint is 22BD E895 8940 7BBC EEA1 CD3B FE6E A1BB 6A0E 3E55

To claim this, I am signing this object:

<html>
<head>
<title>Swimlane using d3.js</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script>
<script type="text/javascript" src="randomData.js"></script>
<style>
.chart {
shape-rendering: crispEdges;
}
@roban
roban / copy_traces.py
Created December 11, 2012 20:09
copy pymc traces from a db instance to a new db.
def copy_traces(db1, dbname, dbclass, traceclass, **kwargs):
"""Copy traces from a db to a new db.
"""
db = dbclass(dbname=dbname, dbmode='w', **kwargs)
db._initialize({}, 1)
db.trace_names = db1.trace_names
db.chains = 1
# Create the Traces.
for name, trace in db1._traces.iteritems():
db._traces[name] = traceclass(name=name, value={0:trace[:]}, db=db)
@roban
roban / make_gif.bash
Created April 21, 2012 17:20
make animated GIF from a series of JPG files
# `convert` is part of Image Magick http://www.imagemagick.org
# The command below scales the images to 500 pixels (in some dimension),
# imposes a delay of 60/100ths of a second between frames, and loops indefinitely.
# The "-layers optimize" option reduces the final file size by optimizing the GIF frames, with a difference threshold
# controlled by the "-fuzz" parameter.
convert -fuzz 2% -layers optimize -scale 500 -delay 60 -loop 0 -verbose IMG_*.JPG animation.gif
@roban
roban / lifetime_mass.py
Created April 15, 2012 16:54
make a plot of stellar lifetime versus mass using enrichpy
# paste this into an "ipython --pylab" session
# You'll need EnrichPy: http://roban.github.com/EnrichPy/
import enrichpy.lifetime
mass = logspace(-1,4,300)
tlife = enrichpy.lifetime.main_sequence_life_K97(mass)
plot(mass, tlife)
xscale('log')
yscale('log')
xlabel('mass (solar masses)')
ylabel('stellar lifetime (years)')
@roban
roban / trackpoint_sensitivity.sh
Created April 4, 2012 18:33
increase trackpoint sensitivity on my lenovo x201
sudo -s "echo -n 250 > /sys/devices/platform/i8042/serio1/serio2/sensitivity"
@roban
roban / makemovie.sh
Created March 27, 2012 14:54
command I use to make a time lapse movie from a list of individual frames using mencoder
# first create a list of frames, perhaps by running:
# ls -tr *.JPG > frames.txt
# Now run mencoder to make the move. I adapted the configuration from
# http://blog.hugochinchilla.net/2011/09/time-lapse-videos-mencoder/
# playback at 15 frames per second
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:autoaspect:vqscale=3 -vf scale=1920:1440 -mf type=jpeg:fps=15 mf://@frames.txt -o time_lapse.avi
# playback at 30 frames per second
@roban
roban / plot2Ddist.py
Created January 24, 2011 12:14
Routines related to plotting 2D distributions of parameters (mainly for pymc models).
"""Routines related to plotting 2D distributions of parameters.
The core of this module is plot2Ddist, which plots a two-dimensional
distribution with 1D marginal histograms along each axis and optional
features like contours and lines indicating ranges and true values.
"""
import itertools
import math
@roban
roban / plot2Ddist.py
Created November 6, 2010 18:46
The plot2Ddist function plots the joint distribution of two variables, with estimated density contours and marginal histograms. Designed to plot paramter distributions for MCMC samples.
import pylab
import numpy
import pymc
import matplotlib.patches
from mpl_toolkits.axes_grid1 import make_axes_locatable
import scipy.stats
def frac_inside_poly(x,y,polyxy):
"""Calculate the fraction of points x,y inside polygon polyxy.