Skip to content

Instantly share code, notes, and snippets.

View robotloveskitten's full-sized avatar

Tim Barkow robotloveskitten

View GitHub Profile
@avibryant
avibryant / bayesab.js
Last active March 22, 2021 18:36
An implementation of http://www.evanmiller.org/bayesian-ab-testing.html with no depenedencies
function probabilityBBeatsA(aa, ba, ab, bb) {
var probability = 0.0;
for(var i = 0; i < ab; i++) {
var product = Math.log(1 + (aa + ba)/(i + bb));
var j = 1;
var start = i+1;
[bb, ba, aa, i].forEach(function(steps){
var stop = start + steps;
@leonardreidy
leonardreidy / ponymailer
Created July 5, 2013 15:30
A simple ruby script that uses pony.rb to mass mail a list of contacts specified in json format.
#
# Note that this program does not have any error-handling code, so if it fails,
# you will just get some error messages at the command line. It won't skip the offending
# email and move on with the task; it will fail entirely.
#
# Keep an eye on the command prompt periodically, if you don't
# know how to write error-handling code. If it does fail, as it occassionally will
# due to a server rejecting the email, or something like that, then look in your
# Gmail 'sent' folder to identify the last email sent. Then, compare to the list
# of contacts. It will almost certainly have failed because of the next email in the list.
@fny
fny / imagemagick_fix_for_rmagick.sh
Last active July 27, 2020 01:20
OS X shell script to fix RMagick compilation issues when using Homebrew's ImageMagick installation. This script will create the symlinks needed for RMagick to compile. Quantum depths of 8 and 16-bits supported.
#! /bin/sh
#
# An OS X shell script to fix RMagick compilation issues when using Homebrew's
# ImageMagick installation. This script creates the symlinks needed for
# RMagick to compile. Quantum depths of 8 and 16-bits are supported.
#
# You can run this script with "sh whatever_script_name.sh" in your terminal
# or with a click if you change the file extension to "command".
#
# You can manually make the links by visiting the ImagicMagick library
@keithcelt
keithcelt / GSE Bash
Created October 3, 2012 20:46
Bash scripts for GSE
i() {
if [[ -s tmp/isolate ]] ; then
echo "\$ rake isolate:sh['$*']"
rake isolate:sh\["$*"\]
else
echo "\$ bundle exec $*"
bundle exec $*
fi
afplay /System/Library/Sounds/Hero.aiff
}
@themactep
themactep / formtocookie.js
Last active July 24, 2017 15:30
How to save form to cookies, restore form from cookies. Requires jQuery and jQuery Cookie plugin.
/*
* Save Form To Cookie
* (cc) Paul Philippov, themactep@gmail.com
*
* This is rather a proof of concept than a production-ready solution.
* It does not handle all kinds of fields.
* You might want to extend it to suit your needs.
*
* Requirements:
*
@mrdanadams
mrdanadams / _pems.scss
Created March 29, 2012 13:32
PX to EMs conversion in Sass
/* See http://mrdanadams.com/2012/pixel-ems-css-conversion-sass-mixin/ */
/* Default font size in pixels if not overridden. */
$baseFontSize: 16;
/* Convert PX units to EMs.
Ex: margin-right: pem(16);
*/
@function pem($pxval, $base: $baseFontSize) {
@return #{$pxval / $base}em;
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
// Create a simple top to bottom linear gradient with a background-color backup
// The first argument, $color will be output as background-color: $color
//
// This yields a gradient that is 5% brighter on the top and 5% darker on the bottom
//
// +gradient-bg(#777)
//
// This yeilds a gradient where the bright and dark colors are shifted 10% from the original color.
// If you don't specify a third argument it will assign this value for the darkness too, keeping the gradient even.
//
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')