Skip to content

Instantly share code, notes, and snippets.

View willgarcia's full-sized avatar
🌴

William Garcia willgarcia

🌴
  • Brisbane, Australia
View GitHub Profile
@willgarcia
willgarcia / gist:7973734
Created December 15, 2013 14:37
bash debugging
set -u # check whether you have initialised all your variables
set -e # exit on fail
bash -n # syntax checks
@willgarcia
willgarcia / gist:8003671
Created December 17, 2013 11:39
yum download rpm
yum install yum-downloadonly
yum update [PACKAGE] -y --downloadonly --downloaddir=[DIR]
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="kolo"
# Example aliases
@willgarcia
willgarcia / gist:8369459
Created January 11, 2014 10:55
mac geeklet - battery cycles
my_ac_adapt=`ioreg -w0 -l | grep ExternalConnected | awk '{print $5}'`
if [ "$my_ac_adapt" != "Yes" ]
then
cur_power=`ioreg -w0 -l | grep CurrentCapacity | awk '{print $5}'`
max_power=`ioreg -w0 -l | grep MaxCapacity | awk '{print $5}'`
bat_percent=`echo "scale=2;$cur_power / $max_power" | bc`
bat_percent=`echo "$bat_percent * 100" | bc | sed 's/.00//'`
cyc_count=`ioreg -w0 -l | grep "Cycle Count" | awk 'BEGIN { FS = "=" } ; {print $8}' | awk 'BEGIN { FS = "}" } ; {print $1}'`
#echo "Power : Battery ($bat_percent%)"
echo "Cycles : $cyc_count"
@willgarcia
willgarcia / gist:8369476
Created January 11, 2014 10:57
mac geeklet - system info
myCPU=`top -l 1 | awk '/CPU usage/ {print $3}' | sed s/%//`
myCPU=`echo "tmp=$myCPU; tmp /= 1; tmp" | bc`
typeset -i b=9
echo "CPU Usage \c"
while [ $b -lt $myCPU ]
do
echo "\033[1;37m▇\033[0m\c"
b=`expr $b + 10`
done
@willgarcia
willgarcia / gist:8369494
Created January 11, 2014 10:58
shell kill by name
kill `pidof httpd`
# unmerged branches
git branch -a --merged master
@willgarcia
willgarcia / gist:8369544
Created January 11, 2014 11:03
change tmp dir - symlink
mv /tmp /tmp.old && ln -s /home/tmp /tmp
chmod +t /home/tmp
chmod a+w /home/tmp
@willgarcia
willgarcia / gist:91970f5786969f808735
Created January 16, 2014 20:05
getting ssh-agent to work
eval `ssh-agent -s`
ssh-add ~/.ssh/*_rsa
$ (root) useradd -m -s /bin/bash myuser
$ (root) passwd myuser