SIGTERMer’s Whim-Based-Log: Git on the FTDI wave…

November 20, 2009 sigtermer Leave a comment

Before I start, an announcement that should make any electronics enthusiast explode with joy.
Any person who has dealt with a computer related project would tell you how incredibly helpful and *indispensable* the parallel port can be. It has this great reputation due to the fact that it’s is extremely easy to deal with both in circuits (IO lines can be connected directly to 74{LS}* – TTL compatible) and programming.
The trusty parallel, however, has been in a recession ever since the USB came out. Today, it’s difficult to find a PC motherboard with an parallel port, and you can definitely forget about laptops with the PP.

Many USB solutions exist, but nearly none are as practical and universal as the good-old PP. and until recently, my only option was my old Compaq Armada PP2060.

It turns out that FTDI (link) manufactures usb-serial converters which can be operated in bit-bang mode! this means that you can get up to 8 general purpose I/O lines. The main selling points for me was that it’s 3.95$ (link), there is a breakout board (link), and most importantly, there is a library for it for linux!
expect a detailed tutorial in the near future :mrgreen:

Now on to whats been happening this past week:

git


The comes a point in every programmer’s life when he/she realizes that he/she needs some sort of source code management. I was no exception. So I started looking for scm software. while searching, I came across git. I read a little about it and had the false assumption that it’s main feature was that Torvalds wrote it, which is not much of a reason for anything. so I decided on svn. recently, I came across a youtube video in which Linus talked about git (link). It opened my eyes on several issues with svn that i wasn’t aware of. he also mentioned some of the futures that got me searching for a SCM system in the first place. It seems that i might be switching to git soon! of course, that is if I ever get around to actually learning it :roll: never mind, switched already :)
for more information, see the video (link) and vist git (link).

Google Wave


Wave is interesting to say the least. a couple of days ago, I was invited by anxious.nut to google wave. To be honest, a did not expect this. after all, I wasn’t invited to gmail when it was invitation only -even though one person offered to invite me verbally, and I certainly didn’t do anything to get invited to this one. but i guess it helps to know a hardcore geek.
Anyways, The interface is designed in a simplistic manner; you get for boxes for wave lists, and for the wave itself. plus two more for contacts and navigation. Waves can be edited simultaneously (like google docs) and can be viewed at deferent point in its history (can single-step from the wave’s start up to its current state). I suppose it has its uses.
Anyways, being who we are (myself, and Anxious), we decided to test if it could be used for programming (you know, real time collaboration). suffice to say, it’s not for code development. it would of been fun if more people joined in though. my googlewave id is SIGTERMer [at] googlewave [dot] com.

A Pleasant Surprise…

It turns out that we have a close ubuntu repository here in Kuwait! It’s provided by qualtynet (link) and is synced every 4 hours. I haven’t switch repos yet but if it’s faster, and everything checks out, I will.
Thanks Qualtynet :)

link dump

Last but not least, some of the more interesting sites I’ve stumbled across this week
- Dirty Coding Tricks (link)

Until next time,
SIGTERMer

Categories: SIGTERMer Tags: , , ,

Compiling and Getting a Recent Version of wxMaxima to Work with Ubuntu

November 6, 2009 sigtermer Leave a comment
.::بسم الله الرحمن الرحيم::.
Ubuntu’s official Repositories are always outdated. Even when the latest distro has just been released. Normally, this isn’t much of an issue unless the software provided in the repository is really outdated as is the case with wxMaxima. this tutorial will go over compiling and setting up wxMaxima 0.8.3a.

 

Table of Contents
Step One: Getting maxima & wxMaxima
Step Two: Configuring & Compiling wxMaxima
Step Three: Improvising…

Step One: Getting maxima & wxMaxima

wxMaxima uses maxima as a backend, requiring you to install maxima. Luckily, the version provided in the official repository is recent enough to do the work required by wxMaxima. installing it from the repository should suffice. of course, you can build it yourself, but there is no need to. to install maxima (though you may want to read through this entire section first), open a terminal and type:

sudo apt-get install maxima

while that downloads, get wxMaxima from sourceforge. now, before you can start compiling wxMaxima, you’ll need a few libraries first (all of which are available in the repos, thankfully). assuming that you’re on on freshly installed system, you’ll need to install the following packages:

  • build-essential; this installs gcc, c libraries, posix, and a whole bunch of other stuff
  • libwxgtk-dev; you’ll need the headers/libs for libwxbase and libwxgtk, and wx-headers. because all these packages are listed as dependancies for libwxgtk-dev, you’ll only need to specify it when using apt-get. make sure that all libraries/headers have matching versions!

Assuming that you want to compile wxMaxima with libwx2.8, issue the following command in the terminal:
sudo apt-get install build-essential libwxgtk2.8-dev

Step Two: Configuring & Building wxMaxima

Extract the compressed archive using whatever software you use. And using the terminal, cd into the directory that was just extracted (if you extracted it on you desktop then type cd ~/Desktop/wxMaxima-0.8.3a). Compiling wxMaxima is like compiling most linux software; the all too familiar configure->build->build install(root). First run:

./configure

If no errors poped up, then you’re ready to go. If you got some errors, however, try resolving them (ussually a missing program or library, all availbe in the official repository). If you’re still having trouble, leave a comment, and i’ll see what i can do :) .

Now run:

make

This may take a while (av. a couple of min.s). If you get errors, check that all libraries are installed and that they are the correct version. Finally, to install wxMaxima, type sudo make install. Note that root privlages are required as the changes made are system wide. Congratulations! You have a working (almost) wxMaxima installation.
Step Three: Improvising…

run wxMaxima by typing wxmaxima at the prompt. you’ll see a nice gui pop up. but wait something’s wrong! the status bar says: “Maxima process terminated.”. Believe it or not, it’s not unheard of. In fact, it’s so common that the problem shows up as one of the suggestion when googling for wxMaxima! Most likely it’s ether one of two things; bad configuration, or a bad network setup. it has also been reported that spaces in the executable’s path may be to blame (ms-windows version).

To troubleshoot: first start a second terminal (or run wxMaxima in the background), and enter maxima -s 4010
now look and see if that ominous message has been replaced with a more pleasing “Ready for user input”. if that did the trick (and it probably did) you’ll have to change the configuration of wxMaxima. if not, check that localhost is 127.0.0.1 and not anything else (in /etc/hosts).

As usual, any feedback is appreciated. you can contact me at:

مستودعات برامج أوبونتو في غالب الأحيان قديمة بحيث لا تحتوي على احدث النسخ. يمكن التعايش مع هذا التقصير، عادةً. ولكن تقع المشكلة عندما يكون الإختلاف بين اصدارات كبير بحيث لا يكون استخدام تلك البرنامج عملياً، كما هو الحال مع wxMaxima. حلاً هذه المشكلة، يجب تصريف و بناء البرنامج من الأساس. و هذا ما سنقوم به بإذن الله سبحانه و تعالى.

المحتوى
الخطوة الأولى: تثبيت البرامج و كيفية الحصول عليها
الخطوة الثانية:تهيئة و تصريف wxMaxima
الخطوة الأخيرة:الإرتجال…

الخطوة الأولى: تثبيت البرامج و كيفية الحصول عليها

قبل الخوض في إعداد wxMaxima، يجب التنويه الى ان هذا البرنامج واجهة ل”Maxima” ، وليس البرنامج الفعلي المستخدم للقيام بالعمليات الحسابية. وبناءً على هذا، يجب جلب و تثبيت Maxima. يمكن تثبيت Maxima عن طريق مستودعات أوبونتو الرسمية حيث ان تلك النسخة حديتة بما يكفي لwxMaxima. لتثبيت Maxima، قم بفتح طرفية (Terminal)، و أدخل الأمر التالي:

sudo apt-get install maxima

بينما يتم تنزيل و تثبيت Maxima، بادر بتنزيل wxMaxima من سورس فورج. على الرغم من أن هذه النسخة هي الأحدث أثناء كتابة هذا الدليل، إنتبه إلى أن النسخة قد تكون قديمة في الوقت الحالي (الخطوات المذكورة هنا مبنية على a0.8.3). حتى تستطيع تصريف wxMaxima، يتوجب عليك أن تجلب بعض المكتبات للتصريف (متوفرة في المستودعات). هذه المكتبات هي:

  • build-essential; يقوم بتثبيت المصرف (gcc) و المكتبات الأساسية
  • libwxgtk-dev; ستحتاج ألى libwxbase، libwxgtk، و wx-headers. تأكد من أن إصدارات المكتبات متوافقة

إذا كنت ستستخدم الاصدار 2.8 للمكتبات في تصريف wxMaxima، قم بإدخال الأمر التالي في الطرفية:

sudo apt-get install build-essential libwxgtk2.8-dev
أنتبه الى أنه ليس من الضروري ان تذكر جميع المكتبات! يرجع هذا إلى أن libwxgtk2.8-dev يحتم وجود المكتبات الأخرى. فإن لم تكون مثبتة، سيقوم النظام بتثبيتها بالنيابة عنك.

الخطوة الثانية:تهيئة و تصريف wxMaxima

لتصريف و تثبيت wxMaxima، قم بإستخراج الملفات من الملف المضغوط باستخدام اي وسيلة تعجبك ثم وجه الطرفية الى الدليل (المجلد) الجديد المستخرج. إذا قمت بأسخراجة على صطح المكتب (Desktop) أدخال الأمر: cd ~/Desktop/wxMaxima-0.8.3a. ألان أبدء بتهيئة مصدر wxMaxima للتصريف من خلال إدخال:

./configure

أذا لم تصدر أي أخطاء أثناء المعايرة، سيكون بوسعك التقدم للخطوة التالية. ولكن إن صدرت أخطاء، حاول معالجتها. في غالب الأحيان يكون سبب المشكلة عدم توفر برنامج معين أو مكتبة في النظام. (جميعها متوفرة في المستودعات). للمباشرة في عملية التصريف، ادخل الأمر التالي:

make

أذا صدرت بعض الاخطاء اثناء عملية التصريف، تأكد من أن جميع المكتبات ذات إصدار متوافق (2.8). سيتطلب تصريف البرنامج بعض الوقت. بعد أن تتم عملية التصريف. إدخل sudo make install حتى يتم تثبيت البرنامج في النظام. بمجرد أتمام العملية الأخيرة، سيكون wxMaxima متوفر للمستخدم.

الخطوة الأخيرة:الإرتجال…

لتشغيل wxMaxima، أكتب wxmaxima في الطرفية. ستلاحظ (أن ظهرت لك هذه المشكلة) أنه على الرغم من أن البرنامج يعمل، لا يمكنك إجراء أي عملية حسابية. في غالب الأمر، ترجع المشكلة ألى خطاء في إعدادات wxMaxima أو خطاء في أعدادات شبكة النظام الداخلية. لمعالجة هذه المشكلة، قم بفتح طرفية أخرى و أدخل:

maxima -s 4010

ثم إختبار wxMaxima. أذا أجرى البرنامج العمليات الحسابية كما هو المطلوب، فإن الخطء يكمن في إعدادات wxMaxima. اذا لم يتغير شيئ و أستمر wxMaxima في عدم تقبل المعطيات أو عدم إجراء العمليات الحسابية، قم بتحقق في الملف

/etc/hosts

أن localhost يساوي 172.0.0.1 وليس أي قيمة أخرى(إن لم يكن localhost متوفر، قم بإضافته يدوياً).

للإستفسار، يمكنك ترك تعليق أو مراسلتي من خلال:

And so it begins with a one segment display…

October 10, 2009 sigtermer Leave a comment

A couple of weeks ago, I decided to learn how to program and use microcontrollers, and today I turned a new 7 segment display (single/10-pin) into a 1 segment display in a couple of seconds. I say we’re off to a good start.

only three segments remained functional

only three segments remained functional

it all started with hackaday.com. although most of the recent posts aren’t that good (it’s not their fault, it’s the hacks that are getting lamer and lamer, bleh!), some of the older projects posted at hackaday.com that were exceptional and down right amazing got me thinking about doing my own projects. since all the complicated projects required uCs, i needed to get my hands on one.

Almost everyone who knows what i do knows I’m an old fashioned TTL guy. I worked a lot with both 74XX and 74LSXX families, and know there attributes (fan out, current sinking, …) like the back of my hand. aside from 74*s, 7805s, 555s, and the required components required to get the circuit running, i never dealt with anything else.

anyway, I searched for a uC. i looked into PICs, and Atmels and ended up choosing an Atmel ATMEGA168. these are inexpensive (they go for 4.11$ at sparkfun.com) and powerful. but best of all, the ATMEGA168 can be programmed in circuit using high level languages (C). when i decided to buy some, I chose sparkfun. this is because of one simple reason: they provide a very well written tutorial. of course, i couldn’t just buy the uC by itself, i had to buy other *stuff* including the ill-fated 7 segment LED display.

After about two weeks my first "imported" box-O-electronics arrives..

After about two weeks my first "imported" box-O-electronics arrives..

I unpacked the package and inserted the 7SD into an old populated (555 astable circuit) breadboard i had laying on my desk since god knows when. without even referring to the datasheet I started experimenting to determine the pin layout (mistake #1). after doing a quick image search, i found the pin layout digram. i connected what seemed to be the OUT pin of the 555 to a segment’s electrode. the segment lite for half a second then went out. being the person i am, i tried another, which ended in a similar fashion. i know i blew something and that the display was probably history but still, there were five left :) . anyways i knew that the 555 OUT wasn’t connected to the power rail directly, so exceeding the current rating was not a possibility. i continued on burning testing the segments one after one until only one remained. then i realized what had happened; I connected the jumper to VCC!

There were two lines side by side. one was OUT which was buffered and could not drive a lot of current. the other, however, was connected directly to the power supply and could supply at least 800mA (upto 1A). no wonder why the thing wouldn’t light up.

bottom line: don’t drive 1000mA into a device that’s rated for 20mA or things might get hot and some get well.. destroyed.

edit: it turns out that one other segment survived along with DT (the dot). i guess i have a 2.5 segment now :)

Categories: Hardware, SIGTERMer

How to install Clam Anti-Virus, update it, and use it in Ubuntu

September 25, 2009 Anxious Nut 3 comments

Clam Anti-Virus is an open-sourced,  GPL-licensed, and a cross-platform application. ClamAV is capable of scanning files, directories, and archives for infected files. Filtering, coping, moving, and removing viruses are all options. For a virus-free PC.

Installing ClamAV

To install Clam Anti-virus, open the terminal and type:

sudo apt-get install clamav

Updating ClamAV database

When Clam is installed, its database may not be up-to-date so to update it enter the following:

sudo freshclam

Now the database will be updated. If you do not want check whether your database is up-to-date each time you want to search for viruses, the following command will check for database updates twice a day (you can increase the times by changing the number “2″, and notice that your limit is 50).

sudo freshclam -d -c 2

Once the enter key has been pressed it’ll ask for your password. This command will run as a daemon (runs in background), and will stop when the computer shuts down. To make is starts automatically when ubuntu starts, follow the following steps:

  1. Goto “System” –> “Preferences” –> “Startup Applications” (“Sessions” in ubuntu 8.10 & older).
  2. Press the “Add” button.
  3. In the name field type “ClamAV database update”, and in the command feild type “gksu freshclam -d -c 2“.
  4. Click the “Add” Button.

Because we used “gksu", each time you log into your gnome session a window will pop up asking for password (freshclam needs administrative privileges)

Of course, by using this method, the daemon will only start when you log into your gnome desktop. if you want it to start when your system boots up, add it with the rest of the system’s daemons; hal fam, gdb, …

Usng Clam AV

For scanning files, the command “clamscan” will be used.

  • To scan files under a specific file type this:
  • clamscan ~/MyFileToScan.extension (the viruses usually have the following extensions: .exe, .dll, .com, cmd, and .scr)

  • To scan files under a specific directory type this:
  • clamscan -r ~/MyDirectoryToScan (-r is used to search recursively)

  • To scan and delete the found viruses type:
  • clamscan -r --remove ~/MyDirectoryToScan

  • To scan and copy the found viruses type:
  • clamscan -r --copy ~/CopiedToHere ~/MyDirectoryToScan

  • To scan and Move the found viruses type:
  • clamscan -r --move ~/MovedToHere ~/MyDirectoryToScan

Other useful options:

  • To have ClamAV prints only the infected files instead of all of them, add the option -i
  • To make the console beeps whenever a virus is detected, ass the option --bell

The command I use for searching viruses:

sudo clamscan -r -i --bell --move ~/Directory ~/VirusArchive

I use sudo so that ClamAV gets the capability of moving all the files, even the ones that I don’t have the permission to move as a normal user

Important Notes

  • This was tested on ubuntu 9.04 .
  • For more information and details see manpages: clamscan(1) and freshclam(1).
  • ClamAV also has a GUI, to install it type “sudo apt-get install clamtk” and then type “clamtk” to run the application.

This document was updated on 5 Nov. 2009

Anxious Nut

Categories: CLI, Software Tags: , , , ,

print text with your toilet

September 23, 2009 sigtermer Leave a comment

Wanting to write about a very interesting article i read at hackaday or WebGL. I ended up writing about this.

By the way, gay means happy..

By the way, gay means happy..

Toilet, a drop-in replacement for figlet, is a nice little CLI tool that prints nice large (optionally colorful) text. for ubunturs: sudo apt-get install toilet.

SIGTERMer
Categories: CLI Tags: , ,

Accelerated graphics standardized in browsers. It’s starting to get real!

September 21, 2009 sigtermer Leave a comment

It looks like the dream of playing nexius in any web browser is starting to get real. the support for a new technology, webGL, has just been added to firefox nightly builds a couple of days ago.
It seems that webkit has also included support for it but it hasn’t been included in the nightly builds yet. see the video bellow:

WebGL aims to bring Hardware Accelerated 3D Graphics to web browsers by defining a standard, cross-platform, javascript API to graphics libraries such as OpenGL and its relative OpenGL ES. Since this technology is embedded in the browser itself, it should be available on any browser that supports it thus removing the uncertainty of whether or not the user has a specific plugin or not. With most browser vendors supporting it (including Google, Mozilla, and Opera), it looks like things might start to progress very quickly in the couple of months to come.

A question that may come to mind is how will computers without accelerated graphics capabilities handle 3D graphics-enabled browsers? Personally, I think it’ll probably be handled by software acceleration (something along the lines of mesa).

WebGL is currently being developed by the WebGL working group. This group includes Google, AMD, NVIDIA, Ericsson, Mozilla, and Opera. Microsoft, with its browser, seems to have fallen behind the pack. again.
More information can be found in this press release and other sources scattered across the web.

SIGTERMer

looking under the hood of your programs, literally!

September 19, 2009 sigtermer Leave a comment

it’s common knowledge that high programming languages are different from one another. some are object-oriented while others require VMs. one way these languages differ is how “low” a particular language is to assembly. for those of you who don’t know what assembly is, i’ll put it this way: if you want fast software, you won’t find anything better then assembly. the general rule is that the closer a language is to assembly, the faster it’ll run.

Now, after this nice intro, i’ll get down to business. take a look at the overly simple-code bellow:

int main(){
        int i = 0;
        i+=1;
        return i;
}

you won’t find anything special other than the fact that the a preschooler could have written it. the real fun starts next: assuming you have gcc and gdb, go ahead and compile the source. then start the gdb:

        gcc code.c -o code.bin
        gdb code.bin

for the other 90% (windows users) : as far as i know, gcc is included with bloodshed dev-C++, the question is whether gdb is included or not. if anyone knows anything, leave a comment.

once running gdb, simply type disas main, and the compiled code will be shown in assembly:

(gdb) disas main
Dump of assembler code for function main:
0x0000000000400448 :	push   %rbp
0x0000000000400449 :	mov    %rsp,%rbp
0x000000000040044c :	movl   $0x0,-0x4(%rbp)
0x0000000000400453 :	addl   $0x1,-0x4(%rbp)
0x0000000000400457 :	mov    -0x4(%rbp),%eax
0x000000000040045a :	leaveq
0x000000000040045b :	retq
End of assembler dump.

If anything, this proves that c is fast. but more importantly, it shows how the program is compiled, and therefore, can be compared with other compilable languages to reliably determine execution speed instead of relying on unreliable benchmarking tools.

by the way, i stumbled on this little gem by accident, and I’m glad that i did. now i have proof that C rules :)

SIGTERMer
Categories: Software, c, programming Tags: , , ,