Skip to content

Instantly share code, notes, and snippets.

View sonsongithub's full-sized avatar

Yuichi Yoshida sonsongithub

View GitHub Profile
@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 ));
}
@sonsongithub
sonsongithub / gist:44768b95a6175c836886
Created September 12, 2014 14:22
debug NSAttriutedString and CoreText
if (self.attributedString != nil && [self.attributedString.string rangeOfString:@"これになる不思議"].location != NSNotFound) {
DNSLog(@"%@", self.attributedString);
UniChar *p = (UniChar*)malloc(sizeof(UniChar) * self.attributedString.string.length);
[self.attributedString.string getCharacters:p];
FILE *fp = fopen("/Users/sonson/bug_data.bin", "wb");
fwrite(p, sizeof(UniChar), self.attributedString.string.length, fp);
fclose(fp);
free(p);
@sonsongithub
sonsongithub / line_counter.rb
Created October 23, 2014 10:58
line counter for itch
#!/usr/bin/env ruby
paths = []
paths.push(ARGV[0] + "/**/*.h")
paths.push(ARGV[0] + "/**/*.m")
blacklist = ["/imobile/", "/nend/", "/Google/", "/Evernote/", "/admob/", "/TestFlight/", "/UICoderz/"]
lines = 0
@sonsongithub
sonsongithub / gestureRecognizerShouldBegin.m
Created December 16, 2014 01:47
detect direction of UIKIt gesture recognizer
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
// スワイプのジェスチャを開始するかを判定する
if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
UIPanGestureRecognizer *panGesture = (UIPanGestureRecognizer *)gestureRecognizer;
CGPoint velocity = [panGesture velocityInView:panGesture.view];
double radian = atan(velocity.y/velocity.x);
double degree = radian * 180 / M_PI;
// 指定した角度よりも大きく(斜めに)スワイプした場合は,ジェスチャは開始されない
@sonsongithub
sonsongithub / gist:37a7c05ef9bb88038b43
Last active August 29, 2015 14:14
NSPredicate - predicateWithFormat
// This is OK
NSString *temp = [NSString stringWithFormat:@"title BEGINSWITH %@", searchBar.text];
NSPredicate *predicate = [NSPredicate predicateWithFormat:temp];
// Bad...
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"title BEGINSWITH %@", searchBar.text];
@sonsongithub
sonsongithub / gist:32aa13cfa382f97da94b
Created March 17, 2015 07:10
post-commit script for 2tch
#!/bin/bash
GIT_MARKETING_VERSION=`git describe --abbrev=0 --tags`
GIT_REVISION=`git rev-parse --short HEAD`
GIT_COMMIT_TIMES_STRING=`git log --since=2000-01-01 --oneline --no-merges | wc -l`
let GIT_COMMIT_TIMES=GIT_COMMIT_TIMES_STRING+13000
cat > ./2tch/info.prefix <<EOT
@sonsongithub
sonsongithub / gist:25b8b0598c7201af5a60
Created April 16, 2015 07:16
Ruby script to create github issue from reddit.com API list.
require 'octokit'
api_div_html_text = <<"EOS"
<div class="toc"><ul><li><strong>API methods</strong><span class="mode-selector"><a class="mode mode-current" href="/dev/api">by section</a><a class="mode " href="/dev/api/oauth">by oauth scope</a></span><ul><li><a href="#section_account" class="section">account</a><ul><li class="supports-oauth"><a href="#GET_api_v1_me">/api/v1/me</a></li><li class="supports-oauth"><a href="#GET_api_v1_me_blocked">/api/v1/me/blocked</a></li><li class="supports-oauth"><a href="#GET_api_v1_me_friends">/api/v1/me/friends</a></li><li class="supports-oauth"><a href="#GET_api_v1_me_karma">/api/v1/me/karma</a></li><li class="supports-oauth"><a href="#GET_api_v1_me_prefs">/api/v1/me/prefs</a></li><li class="supports-oauth"><a href="#GET_api_v1_me_trophies">/api/v1/me/trophies</a></li><li class="supports-oauth"><a href="#GET_prefs_blocked">/prefs/blocked</a></li><li class="supports-oauth"><a href="#GET_prefs_friends">/prefs/friends</a></li><li class="supports-oauth"><a href="#GET_prefs_{