This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CURR_DIR="$(basename $PWD)" | |
BCKP_FILE="$HOME"/"$CURR_DIR""_Backup_""$(date +%F_%T)"".zip" | |
echo "..Starting executing" | |
echo "..Going to backup the current directory ('$CURR_DIR') into" | |
echo " $BCKP_FILE" | |
echo -n "---> Continue [Y/n] ? " && read CONTINUE | |
[ -z "$(echo $CONTINUE| grep -i 'y')" ] && echo "..Aborting" && exit 1 | |
cd .. && zip -9r $BCKP_FILE "$CURR_DIR" | sed -u 's/^/.... /g' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DHCLIENTCONF_FILE="/etc/dhcp3/dhclient.conf" | |
#Prepend Opendns name-servers into DHCLIENTCONF_FILE | |
if [ "$(id -u)" -ne 0 ]; then | |
echo "Must be run as root" | |
exit 1 | |
fi | |
if [ "$(egrep '^prepend domain-name-servers' $DHCLIENTCONF_FILE | wc -l)" -ne 0 ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function msg { | |
# Description: | |
# This function echoes-with-colors the arguments passed in | |
# Usage: | |
# msg 'whatever you want to print :)' | |
echo -e '\033[33m\033[44m'$@'\033[0m' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The fix is based on installing an older version of libsane and libsane-extras | |
# For more info, see [1] and [2] | |
# [1] http://angel-de-vicente.blogspot.com.es/2012/07/lexmark-x1190-with-ubuntu-1110-64-bits.html | |
# [2] https://bugs.launchpad.net/ubuntu/+source/xsane/+bug/774475 | |
# [3] http://ubuntuforums.org/showpost.php?p=12159929&postcount=36 | |
# | |
# To apply the fix, copy/paste the following in a terminal: | |
# . Uninstall libsane + libsane-extras | |
sudo apt-get remove libsane libsane-extras |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to add user into group, and make changes take effect *without logout/login*: the *newgrp* command | |
# | |
# Do note that this method will only update the groups, in the current shell session (and its child-processes). | |
# New shell sessions will not have the groups updated - either use this method to update the groups in each shell | |
# session, or logout/login to make the group update permanent by default | |
# | |
# In short: | |
# $ sudo adduser user_x my_grp | |
# $ newgrp my_grp && newgrp | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
require 'spoon' | |
# I made this code to experiment with 2 things: | |
# 1) Use the 'spoon' gem and Spoon.spawnp as a poor-man-substitute of a normal fork | |
# 2) pass a file-descriptor over unix-sockets, from a parent process to a child process | |
# | |
# Jruby cannot .fork() as MRI Ruby... it seems the alternative is 'spoon' gem and its | |
# spawn/spawnp methods. | |
# Fork is not the same as spawning: basically fork will copy to a child process all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#--------------------------------------------- | |
# xdg-open | |
# | |
# Utility script to open a URL in the registered default application. | |
# | |
# Refer to the usage() function below for usage. | |
# | |
# Copyright 2009-2010, Fathi Boudra <[email protected]> | |
# Copyright 2009-2010, Rex Dieter <[email protected]> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# condition && command-if-true || command-if-false | |
# | |
# CAUTION: condition && ... || ... works, but | |
# condition || ... && ... does NOT work! | |
# | |
$ [[ "your" == "condition" ]] && echo "executed if true" || echo "executed if false" | |
executed if false | |
$ [[ "your" == "your" ]] && echo "executed if true" || echo "executed if false" | |
executed if true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# capture SIGINT (emitted when CTRL-C) | |
function handler__CtrlC { | |
echo "------- handler_CtrlC -------" | |
echo ">> Control-C was pressed. Exiting" | |
exit 1 | |
} | |
trap handler__CtrlC SIGINT | |
echo "Handler for CTRL-C is defined - press CTRL-C or wait 5 seconds to continue" |
OlderNewer