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
/* | |
* /routes/index.js | |
*/ | |
/* | |
* / -> index | |
* | |
*/ | |
exports.routes = function() { |
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'); | |
// Helper function to iterate directory and get resources | |
var recursiveListFiles = function(path) { | |
if (path == undefined) { | |
return []; | |
} | |
var fs = require('fs'); | |
var paths = _.map(fs.readdirSync(path), function(p) { return path + '/' + p}); | |
var files = _.filter(paths, function(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
import networkx as nx | |
from sqlalchemy import create_engine, MetaData | |
import sqlalchemy | |
engine = create_engine('mysql+mysqldb://........', echo=True) | |
meta = MetaData() | |
meta.reflect(bind=engine) | |
try: | |
# Topological sort, which will yield an exception if there is a cyclical dependency |
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
CharsetEncoder encLatin = Charset.forName("ISO-8859-1").newEncoder(); | |
if (encLatin.canEncode(msg)) { | |
return Normalizer. | |
normalize(msg, Normalizer.Form.NFD). | |
replaceAll("[^\\p{ASCII}\\x0a\\x0d\\x20-\\x7a\\xa1\\xa3\\xa4\\xa5\\xa7\\xbf\\xc4\\xc5\\xc6\\xc7\\xc9\\xd1\\xd6\\xd8\\xdc\\xdf\\xe0\\xe4\\xe5\\xe6\\xe8\\xe9\\xec\\xf1\\xf2\\xf6\\xf8\\xf9\\xfc]", ""); | |
} else { | |
return new String(Hex.encodeHex(msg.getBytes("UTF-16"))); | |
} |
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
<property name="discoverySpi"> | |
<bean class="org.gridgain.grid.spi.discovery.tcp.GridTcpDiscoverySpi"> | |
<property name="localAddress" value="10.1.1.2"/> | |
<property name="ipFinder"> | |
<bean class="org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.GridTcpDiscoveryVmIpFinder"> | |
<property name="shared" value="true"/> | |
<property name="addresses"> | |
<list> | |
<value>scheduler.node.com:47500</value> | |
</list> |
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
<property name="discoverySpi"> | |
<bean class="org.gridgain.grid.spi.discovery.tcp.GridTcpDiscoverySpi"> | |
<property name="localAddress" value="10.1.1.1"/> | |
<property name="ipFinder"> | |
<bean class="org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.GridTcpDiscoveryVmIpFinder"> | |
<property name="shared" value="true"/> | |
<property name="addresses"> | |
<list> | |
<value>10.1.1.1:47500</value> | |
</list> |
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 org.gridgain.grid.GridClosureCallMode._ | |
import org.gridgain.scalar.scalar | |
import scalar._ | |
import java.io.File | |
import io.Source | |
import net.liftweb.json._ | |
import net.liftweb.json.JsonDSL._ | |
import java.util.{Date, Collections} | |
import java.util.concurrent.{Callable, TimeUnit, Executors, ConcurrentHashMap} |
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
require 'zookeeper' | |
class Lock | |
def initialize(host, root="/my-app") | |
@zk = Zookeeper.new(host) | |
@root = root | |
end | |
def with_lock(app, timeout, timeout_callback, &block) | |
new_lock_res = @zk.create(:path => "#{@root}/#{app}-", :sequence => true, :ephemeral => 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
(defun merge-sort (lst) | |
(let ((size (length lst))) | |
(if (= size 1) | |
lst | |
(progn | |
(let ((seq1 (merge-sort (subseq lst 0 (floor (/ size 2))))) | |
(seq2 (merge-sort (subseq lst (floor (/ size 2)) size)))) | |
(merge-it seq1 seq2)))))) | |
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
require 'chronic' | |
class DateValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
valid = true | |
begin | |
y = Chronic.parse(value) | |
valid = false unless y | |
rescue |