start new:
tmux
start new with session name:
tmux new -s myname
| func hangman(secretWord string, letters []string) bool { | |
| lettersMap := make(map[string]bool) | |
| for _, v := range letters { | |
| lettersMap[v] = true | |
| } | |
| for _, v := range secretWord { | |
| _, ok := lettersMap[string(v)] | |
| if !ok { | |
| return false | |
| } |
| package main | |
| import ( | |
| "fmt" | |
| "strconv" | |
| ) | |
| func binaryGap(n int) int { | |
| binStr := string(strconv.FormatInt(int64(n), 2)) | |
| longestGap := 0 |
#todayilearned #onunixandgo
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "time" | |
| ) | |
| func main() { | |
| candidates := []string{ |
| package main | |
| import ( | |
| "github.com/labstack/echo/v4" | |
| "net/http" | |
| ) | |
| type Response struct { | |
| Data interface{} `json:"data,omitempty"` | |
| Status string `json:"status,omitempty"` |
| const input = ["ab", "aabbcc", "ababab", "abaabcca"]; | |
| const sol = (words) => | |
| words.map( | |
| (word) => | |
| word.split("").reduce( | |
| (prev, cur) => | |
| prev.lastChar === cur | |
| ? { | |
| ...prev, |
| Dio initDioClient() { | |
| final dio = Dio(); | |
| (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) { | |
| client.badCertificateCallback = (X509Certificate cert, String host, int port) => true; | |
| }; | |
| return dio; | |
| } |
| use std::fs; | |
| fn main() { | |
| let content = | |
| fs::read_to_string("/usr/share/dict/words").unwrap_or("cannot read file".to_string()); | |
| let longest_word = | |
| content.split("\n").fold( | |
| "", | |
| |prev, cur| if cur.len() > prev.len() { cur } else { prev }, | |
| ); |
| package logger | |
| import ( | |
| "errors" | |
| "fmt" | |
| "io" | |
| "github.com/rs/zerolog" | |
| ) |