Skip to content

Instantly share code, notes, and snippets.

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

Lucas Zhang marshluca

🏠
Working from home
View GitHub Profile
@fguillen
fguillen / git_tips.md
Created December 19, 2010 20:53
Git Tips

(Several of these git examples have been extracted from the book 'Pragmatic guide to GIT' of Travis Swicegood )

Git tips

Global git user

git config --global user.name "Fernando Guillen"
git config --global user.email "[email protected]"

Repository git user

cd /develop/myrepo

@marshluca
marshluca / MUtiliity.m
Created December 17, 2010 04:32
MUtility
//
// MUtility.m
// Magazine
//
// Created by wang xuefeng on 10-12-9.
// Copyright 2010 www.5yi.com. All rights reserved.
//
#import "MUtility.h"
#import "MFoundation.h"
@marshluca
marshluca / NSUserDefaults.m
Created December 17, 2010 02:00
persistence
NSDictionary *magazineDict = [NSDictionary dictionary];
[[NSUserDefaults standardUserDefaults] registerDefaults:magazineDict];
// write data to /Library/Preferences.
[[NSUserDefaults standardUserDefaults] synchronize];
@marshluca
marshluca / NSHTTPCookie.m
Created December 16, 2010 06:33
Handle NSHTTPCookieStorage
for (NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
@marshluca
marshluca / FadeAnimation.m
Created December 11, 2010 10:00
视图切换效果, slide, fade, flip
- (void) fadeOut: (id) sender
{
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[[self.view viewWithTag:999] setAlpha:0.0f];
[UIView commitAnimations];
self.navigationItem.rightBarButtonItem = BARBUTTON(@"Fade In", @selector(fadeIn:));
}
@marshluca
marshluca / douban_oauth.rb
Created December 10, 2010 10:21
豆瓣OAuth认证
# Douban OAuth认证包括以下四步内容
# 1. 获取Request Token
# 2. 用户确认授权
# 3. 换取Access Token
# 4. 访问受限资源
require "rubygems"
gem 'oauth','0.4.3'
require 'oauth'
@marshluca
marshluca / oauth_process.rb
Created December 10, 2010 08:52
新浪微薄的OAuth 1.0认证
# OAuth认证包括以下四步内容
# 1. 获取Request Token
# 2. 用户确认授权
# 3. 换取Access Token
# 4. 访问受限资源
require 'rubygems'
gem 'oauth','0.4.3'
require 'oauth'
@marshluca
marshluca / appDelegate.m
Created December 9, 2010 02:05
Splash in iOS
1. 将你需要的splash界面的图片,存成Default.png
2. 在XXXAppDelegate.m程序中,插入如下代码:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//–insert a delay of 5 seconds before the splash screen disappears–
[NSThread sleepForTimeInterval:5.0];
// Override point for customization after application launch.
// Add the view controller’s view to the window and display.
[window addSubview:viewController.view];
@marshluca
marshluca / DragView.m
Created December 8, 2010 04:12
移动到新的位置
#import <UIKit/UIKit.h>
@interface DragView : UIImageView
{
CGPoint startLocation;
}
@end
@implementation DragView
@marshluca
marshluca / getContact.m
Created November 29, 2010 08:32
获取iPhone联系人
- (void)getContactList
{
ABAddressBookRef addressBook = ABAddressBookCreate();
NSMutableArray *peopleArray = (NSMutableArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
for (id *people in peopleArray)
{
// phone
ABMultiValueRef phones = (ABMultiValueRef) ABRecordCopyValue(people, kABPersonPhoneProperty);
int nCount = ABMultiValueGetCount(phones);