Skip to content

Instantly share code, notes, and snippets.

View jakub-g's full-sized avatar

jakub-g jakub-g

  • Antibes, France
  • 19:20 (UTC +01:00)
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active November 15, 2024 15:20
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.
@jakub-g
jakub-g / resource-timings-console-table.js
Last active July 10, 2019 12:14
A little copy-paste to dump resource timings to console via `console.table()`
var regex = /playerv5|jquery/ // customize this
function pick(obj, ...entryNames) { let retObj = {}; entryNames.forEach(key => {retObj[key] = obj[key]}); return retObj }
// uncomment interesting items below, keeping in mind console width / no. of columns constraints
console.table(performance.getEntriesByType("resource")
.filter(item => item.name.match(regex))
.map(i => pick(i, 'name', /*'startTime', 'duration',*/ 'initiatorType',
'transferSize', 'encodedBodySize', 'decodedBodySize',
'fetchStart', /*'domainLookupStart','domainLookupEnd', 'connectStart', 'connectEnd', 'secureConnectionStart', 'requestStart', */'responseStart', 'responseEnd',)))
@offirgolan
offirgolan / unwatch-gh-org.js
Created August 2, 2017 05:57
Unwatch All Org Repos
// Navigate to https://github.com/watching and then run:
// Taken from: https://stackoverflow.com/questions/11043374/how-to-unwatch-multiple-repos-easily-on-github
Array.prototype
.slice.apply(document.querySelectorAll('.js-subscription-row'))
.forEach(el => { const org = el.querySelector('a[href^="/YOUR_ORG"]'); if (org) el.querySelector('button').click()});
@danharper
danharper / demo.md
Last active January 20, 2024 16:09
Open native Maps apps on iOS and Android in Cordova
iOS (with pin, iOS will lookup address too and show that as label)
maps://?q=LAT,LNG
Android, no pin (just open at location)
geo:LAT,LNG
@staltz
staltz / introrx.md
Last active November 14, 2024 11:27
The introduction to Reactive Programming you've been missing
@ndarville
ndarville / business-models.md
Last active October 23, 2024 17:18
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@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 = [email protected]: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:

@yurial
yurial / git-rebase--interactive.patch
Created February 25, 2012 16:29
show author on rebase
fix:
/usr/libexec/git-core/git-rebase--interactive
-git rev-list $merges_option --pretty=oneline --abbrev-commit\
+git rev-list $merges_option --pretty=">%h (%an <%ae>) %s"\
result:
1 pick 19f43c1 (Yuri Dyachenko <[email protected]>) add: gcrypt::noerr
2 pick 990a7e8 (Yuri Dyachenko <[email protected]>) add: gcrypt::throwif( err ) throw if err != noerr
3 pick cb03f3b (Yuri Dyachenko <[email protected]>) add: ext::move<T> move semantic