Skip to content

Instantly share code, notes, and snippets.

View sonsongithub's full-sized avatar

Yuichi Yoshida sonsongithub

View GitHub Profile
@sonsongithub
sonsongithub / NSString+hoge.m
Created October 18, 2011 14:31
Why html tags won't be removed....?
@implementation NSString(hoge)
- (NSMutableString*)stringByEliminatingHTMLTag {
int i = 0;
NSMutableString* str = [NSMutableString string];
UniChar *p = (UniChar*)CFStringGetCharactersPtr((CFStringRef)self);
int length = [self length];
BOOL isCopied = NO;
@sonsongithub
sonsongithub / NSLog+test.m
Created October 18, 2011 15:08
ちょwwwwwwwwwwwNSLogのバグとかwwwwwwwwwwwwww
NSString *sample = @"<font size=+1 color=#FF0000><b>書きこみ&クッキー確認</b></font><ul><br><br><b> </b><br>名前: <br>E-mail: sage<br>内容:<br>sage<br><br></ul><b>投稿確認<br>・投稿者は、投稿に関して発生する責任が全て投稿者に帰すことを承諾します。<br>・投稿者は、話題と無関係な広告の投稿に関して、相応の費用を支払うことを承諾します<br>21条ないし第28<br>対して再許諾する権利を含みます)を許諾しないことを承諾します。<br>投稿者は、掲示板運営者あるいはその指定する者に対して、著作者人格権を一切行使しないことを承諾します。<br><br></b><form method=POST action=\"../test/bbs.cgi?guid=ON\"><input type=hidden name=subject value=\"\"><input TYPE=hidden NAME=FROM value=\"\"> <input TYPE=hidden NAME=mail value=\"sage\"><input type=hidden name=MESSAGE value=\"sage\"><input type=hidden name=bbs value=newsplus><input type=hidden name=time value=1318941809><input type=hidden name=key value=1318932938><input type=hidden name=\"kibi\" value=\"dango\"><br><input type=submit value=\"上記全てを承諾して書き込む\" name=\"submit\"><br></form><br><br>現在、荒らし対策でクッキーを設定していないと書きこみできないようにしています。<br><font size=-1>(cookieを設定するとこの画面はでなくなります。)</font><br>";
NSLog(@"%@", sample);
@sonsongithub
sonsongithub / gist:2822226
Created May 29, 2012 02:45
Xcode "Run script" for auto updating subversion revision and build number.
svn update .
revisionNumber=$(svnversion -n)
/usr/libexec/PlistBuddy -c "Set :CFBundleSubversionRevision $revisionNumber" "$INFOPLIST_FILE"
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
@sonsongithub
sonsongithub / gist:2822231
Created May 29, 2012 02:47
Xcode "Run script" sample for auto localizing Storyboard files.
# make iPhone's storyboard file for Japanese
ibtool --generate-stringsfile $SRCROOT/Resources/Japanese.lproj/MainStoryboard_iPhone.storyboard.string --import-strings-file $SRCROOT/Resources/Japanese.lproj/MainStoryboard_iPhone.storyboard.string $SRCROOT/Resources/English.lproj/MainStoryboard_iPhone.storyboard
ibtool --write $SRCROOT/Resources/Japanese.lproj/MainStoryboard_iPhone.storyboard -d $SRCROOT/Resources/Japanese.lproj/MainStoryboard_iPhone.storyboard.string $SRCROOT/Resources/English.lproj/MainStoryboard_iPhone.storyboard
@sonsongithub
sonsongithub / gist:2868639
Created June 4, 2012 14:11
Parse Xcode project file, project.pbxproj, in Ruby.
json = JSON.parse(`plutil -convert json -o - "#{filename}"`)
@sonsongithub
sonsongithub / gist:3196234
Created July 29, 2012 05:29
Automatically update build number and subversion revision of Info.plist.
# update subversion revision
svn update .
revisionNumber=$(svnversion -n)
revisionNumber=$(echo $revisionNumber | sed 's/:[0-9M]*//')
revisionNumber=$(echo $revisionNumber | sed 's/M//')
/usr/libexec/PlistBuddy -c "Set :CFBundleSubversionRevision $revisionNumber" "$INFOPLIST_FILE"
# update build number
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
@sonsongithub
sonsongithub / gist:3346502
Created August 14, 2012 05:15
Automatically update build number and github revision of Info.plist.
# update github revision
hash=$(git rev-parse HEAD)
/usr/libexec/PlistBuddy -c "Set :CFBundleGithubRevision $hash" "$INFOPLIST_FILE"
shorthash=$(git rev-parse --short HEAD)
/usr/libexec/PlistBuddy -c "Set :CFBundleGithubShortRevision $shorthash" "$INFOPLIST_FILE"
# update build number
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
@sonsongithub
sonsongithub / gist:3405180
Created August 20, 2012 15:30
Defulat pre-comiple header
#if TARGET_IPHONE_SIMULATOR
#import <objc/objc-runtime.h>
#else
#import <objc/runtime.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
@sonsongithub
sonsongithub / gist:3615998
Created September 4, 2012 02:50
Is this bug...?
NSString *input = @"Sun Mar 18 06:42:26 +0000 2007";
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"EEE MMM dd HH:mm:ss Z yyyy"];
[formatter setLocale:[NSLocale systemLocale]];
NSDate *date = [formatter dateFromString:input];
NSLog(@"String = %@", input);
@sonsongithub
sonsongithub / gist:4042482
Created November 8, 2012 23:10
Patch for evernote-sdk-ios(391ca643c5b1cd02e9fa869a6b0760436ea452ed)
Common subdirectories: ./evernote-sdk-ios/3rdParty and ./Evernote/3rdParty
Common subdirectories: ./evernote-sdk-ios/EDAM and ./Evernote/EDAM
diff -c ./evernote-sdk-ios/EvernoteSession.h ./Evernote/EvernoteSession.h
*** ./evernote-sdk-ios/EvernoteSession.h 2012-09-05 21:47:00.000000000 +0900
--- ./Evernote/EvernoteSession.h 2012-11-08 06:07:05.000000000 +0900
***************
*** 66,71 ****
--- 66,74 ----
// Shared dispatch queue for API operations.
@property (nonatomic, readonly) dispatch_queue_t queue;