Skip to content

Instantly share code, notes, and snippets.

View ChristopherA's full-sized avatar

Christopher Allen ChristopherA

View GitHub Profile
@ChristopherA
ChristopherA / MavericksSetupAssistantReInstall.txt
Last active August 29, 2015 14:05
Mac OSX Mavericks Setup Assistant Reinstall
Boot into single-user mode (hold ⌘-S during startup)
Once the command-line prompt appears, type the following:
mount -uw /
rm -R /Library/Preferences/
rm -R /Users/your username/
cd /var/db/dslocal/nodes/Default
ls to list the files
@ChristopherA
ChristopherA / shell-trivialities.md
Last active August 29, 2015 14:06
Bash Shell Trivialities — Short Useful Commands for the OSX Shell

Bash Shell Trivalities: Short Useful Commands & Recipes for the OSX Shell

I find returning to terminal after a break from programming that the simple things sometimes are lost. This document's goal is to capture these, even if otherwise trivial.

Count visible files in folder

$ /bin/ls . | wc -l

Count all files, visible and hidden in folder

@ChristopherA
ChristopherA / nozoomheader.html
Created July 12, 2015 03:50
mobile html no zoom
<meta content="width=device-width, initial-scale=1.0 maximum-scale=1.0 user-scalable=0" name="viewport" />
<meta content="apple-mobile-web-app-capable" content="yes" />
@ChristopherA
ChristopherA / keybase.md
Last active October 15, 2015 18:01
keybase.md

Keybase proof

I hereby claim:

  • I am ChristopherA on github.
  • I am christophera (https://keybase.io/christophera) on keybase.
  • I have a public key whose fingerprint is FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED

To claim this, I am signing this object:

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch

@ChristopherA
ChristopherA / .bash_profile.local
Last active August 13, 2016 20:42
.bash_profile.local — loaded by ~/.bashrc for private data, an example for my github.com/christophera/dotfiles project
#!/bin/bash
# ~/.dotfiles/.brewfile_local.sh -- loaded by ~/.bashrc for private data,
# an example for my github.com/christophera/dotfiles project
#
# ~/.bash_profile.local is sourced by ~/.bashrc for shell code which will be
# .gitignored and thus not be backed up into the .dotfiles repository.
# Load on a new machine via:
@ChristopherA
ChristopherA / dotfiles-ideas.md
Last active October 1, 2016 07:44
Various useful ideas for dotfiles

shell files

at end of .bashrc

source $HOME/.bashrc_$(hostname -f)

alias completion

@ChristopherA
ChristopherA / curl-edit-bash.sh
Last active October 3, 2016 00:56
alternatives to curl | bash -> curl to editor to bash
file=$(mktemp); curl -s "$url" > $file; $EDITOR $file; sh $file; rm $file
curl $URL | ( cat > $HOME/tmp/source; read REPLY; [[ ! $REPLY =~ ^[Yy]$ ]] && cat $HOME/tmp/source ) | sh ; rm $HOME/tmp/source
#need some cross platform way to hashpipe check.
if [[ `uname` == 'Darwin' ]]; then
alias sha256sum='openssl dgst -sha256'
fi
@ChristopherA
ChristopherA / iMovieNetworkVolumeSave.md
Created July 12, 2014 21:00
How to modify Mac OSX iMovie to save projects to a network volume via terminal shell defaults write command

Saving iMovie Projects to Network Volumes

The problem

Apple's iMovie saves its Projects and Events files as folders named "/Documents/Movies/iMovie\ Events", "/Documents/Movies/iMovie\ Projects". You are not able to change this location using the app, however, you can use iMovie to move these folders to an external drive. On that drive, both of these folders MUST be at the root, i.e. "/Volumes/Footage/iMovie\ Events" and "/Volumes/Footage/iMovie\ Projects". If you open iMovie while an external drive has these folders at root, iMovie will automatically add them to its event and project library.

Unfortunately, you can't do this trick with network volumes by default. You can do some tricks with symlinks but when using them across volumes they are unreliable and iMovie will loose track of information.

The solution