Skip to content

Instantly share code, notes, and snippets.

Avatar

Gordon Brander gordonbrander

View GitHub Profile
@blixt
blixt / prng.js
Last active Sep 20, 2020
A very simple, seedable JavaScript PRNG. NOTE: Please read comments on why this is not a good choice.
View prng.js
// NOTICE 2020-04-18
// Please see the comments below about why this is not a great PRNG.
// Read summary by @bryc here:
// https://github.com/bryc/code/blob/master/jshash/PRNGs.md
// Have a look at js-arbit which uses Alea:
// https://github.com/blixt/js-arbit
/**
@fogleman
fogleman / distinct.py
Last active Dec 1, 2020
Python Unique / Distinct Elements Iterator
View distinct.py
def distinct(iterable, keyfunc=None):
seen = set()
for item in iterable:
key = item if keyfunc is None else keyfunc(item)
if key not in seen:
seen.add(key)
yield item
if __name__ == '__main__':
x = [0, 0, 1, 0, 1, 2, 2, 1, 0]
@tbranyen
tbranyen / use.js
Created Jan 13, 2012
A RequireJS compatible plugin to provide shimming capabilities declaratively.
View use.js
(function() {
var buildMap = {};
/* RequireJS Use Plugin v0.2.0
* Copyright 2012, Tim Branyen (@tbranyen)
* use.js may be freely distributed under the MIT license.
*/
define({
version: "0.2.0",
@jsocol
jsocol / data-uri.py
Created Jul 18, 2011
Give an image, get a data-uri
View data-uri.py
#!/usr/bin/env python
"""Command line script to convert a file, usually an image, into a data URI
for use on the web."""
import base64
import mimetypes
import os
import sys
@jed
jed / LICENSE.txt
Created May 10, 2011 — forked from 140bytes/LICENSE.txt
use anchor tags to parse URLs into components
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@borgar
borgar / Tiny JavaScript tokenizer.js
Created Jun 24, 2010
A compact tokenizer written in JavaScript.
View Tiny JavaScript tokenizer.js
/*
* Tiny tokenizer
*
* - Accepts a subject string and an object of regular expressions for parsing
* - Returns an array of token objects
*
* tokenize('this is text.', { word:/\w+/, whitespace:/\s+/, punctuation:/[^\w\s]/ }, 'invalid');
* result => [{ token="this", type="word" },{ token=" ", type="whitespace" }, Object { token="is", type="word" }, ... ]
*
*/
You can’t perform that action at this time.