Skip to content

Instantly share code, notes, and snippets.

@gcoda
gcoda / gist:7e7444aa6bf339079c58
Created November 29, 2014 09:13
How i migrated my TS3 server to new host
# i run this on my current TS3 server to redirect connections on new host
# --to might be changed to --to-destination
# %%DESRINATION.IP%% is ip address of my new VDS
iptables -t nat -A PREROUTING -p tcp --dport 9987 -j DNAT --to %%DESRINATION.IP%%:9987
iptables -A FORWARD -d %%DESRINATION.IP%% -p tcp --dport 9987 -j ACCEPT
# and for UDP, not sure if TCP port even matter for TS3
iptables -t nat -A PREROUTING -p udp --dport 9987 -j DNAT --to %%DESRINATION.IP%%:9987
@gcoda
gcoda / Backup.sh
Created August 10, 2015 14:57
Simple backup script
#!/bin/sh
#
# Dropbox got a symlink to my .Private folder.
# Using rsync to be more sure about stuff
# and not to worry about needless dropbox upload
# when no changes to source files were made
#
# Check if got tools
command -v ecryptfs-mount-private >/dev/null 2>&1 || { echo >&2 "ecryptfs-mount-private it's not installed. Aborting."; exit 1; }
command -v rsync >/dev/null 2>&1 || { echo >&2 "rsync it's not installed. Aborting."; exit 1; }
#!/bin/sh
DMENU="rofi -p LoadLayout: -bg #222222 -dmenu"
if ! command -v "jshon" >/dev/null 2>&1; then
printf "%s\\n" "you need to install 'jshon' to run this program" >&2
exit 1
fi
if ! command -v "rofi" >/dev/null 2>&1; then
@gcoda
gcoda / i3-layout-saver.sh
Created October 4, 2015 04:59
This works not really well, i3 will return "multi document" json and main split will be lost.
#!/bin/sh
DMENU="rofi -p SaveLayout: -bg #922713 -dmenu"
if ! command -v "jshon" >/dev/null 2>&1; then
printf "%s\\n" "you need to install 'jshon' to run this program" >&2
exit 1
fi
if ! command -v "rofi" >/dev/null 2>&1; then
printf "%s\\n" "you need to install 'rofi' to run this program" >&2
@gcoda
gcoda / i3-window-summoner.sh
Created October 4, 2015 05:06
Summons windows from any workspace to current container, if window alredy inside current workspace just changes focus to it
#!/bin/sh
#based on https://github.com/minos-org/minos-tools/blob/master/tools/dmenu-i3-window-jumper
DMENU="rofi -dmenu -i -p Summon: "
if ! command -v "rofi" >/dev/null 2>&1; then
printf "%s\\n" "you need to install 'dmenu' to run this program" >&2
exit 1
fi
### Keybase proof
I hereby claim:
* I am gcoda on github.
* I am gcoda (https://keybase.io/gcoda) on keybase.
* I have a public key whose fingerprint is D729 73FC 8755 06AF 3FB7 4A13 1476 977D 68E3 0242
To claim this, I am signing this object:
#!/usr/bin/sh
# i am not very good with bash, but looks like its working fine
########################################################
#
# evtest /dev/input/event14 | ./4click.sh 'notify-send tap4' | sh
#
########################################################
cancelTap=true
@gcoda
gcoda / notes.md
Last active January 25, 2017 16:18
webpack, load app.js after bundle.js async

webpack config will produce something like

<script type="text/javascript" src="/dist/vendor.0fcb27d1250abb1c9f24.js" async></script>
<script type="text/javascript" src="/dist/app.0fcb27d1250abb1c9f24.js" defer></script>

and while serving index.html i am replacing it with:

<script type="text/javascript" src="/dist/vendor.0fcb27d1250abb1c9f24.js" async></script>
<script type="text/javascript" async>
 var load = function() {
@gcoda
gcoda / generate.sh
Created August 3, 2017 22:56
Bash script to generate favicon and other icons for website
#!/usr/bin/env bash
# based on
# https://github.com/audreyr/favicon-cheat-sheet
# https://realfavicongenerator.net/faq
# generated text files just for refrence, big sizes based on lighthouse test
SIZES="16 24 32 48 64 120 144 150 152 180 192 256 384 512"
COLOR="FFFFFF"
MANIFEST='"icons": ['
@gcoda
gcoda / whiletrue.sh
Created August 22, 2017 22:23
Proper Ctrl + C on infinite bash loop
#!/usr/bin/env bash
#The exit status of a command that terminated because it received a signal shall be reported as greater than 128.
#For example if you interrupt a command with control-C the exit code will be 130, because SIGINT is signal 2 on Unix systems. So:
#source: https://unix.stackexchange.com/questions/42287/terminating-an-infinite-loop
while [ 1 ]; do
echo 1 #do the thing
sleep 1
test $? -gt 128 && break;