Skip to content

Instantly share code, notes, and snippets.

View chuganzy's full-sized avatar

Takeru Chuganji chuganzy

View GitHub Profile
@chuganzy
chuganzy / gist:d88d56e9b402153d687a
Last active March 4, 2016 06:57
Carthageの面倒な作業をどうにかする
#!/usr/bin/env ruby
require 'xcodeproj'
require 'colorize'
Dir.chdir "#{__dir__}/../"
class LibraryUpdateManager
attr_accessor :update_carthage, :update_cocoapods, :acknowledgements_path
def initialize
struct Person {
let name: String
func isValid() -> Bool {
return !name.characters.isEmpty
}
}
let validPerson = Person(name: "Tom")
let invalidPerson = Person(name: "")
@chuganzy
chuganzy / gist:85743eee8609a80dd35a
Last active September 7, 2015 06:09
uuid_generate_time in Swift
extension NSUUID {
class func timeBasedUUID() -> NSUUID {
let uuidSize = sizeof(uuid_t)
let uuidPointer = UnsafeMutablePointer<UInt8>.alloc(uuidSize)
uuid_generate_time(uuidPointer)
let uuid = NSUUID(UUIDBytes: uuidPointer)
uuidPointer.dealloc(uuidSize)
return uuid
}
}
@chuganzy
chuganzy / gist:1f74224d7c62f01654ec
Last active August 29, 2015 14:19
xcdatamodeldからSwiftのコードをいい感じに吐く
#!/usr/bin/env ruby
require 'nokogiri'
require 'colorize'
require 'erubis'
class Manager
class SwiftConverter
def to_swift
raise 'Error: method `to_swift` is not implemented'
@chuganzy
chuganzy / gist:38c0b13068992ffe20e9
Last active August 29, 2015 14:13
OS X ServerでXcodeの設定をするとオフにしていても_xcsbuilddが勝手にログイン状態になる
sudo xcrun xcscontrol --reset
@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(^{
@chuganzy
chuganzy / main.coffee
Last active January 17, 2019 19:48
ofxLibwebsocketsからHerokuに接続できない http://blog.ganzy.jp/javascript/146
WebSocketServer = require("websocket").server
WebSocketClient = require("websocket").client
Http = require("http")
class ServerManager
constructor: ->
@server = {}
@webSocketServer = {}
startServer: ->
@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 / 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();