Skip to content

Instantly share code, notes, and snippets.

@meoso
meoso / gist:ca3838d0d84b4215ccf8
Last active August 29, 2015 14:14
basic errorcode enabled bash prompt
#for ~/.bashrc
DULL=0
FG_RED=31
FG_GREEN=32
ESC="\033"
NORMAL="\[$ESC[m\]"
RED="\[$ESC[${DULL};${FG_RED}m\]"
GREEN="\[$ESC[${DULL};${FG_GREEN}m\]"
PS1="$NORMAL \$(if [[ \$? == 0 ]]; then echo \"$GREEN\342\234\223\"; else echo \"$RED\342\234\227\"=\$?; fi) $NORMAL\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w \$ "
@meoso
meoso / gist:36cb20c41062415cbffc
Last active August 29, 2015 14:14
bash colorization
##############
# in ~/.bashrc
##############
#color in terminal
export GREP_OPTIONS='--color=auto'
export COLORTERM=terminator
export TERM=xterm-256color
export CLICOLOR=1
#export LSCOLORS=ExFxCxDxCxegedabagacad
@meoso
meoso / git-force-pull.sh
Last active April 26, 2017 18:09
git fetch all & reset head
#!/bin/bash
#######################################################
# purpose : git fetch all & reset head i.e. git force pull
# author : njd
# created : 2017-04-26
# usage : ./git-force-pull.sh [path]
#######################################################
if ! [[ -z "$1" ]] ; then
cd "$1" || exit 1
@meoso
meoso / grub2 menuentry spinrite.iso
Created May 7, 2015 20:27
grub2 menuentry for spinrite.iso
### using multisystem - /boot/syslinux/memdisk exists
# sudo apt-add-repository 'deb http://liveusb.info/multisystem/depot all main'
# wget -q -O - http://liveusb.info/multisystem/depot/multisystem.asc | sudo apt-key add -
# sudo apt-get update
# sudo apt-get install multisystem
###
# edit USB devices /boot/grub/grub.cfg
menuentry "SpinRite6" {
@meoso
meoso / gist:4b8b5439569e662ee18a
Created June 23, 2015 16:02
process oui.txt - two different ways / about the same elapsed time
curl -O http://standards-oui.ieee.org/oui.txt
time cat oui.txt | awk '/(base 16)/ {printf $1 ":"; for(i=4;i<=NF;i++) printf "%s", $i (i==NF?ORS:OFS)}'
time cat oui.txt | grep -F "(base 16)" | awk '{$2=$3="" ; print $0}' | awk -F" " '{print $1 ":" $2}'
@meoso
meoso / gist:c760d6e57dbdd72b17b7
Last active August 29, 2015 14:25
Linux Mint's LSCOLORS
export LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl
@meoso
meoso / check-hamachi.sh
Last active April 13, 2021 20:14
bash script to check hamachi status and perform reset tasks if applicable
#!/opt/bin/bash # Synology (requires bash from entware-ng or optware[-ng])
# #!/bin/bash # Other *nix
############# EDIT BLOCK ##############
array_ping_list=("25.1.2.3" "25.2.3.4" "25.3.4.5") #only the IP's expected always-on
array_network_list=("my.net" "my-other.net") #all your networks independent of IP's
log_file=~/check-hamachi.log
#### OS dependent config:
## Linux:
hamachi_service_stop="sudo /etc/init.d/logmein-hamachi stop"
#! /bin/sh
case "$1" in
start)
if ( pidof zerotier-one )
then echo "ZeroTier-One is already running."
else
echo "Starting ZeroTier-One" ;
/opt/bin/zerotier-one -d ;
echo "$(date) Started ZeroTier-One" >> /opt/var/log/zerotier-one.log ;
@meoso
meoso / serviceX.sh
Last active March 23, 2017 15:22
synology service script template
#!/bin/sh
path="/path/to"
binary="executable"
parameters="--some-params"
background=1
logpath="/opt/var/log"
case "$1" in
start)