Skip to content

Instantly share code, notes, and snippets.

View hmhmsh's full-sized avatar

shunkun hmhmsh

View GitHub Profile
{
"cmd": ["javac -J-Dfile.encoding=UTF-8 $file_name && java -Dfile.encoding=UTF-8 $file_base_name"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"path": "/usr/bin/",
"selector": "source.java",
"shell": true
}
@hmhmsh
hmhmsh / Decimal.java
Created December 27, 2016 09:24
Decimal10 to Decimal2 etc...
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
class Decimal {
static int DECIMAL_10 = 20;
public static void main(String[] args) {
System.out.println(convertDecimal(DECIMAL_10, 2)); // 10100
@hmhmsh
hmhmsh / KotlinExtension.swift
Created May 31, 2017 08:03
Extension of Swift like Kotlin
protocol Kotlin {}
extension Kotlin {
func lets<R>(_ closure: (Self) -> R) -> R {
return closure(self)
}
func apply(closure: (Self) -> Void) -> Self {
closure(self)
return self
@hmhmsh
hmhmsh / Controller
Last active November 16, 2017 09:23
デザインパターン入門「Model-View-Controller」 ref: https://qiita.com/hmhmsh/items/271a6cb309761bd965d3
ユーザーからの入力を受け取る
modelへ入力を伝える
@hmhmsh
hmhmsh / CLAlertController.h
Last active November 30, 2017 05:14
iOS標準のAlertController拡張(TODO: 修正が必要かも)
//
// CLAlertController.h
//
// Usage
// CLAlertController* AlertController = [[CLAlertController alloc]initWithTitle:@"タイトル" message:@"本文" delegate:self parent:parent];
//
// [AlertController addView:view];
// [AlertController addActionWithTitle:@"いいえ"];
// [AlertController addActionWithTitle:@"OK"];
// [AlertController show];
@hmhmsh
hmhmsh / Pattern1.m
Last active November 30, 2017 05:14
// pattern1
-(void)a {
[self closure:^BOOL(int a, int b){
return a > b;
}];
}
-(void)closure:(BOOL(^)(int, int))close {
NSLog(@"%@", close(4,2) == 1?@"YES" : @"NO");
}
//
// MotionShake.swift
//
override func canBecomeFirstResponder() -> Bool {
return true
}
override func motionBegan(motion: UIEventSubtype, withEvent event: UIEvent?) {
if event!.type == UIEventType.Motion && event!.subtype == UIEventSubtype.MotionShake {
func a() {
closure({ (a: Int, b: Int) -> Bool in
return a > b
})
closure() { (a, b) in
return a > b
}
//
// Color.swift
//
//
// Usage
// UIColor.HexColor.Red
// UIColor.RGBColor.Red
//
import Foundation
import UIKit
//
// FadeInOut.swift
//
//
// Usage
// フェードイン
// 完了タイミングで何かしたい場合はクロージャーも記述
// FadeView.fadeIn(type: .Slow) { [weak self] in
// println("FadeIn 完了")
// }