Skip to content

Instantly share code, notes, and snippets.

View chourobin's full-sized avatar

Robin Chou chourobin

View GitHub Profile
@chourobin
chourobin / dash_mux_service.conf
Last active August 29, 2015 13:57
Upstart script for nsq applications
description "dash_mux_service"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
limit nofile 50000 50000
respawn
respawn limit 10 5
pre-start script
@chourobin
chourobin / push_collision.m
Created April 28, 2014 14:06
Example using pan gestures and push collision
UIView *view = [panGesture view];
if (panGesture.state == UIGestureRecognizerStateBegan) {
self.collectionView.panGestureRecognizer.enabled = NO;
self.offsetY = view.frame.origin.y;
} else if (panGesture.state == UIGestureRecognizerStateBegan || panGesture.state == UIGestureRecognizerStateChanged)
{
CGPoint translation = [panGesture translationInView:[view superview]];
if (view.frame.origin.y <= 0 && translation.y < 0) {
return;
@chourobin
chourobin / macros.m
Last active August 29, 2015 14:00
iOS screen size macro
#define __IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define __IPHONE_OS_VERSION_MIN_REQUIRED
#define __IPHONE_OS_VERSION_MAX_ALLOWED
@chourobin
chourobin / ansible.md
Created May 8, 2014 19:43
Instructions for setting up ansible
@chourobin
chourobin / mac_setup.md
Created May 8, 2014 19:44
Setup instructions for new Mac
  1. Install Xcode
  2. Install Command Line Tools
  3. Install Homebrew
  4. Install Rbenv w/ Ruby
  5. Install NVM for Node.js & coffee-script

Apps:

  • Dropbox
  • Skydrive
  • Google Drive
var QcValueConverter = {
tensionFromQcValue: function(qcValue) {
return (qcValue - 30.0) * 3.62 + 194.0;
},
qcValueFromTension: function(tension) {
return (tension - 194.0) / 3.62 + 30.0;
},
frictionFromQcValue: function(qcValue) {
# NullStorage provider for CarrierWave for use in tests. Doesn't actually
# upload or store files but allows test to pass as if files were stored and
# the use of fixtures.
class NullStorage
attr_reader :uploader
def initialize(uploader)
@uploader = uploader
end
# encoding : utf-8
require 'openssl'
require 'digest/sha1'
require 'base64'
module Aws
extend self
def signed_url(path, expire_date)
digest = OpenSSL::Digest::Digest.new('sha1')
can_string = "GET\n\n\n#{expire_date}\n/#{S3_BUCKET}/#{path}"
@chourobin
chourobin / UINavigationController+Fade.h
Created July 25, 2012 18:33 — forked from ksm/UINavigationController+Fade.h
UINavigationController custom pop/push transition animation
/*
Copied and pasted from David Hamrick's blog:
Source: http://www.davidhamrick.com/2011/12/31/Changing-the-UINavigationController-animation-style.html
*/
@interface UINavigationController (Fade)
- (void)pushFadeViewController:(UIViewController *)viewController;
- (void)fadePopViewController;
@chourobin
chourobin / UIBarButtonItem+Additions
Created July 26, 2012 13:45
Custom UIBarButtonItem
@interface UIBarButtonItem(MyCategory)
+ (UIBarButtonItem*)barItemWithImage:(UIImage*)image target:(id)target action:(SEL)action;
@end
@implementation UIBarButtonItem(MyCategory)
+ (UIBarButtonItem*)barItemWithImage:(UIImage*)image target:(id)target action:(SEL)action{
// Move your item creation code here