Skip to content

Instantly share code, notes, and snippets.

View acorcutt's full-sized avatar
Making Stuff

Anthony Corcutt acorcutt

Making Stuff
View GitHub Profile
@Protonk
Protonk / prng.js
Last active August 31, 2024 17:14
Various PRNGs, implemented in javascript.
// Linear Congruential Generator
// Variant of a Lehman Generator
var lcg = (function() {
// Set to values from http://en.wikipedia.org/wiki/Numerical_Recipes
// m is basically chosen to be large (as it is the max period)
// and for its relationships to a and c
var m = 4294967296,
// a - 1 should be divisible by m's prime factors
a = 1664525,
// c and m should be co-prime
@afeld
afeld / gist:5704079
Last active June 6, 2025 21:03
Using Rails+Bower on Heroku
@chrisross
chrisross / gcd_sass_script.scss
Last active February 23, 2023 23:27
This Sass (SCSS) function utilises the Greated Common Divisor (gcd) to reduce duplicate styles.
// Algorithm to calculate the Lowest Common Denominator
@function gcd($a, $b){
@if $b == 0 {
@return $a;
} @else {
@return gcd($b, $a%$b);
}
}
// Example Use-case:
@chrisveness
chrisveness / crypto-pbkdf2.js
Last active May 11, 2025 22:15
Uses the SubtleCrypto interface of the Web Cryptography API to hash a password using PBKDF2, and validate a stored password hash against a subsequently supplied password. Note that both bcrypt and scrypt offer better defence against ASIC/GPU attacks, but are not available within WebCrypto.
/**
* Returns PBKDF2 derived key from supplied password.
*
* Stored key can subsequently be used to verify that a password matches the original password used
* to derive the key, using pbkdf2Verify().
*
* @param {String} password - Password to be hashed using key derivation function.
* @param {Number} [iterations=1e6] - Number of iterations of HMAC function to apply.
* @returns {String} Derived key as base64 string.
*
@acorcutt
acorcutt / Cloud9GithubOrg
Created April 13, 2017 20:52
Allow Cloud9 to push to org repo
To allow c9 workspace to push to github org repository you must allow it in 3rd party access setup https://github.com/organizations/<org>/settings/oauth_application_policy
Either remove restrictions or allow it from your https://github.com/settings/applications
@busypeoples
busypeoples / validateSpec.js
Last active September 27, 2017 18:08
Validate deeply nested inputs.
const R = require('ramda')
const colors = ['green', 'blue', 'red']
const notEmpty = R.compose(R.not, R.isEmpty)
const minLength = a => b => R.length(b) > a
const hasPresetColors = x => R.indexOf(x, colors) !== -1
const input = {
id: 1,
userName: 'Random',