Skip to content

Instantly share code, notes, and snippets.

View syou007's full-sized avatar

atsushi ichikawa syou007

View GitHub Profile
@syou007
syou007 / file0.html
Created August 1, 2016 01:46
Rails5(Turbolinks5)にGA(google analytics)を設置! ref: http://qiita.com/syou007/items/8cc24b0bf317de72cc0b
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-000000-00', 'auto');
ga('send', 'pageview');
</script>
@syou007
syou007 / file0.coffee
Last active October 4, 2016 05:57
Rails5でTurbolinksの挙動が変わってた。 ref: http://qiita.com/syou007/items/fda40f65634bb2fadf36
$(document).on 'page:before-change' , -> console.log 'page:before-change'
$(document).on 'page:fetch' , -> console.log 'page:fetch'
$(document).on 'page:receive' , -> console.log 'page:receive'
$(document).on 'page:change' , -> console.log 'page:change'
$(document).on 'page:update' , -> console.log 'page:update'
$(document).on 'page:load' , -> console.log 'page:load'
$(document).on 'ready page:load' , -> console.log 'ready and load'
$(document).ready -> console.log '$(document).ready in assets'
$(window).on 'load' , -> console.log '$(window).load in assets'
@syou007
syou007 / file0.txt
Last active June 8, 2016 13:48
初めてフリーランスになる時の指標 ref: http://qiita.com/syou007/items/34a7f9afce0425674c0a
(1000万 - 300万) * 0.8 = 56万
@syou007
syou007 / file0.swift
Created May 24, 2016 02:23
MKMapViewに全てのピンを表示させる。 ref: http://qiita.com/syou007/items/f6d190c08ee57cf6455f
// 最低限の地図の大きさ
let MINIMUM_MAP_SPAN = MKCoordinateSpanMake(0.002, 0.002)
var topLeftCoord = CLLocationCoordinate2D(latitude: -90, longitude: 180)
var bottomRightCoord = CLLocationCoordinate2D(latitude: 90, longitude: -180)
// 2点間の計算を行う。
// 現在地
topLeftCoord.longitude = fmin(topLeftCoord.longitude, localCoordinate.longitude)
topLeftCoord.latitude = fmax(topLeftCoord.latitude, localCoordinate.latitude)
let daddr = NSString(format: "%f,%f", latitude, longitude)
let urlString = "http://maps.apple.com/?daddr=\(daddr)&dirflg=d"
let encodedUrl = urlString.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
let url = NSURL(string: encodedUrl)!
UIApplication.sharedApplication().openURL(url)
@syou007
syou007 / file0.swift
Created May 19, 2016 06:55
Observableを順番に処理させるサンプル ref: http://qiita.com/syou007/items/44e5d4541b22f973d12b
let a:Observable<Int> = Observable.create { observable in
NSOperationQueue().addOperationWithBlock({ () -> Void in
sleep(5)
observable.onNext(1)
observable.onCompleted()
})
return NopDisposable.instance
}
let b:Observable<Int> = Observable.create { observable in
var value:Int
@syou007
syou007 / file0.swift
Last active April 16, 2016 10:33
NSNotificationCenterはもう古い。 ref: http://qiita.com/syou007/items/c7f790f2f40776f38578
import RxSwift
class NotificationCenter {
static let observable = PublishSubject<String>()
}
@syou007
syou007 / CCBLocalizationManager.m
Last active November 6, 2016 12:31
性懲りも無くSpriteBuilderを使っている方へ ref: http://qiita.com/syou007/items/4071ced9eb30b76b1a6c
- (void) loadStringsFile:(NSString*) file
{
// Load default localization dictionary
NSString* path = [[CCFileUtils sharedFileUtils] fullPathForFilename:file];
// Load strings file
NSDictionary* ser = [NSDictionary dictionaryWithContentsOfFile:path];
// Check that format of file is correct
NSAssert([[ser objectForKey:@"fileType"] isEqualToString:@"SpriteBuilderTranslations"], @"Invalid file format for SpriteBuilder localizations");
@syou007
syou007 / AppDelegate.swift
Created April 13, 2016 06:12
SwiftでGoogleAnalyticsの設定とスクリーン名自動設定 ref: http://qiita.com/syou007/items/49fdc84be92acae19bb1
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
// GoogleAnalytice
GoogleAnalytics.setup()
}