Skip to content

Instantly share code, notes, and snippets.

View yimajo's full-sized avatar
:octocat:

Yoshinori Imajo yimajo

:octocat:
  • Curiosity Software inc.
  • Tokyo, Japan
  • 01:25 (UTC +09:00)
View GitHub Profile
@yimajo
yimajo / gist:2928598
Created June 14, 2012 07:09
RebootXCode
say "Reboot! XCode"
set aWorkflow to "/Users/yimajo/Documents/work/Dropbox/Automator/RebootXCode.workflow"
set aRes to executeAutomatorWorkflow(aWorkflow) of me
on executeAutomatorWorkflow(aWorkflow)
set aShell to "/usr/bin/automator " & (quoted form of POSIX path of aWorkflow)
with timeout of 3600 seconds
try
set aRes to (do shell script aShell)
on error errorMes
@yimajo
yimajo / gist:3172557
Created July 24, 2012 20:45
良い感じにViewをポップアップしてくれるアニメーション
- (void)popupView:(UIView *)view
{
view.transform = CGAffineTransformScale(CGAffineTransformIdentity,0.5f,0.5f);
[UIView animateWithDuration:0.2
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.2f,1.2f);
}
@yimajo
yimajo / gist:3174070
Created July 25, 2012 02:41
未キャッチの例外をキャッチするメソッドを登録してEXC_BAD_ACCESSを保存する
void uncaughtExceptionHandler(NSException *exception);
void uncaughtExceptionHandler(NSException *exception)
{
NSString *crashReport = [NSString stringWithFormat:@"Crash Name:%@\r\n%@\r\nStack Trace:%@",[exception name], [exception reason], [exception callStackSymbols]];
NSString *crashSection = @"====Crash Report====";
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[ud setObject:[NSString stringWithFormat:@"%@\r\n%@",crashSection,crashReport] forKey:@"CrashReportText"];
@yimajo
yimajo / gist:91cf9ef030c7a79500f0
Created June 30, 2014 10:28
bashでgitのリポジトリを表示
# git settings
source /usr/local/git/contrib/completion/git-prompt.sh
source /usr/local/git/contrib/completion/git-completion.bash
git_ps1_showdirtystate=true
export PS1='\h\[\e[0;32m\]\[\e[00m\]:\[\033[34m\]\W \[\033[32m\]\u\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '
@yimajo
yimajo / CnnnpassAPISearchRequest.swift
Last active May 12, 2018 01:35
Connpass APIのAPIKit.Request
import Foundation
import APIKit
struct ConnpassAPI {}
extension ConnpassAPI {
struct SearchResult: Decodable {
let events: [Event]
}
@yimajo
yimajo / AtndAPISearchRequest.swift
Created May 12, 2018 01:36
ATND APIののAPIKit.Request
import Foundation
import APIKit
struct AtndAPI {}
extension AtndAPI {
struct SearchResult: Decodable {
let events: [EventContainer]
}
@yimajo
yimajo / suspend2.kt
Last active July 20, 2018 00:36
Kotlinでsuspend functionだけでDeferredなメソッドを作らずに2つの処理を同時に動かして待ち合わせる
// Kotlin 1.2.51
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.experimental.runBlocking
fun main(args: Array<String>) {
runBlocking {
var jobA = async { job() }
var jobB = async { job() }
@yimajo
yimajo / quiz.swift
Last active September 6, 2018 02:39
Swiftクイズ1
var value: Int? = nil
print(value ?? 0 < 1) // この出力はtrueです
value = 10
print(value ?? 0 < 1) // Q. この出力は何でしょう?
/*:
回答の選択肢
- 10
@yimajo
yimajo / quiz.kt
Last active September 6, 2018 05:00
Kotlin クイズ1
fun main(args: Array<String>) {
var value: Int? = null
println(value ?: 0 < 1) // この出力はtrueです
value = 10
println(value ?: 0 < 1) // Q. この出力は何でしょう?
}
/*:
回答の選択肢
- 10
@yimajo
yimajo / protocol_inherit_from_class.swift
Last active March 30, 2019 06:52
Swift5からprotocolでclassをinheritできるようになった?
class Hoge {}
// Swift 5から
protocol ComponentA: Hoge {
func name() -> String
}
// Swift 4でも同じようなことはできた
protocol ComponentB where Self: Hoge {
func name() -> String