Skip to content

Instantly share code, notes, and snippets.

View GregGallant's full-sized avatar
🌎
Building...

Greg Gallant GregGallant

🌎
Building...
View GitHub Profile
@GregGallant
GregGallant / SudoSave
Last active December 27, 2015 14:58
Save a file in vi as sudo instead of cursing and :q!
:w !sudo tee %
@GregGallant
GregGallant / VimrcSanity
Created November 6, 2013 21:05
Python vim indentation? It's dangerous to go alone... take this.
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smarttab
set expandtab
@GregGallant
GregGallant / Linux swap state
Created November 6, 2013 21:08
Linux memory swap sweep (Ubuntu)
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1
@GregGallant
GregGallant / Regex4Dates
Created April 8, 2014 17:16
Regex for Dates
(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])
@GregGallant
GregGallant / Vagrant Funnies
Created April 16, 2014 14:41
Vagrant Funnies
alias vagrantfix='sudo /Library/StartupItems/VirtualBox/VirtualBox restart'
alias vagrantshalt='vboxmanage list runningvms | cut -d \" -f 2 | xargs -I % vboxmanage controlvm % poweroff' # Halt all vagrants
alias vagrantbounce="sudo echo ; vagrantshalt ; sleep 5 ; vagrantfix ; sleep 5 ; vagrantfix ; vagrant up ; vagrant ssh"
@GregGallant
GregGallant / Precision chmod
Last active August 29, 2015 14:06
Specified chmod for files and dirs
Recursive change mode of only files (to something workably secure)
find /my/awesome/path -type f -exec chmod 644 {} +
Recursive change mode of only directories (to something workably secure)
find /my/awesome/path -type d -exec chmod 755 {} +
@GregGallant
GregGallant / Bash Usage
Last active August 29, 2015 14:06
Be Bash Awesome... every shell script should have something similar
pparam=$@;
if [ -z "$pparam" ]; then
echo "Usage: beAwesome.sh --[prod,stage]"; exit 1;
fi
for opt in $@; do
case $opt in
"--prod")
echo "Production run";
DATABASE=seriousAwesome;
@GregGallant
GregGallant / mysql watch
Last active August 29, 2015 14:06
Watch MySQL process from command line in real time
#/bin/bash
watch -n 1 mysqladmin --user=<user> --password=<password> processlist
@GregGallant
GregGallant / SQL out to file from cmdline
Created September 24, 2014 21:10
Suck my Outfile permissions MySQL
echo "select * FROM awesome" | mysql -u <user> -p <password> -h <host> <database> > /tmp/awesome.sql
@GregGallant
GregGallant / memcache flush
Created September 30, 2014 16:32
I can never remember this...
echo 'flush_all' | nc localhost 11211