Skip to content

Instantly share code, notes, and snippets.

@Soares
Soares / phacker.py
Created July 3, 2016 19:49
Let's say you have a coin that you can flip at most 300 times, and you want to generate a "statistically significant" result, and you're willing to stop as soon as the data looks like it's going your way. How often will you be able to get p < 0.05? p < 0.01?
# Question: Let's say you have a coin, and you are willing to flip it a bunch of times,
# and you're going to stop as soon as you get a "statistically significant" bias in favor of heads.
# Let's say you are willing to flip it at most 300 times.
# What's the probability that you can get your statistically significant result?
from sys import stdout
from random import random
from scipy.misc import comb
# The actual bias of the coin
BIAS = 0.5
@Soares
Soares / coin_bias_test.py
Last active January 17, 2022 14:32
Let's say you have a fair coin, and can flip it at most 300 times. What percentage of the time will tossing the coin generate a sequence that, at some point along the way, supports the hypothesis "the coin is biased 75% towards heads" 20x as much as it supports the hypothesis "the coin is fair"?
# Let's say you have a fair coin.
# Let's say you don't know whether or not it's actually biased towards heads by a certain degree.
# Let's say you can flip it at most a certain number of times.
# What's the probability that, at some point along the way, it looks pretty likely to be biased?
from random import random
from scipy.misc import comb
# The actual bias of the coin
BIAS = 0.5
# The number of times to flip the coin
@Soares
Soares / gist:a183d3bad69b533892b7
Created June 22, 2015 21:50
MacBook Pro WindowServer log messages after disconnecting external monitor (text is blurry afterwards)
6/22/15 2:47:44.127 PM WindowServer[155]: Received display connect changed for display 0x4280a40
6/22/15 2:47:44.128 PM WindowServer[155]: Found 27 modes for display 0x04280a40 [27, 0]
6/22/15 2:47:44.156 PM WindowServer[155]: Received display connect changed for display 0x3f003d
6/22/15 2:47:44.156 PM WindowServer[155]: Found 1 modes for display 0x003f003d [1, 0]
6/22/15 2:47:44.157 PM WindowServer[155]: Received display connect changed for display 0x2b282dce
6/22/15 2:47:44.157 PM WindowServer[155]: Found 1 modes for display 0x2b282dce [1, 0]
6/22/15 2:47:44.157 PM WindowServer[155]: Display 0x2b282dce changed state to offline
6/22/15 2:47:44.177 PM WindowServer[155]: Display 0x04280a40: GL mask 0x1; bounds (1920, 1200)[1280 x 800], 27 modes available
Main, Active, on-line, enabled, built-in, boot, OpenGL-accel, Vendor 610, Model a029, S/N 0, Unit 0, Rotation 0
UUID 0xe5e926ffff838251e163d61f52faa3e5, ColorSpace { -1569668179 }
@Soares
Soares / keybase.md
Created March 17, 2015 02:38
Keybase proof

Keybase proof

I hereby claim:

  • I am soares on github.
  • I am so8res (https://keybase.io/so8res) on keybase.
  • I have a public key whose fingerprint is D44F 9407 513A 18E4 6CDE E43F 6E2E 054D CFDD FBBB

To claim this, I am signing this object:

@Soares
Soares / gist:10444320
Created April 11, 2014 06:34
Illiterate Botworld
module Botworld where
import Control.Applicative ((<$>), (<*>))
import Control.Monad (join)
import Control.Monad.Reader (Reader, asks)
import Data.List (delete, elemIndices, intercalate, sortBy)
import Data.List.Split (chunksOf)
import Data.Maybe (catMaybes, isJust, fromMaybe, mapMaybe)
import Data.Ord (comparing)
import Text.Printf (printf)
@Soares
Soares / vim.rb
Last active December 14, 2015 02:19 — forked from mgrouchy/vim.rb
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
url 'https://vim.googlecode.com/hg/', :revision => '6c318419e331'
version '7.3.515'
def features; %w(tiny small normal big huge) end
def interp; %w(lua mzscheme perl python python3 tcl ruby) end
@Soares
Soares / Exploder.hs
Created April 10, 2012 14:46
How to explode GHC's brain
{-# LANGUAGE ExistentialQuantification #-}
data Test = forall a. Show a => Box a
main = print a where Box a = undefined