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
| package main | |
| import "fmt" | |
| func main() { | |
| fmt.Println("hello world") | |
| } |
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
| package main | |
| import "fmt" | |
| func main() { | |
| fmt.Println("hello world") | |
| } |
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
| echo "Need root permission." | |
| sudo echo "Done." | |
| read -p "1. Enter username: " username | |
| read -p "2. Enter comment: " comment | |
| sudo adduser $username -c "$comment" --firstuid 10000 --ingroup developers --disabled-password --gecos "" | |
| echo "User created!" | |
| echo -e "$username\n$username" | sudo passwd $username >/dev/null 2>&1 | |
| sudo passwd -e $username >/dev/null 2>&1 | |
| echo "username : $username" | |
| echo "initial password : $username" |
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
| # install ubuntu packages | |
| apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ | |
| libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ | |
| xz-utils tk-dev | |
| touch ~/.bash_profile | |
| # install pyenv | |
| git clone https://github.com/pyenv/pyenv.git ~/.pyenv | |
| echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile |
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
| public enum Result<Value> { | |
| case Success(Value) | |
| case Failure(NSData?, ErrorType) | |
| } |
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
| func evaluate(_ expression: ArithmeticExpression) -> Int { | |
| switch expression { | |
| case let .number(value): | |
| return value | |
| case let .addition(left, right): | |
| return evaluate(left) + evaluate(right) | |
| case let .multiplication(left, right): | |
| return evaluate(left) * evaluate(right) | |
| } | |
| } |
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
| enum ArithmeticExpression { | |
| case number(Int) | |
| indirect case addition(ArithmeticExpression, ArithmeticExpression) | |
| indirect case multiplication(ArithmeticExpression, ArithmeticExpression) | |
| } |
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
| // declare variables. | |
| var today = WeatherCondition.sunny(24) | |
| var yesterday = WeatherCondition.cloudy(Cloud.cirrus, 10) | |
| switch today { | |
| case .sunny(let temperature): | |
| print("today's temperature is \(temperature).") | |
| case .rainy(let inchesPerHour): | |
| print("\(inchesPerHour) inches of rainwater.") |
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
| enum Cloud { | |
| case cirrus | |
| case cumulus | |
| case altocumulus | |
| case cumulonimbus | |
| } | |
| enum WeatherCondition { | |
| case sunny(temperature: Float) | |
| case rainy(inchesPerHour: Float) |
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
| // Enumeration of type Fruit. | |
| enum Fruit: Int { | |
| case apple = 1000 | |
| case banana = 500 | |
| case grape = 2500 | |
| } | |
| // declare variable. | |
| let orderedFruit: Fruit = .apple |