Saturday, May 27, 2017
Friday, May 26, 2017
Thursday, May 25, 2017
Tuesday, May 23, 2017
Swift: Reading from Standard Streams (標準ストリーム)
Command:
$ cat ./Desktop/StandardInput/StandardInput/main.swift
Result:
import Foundation
var string = ""
func showMainMenu(){
print("1) Walk")
print("2) Study")
print("3) Work")
print("4) Sleep")
print("> ", terminator: "")
}
func walk(){
var line = ""
repeat {
print("Walking...")
print("Enter 'exit' to finish")
print("> ", terminator: "")
line = readLine()!
} while line != "exit"
}
func work(){
var line = ""
repeat {
print("Working...")
print("Enter 'exit' to finish")
print("> ", terminator: "")
line = readLine()!
} while line != "exit"
}
func study(){
var line = ""
repeat {
print("Studying...")
print("Enter 'exit' to finish")
print("> ", terminator: "")
line = readLine()!
} while line != "exit"
}
func sleep(){
var line = ""
repeat {
print("Sleeping...")
print("Enter 'exit' to finish")
print("> ", terminator: "")
line = readLine()!
} while line != "exit"
}
showMainMenu()
while let line = readLine(){
switch line{
case "1":
walk()
break
case "2":
study()
break
case "3":
work()
break
case "4":
sleep()
break
default:
print("Enter again")
break
}
showMainMenu()
}
Command:
$ ./Library/Developer/Xcode/DerivedData/StandardInput-eauwzvcnsumxppbvwnagppvlylcg/Build/Products/Debug/StandardInput ; exit;
Result:
1) Walk
2) Study
3) Work
4) Sleep
> 1
Walking...
Enter 'exit' to finish
>
Walking...
Enter 'exit' to finish
>
Walking...
Enter 'exit' to finish
> exit
1) Walk
2) Study
3) Work
4) Sleep
> 2
Studying...
Enter 'exit' to finish
>
Studying...
Enter 'exit' to finish
>
Studying...
Enter 'exit' to finish
>
Studying...
Enter 'exit' to finish
> exit
1) Walk
2) Study
3) Work
4) Sleep
> 3
Working...
Enter 'exit' to finish
> exit
1) Walk
2) Study
3) Work
4) Sleep
> 4
Sleeping...
Enter 'exit' to finish
>
Sleeping...
Enter 'exit' to finish
>
Sleeping...
Enter 'exit' to finish
>
Sleeping...
Enter 'exit' to finish
>
Sleeping...
Enter 'exit' to finish
> exit
1) Walk
2) Study
3) Work
4) Sleep
> exit
Enter again
1) Walk
2) Study
3) Work
4) Sleep
> ^C
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
$ cat ./Desktop/StandardInput/StandardInput/main.swift
Result:
import Foundation
var string = ""
func showMainMenu(){
print("1) Walk")
print("2) Study")
print("3) Work")
print("4) Sleep")
print("> ", terminator: "")
}
func walk(){
var line = ""
repeat {
print("Walking...")
print("Enter 'exit' to finish")
print("> ", terminator: "")
line = readLine()!
} while line != "exit"
}
func work(){
var line = ""
repeat {
print("Working...")
print("Enter 'exit' to finish")
print("> ", terminator: "")
line = readLine()!
} while line != "exit"
}
func study(){
var line = ""
repeat {
print("Studying...")
print("Enter 'exit' to finish")
print("> ", terminator: "")
line = readLine()!
} while line != "exit"
}
func sleep(){
var line = ""
repeat {
print("Sleeping...")
print("Enter 'exit' to finish")
print("> ", terminator: "")
line = readLine()!
} while line != "exit"
}
showMainMenu()
while let line = readLine(){
switch line{
case "1":
walk()
break
case "2":
study()
break
case "3":
work()
break
case "4":
sleep()
break
default:
print("Enter again")
break
}
showMainMenu()
}
Command:
$ ./Library/Developer/Xcode/DerivedData/StandardInput-eauwzvcnsumxppbvwnagppvlylcg/Build/Products/Debug/StandardInput ; exit;
Result:
1) Walk
2) Study
3) Work
4) Sleep
> 1
Walking...
Enter 'exit' to finish
>
Walking...
Enter 'exit' to finish
>
Walking...
Enter 'exit' to finish
> exit
1) Walk
2) Study
3) Work
4) Sleep
> 2
Studying...
Enter 'exit' to finish
>
Studying...
Enter 'exit' to finish
>
Studying...
Enter 'exit' to finish
>
Studying...
Enter 'exit' to finish
> exit
1) Walk
2) Study
3) Work
4) Sleep
> 3
Working...
Enter 'exit' to finish
> exit
1) Walk
2) Study
3) Work
4) Sleep
> 4
Sleeping...
Enter 'exit' to finish
>
Sleeping...
Enter 'exit' to finish
>
Sleeping...
Enter 'exit' to finish
>
Sleeping...
Enter 'exit' to finish
>
Sleeping...
Enter 'exit' to finish
> exit
1) Walk
2) Study
3) Work
4) Sleep
> exit
Enter again
1) Walk
2) Study
3) Work
4) Sleep
> ^C
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
ラベル:
Standard streams,
Swift,
標準ストリーム
Swift: Command Line Argument Parsing
Command:
$ cat ./Desktop/Arguments\ Test/Arguments\ Test/main.swift
Result:
import Foundation
var count = 0
for argument in CommandLine.arguments {
print("Arg[\(count)]: \(argument)")
count += 1
}
Command:
$ ./Library/Developer/Xcode/DerivedData/Arguments_Test-ffnafkbrsdftjxdawcsyrdhlfnvu/Build/Products/Debug/Arguments\ Test first second third
Result:
Arg[0]: ./Library/Developer/Xcode/DerivedData/Arguments_Test-ffnafkbrsdftjxdawcsyrdhlfnvu/Build/Products/Debug/Arguments Test
Arg[1]: first
Arg[2]: second
Arg[3]: third
$ cat ./Desktop/Arguments\ Test/Arguments\ Test/main.swift
Result:
import Foundation
var count = 0
for argument in CommandLine.arguments {
print("Arg[\(count)]: \(argument)")
count += 1
}
Command:
$ ./Library/Developer/Xcode/DerivedData/Arguments_Test-ffnafkbrsdftjxdawcsyrdhlfnvu/Build/Products/Debug/Arguments\ Test first second third
Result:
Arg[0]: ./Library/Developer/Xcode/DerivedData/Arguments_Test-ffnafkbrsdftjxdawcsyrdhlfnvu/Build/Products/Debug/Arguments Test
Arg[1]: first
Arg[2]: second
Arg[3]: third
Monday, May 22, 2017
Sunday, May 21, 2017
Kemono Friends (けものフレンズ): Episode #1 (第1話)
- Cerulean (セルリアン)
ラベル:
Cerulean,
Kemono Friends,
Media mix,
けものフレンズ,
メディアミックス
Huawei P9: Pocketnow: More than just a pair of cameras?
- HiSilicon Kirin 955
- 6.95mm thickness
- Leica Dual cameras
ラベル:
HiSilicon,
Huawei,
Huawei P9,
Leica Camera
Huawei Mate 9: Pocketnow: One Week Later
- HiSilicon (Huawei) Kirin 960
- Dual cameras
- Leica Camera
- Dual speakers
- Android 7.0
ラベル:
HiSilicon,
Huawei,
Huawei Mate 9,
Leica Camera
Cron: Copying all Labels from Blog to a File (Example)
Command:
$ cat smashingtheory_label_urls.sh
Result:
if [ $# -eq 1 ]; then
curl -s https://smashingtheory.blogspot.jp | sed -n "s/.*dir='ltr' href='https:\/\/smashingtheory.blogspot.jp\/search\/label\/\\([^']*\\).*/\1/p" > $1
else
echo "Usage: smashingtheory_label_urls.sh FILENAME" >&2
fi
Note:
Double backslashes before the round brackets should be single backslash. I did this to escape Mathjax's behavior.
$ cat smashingtheory_label_urls.sh
Result:
if [ $# -eq 1 ]; then
curl -s https://smashingtheory.blogspot.jp | sed -n "s/.*dir='ltr' href='https:\/\/smashingtheory.blogspot.jp\/search\/label\/\\([^']*\\).*/\1/p" > $1
else
echo "Usage: smashingtheory_label_urls.sh FILENAME" >&2
fi
Note:
Double backslashes before the round brackets should be single backslash. I did this to escape Mathjax's behavior.
ラベル:
Bash (Unix shell),
Blogger (service),
Cron,
cURL,
sed
Saturday, May 20, 2017
Tuesday, May 16, 2017
Monday, May 15, 2017
Sunday, May 14, 2017
NHKスペシャル: 映像の世紀: 第5集: 世界は地獄を見た: 無差別爆撃、ホロコースト、そして原爆
- マジノ要塞
- Maginot Line (マジノ線)
- ワルシャワ
- 部屋はありませんか?
- ゲットーのユダヤ人
- Bataan Death March (バターン死の行進)
- The Battle of China (ザ・バトル・オブ・チャイナ)
- アブラハム・レビンの回想
NHKスペシャル: 映像の世紀: 第4集: ヒトラーの野望: 人々は民族の復興を掲げたナチス・ドイツに未来を託した
Adolf Hitler (アドルフ・ヒトラー) |
- Adolf Hitler (アドルフ・ヒトラー)
- Puyi (愛新覚羅溥儀)
- Inukai Tsuyoshi (犬養毅)
- Nanking Massacre (南京事件 (1937年))
- Francisco Franco (フランシスコ・フランコ)
- Bombing of Guernica (ゲルニカ爆撃)
- Guernica (Picasso) (ゲルニカ (絵画))
- Braunau am Inn (ブラウナウ・アム・イン)
- Keep Calm and Dig
- Benito Mussolini (ベニート・ムッソリーニ)
- Neville Chamberlain (ネヴィル・チェンバレン)
- Sudetenland (ズデーテン地方)
- Invasion of Poland (ポーランド侵攻)
ラベル:
Nanking Massacre,
People,
南京事件 (1937年),
映像の世紀
Friday, May 12, 2017
NHKスペシャル: 映像の世紀: 第2集 大量殺戮の完成: 塹壕の兵士たちはすさまじい兵器の出現を見た
- Trench warfare (塹壕)
- 塹壕足
- Tank (戦車)
- Winston Churchill (ウィンストン・チャーチル)
- Lawrence of Arabia (film) (アラビアのロレンス)
- T. E. Lawrence (トーマス・エドワード・ロレンス)
NHKスペシャル: 映像の世紀: 第1集 20世紀の幕開け: カメラは歴史の断片をとらえ始めた
- 夏目漱石
- パリ万国博覧会 (1900年)
- パリジェンヌ
- さあ着飾って外に出よう
- Queen Victoria (ヴィクトリア (イギリス女王))
- 喪服
- Mourning dress
- Leo Tolstoy (レフ・トルストイ)
- Isadora Duncan (イサドラ・ダンカン)
- Bloody Sunday (1905) (血の日曜日事件 (1905年))
- Nicholas II of Russia (ニコライ2世)
- インディアン・オピニオン
- 無抵抗主義の人々
- Mahatma Gandhi (マハトマ・ガンディー)
- Grand Duchess Anastasia Nikolaevna of Russia (アナスタシア・ニコラエヴナ)
- Grigori Rasputin (グリゴリー・ラスプーチン)
- Assassination of Archduke Franz Ferdinand of Austria (サラエボ事件)
- Black Hand (Serbia) (黒手組)
- House of Habsburg (ハプスブルク家)
Wednesday, May 10, 2017
Tuesday, May 9, 2017
Monday, May 8, 2017
ZEITGEIST: ADDENDUM (2008)
John Perkins (author) |
Roxanne Meadows |
- Dept (債務)
- Interest (利子)
- Greenback (1860s money)
- Bank (銀行)
- Economic hitman
- John Perkins
- Corporatocracy
- Scarcity
- Venus Project
ラベル:
Bank,
Corporatocracy,
Dept,
Greenback (1860s money),
Interest,
People,
Scarcity,
Venus Project,
債務,
利子,
希少性,
銀行
Friday, May 5, 2017
Thursday, May 4, 2017
Swift: Random Message Example
Command:
$ cat /Users/username/Desktop/macOS\ Swift\ Test/macOS\ Swift\ Test/main.swift
Result:
import Foundation
import Darwin
let goodmorning: Array<String> = ["おはよう!","おはようございます。","やあ!","ねむたそうだね","おっはー!","グッドモーニング!","モーニング!","今日もよろしく!"]
let randomIndex = Int(arc4random_uniform(UInt32(goodmorning.count)))
print("\(goodmorning[randomIndex])")
Command:
$ /Users/username/Library/Developer/Xcode/DerivedData/macOS_Swift_Test-arwavijyybnxpmctpfzeonufbnvy/Build/Products/Debug/macOS\ Swift\ Test ;
Result:
モーニング!
$ cat /Users/username/Desktop/macOS\ Swift\ Test/macOS\ Swift\ Test/main.swift
Result:
import Foundation
import Darwin
let goodmorning: Array<String> = ["おはよう!","おはようございます。","やあ!","ねむたそうだね","おっはー!","グッドモーニング!","モーニング!","今日もよろしく!"]
let randomIndex = Int(arc4random_uniform(UInt32(goodmorning.count)))
print("\(goodmorning[randomIndex])")
Command:
$ /Users/username/Library/Developer/Xcode/DerivedData/macOS_Swift_Test-arwavijyybnxpmctpfzeonufbnvy/Build/Products/Debug/macOS\ Swift\ Test ;
Result:
モーニング!
ラベル:
macOS Sierra,
Swift
Wednesday, May 3, 2017
Monday, May 1, 2017
Subscribe to:
Posts (Atom)