Skip to content

Instantly share code, notes, and snippets.

View atljeremy's full-sized avatar

Jeremy Fox atljeremy

View GitHub Profile
@atljeremy
atljeremy / makeSortedList.js
Created February 7, 2012 04:12
Javascript/HTML5 localStorage Object Sorting Function
//************************************************************************
// Author: Jeremy Fox
// Please Note: This function requires the underscore.js library
// You can get underscore.js here: http://documentcloud.github.com/underscore/
//
// Usage: Simply call the makeSortedList() function where you want the
// sorted list to be returned to. You will also need to specify which
// object property you would like to sort by. For example, if you have an
// object with properties "id", "name", "date", "price", "type", etc. You
// just need to specify which property you want to sort by where you see
@atljeremy
atljeremy / parseSpreadsheet.rb
Created April 6, 2012 19:03
Parse XLS Spreadsheet into Multi-Line Hash Using Ruby
# Required Gems
require "rubygems"
require "spreadsheet"
def getPixelTrackers
main=Hash.new
Spreadsheet.open('public/chart.xls') do |book|
book.worksheet('Sheet1').each do |row|
@atljeremy
atljeremy / ViewController.m
Created April 20, 2012 03:20
Project 3 AOC - ViewController.m - Full Sail
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
@atljeremy
atljeremy / ViewController.h
Created April 20, 2012 03:21
Project 3 AOC - ViewController.h - Full Sail
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UIAlertViewDelegate>
- (int) add:(int)num1 with:(int)num2;
- (BOOL) compare:(int)num1 with:(int)num2;
- (NSString*) append:(NSString*)string1 with:(NSString*)string2;
- (void) displayAlertWithString:(NSString*)string andTitle:(NSString*)title;
- (void)showStringDialog;
@atljeremy
atljeremy / git-auto-rebase-bash-function
Created October 23, 2012 20:18
git auto rebase bash function
git() { if [[ $@ == "pull" ]];
then command git pull --rebase;
elif [[ $@ == "pull origin dev" ]];
then command git pull --rebase origin dev;
elif [[ $@ == "pull origin master" ]];
then command git pull --rebase master;
else command git "$@";
fi;
}
@atljeremy
atljeremy / 0-readme.md
Last active December 21, 2015 03:09 — forked from crmaxx/0-readme.md

Amazon AWS EC2 production for Ruby on Rails

Prepare cloud

Speed up ssh login

echo 'UseDNS no # if slow connection' >> /etc/ssh/sshd_config
echo 'PrintMotd yes # if you need motd messages' >> /etc/ssh/sshd_config

From /etc/pam.d/login && /etc/pam.d/sshd delete all strings included

session optional pam_motd.so
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
API_TOKEN=<TestFlight API token here>
TEAM_TOKEN=<TestFlight team token here>
SIGNING_IDENTITY="iPhone Distribution: Development Seed"
PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/MapBox Ad Hoc.mobileprovision"
#LOG="/tmp/testflight.log"
@atljeremy
atljeremy / UIView Category For Rounding View's
Created December 5, 2013 14:33
A UIView Category for making round View's. Doesn't play nice with auto layout, for obvious reasons (direct frame manipulation).
@implementation UIView (Extras)
- (void)makeRound
{
self.contentMode = UIViewContentModeScaleAspectFill;
self.clipsToBounds = YES;
CGRect f = self.frame;
CGFloat w = CGRectGetWidth(f);
CGFloat h = CGRectGetHeight(f);
CGFloat corner = w;
@atljeremy
atljeremy / DownloadImageOperation
Last active January 2, 2016 09:39
DownloadImageOperation
@interface DownloadImageOperation() <NSURLConnectionDataDelegate, NSURLConnectionDelegate>
@property (nonatomic, strong) NSManagedObjectContext* innerMOC;
@property (nonatomic, strong, readwrite) PhotoID* photoID;
@property (nonatomic, strong) UIImage* downloadedImage;
@property (nonatomic, strong) NSURLConnection* connection;
@property (nonatomic, strong) NSMutableData* imageData;
@property (nonatomic, strong) NSDate* startedReceivingData;
@property (nonatomic, strong) NSDate* finishedReceivingData;
@property (nonatomic, strong) NSDictionary* responseHeaders;
@end
#Deploy and rollback on Heroku in staging and production
%w[staging production].each do |app|
desc "Deploy to #{app}"
task "deploy:#{app}" => %W[deploy:set_#{app}_app deploy:push deploy:restart deploy:tag]
desc "Deploy #{app} with migrations"
task "deploy:#{app}:migrations" => %W[deploy:set_#{app}_app deploy:push deploy:off deploy:migrate deploy:restart deploy:on deploy:tag]
desc "Rollback staging"