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
exports.pipe = function (source, sink) { | |
var resolve, reject; | |
return new Promise(function(resolve_, reject_) { | |
resolve = resolve_; | |
reject = reject_; | |
source | |
.on("error", reject) | |
.pipe(sink) | |
.on("error", reject); | |
.on("finish", resolve); |
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
var raven = require('raven') | |
, Promise = require('bluebird') | |
, requestAsync = require('request-promise') | |
var redis = Promise.promisifyAll(require('redis').createClient()) | |
var languages = JSON.parse(require('fs').readFileSync(__dirname + '/languages.json')).languages | |
Promise.all(languages.map(function(language){ | |
return redis.setAsync('lang:'+language.tag+':name', language.name) |
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
export class CodedError extends Error { | |
constructor(code, msg) { | |
super(msg) | |
this.code = code; | |
this.msg = msg; | |
} | |
static is(code) { | |
return (e) => e.code == code; | |
} | |
static only(code, handler) { |
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
/// <reference path="anydb-sql.d.ts" /> | |
import anydbsql = require('anydb-sql'); | |
var db = anydbsql({ | |
url: 'postgres://user:pass@host:port/database', | |
connections: { min: 2, max: 20 } | |
}); | |
// Table Post |
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
create table male | |
( male_id int not null | |
, primary key (male_id) ); | |
create table female | |
( female_id int not null | |
, primary key (female_id) ); | |
create table name | |
( id int not null |
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
let pending = new Promise((r,rj) => {}) | |
let waitForever = () => pending | |
let reject = Promise.reject.bind(promise) | |
let identity = x => x | |
let promiseTransform = fns => p => p.then(fns.fullfilment, fns.rejection) | |
function any(promises) { | |
let fulfillments = promises.map(promiseTransform({fullfilment: identity, rejection: waitForever})) | |
let rejections = promises.map(promiseTransform({fullfilment: waitForever, rejection: identity})) | |
let firstFulfill = Promise.race(fulfillments); |
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
#include <OneWire.h> | |
#include <LiquidCrystal.h> | |
#include <avr/delay.h> | |
#define CHANGERATE 5 // in which limits will the temperature change since the last reading, in degrees | |
#define INPUTPIN 5 | |
// For every sensor found it outputs to serial: | |
// SensorID,CurrentTemp,Readout time,Current time | |
// Info at: http://wiki.spodeli.org/Хаклаб/Температура |
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
ffmpeg = require 'fluent-ffmpeg' | |
mongoose = require 'mongoose' | |
amqp = require 'amqp' | |
async = require 'async' | |
# Connect to RabbitMQ | |
amqpConnect = (done) -> | |
amqpConnection = amqp.createConnection {host: 'localhost'} | |
amqpConnection.on 'ready', done.bind(this, null, amqpConnection); | |
amqpConnection.on 'error', done.bind(this, "Failed connecting to rabbit"); |
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
var fs = require('fs'); | |
function run(makeGenerator) { | |
return function () { | |
var generator = makeGenerator.apply(this, arguments); | |
var continuable, sync, value; | |
next(); | |
function next() { |
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
var less = require("less"), | |
Promise = require("promise"); | |
module.exports = function(options) { | |
return function(inputs) { | |
return Promise.all(inputs.map(lessp)).then(function(css) { return css.join(''); }); | |
}; | |
}; | |
function lessp(input) { |
OlderNewer