Skip to content

Instantly share code, notes, and snippets.

View lancejpollard's full-sized avatar
😍
Lots of coding

Lance Pollard lancejpollard

😍
Lots of coding
View GitHub Profile
@cartazio
cartazio / xcode5-haskell-directions.md
Last active May 28, 2019 00:35
xcode 5 + OS X 10.9 mavericks GHC work around nuttiness

PSA :

just use GHC for OSX https://ghcformacosx.github.io

the rest of these directions are preserved for historical purposes

TLDR version, if you have homebrew

xcode-select --install ; brew tap homebrew/versions ;   brew tap homebrew/dupes \
@ryohey
ryohey / vlq.js
Last active November 29, 2019 11:17
Convert Integer to Variable Length Quantity as an array. JavaScript で整数を可変長数値表現するコードが短く書けた
function varIntBytes(v) {
const r = [v & 0x7f]
while ((v >>= 7) > 0) {
r.unshift(0x80 + (v & 0x7f))
}
return r
}
@rumkin
rumkin / chacha20.js
Last active May 29, 2020 10:50
Chacha20-Poly1305.js
/* chacha20 - 256 bits */
// Written in 2014 by Devi Mandiri. Public domain.
//
// Implementation derived from chacha-ref.c version 20080118
// See for details: http://cr.yp.to/chacha/chacha-20080128.pdf
function U8TO32_LE(x, i) {
return x[i] | (x[i+1]<<8) | (x[i+2]<<16) | (x[i+3]<<24);
}
@max-mapper
max-mapper / readme.md
Last active October 20, 2020 03:21
node modules for converting PDFs into other formats
@bodil
bodil / bool.rs
Last active February 28, 2021 03:50
Simple type level natural numbers in Rust
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct True;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct False;
pub trait Bool {
fn new() -> Self;
}
impl Bool for True {
@joelpt
joelpt / squirt.js
Created October 2, 2012 23:41
Manually calculate the square root of a number with Javascript
// The Babylonian Method
// http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
// @param n - the number to compute the square root of
// @param g - the best guess so far (can omit from initial call)
function squirt(n, g) {
if (!g) {
// Take an initial guess at the square root
g = n / 2.0;
}
var d = n / g; // Divide our guess into the number
@joyrexus
joyrexus / README.md
Created January 5, 2015 18:24
js zip function

Routing in Ember

In Ember, the application's state manager handles routing. Let's take a look at a simple example:

App.stateManager = Ember.StateManager.create({
  start: Ember.State.extend({
    index: Ember.State.extend({
      route: "/",
@lancejpollard
lancejpollard / readme.md
Last active January 13, 2022 04:21
Universal Language Encoding (ULE)

Universal Language Encoding (ULE)

An alternative to the UTF encodings to handle more languages in a more compact way.

<language><characters><language><characters>...

Everything is in bytes.

@cwholt
cwholt / Autocomplete.js
Created February 17, 2012 16:39
node.js + redis prefix trie (autocomplete)
module.exports = function(redisClient,prefix) {
var Autocomplete = {};
Autocomplete.prefix = prefix;
Autocomplete.terminal = "+";
Autocomplete.add = function(word, next) {
function add(letters, key, last, x) {
var letter = last ? Autocomplete.terminal : letters[x];
var score = last ? 0 : letter.charCodeAt(0);