Skip to content

Instantly share code, notes, and snippets.

View samliew's full-sized avatar
🌈
Happy Pride!

Samuel Liew samliew

🌈
Happy Pride!
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active April 25, 2024 08:14
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@e1024kb
e1024kb / gist:41bf38fdb1a2cb19a781
Created September 27, 2014 13:29
Country - state list in JSON
{
"countries": [
{
"country": "Afghanistan",
"states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"]
},
{
"country": "Albania",
"states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"]
},
@addyosmani
addyosmani / jQueryPluginPatterns.js
Created August 31, 2011 18:02
jQuery Plugin Patterns
/*
A (very) WIP collection of optimized/recommended jQuery plugin patterns
from @addyosmani, @cowboy, @ajpiano and others.
Disclaimer:
-----------------------
Whilst the end-goal of this gist is to provide a list of recommended patterns, this
is still very much a work-in-progress. I am not advocating the use of anything here
until we've had sufficient time to tweak and weed out what the most useful patterns
@jayj
jayj / flexbox.less
Last active November 20, 2023 04:51
CSS3 Flexbox - LESS Mixins
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
display: ~"-webkit-@{display}";
display: ~"-ms-@{display}box"; // IE10 uses -ms-flexbox
@Terrance
Terrance / AjaxQueue.js
Created April 10, 2016 14:37
Limit concurrent jQuery ajax requests to at most 3 at a time, and queue the rest.
var ajaxReqs = 0;
var ajaxQueue = [];
var ajaxActive = 0;
var ajaxMaxConc = 3;
function addAjax(obj) {
ajaxReqs++;
var oldSuccess = obj.success;
var oldError = obj.error;
var callback = function() {
ajaxReqs--;
// ==UserScript==
// @name Stack Experiment Off
// @author CertainPerformance
// @description Turns off the voting experiment - shows true vote totals on pageload and after voting
// @description https://meta.stackoverflow.com/questions/390178/new-popup-message-when-voting-on-a-question
// @version 1.1.1
// @include /^https://stackoverflow\.com/questions/(?:\d+|tagged|search)/
// @run-at document-start
// @grant none
// ==/UserScript==