Skip to content

Instantly share code, notes, and snippets.

View olehcambel's full-sized avatar
🐍

Олег Моисеенко olehcambel

🐍
  • @[object Object]
  • Kyiv
View GitHub Profile
require("microtime");
const
_ = require('lodash'),
Benchmark = require('benchmark'),
suite = new Benchmark.Suite,
result = [],
seedSize = 10000,
seedData = Array(seedSize).fill().map(() => String(Math.round(Math.random() * seedSize))).reduce((obj, val) => {
@olehcambel
olehcambel / who-face.go
Last active May 20, 2020 07:20
detect face
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"regexp"
"github.com/Kagami/go-face"
package main
import (
"bufio"
"fmt"
"log"
"os"
)
/*
list.txt
@olehcambel
olehcambel / status-checker.go
Last active May 16, 2020 14:59
check status code of websites
package main
import (
"fmt"
"net/http"
"runtime"
)
func printDomain(d string) {
fmt.Println(d)
@olehcambel
olehcambel / recover-panic.go
Created May 8, 2020 09:01
A way to recover from panic (regexp) and return error.
// Error is the type of a parse error; it satisfies the error interface.
type Error string
func (e Error) Error() string {
return string(e)
}
// error is a method of *Regexp that reports parsing errors by
// panicking with an Error.
func (regexp *Regexp) error(err string) {
panic(Error(err))
package main
import (
"fmt"
"runtime"
"time"
)
var numCPU = runtime.NumCPU()
package main
import (
"fmt"
"net/http"
"time"
)
const maxOutstanding = 2
@olehcambel
olehcambel / channel.go
Last active May 5, 2020 16:53
buffered/unbuffered channel impl.
package main
import (
"fmt"
"time"
)
func main() {
c := make(chan int) // Allocate a channel.
// uncomment this line
@olehcambel
olehcambel / implements.go
Last active May 5, 2020 10:24
A way to check if struct implements an interface
package main
import (
"sort"
)
type RawMessage []int
func (mes RawMessage) Len() int {
return len(mes)
package main
import (
"fmt"
"math/rand"
"time"
)
// Query a replicated database
// Teardown of late finishers is left as an exercise.