Skip to content

Instantly share code, notes, and snippets.

View tlehman's full-sized avatar

Tobi Lehman tlehman

View GitHub Profile
# http://www.evanmiller.org/bayesian-ab-testing.html implemented in ruby
# requires the distribution gem from https://github.com/clbustos/distribution (gem 'distribution', require: false)
def probability_b_beats_a(completed_a, total_a, completed_b, total_b)
require 'distribution/math_extension'
total = 0.0
alpha_a = completed_a + 1
beta_a = total_a - completed_a + 1
alpha_b = completed_b + 1
graph = {}
ObjectSpace.each_object(Class) do |klass|
sup = klass.superclass and graph[klass] = sup
end
puts "digraph{"
graph.map do |key, value|
puts %("#{key}"\n"#{key}"->"#{value}")
end
puts"}"
@gerryster
gerryster / us_geo_chart_google
Created December 8, 2012 23:13
US State Map using the GeoChart from the Google Chart Tools
// GeoChart from https://google-developers.appspot.com/chart/interactive/docs/gallery/geochart
// Try out by pasting code into: https://code.google.com/apis/ajax/playground/?type=visualization#geo_chart
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['State', 'Foo Factor'],
['US-IL', 200],
['US-IN', 300],
['US-IA', 20],
@BrockA
BrockA / waitForKeyElements.js
Created May 7, 2012 04:21
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite