Skip to content

Instantly share code, notes, and snippets.

View wuriyanto48's full-sized avatar

wuriyanto wuriyanto48

View GitHub Profile
@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
@wuriyanto48
wuriyanto48 / gpg.md
Last active March 19, 2022 08:40
How to Manage, Create, and Use The GNU Privacy Guard (also known as PGP)

What is a GPG key?

The GPG key (means: Gnu Privacy Guard, aka GnuPG) is a free software which provides cryptographic privacy and authentication.

It allow users to communicate securely using public-key cryptography.

How Does the GPG key work on Repository?

All packages are signed with a pair of keys consisting of a private key and a public key, by the package maintainer.

A user’s private key is kept secret and the public key may be given to anyone the user wants to communicate.

@wuriyanto48
wuriyanto48 / max_call_stack_size_exceeded.js
Last active March 15, 2022 18:30
Javascript How to fix: RangeError: Maximum call stack size exceeded
let arr = [];
for (let i = 0; i < 1000000; i++) {
arr.push(i);
}
let arr2 = [];
// Something else here that changes arr2:
arr2.push(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@wuriyanto48
wuriyanto48 / generate_key_step.md
Last active March 1, 2022 14:46
Golang Parsing RSA Private Key and Public Key

generate private key:

openssl genrsa -out private_key.pem 4096

generate public key:

openssl rsa -pubout -in private_key.pem -out public_key.pem
@wuriyanto48
wuriyanto48 / main.go
Created February 4, 2022 05:54
go for loop multiple select
package main
import (
"fmt"
"time"
)
func main() {
tick := time.Tick(100 * time.Millisecond)