Skip to content

Instantly share code, notes, and snippets.

@cmdoptesc
cmdoptesc / ps-filter-long-running-chrome.md
Last active September 14, 2023 04:14
ps - list processes running longer than x with name y
@cmdoptesc
cmdoptesc / You_Dont_Know_JS_this_all_makes_sense_now.md
Created April 7, 2018 02:32
YDKJS: this & Object Prototypes, this call site, implicit, explicit binding (Kyle Simpson)

Mirror of You Don't Know JS: this & Object Prototypes, this All Makes Sense Now!

You Don't Know JS: this & Object Prototypes

Chapter 2: this All Makes Sense Now!

In Chapter 1, we discarded various misconceptions about this and learned instead that this is a binding made for each function invocation, based entirely on its call-site (how the function is called).

Call-site

To understand this binding, we have to understand the call-site: the location in code where a function is called (not where it's declared). We must inspect the call-site to answer the question: what's this this a reference to?

@cmdoptesc
cmdoptesc / bikes-shimano-compatibility-history.md
Created July 4, 2023 20:10
A Brief History of Shimano Compatibility by nalc

A Brief History of Shimano Compatibility by nalc / "Always gritty in Philly"

Mirror of https://old.reddit.com/r/Velo/comments/84z9p9/a_brief_history_of_shimano_compatibility/

I promised /u/thirty-five- that I would give him another writeup for the wiki, and I've got some time today so I figured why the hell not tackle drivetrain and derailleur compatibility?

As usual, the late great Sheldon Brown is a fantastic resource, but following his passing in 2008 it is rather hit or miss whether you can find compatibility information on newer stuff.

To start off with a disclaimer, this information is compiled from a variety of sources and while I believe it to be correct, there could be mistakes. Feel free to point them out and I will correct them.

To start off, we must explain how a derailleur works. At the simplest level, the point of the derailleur is to move the chain sideways at the point where it meshes with the chainrings or sprockets, forcing the chain onto the adjacent chainring or sprocket. In ye olde

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@cmdoptesc
cmdoptesc / You_Dont_Know_JS_Scope_Closures_Lexical_this.md
Created April 7, 2018 02:27
YDKJS: Lexical Scope this and ES6 arrow functions (Kyle Simpson)

Mirror of You Don't Know JS: Scope & Closures, Appendix C: Lexical-this

You Don't Know JS: Scope & Closures

Appendix C: Lexical-this

Though this title does not address the this mechanism in any detail, there's one ES6 topic which relates this to lexical scope in an important way, which we will quickly examine.

ES6 adds a special syntactic form of function declaration called the "arrow function". It looks like this:

@cmdoptesc
cmdoptesc / nodejs-express-cors.js
Created August 21, 2013 06:39
Node.js Express CORS settings / cross origin resource sharing / XMLHttpRequest Origin is not allowed by Access-Control-Allow-Origin
// Express CORS middleware.. so much easier than trying to get Restify to work
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'X-Requested-With, Accept, Origin, Referer, User-Agent, Content-Type, Authorization');
// intercept OPTIONS method
if (req.method === 'OPTIONS') {
res.send(200);
@cmdoptesc
cmdoptesc / script-template.sh
Created November 28, 2021 21:54 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@cmdoptesc
cmdoptesc / Readme.md
Last active November 26, 2021 17:38
D3: Open Hours (.csv parsing)

D3: Open Hours

view on bl.ocks.org
github repo

D3 visualisation utilising D3's text/CSV to read/parse a CSV file with restaurant information and display which restaurants are currently open.

Users can drag the time (red line) to display restaurants open at other hours.

@cmdoptesc
cmdoptesc / .macos
Created February 17, 2017 08:46
Mathias Bynen's macOS defaults script
#
# Originally..
# https://github.com/mathiasbynens/dotfiles/blob/master/.macos
#
#!/usr/bin/env bash
# ~/.macos — https://mths.be/macos
# Close any open System Preferences panes, to prevent them from overriding
@cmdoptesc
cmdoptesc / README.md
Last active September 7, 2021 06:18 — forked from mbostock/.block
TopoJSON Examples

Some of these files are from the us-atlas:

  • us.json - make topo/us-10m.json
  • us-congress-113.json - make topo/us-congress-10m.json

Others are from the world-atlas:

  • world-50m.json - make topo/world-50m.json
  • world-110m.json - make topo/world-110m.json