Skip to content

Instantly share code, notes, and snippets.

require File.expand_path(File.dirname(__FILE__) + '/neo')
require 'pry'
# Greed is a dice game where you roll up to five dice to accumulate
# points. The following "score" function will be used to calculate the
# score of a single roll of the dice.
#
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
@isomorphisms
isomorphisms / tensors.html
Created June 3, 2014 18:05
tensors in QM
http://math.ucr.edu/home/baez/photon/tensor.htm:
<blockquote>Both direct sum and tensor product are standard ways of <b>putting together little Hilbert spaces to form big ones.</b> They are used for different purposes. Suppose we have two physical systems.... Roughly speaking, if ... a physical system's ... states are either of A OR of B, its Hilbert space will be [a] direct sum.... If we have a system whose states are states of A AND states of B, its Hilbert space will be [a] tensor product....
<pre>
<b>MEASURE SPACE</b> disjoint union Cartesian product
<b>HILBERT SPACE</b> direct sum tensor product
</pre>
</blockquote>
@isomorphisms
isomorphisms / -mitx.Rmd
Last active August 29, 2015 14:02
MITx and HarvardX course data
`> sort( round(sapply( split( HX, HX$course_id ), function(x) sum(x$viewed) / sum(x$registered) *100 )), decreasing=T)`
Programming
77
Mechanical Engineering
71
Structural Engineering
68
E&M
67
Computer Science
s#MITx/2.01x/2013_Spring#Structural Engineering#g
s#MITx/3.091x/2013_Spring#Solid State Chemistry#g
s#MITx/8.MReV/2013_Summer#Mechanical Engineering#g
s#MITx/8.02x/2013_Spring#E\&M#g
s#MITx/14.73x/2013_Spring#Poverty#g
s#MITx/6.002x/2013_Spring#Circuits \& Electronics#g
s#MITx/3.091x/2012_Fall#Solid State Chemistry#g
s#MITx/8.MReV/2013_Summer#Mechanical Engineering#g
s#MITx/6.00x/2013_Spring#Programming#g
s#MITx/6.00x/2012_Fall#Programming#g
@isomorphisms
isomorphisms / .muttrc
Created May 27, 2014 18:52
configure Mutt to work with Gmail — fast / non-gui / cli alternative to Gmail Web Interface
set from = "[email protected]"
set realname = "Humility Consulting"
set imap_user = "[email protected]"
set imap_pass = "my password in plaintest"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed = "+[Gmail]/Drafts"
@isomorphisms
isomorphisms / peek.bash
Last active March 9, 2019 08:25
an inspector/peeking function ... alternative to "head"
#print a specific line
li() { sed -n "$1"p ; }
lines() { sed -n "$1,$2"p ; }
#whitespace
ws() { echo -e "\t⋮\t⋮\t⋮" ; } #could also do this once for each column à la (head -1 | tr -dC , | sed "s/,/\t⋮/g")
" fun! MySys()
" return "$1"
" endfun
" set runtimepath=~/.vim_runtime,~/.vim_runtime/after,\$VIMRUNTIME
" source ~/.vim_runtime/vimrc
" helptags ~/.vim_runtime/doc
imap jk <Esc>
# You're meant to read through this
# configuraton file rather than simply
# copying it to your home directory.
#
# There are some places where you're
# meant to uncomment something if you
# want to use it in your TMUX.
#
# I hope it's readable.
#
require(microbenchmark)
# ζ is U+3b6 in Ubuntu
ready.set.go.10000000 <- microbenchmark( "ζ <- complex(0); for (j in 1:1e6) ζ <- c(ζ,complex(argument=j/1e6*2*pi,modulus=1) )", "ζ <- complex(1e6); for (j in 1:1e6) ζ[j] <- complex(argument=j/1e6*2*pi, modulus=1)", "ζ <- complex( argument=1:1e6*2*pi, modulus=1 )" )
a<-Sys.time(); ready.set.go.10000000 <- microbenchmark( "ζ <- complex(0); for (j in 1:1e7) ζ <- c(ζ,complex(argument=j/1e7*2*pi,modulus=1) )", "ζ <- complex(1e7); for (j in 1:1e7) ζ[j] <- complex(argument=j/1e7*2*pi, modulus=1)", "ζ <- complex( argument=1:1e7*2*pi, modulus=1 ))" ,times=5e4L); b<-Sys.time()
b-a
@isomorphisms
isomorphisms / peek.bash
Last active January 1, 2016 11:48
alternative peeking tool to head and tail: pick out a random 20 lines of a file, plus the first and last lines.
#!/bin/bash
# peek
# look at N random lines of datafile.csv
# usage: rand datafile.csv N
# rand $1 $2
head -1 $1 #names row of $1