Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>upload5</title>
<script src="jquery-1.4.3.js"></script>
</head>
@darcyliu
darcyliu / gist:930669
Created April 20, 2011 08:04
auto center
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>auto center</title>
<style>
.box{
width: 500px;
border: 2px solid #777;
padding: 5px;
@darcyliu
darcyliu / gist:931733
Created April 20, 2011 15:52
Google Page Rank
#!/usr/bin/env python
#
# Script for getting Google Page Rank of page
# Google Toolbar 3.0.x/4.0.x Pagerank Checksum Algorithm
#
# original from http://pagerank.gamesaga.net/
# this version was adapted from http://www.djangosnippets.org/snippets/221/
# by Corey Goldberg - 2010
#
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
//
// NSString+Split.h
// Categories
//
// Created by Darcy Liu on 6/17/12.
// Copyright (c) 2012 Close To U. All rights reserved.
//
#import <Foundation/Foundation.h>
@darcyliu
darcyliu / Singleton.h
Created August 18, 2012 06:56
Objective-C Singleton Demo
#import <Foundation/Foundation.h>
@interface Singleton : NSObject
+(Singleton*)sharedSingleton;
-(void)sayHello;
@end
@darcyliu
darcyliu / gist:4498998
Created January 10, 2013 02:49
Delete Unversioned Files Under SVN
#Show Unversioned Files
svn status --no-ignore | grep '^\?' | sed 's/^\? //'
#Delete Unversioned Files
svn status --no-ignore | grep '^\?' | sed 's/^\? //' | xargs -Ixx rm -rf xx
#via http://www.guyrutenberg.com/2008/01/18/delee-unversioned-files-under-svn/
@darcyliu
darcyliu / gist:4499023
Created January 10, 2013 02:55
svn global ignores for xcode
#vim ~/.subversion/config
global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
*.rej *~ #*# .#* .*.swp .DS_Store *.xcuserdatad
@darcyliu
darcyliu / gist:5496717
Created May 1, 2013 17:20
Core Data Snippets
//1 Creating a New Managed Object Context
//To create a new managed object context, you need a persistent store coordinator.
NSPersistentStoreCoordinator *psc = <#Get the coordinator#>;
NSManagedObjectContext *newContext = [[NSManagedObjectContext alloc] init];
[newContext setPersistentStoreCoordinator:psc];
//using the same coordinator as the existing one
NSManagedObjectContext *context = <#Get the context#>;
NSPersistentStoreCoordinator *psc = [context persistentStoreCoordinator];
NSManagedObjectContext *newContext = [[NSManagedObjectContext alloc] init];
@darcyliu
darcyliu / start_memcached.sh
Created August 6, 2013 14:43
start/stop memcached
memcached -d -l 127.0.0.1 -p 11211 -m 64
@darcyliu
darcyliu / gist:6326095
Created August 24, 2013 04:38
UIMotionEffect Demo
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame = self.view.bounds;
for (NSInteger i=0; i<10; i++) {
CGFloat left = (frame.size.width-100)/2+i%2*10;
CGFloat top = (frame.size.height-100)/2+i%3*10;