I hereby claim:
- I am mudge on github.
- I am mudge (https://keybase.io/mudge) on keybase.
- I have a public key ASBDGnU-C3RqiI8Qhc2PUEsdVcNTtf5avLN5urIUcEbzOwo
To claim this, I am signing this object:
module MongoDB | |
class URI | |
attr_reader :uri | |
def initialize(uri) | |
@uri = uri | |
end | |
def username | |
matches[:username] |
class Hash | |
def to_proc | |
method(:[]).to_proc | |
end | |
end | |
%w(a b c d).map(&{"a" => 1, "b" => 2, "c" => 3}) | |
# => [1, 2, 3, nil] | |
# Or, a more readable example: |
I hereby claim:
To claim this, I am signing this object:
<?php | |
$a = array(1, 2, 3); | |
$pairs = array_map(null, $a, array_slice($a, 1)); | |
/** | |
* Prints: | |
* (1,2)(2, 3)(3, ) | |
*/ | |
foreach ($pairs as list($x, $y)) { | |
echo "({$x}, {$y})"; |
<?php | |
/* From https://github.com/guzzle/iterator/blob/master/MapIterator.php */ | |
class MapIterator extends \IteratorIterator | |
{ | |
/** @var mixed Callback */ | |
protected $callback; | |
/** | |
* @param \Traversable $iterator Traversable iterator |
<?php | |
/* Given an anonymous function with a previously unspecified number of arguments like so: */ | |
$f = function ($x, $y, $z) { | |
/* Do something interesting with $x, $y and $z. */ | |
return; | |
}; | |
/* How can I convert it into the following nested function (each function yielding one argument), | |
* finally calling $f when there are enough arguments? | |
*/ |
/* go(function () { | |
* console.log('Foo'); | |
* }); | |
*/ | |
var go = function (f) { | |
if (typeof process.nextTick === 'function') { | |
process.nextTick(f); | |
} else if (typeof setImmediate === 'function') { | |
setImmediate(f); | |
} else { |
<?php | |
/* A simple function to determine whether an IP is within a range | |
* or not. | |
* | |
* Examples: | |
* | |
* withinCIDR('1.2.3.4', '1.2.3.0/24'); | |
* => 1 | |
* | |
* withinCIDR('1.2.3.4', '1.2.3.4'); |
paste -d '\n' <(curl 127.0.0.1:9200/collection/_search | jq -c '.hits.hits[] | {"index": {_index, _type, _id}}') <(curl 127.0.0.1:9200/collection/_search | jq -c '.hits.hits[]._source') |
import socket | |
port = 3001 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind(('localhost', port)) | |
s.listen(5) | |
while 1: | |
client, address = s.accept() | |
data = client.recv(1024) | |
if data: |