Skip to content

Instantly share code, notes, and snippets.

View dbrockman's full-sized avatar

David Brockman dbrockman

View GitHub Profile
export default createFromSeed(randomSeed());
export function createFromSeed(seed) {
if (!Number.isInteger(seed) || seed <= 0) {
throw new TypeError('seed must be an int > 0');
}
let value = seed;
const next = () => {
const hi = 16807 * (value >> 16);
@dbrockman
dbrockman / gist:1851609
Created February 17, 2012 07:41
Git aware bash PS1
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_status() {
local color=""
if git rev-parse --git-dir >/dev/null 2>&1
then
/**
Axial coordinates
# convert cube to axial
q = x
r = z
# convert axial to cube
x = q
z = r
function modulo(a, b) {
var r = a % b;
return (r * b < 0) ? r + b : r;
}
function nthArrayItem(array, n) {
return array[modulo(n, array.length)];
}
### ALIAS
alias cd..='cd ..'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias §='exit'
# Get week number
alias week='date +%V'

Keybase proof

I hereby claim:

  • I am dbrockman on github.
  • I am dbrckmn (https://keybase.io/dbrckmn) on keybase.
  • I have a public key whose fingerprint is 1D11 8D7A 9177 F946 DD3A C5A7 4EEA C966 0D82 F1EB

To claim this, I am signing this object:

@dbrockman
dbrockman / countTilesInRegion.m
Created February 11, 2014 08:56
How to count the number of tiles in a map region with min/max zoom level
- (NSUInteger)countTilesInRegionSouthWest:(CLLocationCoordinate2D)southWest
northEast:(CLLocationCoordinate2D)northEast
minZoom:(int)minZoom
maxZoom:(int)maxZoom
{
double minLat = southWest.latitude;
double maxLat = northEast.latitude;
double minLon = southWest.longitude;
double maxLon = northEast.longitude;