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
| // n = file line number | |
| func getLine(filename string, n int) (string, error) { | |
| if n < 1 { | |
| return "", fmt.Errorf("invalid request: line %d", n) | |
| } | |
| f, err := os.Open(filename) | |
| if err != nil { | |
| return "", err | |
| } | |
| defer f.Close() |
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
| kubernetes commands | |
| kubectl get pods && kubectl get services --all-namespaces | |
| kubectl get nodes - список нодов | |
| kubectl taint nodes --all node-role.kubernetes.io/master- - запуска подов на мастере. | |
| kubectl get pod redis --watch |
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
| function extractHostname(url) { | |
| var hostname; | |
| //find & remove protocol (http, ftp, etc.) and get hostname | |
| if (url.indexOf("//") > -1) { | |
| hostname = url.split('/')[2]; | |
| } | |
| else { | |
| hostname = url.split('/')[0]; | |
| } | |
| //find & remove port number |
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
| FROM golang:1.12 | |
| WORKDIR $GOPATH/src/project | |
| COPY . . | |
| RUN go get -d -v ./... | |
| RUN go install -v ./... |
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
| // 'Hello World' nodejs6.10 runtime AWS Lambda function | |
| exports.handler = (event, context, callback) => { | |
| console.log('Hello, logs!'); | |
| callback(null, 'great success'); | |
| } |
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
| var http = require('http'); | |
| exports.handler = function( event, context ){ | |
| http.get({'host': 'api.ipify.org', 'port': 80, 'path': '/'}, function(resp) { | |
| resp.on('data', function(ip) { | |
| context.succeed(ip.toString()); | |
| }); | |
| resp.on('error', context.fail); | |
| }); | |
| }; |
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
| const AWS = require('aws-sdk'); | |
| AWS.config.update({ | |
| accessKeyId: "", | |
| secretAccessKey: "", | |
| region : "" | |
| }); | |
| function uploadReport(dest, file, report) |
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" | |
| "log" | |
| "strings" | |
| "github.com/PuerkitoBio/goquery" | |
| ) |
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" | |
| "math/rand" | |
| "net/http" | |
| "net/url" | |
| "time" | |
| ) |
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 readLine(path string) { | |
| inFile, _ := os.Open(path) | |
| defer inFile.Close() | |
| scanner := bufio.NewScanner(inFile) | |
| scanner.Split(bufio.ScanLines) | |
| for scanner.Scan() { | |
| fmt.Println(scanner.Text()) | |
| } | |
| } |