Skip to content

Instantly share code, notes, and snippets.

# Cleaner invocation of presenter on collection
current_user.tickets.map(&TicketPresenter.method(:new))
@AquaGeek
AquaGeek / install_profiles.rb
Created January 11, 2013 16:17
Provisioning Profiles
#!/usr/bin/env ruby
require 'FileUtils'
# Grab all of the profiles in [REPO]/Deployment/Provisioning and copy them to /Library/MobileDevice/Provisioning Profiles
DEPLOYMENT_DIR = File.join(ENV['PROJECT_DIR'], '..', '..', 'Deployment')
def install_provisioning_profile(profile)
raise "File not found" unless File.exists?(profile)
@AquaGeek
AquaGeek / New Project Setup.sh
Last active December 10, 2015 18:38
Postgres
# Create the user
createuser -P --interactive # Enter the values asked
# Create the DBs
createdb -O {username created above} {database name}
# Install pg gem
bundle config build.pg --with-pg-config={path to pg_config}
bundle install
@AquaGeek
AquaGeek / .bash_profile
Last active December 10, 2015 15:38
Bash Profile
# Helpful shortcuts
alias gs='clear && git status'
alias git-count='git shortlog -sn'
alias pbsort='pbpaste | sort | pbcopy'
# From @nvie coderwall.com/p/4tkkpq
alias map="xargs -n1"
# Git in prompt
# From: https://gist.github.com/738048
@AquaGeek
AquaGeek / UIImage+Retina4.h
Created November 20, 2012 21:24
iPhone 5 image support
//
// UIImage+Retina4.h
// StunOMatic
//
// Created by Benjamin Stahlhood on 9/12/12.
// Copyright (c) 2012 DS Media Labs. All rights reserved.
//
#import <UIKit/UIKit.h>
@AquaGeek
AquaGeek / keychain.m
Created October 22, 2012 21:28
Keychain
- (BOOL)checkKeychainForAuthCredentials
{
NSMutableDictionary *keychainQuery = [self keychainSearchDictionary];
// Fire off the query
OSStatus keychainErr = noErr;
CFDictionaryRef outDictionary;
keychainErr = SecItemCopyMatching((__bridge CFDictionaryRef)keychainQuery, (CFTypeRef *)&outDictionary);
@AquaGeek
AquaGeek / git.sh
Last active October 7, 2015 00:48
Useful git tricks
# Get a list of changes in a given range, grouped by author
git shortlog {starting ref}..{ending ref}
# ... sorted by most commits per author
git shortlog -n {starting ref}..{ending ref}
# Get a list of branches that have been merged into the given branch (defaults to HEAD), but not deleted
git branch --merged {branch}
# ... on a given remote
@AquaGeek
AquaGeek / Ideas.md
Created July 9, 2012 20:20
iOS discussions

iOS Discussion Topics

  1. Application lifecycle
    • main()
    • Run loop
    • Initializing from Storyboard vs nib vs manually
  2. Event handling
    • -[UIApplication sendEvent:]
    • App "screen saver"
  • Hooking up buttons to firstResponder
@AquaGeek
AquaGeek / Gemfile.rb
Created June 20, 2012 02:38
Git pre receive hooks
#!/usr/bin/env ruby
# From: http://rand9.com/blog/git-pre-receive-hook-for-rejecting-a-bad-gemfile/
BRANCHES = %w( master stable )
REJECT_OPTIONS = %w( git tag branch path )
old_sha, new_sha, ref = STDIN.read.split(' ')
exit 0 unless BRANCHES.include?(ref.split('/').last)
diff = %x{ git diff-index --cached --name-only #{old_sha} 2> /dev/null }
@AquaGeek
AquaGeek / APIClient.h
Created May 1, 2012 17:08
AFNetworking with XML request body
#import <Foundation/Foundation.h>
#import "AFHTTPClient.h"
@interface APIClient : AFHTTPClient
+ (APIClient *)sharedClient;
@end