Skip to content

Instantly share code, notes, and snippets.

View brysgo's full-sized avatar

Bryan Goldstein brysgo

View GitHub Profile
@brysgo
brysgo / VerboseAsync.js
Last active March 19, 2024 19:53
verbose logging of nodejs async function by converting to generator
async function myAsyncFunction() {
await callToSomethingAsync();
someNonAsyncFunctionCall();
await callToAnotherAsyncThing();
}
function convertAsyncFunctionToGenerator(fn) {
// Convert the function to string
let stringFn = fn.toString();
@brysgo
brysgo / install_command_line_tools_no_prompt
Created February 14, 2014 19:43
Install xcode command line tools without prompt
do shell script "xcode-select --install"
do shell script "sleep 1"
tell application "System Events"
tell process "Install Command Line Developer Tools"
keystroke return
click button "Agree" of window "License Agreement"
end tell
end tell
javascript:(function()%7Bconst%20scrollToBottom%20%3D%20(className)%20%3D%3E%20%7B%0A%20%20%20%20const%20element%20%3D%20document.getElementsByClassName(className)%5B0%5D%3B%0A%20%20%20%20element.scrollTop%20%3D%20element.scrollHeight%3B%0A%7D%0Alet%20shuffle%20%3D%20(array)%20%3D%3E%20%7B%0A%20%20let%20currentIndex%20%3D%20array.length%2C%20%20randomIndex%3B%0A%0A%20%20%2F%2F%20While%20there%20remain%20elements%20to%20shuffle.%0A%20%20while%20(currentIndex%20!%3D%200)%20%7B%0A%0A%20%20%20%20%2F%2F%20Pick%20a%20remaining%20element.%0A%20%20%20%20randomIndex%20%3D%20Math.floor(Math.random()%20*%20currentIndex)%3B%0A%20%20%20%20currentIndex--%3B%0A%0A%20%20%20%20%2F%2F%20And%20swap%20it%20with%20the%20current%20element.%0A%20%20%20%20%5Barray%5BcurrentIndex%5D%2C%20array%5BrandomIndex%5D%5D%20%3D%20%5B%0A%20%20%20%20%20%20array%5BrandomIndex%5D%2C%20array%5BcurrentIndex%5D%5D%3B%0A%20%20%7D%0A%0A%20%20return%20array%3B%0A%7D%0Alet%20shuffledNames%20%3D%20shuffle(Array.from(document.getElementsByClassName(%22c-m
@brysgo
brysgo / usePeekaboo.ts
Created April 27, 2021 16:20
cascading sticky elements (open sourced from a side project of mine)
import useComponentSize from '@rehooks/component-size'
import useWindowScrollPosition, { WindowScrollPosition } from '@rehooks/window-scroll-position'
import { useMemo, useRef, RefObject } from 'react'
interface Props<T extends HTMLElement> {
min?: number
max?: number
ref?: RefObject<T>
}
@brysgo
brysgo / cloudSettings
Last active July 25, 2020 01:32
vscode user settings
{"lastUpload":"2020-07-25T01:32:22.204Z","extensionVersion":"v3.4.3"}
@brysgo
brysgo / post_checkout_migrations.sh
Last active October 5, 2019 11:13 — forked from skyriverbend/rails_switch_branch.py
Post checkout hook for managing rails migrations and bundle install
CHECKING_OUT_BRANCH=$3
OLD_BRANCH=$1
NEW_BRANCH=$2
if [ $CHECKING_OUT_BRANCH -eq 1 ]
then
FILES_CHANGED=`git diff $OLD_BRANCH $NEW_BRANCH --name-status`
MIGRATIONS_REMOVED=`echo "$FILES_CHANGED" | egrep 'D\tdb/migrate/([0-9]+)' | sort -r`
MIGRATIONS_ADDED=`echo "$FILES_CHANGED" | egrep 'A\tdb/migrate/([0-9]+)'`

Keybase proof

I hereby claim:

  • I am brysgo on github.
  • I am brysgo (https://keybase.io/brysgo) on keybase.
  • I have a public key ASDCZLDZgtKM_8KZLwR7VBTsJAvCur4wv3xDSFmZzR3YFQo

To claim this, I am signing this object:

@brysgo
brysgo / .zshrc
Last active September 20, 2019 14:44
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
[
{
"id": "adelphes.android-dev-ext",
"name": "android-dev-ext",
"publisher": "adelphes",
"version": "0.7.1"
},
{
"id": "dbaeumer.vscode-eslint",
"name": "vscode-eslint",
@brysgo
brysgo / linkAll.sh
Created March 14, 2019 20:43
Bash script to link all the packages in a half baked mono repo
#!/bin/bash
for d in ./packages/*/ ; do
echo ""
echo "##################################################"
echo "##"
echo "## Linking in $d"
echo "##"
echo ""
echo