Skip to content

Instantly share code, notes, and snippets.

View wuriyanto48's full-sized avatar

wuriyanto wuriyanto48

View GitHub Profile
@alexedwards
alexedwards / main_test.go
Last active April 17, 2024 03:46
MaxOpenConns benchmark
package main
import (
"database/sql"
"testing"
"time"
_ "github.com/lib/pq"
)
@tboerger
tboerger / gist:4840e1b5464fc26fbb165b168be23345
Created February 17, 2017 09:37
Golang LDAP search and authentication
package main
import (
"fmt"
"strings"
"gopkg.in/ldap.v2"
)
const (
ldapServer = "ad.example.com:389"
@dgonzo
dgonzo / predict.js
Last active November 29, 2019 20:28
Predictions with AWS Machine Learning w/ JavaScript (Node.js)
/*
Setup your aws account and create a credentials file:
$ mkdir ~/.aws # if it doesn't exist
$ cat <<'EOF' >> ~/.aws/credentials
[default]
aws_secret_access_key = "secret key"
aws_access_key_id = "your id"
EOF
Install aws module:
@thealexcons
thealexcons / jwt_golang_example.go
Last active April 16, 2023 03:04
JSON Web Tokens in Go
package main
import (
"io/ioutil"
"log"
"strings"
"net/http"
"encoding/json"
"fmt"
"time"
@harlow
harlow / golang_job_queue.md
Last active April 24, 2024 10:21
Job queues in Golang
@denji
denji / golang-tls.md
Last active April 29, 2024 03:39 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@skeggse
skeggse / crypto-pbkdf2-example.js
Last active April 17, 2024 21:04
Example of using crypto.pbkdf2 to hash and verify passwords asynchronously, while storing the hash and salt in a single combined buffer along with the original hash settings
var crypto = require('crypto');
// larger numbers mean better security, less
var config = {
// size of the generated hash
hashBytes: 32,
// larger salt means hashed passwords are more resistant to rainbow table, but
// you get diminishing returns pretty fast
saltBytes: 16,
// more iterations means an attacker has to take longer to brute force an
@ikennaokpala
ikennaokpala / _.sh
Last active June 10, 2021 07:24
Starting up and Monitoring a Golang binary in production
# Make it executable
sudo chmod +x etc/init.d/myapp
# Try it:
sudo service myapp start
# Make it run upon boot:
sudo update-rc.d myapp defaults
@jakecoffman
jakecoffman / go_functional.go
Last active December 14, 2021 16:04
Example of functional programming in Golang.
package main
import (
"constraints"
"fmt"
)
func main() {
fmt.Println(Sum(1, 2, 3, 4))
fmt.Println(Sum("1", "2", "3"))
@ardan-bkennedy
ardan-bkennedy / GoMgoSample-1.go
Last active February 27, 2021 08:31
Sample Go and MGO example
type (
// BuoyCondition contains information for an individual station.
BuoyCondition struct {
WindSpeed float64 `bson:"wind_speed_milehour"`
WindDirection int `bson:"wind_direction_degnorth"`
WindGust float64 `bson:"gust_wind_speed_milehour"`
}
// BuoyLocation contains the buoy's location.
BuoyLocation struct {