Skip to content

Instantly share code, notes, and snippets.

View dinigo's full-sized avatar

Daniel Iñigo dinigo

View GitHub Profile
@lmarkus
lmarkus / SlackPGP.js
Created May 27, 2016 08:30
PGP over Slack using Greasemonkey
// ==UserScript==
// @name SlackPGP
// @namespace slack
// @description slackPGP
// @include https://*.slack.com/messages/*
// @version 1
// @grant none
// ==/UserScript==
@samgiles
samgiles / flatMap.js
Created June 20, 2014 11:32
Javascript flatMap implementation
// [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (:
Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};
@narqo
narqo / producer-consumer.js
Created December 29, 2013 19:41
"Producer-Consumer" example implementation using generators. See http://en.wikipedia.org/wiki/Deterministic_concurrency#Comparison_with_generators for more about coroutine
/* jshint esnext:true */
/**
* "Producer-Consumer" implementation using generators.
* @see http://en.wikipedia.org/wiki/Deterministic_concurrency#Comparison_with_generators
*/
var SIZE = 3,
queue = newQueue();
@willurd
willurd / web-servers.md
Last active April 26, 2024 12:46
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@possibilities
possibilities / meteor-async.md
Created August 23, 2012 22:53
Meteor Async Guide

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished. This pattern can be seen all over Meteor's own codebase:

@sindresorhus
sindresorhus / simplexhr.js
Created January 9, 2012 15:19
Simple XMLHttpRequest wrapper
var xhr = function() {
var xhr = new XMLHttpRequest();
return function( method, url, callback ) {
xhr.onreadystatechange = function() {
if ( xhr.readyState === 4 ) {
callback( xhr.responseText );
}
};
xhr.open( method, url );
xhr.send();
@ssokolow
ssokolow / .Xresources
Created May 1, 2011 15:54
.Xresources settings for more modern XTerm keybindings
! {{{ Quick Reference
!
! Scrolling:
! Scroll Wheel
! Shift-PgUp/PgDn
!
! Copy/Paste:
! Mouse-Select : Copy to PRIMARY
! Shift + Mouse-Select: Copy to CLIPBOARD
!