Skip to content

Instantly share code, notes, and snippets.

require 'net/https'
def restore_shorten_uri(uri)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == 'https'
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start do |h|
res = h.head(uri.path)
loc = res['Location']
URI.regexp =~ loc ? URI.parse(loc) : uri
@yatatsu
yatatsu / AppDelegate.m
Created June 9, 2014 07:02
ios, debug
#if DEBUG
// http://www.zero4racer.com/blog/480
static void uncaughtExceptionHandler(NSException *exception) {
NSLog(@"CRASH: %@", exception);
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
// Internal error reporting
}
#endif
@implementation AppDelegate
@yatatsu
yatatsu / HTTPClient.m
Created June 10, 2014 03:36
jsonnic operation
// override
- (instancetype)initWithBaseURL:(NSURL *)url
{
self = [super initWithBaseURL:url];
if (self) {
self.requestSerializer = [AFJSONRequestSerializer serializer];
}
return self;
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// wait...
[NSThread sleepForTimeInterval:1.0];
dispatch_async(dispatch_get_main_queue(), ^{
// something you do ...
});
});
@yatatsu
yatatsu / macro.h
Created July 29, 2014 07:23
mrc macro
#define RELEASE_SAFELY(__POINTER) { [__POINTER release]; __POINTER = nil; }
@yatatsu
yatatsu / pedometer.md
Last active July 30, 2018 03:52
pedometer

スマートフォンの歩数計測について

2014-08-05更新

歩数計とは

  • 移動速度, 加速度センサーなどから歩数を計測.
  • GPSやwifiの位置情報から移動距離を計測.
  • 車など他の移動手段や消費カロリーなどの計測をするものもある.
  • 万歩計は登録商標.
@yatatsu
yatatsu / MyURLProtocol.m
Last active August 29, 2015 14:05
NSURLProtocolを使ってフィルタリングする
//
// MyURLProtocol.m
//
// Created by kitagawa on 2014/08/21.
// Copyright (c) 2014年 kitagawa. All rights reserved.
//
#import "MyURLProtocol.h"
static NSString *kCustomHeaderKey = @"API-Key";
@yatatsu
yatatsu / notification.md
Last active August 29, 2015 14:05
What's New in iOS Notifications
#!/bin/sh
# According to https://developer.apple.com/LIBRARY/PRERELEASE/IOS/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html
# And Referring to https://gist.github.com/lexrus/1984984
convert $1 -resize 180x180 [email protected]
convert $1 -resize 120x120 [email protected]
convert $1 -resize 152x152 [email protected]
convert $1 -resize 76x76 [email protected]