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 / 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:5334805
Last active April 14, 2021 19:42
Convert .json file to .plist file
plutil -convert xml1 in.json -o out.plist
@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 / json-to-plist.sh
Last active December 6, 2020 03:06
A shell script for Automator that can convert JSON to .plist file.
for f in "$@"
do
filename="${f%.*}"
plutil -convert xml1 "$filename".json -o "$filename".plist
done
@sugarmo
sugarmo / embed-github-things.md
Last active January 11, 2024 03:44
Embed Github Things (geoJSON, 3D model)

Embedding your geoJSON map elsewhere

<script src="https://embed.github.com/view/geojson/<username>/<repo>/<ref>/<path_to_file>"></script>

Embedding your 3D model elsewhere

@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>