Skip to content

Instantly share code, notes, and snippets.

View frozeman's full-sized avatar

Fabian Vogelsteller frozeman

View GitHub Profile
@VictorTaelin
VictorTaelin / promise_monad.md
Last active March 23, 2024 17:49
async/await is just the do-notation of the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing

@davidwkeith
davidwkeith / localization_helper.js
Created July 11, 2012 21:50
Localization Helper for Ember.js's Handlebars
Handlebars.registerHelper('loc', function(property, fn) {
var str;
// we are bound to a value, it is now the context
if (fn.contexts && typeof fn.contexts[0] === 'string') {
str = fn.contexts[0];
// Convention, start all localization keys with _
} else if (property[0] === '_') {
str = property;
/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
@kTmnh
kTmnh / ios6-timers.js
Last active April 27, 2022 21:24 — forked from ronkorving/ios6-timers.js
iOS6 webkit timer bug workaround
(function (window) {
// This library re-implements setTimeout, setInterval, clearTimeout, clearInterval for iOS6.
// iOS6 suffers from a bug that kills timers that are created while a page is scrolling.
// This library fixes that problem by recreating timers after scrolling finishes (with interval correction).
// This code is free to use by anyone (MIT, blabla).
// Original Author: rkorving@wizcorp.jp
var timeouts = {};
var intervals = {};
var orgSetTimeout = window.setTimeout;
var orgSetInterval = window.setInterval;
@kurtmilam
kurtmilam / deep_extend_javascript_objects_underscore_mixin.js
Last active October 3, 2020 14:56
Deep Extend / Merge Javascript Objects - underscore.js Mixin
/* Copyright (C) 2012-2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955
*
* This mixin now has its own github repository: https://github.com/kurtmilam/underscoreDeepExtend
* It's also available through npm and bower
*
* 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 furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFR
@bas-vk
bas-vk / whisper demo.md
Created June 9, 2017 09:21
Whisper chat demo
@bas-vk
bas-vk / chat.js
Last active March 21, 2018 09:52
whisper chat demo
var chat = {
username: "<not set>",
topic: "0xfeedbabe",
key: "",
identity: "",
pollInterval: null,
filter: null,
setUsername: function(name) {
this.username = name;
@molily
molily / apps-berlin-js.md
Last active October 7, 2015 19:48
Slides of the apps.berlin.js meetups

The apps.berlin.js meetup

apps.berlin.js is a Berlin.js spin-off with a special focus on JavaScript-driven web applications (“HTML5 apps”), desktop browser apps as well as mobile apps and games written in JavaScript. Here you can find the slides and additional links of all past talks. Please fork this Gist to add more info!

First meetup on May 10th 2012