Skip to content

Instantly share code, notes, and snippets.

@chriskite
chriskite / gist:4171686
Created November 29, 2012 20:28 — forked from jimbojsb/gist:4171673
deduplicator
<?php
class Deduplicator
{
protected $items = [];
public function add($item)
{
// name field will be in $item->name
$this->items[] = $item;
}
@chriskite
chriskite / bernoulli.php
Created April 12, 2012 15:24
Bernoulli PHP
#!/usr/bin/env php
<?php
/*
* @param float $p should be 0= < $p <= 1
* @return 1 with probability $p, 0 with probability (1 - $p)
*/
function bernoulli($p) {
$r = mt_rand() / mt_getrandmax();
@chriskite
chriskite / Git Bash Prompt
Created April 9, 2010 15:45
Git Customization
PS1='\u@\h:\w\[\033[32m\]$(__git_ps1)\[\033[0m\]$ '