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 $waitForOneBlock(){ | |
const id = Date.now(); | |
return new Promise((resolve, reject) => { | |
web3Instance.currentProvider.send({ | |
jsonrpc: "2.0", | |
method: "evm_mine", | |
params: [], "id": id, | |
}, function(e,r){ | |
if(e) reject(e); |
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
from multiprocessing import Pool | |
from os import listdir, stat, rename, mkdir, rmdir | |
from os.path import join, isdir, getsize | |
import sys | |
def listFolders(path): | |
return filter(lambda f: isdir(join(path, f)), listdir(path)) | |
PATH = sys.argv[1] |
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
"/api/v1/resources/:resource_id" | |
"/api/v1/master/:master_id/resources/:id" | |
{ | |
master_id: "master_id", | |
resource_id: "resource_id", | |
} | |
var Resource = function(url, map){ |
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
class ArrayInquirer < Array | |
private | |
def method_missing method, *args | |
begin | |
any? { |elem| elem.to_s == method[0..-2] } | |
rescue NoMethodError | |
super method, *args | |
end | |
end | |
end |
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
class OrdersQuery | |
def initialize(relation = Order.all) | |
@relation = relation.extending(Scopes) | |
end | |
def find | |
@relation.includes(:order_state, | |
:region, | |
:merchant_payment_method_currency => [ | |
:merchant, :payment_method_currency => [ :payment_method_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
class With | |
attr_accessor :object, :result | |
def initialize(object) | |
@object = object | |
@result = nil | |
end | |
def method_missing(method, *args, &block) |
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
module Util | |
class MessageHandler | |
@@data = {} | |
class << self | |
def data_in(language) | |
load! if !@@data[language] or (files_changed? and Rails.env.development?) | |
@@data[language][language.to_s] |
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
def render(view_name) | |
filename = File.join "app", "views", "#{view_name}.html.erb" | |
template = File.read filename | |
eruby = Erubis::Eruby.new(template) | |
eruby.result | |
end |
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 Promise = function(){ | |
this.pending = []; | |
} | |
Promise.prototype = { | |
then: function(onResolve, onReject){ | |
this.pending.push({ | |
resolve: onResolve, | |
reject: onReject |
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
#Non-Tail-Recursion | |
def fact(x) | |
(x == 0) ? 1 : x * fact(x-1) | |
end | |
#Tail-Recursion | |
def factorial(x) | |
iteration = ->(acc, n) { | |
(n == 0) ? acc : iteration.call(acc * n, n-1) | |
} |
NewerOlder