Skip to content

Instantly share code, notes, and snippets.

View sugarmo's full-sized avatar
🏠
Working from home

Steven Mok sugarmo

🏠
Working from home
View GitHub Profile
@sugarmo
sugarmo / gist:987f9b058d0b23747ebb
Created May 14, 2014 09:18
Force Device to Rotate
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), newOrientation);
}
@sugarmo
sugarmo / rebuild-mac-os-x-lauchservices.sh
Last active December 15, 2015 13:39
Rebuild Mac OS X LauchServices
$ /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
@sugarmo
sugarmo / gist:5360862
Last active December 16, 2015 02:09
Various Parameters Method in Obj-C
- (void)method:(id)obj1,...
{
va_list args;
void *arg;
va_start(args,obj1);
while((arg = va_arg(args, void *)))
{
// Now you can use arg. This will only work when all arguments are objects.
@sugarmo
sugarmo / Doxygenize.rb
Last active December 16, 2015 14:29
a script for Mac service that can comment code automatically.
#! /usr/bin/ruby
#
# This script helps us make doxygen comments in obj-c files in Xcode
#
# Created by Fred McCann on 03/16/2010.
# http://www.duckrowing.com
#
module Duckrowing
@sugarmo
sugarmo / theme.css
Created May 10, 2013 16:52
my tumblr's theme
code, tt {
margin: 0 2px;
padding: 0 5px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px;
}
pre code {
@sugarmo
sugarmo / Mac Development Environment.md
Last active December 21, 2015 00:18
Mac Development Environment

Command Line tools

brew

mysql

node

rvm

@sugarmo
sugarmo / center zooming view.m
Last active December 21, 2015 16:29
Center zooming view in scroll view -layoutSubview.
- (void)layoutSubviews {
[super layoutSubviews];
// center the image as it becomes smaller than the size of the screen
CGSize boundsSize = self.bounds.size;
CGRect frameToCenter = self.imageView.frame;
// center horizontally
if (frameToCenter.size.width < boundsSize.width) {
frameToCenter.origin.x = (boundsSize.width - frameToCenter.size.width) / 2;
} else {
frameToCenter.origin.x = 0;
@sugarmo
sugarmo / Info.plist
Created August 31, 2013 04:20
发布破解包要添加的字段
<key>SignerIdentity</key>
<string>Apple iPhone OS Application Signing</string>
@sugarmo
sugarmo / warn-for-todo-or-fixme-comments.sh
Created October 9, 2013 09:19
Warn for TODO or FIXME comments.
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" -ipath "${SRCROOT}/pods" -prune -o \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
@sugarmo
sugarmo / GitHub Ver.Mok.css
Created October 12, 2013 02:58
GitHub css for Mou app.
body {
font-family: Helvetica, arial, freesans, clean, sans-serif;
font-size: 15px;
line-height: 1.7;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {