Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Yao Cheng alex-cellcity

  • CellCity Ltd.
  • Singapore
View GitHub Profile
View git build version
#!/bin/bash
release=`git tag | tail -n 1`
if [ -n release ]; then
release="1.0"
fi
build=`git log --oneline HEAD | wc -l | awk '{print $1 }'`
# build=`git log -n1 --date=short --format="%ad (%h)"`
# Shows 2012-04-24 (5fb42cb)
View zoomToFitMapAnnotations.m
- (void)zoomToFitMapAnnotations:(MKMapView *)mapView {
if ([mapView.annotations count] == 0) return;
int i = 0;
MKMapPoint points[[mapView.annotations count]];
//build array of annotation points
for (id<MKAnnotation> annotation in [mapView annotations])
points[i++] = MKMapPointForCoordinate(annotation.coordinate);
View ipaddress+gcd.m
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{
NSString *ipaddress = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://ifconfig.me/ip"] encoding:NSUTF8StringEncoding error:NULL];
dispatch_sync(dispatch_get_main_queue(), ^{
[response respondWith:ipaddress];
});
});
@alex-cellcity
alex-cellcity / UINavigationBar+Height.m
Created Sep 6, 2012
Customize UINavigationBar Height
View UINavigationBar+Height.m
#import "UINavigationBar+Height.h"
@implementation UINavigationBar (Height)
- (CGSize)sizeThatFits:(CGSize)size
{
CGSize newSize = CGSizeMake(self.frame.size.width, 70);
return newSize;
}
@alex-cellcity
alex-cellcity / NSDate+Age.h
Created Aug 7, 2012
Calculate age from NSDate
View NSDate+Age.h
//
// NSDate+Age.h
//
// Created by Alex Yao on 7/8/12.
// Copyright (c) 2012 alex@thecellcity.com. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSDate (Age)
@alex-cellcity
alex-cellcity / Gemfile
Created Aug 3, 2012
Gemfile for tnpfk api
View Gemfile
source 'http://rubygems.org'
gem 'actionmailer', '2.3.8'
gem 'actionpack', '2.3.8'
gem 'activerecord', '2.3.8'
gem 'activeresource', '2.3.8'
gem 'activesupport', '2.3.8'
gem 'addressable', '2.2.6'
gem 'akami', '1.0.0'
gem 'apns', '0.9.0'
@alex-cellcity
alex-cellcity / ShareKit.podspec
Created Jul 30, 2012
Sharekit.podspec + Fix Twitter weak_framework
View ShareKit.podspec
Pod::Spec.new do |s|
s.name = 'ShareKit'
s.version = '2.0'
s.platform = :ios
s.summary = 'Drop in sharing features for all iPhone and iPad apps.'
s.homepage = 'http://getsharekit.com/'
s.author = 'ShareKit Community'
s.source = { :git => 'https://github.com/ShareKit/ShareKit.git', :commit => 'b8129c7c229a383ea5926aaa7869aadbccb71e8f' }
s.license = { :type => 'MIT',
:text => %Q|Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n| +
@alex-cellcity
alex-cellcity / ShareKit.podspec
Created Jul 30, 2012
Sharekit.podspec + Fix Twitter weak_framework
View ShareKit.podspec
twitter.source_files = 'Classes/ShareKit/Sharers/Services/Twitter/**/*.{h,m}'
twitter.weak_framework = 'Twitter'
twitter.dependency 'JSONKit'
@alex-cellcity
alex-cellcity / SVWebViewController.podspec
Created Jul 30, 2012
SVWebViewController.podspec MRC Version
View SVWebViewController.podspec
Pod::Spec.new do |s|
s.name = 'SVWebViewController'
s.version = '0.1'
s.summary = 'A drop-in inline browser for your iOS app.'
s.homepage = 'https://github.com/samvermette/SVWebViewController'
s.author = { 'Sam Vermette' => 'http://samvermette.com' }
s.source = { :git => 'https://github.com/samvermette/SVWebViewController.git',
:commit => '3044698e210318cca7d9acf5b2ca3394ea389723' }
s.platform = :ios
s.source_files = 'SVWebViewController/*.{h,m}'
@alex-cellcity
alex-cellcity / league.json
Created Apr 3, 2012
example of League data
View league.json
[
{
"team":"JSSL Walcott",
"pos":"1",
"P":"13",
"W":"11",
"D":"2",
"L":"0",
"GF":"74",
"GA":"3",