Writings Photos Code Contact Resume
Coding and hacking

You are here

Acer Embedded Controller no spinlock patch updated to 2.6.16.20

Submitted by msameer on Mon, 12/06/2006 - 1:25pm

OK, Without this patch, My laptop suffers from jumpy touchpad and sticky keys. It's mainly because the Linux ACPI implementation is trying to access the battery state through the laptop embedded controller. The problem is that this access causes lost interrupts which leads to the above problems.

The patch was only for 2.6.14 and was not updated to 2.6.16. It doesn't apply. I was stuck until I decided to port it. It's working fine since a couple of minutes ;-)

Here it is anyway. But be aware. I feel the touchpad is not in the usual state I used to. I'm not sure how.


Drupal, The rules, Start with 3...

Submitted by msameer on Sun, 14/05/2006 - 2:27pm

Rule #1: When you create a module, Never do

<?php
function foo_menu($may_cache) {
$links = array();
 if (
$may_cache)
  {
  
$links[] = array(
                
'path' => 'foo/foo',
                
'title' => 'FOO Title',
                 
'callback' => 'foo_page',
                 
'access' => TRUE
                 
);
}
 if ((
arg(0) == 'node') && (is_numeric(arg(1)) && (user_access('administer foo'))))
{
 
$links[] = array(
          
'path' => 'node/'.arg(1).'/foo',
          
'title' => 'Foo 2',
          
'callback' => 'foo_2_page',
          
'callback arguments' => array(arg(1)),
          
'access' => user_access('administer foo'),
          
'type' => MENU_LOCAL_TASK,
    );
}
return
$links;
}
?>

Always do:

<?php
function foo_menu($may_cache) {
$links = array();
  if (
$may_cache)
    {
     
$links[] = array(
                      
'path' => 'foo/foo',
                      
'title' => 'FOO Title',
                      
'callback' => 'foo_page',
                      
'access' => TRUE
                      
);
}
else {
    if ((
arg(0) == 'node') && (is_numeric(arg(1)) && (user_access('administer foo'))))
{
    
$links[] = array(
               
'path' => 'node/'.arg(1).'/foo',
               
'title' => 'Foo 2',
               
'callback' => 'foo_2_page',
               
'callback arguments' => array(arg(1)),
               
'access' => user_access('administer foo'),
               
'type' => MENU_LOCAL_TASK,
                 );
}
}
return
$links;
}
?>

Rule #2:
NEVER EVER have a module called foo and a theme called foo, The module foo_help will be called without an argument and you'll get a warning.

Rule #3: The ultimate: Screw Amr, Drupal 4.7 is not buggy, The problem is between your keyboard and monitor.


CLRSpell, My first and hopefully last VC++/.NET application.

Submitted by msameer on Fri, 12/05/2006 - 9:30pm

So, The wordlist has been growing lately, We hit 250,000 words, I tried hard not to put incorrect words but a lot of incorrect words went in, Manual review doesn't seem right to me, It'll take years!

There's already an Arabic spell checker shipped with Microsoft Office 2003, Why not use it ?

I tried to do it manually but hell, No way!

I tried to discover how can it be coded, Neither VBA nor VC++ helped me, Of course it's me here as I'm not a windows developer at all.

Diaa Radwan, One of our LUG administrators and the master of talking proposed that I wait for him, He'll ask any .NET developer to do it, Long weeks with nothing from him.

BooDy, The only one I know with windows development background said that he doesn't have windows installed.

Mohammed Nabil is a sweet guy! He wrote something for me using mono, Maybe it was my stupidity that I wasn't able to compile and run it.

Now enough is enough! I'll code it, Google found something for me this time and here it is in the CVS, Now I really don't get the whole thing of .NET/CLR

I thought that you can use existing COM objects in VC++ applications and that's what I did, The point is that no COM object was available in the Visual Studio 2005 References window when I didn't enable CLR, Strange.

Now WTH is CLR ? And how can .NET tie all this ?

Did I really use .NET ? I think yes, So .NET is only the System classes and such things ? So what is CLR doing here ?

And god damn it! You have old syntax for CLR where you have to use pointers and for sure no one is using the standard C++ auto pointers, There's a new syntax where you have to use ^ instead of a *, If I understand right, The main(int argc, char *argv[]) works fine with the old syntax but not with the new!!

The problem is that most of the tutorials use pointers, They don't use the new syntax and no one is telling you about that.

No farther comment about me searching for the Microsoft::Office::Interop namespace and not finding it, How would I know that I neede to rerun the Office 2k3 setup and select .NET programmability "Sure the setup had to fail for a lot of times anbd don't ask me how!", Poor windows developers using pointers because the damn classes don't have copy constructors!



Yet another Arabic support patch, Gedit!

Submitted by msameer on Sun, 02/04/2006 - 8:14pm

God damn you Islam you are always getting me into this.

Gedit doesn't identify Arabic as a known language thus won't use the aspell Arabic dictionary for it. This patch adds Arabic and Arabic (Egypt).

The patch is against 2.12.1 but should apply to 2.14 and here's the bug report!

Written and worked from the first time!


Help! What's wrong with this C++ code ?

Submitted by msameer on Mon, 06/03/2006 - 2:18pm

Why won't this shit compile ? What's wrong ? I don't get it!

#include <vector>
#include <iostream>

using namespace std;

class foo {
public:
   virtual void write();
};

class fubar : public foo {
public:
  void write() { cout << __PRETTY_FUNCTION__ << endl; }
};

class fubar2 : public foo {
public:
  void write() { cout << __PRETTY_FUNCTION__ << endl; }
};

int main()
{
  vector<foo> v;
  fubar one;
  v.push_back(one);
}

g++ -o foo foo.cc
/tmp/cchSMAqr.o:(.gnu.linkonce.r._ZTI5fubar[typeinfo for fubar]+0x8): undefined reference to `typeinfo for foo'
/tmp/cchSMAqr.o: In function `foo::foo()':foo.cc:(.gnu.linkonce.t._ZN3fooC2Ev[foo::foo()]+0x4): undefined reference to `vtable for foo'
/tmp/cchSMAqr.o: In function `foo::foo(foo const&)':foo.cc:(.gnu.linkonce.t._ZN3fooC1ERKS_[foo::foo(foo const&)]+0x4): undefined reference to `vtable for foo'
/tmp/cchSMAqr.o: In function `foo::~foo()':foo.cc:(.gnu.linkonce.t._ZN3fooD1Ev[foo::~foo()]+0x4): undefined reference to `vtable for foo'
collect2: ld returned 1 exit status

تدقيق املائى من كلمات المصحف الشريف

Submitted by msameer on Sat, 04/03/2006 - 1:10am

اوكى

بصراحه نفسى اقول كلام كتير لانى فى حالة من الضيق لا يتخيلها احد
المهم

ده ملف قاموس للمدقق الاملائى aspell انا عملته من نص القران الكريم

فك ضغط الملف فى "/usr/lib/aspell" او دور بنفسك aspell بيدور على القواميس فى انهى داهيه و لو ما عرفتش ولع فى نفسك و بطل تستخدم لينوكس يا حمار

كان هدفى ان اعمل قاموس عربى ل aspell علشان نتنيل نعرف نعمل تدقيق املائى للعربى "و الله نفسى اشتم بجد" لان ى اكتشفت ان بغداد مش هاينفع و هابقى اكتب بوست ليه مش هاينفع

اللى طلعها فى دماغى انى اقوم و اعملها رغم انى كنت ناوى ماعملهاش "لانى محبط من ال community العربى" اسلام.

المهم جبت كلمات المصحف كلها و عملت منها قاموس بس خد بالك لو هاتستعمله ان فيه كلمات كتير غلط هايعديها و يقول عليها صح علشان الرسم العثمانى بتاع المصحف

عمرو غربية وعدنى انى هايبعتلى ملفات صح و هاعمل منها قاموس ينفع للعربى المعاصر

و علشان كده انا مش هادى للناس ال ملفات الاصليه اللى عملت منها القاموس و اللى مش عاجبه يخبط دماغه فى الحيط

و مش عايز اى حد يسالنى على الداتا لانى مش هاديها لحد. اسف

يا رب نفسى اتخانق مع حد


Drupal patch monkey, Remember me patch to drupal HEAD

Submitted by msameer on Fri, 03/03/2006 - 1:10am

Well, I ported the patch to drupal CVS HEAD which 4.7 ATM per moshe's request. Looks like I did hit another thing. Might be my stupidity, Might be something wrong. We'll see!

PS. Patch is also in my CVS ;-)


Don't fear the socket. Discontinued.

Submitted by msameer on Sat, 25/02/2006 - 4:42pm

I've started writing a simple sockets programming series. I passed by Beej's Guide to Network Programming Using Internet Sockets and discovered that it's very good and it's not that complicated like I thought a few years ago.

Looks like I skipped the introduction as usual and jumped to the code or the guy improved it, I can't really tell.

That's why I decided not to continue the series.


Generate random passwords under GNU/Linux...

Submitted by msameer on Fri, 10/02/2006 - 11:30pm

Well, I want to generate random passwords for people I give subdomains.

Since creating the subdomain involves a lot of steps, I decided to automate it a bit.

And since I only install the most needed things on the server, I decided to create a small script to generate the random password for me as I don't feel like installing a password generator.

dd if=/dev/random count=10 bs=1 | hexdump  | cut -d \  -f 2-| head -n 1 | tr -d " "

Now the only 2 problems with the above script are:
1) No upper case letters.
2) No special characters.

I don't really think that the above problems are fatal since the user will change the password after that to something stupid, Why ? Because users are idiots, They are not as smart as me ;-)