This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
from cStringIO import StringIO | |
import sys | |
INFSTR = '1e308' | |
def interleave(inter, f, seq): | |
seq = iter(seq) | |
try: | |
f(next(seq)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <memory> | |
#include <iostream> | |
#include <sstream> | |
#include <utility> | |
#include <algorithm> | |
#include <iterator> | |
struct sequence_tag {}; | |
struct pointer_tag {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require "thread.php"; | |
function doSomething($res, $t) { | |
usleep($t); | |
exit($res); | |
} | |
$thread1 = new Thread('doSomething'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Found on http://www.alternateinterior.com/2007/05/multi-threading-strategies-in-php.html | |
//Modified by http://www.php-code.net | |
//Modified: add executor | |
class Thread { | |
var $pref ; // process reference | |
var $pipes; // stdio | |
var $buffer; // output buffer | |
var $output; | |
var $error; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Functional promise | |
*/ | |
var Promise = (function createPromise(listeners, resolved) { | |
var self = this; | |
if (typeof listeners === 'undefined') { | |
listeners = []; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dart code snippet to get next week's winning lottery numbers | |
// by taking a random guess... | |
// dartbit.com | |
final int out_of_nbs = 6; // Total numbers required to play. | |
final int number_max = 40; // NYC lotto game (Sweet Million) | |
//final int number_max = 49; // CAN lotto game (The Lotto 6/49) | |
/* | |
* Returns a random [int] between 1 and [int] 'max_inclusive'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import("dart:io"); | |
#import("dart:utf"); | |
class Bot { | |
Socket socket; | |
bool sendNick = true; | |
Bot() { | |
socket = new Socket("irc.freenode.net",6667); | |
socket.onError = (e) { | |
print("onError: ${e}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function domSelect(element) { | |
var elm_type = element.substring(0, 1); | |
var _element = element.substring(1); | |
return elm_type != '.' | |
? elm_type != '#' | |
? document.getElementsByName(element) // Default to name. | |
: document.getElementById(_element) // By an id request. | |
: document.getElementsByClassName(_element) // By class request. | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bind = function (prev, bridge) { | |
return function (input) { | |
var result = prev(input); | |
return result.length === 0 ? result : bridge(result[0])(result[1]); | |
}; | |
}; | |
var result = function (a) { | |
return function (input) { | |
return [a, input]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// checking with rhino | |
(function(){ | |
// MonadBase {{{ | |
var MonadBase = function(){}; | |
MonadBase.prototype.result = function(v){ | |
return function(){ return v; }; | |
}; | |
MonadBase.prototype.bind = function(a, f){ | |
return f(a()); |