Skip to content

Instantly share code, notes, and snippets.

View compleatang's full-sized avatar

Casey Kuhlman compleatang

View GitHub Profile
require 'growl'
module Jekyll
class GrowlPreHook < Hook
safe false
sequence :pre
def run(site)
Growl.notify 'Building...', :title => 'Jekyll'
end
@compleatang
compleatang / .cmds
Created February 12, 2013 16:15
Simple reference file for commands that I need every once in a while but have a difficult time remembering....
# ZSH
sudo add-apt-repository ppa:XXXXXXXX - to add repository
se /etc/apt/sources.list - where to add repositories manually
rm /var/lib/apt/lists/XXXXX - another place where repositories are kept
chown -R www-data /usr/share/wordpress - to change the owner of a file, recursively
df -h - to check the size of the disk and % used!
ps aux - to see all of the running processes!
grep -v XXXXX - sort a file but skip any line that has XXXXX on it
dig +short - to see the IP of a web site
apt-get install <package-name>=<version> - to install a specific version of a package
@compleatang
compleatang / Move Git Directory Away
Last active December 12, 2015 17:59
This is useful if you want to track your dropbox or gdrive files with git but do not want all the git files to be taking up the space and sync bandwidth of dropbox/gdrive. It assumes that your project is already built.... credit to @braitsch's reply to this SO question: http://stackoverflow.com/questions/5408475/moving-a-git-repository-up-one-hi…
cd <destination>
mv <source>/.git ./.git
git config core.worktree /absolute/path/to/project-files
@compleatang
compleatang / bootstrap
Last active December 13, 2015 17:48
Updated Dropbox Bootstrap Script
#!/usr/bin/zsh
#^jist /home/coda/Dropbox/bootstrap -u 4950102
if [ ! -d ~/Dropbox/Dot-Files ]; then
mkdir Dropbox/Dot-Files/
fi
if [ ! -d ~/Dropbox/Camera\ Uploads ]; then
mkdir Dropbox/Camera\ Uploads/
fi
@compleatang
compleatang / gist:4954274
Created February 14, 2013 17:02
Automatically import all the gems. Assumes that gem lists have been exported (I use a cron job to keep this up to date) into ~/Dropbox/Rvm-Gems.
#!/bin/zsh
rvm use default@global
cd ~/Dropbox/Rvm-Gems
gemfiles=("${(@f)$(ls /home/coda/Dropbox/Rvm-Gems)}")
IFS='.'
for f in $gemfiles[@]; do
gems=($(echo $f))
rvm gemset use $gems[1] --create
rvm gemset import $gems[1]
@compleatang
compleatang / split-for-gdocs.sh
Created February 16, 2013 21:34
Since Google Drive PDF viewer has a pretty functional OCR system, but since that system only looks at the first 10 pages, I built a simple shell script that will explode a pdf into 10 page blocks. I just call this script from my GDrive folder on my HD and then pull up the exploded pdfs online to copy and paste from the Google supplied OCRing! **…
#!/bin/zsh
dump_data=$(pdftk $1 dump_data | grep NumberOfPages:)
base_name=$(echo $1 | sed -E 's/(.*).pdf(.*)/\1/')
number_pages=$(echo $dump_data | sed -E 's/(.*): (.*)/\2/')
((splits = $number_pages / 10))
((do_end = $number_pages % 10))
start=1
stop=10
for ((i=0; i < $splits; i++)); do
@compleatang
compleatang / cursormove.py
Created February 16, 2013 21:38
Sublime Plugin -- Find the cursor position and move it one position back
(row,col) = self.view.rowcol(self.view.sel()[0].begin())
target = self.view.text_point(row, col-1)
self.view.sel().clear()
self.view.sel().add(sublime.Region(target))
self.view.show(target)
@compleatang
compleatang / .gitattributes_example
Created March 24, 2013 18:17
This specifies a new merge strategy called railsschema, along with the necessary command that Git needs to execute to resolve conflicts. The command itself is just a piece of Ruby code that figures out which schema.rb is the most recent one.
[merge "railsschema"]
name = newer Rails schema version
driver = "ruby -e '\n\
system %(git), %(merge-file), %(--marker-size=%L), %(%A), %(%O), %(%B)\n\
b = File.read(%(%A))\n\
b.sub!(/^<+ .*\\nActiveRecord::Schema\\.define.:version => (\\d+). do\\n=+\\nActiveRecord::Schema\\.define.:version => (\\d+). do\\n>+ .*/) do\n\
%(ActiveRecord::Schema.define(:version => #{[$1, $2].max}) do)\n\
end\n\
File.open(%(%A), %(w)) {|f| f.write(b)}\n\
exit 1 if b.include?(%(<)*%L)'"
@compleatang
compleatang / .gitattributes_example
Created March 24, 2013 18:17
OOpps. Before gist goes in .gitconfig
db/schema.rb merge=railsschema
@compleatang
compleatang / install_a_bunch
Created April 9, 2013 15:27
Install a bunch of packages. First check if they can be found in repos, then check if they are installed. If yes to first and no to second, add to an array, then install the entire array.
#!/bin/bash
function install_a_bunch() {
PKGS_INST=( )
for pkg in $1; do
CAN_WE_FIND_IT=`sudo apt-get -qq --dry-run install $pkg`
if [ ! "$CAN_WE_FIND_IT" == 100 ]; then
IS_IT_THERE=`dpkg -l | grep $pkg`
if [[ ! "$IS_IT_THERE" ]]; then
PKGS_INST=( "${PKGS_INST[@]}" "${pkg}" )
fi