Skip to content

Instantly share code, notes, and snippets.

// Given a number, find the next higher number which has the exact same set of digits as the original number
// http://stackoverflow.com/questions/9368205/given-a-number-find-the-next-higher-number-which-has-the-exact-same-set-of-digi
function nextUp(iNumber){
var sDigitsSorted = iNumber.toString().split('').sort().join('');
var aPermutations = (function(){
var i = parseInt(iNumber.toString().split('').sort().reverse().join(''),10) + 1,
a = [];
/*
d3.phylogram.js
Wrapper around a d3-based phylogram (tree where branch lengths are scaled)
Also includes a radial dendrogram visualization (branch lengths not scaled)
along with some helper methods for building angled-branch trees.
Copyright (c) 2013, Ken-ichi Ueda
All rights reserved.
@adnils
adnils / doublefloat.js
Created January 30, 2014 10:05
find the next representable double float
"use strict";
var SMALLEST_NORMALIZED_VALUE = 2.2250738585072014e-308; // Math.pow(2, -1022)
var MIN_VALUE = 5e-324 === 0 ? SMALLEST_NORMALIZED_VALUE : 5e-324;
var MAX_VALUE = Number.MAX_VALUE;
Math.nextUp = function (x) {
x = Number(x);
if (x !== x) {
return x;
@adnils
adnils / murmur.js
Created January 30, 2014 10:03
murmur hash
function doHash(str, seed) {
var m = 0x5bd1e995;
var r = 24;
var h = seed ^ str.length;
var length = str.length;
var currentIndex = 0;
while (length >= 4) {
var k = UInt32(str, currentIndex);
@adnils
adnils / af-magic.zsh-theme
Created December 10, 2013 08:24
fix virtualenv
# af-magic.zsh-theme
#
# Author: Andy Fleming
# URL: http://andyfleming.com/
# Repo: https://github.com/andyfleming/oh-my-zsh
# Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme
#
# Created on: June 19, 2012
# Last modified on: June 20, 2012