Skip to content

Instantly share code, notes, and snippets.

@ekanant
ekanant / docker_compose_mysql_backup.sh
Last active October 25, 2024 13:59
Backup and restore MySQL in docker-compose
#reference https://medium.com/@siriphonnot/backup-and-restore-a-mysql-database-from-a-running-docker-mysql-container-6c932907e21f
#reference https://medium.com/@vineetcic/script-to-take-mysql-database-backup-for-last-7-days-45f97ed067a9
mysqlUser="root"
mysqlPassword="xxxxx"
mysqlHost="127.0.0.1"
DB="my_db"
credentialsFile="/mysql-credentials.cnf"
/usr/local/bin/docker-compose exec -T mysql bash -c "
@ekanant
ekanant / docker-compose.yml
Last active September 27, 2020 02:39
centos 8 docker compose enable container to nslookup
version: '3.3'
services:
certbot:
image: certbot/certbot:v1.8.0
restart: unless-stopped
volumes:
- "./certbot/conf/:/etc/letsencrypt/"
- "./certbot/www:/var/www/certbot/"
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
# necessary to set network_mode and dns, because certbot will connect to letsencrypt website
@ekanant
ekanant / golang_centos_build.sh
Created June 3, 2020 14:07
Golang centos 64 bit build script
export GO111MODULE=on
export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=1
go build -o=myapp
@ekanant
ekanant / index.html
Created May 8, 2020 12:52
Example google ad manager (Doubleclick) with change url in interval
<head>
<meta name="ad.size" content="width=100,height=125">
<!--Ad size 100x125-->
<!--
Ad manager HTML
https://support.google.com/admanager/answer/7046902
-->
<!--
Click tag example
https://support.google.com/admanager/answer/7046799#clicktagguideline
@ekanant
ekanant / SQL Server Express Backup PowerShell script
Last active March 9, 2020 04:34
In this script show example backup 3 database if want more, you can add to db_backup variable
<#
For powershell
Task schedule
Program: Powershell.exe
Add Arguments: -ExecutionPolicy Bypass c:/path/to/script/SQLExpressBackups.ps1
If you want logging
Add Arguments: -ExecutionPolicy Bypass c:/path/to/script/SQLExpressBackups.ps1 | Out-File -FilePath sql_express_backup.log
#>
@ekanant
ekanant / dayjs.example.withLocale.js
Last active August 31, 2019 08:44
Day.js with locale
import dayjs from 'dayjs'
import 'dayjs/locale/th'
//Format date with en locale
console.log("day js DD-MM-YYYY", dayjs('2019-08-01').locale('en').format('DD-MMMM-YYYY'))
// => day js DD-MM-YYYY 01-August-2019
console.log("day js DD-MM-YYYY", dayjs('2019-08-01').locale('th').add(543, 'year').format('DD MMMM YYYY'))
// => day js DD-MM-YYYY 31 สิงหาคม 2562
@ekanant
ekanant / dayjs.example.js
Last active August 31, 2019 08:24
Day.js example
const dayjs = require("dayjs") // or import dayjs from 'dayjs'
console.log("Format date DD-MM-YYYY", dayjs('2019-08-01').format('DD-MM-YYYY'))
// => Format date DD-MM-YYYY 01-08-2019
console.log("Format date DD-MMMM-YYYY", dayjs('2019-08-01').format('DD-MMMM-YYYY'))
// => Format date DD-MMMM-YYYY 01-August-2019
console.log("Last date in August 2019", dayjs('2019-08-01').endOf('month').toDate())
// => Last date in August 2019 2019-08-31T16:59:59.999Z
@ekanant
ekanant / Rancher Troubleshoot network, kubectl
Last active November 6, 2021 17:48
Centos Firewalld service for rancher port
#https://rancher.com/docs/rancher/v2.x/en/troubleshooting/networking/
echo "=> Start network overlay test"; kubectl get pods -l name=overlaytest -o jsonpath='{range .items[*]}{@.metadata.name}{" "}{@.spec.nodeName}{"\n"}{end}' | while read spod shost; do kubectl get pods -l name=overlaytest -o jsonpath='{range .items[*]}{@.status.podIP}{" "}{@.spec.nodeName}{"\n"}{end}' | while read tip thost; do echo "source_host=>"$shost", pod=>"$spod", dest_host=>"$thost", ip=>"$tip;kubectl --request-timeout='10s' exec $spod -- /bin/sh -c "ping -c2 $tip > /dev/null 2>&1"; RC=$?; if [ $RC -ne 0 ]; then echo $shost cannot reach $thost; fi; done; done; echo "=> End network overlay test"
@ekanant
ekanant / cleanup.sh
Last active August 15, 2019 16:37 — forked from superseb/cleanup.sh
Cleanup host added as custom to Rancher 2.0
#!/bin/sh
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
cleanupdirs="
/etc/ceph \
/run/secrets/kubernetes.io \
/run/calico \
/run/flannel \
/var/lib/calico \
/var/lib/kubelet \
function configFontLoader(config, options = {}) {
let { isServer, name = "[name].[ext]" } = options;
config.module.rules.push({
test: /\.(woff|woff2|eot|ttf|otf|svg)$/,
use: [
{
loader: "url-loader",
options: {
limit: 8192,