Skip to content

Instantly share code, notes, and snippets.

@AlexMoffat
AlexMoffat / TypeScript_project_setup.md
Last active July 9, 2023 02:13
Instructions for creating a basic TypeScript project from scratch

Setting up a TypeScript project from scratch on OS X. All TypeScript source will be under a src directory.

nvm and node

Install nvm globally. Follow the instructions from the nvm github readme.

Create the project directory and cd into it.

Use nvm to install and choose the version of node. Here we'll use version 18.

@AlexMoffat
AlexMoffat / display_off.sh
Last active May 21, 2016 01:21
raspberry pi turn off hdmi connected display. Easier that the inverse. Only turn the display off if tvservice does not report it's already off.
#!/bin/bash
set -o pipefail
tvservice -s | grep -q '\[TV is off\]'
if [[ $? -eq 1 ]]; then
/usr/bin/tvservice -o &> /dev/null
fi
@AlexMoffat
AlexMoffat / display_on.sh
Last active September 5, 2022 16:23
raspberry pi turn on hdmi connected display. Use fbset -s to find the current values for xres and yres. You need to make some change to the fb values before the refresh call or nothing happens.
#!/bin/bash
set -o pipefail
tvservice -s | grep -q '\[TV is off\]'
if [[ $? -eq 0 ]]; then
# Turn display on.
/usr/bin/tvservice -p &> /dev/null
# Change color depth to 8 and back to 16.
/bin/fbset -xres 1920 -yres 1200 -depth 8
/bin/fbset -xres 1920 -yres 1200 -depth 16
# Now that something has changed refresh.
@AlexMoffat
AlexMoffat / .bashrc
Last active December 14, 2015 23:38
Set the bash prompt, terminal tab and window names on OS X. Based on this https://gist.github.com/henrik/31631 with additional comments and using PROMPT_COMMAND instead of directly setting PS1. Add to your .bashrc file. Format of prompt is "last_part_of_directory_path $" - If not in git managed directory "last_part_of_directory_path [branch_name…
# Set the bash prompt, terminal tab and window names on OS X.
#
# Return * if changes, nothing otherwise.
# You could add "--untracked-files=no" to the git status command if you
# don't want untracked files to mark the directory as dirty.
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
# Return branch name with dirty flag (* after name if dirty) or nothing if not in git directory.
# First sed expression matches line starting with *. Second sed expression extracts the rest of