Skip to content

Instantly share code, notes, and snippets.

View wuriyanto48's full-sized avatar

wuriyanto wuriyanto48

View GitHub Profile
@wuriyanto48
wuriyanto48 / interval.js
Created July 26, 2022 06:03
Nodejs setInterval usage for delay execution
let sendStatus = 'FAILED';
// DELAY in Milliseconds
const DELAY = 1000; // 1 second
const retryEmail = () => {
console.log('retry failed email');
return 'FAILED';
};
@wuriyanto48
wuriyanto48 / Makefile
Created July 1, 2022 06:34
Scheduling Cron (Golang)
.PHONY : test build clean format
ALL_PACKAGES=$(shell go list ./... | grep -v "vendor")
test:
$(foreach pkg, $(ALL_PACKAGES),\
go test -race -short $(pkg);)
build:
@echo "building binary"
@wuriyanto48
wuriyanto48 / graphite_install.sh
Created June 10, 2022 03:37 — forked from amoslanka/graphite_install.sh
Install StatsD on an Ubuntu box, including creating an upstart service and the option to build a graphite box or configure Librato as a backend.
#
# Assumes an independent box (we'll call this one "graphite")
#
# Stay up to date
sudo apt-get update
sudo apt-get upgrade
# Install git
sudo apt-get install g++ curl libssl-dev -y
@wuriyanto48
wuriyanto48 / main.go
Last active October 23, 2022 18:02
Draw Circle to Console (implementation with Golang)
package main
import (
"bytes"
"fmt"
"math"
"strings"
)
// α(radians) = α(degrees) × π / 180°
@wuriyanto48
wuriyanto48 / main.go
Created May 5, 2022 10:12
luhn's algorithm for validating Credit Card
// luhn's algorithm
// https://en.wikipedia.org/wiki/Luhn_algorithm
package main
import (
"errors"
"fmt"
"strconv"
"strings"
)
@wuriyanto48
wuriyanto48 / main.go
Last active June 18, 2023 06:40
ELO Rating System implementation example with Golang
package main
import (
"errors"
"fmt"
"math"
)
// K K-factor
const K = 30
@wuriyanto48
wuriyanto48 / main.go
Last active April 15, 2022 14:39
Queue data structure Golang
package main
import (
"fmt"
)
type Queue[T any] struct {
elements []T
size uint
rear uint
@wuriyanto48
wuriyanto48 / README.md
Created April 4, 2022 05:11
Convert OpenSSH Private Key to RSA Private Key

Your OpenSSH Private Key looks like this

-----BEGIN OPENSSH PRIVATE KEY-----
b34ahC
-----END OPENSSH PRIVATE KEY-----

First, backup your OpenSSH Private Key

$ cp server_ssh.key server_ssh.key.backup
@wuriyanto48
wuriyanto48 / main.go
Created April 1, 2022 08:21
Radian to Degree and Degree to Radian
package main
import (
"fmt"
"math"
)
// α(radians) = α(degrees) × π / 180°
func DegToRad(deg float64) float64 {
return deg * (math.Pi / 180)
@wuriyanto48
wuriyanto48 / main.go
Last active April 5, 2022 14:49
golang pointer arithmetic
package main
import (
"fmt"
"unsafe"
)
type sample struct {
a int
b string