Skip to content

Instantly share code, notes, and snippets.

View luqmansen's full-sized avatar
🎯
Focusing

Luqman luqmansen

🎯
Focusing
View GitHub Profile
@luqmansen
luqmansen / debugstruct.go
Created November 17, 2021 10:26
Debug Golang Struct
func debugStruct(d interface{}) {
s, _ := json.MarshalIndent(d, "", "\t")
fmt.Println(string(s))
}
@luqmansen
luqmansen / docker-compose.yaml
Last active June 27, 2021 09:21
mysql docker compose
version: '3.1'
services:
db:
image: mysql
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: morph
MYSQL_USER: mysql
@luqmansen
luqmansen / main.go
Created June 10, 2021 15:23
Exit a for loop using channel
package main
import (
"fmt"
"time"
)
func main() {
function2()
@luqmansen
luqmansen / main.go
Created June 3, 2021 14:56
stream stdout from long running asynchronous cmd
package main
import (
"bufio"
"fmt"
"os/exec"
"time"
)
func main() {
@luqmansen
luqmansen / main.go
Created May 23, 2021 15:21
Golang Make sure all goroutine function executed unless there is an error
package main
import (
"errors"
"fmt"
"log"
"os"
"strconv"
"sync"
"time"
@luqmansen
luqmansen / mime.types
Created April 29, 2021 17:44
Apache mime type
# This file maps Internet media types to unique file extension(s).
# Although created for httpd, this file is used by many software systems
# and has been placed in the public domain for unlimited redisribution.
#
# The table below contains both registered and (common) unregistered types.
# A type that has no unique extension can be ignored -- they are listed
# here to guide configurations toward known types and to make it easier to
# identify "new" types. File extensions are also commonly used to indicate
# content languages and encodings, so choose them carefully.
#
mkdir -p k8s/cert/ && cd k8s/cert/
openssl req -nodes -newkey rsa:2048 -keyout dashboard.key -out dashboard.csr -subj "/C=/ST=/L=/O=/OU=/CN=*"
openssl x509 -req -sha256 -days 3650 -in dashboard.csr -signkey dashboard.key -out dashboard.crt
microk8s kubectl -n kube-system delete secret kubernetes-dashboard-certs
microk8s kubectl -n kube-system create secret generic kubernetes-dashboard-certs --from-file=dashboard.crt --from-file=dashboard.key
microk8s kubectl -n kube-system edit deploy kubernetes-dashboard -o yaml
# change args part
args:
@luqmansen
luqmansen / conn_pool.py
Last active August 18, 2022 16:55
Simple Object Pool pattern to Create Connection Pool
from datetime import datetime
from multiprocessing import Lock
import mysql.connector
USER = "root"
PASSWD = "admin"
HOST = 'localhost'
DB = "db_test"
@luqmansen
luqmansen / init_ubuntu_mate.sh
Last active July 15, 2020 17:33
Debloat ubuntu mate 16.04
sudo apt-get remove account-plugin-facebook account-plugin-flickr account-plugin-jabber account-plugin-salut account-plugin-twitter account-plugin-windows-live account-plugin-yahoo aisleriot brltty duplicity empathy empathy-common
sudo apt remove rhythmbox rhythmbox-plugins rhythmbox-plugin-zeitgeist sane-utils shotwell shotwell-common telepathy-gabble telepathy-haze telepathy-idle telepathy-indicator telepathy-logger telepathy-mission-control-5 telepathy-salut
sudo apt install git zsh curl
/bin/bash -c "$(curl -sL https://git.io/vokNn)"
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
@luqmansen
luqmansen / download_google_image.js
Created July 10, 2020 10:10
Download All Image from google search, THIS IS NOT MINE, I JUST AGGREGATING IT, original credit goes to pyimagesearch.com
function simulateRightClick( element ) {
var event1 = new MouseEvent( 'mousedown', {
bubbles: true,
cancelable: false,
view: window,
button: 2,
buttons: 2,
clientX: element.getBoundingClientRect().x,
clientY: element.getBoundingClientRect().y
} );