This is a quick, visual explanation of how blocks work in Ruby.
Let's define a function foo
that accepts an optional block callback, and calls
it if it was passed:
def foo
puts 'foo 1'
import gevent | |
import greenlet | |
import logging | |
import time | |
import traceback | |
_last_switch_time = None | |
_min_elapsed_time = 0.1 | |
def trace(event, (origin, target)): |
diff --git a/phantom-main.js b/phantom-main.js | |
index 0b6d1a1..a6e2e0a 100644 | |
--- a/phantom-main.js | |
+++ b/phantom-main.js | |
@@ -21,6 +21,8 @@ var options = JSON.parse(phantom.args[2] || {}); | |
// Default options. | |
if (!options.timeout) { options.timeout = 5000; } | |
+if (!options.uploadDir) { options.uploadDir = fs.workingDirectory; } | |
+options.uploadDir = fs.absolute(options.uploadDir).replace(/[\/\\]*$/, '') + fs.separator; |
#include <assert.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <curl/curl.h> | |
#include "http.h" | |
int http_response_init(http_response_t * const response) | |
{ |
// really slow: ~50s | |
try { | |
return ret.concat.apply([], ret); | |
} catch (e) { | |
if (e instanceof RangeError && ret.reduce) { | |
return ret.reduce(function(a, b) { | |
return a.concat(b); | |
}, []) | |
} else { | |
throw e; |
#!/usr/bin/env python | |
from __future__ import print_function | |
import argparse | |
import os | |
import requests | |
import sys | |
import zlib | |
from pythonopensubtitles import opensubtitles, utils |
m = 4294967296 | |
a = 69069 | |
c = 1 | |
seed = 6 | |
for i in range(4): | |
seed = (a * seed + c) % m | |
print "%i" % (seed % 36) |
window.sha1 = (function() { | |
/* | |
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined | |
* in FIPS 180-1 | |
* Version 2.2 Copyright Paul Johnston 2000 - 2009. | |
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet | |
* Distributed under the BSD License | |
* See http://pajhome.org.uk/crypt/md5 for details. | |
*/ |
FILES=$(echo "man1/mailq.1 | |
man1/newaliases.1 | |
man1/postalias.1.gz | |
man1/postcat.1.gz | |
man1/postconf.1.gz | |
man1/postdrop.1.gz | |
man1/postfix.1.gz | |
man1/postkick.1.gz | |
man1/postlock.1.gz | |
man1/postlog.1.gz |
powerSet = (set) -> | |
p = [[]] | |
for val in set | |
for i in [0...p.length] | |
p[p.length] = p[i].concat([val]) | |
p |