Skip to content

Instantly share code, notes, and snippets.

View atljeremy's full-sized avatar

Jeremy Fox atljeremy

View GitHub Profile
@atljeremy
atljeremy / gist:e375618420b0c6d9b0dae56afd3ccb7e
Created September 19, 2016 16:33
Rails Request Headers
applicationID: #<ActionDispatch::Http::Headers:0x007f97a82499a0 @req=#<ActionDispatch::Request:0x007f97a2b4a820 @env={"rack.version"=>[1, 3], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"puma 3.6.0 Sleepy Sunday Serenity", "GATEWAY_INTERFACE"=>"CGI/1.2", "REQUEST_METHOD"=>"GET", "REQUEST_PATH"=>"/v1/buildings/18906/", "REQUEST_URI"=>"/v1/buildings/18906/", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_HOST"=>"localhost:3000", "HTTP_USER_AGENT"=>"curl/7.43.0", "HTTP_ACCEPT"=>"*/*", "HTTP_XAPPLICATIONID"=>"ag/iphone", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "PATH_INFO"=>"/v1/buildings/18906", "REMOTE_ADDR"=>"::1", "puma.socket"=>#<TCPSocket:fd 33>, "rack.hijack?"=>true, "rack.hijack"=>#<Puma::Client:0x3fcbd4824814 @ready=true>, "rack.input"=>#<Puma::NullIO:0x007f97a548e330>, "rack.url_scheme"=>"http", "rack.after_reply"=>[], "puma.config"=>#<Puma::Configuration
@atljeremy
atljeremy / DateUtils.swift
Last active March 26, 2017 18:47
Swift extension on NSTimeInterval and NSDate to make NSDate Comparable and to make working with dates in general more concise
/*
Examples:
var date: NSDate
date = 10.seconds.fromNow
date = 30.minutes.ago
date = 2.days.from(someDate)
date = NSDate() + 3.days
if dateOne < dateTwo {
@atljeremy
atljeremy / UIView.swift
Created December 30, 2014 17:03
Swift UIView Extension for Rounding Views
//
// UIView.swift
// Kidsay
//
// Created by Jeremy Fox on 12/19/14.
// Copyright (c) 2014 Jeremy Fox. All rights reserved.
//
import UIKit
#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"
@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
@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;
#!/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 / 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
@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 / 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;