Skip to content

Instantly share code, notes, and snippets.

View shibukawa's full-sized avatar

Yoshiki Shibukawa shibukawa

View GitHub Profile
@shibukawa
shibukawa / config.json
Created March 28, 2012 07:32
JSHint config file for ngCore/ngGo
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 200, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : false, // Standard browser globals e.g. `window`, `document`.
"node" : false,
@shibukawa
shibukawa / distance.js
Created April 10, 2012 23:25
Damerau–Levenshtein distance
// Base code is http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance
function damerauLevenshtein(source, target, distanceLimit)
{
if (source === target)
{
return 0;
}
var m = source.length;
var n = target.length;
@shibukawa
shibukawa / distance.js
Created April 11, 2012 00:10
Arranged Damerau–Levenshtein distance
function calcWeight(index, length)
{
var distance = (length - 1 - index) / (length - 1);
return distance * distance * 0.5 + 1;
}
function stringsDistance(source, target, distanceLimit)
{
if (source === target)
{
@shibukawa
shibukawa / distance.rb
Created April 19, 2012 15:38
Arranged Damerau–Levenshtein distance
module Distance
module_function
def calc_weight(index, length)
distance = (length - 1.0 - index) / (length - 1.0)
distance * distance * 0.5 + 1.0
end
def strings_distance(source, target, distance_limit)
if source == target
@shibukawa
shibukawa / HAL.rb
Created April 21, 2012 05:51
Fuzzy method calling
module HAL
module_function
def calc_weight(index, length)
distance = (length - 1.0 - index) / (length - 1.0)
distance * distance * 0.5 + 1.0
end
def strings_distance(source, target, distance_limit)
if source == target
@shibukawa
shibukawa / build graphiviz as layout engine
Created January 22, 2013 09:30
Graphviz's "plain" output is good for layout engine. This command creates the simplest Graphviz binary on Mac. You can easy to bundle your own program. I will try to run on Windows or cross-compile. This build supports only following output formats: canon cmap cmapx cmapx_np dot eps fig gv imap imap_np ismap pic plain plain-ext pov ps ps2 svg sv…
#! /bin/sh
./configure --enable-static --disable-shared --disable-ltdl --disable-swig --disable-sharp --disable-go --disable-guile --disable-io --disable-java --disable-lua --disable-perl --disable-php --disable-python --disable-r --disable-ruby --disable-tcl --without-pic --without-tclsh --without-x --without-wish --without-expat --without-xpm --without-z --without-Xaw --without-webp --without-rsvg --without-ghostscript --without-visio --without-pangocairo --without-lasi --without-glitz --without-freetype2 --without-fontconfig --without-gtk --without-ming --without-qt --without-quartz --without-glut --without-cgraph --without-libgd --without-gdk_pixbuf LDFLAGS="-mmacosx-version-min=10.6"
$ node
> (-90) % 360
-90
$ python
Python 2.7.3 (default, Dec 3 2012, 16:37:49)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> (-90) % 360
270
@shibukawa
shibukawa / bwt.jsx
Last active December 11, 2015 19:09
Burrows-Wheeler Transform by JSX
class _BWEntry {
static var LAST_CHAR = String.fromCharCode(1);
var last: string;
var key: string;
var _index: number;
function constructor(str: string, index: number) {
this.key = str.slice(index);
this._index = index;
if (index == 0)
@shibukawa
shibukawa / bit_vector.jsx
Created January 28, 2013 08:44
BitVector implementation in JSX.
/**
* This is a JSX version of shellinford library:
* https://code.google.com/p/shellinford/
*
* License: http://shibu.mit-license.org/
*/
class BitVector
{
static const SMALL_BLOCK_SIZE : int = 32;
@shibukawa
shibukawa / Makefile
Last active December 11, 2015 23:39
Makefile for building oggenc/oggdec command.
TOPDIR := $(shell pwd)
LIBPOS := $(TOPDIR)/libs
RESULTPOS := $(TOPDIR)/result
LIBS := $(TOPDIR)/libs/lib
HEADERS := $(TOPDIR)/libs/include
build: libs/lib/libvorbis.a libs/lib/libiconv.a libs/lib/libintl.a result
cd vorbis-tools-1.4.0; ./configure --prefix=$(RESULTPOS) --enable-static --with-libiconv-prefix=$(LIBPOS) --without-curl --disable-shared --disable-ogg123 --disable-ogginfo --disable-vcut --disable-vorbiscomment --disable-oggtest --disable-vorbistest --disable-curltest --with-ogg=$(LIBPOS) --with-vorbis=$(LIBPOS) LDFLAGS="-mmacosx-version-min=10.6" --with-libintl-prefix=$(LIBPOS)
cd vorbis-tools-1.4.0; make;