Skip to content

Instantly share code, notes, and snippets.

@ekanant
ekanant / coredns.conf
Created March 19, 2024 20:33
Coredns learning
.:53 {
hosts /config/host {
fallthrough
}
forward . 1.1.1.1 8.8.8.8
# Cache 300 second
cache 300 {
success 10000
denial 2500
@ekanant
ekanant / docker-compose.yaml
Created December 15, 2023 10:08
Cockroach DB 3 cluster node with docker compose
version: '3.9'
services:
crdb-1:
image: cockroachdb/cockroach:v23.1.13
ports:
- "26257:26257"
- "8080:8080"
environment:
- COCKROACH_USER=admin
- COCKROACH_PASSWORD=password
@ekanant
ekanant / scylladb-docker-compose.yml
Created April 25, 2023 04:54
Docker compose for start a simple standalone scylladb
version: '3.9'
services:
scylladb:
image: "scylladb/scylla:5.1.8"
ports:
- "9042:9042"
volumes:
- "./docker-data/scylla/:/var/lib/scylla/"
@ekanant
ekanant / kubernetes_backup.sh
Last active March 22, 2023 16:07
Shell script for backup kubernetes everything by namespace
namespaces=("namespace_a" "namespace_b")
for n in "${namespaces[@]}"
do
echo "Process for namespace=${n}"
# Backup kubernetes namespace
echo "Backup namespace"
kubectl get namespaces "${n}" -o yaml > "ns-${n}.yaml"
@ekanant
ekanant / example.sql
Last active March 7, 2022 14:13
Oracle sql for check data range intersect.
--Find data range between '20200901' AND '20200930'
-- Full sql
SELECT DATA.* FROM (
SELECT 1 AS ID, '20200801' AS START_D, '20200915' AS END_D FROM DUAL
UNION
SELECT 2 AS ID, '20200913' AS START_D, '20200923' AS END_D FROM DUAL
UNION
SELECT 3 AS ID, '20200924' AS START_D, '20201225' AS END_D FROM DUAL
UNION
@ekanant
ekanant / GoogleDFP.tsx
Last active October 4, 2021 12:25
Next.js with google ad doubleclick. Google DFP
import Script from "next/script";
const GoogleDFP: React.FC<{
path: string;
size: number[][];
id: string;
}> = ({ id = "", path, size }) => {
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
return () => {
@ekanant
ekanant / backup_mysql.sh
Created August 7, 2021 17:32
Backup mysql 5 each database to each file and change structure to mysql 8
MYSQL_USER=xxxx
MYSQL_PASS=yyyyy
MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}"
/usr/local/mysql/bin/mysql ${MYSQL_CONN} -N -e 'show databases' \
| while read dbname; \
do /usr/local/mysql/bin/mysqldump ${MYSQL_CONN} --complete-insert --routines --triggers --single-transaction --databases "$dbname" \
| sed -r "s/ENGINE=MyISAM/ENGINE=InnoDB/g" \
| sed -r "s/COLLATE=(latin1|utf8_bin|utf8|utf8_unicode_ci|utf8_unicode_ci|)/COLLATE=utf8mb4_0900_ai_ci/g" \
| sed -r "s/COLLATE (latin1|utf8_bin|utf8|utf8_general_ci|utf8_unicode_ci)/COLLATE utf8mb4_0900_ai_ci/g" \
@ekanant
ekanant / gist:35252ebde0aa286113bdd29ead5154aa
Created June 20, 2021 09:38
Docker iptables allow outside to container
iptables -I DOCKER-USER -i "*" -o "*" -j ACCEPT
@ekanant
ekanant / remove_empty_dom.js
Last active May 13, 2021 02:23
VanillaJS function for remove empty html dom and style
var tagToExcludes = {'br': true, 'meta': true, 'style': true, 'title': true, 'script': true};
var contentDomProcessor = function(dom) {
if(dom.children.length === 0) {
//Remove tag
var tagName = dom.tagName.toLowerCase();
if(tagName in tagToExcludes) {
dom.remove();
}
//If empty tag remove
@ekanant
ekanant / logrotate nginx
Created April 29, 2021 15:42
nginx log rotate config
#Create file in /etc/logrotate.d/nginx
/usr/local/nginx/logs/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm