Skip to content

Instantly share code, notes, and snippets.

@cn00
cn00 / split-string-to-vars.sh
Last active February 3, 2023 02:00
split string to vars
# IFS set
a='111|222|333'
OIFS=$IFS; IFS="|"; set -- $a; aa=$1;bb=$2;cc=$3; IFS=$OIFS
echo $aa $bb $cc
111 222 333
#eval
s='a=22;b=33;c=44;d=5'
eval $s
echo $a $c $b $d
# `.` = document, `[]` = foreach
docker ps --format "{{json .}}" |yq -pjson '.|del(.Labels)|{"Names":.Names, "ID":.ID,"img":.Image}|[.]'
@cn00
cn00 / 2019-https-localhost.md
Created June 13, 2022 12:07 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@cn00
cn00 / mysql2sqlite.sh
Created June 2, 2018 11:45 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite