Skip to content

Instantly share code, notes, and snippets.

View natalan's full-sized avatar

Andrei Zharov natalan

View GitHub Profile
@unscriptable
unscriptable / tiny Promise.js
Created February 7, 2011 06:02
A minimalist implementation of a javascript promise
// (c) copyright unscriptable.com / John Hann
// License MIT
// For more robust promises, see https://github.com/briancavalier/when.js.
function Promise () {
this._thens = [];
}
Promise.prototype = {
@icodejs
icodejs / highchartsDraggable.js
Created October 25, 2012 08:34
JS: Highcharts draggable shim
// http://jsfiddle.net/icodejs/TAVz5/
(function(Highcharts) {
var
addEvent = Highcharts.addEvent,
each = Highcharts.each;
/**
* Filter by dragMin and dragMax
*/
@branneman
branneman / better-nodejs-require-paths.md
Last active October 18, 2024 20:29
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@janmarek
janmarek / createLocalStorageReducer.js
Last active December 27, 2022 21:23
Save part of a Redux store to local storage
function mergeData(reducerDefaults, storedData) {
return {
...reducerDefaults,
...storedData,
};
}
function createLocalStorageReducer(
reducer,
key,
@Alex3917
Alex3917 / scrape_spa_performance_data.py
Last active July 7, 2022 01:33
Get the PageSpeed Insights data for every Angular site on madewithangular.com, and every Next.js site from the nextjs.org/showcase
from pprint import pprint
import csv
import os
import urllib3
import re
import requests
import bs4
from bs4 import BeautifulSoup