Skip to content

Instantly share code, notes, and snippets.

Avatar

Thanos Polychronakis thanpolas

View GitHub Profile
View gist:8730799
27ms Created RTCPeerConnnection with: config: '{"iceServers":[{"url":"stun:stun.l.google.com:19302"}]}'; constraints: '{"mandatory":{"OfferToReceiveAudio":true,"OfferToReceiveVideo":true}}'.
85ms onSignalingStateChanged() ::, signalingstatechange
86ms Set session description success.
221ms ICE Candidate. Type:, HOST, Medium:, audio, Candidate:, a=candidate:505434299 1 udp 2113937151 192.168.1.6 61829 typ host generation 0
221ms ICE Candidate. Type:, HOST, Medium:, audio, Candidate:, a=candidate:505434299 2 udp 2113937151 192.168.1.6 61829 typ host generation 0
@thanpolas
thanpolas / test.js
Created Feb 13, 2014
How to test a promise returning async method using Mocha
View test.js
test('test case', function(done) {
promise.method(function(result) {
assert.equal(result.name, 'mocha');
}).then(done, done);
});
View api.js
var express = require("express");
// Create the API application.
var api = express();
api.get("/v1/money", function(req, res) {
res.json({ "bling": "$$$" });
});
module.exports = api;
@balupton
balupton / README.md
Last active Oct 11, 2015
DocPad: Minify your assets with Grunt
View README.md

DocPad: Minify your assets with Grunt

The following will minify your assets with grunt each time a generation write completes.

Installation

  1. Install Dependencies
View Gruntfile.js
'use strict';
module.exports = function(grunt) {
// Override process.stdout to log the name+args of the current task before
// every logged line.
var hooker = require('hooker');
var newline = true;
hooker.hook(process.stdout, 'write', function(str) {
var prefix = grunt.task.current.nameArgs;
if (newline && prefix && str !== '\n') {
@briancavalier
briancavalier / settleAll.js
Created Mar 25, 2013
Wait for all promises to settle
View settleAll.js
function settleAll(array) {
return when(array, function(array) {
var i, len, results;
results = [];
for(i = 0, len = array.length; i < len; i++) {
if(i in array) {
results[i] = when(array[i], null, identity);
}
@thanpolas
thanpolas / Gruntfie.js
Last active Dec 26, 2015
Grunt Config for node server + livereload
View Gruntfie.js
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
express: {
options: {
// Override defaults here
},
web: {
options: {
@thanpolas
thanpolas / test.js
Created Apr 11, 2013
Testing promises with mocha
View test.js
var assert = require('chai').assert;
var when = require('when');
var def1 = when.defer();
function getProm() {
return def1.promise;
}
View gist:8947417

[In reply to https://news.ycombinator.com/item?id=7219005]

Here's the history, hope it helps.

I wrote the original version of the npm registry in a day or two on top of CouchDB. I built it quickly and didn't think much about scale.

Isaacs continued to improve and maintain that code. At one point he even wrote up an open standard for generic js package registries for CommonJS but they didn't seem to care (they were too busy arguing about promises).

At the time I wrote the initial code I was employed at CouchOne and we had a small CouchDB hosting platform operated by Jason Smith which is where we ran the registry free of charge. Later on, after CouchOne was aquired by Membase and became Couchbase, it decided to break off the hosting company and give/sell it to Jason Smith, which became IrisCouch.

@thanpolas
thanpolas / singleton-class.js
Created Sep 16, 2016
ES6 Singleton Pattern
View singleton-class.js
/**
* @fileOverview Singleton pattern on ES6.
*/
import logger from './logger.midd';
/**
* The class statement.
*
*/