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
'use strict' | |
_ = require 'underscore' | |
# CombinationGenerator ported from Java. | |
# The algorithm is described by Kenneth H. Rosen, Discrete Mathematics and | |
# Its Applications, 2nd edition (NY: McGraw-Hill, 1991), pp. 284-286. | |
# | |
# Simple usage: | |
# combinations(["a", "b", "c", "d", "e"], 3) |
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() { | |
this.tmpl3 = function tmpl(str, data) { | |
var value = "var out = ''; out+=" + "'" + | |
str.replace(/[\r\t\n]/g, " ") | |
.replace(/'(?=[^%]*%>)/g,"\t") | |
.split("'").join("\\'") | |
.split("\t").join("'") | |
.replace(/<%=(.+?)%>/g, "'; out += $1; out += '") | |
.split("<%").join("';") |
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 _ = require('underscore'); | |
function sortByWeight (arr, weightMap) { | |
arr.sort(function (e1, e2) { | |
var w1 = weightMap[e1]; | |
var w2 = weightMap[e2]; | |
if (_.isNumber(w1) && _.isNumber(w2)) { | |
return w1 - w2; | |
} else { | |
return 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
_.mixin({ | |
/** | |
* Iterates over an array of numbers and returns the sum. Example: | |
* | |
* var sum = _.sum([1, 2, 3]); | |
* => 6 | |
* | |
* @param obj | |
* @returns {Number} | |
*/ |
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
#!/bin/sh | |
# one way (older scala version will be installed) | |
# sudo apt-get install scala | |
#2nd way | |
sudo apt-get remove scala-library scala | |
wget www.scala-lang.org/files/archive/scala-2.10.3.deb | |
sudo dpkg -i scala-2.10.3.deb | |
sudo apt-get update |
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
import junit.framework.Assert; | |
import org.apache.commons.codec.binary.Base64; | |
import org.bouncycastle.crypto.engines.RC4Engine; | |
import org.bouncycastle.crypto.params.KeyParameter; | |
import org.bouncycastle.jce.provider.BouncyCastleProvider; | |
import org.junit.Before; | |
import org.junit.Test; | |
import javax.crypto.Cipher; | |
import javax.crypto.spec.SecretKeySpec; |
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
/** | |
* @see http://www.java2s.com/Code/Java/Security/JCEalgorithmsinBrowser.htm | |
*/ | |
import java.awt.Dimension; | |
import java.security.Provider; | |
import java.security.Security; | |
import java.util.HashSet; | |
import java.util.Set; |
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
// expose angular query string utilities | |
(function () { | |
'use strict'; | |
var module = angular.module('myQueryString', []); | |
module.factory('myQueryString.QueryString', [function () { | |
var forEach = angular.forEach; | |
var hasOwnProperty = angular.hasOwnProperty; | |
var isArray = angular.isArray; |
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
'''cjson, jsonlib, simplejson, and yajl also use C code | |
demjson did not use C code, but was too painfully slow to benchmark | |
(took about 20 seconds for these tests) | |
''' | |
import json | |
import sys | |
import time | |
with open('doc.json') as f: |
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
/** | |
* | |
* Base64 encode / decode | |
* http://www.webtoolkit.info/ | |
* | |
**/ | |
var Base64 = { | |
// private property |
OlderNewer