Skip to content

Instantly share code, notes, and snippets.

Dean Radcliffe deanius

View GitHub Profile
View async_ruby.rb
# some of the syntax requires Ruby 2.5+
module Async
refine BasicObject do
def async(&block)!
def enqueue(&block)
::Fiber.yield [:append, block]
JoshCheek / observer_async_options.js
Last active Mar 6, 2019
Three variations on async
View observer_async_options.js
// based on
// three different algorithms on async, with a fake file system that's easy to modify
const { agent } = require("rx-helper");
// Timer (useful for understanding how output gets processed)
const start = new Date()
const log = (whatevz) => console.log(new Date() - start, whatevz)
// Fake slow file system:
gaearon / connect.js
Last active Apr 25, 2019
connect.js explained
View connect.js
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
deanius /
Last active Aug 29, 2015
Meteor package.json for fun and profit

Why use pacakge.json with Meteor ?

  • Keep the preferred port with the project
  • Each project need not run on port 3000 (Keep your favicon.ico from getting confused!)
  • Start up with settings.json in a conventional way
  • Install utils with your project, like spacejam, ESLint, etc..
  • Have a uniform interface between package projects and meteor apps

How to use it ?

nolanlawson / protips.js
Last active Apr 16, 2019
Promise protips - stuff I wish I had known when I started with Promises
View protips.js
// Promise.all is good for executing many promises at once
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
View extract_meteor_deps.js
// p = require('./extract_meteor_deps');
// Package = p.Package;
// getPackageDeps = p.getPackageDeps; depsByPackage = p.depsByPackage;
// > getPackageDeps('spacebars')
// ['htmljs', 'blaze', 'observe-sequence', 'templating']
// > depsByPackage
// {"spacebars": ['htmljs', 'blaze', 'observe-sequence', 'templating']}
var Package, api, depsByPackage, getPackageDeps, mockApiUse, _;
deanius / load-it.js
Last active Aug 29, 2015
Load core Meteor Libraries for a Meteor-style REPL in the browser
View load-it.js
var loadScript = function(url){
var d=document;
var s=d.createElement('script');
(d.head || d.documentElement).appendChild(s)
/*needed for reactive-coffee, and meteor*/
/*Tracker.autorun (as, ReactiveDict (as ReactiveMap), ReactiveVar, and ReactiveObject */
fraserxu / auth.js
Last active Feb 6, 2018
Handling CORS in Meteor app
View auth.js
* packages/reststop2/auth.js
* Add a method to handle OPTIONS request
// return nothing
RESTstop.add('login', {'method': 'OPTIONS'}, function() {})
View 1-meteor-internationalization.bash
# This little gist shows how to easily internationalize your application using the meteor-just-i18n package.
# Package repository:
# 1. Adding the package.
$ meteor add anti:i18n
CrabDude /
Created Apr 16, 2014
Node.js Callback Contract

#callback/errback contract

  1. Function that takes 2 arguments
    • first argument is an error
    • second argument is the result
    • Never pass both
    • error should be instanceof Error
  2. Must never excecute on the same tick of the event loop
  3. Must be passed as last argument to function
  4. Return value is ignored
  5. Must not throw / must pass resulting errors
You can’t perform that action at this time.