This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(a,b){ | |
var x, o; | |
do { | |
x = a & b; | |
o = a | b; | |
a = o ^ x; | |
b = x << 1; | |
} while (x) | |
return o; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Three Value Toggle</title> | |
</style> | |
</head> | |
<body> | |
<input name="foo" type="tvg" value="Maybe"> | |
<input name="bar" type="tvg" value="True"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'tempfile' | |
require 'drb/drb' | |
class DServer | |
attr_reader :active_server | |
attr_reader :service |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WorkQueue | |
attr_reader :result | |
def initialize | |
@q = [] | |
end | |
def push &block | |
@q << block |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# | |
# Created by Nat Noordanus on 2013-12-13. | |
# Description: | |
# Analyses the first 100 billion digits of pi to determine the greatest number | |
# of decimal places separating consecutive occurrences of the same digit. | |
# The purpose is to discover the first gap of more than 255 decimal places | |
# between consecutive occurrences of a base 10 digit in pi. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs, vi, sys, rs, bufferSize, remainder, startTime; | |
startTime = Date.now(); | |
fs = require('fs'); | |
vi = require('varint'); | |
sys = require('sys'); | |
rs = fs.createReadStream('/path/to.file'); | |
total = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# created on 18/5/13 by Nat Noordanus [email protected] | |
import os, argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("input_dir") | |
parser.add_argument("stamp_file") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Provides an efficiently searchable tree index of a given array of stringafiable objects. | |
# Is specifically designed to be much faster than using Array's _index_ or _include?_ methods for locating a numerical value within an Array. | |
# However it should work just as well with Arrays of strings or other objects that respond appropriately to _to_s_. | |
class QuickIndex | |
# @param ary [Array] of items to be indexed. | |
# @param stop_char (String) which should not occur as a substring in any of the stringified objects in ary. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A very light wrapper for the InsightToolkit Convert3D tool which must be downloaded seperately. | |
# See http://www.itksnap.org/pmwiki/pmwiki.php?n=Convert3D.Convert3D | |
# It is assumed that the Convert3D tool resides in the shall path as c3d. | |
# Otherwise Convert3D.path= must be used to set the location of the executable. | |
module Convert3D | |
@@c3d_path = "c3d" # assume c3d is in the environment path by default | |
@@Formats = [".nrrd", ".hdr", ".img", ".img.gz", ".dcm", ".cub", ".mha", ".df3", ".nii.gz"] | |
def self.path= path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import argparse | |
import collections | |
import numpy | |
import nibabel as nib | |