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 |
| ### | |
| 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; } |
| # i'd like this syntax to work | |
| someFunc 42, 69, | |
| foo: 42 | |
| bar: 79 | |
| baz: 88 | |
| "x#{x}": 92 | |
| # which would compile to something like this: | |
| ### | |
| someFunc(42, 69, (function () { |
| @-moz-document url("https://www.hipchat.com/chat") { | |
| #action_tabs .download { display: none !important; } | |
| body.chat .tabs li a { padding-top: 4px !important; } | |
| #action_tabs li.icon a img { top: 4px !important; } | |
| #action_tabs { right: 1px !important; } | |
| #header a.logo { | |
| height: 30px !important; | |
| width: 32px !important; | |
| display: block !important; | |
| overflow: hidden !important; |