Skip to content

Instantly share code, notes, and snippets.

@jstn
jstn / RandomNumbers.swift
Last active May 5, 2023 03:26
generate random numbers for 64-bit types while mitigating modulo bias
/*
`arc4random_uniform` is very useful but limited to `UInt32`.
This defines a generic version of `arc4random` for any type
expressible by an integer literal, and extends some numeric
types with a `random` method that mitigates for modulo bias
in the same manner as `arc4random`.
`lower` is inclusive and `upper` is exclusive, thus:
@doole
doole / install_psql_php.sh
Last active September 21, 2023 19:12
Install PostgreSQL PHP extensions on Mac OS X
#!/bin/bash
# Install Xcode Command Line Tools first (required)
xcode-select --install
# Check PHP version `php --version`
PHP_VER=$(php -v | head -1 | awk '{ print $2 }')
# Extensions directory (default: empty string)
EXT_DIR=""
@evilmarty
evilmarty / README.md
Created October 25, 2012 07:39
Sass vendor helper mixins

If like me you find it frustrating to define the same vendor prefixes over and over again. Sure, you might create mixins that help reduce the amount of repetitiveness but when your mixins file becomes a library (or not) you see so many lines of near-identical code and wonder if there is an easier way.

Say you have this (all-too familiar) mixin:

@mixin border-radius($radius) {
  -webkit-border-radius: $radius;
  -moz-border-radius: $radius;
  -ms-border-radius: $radius;
 -o-border-radius: $radius;