Skip to content

Instantly share code, notes, and snippets.

View sonsongithub's full-sized avatar

Yuichi Yoshida sonsongithub

View GitHub Profile
@sonsongithub
sonsongithub / gist:4138703
Created November 24, 2012 06:51
Patch for evernote-sdk-ios(327a961b1ef40a65fb4fb699ae8da7bfefda6369)
Only in .: evernote-sdk-ios-Prefix.pch
diff -r ./internal/ENOAuthViewController.m /Users/sonson/code/Core2ch/ios/3tch/Framework/Library/Evernote/internal/ENOAuthViewController.m
170,171c170,172
< if ([[request.URL absoluteString] hasPrefix:self.oauthCallbackPrefix]) {
< // this is our OAuth callback prefix, so let the delegate handle it
---
> NSRange r = [[request.URL absoluteString] rangeOfString:self.oauthCallbackPrefix];
> if (r.location != NSNotFound) {
> NSString *responseURLString = [[request.URL absoluteString] substringWithRange:NSMakeRange(r.location, [request.URL absoluteString].length - r.location)];
173c174
@sonsongithub
sonsongithub / gist:4481617
Last active December 10, 2015 19:29
Workaround, make UITableViewCell's indention work properly in iOS6 using Autolayout. Cited from http://stackoverflow.com/a/13893146.
-(void)awakeFromNib{
[super awakeFromNib];
for(NSLayoutConstraint *cellConstraint in self.constraints){
[self removeConstraint:cellConstraint];
id firstItem = cellConstraint.firstItem == self ? self.contentView : cellConstraint.firstItem;
id seccondItem = cellConstraint.secondItem == self ? self.contentView : cellConstraint.secondItem;
NSLayoutConstraint* contentViewConstraint =
[NSLayoutConstraint constraintWithItem:firstItem
attribute:cellConstraint.firstAttribute
relatedBy:cellConstraint.relation
@sonsongithub
sonsongithub / ibhelper.rb
Created July 2, 2013 01:25
Merge script for .strings file generated from Storyboard. ibtool often fails to merge importing .strings file into new generated one.
#!/usr/bin/ruby
require 'optparse'
def main
argv = {}
OptionParser.new do |opt|
opt.on('--previous VALUE') do |v|
argv[:previous] = v
@sonsongithub
sonsongithub / genstringsHelper.rb
Created July 2, 2013 05:50
This code is an alternative to Lingua that does not work for Xcode 4.6.3....
#!/usr/bin/ruby
require 'optparse'
require 'kconv'
def update(filepath, dictionary)
puts filepath
fr = File::open(filepath, "r")
localizedSource = fr.read
fr.close
@sonsongithub
sonsongithub / gist:6005034
Last active December 19, 2015 19:19
parser for extract UTI idenfier from Xcode documents for exmample path file:///Users/sonson/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS6.1.iOSLibrary.docset/Contents/Resources/Documents/index.html#documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
#!/usr/bin/ruby
# parser for extract UTI idenfier from Xcode documents
# for exmample path
# file:///Users/sonson/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS6.1.iOSLibrary.docset/Contents/Resources/Documents/index.html#documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
if __FILE__ == $0
str = $stdin.read
str.scan(/<tr><td scope=\"row\"><p>(.+?)<\/p><\/td>/).each{|e|
e1 = e[0].gsub(/\(.+\)/, "")
TEAM_TOKEN="<TEAM TOKEN>"
API_TOKEN="<API TOKEN>"
DISTRIBUTION_LISTS="<Distribution list, that is separated by comma>"
/bin/mkdir -p ./tmp
DSYM="/tmp/Archive.xcarchive/dSYMs/${PRODUCT_NAME}.app.dSYM"
IPA="/tmp/Archive.xcarchive/${PRODUCT_NAME}.ipa"
APP="/tmp/Archive.xcarchive/Products/Applications/${PRODUCT_NAME}.app"
@sonsongithub
sonsongithub / gist:b3ffae00e735e6e59e6c
Created June 10, 2014 06:15
git exrport command sample
git archive --format=zip HEAD > Sample.zip
ruby -rubygems -e 'require "jekyll-import";
JekyllImport::Importers::WordpressDotCom.run({
"source" => "wordpress.xml",
"tags" => false,
"more_excerpt" => true,
"more_anchor" => true
})'
@sonsongithub
sonsongithub / extract_signature.rb
Created August 4, 2014 05:46
Objective-Cのコメントとsignatureを抽出してみる.
def main
begin
fr = File::open(ARGV[0],"r")
rescue
else
depth = 0
buf = ""
fr.read.each_char{|c|
if c == '{'
depth = depth + 1
@sonsongithub
sonsongithub / gist:139bcd5b2f66f1ccdf7a
Created September 7, 2014 21:34
check inside of NSString
void hoge(NSString* temp) {
DNSLog(@"------------------%ld", temp.length);
NSData *data = [temp dataUsingEncoding:NSUTF8StringEncoding];
unichar *uni = nil;
uni = (unichar*)malloc(sizeof(unichar) * temp.length);
[temp getCharacters:uni];
for (int i = 0; i < [temp length]; i++) {
NSLog(@"%d - %04x", i, *(uni + i ));
}