Skip to content

Instantly share code, notes, and snippets.

View zipizap's full-sized avatar

zipizap

View GitHub Profile
@TeWu
TeWu / gist:1234573
Last active February 2, 2022 20:23
TCP client and multithreaded server in 14 lines of Ruby code

TCP client and multithreaded server in 14 lines of Ruby code

Server:

require "socket"
server = TCPServer.open(2626)
loop do
	Thread.fork(server.accept) do |client| 
 client.puts("Hello, I'm Ruby TCP server", "I'm disconnecting, bye :*")
@zipizap
zipizap / OpenDns_setup_dhclient.conf.sh
Created September 4, 2010 11:59
Script to configure dhclient to use as primary DNS the OpenDns servers
#!/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
@zipizap
zipizap / bckpDir2home.sh
Created September 3, 2010 19:32
Backs up the current directory, in a ZIP file to the HOME folder. Run the script inside the directory that you want to backup
#!/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'