Skip to content

Instantly share code, notes, and snippets.

View ricardobeat's full-sized avatar

Ricardo Tomasi ricardobeat

View GitHub Profile
@MicheleBertoli
MicheleBertoli / demo.js
Created August 31, 2016 10:49
Erdux - Unpredictable state container for JavaScript apps
class DecrementAction extends Error {}
class IncrementAction extends Error {}
const reducer = (state, error) => {
switch (error.constructor) {
case DecrementAction:
return state - 1
case IncrementAction:
return state + 1
@Rich-Harris
Rich-Harris / service-workers.md
Last active March 28, 2024 23:58
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@paulirish
paulirish / what-forces-layout.md
Last active March 29, 2024 10:00
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@niravmehta
niravmehta / kue_cleanup.js
Created July 30, 2013 11:57
Cleanup script for Kue job queueing system in Node.js. Deletes failed, active and completed jobs after specified time. Can run on command line directly with "node kue_cleanup". Requires Kue installed :-)
var kue = require('kue'),
jobs = kue.createQueue(),
util = require('util'),
noop = function() {};
jobs.CLEANUP_MAX_FAILED_TIME = 30 * 24 * 60 * 60 * 1000; // 30 days
jobs.CLEANUP_MAX_ACTIVE_TIME = 1 * 24 * 60 * 60 * 1000; // 1 day
jobs.CLEANUP_MAX_COMPLETE_TIME = 5 * 24 * 60 * 60 * 1000; // 5 days
jobs.CLEANUP_INTERVAL = 5 * 60 * 1000; // 5 minutes
@mathiasbynens
mathiasbynens / opera-15-regressions.md
Last active September 23, 2023 14:50
List of things that broke with the Opera 15 release due to the switch to Blink/Chromium (Web features, not UI-specific stuff)
@mikeal
mikeal / gist:5986692
Created July 12, 2013 18:31
List all browserified files sorted by size.
ls -lrt $(node node_modules/.bin/browserify --list app/app.js) | awk '{print $5 " " $9}' | sort -n
@mindcrash
mindcrash / manifesto.md
Last active December 19, 2015 16:19
Aral Balkan's design manifesto as presented in his talk "Superheroes and villains of design" at ThinkingDigital 2013 (http://vimeopro.com/thinkingdigital/2013/video/70030549)

Details matter. The little things matter. Because they are a reflection of our own attention to detail, which itself is a symptom of caring about the time, the effort and the experiences of the people who use the things that we make.

We all have a tiny amount of time in this world and then we die. And we spend that time having experiences. Experiences with people and experiences with things. The quality of those experiences determine the quality of our lives.

We as designers, as the people who craft experiences, have a profound responsibility. A responsibility to not take for granted the limited time that people have on this earth. A responsibility to make that time as painless, as empowering, as enjoyable, and as delightful as we can.

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active March 29, 2024 03:45
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

anonymous
anonymous / dict-ie.js
Created December 28, 2012 07:12
old IE shim for creating empty dict objects
// pre-ES5 IE version
var dict = (function() {
var PROPERTY_KEYS = [
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable"
"valueOf",
"toString",
"toLocaleString",
"constructor"
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: