ES5-compatible polyfill for Promise.defer()
that will work regardless of whether the Promise
constructor invokes the passed function synchronously or asynchronously.
This file contains 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
#ifndef OPTIONAL_HPP | |
#define OPTIONAL_HPP | |
#include <utility> | |
namespace gamesolver { | |
template <typename T> | |
class optional { | |
public: |
This file contains 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
Promise.fromCallback = fn => | |
new Promise((r, j) => { | |
fn((err, result) => err ? j(err) : r(result)); | |
}); | |
Promise.prototype.nodeify = function (cb) { | |
cb && this.then(r => cb(null, r), cb); | |
return cb ? undefined : this; | |
}; |
Simple implementation of a Promises/A+ queue module.
Exports a single function that creates a new queue, and can be passed a configuration object with the following keys:
concurrency
: The maximum number of concurrently-executing functions. (Default:1
)Promise
: Promise constructor. (Default:global.Promise
)
The return value is the enqueue function, which accepts a single function as its argument. It will return a promise for the result of that function. The function is considered executing until this promise resolves; that is, if the function returns a promise, it will still be considered executing until that promise is settled.
This file contains 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
> mocha --bail --slow 125 --timeout 10000 --check-leaks api-server/tests/index.js | |
NET 6043: listen2 null 4567 4 false undefined | |
NET 6043: _listen2: create a handle | |
NET 6043: bind to :: | |
NET 6043: listen2 127.0.0.1 4568 4 false undefined | |
NET 6043: _listen2: create a handle | |
NET 6043: bind to 127.0.0.1 |
This project has moved to https://github.com/cdhowie/netflix-no-ipv6-dns-proxy
This file contains 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
#!/bin/env python | |
import fileinput | |
counts = {} | |
for line in fileinput.input(): | |
chomped = line.rstrip('\r\n') | |
counts[chomped] = counts.get(chomped, 0) + 1 |
This file contains 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
do | |
-- Don't allow error() to be replaced out from underneath the security checks! | |
local real_error = error | |
do | |
local real_collectgarbage = collectgarbage | |
collectgarbage = function(oper) | |
if oper == 'collect' or oper == 'count' then | |
return real_collectgarbage(oper) |
This file contains 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
using System; | |
using System.Text; | |
using Eluant; | |
class Example { | |
static void Main() { | |
using (var runtime = new LuaRuntime()) { | |
using (var proxy = runtime.CreateFunctionFromDelegate(new Action<LuaTable>(PrintProxy))) { | |
runtime.Globals["printproxy"] = proxy; | |
} |
This file contains 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
/* | |
The MIT License (MIT) | |
Copyright (c) 2013 Chris Howie <me@chrishowie.com> | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
NewerOlder