Getting seconds or milliseconds since January 1, 1970, 00:00:00 GMT in various languages
// ms
struct timespec spec;
clock_gettime(CLOCK_REALTIME, &spec);
module Main where | |
import Random | |
import List | |
p=putStrLn | |
f(x,y)=x\\(x\\y) | |
e z=['*'|(p,q)<-z,p==q]++(f(unzip[x|x@(p,q)<-z,p/=q])>>"+") | |
n a s=getLine>>=m where{m i|i==s=return a;m i=p(e$zip i s)>>n(a+1)s} | |
main=mapM(\x->randomRIO('1','6'))"mind">>=n 1>>=p.("Tries: "++).show |
@-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; |
# 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 () { |
#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; } |
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() |
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? |
### | |
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 |
module TexasHoldEm | |
class RulesViolation < RuntimeError | |
end | |
class RingArray < Array | |
def [](n) | |
at n % size | |
end | |
end |
#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 |