Getting seconds or milliseconds since January 1, 1970, 00:00:00 GMT in various languages
// ms
struct timespec spec;
clock_gettime(CLOCK_REALTIME, &spec);
require "option_parser" | |
require "http/params" | |
def_fields = "ip,ident,user,year,mon,day,hour,min,sec,method,path,query," + | |
"http,code,bytes,referrer,ua" | |
quiet = false | |
fields_str = def_fields | |
output = STDOUT | |
print_header = false | |
DASH_FIELDS = %w(ident user referrer ua bytes) |
'use strict'; | |
const fs = require('fs'); | |
const AH = require('async_hooks'); | |
const net = require('net'); | |
const { inspect } = require('util'); | |
function log(...args) { | |
fs.writeSync(process.stdout.fd, `${args.map(x => inspect(x, { depth: null, colors: true })).join(' ')}\n`); | |
} |
$ cat foo.js | |
'use strict'; | |
const asyncHooks = require('async_hooks'); | |
const { writeSync } = require('fs'); | |
const Memcached = require('memcached'); | |
function debugHooks(types) { | |
// will contain metadata for all tracked events |
#f '123456789',100 | |
def f(d,t)(0...3**(d.size-1)).map{|c|d.chars.reduce{|s,g|o='+-'[c%3]||'';c=(c/3).floor;s+o+g}}.select{|e|e.scan(/\D?\d+/).map(&:to_i).reduce(:+)==t}end | |
if __FILE__ == $0 | |
p f('123456789', 100) | |
end |
module TexasHoldEm | |
class RulesViolation < RuntimeError | |
end | |
class RingArray < Array | |
def [](n) | |
at n % size | |
end | |
end |
### | |
replace yourlib's: | |
module.exports = { foo, bar } | |
with: | |
module.exports = require('./stubbable') { foo, bar } | |
now when some file does: | |
{ foo } = require './yourlib' | |
you can still stub it with: | |
yourlib = require './yourlib' | |
bond(yourlib._fns, 'foo').return 42 |
cp = require 'child_process' | |
git = (cmd, args, cb) -> # same as vanilla | |
cp.execFile 'git', [cmd].concat(args), (err, stdout) -> cb err, stdout.trim() | |
createTagIfMissing = (origin, tag, cb) -> | |
await git 'show-ref', [tag], defer err, showRef | |
if err? | |
await git 'tag', [tag], defer err | |
return cb err if err? |
request = require 'request' | |
prompt = (str, cb) -> # same as vanilla | |
in = process.stdin | |
process.stdout.write "#{str}: " | |
in.setEncoding 'utf8' | |
in.once 'error', cb | |
in.once 'data', (res) -> | |
in.pause() | |
cb null, res.trim() |
#Container > div.Left { | |
margin-left: -25px; | |
width: 87%; | |
} | |
#room_title h2#topic { font-size: 8px; } | |
div#Sidebar { width: 16%; } | |
#room_title h1#room_name { font-size: 18px; } |