Skip to content

Instantly share code, notes, and snippets.

@domenic
domenic / promise-retryer.js
Last active September 16, 2023 02:43
Generalized promise retryer
"use strict";
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances.
// If one of those happens, we want to retry until it doesn't.
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects;
// it has no synchronous behavior (e.g. throwing).
function dontGiveUp(f) {
return f().then(
undefined, // pass through success
@Integralist
Integralist / node debug.md
Last active December 31, 2015 00:49
Node debugger API
Run your application using: `node debug xxx.js` then use the following commands to step-through the code (note: Ctrl+D to exit the debugger)...
 
    `cont`                      -> continue running
    `next`                      -> step over next statement
    `step`                      -> step into next statement (if possible, otherwise it just steps over)
    `out`                       -> step out of the currently executing function
    `backtrace`                 -> show the current call execution frame or call stack
    `repl`                      -> start the node repl to allow you to view variable values and execute code
    `watch(expr)`               -> add given expression to the watch list (which is shown whenever you step through anything in the debugger)

Performance Hack - December 2013

Legacy of the hack

  • The majority of the hacks will be be made a reality
  • Pretty bad performance bug was found and fixed!
  • The Rashboard hack will help developer teams understand the real-time performance of the site
  • Everyone was excited about the potential of RUM data after James's talk
  • N&K data developers joined in and were keen to develop ideas useful to News
  • Great to see the unsurmountable stairs between floor 3/4 start to break down as everyone worked and chatted in the same space for 2 days
@WebReflection
WebReflection / handleEvent.md
Last active August 29, 2015 13:57
because handleEvent is the most powerful way to deal with DOM events or states (and not only DOM)

Update

This snippet is now improved and officially an npm module called dom-handler

@sebmarkbage
sebmarkbage / ReactCanvasDrawing.js
Created July 25, 2014 19:14
Canvas Drawing Example
/** @jsx React.DOM */
var Graphic = React.createClass({
componentDidMount: function() {
var context = this.getDOMNode().getContext('2d');
this.paint(context);
},
componentDidUpdate: function() {
@addyosmani
addyosmani / a_small_note.md
Last active October 16, 2021 04:40
clone.sh

This let's me git clone a template repo, cd into and fire up a new template in my editor of choice:

$ clone starter # clones https://github.com/addyosmani/starter (a personal boilerplate)

$ clone h5bp html5-boilerplate # get me HTML5 Boilerplate

$ clone angular angular-seed # same for AngularJS seed

$ clone polymerlabs seed-element # same for a new Polymer element
@ericelliott
ericelliott / essential-javascript-links.md
Last active July 18, 2024 15:03
Essential JavaScript Links
@bendc
bendc / functional-utils.js
Last active September 15, 2023 12:12
A set of pure ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("twitter.com") {
/* styles for collapsing media in tweets and showing an arrow to indicate their existence
but only at the top level */
ol.stream-items > .expanding-stream-item:not(.open) .OldMedia,
ol.stream-items > .expanding-stream-item:not(.open) .AdaptiveMedia {
display: none;
}