Skip to content

Instantly share code, notes, and snippets.

View majie1993's full-sized avatar

Jeff Ma majie1993

View GitHub Profile
@majie1993
majie1993 / HD.txt
Last active August 29, 2015 14:01 — forked from lexrus/HD.txt
WWDC 2013
http://devstreaming.apple.com/videos/wwdc/2013/710xfx3xn8197k4i9s2rvyb/710/710-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/202xdx2x47ezp1wein/202/202-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/200xdx2x35e1pxiinm/200/200-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/413xdx5x97itb5ek4yex3r7/413/413-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/612xax4xx65z1ervy5np1qb/612/612-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/221xex4xxohbllf4hblyngt/221/221-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/220xbx4xipaxfd1tggxuoib/220/220-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/711xcx4x8yuutk8sady6t9f/711/711-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/404xbx2xvp1eaaqonr8zokm/404/404-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/505xbx4xrgmhwby4oiwkrpp/505/505-HD.mov?dl=1
@majie1993
majie1993 / ocf-cc.py
Last active August 29, 2015 14:01 — forked from jjgod/ocf-cc.py
Traditional Chinese to Simplified Chinese
#!/usr/bin/env python
# Convert files in Open Container Format from Traditional Chinese
# to Simplified Chinese.
import sys, os, zipfile, re, codecs, subprocess
from xml.dom import minidom
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
debug = True
@majie1993
majie1993 / 0_reuse_code.js
Last active August 29, 2015 14:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@majie1993
majie1993 / UIImageView+loadGif.m
Created December 26, 2014 04:10
Display a GIF in UIImageView
//
// UIImageView+loadGif.m
// GifTest
//
// Created by WaterWood on 14-5-21.
#import "UIImageView+loadGif.h"
#import <QuartzCore/QuartzCore.h>
#import <ImageIO/ImageIO.h>
@majie1993
majie1993 / new_gist_file
Created December 26, 2014 04:12
Delete blank cell in the foot of UITableView
- (void)setExtraCellLineHidden: (UITableView *)tableView
{
UIView *view =[ [UIView alloc]init];
view.backgroundColor = [UIColor clearColor];
[tableView setTableFooterView:view];
[tableView setTableHeaderView:view];
}
sqlite3_stmt *statement = NULL;
sqlite3_prepare_v2(db, "SELECT strftime('%s', ?);", -1, &statement, NULL);
sqlite3_bind_text(statement, 1, [dateString UTF8String], -1, SQLITE_STATIC);
sqlite3_step(statement);
sqlite3_int64 interval = sqlite3_column_int64(statement, 0);
NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];
@majie1993
majie1993 / NSString_to_NSDate
Last active August 29, 2015 14:12
NSString to NSDate
int main(int argc, char *argv[]) {
@autoreleasepool {
NSString* dateString = @"2015/12/9 00:10:00";
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy/MM/dd hh:mm:ss"];
NSDate* date = [dateFormatter dateFromString:dateString];
NSString * updatedStr = [dateFormatter stringFromDate:date];
NSLog(@"time %@", updatedStr);
}
}
UIFont *font = [UIFont fontWithName:@"Helvetica" size:30];
NSDictionary *userAttributes = @{NSFontAttributeName: font,
NSForegroundColorAttributeName: [UIColor blackColor]};
NSString *text = @"hello";
...
const CGSize textSize = [text sizeWithAttributes: userAttributes];
SEL theSelector = NSSelectorFromString(@"setOrientation:animated:");
NSInvocation *anInvocation = [NSInvocation
invocationWithMethodSignature:
[MPMoviePlayerController instanceMethodSignatureForSelector:theSelector]];
[anInvocation setSelector:theSelector];
[anInvocation setTarget:theMovie];
UIInterfaceOrientation val = UIInterfaceOrientationPortrait;
BOOL anim = NO;
[anInvocation setArgument:&val atIndex:2];
+ (TZUser *)userWithUniqueUserId:(NSString *)uniqueUserId inManagedObjectContext:(NSManagedObjectContext *)context
{
TZUser *user = nil;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
request.entity = [NSEntityDescription entityForName:@"TZUser" inManagedObjectContext:context];
request.predicate = [NSPredicate predicateWithFormat:@"objectId = %@", uniqueUserId];
NSError *executeFetchError = nil;
user = [[context executeFetchRequest:request error:&executeFetchError] lastObject];