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
//don't log tests | |
if (process.env.NODE_ENV !== 'test') { | |
app.use( (req, res, next) => { | |
//don't log OPTIONS calls | |
if (req.method !== 'OPTIONS' ) { | |
let startTime = Date.now(); | |
res.on('finish', ()=> { |
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
const obj={ | |
"_id": "5998e0e7190855d671bbce52", | |
"source_creator": { | |
"type": "scripts", | |
"id": "55ec63d54db0c69c6293baa5" | |
}, | |
"source_property": { | |
"id": "5998e0e6e33c9cd672b21727" | |
}, |
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
[{ | |
"$match": { | |
"createdAt": { | |
$gte:new Date(1479189560111) | |
} | |
} | |
}, { | |
"$group": { | |
"_id": { | |
"year": { "$year": "$createdAt" }, |
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 QRandom | |
def next | |
RestClient.get('http://qrng.anu.edu.au/API/jsonI.php?type=uint16&length=1'){ |response, request, result, &block| | |
case response.code | |
when 200 | |
_json=JSON.parse(response) | |
if _json["success"]==true && _json["data"] | |
_json["data"].first || Random.rand(65535) | |
else |
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 ApplicationController < ActionController::Base | |
protect_from_forgery with: :exception | |
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
# IRBRC file by Iain Hecker, http://iain.nl | |
# put all this in your ~/.irbrc | |
require 'rubygems' | |
require 'yaml' | |
alias q exit | |
class Object | |
def local_methods |
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
require 'rest_client' | |
access_token = YOUR_TOKEN | |
github_user = "whoisstan" | |
github_repo = "test_for_github_api" | |
path = "test7.html" | |
content = Base64.encode64('my file content2') | |
sha = nil | |
url="https://api.github.com/repos/#{github_user}/#{github_repo}/contents/#{path}" |
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
require 'benchmark' | |
require 'benchmark/ips' | |
Benchmark.ips do |r| | |
N = 100000 | |
r.report("<< ") do | |
s = "" | |
N.times { s << "." } | |
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
logger.warn "*** BEGIN HTTP HEADER DUMP ***" | |
self.request.env.each do |header| | |
if header[0].match("^HTTP.*") | |
logger.warn "#{header[0]}: #{header[1]}" | |
end | |
end | |
logger.warn "*** END HTTP HEADER DUMP ***" |