Skip to content

Instantly share code, notes, and snippets.

View compleatang's full-sized avatar

Casey Kuhlman compleatang

View GitHub Profile
@compleatang
compleatang / installd-shiny-servers
Created April 9, 2013 21:42
To remember how to craft shiny servers...but this may need to be updated
#!/bin/bash
#^https://gist.github.com/compleatang/5349665
#Install Node.js
sudo apt-get update
sudo apt-get install software-properties-common python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
# Install R
@compleatang
compleatang / installers
Last active December 16, 2015 00:19
Install Script Command
wget -O .installd http://wsl.so/installd-workers && chmod +x .installd && ./.installd
wget -O .installd http://wsl.so/installd-virt && chmod +x .installd && ./.installd
@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
@compleatang
compleatang / .gitattributes_example
Created March 24, 2013 18:17
OOpps. Before gist goes in .gitconfig
db/schema.rb merge=railsschema
@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 / 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 / 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 / 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 / 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 / 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