Posts Tagged ‘Hacks’

Macbook Pro External Display

March 14th, 2010

I own a macbook for 2 years now and only a few months ago I needed to connect my Macbook to an external display “only”, meaning that I want to close the laptop lid and work on a huge external display with an external keyboard and mouse to save the screen and to enjoy everything in a one big screen (I love dual-head too but I hate it when one screen is much bigger that the other).

So, for quite sometime I thought that this is not possible, but it turned out to be possible and pretty easy to do.

Now to the important part ;)

You MUST connect all of the following things first;

  • MagSafe.
  • External Display
  • USB Mouse and USB Keyboard

then close the lid, you will get the system sleeping as you usually do, then click on the mouse and the system will fire up again and shining on the external display :)

It’s a trivial trick but it took me quite sometime to discover and I tested it only on Macbook pro and snow leopard, however, it should still work on any other macbook I suppose.

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.

Linux Anti Netcut V0.2

June 1st, 2007

The famous ARP Poisoning problem started to spread here in egypt and while we are putting the main problems an engineer or specifically an egyptian engineer may face, we found that Netcut problem is one of the major ;)

I’ve developed a small script to magically terminate this issue, this is an Intelligent Anti netcut script, it has the following main features:

  1. Support for Multiple Interfaces and auto-detection of the correct interface
  2. Detection of poisoning or weird settings.
  3. Doesn’t need to be run continuously, run it once each 1 minute or even every 1 hour. [Typically, you'll need to run this script once!]
  4. Smart detection of Gateway Settings
  5. Verbose

You can download it directly from here http://www.ahmedsoliman.com/download-manager.php?id=1

NOTE: I’m not responsible for any damage you may have or face or any diseases that might spread or pets that might be killed in an area of half of the universe per using this script :D

UPDATE

This version is pretty old, if you want the latest version please check http://code.google.com/p/antinetcut

Waiting for feedback…

Mplayer With Arabic Subtitles FIX

May 24th, 2007

Well, this is my first contribution to “HackRoot” The CAT Distro – Based on Fedora.
There is a very common problem regarding arabic subtitles in Linux video players, I’ve googled and found some old patches with ugly ideas (it was best at their time, because fribidi didn’t support arabic shaping), but now after fribidi2 (beta) which has a almost-finished arabic shaping support I thought I could hack Mplayer and fribidi2 and get things to work together for the complete Linux beginner.Mplayer With Arabic Subtitles

I’ve compiled fribidi2 and hacked it’s configuration alittle and prepared a RPM as there is no RPMS for fribidi2 (because it’s still beta).

I Also hacked the Mplayer to work with my new fribidi2 RPM and to use the arabic shaping capabilities, and here is how you can get arabic subtitles working in Linux:Mplayer With Arabic Subtitles

- You’ll have to remove mplayer if you already have it installed

rpm -e mplayer mplayer-gui

- Download Mplayer RPMs and Fribidi rpms into a new empty directory, aka. /opt/mplayer
- Install all the packages, use force if neccessary (libfribidi may have some conflicts, don’t worry about using force with it)
- Make sure that you have fonts-arabic already installed, if not, Install them via yum.
- Now you need to convert the subtitles for your movie into UTF-8 encoding before playing, let’s see how can you do this

#assume the .sub or srt file is named movie.sub

$ mv movie.sub movie.sub.old

$ iconv -f windows-1256 -t utf8 movie.sub.old > movie.sub

# rm movie.sub.old

OR:

you can download convert_sub script and chmod +x convert_sub.sh and just pass the subtitles file to it and it’ll do the conversion.

then you are ready to play :)

Basically you’ll need to install mplayer, mplayer-gui and fribidi0 RPMS and you’ll have everything setuped. you can download the tree rpms in an empty directory and install them as follows *Please make sure that you have Livna Repo. setuped*

# cd /opt/empty_directory
# yum localinstall *

while /opt/empty_directory is an example for an empty directory you copied the RPMS into.

please don’t hesitate to tell me any comments or problems..

Download RPMS:

mplayer-1.0-0.72.20070325svn.AhmedSoliman.com.i386.rpm
mplayer-gui-1.0-0.72.20070325svn.AhmedSoliman.com.i386.rpm
mplayer-doc-1.0-0.72.20070325svn.AhmedSoliman.com.i386.rpm
mencoder-1.0-0.72.20070325svn.AhmedSoliman.com.i386.rpm

fribidi0-0.19-1.AhmedSoliman.com.i386.rpm

libfribidi0-0.19-1.AhmedSoliman.com.i386.rpm
libfribidi0-devel-0.19-1.AhmedSoliman.com.i386.rpm

Source RPMS:

fribidi-0.19-1.AhmedSoliman.com.src.rpm
mplayer-1.0-0.72.20070325svn.AhmedSoliman.com.src.rpm

NOTE1: Those packages are based on rpm.livna.org packages and are completely compliant with Fedora Core 6

NOTE2: If you chose to install fribidi0-0.19-1.AhmedSoliman.com.i386.rpm then you shouldn’t install libfribidi0 and libfribidi0-devel as they are self-contained in fribidi0, this package was made to make the installation thing easier.

NOTE3: You may face conflicts with original fribidi package while installation, you can rpm -ivh –force fribidi0* before installing mplayer, then do the normal installation and remove fribidi0 from directory.

NOTE4: You may face a problem that my packages aren’t signed during installation using yum localinstall, edit /etc/yum.conf and change gpgcheck=0