Posts Tagged ‘Snippets’

mercurial-server on Fedora/Centos

November 2nd, 2009

If you want to setup mercurial-server on fedora or centos/rhel server you are going to see lots of failure messages during installation and the installation will definitely fail.

Mercurial-server was written to run smoothly on debian-based systems, so I patched it to run on fedora/centos and I would like to share the patch with you.

Using the patch is straight-forward, simply download the tip or the latest version of mercurial-server and put the patch file into the extracted directory.

patch < mercurial-server-centos.patch

the patch is a few lines, so it’s naive for professionals.

Get the patch from here

Have Fun.

Screen Tricks

September 14th, 2009

If you are using the famous ‘screen‘ command and you are using ‘windows‘ in screen alot then you might find it pretty useful to add the following lines in either your /etc/screenrc or ~/.screenrc file.

hardstatus alwayslastline
hardstatus string ‘%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]‘
shelltitle “$ |bash”
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'
shelltitle "$ |bash"

This will add a very useful bar in the bottom of the screen where you can see in which window you are working and the process running and some other useful stuff.

Special thanks goes to Ahmed Kamal for the tip.

Talk to GTalk from Python

April 27th, 2009

Some friend of mine asked me today if I can help him to communicate with google talk from python as he wants to send notifications about some network usage over the chat service. In fact, that was pretty interesting and it just inspired me with tons and zillions of ideas that you can do with that, things like getting security alters, usage logs, any simply feedback that you want to receive while being online and without being irritated with the fact that you have to refresh what you are monitoring every while.

It’s not a hard trick at all, but looks like all of the scripts on the internet are written wrong! and he have been trying to use all of them with no luck, so I helped him as I have some good experience with python-xmpp (xmpppy) module in python.

The idea is that we want to send a message to a Google Apps. User and use another account on the same domain to chat and here comes the trick about it and of course this script is released under the BSD License so you can do whatever you want to do with it :)

import xmpp

client = xmpp.Client('ahmedsoliman.com')
client.connect(server=('<a href="http://talk.google.com/" target="_blank">talk.google.com</a>', 5222))
client.auth(user='myUser', password='myPassword', resource='myResource', sasl=0)

client.send( xmpp.Message('anotherUser@ahmedsoliman.com', 'Hello World'))

Of course you can download the python-xmpp package manually or if you are using fedora, simply use the magical yum install python-xmpp

AntiNetCut v2

August 13th, 2008

At last, I’m very happy to announce the release of the long-waited Anti NetCut version2.

Main Features:

  1. Works on Ubuntu/Fedora/RHEL..
  2. Written in Python so it’s easy to maintain and update.
  3. Automatic detection of almost everything (you might need to supply the interface name as illustrated below)
  4. Works perfectly with NetCut 2.8…

The usage instructions are too easy, just download and edit the antinetcut.py file (change “device=eth0″) to your interface name and run the script…


Notes

  • You must leave the script running in the background, stopping the script means that you might get attacked again.
  • After starting the script, it might take a few seconds before you get your connection back, so please be patient.

Anyone wants to join development, please see the official page http://code.google.com/p/antinetcut/

Download from here: Download Here

Good Backup script

June 14th, 2008

I’ve a local home server that works as a local RAID storage with some virtual machines that serve different services to me and to some friends. The most known service to most of you is the XMPP service for chat.cat-hackers.net that enables all the H4ck3rZ Foundation members to communicate in an efficient way.

Another thing is that this server hold all of my important data that represents my own work throughout the years, so it’s very important to keep them secure and safe. I’d a bad experience of losing a 2.5GB harddrive that had all of my programming work. That experience taught me how to spend more money to keep your data safe and secure.

So :) I got an external 500GB USB hard drive to have it mainly as a backup drive for my 500GB RAID local home server, and as you can see it’s 500GB too, so I can’t do incremental backups on that disk because it too small for such a plan, so I decided to rsync the data on the storage server to the USB hard drive and I wrote a nice script that does some smart stuff….

Let’s post the script first then I’ll describe more about it.. » Read more: Good Backup script

Internet Connectivity Monitor Script

November 26th, 2007

I was assigned to monitor the link status here in the company because we had many problems regarding our new TEData internet line. We couldn’t calculate exactly when the line is down and up, so I wrote a small script to run as a cronjob to create a log for the internet connectivity status.

The script is quite useful and very light, it’ll generate a log about your internet connectivity and will try to detect the reason of the internet connectivity problems.

Note: you’ll need to change the value of the variable GATEWAY_IP to your gateway/router/dsl_modem IP address before running the script. And you don’t have to be root to run this script.

you can download it from this link