Skip to content

Instantly share code, notes, and snippets.

View smling's full-sized avatar

C. H. Ling smling

View GitHub Profile
@smling
smling / 1-create-schemash
Last active January 21, 2024 15:40
Install Giuacamole with Docker
# Get DB schema MySQL format and delete exit container.
# Remember run in server to setup structure.
docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --mysql > initdb.sql
docker rm $(docker ps --filter status=exited -q)
@smling
smling / enable-full-right-click-menu.bat
Created June 15, 2023 08:00
Enable full right click menu in Windows 11
reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
@smling
smling / get-package-latest-version.py
Created May 17, 2023 08:25
Get maven package latest version
import urllib.request
import xml.etree.ElementTree as ET
repository_url = "https://repo.maven.apache.org/maven2/"
package_name = "org.junit.jupiter.junit-jupiter-api"
metadata_url = repository_url + package_name.replace('.', '/') + "/maven-metadata.xml"
# Send a GET request and retrieve the XML content
with urllib.request.urlopen(metadata_url) as response:
@smling
smling / random-uuid.ps1
Last active March 14, 2023 20:48
Generate random UUID in PowerShell
<#
.Synopsis
Generate new UUID.
.Description
Powershell script to generate new UUID for different purpose.
.Parameter count
Optional parameter to specific number of UUID to be generated. By default it is 1 and maxium 500.
@smling
smling / git-repo-mirror.sh
Created March 1, 2023 18:04
Mirror Git repository
$source=$args[0]
$destination=$args[1]
$repoHome=$args[2]
$sourceUrl=[uri]$source
$folderName=$repoHome+"\\"+$source.Split('/')[-1]+".git"
cd $repoHome
git clone $source --mirror
cd $folderName
git push $destination --mirror
@smling
smling / get-latest-elastic-apm-agent-version.sh
Created March 1, 2023 18:00
Get latest elastic APM agent version
curl -s "https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/maven-metadata.xml" | xmllint --xpath "//metadata/versioning/release/text()" -
@smling
smling / install-oh-my-posh.sh
Created February 26, 2023 15:14
Setup oh-my-posh in Ubuntu Linux
# Install oh-my-posh and add executable permission.
sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
sudo chmod +x /usr/local/bin/oh-my-posh
# Setup themes and set permission.
mkdir ~/.poshthemes
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -O ~/.poshthemes/themes.zip
unzip ~/.poshthemes/themes.zip -d ~/.poshthemes
chmod u+rw ~/.poshthemes/*.json
@smling
smling / apt-get-patching.sh
Last active March 1, 2023 18:01
Patching dpkg based Linux distribution
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get clean
@smling
smling / choco-update.ps1
Last active March 1, 2023 18:02
Update all package with `choco` command
choco upgrade -y all --ignore-checksums
@smling
smling / javascript-array-remove.js
Last active November 26, 2021 07:04
javascript-array-remove
/**
* Remove array element(s) by value.
* @param {Value to be remove} value
* @returns Array which removed value.
*/
Array.prototype.remove = function(value) {
let index = 0;
do {
index = this.indexOf(value);
if(index >=0)