Skip to content

Instantly share code, notes, and snippets.

View elliot-nelson's full-sized avatar
🦈
Computer Science Lullaby

Elliot Nelson elliot-nelson

🦈
Computer Science Lullaby
View GitHub Profile
@elliot-nelson
elliot-nelson / open-vscode-from-command-line.md
Created June 1, 2021 13:09
Tip - Open VSCode from command line

Open VSCode from the MacOS command line

After downloading VSCode, it's probably just a binary sitting in your Downloads folder. The first thing you want to do is copy that binary into your /Applications folder. (Or open Explorer windows for both folders and just drag and drop the VSCode icon into the Applications folder.)

Next, you'll want to make a link to the VSCode app in your user binary folder. (If you don't have one, create it first and then come back.)

Double-check the location of the VSCode binary (mine is at /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code). Create a soft link to it like so:

@elliot-nelson
elliot-nelson / user-binary-folder.md
Created June 1, 2021 13:03
Tip - User binary folder

Create a user binary folder on MacOS

A user binary folder is a great place to put personal scripts and links to often-used commands.

First, create a folder in your home folder -- you can call it anything, but I prefer to call mine bin:

mkdir ~/bin
# Don't do this...
my_url = @thing.new_record? ? new_thing_path : thing_path(@thing)
# Do this...
my_url = polymorphic_path(@thing)
# Especially useful for cases where you need to change the namespace or add extra params...
# Find foo's and replace with bar's, backing up as *.bak
grep -rl "foo" app/views | xargs sed -i .bak s/foo/bar/g
# Alternate: Require other patterns on the line
grep -rl "grok" app/views | xargs sed -i .bak -e '/grok/ s/foo/bar/g'
# Throw away the backup files