Skip to content

Instantly share code, notes, and snippets.

@linktoming
linktoming / launchrock.css
Created April 6, 2012 11:08
LaunchRock Css
#lrcontent-4V2MA5IM{
background:rgba(0,105,255,0.8);
}
@linktoming
linktoming / gist:3826773
Created October 3, 2012 12:58
System Versioning Preprocessor Macros
/*
* System Versioning Preprocessor Macros
* http://stackoverflow.com/questions/3339722/check-iphone-ios-version/5337804#5337804
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
@linktoming
linktoming / gist:3971175
Created October 29, 2012 02:47 — forked from c0diq/gist:2213492
Automatic CFBundleVersion increment Build Pre-Action Scheme
#!/bin/bash
if [[ $CONFIGURATION == *Adhoc* ]]; then
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ${PROJECT_DIR}/${INFOPLIST_FILE})
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" ${PROJECT_DIR}/${INFOPLIST_FILE}
fi
@linktoming
linktoming / Xcode4HockeyAppTestFlightintegration.sh
Created October 29, 2012 02:48 — forked from c0diq/Xcode4HockeyAppTestFlightintegration.sh
Automatic TestFlight/HockeyApp Upload XCode Script
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
# Inspired by original script by incanus:
# https://gist.github.com/1186990
#
# Rewritten by martijnthe:
# https://gist.github.com/1379127
#
@linktoming
linktoming / Xcode4TestFlightintegration.sh
Created October 29, 2012 03:04 — forked from incanus/Xcode4TestFlightintegration.sh
Xcode 4 scheme Archive step Post-script for automatic TestFlight build uploading. See the blog post here: http://developmentseed.org/blog/2011/sep/02/automating-development-uploads-testflight-xcode
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
API_TOKEN=<TestFlight API token here>
TEAM_TOKEN=<TestFlight team token here>
SIGNING_IDENTITY="iPhone Distribution: Development Seed"
PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/MapBox Ad Hoc.mobileprovision"
#LOG="/tmp/testflight.log"
@linktoming
linktoming / RoundedRectLabel.h
Created October 30, 2012 08:57 — forked from digerata/RoundedRectLabel.h
Create a UILabel with a rounded rect background like in the iPhone Mail app. (Much faster than using UILabel.layer.cornerRadius)
//
// RoundedRectLabel.h
//
#import <UIKit/UIKit.h>
@interface CountLabel : UILabel {
NSInteger cornerRadius;
UIColor *rectColor;
}
@linktoming
linktoming / gist:3986189
Created October 31, 2012 10:00
Crop and Scale CGContext - iOS
//Crop and Scale CGContext - iOS
//http://pastebin.com/8xWrr1tv
- (void)modifyImage:(CMSampleBufferRef) sampleBuffer {
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
// Lock the image buffer
CVPixelBufferLockBaseAddress(imageBuffer,0);
// Get information about the image
uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer);
(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CellId" forIndexPath:[indexPath row]];
[[cell myButton] addTarget:self action:@selector(myClickEvent:event:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
-(NSString *)LunarForSolar:(NSDate *)solarDate{
//天干名称
NSArray *cTianGan = [NSArrayarrayWithObjects:@"甲",@"乙",@"丙",@"丁",@"戊",@"己",@"庚",@"辛",@"壬",@"癸", nil];
//地支名称
NSArray *cDiZhi = [NSArrayarrayWithObjects:@"子",@"丑",@"寅",@"卯",@"辰",@"巳",@"午",@"未",@"申",@"酉",@"戌",@"亥",nil];
//属相名称
NSArray *cShuXiang = [NSArrayarrayWithObjects:@"鼠",@"牛",@"虎",@"兔",@"龙",@"蛇",@"马",@"羊",@"猴",@"鸡",@"狗",@"猪",nil];
char *GetDayOf(PSYSTEMTIME pSt)
{
/*天干名称*/
const char *cTianGan[] = {"甲","乙","丙","丁","戊","己","庚","辛","壬","癸"};
/*地支名称*/
const char *cDiZhi[] = {"子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"};
/*属相名称*/
const char *cShuXiang[] = {"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"};