My (mostly technical) blog

If you are developing using Qt Creator for the MeeGo/Harmattan target, and upon launching the emulator for your application you get a message like this in the compiler window:

chmod: /opt/MeeGoApp/bin/MeeGoApp: No such file or directory
warning: aegisSessionOpen() - failed to open platsec device (ret=-1)
warning: aegisSessionOpen() - failed to open platsec device (ret=-1)
sh:
/opt/MeeGoApp/bin/MeeGoApp: not found
Killing remote process(es)...
Finished running remote process. Exit code was 127.

Make sure your project path has no spaces. For example C:\Qt Projects\MeeGoApp will fail. Notice the space in “Qt Projects”.

Steps to force a 32-bit DEB to install on a 64-bit system

Posted by: sabbour on: April 19, 2011

I came across some packages compiled for 32-bit, like Adobe Air that I needed to install on my 64-bit ubuntu, the following commands will fix the flags on the .deb package to force install it on a 64-bit system.

Note that it the converted package might install but not work correctly, so you are at luck whether it will work after that or not.

cd ~/Downloads
mkdir tmp
dpkg-deb -x package_i386.deb tmp
dpkg-deb --control package_i386.deb tmp/DEBIAN
sed -i "s/i386/all/" tmp/DEBIAN/
dpkg -b tmp package_64.deb
sudo dpkg -i package_64.deb

Tags:

Compatibility: Microsoft SQL Server Azure Spatial

Posted by: sabbour on: June 28, 2010

As I’m just trying out Microsoft SQL Server Azure Spatial, the following things need to be removed from any generated SQL script in order to make it run on SQL Server Azure as they are not supported:

ON [PRIMARY]
PAD_INDEX
ALLOW_ROW_LOCKS
ALLOW_PAGE_LOCKS
SORT_IN_TEMPDB
newsequentialid()

I will keep this post updated as I discover new booby traps!
For a full list, check: http://msdn.microsoft.com/en-us/library/ee336253.aspx 

Simply, if you get this error:

---------------------------
Microsoft Visual Studio
---------------------------
Could not load type 'Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemTypeDeniedOrNotExistException' from assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
---------------------------
OK
---------------------------

Then you probably installed Visual Studio, Visual Studio service pack, then the Team explorer. Doing it in that matter overwrites parts of Visual Studio SP hence giving you such errors.

The correct way to install would be:

  1. Visual Studio (Team Edition)
  2. Team Explorer
  3. Team Foundation 2008 October Power Tools
  4. Visual Studio 2008 Service Pack 1

To fix the error now, just re-install Visual Studio 2008 Service Pack 1.

Deploying Symbian Qt Applications on the phone

Posted by: sabbour on: April 7, 2010

As a reminder to myself, these are the steps to deploy an Qt application on the mobile phone.

  1. Project settings:
    1. Add new build configuration S60_5th_Edition_SDK_v1.0 (Qt 4.6.0) Release
    2. Change its Tool Chain to be WINSCW

    3. Add a new Run Setting (ProjectName in Symbian Emulator)
    4. Open the project file (TestLBSWS.pro) and add the following to enable network usage:
      symbian {
          TARGET.CAPABILITY = NetworkServices
      }
      
  2. Mobile deployment:
    1. Without smart installer (Qt 4.6.0)
      • Open command prompt
      • Navigate to project path
      • Run:
        qmake && make release-gcce
      • Then run:
        make sis
      • You now have your .sis file ready. Make sure qt in already installed on the device
    2. With smart installer (Qt 4.6.2+) steps

Data binding from a property in the code behind

Posted by: sabbour on: February 17, 2010

I’ve run across this situation multiple times, where I have for example, an ID that I get in the code behind, and I want to append it to some href in the aspx, and each time I forget how to do it, so as a reminder for myself, here is how to do it and problems I ran into:

Assuming I have a property in the code behind that returns a GUID

protected Guid CustomerId {
 get { return new Guid(); }
}

And assuming I have a link in my aspx page that I want to append this property to, here is how to do it

<a href="upgrade.aspx?id=<%= CustomerId .ToString() %>">Upgrade</a>

Note that this will not work if you specify a runat=server to the href for any reason, for example. to show the link or hide it according to specific logic.

If you need to show and hide the link, you can enclose it in a place holder and access that placeholder from the code behind

<asp:PlaceHolder ID="UpdgradeLinkPlaceholder" runat="server">
<a href="upgrade.aspx?id=<%= CustomerId .ToString() %>">Upgrade</a>
</asp:PlaceHolder>

Tags:

cPanel Password Protect directory bug

Posted by: sabbour on: April 25, 2009

Today, I was trying to password protect a directory on a website that operated the cPanel software on Bluehost and I went ahead and used the “Generate Password” function which generated this nice looking password

w7WY/a3HIUx>

Now when I was trying to login with this password, whatever I tried to do it gave me a 401 Authorization required. It just didn’t accept my password. I contacted the support of Bluehost but they weren’t able to help!

After some searching, I found this forum post http://forums.cpanel.net/showthread.php?t=112117 which makes me wonder why hasn’t cPanel fixed that bug so far?

If your password or the generated password contains greater than (<) or less than (>) characters (or maybe other ones that I haven’t discovered yet), they will be filtered out by cPanel before the password is saved, effectivley changing the password you set.

As a work around if you really need to use those characters (I liked the generated password :P ) you can set it through the shell

htpasswd -n username
New password: w7WY/a3HIUx>
Re-type new password: w7WY/a3HIUx> 

username:hash

Then copy the last line (username:hash) into your .htpasswd file which you can find by editing the .htaccess file in the directory that you were trying to protect. (Does this make sense?)

Tags:

I have never been more in need of a proper PHP debugger in my whole life. I have been stuck with a very mysterious behavior with CakePHP for the past 4 hours.

I was editing a model, then saving it. For some reason, my form action was changing from

/controller/edit/1
to
/controller/add

it was making me go crazy!

After seaching around (finally) I found this: https://trac.cakephp.org/ticket/5871
I came to realize that I have actually omitted the

<?= form->input('id'); ?>

from my edit view because I thought “why the hell do I need to edit the primary key?”

As it turns out, CakePHP needs a field (hidden or not) with the name ID or else it will revert to the ADD form.

Luckily though, it is smart enough to render it as a hidden field.

Google is your friend.

Tags: ,

Indoor Localization using Wireless LAN/WiFi Infrastructure

Posted by: sabbour on: October 20, 2008

This was my bachelor thesis that I have done as part of my studies for a B.Sc. degree in Computer Science and Engineering from the German University in Cairo.

Download presentation:
Indoor Localization Using Wireless LAN/WiFi Infrastructure

Download thesis:
Indoor Localization using Wireless LAN/WiFi Infrastructure

Abstract:
The rapid advances in wireless technology as well as in the manufacturing of portable devices caused a growing interest in location aware services. A location sensing
system responsible for locating a mobile user, is a crucial factor for the success of such services. With the prevalence of wireless hotspots and wireless area networks, the use of a wireless network infrastructure as basis for an indoor positioning system becomes a viable option. In this work, we propose an indoor guide system that provides information about points of interest and objects within the vicinity of the user. Our system can be deployed on a university campus or inside a museum equipped with a wireless network.

The system uses the fingerprinting technique to associate position dependent information such as the strength of the received signal with a location. A range based matching algorithm for matching the physical signal strength with the fingerprints in the database is used and its performance is compared to an Euclidean distance based matching algorithm. The properties of the wireless signals and their distribution under several controlled experiments are analyzed.

I got asked this question during an interview last week. I think I gave a wrong answer in the interview but I decided I needed to find the correct answer! I searched and found this solution which involved bit manipulations, though I didn’t find it intuitive.

I came up with this simple solution

public class PowerOfTwo {
	public static void main(String args[]){
		for(int n=0,limit=16; n<Math.pow(2, limit);n++)
			if(isPowerOfTwo(n))
				System.out.println(n);
	}

	private static boolean isPowerOfTwo(int n) {
		double logNbase2 =  Math.log(n)/Math.log(2);	
		int logNbase2Integer = (int) (Math.floor(logNbase2));
		
		if(logNbase2-logNbase2Integer==0)
			return true;
		else
			return false;
	}
}

maybe not quite as elegant as the bit hack, but I understand it!

Update:
Actually, I understood how the bit hack function below works:

	private static boolean isPowerOfTwoFast(int n) {
		return ((n!=0) && (n&(n-1))==0);
	}

Note that powers of two have only 1 bit set to one:

1:  000001
2:  000010
4:  000100
8:  001000
16: 010000
32: 100000

and so on, so we need to check if the number only has one bit that is set, and that the number is not 0 (because zero is not a power of two).

We can count the number of set bits (which is another interview question!), and if the number of set bits is one, then the number is a power of two. A smarter way to do it would be bitwise ANDing of the number and the number-1, and then check that the result == 0.

For example, to check that 32 is a power of 2, convert 32 to binary to be 100000, convert 31 to binary to be 011111. Bitwise ANDing of those 2 numbers would obviously result in 0.

Ahmed Sabbour's Facebook profile

 

January 2012
S M T W T F S
« Sep    
1234567
891011121314
15161718192021
22232425262728
293031  

Tweets

RSS StackOverflow

  • Answer by sabbour for Unable to compile Qt Symbian application that uses gSOAP September 13, 2010
    To finally make it work, I had to port gSOAP to use stdapis instead of libc. I removed one of the lines and used instead. You can find the ported stdsoap2.h file at http://pastebin.com/xnrDbfFa. I also discovered that Symbian does not load STL by default, so all my methods that were returning std::vector and std::string are now not compiling. Instead of opti […]
  • Unable to compile Qt Symbian application that uses gSOAP September 8, 2010
    I'm using gSOAP along with Qt for Symbian. Under the emulator, the application compiles fine, but when I change the target of the compiler to compile for the device, I get the following error. WARNING: Can't find following headers in System Include Path This gets included from the stdsoap2.h file as follows: #ifndef WITH_NOIO # ifndef WIN32 # ifnde […]
  • How can I POST data to a url using QNetworkAccessManager April 8, 2010
    I have a webservice that I need to POST some data to using Qt. I figured that I can use a QByteArray when POSTing to the web service. My question is, how can I format this array in order to be parsed correctly at the other end? This is the code I have so far: // Setup the webservice url QUrl serviceUrl = QUrl("http://myserver/myservice.asmx"); QByt […]
  • Facebook Graph API: FB.login() called before calling FB.init() May 18, 2010
    I'm trying to use the new Facebook Graph API on my website. This is what I have: Somewhere on the page: Right after the tag: window.fbAsyncInit = function () { FB.init({ appId: '', status: true, cookie: true, xfbml: true }); /* All the events registered */ FB.Event.subscribe('auth.login', function (response) { // do something with re […]
  • What is the correct way to create dynamic javascript in ASP.net MVC2? May 9, 2010
    I'm creating a Google Maps partial view/user control in my project that is passed a strongly typed list of objects containing latitude and longitude values. Currently, this is the code I have for the partial: google.load("maps", "2"); $(document).ready(initializeMap); function initializeMap() { if (GBrowserIsCompatible()) { var map = […]

Recently bookmarked

Follow

Get every new post delivered to your Inbox.