Skip to content

Instantly share code, notes, and snippets.

View chuganzy's full-sized avatar

Takeru Chuganji chuganzy

View GitHub Profile
#import <XCTest/XCTest.h>
@interface XCTestCase (Private)
- (void)_enqueueFailureWithDescription:(id)arg1 inFile:(id)arg2 atLine:(unsigned long long)arg3 expected:(_Bool)arg4;
@end
@interface UniversalLinksUITests : XCTestCase
@property (assign, nonatomic) BOOL ignoreFailure;
@end
import Foundation
extension NSString {
func utf16IndexForIndex(index: Int) -> Int {
var index = index
var result = 0
while result < index {
if result + 1 < self.length &&
CFStringIsSurrogateHighCharacter(self.characterAtIndex(result)) &&
CFStringIsSurrogateLowCharacter(self.characterAtIndex(result + 1)) {
# Description:
# シャッフルランチの管理をします
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
import Foundation
import AVFoundation
import RxSwift
import RxCocoa
private let associatedkey = UnsafePointer<Void>(malloc(1))
class RxCaptureMetadataOutputObjectsDelegateProxy: DelegateProxy, DelegateProxyType, AVCaptureMetadataOutputObjectsDelegate {
static func setCurrentDelegate(delegate: AnyObject?, toObject object: AnyObject) {
(object as! AVCaptureMetadataOutput)
@chuganzy
chuganzy / APIKit+Rx.swift
Last active April 24, 2017 10:05
RxSwift x APIKit
import Foundation
import APIKit
import RxSwift
extension Session {
func rx_sendRequest<T: RequestType>(request: T) -> Observable<T.Response> {
return Observable.create { observer in
let task = self.sendRequest(request) { result in
switch result {
case .Success(let res):
@chuganzy
chuganzy / gist:7409269
Last active January 17, 2019 19:46
Androidで要素の幅が勝手に狭まる http://blog.ganzy.jp/css/12
.../* 勝手に狭まる要素に対して */ {
background: url(data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH/C1hNUCBEYXRhWE1QAz94cAAh+QQFAAAAACwAAAAAAQABAEACAkQBADs=);
}
@chuganzy
chuganzy / testApp.h
Last active January 17, 2019 19:46
openFrameworks for iOSでデバイスの姿勢を取得する http://blog.ganzy.jp/cpp/64
#import <CoreMotion/CoreMotion.h>
class testApp : public ofxiOSApp {
CMMotionManager *motionManager;
public:
void setup();
void update();
void draw();
void exit();
@chuganzy
chuganzy / gist:6cd5b915b759e60de389
Last active January 17, 2019 19:47
モーダルで開いたUIViewControllerを一気に閉じる http://blog.ganzy.jp/objective-c/133
/* とにかくモーダルを全部閉じる */
// どこからでもOK
[[UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:YES completion:nil];
// もしくはこちら
[[UIApplication sharedApplication].delegate.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
/* ある階層までのモーダルを閉じる */
@chuganzy
chuganzy / gist:ce9cd0e51f3022e07aff
Last active January 17, 2019 19:47
iOSプロジェクトの全ターゲットのバージョンを一気に上げる http://blog.ganzy.jp/objective-c/219
#!/usr/bin/env ruby
require 'xcodeproj'
require 'plist'
class UpdateVersionManager
def initialize
path = File.expand_path("#{__dir__}/../") # absolute path to your project file
projects = Xcodeproj::Project.open(*Dir.glob("#{path}/*.xcodeproj"))
@base_path = path
@chuganzy
chuganzy / gist:936e5fac1e00e49fdd85
Last active January 17, 2019 19:48
SDWebImageのcompleteBlockが呼ばれないことがある http://blog.ganzy.jp/objective-c/191
// どこかでNotificationを受け取れるようにする
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(hc_sdWebImageDownloadStopNotification:)
name:SDWebImageDownloadStopNotification
object:nil];
// 通知を受け取る
- (void)hc_sdWebImageDownloadStopNotification:(NSNotification *)notification {
dispatch_main_async_safe(^{