Skip to content

Instantly share code, notes, and snippets.

View taktamur's full-sized avatar

Takafumi Tamura taktamur

View GitHub Profile
@taktamur
taktamur / DicKeyForin
Created June 28, 2014 10:02
Swift Dictionary sort array
// https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/swift_programming_language/Closures.html
let data:Dictionary = [30:"value1", 20:"2", 10:"3"]
println("patter 1")
for key in sort(Array(data.keys), { (a:Int,b:Int) -> Bool in return a > b }) {
println( data[key] )
}
println("patter 2")
for key in sort(Array(data.keys), { return $0 > $1 }) {
@taktamur
taktamur / wwdc2014_video.rb
Created June 7, 2014 05:56
WWDC2014のビデオ一覧をmarkdown形式のリストに変換するrubyスクリプト
# WWDC2014のビデオ一覧をスクレーピングして、markdown形式のリストで出力するスクリプト
# ruby ./wwdc2014_video.rb > wwdc2014_video_list.md5
#
# 参考にしたサイト:
# http://morizyun.github.io/blog/ruby-nokogiri-scraping-tutorial/
# http://d.hatena.ne.jp/otn/20090509/p1
require 'open-uri'
require 'nokogiri' #gem install nokogiri
@taktamur
taktamur / atom.ioのパッケージ作成を試す.md
Created May 31, 2014 06:24
atom.ioのパッケージ作成メモ

atom.ioのパッケージ作成を試しながら、いろいろ調べる。

https://atom.io/docs/v0.64.0/your-first-package をみながら、ascii-artなパッケージを作る。

  • window.reloadした後にパッケージが出てこなくなったけど、これはタイプミスが原因だった。
    • エラーログ的な表示(console)は、option-cmd-Iで出てくるDeveloperToolの中で確認出来た。
    • !
  • "Add a Key Binding"の中でctrl-alt-aにバインドしているけど、これはすでに別の動きが割り当てられてたので動作しなかった。ctrl-lは空いていたのでそれで代用。
    • キーマップ一覧は、Show keybindingsで確認出来た。
  • !
@taktamur
taktamur / gist-itを試す.md
Last active August 29, 2015 14:02
atom.ioでgist-itを試した。
@taktamur
taktamur / AppDelegate.m
Last active July 24, 2017 03:17
既存クラスのメソッドを入れ替える(Method Swizzling) ref: http://qiita.com/paming/items/25eaf89e4f448ab05752
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[UIViewController switchLoggingMethod]; // ←これでメソッドが入れ替わる
return YES;
}
@taktamur
taktamur / file0.txt
Created August 17, 2013 15:04
iOSアプリをビルドしてTestFlightに送り込むMakefile ref: http://qiita.com/paming/items/98929336dea4560a34fc
# http://hakobe932.hatenablog.com/entry/2012/01/21/142726#fn1
.PHONY: all build archive testflight
PROJECT ?= PAMEventBoard.xcworkspace
SCHEME ?= PAMEventBoard
SIGN ?= iOS Developer
DSYM = $(PWD)/out/build/PAMEventBoard.app.dSYM
all: archive
@taktamur
taktamur / file0.txt
Created August 13, 2013 13:21
とあるページの要素分解 ref: http://qiita.com/paming/items/207641782b672222f401
NSString *html_ = [NSString stringWithContentsOfURL:url
encoding:NSUTF8StringEncoding
error:nil];
NSString *html = [html_ stringByReplacingOccurrencesOfString:@"\n"
withString:@""];
[UIApplication sharedApplication].networkActivityIndicatorVisible=NO;
// 正規表現の中で.*?とやると最短マッチするらしい。
NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:@"<h5><a.*? href=\"(.*?)\".*?>(.*?)</a></h5>"
options:0
error:nil];
@taktamur
taktamur / ViewController
Last active December 20, 2015 23:18
3つのUIViewをくるくる入れ替える ref: http://qiita.com/paming/items/e940dbe4fd5fb77ddf60
@interface UIView(Swap)
-(void)removeAllGestures;
@end
@implementation UIView(Swap)
-(void)removeAllGestures
{
for (UITapGestureRecognizer *gesture in self.gestureRecognizers) {
[self removeGestureRecognizer:gesture];
}
@taktamur
taktamur / UIScrollView+LadderLayout.m
Created August 8, 2013 14:37
UIScrollViewでハシゴ状レイアウトするカテゴリ拡張 ref: http://qiita.com/paming/items/a7f28c3eb23a7c297b27
//
// UIScrollView+LadderLayout.m
// UIScrollView+LadderLayout
//
#import "UIScrollView+LadderLayout.h"
// 便利拡張。UIViewのframe.{origin|size}へのアクセスを簡略化
@interface UIView(LadderLayout)
@property(readonly)CGFloat x;
@taktamur
taktamur / file0.txt
Created August 5, 2013 14:24
Storyboardの"ContainerView"を使ってみる ref: http://qiita.com/paming/items/d8a29d644c994ce60d6a
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
for (id c in self.childViewControllers) {
NSLog( @"c=%@",c);
}
for( UIView *v in self.view.subviews){
NSLog(@"v=%@",v);
for( UIView *v2 in v.subviews){
NSLog(@"v2=%@",v2);