Skip to content

Instantly share code, notes, and snippets.

View followben's full-sized avatar

Ben Stovold followben

View GitHub Profile
@followben
followben / prng.js
Created March 24, 2020 03:42 — forked from lpinca/prng.js
Pseudorandom number generator based on crypto.randomBytes
var crypto = require('crypto')
, rrange = 4294967296;
/**
* Return an integer, pseudo-random number in the range [0, 2^32).
*/
var nextInt = function() {
return crypto.randomBytes(4).readUInt32BE(0);
};
@followben
followben / gist:4272a8684458946f93dd
Last active August 29, 2015 14:15 — forked from hollance/gist:2936287
Drawing inner glow with Core Graphics
- (CGImageRef)createMaskFromAlphaChannel:(UIImage *)image
{
size_t width = image.size.width;
size_t height = image.size.height;
NSMutableData *data = [NSMutableData dataWithLength:width*height];
CGContextRef context = CGBitmapContextCreate(
[data mutableBytes], width, height, 8, width, NULL, kCGImageAlphaOnly);