Skip to content

Instantly share code, notes, and snippets.

View iamucil's full-sized avatar
:octocat:
Working remotelly.

iamucil iamucil

:octocat:
Working remotelly.
View GitHub Profile
@iamucil
iamucil / extract.go
Created June 5, 2023 12:44
Extract metadata from pdf file
package pdflib
import (
"fmt"
"time"
"github.com/timemore/foundation/errors"
pdf "github.com/unidoc/unipdf/v3/model"
)
@iamucil
iamucil / rename_interface_any.md
Last active June 6, 2023 07:30
First thing to do after moving to go 1.19

Rename all interface{} to any

find . -type f -name "*.go" | xargs gofmt -w -r 'interface{} -> any' 

Run SQL script in maria/mysql db container

Run this script from your local machine,

docker exec -i CONTAINER_ID sh -c \
	'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD" YOUR_DATABASE' \
	< your_file.sql 
@iamucil
iamucil / generate_jwt_token_for_header_signature.js
Last active November 15, 2021 11:47
Postman Pre-Request script to generate JWT token from request body.
/*
https://jwt.io/introduction/
In its compact form, JSON Web Tokens consist of three parts separated by dots (.), which are:
Header
Payload
Signature
Therefore, a JWT typically looks like the following.
@iamucil
iamucil / auto load go(lang) code.md
Last active July 31, 2021 09:40
Auto loading go(lang) code dengan docker-compose

Autoloading go(lang) code menggunakan docker-compose

Buat docker file untuk development development.Dockerfile

FROM cosmtrek/air AS loader

FROM golang:1.16

WORKDIR /workspace
@iamucil
iamucil / git_ssl_verify.md
Created April 7, 2021 04:45
How do I set GIT_SSL_NO_VERIFY for specific repos only?
fatal: unable to access 'https://baseurl/username/repo_name.git/': SSL certificate problem: unable to get local issuer certificate
error: Could not fetch upstream

Use this command to make git not verify ssl certificate. If you want to unverify all git repo use --global instead of --local. Run this inside your working directory.

git config --local http.sslVerify false
@iamucil
iamucil / hmacsignaturegenerator.md
Created April 2, 2021 23:24
hmac signature sha256
clientID = pm.variables.get("CLIENT_ID");
clientSecret = pm.variables.get("CLIENT_SECRET");
authStr = btoa(clientID +":"+ clientSecret);
pm.environment.set("BASIC_AUTHORIZATION_REQUEST",authStr);
apiKey = pm.variables.get("API-Key");
var ts = (new Date()).toISOString();
pm.environment.set("Timestamp", ts);

var jsonReq = JSON.parse(pm.request.body);
@iamucil
iamucil / gen-secure-password.sh
Created July 24, 2020 07:34
Generate secure password using openssl
openssl rand -base64 32 | tr -d "=+/" | cut -c1-16
#!/bin/bash
# echo "data:$(xdg-mime query filetype 02_KTP.png);base64,$(base64 -w 0 02_KTP.png)"
filename=
usage() {
echo "usage: base64encode [[-f file ] | [-h]]"
}
exiftool -r '-FileName<${model;}_${createdate#;DateFmt("%Y-%m-%d_%H%M%S")}%-c.$FileTypeExtension' '-Directory<${model;}/${createDate#;DateFmt("%Y/%m")}' .
File format
-d %Y-%m-%d_%H%M%S%%-c.%%e
Date format for folder
-d %Y/%m/%d