Last active
August 29, 2015 14:02
-
-
Save hachibeeDI/f8de54c6b9abd78349b1 to your computer and use it in GitHub Desktop.
こ…こんな!こんなこと!残酷すぎる!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Cocoa | |
let CORRECT_CASE = "波紋疾走" | |
let AN = "深仙脈" | |
let DO = "波紋" | |
let TROW = "疾走" | |
let SEED = [ | |
"山吹色", | |
"青緑", | |
"緋色", | |
AN, | |
DO, | |
TROW, | |
"破門", | |
"刃文", | |
"ハム", | |
"疾走", | |
"執奏", | |
"湿瘡", | |
] | |
let MAX_COUNT = SEED.count | |
func overdrive() { | |
var counter = 0 | |
var trybuffer = String[]() | |
while true { | |
let word = SEED[random() % MAX_COUNT] | |
println(word) | |
trybuffer.append(word) | |
switch trybuffer { | |
case ["深仙脈", "波紋", "疾走"]: | |
let deepas = trybuffer.reduce("", {(x, y) in x + y}) | |
println("ジョジョ 継いでくれ わしの意志をーー!! \(deepas)!") | |
println("ボドァ……") | |
println("you try \(counter) times") | |
return | |
case let x where x.count <= 2: | |
continue | |
default: | |
trybuffer.removeAtIndex(0) | |
} | |
counter += 1 | |
} | |
} | |
overdrive() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Cocoa | |
let url = NSURL(string: "https://qiita.com/api/v1/items") | |
let config = NSURLSessionConfiguration.defaultSessionConfiguration() | |
let session = NSURLSession(configuration: config) | |
let task = session.dataTaskWithURL(url, completionHandler: {(data, response, error) -> Void in | |
if let text = data { | |
println(NSString(data: text, encoding: NSUTF8StringEncoding)) | |
} | |
session.invalidateAndCancel() | |
} | |
) | |
task.resume() | |
while task.state != NSURLSessionTaskState.Completed { | |
sleep(1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment