Skip to content

Instantly share code, notes, and snippets.

@bgerstle
bgerstle / jswarrior
Created October 5, 2013 16:05
Beat JS Warrior!
var extensions = {
low_hp: 9,
check_actions: {
'enemy': 'attack',
'diamond': 'collect'
},
check_and_act: function (direction) {
var status = this.check(direction);
if(this.check_actions.hasOwnProperty(status)) {
var method = this.check_actions[status];
@bgerstle
bgerstle / custom CALayer property animation
Created October 17, 2013 20:53
Animating a custom property of a CALayer subclass
@implementation PXScrubberView
+ (Class)layerClass
{
return [PXScrubberLayer class];
}
- (void)setFillHeight:(float)fillHeight animated:(BOOL)animated
{
if (animated) {
@bgerstle
bgerstle / login.feature
Created November 22, 2013 04:01
Example cucumber test
Feature: Authentication
As a user
I can use my credentials
So I can login to the app
And be remembered when the app launches
And log out of the app
Scenario: Email and password submit using keyboard
Given the app is clean
And I am on the Login Screen
@bgerstle
bgerstle / Login.rb
Created November 22, 2013 04:07
Example cucumber step definitions
Given /^I am on the Login Screen$/ do
# login becomes visible
wait_for_elements_exist(["view marked:'login view'"])
# fields fade in
wait_for_elements_exist(["textField marked:'username field'"])
check_element_exists("textField marked:'password field'")
# TODO: add checks to make sure loading indicator and error box aren't visible
sleep(STEP_PAUSE)
end
@bgerstle
bgerstle / ExampleAppledoc.h
Created January 9, 2014 22:35
Example of various appledoc commenting styles
//------------------------------
// The method we're documenting:
//------------------------------
- (BOOL)maybeDoWork:(dispatch_block_t)something;
//-------------------------------------------------------------------------------------------
/**
* @brief You just called me, and this is crazy. But here's a `BOOL`, I did work maybe?
@bgerstle
bgerstle / .vimrc
Created February 9, 2014 20:21
Automatic ruby syntax & filetype detection for Cocoapods files in vim
" Automatic commands
if has("autocmd")
" Enable file type detection
filetype on
" Recognize the following as Ruby files
autocmd BufNewFile,BufRead *.podspec set filetype=ruby syntax=ruby
autocmd BufNewFile,BufRead Podfile set filetype=ruby syntax=ruby
endif
@bgerstle
bgerstle / Ruby.sublime-settings
Last active August 29, 2015 13:56
Automatic Ruby syntax & filetype detection for Cocoapods files in Sublime Text
{
"extensions":
[
"Podfile",
"podspec"
]
}
@bgerstle
bgerstle / git_filter_files
Last active August 29, 2015 13:56
Rewrite git history by removing everything except desired files, which are represented by a line-separated list of regex patterns in ~/file_patterns.
git filter-branch --tree-filter \
'find . \
\( -name ".gitignore" -o -path "./.git*" \) -prune -o \
\( -type f -o -type l \) -exec echo \"{}\" ";" \
| grep -vE -f ~/file_patterns \
| xargs rm \
&& find . -empty -delete' \
--prune-empty HEAD
# 1: rewrite git history by running the following command for each commit
@bgerstle
bgerstle / mv_impl_files
Created February 14, 2014 03:00
`git mv` all *.{h,m} files which aren't in the "Project-X/Tests/" folder into "Classes/"
find . \( -name "*.h" -o -name "*.m" \) -not -path ./Project-X/Tests/\* -exec git mv {} Classes/ \;
@bgerstle
bgerstle / rm_empty_dir
Last active August 29, 2015 13:56
Delete all empty directories (except those in ".git")
find . -empty -not -path "./.git*" -delete