Skip to content

Instantly share code, notes, and snippets.

View camsaul's full-sized avatar
💭
I am Cam

Cam Saul camsaul

💭
I am Cam
View GitHub Profile
@camsaul
camsaul / fix_busted_mysql.sh
Created July 11, 2017 19:25
fix busted MySQL
#! /bin/bash
# kill the server
pkill -KILL mysqld
# drop all the DBs, logfiles, and other busted data
rm -rf /usr/local/var/mysql/*'@002'*
rm /usr/local/var/mysql/ib*
# now restart the server
@camsaul
camsaul / generate-javadoc.sh
Created June 7, 2017 21:42
generating javadocs
#!/bin/bash
javadoc -sourcepath ./src/main/java -subpackages net.sf.jsqlparser
@camsaul
camsaul / json-to-yaml.sh
Created April 11, 2017 22:01
Convert JSON file to YAML
#! /bin/bash
python -c 'import sys, yaml, json; yaml.safe_dump(json.load(sys.stdin), sys.stdout, default_flow_style=False)' < $file
@camsaul
camsaul / lein-different-jvm.sh
Created March 29, 2017 18:19
Run lein with different JVM
#!/bin/bash
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home lein run
@camsaul
camsaul / your_kit.clj
Created March 18, 2017 00:40
Profiling with YourKit
{:jvm-opts ["-agentpath:/Users/camsaul/Downloads/YourKit-Java-Profiler-2017.02.app/Contents/Resources/bin/mac/libyjpagent.jnilib"]}
@camsaul
camsaul / git_cleanup.sh
Created January 4, 2017 21:08
Cleanup old branches in local git repo
#! /bin/bash
# Switch back to master
git checkout master
# Delete all local branches besides master
for branch in `git branch | grep -v 'master'`
do
git branch -D $branch
done
@camsaul
camsaul / .bash_profile
Last active May 9, 2018 02:41
.bash_profile
alias ls='ls -AFGh'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias emacs=/Applications/Emacs.app/Contents/MacOS/Emacs
PATH=$PATH:/usr/local/bin
PATH=$PATH:~/scripts
PATH=/usr/local/opt/ruby/bin:$PATH
PATH=/usr/local/Cellar/perl/5.20.1/bin/:$PATH
PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH
@camsaul
camsaul / kill_pg_connections.sql
Created August 5, 2016 19:45
Terminate all other connections to Postgres DB
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '<db-name>'
AND pid <> pg_backend_pid();
@camsaul
camsaul / fake-smtp.sh
Created July 13, 2016 22:19
Run local fake SMTP server for debugging
#!/bin/bash
sudo python -m smtpd -n -c DebuggingServer localhost:25
@camsaul
camsaul / killing_processes.sh
Created June 22, 2016 22:44
Killing process locking a file
# list process that owns a file
lsof | grep myfile
# kill all java processes
killall -9 java