Skip to content

Instantly share code, notes, and snippets.

View marcuswestin's full-sized avatar

Marcus Westin marcuswestin

  • New York
View GitHub Profile
@marcuswestin
marcuswestin / gist:8368115
Last active January 2, 2016 22:09
git rebase workflow

(use git rebase -i)

  1. Pull master

git checkout master
git fetch origin && git merge master # or, `git pull origin master`
  1. Create feature branch

#import <UIKit/UIKit.h>
@interface UIView (Blur)
- (void)blur;
- (void)blur:(CGSize)size;
@end
@marcuswestin
marcuswestin / UINavigationBar-multiple-buttons-fix-positioning.m
Created December 5, 2013 02:58
Multiple UINavigationBar buttons with corrected positioning.
UIButton* left = [UIButton.styler.h(44) onTap:^(UIEvent *event) {
[Overlay showMessage:@"Me"];
}];
[UIImageView.appendTo(left).image([UIImage imageNamed:@"img/Me"]).xy(-10, 2) render];
UIButton* right = [UIButton.styler.wh(88,44) render];
CGFloat offsetRight = 26;
UIView* compose = [UIImageView.appendTo(right).image([UIImage imageNamed:@"img/Compose"]).fromRight(6) render];
UIView* search = [UIImageView.appendTo(right).image([UIImage imageNamed:@"img/Search"]).leftOf(compose, 0) render];
[right onTap:^(UIEvent *event) {
@marcuswestin
marcuswestin / iOSGetColorOfDevice.m
Created November 20, 2013 22:30
Get color of iOS device
UIDevice *device = [UIDevice currentDevice];
SEL selector = NSSelectorFromString(@"deviceInfoForKey:");
if (![device respondsToSelector:selector]) {
selector = NSSelectorFromString(@"_deviceInfoForKey:");
}
if ([device respondsToSelector:selector]) {
NSLog(@"DeviceColor: %@ DeviceEnclosureColor: %@", [device performSelector:selector withObject:@"DeviceColor"], [device performSelector:selector withObject:@"DeviceEnclosureColor"]);
}
@marcuswestin
marcuswestin / InstallPostgresApp.sh
Created November 14, 2013 21:06
Download & start postgres app for OSX
mkdir /tmp/postgresdl
cd /tmp/postgresdl
curl -L http://postgresapp.com/download > dl.zip
unzip dl.zip
mv Postgres*.app /Applications/
open /Applications/Postgres*.app
rm -rf /tmp/postgresdl
@marcuswestin
marcuswestin / fabfile.py
Last active December 26, 2015 11:19
Base fabfile.py constructs
from fabric.api import local, run, put, env, sudo, cd, lcd, settings
env.user = 'ubuntu'
env.key_filename = './private-key.pem'
isLocal = False
go = lcd if isLocal else cd
do = local if isLocal else run
sudo_do = local if isLocal else sudo
@marcuswestin
marcuswestin / Makefile
Created October 24, 2013 18:45
Makefile for phantomjs
PHANTOMJS = /usr/local/bin/phantomjs
${PHANTOMJS}:
echo "\n\n*** Installing phantomjs to ${PHANTOMJS}\n****************************************************\n\n"
rm -rf /tmp/phantomjs-1.6.1-macosx-static*
curl http://phantomjs.googlecode.com/files/phantomjs-1.6.1-macosx-static.zip > /tmp/phantomjs-1.6.1-macosx-static.zip
cd /tmp && unzip /tmp/phantomjs-1.6.1-macosx-static.zip
cp /tmp/phantomjs-1.6.1-macosx-static/bin/phantomjs ${PHANTOMJS}
test-foo.js: ${PHANTOMJS}
@marcuswestin
marcuswestin / python-3-install-no-sigaltstack.sh
Created October 23, 2013 19:57
Install Python 3 without SIGALTSTACK
mkdir -p python-3-install-no-sigaltstack
cd python-3-install-no-sigaltstack
curl http://www.python.org/ftp/python/3.3.2/Python-3.3.2.tar.bz2 > Python-3.3.2.tar.bz2
tar -xzvf Python-3.3.2.tar.bz2
cd Python-3.3.2
./configure
sed -i .bak 's/#define HAVE_SIGALTSTACK 1/\/* #undef HAVE_SIGALTSTACK *\//' pyconfig.h
rm pyconfig.h.bak
@marcuswestin
marcuswestin / generate-iOS-app-icons.sh
Created October 9, 2013 20:09
Generate all xcode 5 app icon sizes from one original large icon
mkdir -p generated
sips -Z 29 --out generated/iPhoneSettings-29x29.png sourceIcon.png
sips -Z 58 --out generated/[email protected] sourceIcon.png
sips -Z 80 --out generated/[email protected] sourceIcon.png
sips -Z 120 --out generated/[email protected] sourceIcon.png
sips -Z 29 --out generated/iPadSettings-29x29.png sourceIcon.png
sips -Z 58 --out generated/[email protected] sourceIcon.png
sips -Z 40 --out generated/iPadSpotlight-40x40.png sourceIcon.png
@marcuswestin
marcuswestin / gist:6692308
Created September 24, 2013 22:36
List of all methods and properties available to UIAppearance manipulation in iOS7
UIBarButtonItem.h
-(void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics
(UIImage *)backgroundImageForState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics
(void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state style:(UIBarButtonItemStyle)style barMetrics:(UIBarMetrics)barMetricsUI_APPEARANCE_SELECTOR;
(UIImage *)backgroundImageForState:(UIControlState)state style:(UIBarButtonItemStyle)style barMetrics:(UIBarMetrics)barMetrics
(void)setBackgroundVerticalPositionAdjustment:(CGFloat)adjustment forBarMetrics:(UIBarMetrics)barMetrics
(CGFloat)backgroundVerticalPositionAdjustmentForBarMetrics:(UIBarMetrics)barMetrics
(void)setTitlePositionAdjustment:(UIOffset)adjustment forBarMetrics:(UIBarMetrics)barMetrics
(UIOffset)titlePositionAdjustmentForBarMetrics:(UIBarMetrics)barMetrics
(void)setBackButtonBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics