Skip to content

Instantly share code, notes, and snippets.

View wuriyanto48's full-sized avatar

wuriyanto wuriyanto48

View GitHub Profile
@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)
@wuriyanto48
wuriyanto48 / index.js
Last active February 4, 2022 05:55
Number to Indonesian Rupiah format in Javascript
var t = (10000000.000000).toLocaleString('ID', {
style: 'currency',
currency: 'IDR',
});
console.log(t);
@wuriyanto48
wuriyanto48 / index.js
Last active November 12, 2022 18:32
Nodejs, Golang pull multiple file from the server, then archives all files to ZIP and all running processes in memory without writing them to disc
const rp = require('request-promise');
const Stream = require('stream');
const archiver = require('archiver');
const fs = require('fs');
const load = async () => {
let streams = [];
for (let i = 0; i < 3; i++) {
let res = await rp.get(
{
@wuriyanto48
wuriyanto48 / main.go
Created January 20, 2022 05:43
Golang process large amount of query result
package main
import "fmt"
func main() {
// set channel buffer = 2
dataOut := make(chan string, 2)
done := make(chan bool, 1)
go QueryData(dataOut)
@wuriyanto48
wuriyanto48 / Vagrantfile
Last active January 9, 2022 12:00
Setup Openfire XMPP Server on Ubuntu
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@wuriyanto48
wuriyanto48 / index.js
Created January 1, 2022 08:33
Javascript Timezone
// get local timezone offset and convert to millisecond
var d = new Date();
var offset = d.getTimezoneOffset();
const localOffsetMillis = 60 * 1000 * offset;
console.log(localOffsetMillis);
// get local timezone name
var dtf = Intl.DateTimeFormat();
var dtfResolveOptions = dtf.resolvedOptions();
var tz = dtfResolveOptions.timeZone;
@wuriyanto48
wuriyanto48 / README.md
Created December 7, 2021 07:26
Kafka, Redis, Elastic Search, Mongodb with docker compose

Run

$ docker-compose up