Archive

Archive for the ‘Technical’ Category

Ubuntu 10.04

When Ubuntu 9.10 came out I was very eager to try it, but sadly I was very disappointed. So when I was downloading 10.04 I wasn’t really expecting anything. I’m glad I was wrong.

So far it appears the sound and flash issues have been fixed. Empathy seems to have gotten some improvements. Most noticeable are the fact it now saves the window position of the contact list, and gives you an indication when the person you’re chatting with on Google Talk is typing something on the keyboard.

If you hate the new window button placement, like I do, here’s how to fix it:

  1. Open gconf-editor
  2. Got to /apps/metacity/general
  3. Change “button_layout” to “menu:minimize,maximize,close”

Delete all Messages from a POP3 Account

April 21st, 2010 Mohammad Al-Shami No comments

Here at the office, we host a few domains with Verio. Not my choice, and I’m not happy with it. We also host some mailboxes for one of those domains with Verio. I got a message from Verio support saying the mailboxes for that domain are occupying around 1GB of space, and that we need to delete some of them.

Turns out the mailboxes were neglected for months, and one of those mailboxes got around 55,000 messages.

Simple enough, I said, let’s log in to web mail, keep recent relevant messages and delete the rest. But the web mail interface kept timing out, and I couldn’t access any of the accounts. Seems they built their own web mail interface, which tries to load everything in your mailbox. This makes it time out when a mailbox has this huge number of messages.

After contacting Verio’s support they gave me an IP address to use as an IMAP server, which, surprisingly (well, not really, I expected it) wouldn’t connect. After a few days of deliberation the department in charge of the accounts decided to delete all messages in all accounts.

At first I configured Evolution to download all messages from POP3, which thankfully worked (Thanks Dovecot), but that took too long, and downloading 50K messages would overload our uplink. A simple solution would be as follows:


#!/usr/bin/python

import poplib

server = 'server'
user = 'user'
password = 'password'

whenToQuit = 500
loop = 0
totalMessages = 0 

while 1:
        M = poplib.POP3(server)
        M.user(user)
        M.pass_(password)
        numMessages = len(M.list()[1])
        if totalMessages == 0: totalMessages = numMessages
        i = 0
        for i in range(numMessages):
                print 'Deleted %d out of %d messages' % (loop * whenToQuit + i + 1, totalMessages)
                M.dele(i+1)
                if i == whenToQuit - 1:
                        M.quit()
                        loop = loop + 1
                        break

        if i != whenToQuit - 1:
                M.quit()
                break

Since the actual deletion of messages happens when a client “quit”s, I wrote this to do a quit after 500 message, this will enable you to quit the script after some time without having to lose all the progress.

Hope this helps.

Speeding up Firefox under Ubuntu

February 14th, 2010 Mohammad Al-Shami No comments

Ever wonder why browsing under Ubuntu is slower than Windows even on the same network? Well, it has to do with Ubuntu enabling IPv6 by default. This means Ubuntu will try IPv4 only after IPv6 times out. Also, Firefox comes built with Pango by default which makes it slower than it should be. I’ve fixed that on Karmic Koala, other versions should be similar. Here’s how to do it:

Disable IPv6 globally:

sudo vi /etc/default/grub

then find

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

and replace it with

GRUB_CMDLINE_LINUX_DEFAULT=”ipv6.disable=1 quiet splash”

Then update grub from the command line

sudo update-grub

Tell Firefox not to load Pango:

vi ~/.bashrc

and add

MOZ_DISABLE_PANGO=1

at the end

Tweak Firefox’s about:config settings:

network.http.pipelining -> True
- network.http.pipelining.maxrequests -> 8 or 10
- network.http.proxy.pipelining -> True
- network.dns.disableIPv6 -> True

Enjoy

Categories: Linux Tags:

Cleaning up your boot partition with Ubuntu

December 25th, 2009 Mohammad Al-Shami No comments

If you haven’t reinstalled Ubuntu in a while, the /boot partition will eventually fill up with all the updated kernels, and you’ll get an error when trying update.

At first I used to uninstall the old kernels manually but being lazy I think it’s too much work. When you get the error with update-manager or Synaptic try this:


sudo aptitude search linux -w 160 | egrep '(image|headers|restricted)' | egrep '^i' | grep -v 'KERNEL_VERSION' | grep -v -P '[^\d]-generic' | grep -v linux-restricted-modules-common | sed 's/i A/i  /' | awk '{print $2}' | xargs sudo aptitude remove

Replace “KERNEL_VERSION” with your currently running kernel.

This might break your grub configuration but update-manager will fix that for you so no need to worry. Just make sure you run this BEFORE update-manager does the update.

To be honest I didn’t try this without “grep -v ‘KERNEL_VERSION’” so I’m not sure if removing it would break something. Just leave it there to be safe.

Categories: Linux, Technical Tags:

My Experience with the Motorola CPEo 400 Wimax CPE

November 10th, 2009 Mohammad Al-Shami 14 comments

Where I live we have no proper DSL (512Kbps max), GSM signals are weak. Sometimes I have to stick my head out of the window just to be able to make a call. Even when I got my Wimax account the indoor CPE kept disconnecting every few minutes. I finally managed to get my hands on an Outdoor CPE which made things much better. Typical for someone living at the edge of the world (West Amman).

The Motorola CPEs act as network gateways, they connect to the Wimax network and do NATing for you. That’s nice for a home network, less stuff to configure and less clutter.

The indoor CPE worked well when it had coverage, but when I switched to the CPEo 400 I started running into all sorts of problems; DHCP and DNS stopped working, Connection drops, signal losses, and CPE restarts for no apparent reason.

Calling customer care for a week didn’t help, as you know it’s useless if your problem is a bit different. Oh believe me, Orange’s customer care is much worse, at least with Zain they tell you if they’re experiencing technical issues, with Orange it’s always your indoor wiring.

Turns out there are some bugs in the OS running on the CPE, I’m assuming it’s some sort of Linux distribution gone horribly wrong (Software version 02.01.90-02/11/2009). If you turn on UPnP all Hell breaks loose. I thought I should share this because of the lack of documentation and support for this particular unit.

You have 2 solutions, choose whichever fits your technical skills and/or your time.

Solution 1 (simple): This was the first one I went with, just connect the CPE to the WAN port of your aDSL router. Configure a static IP address and DNS on the router so it won’t use the CPE and use that IP as the DMZ. This will have the CPE forward all traffic to the router and have the router handle all the UPnP issues. This, however, you’d end up with double NATing, something not everybody likes.

Solution 2 (A bit technical): Install dd-wrt on your aDSL router and have it take of DHCP and DNS, then configure the default gateway as your CPE. You won’t have UPnP here but you can set up port forwarding on the CPE which should work fine.

VMware remote console Firefox plug-in and arrow keys

June 30th, 2009 Mohammad Al-Shami 2 comments

VMware remote console was working properly for me when I was using Ubuntu Hardy. After upgrading to Jaunty the arrow keys stopped working inside the remote console. Seems some people face this problem even under windows.

A search got me to this:

echo xkeymap.nokeycodeMap="TRUE" > ~/.vmware/config

Just close any open remote consoles and open up again and you’re in business.

Lighttpd, Joomla, and clean URLs

June 22nd, 2009 Mohammad Al-Shami No comments

So I’m working on a new web server but I don’t want to use Apache since it’s a virtual machine. Had some trouble with the rewirte rules but I think I got them

From this forum post


$HTTP["url"] !~ "\.(gif|png|css|jpg|jpeg|js)$" {
   server.error-handler-404 = "/index.php"
}

But I thought of a different approach and it seems to work so far, and maybe causes less error messages in the logs:


url.rewrite-once = ("^/(.*\.html)$" => "/index.php?page=$1", "^/(.*\.html\?.*)" => "/index.php?page=$1", "^/(.*/\?.*)" => "/index.php?page=$1")

Have a good one

Throttling outgoing emails to certain domains with Postfix

March 29th, 2009 Mohammad Al-Shami No comments

I’ve been busy setting up a PHPlist server for my employer. All tests went ok, but as soon as we sent our first newsletter Yahoo! blocked the server. After looking around for a solution people suggested we sign all outgoing emails with DomainKeys and not hammer Yahoo’s servers with consecutive connection.

Using DomainKeys was a simple setup with DKIMproxy, as for throttling, you all know Postfix is one high performance MTA, so that would be hard to do. PHPlist has a throttling feature but I didn’t want to use that because it would slow emails going to all domains and it took about half a day to send messages to about 6,000 users. That is unacceptable.

After some more digging around I found that Postfix 2.5 introduced the perfect solution, here you go:

First, add the following lines to your master.cf


domain1      unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
domain2      unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
domain3      unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=

Now, to use those transports add these lines to your transport_maps file


domain1.tld    domain1:
domain2.tld    domain2:
domain3.tld    domain3:

Finally, set the destination_rate_delay for those transports in main.cf


domain1_destination_rate_delay = 10s
domain2_destination_rate_delay = 20s
domain3_destination_rate_delay = 30s

This will effectively send all outgoing messages at full speed, except for messages going to domain1.tld, domain2.tld, and domain3.tld; Postfix will wait 10/20/30 seconds after sending each message to domain1.tld/domain2.tld/domain3.tld.

Categories: Mail Tags:

Fixing MySQL Error 1064 with PHPList when selecting new criteria

March 14th, 2009 Mohammad Al-Shami 10 comments

I’m currently experimenting with PHPlist to use for our corporate newsletters. During the tests I got the following error

Database error 1064 while doing query You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘1)’ at line 3

Tracking this problem down I found the following code segment in “admin/send_core.php”


if (is_array($_POST["criteria_values"])) {
$values = join(", ",$_POST["criteria_values"]);
} else {
$values = $_POST["criteria_values"];
}

$values in this segment will always start with a comma. We just need to add a substr statement to fix that. Just change it to


if (is_array($_POST["criteria_values"])) {
$values = join(", ",$_POST["criteria_values"]);
} else {
$values = $_POST["criteria_values"];
}
if (substr($values, 0, 1) == ",") {
$values = substr($values, 1);
}

That’s it. This will remove the starting comma (If it exists)

Categories: Mail, Technical Tags:

Empathy, the new kid on the block

February 5th, 2009 Mohammad Al-Shami No comments

If you’ve used Linux as a desktop, you’ll know it’s only playing catch-up when it comes to instant messaging. I’ve been using Pidgin since was called Gaim, I think I started using it back in 2003. I love how minimalistic it is. Sadly the developers are going nowhere with it, at least that’s my (as well as a few others) humble opinion.

I stumbled upon this post which mentions a new (or maybe just new to me) client called Empathy. After playing with it for a few days now I think it has great potential. It’s still pretty basic but also under heavy development. It’s very minimalistic and uses the Telepathy library, which IMHO is a better approach than Pidgin’s libpurple.

It still doesn’t have proxy support, but you can work around that, at least for MSN and Gtalk, the protocols that I use. Here is how I did it it:

Gtalk: Just create a tunnel with SSH


ssh -C -q -f -M 0 -N -L 5223:209.85.137.125:5223

Where 209.85.137.125 is the IP address of talk.google.com, then set the account to use localhost as a server

MSN is a little different, this trick didn’t work because the client connects to a login server, which redirects the client to a different server. MSN is implemented using the telepathy-butterfly executable. Just use a socks server like this:


mv /usr/lib/telepathy/telepathy-butterfly /usr/lib/telepathy/telepathy-butterfly-old
vi /usr/lib/telepathy/telepathy-butterfly

#!/bin/bash
exec /usr/bin/tsocks /usr/lib/telepathy/telepathy-butterfly-old

chmod +x /usr/lib/telepathy/telepathy-butterfly

Enjoy :)

Categories: Linux Tags: