This file contains 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 Trie = require("./index").Trie; | |
var t = new Trie(); | |
// ... add your word dictionary .... | |
t.addStrings(["experts", "exchange", "pen", "island", "choose", "spain", "kids", "express", "childrens", "wear", "dickson", "web"]); | |
var testDomains = ["expertsexchange", "penisland", "choosespain", "kidsexpress", "childrenswear", "dicksonweb"]; | |
function decompose(search) { | |
// find all of the words which start from the first letter |
This file contains 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
// Requires Node.js and [Natural](https://github.com/NaturalNode/natural) | |
var natural = require("natural"); | |
var fs = require("fs"); | |
// NOTE: This file should exist on most UNIX varieties | |
var dictionary = "/usr/share/dict/words"; | |
var trie = new natural.Trie(false); | |
console.time("Build Trie"); |
This file contains 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
#!/bin/bash | |
# CHANGE THIS TO MATCH YOUR PROJECT | |
root_dir=/var/www/example.com; | |
while read oldrev newrev refname | |
do | |
branch=$(git rev-parse --symbolic --abbrev-ref $refname); | |
branch_dir=$root_dir/$branch/$newrev; | |
echo "[CI] Commit recieved on branch $branch"; |
This file contains 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
// NOTE: These are not rock-solid benchmarks, just a quick illustrative test. | |
var wordnet = new natural.WordNet(); | |
var fs = require("fs"); | |
var loops = 100; | |
var allWords = []; | |
// NOTE: This file should exist on most UNIX varieties | |
var dictionary = "/usr/share/dict/words"; | |
var trie = new natural.Trie(false); |
This file contains 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 categorizeGroups(token) { | |
var previous = null; | |
var current = null; | |
var string = ""; | |
for(var c in token) { | |
var ch = token[c]; | |
var next = null; | |
// Y is a special case, it is only a vowel if preceeded by a vowel. | |
if(ch === "y") { |
This file contains 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
import nltk, re, pprint | |
import json | |
import sys | |
# a function to convert a tree into an array for json encoding | |
def tree_to_dict(tree): | |
return {tree.label(): [tree_to_dict(t) if isinstance(t, nltk.Tree) else t for t in tree]} | |
# download required corpora | |
required_downloads = [ |
This file contains 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 Unit = function(value, grad) { | |
this.value = value; | |
this.grad = grad; | |
}; | |
var multiplyGate = function(){ }; | |
multiplyGate.prototype = { |
This file contains 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
<script type="text/javascript" src='http://code.jquery.com/jquery-2.1.3.min.js'></script> | |
<audio id="myAudio" src="http://sqr.bartekdrozdz.com/demo/soundviz/assets/spy.mp3" controls><p>Your browser does not support the audio element.</p></audio> | |
<!-- <audio id="myAudio" src="./a-little-something.mp3" controls><p>Your browser does not support the audio element.</p></audio> --> | |
<div id="visualization" style="width:100%; height:500px"></div> | |
<script type="text/javascript"> | |
Number.prototype.map = function ( in_min , in_max , out_min , out_max ) { | |
return ( this - in_min ) * ( out_max - out_min ) / ( in_max - in_min ) + out_min; | |
} |
This file contains 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 solve(prisoner_count, hard_limit) { | |
var prisoners = []; | |
var startTime = ((new Date()).getTime()); | |
for(var x = 0 ; x < prisoner_count ; x++) { | |
prisoners[x] = false; | |
} | |
// Pick a random prisoner | |
function pickPrisoner() { | |
return Math.floor(Math.random() * prisoner_count); |
This file contains 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
String.prototype.splitSpacesAsInts = function() { | |
return this.split(" ").map(function(aNum) { return parseInt(aNum); }); | |
}; | |
function processData(input) { | |
var lines = input.split("\n"); | |
var first = lines[0].splitSpacesAsInts(); | |
var n = first[0]; | |
var m = first[1]; | |
var ops = lines.slice(1).map(function(line) { return line.splitSpacesAsInts(); }); |
OlderNewer