Skip to content

Instantly share code, notes, and snippets.

Setup Mac OS X

I'm in a hospital in Spain and my MacBook was stolen.

Now I bought a new one and need to configure it. I have an external hard drive that backup everything using Time Machine, but I don't want all the crap I had in the old one.

1. Run Software Update

Make sure everything is up to date.

@mike0004
mike0004 / shellaliases.sh
Created September 14, 2014 23:16
shellaliases
unalias -a ls
alias l="ls -lah"
alias ltr="ls -ltr"
alias psg="ps -efa|grep -i --color=AUTO"
alias psgc="ps -efa | cut -c1-200 | grep --color=AUTO -i "
alias ..="cd .."; alias ...="cd ../.."; alias ....="cd ../../..";
alias h="history"
alias hgrep="history | grep -i"
alias h10="history 10"
alias c="clear"
@mike0004
mike0004 / update_tz_to_NY.sh
Created September 18, 2014 11:57
Change CentOS timezone New_York
#!/bin/bash -uxe
# creds to https://chrisjean.com/2009/03/03/change-timezone-in-centos
sudo mv /etc/localtime /etc/localtime.bak
sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
@mike0004
mike0004 / show-git-branch-dates.sh
Last active January 28, 2017 11:14
show date of last commit for each branch in current repo
#!/bin/sh
# show the branches in git
for ref in $(git for-each-ref --sort=-committerdate --format="%(refname)" refs/heads/ refs/remotes ); do git log -n1 $ref --pretty=format:"%cr%d% an%n" | cat ; done | awk '! a[$0]++' | head -10
@mike0004
mike0004 / homebrew.mxcl.jenkins.plist
Created April 27, 2015 16:47
Jenkins autostart as setup by homebrew
#Jenkins autostart as setup by homebrew (only starts when user logs in- not good enough):
# $HOME/Library/LaunchAgents/homebrew.mxcl.jenkins.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.jenkins</string>
@mike0004
mike0004 / Jenkins-Job-Config-Bookmarklet.js
Created May 23, 2015 16:38
Bookmarklet to jump to the Jenkins configuration page of a job
javascript:(function()%7Btarget%3D"/configure"%3Bcurr%3Dwindow.location.href%3Bwhile((curr.lastIndexOf("/")%2B1)%3D%3Dcurr.length)%7Bcurr%3Dcurr.substr(0,curr.length-1)%3B%7Dloc1%3Dcurr.indexOf("/job/")%3Bif(loc1<0)%7Balert("must be in a job")%3Breturn%3B%7Djobrootloc%3Dloc1%2B5%3Bloc2%3Dcurr.indexOf("/",jobrootloc)%3Bif(loc2>%3D0)%7Bpath%3Dcurr.substring(0,loc2)%3B%7Delse%7Bpath%3Dcurr%7Dwindow.location.href%3Dpath%2Btarget%3B%7D)()%3B
@mike0004
mike0004 / mac-realsleep.sh
Created October 12, 2015 12:07
Set mac power settings to prevent battery drain during sleep
# show pmsettings (see `man pmset` or http://bit.ly/1LDWm37)
pmset -g
# see what wakes up your host
syslog |grep -i "Wake reason"
# turn off sleep settings
sudo pmset ttyskeepawake 0
sudo pmset womp 0
sudo pmset powernap 0
@mike0004
mike0004 / arrays.sh
Last active October 16, 2015 14:16
associative array example, requires bash 4
#!/usr/bin/env bash
# good ref: http://www.artificialworlds.net/blog/2012/10/17/bash-associative-array-examples/
# requires bash 4 for associative arrays
declare -A MYMAP=(
[foo]=bar
[baz]=quux
)
KEYS=(${!MYMAP[@]}) # Make a normal array containing all the keys in the associative array
for (( I=0; $I < ${#MYMAP[@]}; I+=1 )); do