Skip to content

Instantly share code, notes, and snippets.

@sprhawk
sprhawk / gist:2779208
Created May 24, 2012 03:06
git diff localizable.strings
(from :http://www.entropy.ch/blog/Developer/2010/04/15/Git-diff-for-Localizable-strings-Files.html)
First, add this to the project’s .git/info/attributes file:
+
*.strings diff=localizablestrings
(Unfortunately you do have to add it to every project, there doesn’t seem to be a global attributes configuration file)
Second, add this to your ~/.gitconfig file:
@sprhawk
sprhawk / gist:2779210
Created May 24, 2012 03:07
git co ours or theirs
git checkout --ours -- path/to/file.txt
git checkout --theirs -- path/to/file.txt
@sprhawk
sprhawk / gist:3293174
Created August 8, 2012 07:33
my git config
[core]
excludesfile = .global_gitignore
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
ll = log --name-status
[diff "localizablestrings"]
@sprhawk
sprhawk / gist:3523472
Created August 30, 2012 06:49
UIGestureRecognizer
if (UIGestureRecognizerStateRecognized == gesture.state) {
}
在识别touch时忽略掉某些子view的response
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([touch.view isDescendantOfView:loginButton]) {
return NO;
}
NSArray * strings = [text componentsSeparatedByString:@"@"];
if([strings count] == 2) {
NSString * string = [strings objectAtIndex:0];
NSCharacterSet * set = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.-"];
set = [set invertedSet];
if ([string length]) { //@之前不是空字串
range = [string rangeOfCharacterFromSet:set];
if (NSNotFound == range.location) { //只包含合法字符
string = [strings objectAtIndex:1];
if ([string length]) { //@之后不是空字串
<canvas id="canvas" style="position:absolute; top:0; left:0;"></canvas>
<div id="buffer" style="display:none;">
@sprhawk
sprhawk / gist:9995088
Created April 5, 2014 17:30
rsync between my macs
rsync -O -vvv -C -ruN --size-only -h --progress --exclude="xcuserdata" --exclude="*.xcworkspace" --exclude=".DS_Store" Docs/ xxxxxx.local::docs
import (
"runtime"
)
_, file, num, _ := runtime.Caller(2)