Skip to content

Instantly share code, notes, and snippets.

Brendan Graetz bguiz

Block or report user

Report or block bguiz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View web3-provider-with-fallback-for-old-version.js
// web3 provider with fallback for old version
window.addEventListener('load', async () => {
// New web3 provider
if (window.ethereum) {
window.web3 = new Web3(ethereum);
try {
// ask user for permission
await ethereum.enable();
// user approved permission
View whoami.json
{"id": "0d593b03242553b24568b3dbccceadd8cb419795091f6e75267f37d8e6100771c10b3bd55285eae9adc99c3e1b0a770f152e132c20c8425b94d43c7d65fc36a9"}
View .block
license: gpl-3.0
height: 700
border: no


  • You want to do a minor edit to files on another branch
  • The copy of the git repo that you have locally is in a state that is too much effort to clean up/ revert/ stash etc to bother


  • simply clone the repo in a different folder
  • but this clone is minimal, so it's much faster
View javascript-unsigned-integer-16-bitshift.txt
> 0b11111111111111110000000000000000 - 0b100000000000000000
> ((0xffff - 2) * 0x10000)
> ((0xffff - 2) << 16)
-196608 # WHY??>?
> ((0xffff - 2) << 16) >>> 0
bguiz /
Last active Aug 22, 2017
Custom NodeJs REPL

Custom NodeJs REPLs

A way to create read-eval-print-loops for your own projects, with a per-instance history, rather than a global history.

Sample Usage

bguiz / RouteListener.js
Last active Jul 24, 2017
onUpdate in react-router-4
View RouteListener.js
import { Component } from 'react';
import PropTypes from 'prop-types';
function RouteListenerFactory(plugins = []) {
plugins.forEach((plugin, pluginIdx) => {
if (! { = `routeListenerPlugin#${pluginIdx}`;
if (!plugin.initialise) {
bguiz /
Created Aug 25, 2016
See what npm run prepends to the PATH
$ pwd
$ echo ${PATH}
$ npm run print-my-path # "print-my-path": "echo ${PATH}"
> scratch-project@0.8.2 print-my-path /Users/bguiz/code/scratch-project
> echo ${PATH}
bguiz /
Created Aug 23, 2016
Installs a dependency from a git repo using info specified in pakage.json, then builds it
# Installs a dependency from a git repo using info specified in pakage.json, then builds it
: <<"MultilineCommentDelimiter"
Place this file in ./devops/git-dependency/
Update package.json to add "config" and a a build step to "scripts"
"config": {
bguiz / catch-doesnt-stop-promise-chain.js
Last active Jul 1, 2016
`.catch()` doesn't stop the rest of a promise chain from executing
View catch-doesnt-stop-promise-chain.js
// returns a promise that always rejects
function myPromise() {
return new Promise((resolve, reject) => {
reject('error in myPromise');
// promise.catch(a).then(b).catch(c)
myPromise().catch(function a(err) {
console.log('a:', err);
You can’t perform that action at this time.