Skip to content

Instantly share code, notes, and snippets.

@canabady
canabady / .tmux.conf
Last active August 14, 2021 10:39
tmux configuration
set -g @resurrect-processes ':all:'
#set -g mode-mouse on
set -g mouse on
# sane scrolling:
#bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"
# In order for Tmux to do its magic focus-events option has to be set to on.
# Needed by 'tmux-focus-events.vim'
@canabady
canabady / change-relative-link-2-absolute
Last active July 19, 2019 04:31
To change the webpage anchor from relative to absolute reference
@canabady
canabady / open url in docker chrome
Last active July 16, 2019 03:53
To open a url from other application into running docker based chrome
# Docker, Chrome and Ubuntu
# When the chrome container exists and it is running, to open a url in it from other applications
if [ "$CHROME_RUNNING" == "false" ]; then
docker start chrome
else
docker exec chrome sh -c "/usr/bin/google-chrome '$@' --user-data-dir=/data" &> /dev/null
fi
# Source: https://tuttlem.github.io/2015/10/08/docker-chrome-and-ubuntu.html
@canabady
canabady / only-one-thevara-pathigam-temples.sql
Last active December 5, 2018 15:20
Thevara Temple that have only one pathigam
# List all temples that have only one pathigam order by thirumurai
sqlite> select koil_name_ta, cast(thirumurai_1 as integer) as t1,cast(thirumurai_2 as integer) as t2, cast(thirumurai_3 as integer) as t3,cast(thirumurai_4 as integer) as t4,cast(thirumurai_5 as integer) as t5,cast(thirumurai_6 as integer) as t6,cast(thirumurai_7 as integer) as t7 from koil_pathigam WHERE ((thirumurai_1 is not null and COALESCE (thirumurai_2,thirumurai_3,thirumurai_4,thirumurai_5,thirumurai_6,thirumurai_7) is null) or (thirumurai_2 is not null and COALESCE(thirumurai_1,thirumurai_3,thirumurai_4,thirumurai_5,thirumurai_6,thirumurai_7) is null) or (thirumurai_3 is not null and COALESCE(thirumurai_1,thirumurai_2,thirumurai_4,thirumurai_5,thirumurai_6,thirumurai_7) is null) or (thirumurai_4 is not null and COALESCE(thirumurai_1,thirumurai_2,thirumurai_3,thirumurai_5,thirumurai_6,thirumurai_7) is null) or (thirumurai_5 is not null and COALESCE(thirumurai_1,thirumurai_2,thirumurai_3,thirumurai_4,thirumurai_6,thirumurai_7) is nu
@canabady
canabady / list-month-names-in-bash
Last active November 21, 2018 10:03
List month names in Title case, Lower case and Upper case
# List month names in Title case, Lower case and Upper case
$ for i in {1..12}; do month=$(date -d "$i/01" +%b); echo "${month} ${month,,} ${month^^}"; done
# Output
# Jan jan JAN
# Feb feb FEB
# Mar mar MAR
# Apr apr APR
# May may MAY
# Jun jun JUN
@canabady
canabady / filter-files-from json-2-create-ebook.sh
Last active November 20, 2018 04:33
To filter id and title from json file and output to html for ebook creation
# Select id and title from JSON File based on TEXT_TO_SEARCH and append it to OUTPUT.html
$ for f in $(find $PWD -name "JSON_FILE.json"); do idTitleTextArray=($(cat $f | jq -r -c '.categories[].articles[] | select(.title | contains("TEXT_TO_SEARCH"))|"\(.id).html\">\(.title)</a>"'|sort)); if [ ${#idTitleTextArray[@]} -gt 0 ];then echo "<a href=\"${f%/*}/web/html/${idTitleTextArray[@]}" >> OUTPUT.html; fi; done;
# Create MOBI ebook from HTML
$ ebook-convert OUTPUT.html OUTPUT.mobi
@canabady
canabady / keyboard_layout in lxde
Last active October 18, 2018 11:12
To set English and Tamil keyboard layout in lxde
# To set English and Tamil keyboard layout in lxde, add the below line to ~/.bashrc
setxkbmap -option grp:switch,grp:lwin_toggle,grp_led:scroll -layout "us,in" -variant "basic, tam_keyboard_with_numerals"
@canabady
canabady / sqlite-column-data-filepath-change.txt
Last active April 3, 2018 06:00
If you want to replace path in images for WooProduct kept in sqlite
If you want to replace path in images for WooProduct kept in sqlite
===================================================================
The replace ((())) does extract filename from the existing path in the images
columsn and we add base path of the server folder for accesss
SQLITE Query command is as below
--------------------------------
UPDATE local_wc_product SET Images = 'http://wordpress.com/wp-content/uploads/2018/04/' || replace(images, rtrim(images, replace(images, '/', '')),'') WHERE Images IS NOT NULL;
@canabady
canabady / openldap-modify-acl
Last active July 13, 2022 15:22
To modify openldap ACL
########################
# To modify openldap ACL
########################
# delete the existing ACL
# delete-acl.ldif
dn: olcDatabase={1}hdb,cn=config
changetype: modify
delete: olcAccess
@canabady
canabady / rename_with_increment
Last active March 6, 2018 04:26
To bulk rename files with increment or decrement
To bulk rename files with increment or decrement
================================================
e.g.
song_002.mp3
song_003.mp3
...
song_011.mp3
To rename above file list to: