Skip to content

Instantly share code, notes, and snippets.

View cvan's full-sized avatar
🚌
🌊

Christopher Van Wiemeersch cvan

🚌
🌊
View GitHub Profile
@cvan
cvan / .zshrc
Created March 24, 2020 21:42
useful git aliases
# Inspired from https://github.com/cvan/dotfiles/blob/f21e950/.aliasrc#L26-L48
alias gco='git checkout'
alias gg='git get'
alias gb='git branch'
alias ga='git add'
alias gd='git diff'
alias gs='git status'
alias gst='git stash'
alias gsta='git stash apply'
@cvan
cvan / index.js
Last active March 24, 2020 20:19 — forked from MoOx/index.js
Export GitHub Labels as JSON (name, description, color)
// Remixed from original source: https://gist.github.com/MoOx/93c2853fee760f42d97f
//
// 1. Go to a GitHub Labels page. (e.g., https://github.com/cssnext/cssnext/labels)
// 2. Open your Dev Tools' Console and paste this script.
// 3. Now you have a dump of your labels.
//
// P.S. The JSON output can be later imported using a tool using https://github.com/popomore/github-labels
labels = [];
Array.prototype.forEach.call(document.querySelectorAll('.Box-row a[class^=IssueLabel]'), el => {
@cvan
cvan / gist:8a10ea4929d5a29ac931e479ebbba6a4
Last active March 24, 2020 01:16
generate every five number from 0 through 100 (javascript for use in devtools)
str = ''; for (let i = 0 ; i <= 100 ; i += 5) { str+=` '${i}': '${i}%,'\n`; }
copy(str);
/*
Output:
'0': '0%',
'5': '5%',
'10': '10%',
@cvan
cvan / extract-nextjs-css.sh
Created March 24, 2020 00:51
extract CSS from next.js export + copy to clipboard
cat out/**/*.css | ./node_modules/.bin/prettier --stdin-filepath abc.css | pbcopy
@cvan
cvan / npm-dependencies.js
Created March 23, 2020 22:42
extract dependencies from package.json
copy(Object.keys(x).sort().map(i => ` - \`${i}\``).join('\n') + '\n')
@cvan
cvan / made-with-nextjs.md
Last active October 30, 2023 09:51
next.js production examples - sites in the wild open with open-source code
@cvan
cvan / git-files-changed-since-master.txt
Created March 13, 2020 20:12
git - list of files changed in a branch vs. master
% git diff master..head --name-only
icon.svg
index.html
package.json
package-lock.json
% git diff master..head
@cvan
cvan / monitor-event-loop-delays.js
Last active February 27, 2020 22:56
monitor Node.js event-loop delays (requires Node.js v11+)
// Source: https://twitter.com/jasnell/status/1233135311959445504
//
// PSA: Did you know that since Node.js 11.0.0 there's been a built-in mechanism for monitoring event loop delay?
const { monitorEventLoopDelay } = require('perf_hooks');
const h = monitorEventLoopDelay({ resolution: 20 });
h.enable();
@cvan
cvan / nice-popup.js
Last active February 2, 2021 20:51
(() => {
const width = window.outerWidth / 2;
const height = window.outerHeight / 2;
const top = 0;
const left = width * 3;
const popupEl = window.open('http://example.com', 'preview', `height=${height},width=${width},scrollbars=yes,left=${left},top=${top}`);
popupEl.focus();
})();
// Source: adapted from https://stackoverflow.com/a/48161723
// This returns a SHA-256-hashed string.
function sha256(message) {
// Encode as UTF-8.
const msgBuffer = new TextEncoder('utf-8').encode(message);
if (typeof window !== 'object' || !window.crypto) {
return Promise.resolve(null);
}