Skip to content

Instantly share code, notes, and snippets.

View stevenschobert's full-sized avatar

Steven Schobert stevenschobert

View GitHub Profile
function isPortrait() {
return Math.abs(window.orientation) / 90 !== 1);
}
// note: if you don't need IE8 support, you can just do
// return image.tags.indexOf('TAGNAME') !== -1;
filter: function(image) {
var foundTag = false, tags = image.tags;
for(var i=0,len=tags.length; i<len && !foundTag; i++) {
if (tags[i] === 'THE_TAG_NAME') foundTag = true;
};
return foundTag;
@stevenschobert
stevenschobert / fix_vim_ruby.sh
Created February 17, 2014 16:42
thing to run when vim isn't using the right ruby (rbenv + zsh)
sudo chmod ugo-x /usr/libexec/path_helper
@stevenschobert
stevenschobert / disable_press_and_hold.sh
Created February 17, 2014 16:43
Turn off Apples "Press and Hold" keyboard option (for alt characters). Useful if you want key-repeat for letter characters.
# app-specific. replace BUNDLE_NAME with app bundle (ex: com.sublimetext.2)
defaults write BUNDLE_NAME ApplePressAndHoldEnabled -bool false
# global
defaults write -g ApplePressAndHoldEnabled -bool false
@stevenschobert
stevenschobert / Gemfile
Created February 20, 2014 19:57
Starter set of files for a simple rack app. Useful for quickly deploying static sites to something like Heroku, or using Pow for editing static sites.
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rack'
@stevenschobert
stevenschobert / filepath_regex
Last active August 29, 2015 13:58
My take on a filepath testing regular experession. Requires a relative or absolute path, and an extension. Excludes plain filenames.
^[\.+]*\/+.*\.[a-zA-Z0-9]+$
# Matches
/Users/stevenschobert/Documents/project/tmp/tmp-8205.txt
../somepath.txt
./sompat/h.d
./Something with spaces/word.txt
# Does not match
../sompath
@stevenschobert
stevenschobert / remove_not_created_today.sh
Created April 23, 2014 16:11
Remove files from directory not created today
grep -l -R -v "$(date '+%b %e')" * | xargs rm
@stevenschobert
stevenschobert / covert_dir_haml.sh
Created May 5, 2014 20:25
Convert a directory of Haml files.
find in/ -name '*.haml' | xargs basename -s .haml | xargs -I % bundle exec haml in/%.haml out/%.html
@stevenschobert
stevenschobert / crashlytics_run_optional.sh
Created October 7, 2014 21:15
Optional Crashlytics script for Xcode
testCrashlyticsPresent='try\n set crashlytics to application "Crashlytics"\n properties of crashlytics\non error errorMessage\n if errorMessage contains "application" then\n error\n else\n return true\n end if\nend try\n'
if $(echo $testCrashlyticsPresent | /usr/bin/osascript 2>/dev/null); then
./Crashlytics.framework/run CRASHLYTICS_KEY
else
echo "Crashlytics isn't installed. Skipping."
exit 0
fi
@stevenschobert
stevenschobert / app_exists.scpt
Created October 7, 2014 21:16
Tests if an application is installed on your system
try
set targetApp to application "APPNAME"
properties of targetApp
on error errorMessage
if errorMessage contains "application" then
error
else
return true
end if
end try