Skip to content

Instantly share code, notes, and snippets.

View wuriyanto48's full-sized avatar

wuriyanto wuriyanto48

View GitHub Profile
@wuriyanto48
wuriyanto48 / index.js
Created March 13, 2023 04:26
Nodejs: Fetch Google Analytic 4 data with google-analytics/data module
const { BetaAnalyticsDataClient } = require('@google-analytics/data');
const PROPERTY_ID = '292104555';
const analyticsDataClient = new BetaAnalyticsDataClient({
keyFile: 'credentials.json'
});
// Runs a simple report.
async function runReport() {
@wuriyanto48
wuriyanto48 / index.js
Created March 13, 2023 03:58
Big Query Nodejs example
'use strict';
function main() {
const projectId = 'project-name';
const datasetId = 'my_dataset';
const tableId = 'animals';
const datasetLocation = 'asia-southeast2';
// [START bigquery_client_json_credentials]
@wuriyanto48
wuriyanto48 / README.md
Created March 9, 2023 08:14
Vagrant WSL

This is caused when VAGRANT_WSL_ENABLE_WINDOWS_ACCESS environment variable is not set.

First Export Environment Variables

export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
export PATH="${PATH}:/mnt/c/Program Files/Oracle/VirtualBox"

Run Vagrant using following commands

@wuriyanto48
wuriyanto48 / main.go
Last active February 14, 2023 06:15
Golang os/exec: execute df command
package main
import (
"fmt"
"io"
"os"
"os/exec"
"regexp"
"strings"
"encoding/json"
@wuriyanto48
wuriyanto48 / Pbkdf2.java
Last active February 9, 2023 09:08
Keycloak Password Hash Implementation in Golang and Java
package com.wuriyanto.pbkdf2;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
@wuriyanto48
wuriyanto48 / convert.py
Created February 7, 2023 05:29
Python: convert oneline RSA key to multiline with Header
#!/usr/bin/env python
import sys
def main():
argc = len(sys.argv)
if argc < 3:
print("required keyfile and type")
print("eg: ./convert.py private.key private")
sys.exit(1)
@wuriyanto48
wuriyanto48 / README.md
Created February 3, 2023 15:20
Elasticsearch: Max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]: Windows
> wsl -d docker-desktop
> sysctl -w vm.max_map_count=262144
@wuriyanto48
wuriyanto48 / main.go
Last active February 3, 2023 20:37
Golang time to words
package main
import (
"errors"
"fmt"
"math"
"time"
)
func main() {
@wuriyanto48
wuriyanto48 / index.js
Created January 12, 2023 14:46
RSA | convert multiline RSA Private and Public key to oneline
const readline = require('readline');
const fs = require('fs');
const path = require('path');
function main() {
const args = process.argv;
if (args.length <= 2) {
console.log('required pem file argument');
process.exit(1);
}
@wuriyanto48
wuriyanto48 / index.js
Created December 5, 2022 07:57
axios custom httpAgent with root certificate
const https = require('https');
const axios = require('axios');
const fs = require('fs');
const httpsAgent = new https.Agent({
requestCert: true,
rejectUnauthorized: true,
ca: [fs.readFileSync('./root_cert.pem')],
// cert: [fs.readFileSync('./cert.pem')]
});