Skip to content

Instantly share code, notes, and snippets.

Avatar

Takeru Chuganji chuganzy

View GitHub Profile
@chuganzy
chuganzy / main.coffee
Last active Jan 17, 2019
ofxLibwebsocketsからHerokuに接続できない http://blog.ganzy.jp/javascript/146
View main.coffee
WebSocketServer = require("websocket").server
WebSocketClient = require("websocket").client
Http = require("http")
class ServerManager
constructor: ->
@server = {}
@webSocketServer = {}
startServer: ->
@chuganzy
chuganzy / gist:936e5fac1e00e49fdd85
Last active Jan 17, 2019
SDWebImageのcompleteBlockが呼ばれないことがある http://blog.ganzy.jp/objective-c/191
View gist:936e5fac1e00e49fdd85
// どこかでNotificationを受け取れるようにする
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(hc_sdWebImageDownloadStopNotification:)
name:SDWebImageDownloadStopNotification
object:nil];
// 通知を受け取る
- (void)hc_sdWebImageDownloadStopNotification:(NSNotification *)notification {
dispatch_main_async_safe(^{
@chuganzy
chuganzy / gist:ce9cd0e51f3022e07aff
Last active Jan 17, 2019
iOSプロジェクトの全ターゲットのバージョンを一気に上げる http://blog.ganzy.jp/objective-c/219
View gist:ce9cd0e51f3022e07aff
#!/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:6cd5b915b759e60de389
Last active Jan 17, 2019
モーダルで開いたUIViewControllerを一気に閉じる http://blog.ganzy.jp/objective-c/133
View gist:6cd5b915b759e60de389
/* とにかくモーダルを全部閉じる */
// どこからでもOK
[[UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:YES completion:nil];
// もしくはこちら
[[UIApplication sharedApplication].delegate.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
/* ある階層までのモーダルを閉じる */
@chuganzy
chuganzy / testApp.h
Last active Jan 17, 2019
openFrameworks for iOSでデバイスの姿勢を取得する http://blog.ganzy.jp/cpp/64
View testApp.h
#import <CoreMotion/CoreMotion.h>
class testApp : public ofxiOSApp {
CMMotionManager *motionManager;
public:
void setup();
void update();
void draw();
void exit();
@chuganzy
chuganzy / gist:7409269
Last active Jan 17, 2019
Androidで要素の幅が勝手に狭まる http://blog.ganzy.jp/css/12
View gist:7409269
.../* 勝手に狭まる要素に対して */ {
background: url(data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH/C1hNUCBEYXRhWE1QAz94cAAh+QQFAAAAACwAAAAAAQABAEACAkQBADs=);
}
@chuganzy
chuganzy / APIKit+Rx.swift
Last active Apr 24, 2017
RxSwift x APIKit
View APIKit+Rx.swift
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):
View RxCaptureMetadataOutputObjectsDelegateProxy.swift
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)
View shuffle_lunch.coffee
# Description:
# シャッフルランチの管理をします
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
View NSString+Surrogate.swift
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)) {
You can’t perform that action at this time.