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" | |
| "runtime" | |
| "strconv" | |
| "time" | |
| ) | |
| func printMemStats(message string, rtm runtime.MemStats){ |
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
| // html | |
| // <input type="file" onchange="imagesSelected" multiple accept=".gif,.jpg,.jpeg,.png" /> | |
| async function imagesSelected(event) { | |
| let files = [...event.target.files]; | |
| let images = await Promise.all(files.map(f=>{return readAsDataURL(f)})); | |
| //all images' base64encoded data will be available as array in images | |
| } | |
| function readAsDataURL(file) { |
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 server | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "log" | |
| "net" | |
| ) | |
| // Server ... |
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
| // CPU friendly | |
| for { | |
| select { | |
| case <-time.After(time.Second): | |
| // do something | |
| } | |
| } | |
| // instead of busy loop | |
| for { |
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
| DROP TABLE currency; | |
| -- Create table variable | |
| CREATE TABLE currency ( | |
| name VARCHAR(20), | |
| code VARCHAR(3), | |
| symbol VARCHAR(5) | |
| ); | |
| ALTER TABLE currency CONVERT TO CHARACTER SET utf8; |