This file contains 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
#cloud-config | |
write_files: | |
- path: /etc/environment | |
content: | | |
DOCKER_CLI_EXPERIMENTAL="enabled" | |
DOCKER_BUILDKIT=1 | |
EDITOR=vim | |
append: true | |
- path: /etc/docker/daemon.json | |
content: | |
This file contains 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
#!/usr/bin/env zsh | |
# vim: ts=2 sw=2 | |
export AUTOENV_IN_FILE=".env" | |
export AUTOENV_OUT_FILE="~/.bashrc" | |
if [[ -z "$AUTOENV_AUTH_FILE" ]]; then | |
AUTOENV_AUTH_FILE=~/.autoenv_authorized | |
fi |
This file contains 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
# Custom zsh plugin called gopath | |
gopath() { | |
: ${1?=GOROOT required} | |
: ${2?=GOPATH required} | |
cat > ~/.gopath <<EOF | |
export GOROOT=$1 | |
export GOPATH=$2 | |
export PATH="$1/bin:$2/bin:\$ORIGINAL_PATH" | |
EOF |
This file contains 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
@kubernetes:Deployment { | |
image: "exchange-simple:v.1.0", | |
dockerHost: "tcp://192.168.99.100:2376", | |
dockerCertPath: "/Users/mhmxs/.minikube/certs" | |
} | |
@http:ServiceConfig { | |
basePath: "/exchangeSimple" | |
} | |
@kubernetes:Service { | |
serviceType: "NodePort" |
This file contains 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 ballerina/http; | |
import ballerina/io; | |
http:Client simpleEndpoint = new("http://localhost:9091/exchangeSimple/getRate"); | |
http:Client enterpriseEndpoint = new("http://localhost:9092/exchangeEnterprise/getRate", config = { | |
retryConfig: { | |
interval: 3000, | |
count: 2, | |
backOffFactor: 2.0, | |
maxWaitInterval: 20000 |
This file contains 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 ballerina/http; | |
type Operand "+"|"-"|"*"|"/"; | |
type Operation record { | |
float leftSide = 0; | |
float rightSide = 0; | |
Operand operand?; | |
!... | |
}; |
This file contains 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
type Response record { | |
string currency; | |
float rate; | |
string description?; | |
}; | |
type Handler object { | |
private Exchanger e = new; | |
function generateResponse(http:Request request) returns json|error; |
This file contains 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
service exchangeEnterprise on new http:Listener(9092) { | |
private Handler handler = new; | |
resource function getRate(http:Caller caller, http:Request request) { | |
json|error message = self.handler.generateResponse(request); | |
http:Response response = new; | |
if (message is json) { | |
response.setJsonPayload(message); | |
} else { |
This file contains 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
type CurrencyNotFoundError error<string>; | |
type Exchanger object { | |
private map<float> currencies; | |
function __init() { | |
map<float> currencies = { | |
USD: 34.80, | |
EUR: 35.70, | |
GBP: 32.00 |
This file contains 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
function generateResponse(string|error payload) returns @untainted json { | |
return payload is string | |
? { currency: payload, rate: getExchangeRate(payload) } | |
: { "error": string `Invalid currency: {{payload.reason()}}` }; | |
} | |
function getExchangeRate(string currency) returns float { | |
match currency { | |
"USD"|"EUR" => return 35.50; | |
"GBP" => return 32.00; |