Skip to content

Instantly share code, notes, and snippets.

@freakynit
freakynit / readMemStatsExample.go
Created November 29, 2021 04:08
Example usage of runtime.ReadMemStats function
package main
import (
"fmt"
"runtime"
"strconv"
"time"
)
func printMemStats(message string, rtm runtime.MemStats){
@resistancecanyon
resistancecanyon / multipleImageContentReader.js
Last active September 5, 2024 08:29
Reading Multiple Image Base64 data using Es6 Async/Await in a html:type:file input
// 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) {
@miguelmota
miguelmota / server.go
Last active August 24, 2024 18:36
Golang TCP server example
package server
import (
"bufio"
"fmt"
"log"
"net"
)
// Server ...
@kschaper
kschaper / infinite_loop.go
Last active March 21, 2024 14:02
CPU friendly infinite loop in Go
// CPU friendly
for {
select {
case <-time.After(time.Second):
// do something
}
}
// instead of busy loop
for {
@voskobovich
voskobovich / gist:537b2000108e4781f70b
Last active June 30, 2024 01:33
List of most currency ISO code and symbol format in SQL.
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;