Skip to content

Instantly share code, notes, and snippets.

View zipizap's full-sized avatar

zipizap

View GitHub Profile
#allow group "mygroup" to use "sudo /my/command/that/will/be/run/as/root" without password
%mygroup ALL = NOPASSWD: /my/command/that/will/be/run/as/root
#allow user "zipizap" to use "sudo" for all commands, without password
zipizap ALL=(ALL) NOPASSWD: ALL
echo -e '\033[37m' #turn on foreground color: white
echo -e '\033[44m' #turn on background color: blue
echo 'print your text - everything written from now on will have the previous colors, untill you turn them off'
echo -e '\033[0m' #turn off foreground and background color, to defaults
echo -e '\033[37m\033[44mprint your text - everything written from now on will have the previous colors, untill you turn them off\033[0m'
puts "\e[1;30msome color text\e[0m"
#Download the script OpenDns_setup_dhclient.conf.sh
wget "http://gist.github.com/raw/565137/0ac98870256cbdb53eb8c16ccb69008a95c20127/OpenDns_setup_dhclient.conf.sh"
#Run it once as root
sudo bash OpenDns_setup_dhclient.conf.sh
#download the script into the Dropbox folder
cd $HOME/Dropbox && wget "http://gist.github.com/raw/564419/35634bc7a13e22dd58b5b0db645c2620b5aedc20/bckpDir2home.sh"
#and run it whenever you want to make a new backup.
cd $HOME/Dropbox
bash bckpDir2home.sh
@zipizap
zipizap / resize_jpegs.sh
Last active December 28, 2015 01:59
Resize all JPEG files in current directory, to <GEOMETRY> size
#!/bin/bash
function shw_grey { echo -e '\033[1;30m'"$1"'\033[0m'; }
function shw_norm { echo "$1"; }
function shw_info { echo -e '\033[1;34m'"$1"'\033[0m'; }
function shw_warn { echo -e '\033[1;33m'"$1"'\033[0m'; }
function shw_err { echo -e '\033[1;31mERROR: '"$1"'\033[0m'; }
function shw_usage {
cat <<EOT
Resize all JPEG files in current directory, to <GEOMETRY> size
@zipizap
zipizap / gist:7489927
Last active December 28, 2015 10:59
Detect ssh login from ~/.bashrc
# If you put this check inside ~/.bashrc you can detect bash session opened by ssh-logins :)
[ "$SSH_CONNECTION" -a "$SSH_TTY" == $(tty) ] && echo "This bash session was opened from an ssh login :)"
@zipizap
zipizap / check_files_integrity.sh
Created December 4, 2013 15:25
Check that all files under current dir are readable. I use it to check the decrypted-version of files ofan EncFs dir... to check that the decrypted files are all ok... if the EncFs dir is in Dropbox and the upload/sync fails, then the decrypted-version will have errors, which can be spoted with this simple script
#!/bin/bash
function shw_grey { echo -e '\033[1;30m'"$1"'\033[0m'; }
function shw_norm { echo "$1"; }
function shw_info { echo -e '\033[1;34m'"$1"'\033[0m'; }
function shw_warn { echo -e '\033[1;33m'"$1"'\033[0m'; }
function shw_err { echo -e '\033[1;31mERROR: '"$1"'\033[0m'; }
shw_info "Check starting..."
find . -type f -exec wc -l \{\} 2>&1 \; | grep error
shw_info "Check finished"