This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts, | |
that detects and handles AJAXed content. | |
Usage example: | |
waitForKeyElements ( | |
"div.comments" | |
, commentCallbackFunction | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |