Archive for the ‘Geeky’ Category
Collectd Python plugin
One of the most interesting development in collectd recently (4.9) would have to be the availability of a Python binding. You can find the man page here with some samples.
Another interesting feature available with collectd plugins is the availability to overwrite the `hostname`. This opens up a whole new page to collectd, including what I’m attempting right now which is active checks.
In any case, a sample python plugin which overwrites the `hostname` would look like so:
# Sample Python module to use python plugin
import collectd
#== Our Own Functions go here: ==#
def configer(ObjConfiguration):
collectd.debug('Configuring Stuff')
def initer():
collectd.debug('initing stuff')
def reader(input_data=None):
metric = collectd.Values();
metric.plugin = 'python_plugin_test'
metric.type = 'gauge'
metric.values = [100]
metric.host = 'OverwritenHostname'
metric.dispatch()
#== Hook Callbacks, Order is important! ==#
collectd.register_config(configer)
collectd.register_init(initer)
collectd.register_read(reader)
Lets assume a few things here:
1. Collectd installation:
/opt/collectd/current/,
2. python plugins
/opt/collectd/current/share/python/.
3. plugin file python_plugin_test.py will be in
/opt/collectd/current/share/python/python_plugin_test.py
The relevant corresponding config in /opt/collectd/current/etc/collectd.conf would look something like:
LoadPlugin python
<Plugin python>
ModulePath "/opt/collectd/current/share/python/"
LogTraces true
Interactive false
Import python_plugin_test
<Module python_plugin_test>
Test "This" "are" "the" "inputs"
</Module>
</Plugin>
Dont forget to test your plugins by running sbin/collectd -C etc/collectd.conf -T If this causes nothing to be printed on the STDOUT, that means your plugins are good.
N900 development Part 2
Before you continue on reading, understand that a prerequisite is for you to start with part 1 and especially Maemo’s Getting Started guide.
For this guide, I’ll be showing how to create multiple widgets in one window. The code from Maemo provides you one window with one widget (the button). You cannot add on more widgets to the example just like that. Adding >1 widget to a HildonWindow will still allow the program to compile, however if you run it you will have to expect an error message that looks something like “… as a GtkBin subclass a HildonWindow can only contain one widget at a time; it already contains a widget of type …”
So the alternative is to create one vBox (or hBox) and pack all other widgets (including other hBox and vBox) inside of it. The end result from the sample should be an applicati
on with an interface that looks like this
The blog formatting makes it a bitch to paste my code here, so just download the code into scratchbox environment with something like this:
wget http://dartarrow.net/wp-content/uploads/2010/03/hworld.c
You should now be able to compile the program with the following line:
gcc hworld.c `pkg-config hildon-1 --cflags --libs` -o hworld
Execute the programe
./hworld
And voila.
Take note of how the hbox is prepared and then packed into the vbox. Understanding the interaction is key to your own gui development with C, GTK, and Hildon.
Credit where credit’s due, I stole and modified the code from Maemo’s Wiki
N900 Development Part 1
This section shows you how to get started (Your baby steps in N900 development starts by starting up the environment. And gettin some sample codes from the community).
Development for Maemo currently utilizes GTK, so if you’re planning on developing something for Maemo devices I’d recommend you start here and then proceed to the Maemo Wiki.
Step 1 in development is setting up the SDK which can be done by following the guide here or here
If you’ve already done that, then start up Xephyr (and here’s how). From a terminal first startup the SDK
sudo sh -c 'echo 0 > /proc/sys/vm/vdso_enabled' Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb &
Go into scratchbox
/scratchbox/login
Switch to the x86 environment
sb-conf se FREMANTLE_X86
export the display and start up
export DISPLAY=:2 af-sb-init.sh start
You will get a screen that looks like this
. Remember to click, click + drag and just play with it as much as possible to just make sure you get familiar with the interface
You can then look through this pseudo-maemo-emulator for applications you can install. You can start with the sample widget – the process of which is nicely documented here. Or better yet, write (and compile) your own obligatory Hello World program as documented here
Maemo SDK installation on Linux
There are 3 Options on how to install the Maemo 5 SDK,
1. The GUI Installer (recommended)
2. Script based installer.
Instruction for both can be found here
3. Manual installation
This is a Manual Installation instruction, covering the installation of Scratchbox, Nokia + Maemo binaries and Xephyr X server – which are the prerequisites for development. The host machine here is Debian based machine. so k/ubuntu will work. I’ve tried this on Kubuntu 9.10 with a 32-bit architecture and can confirmt that it works. I can’t guarantee you it will work on a 64-bit machine.
- Install Xephyr
- Download / Install scratchbox
- Setup Scratchbox
- Setup Mamemo Packages
- Log into scratchbox environment
- Configure the scratchbox x86 and armel target as such:
- Now download the rootstraps:
- Now switch to the x86 target and install the binaries,
- Add the nokia repos
- fix the scratchbox symlinks
- repeat the same for armel architecture
- Startup Xephyr, with the x86 targets pointing the output to it
sudo aptitude install xserver-xephyr
Note: before you start, take note that scratchbox installs by default in “/scratchbox” so make sure you have about 4GB’s in your “/” partition.
sudo sh -c 'echo "deb http://scratchbox.org/debian/ maemo5-sdk main" > /etc/apt/sources.list.d/scratchbox.list'
sudo aptitude update
sudo aptitude install scratchbox-core scratchbox-libs scratchbox-devkit-qemu scratchbox-devkit-debian scratchbox-devkit-doctools scratchbox-devkit-perl scratchbox-toolchain-host-gcc scratchbox-toolchain-cs2007q3-glibc2.5-arm7 scratchbox-toolchain-cs2007q3-glibc2.5-i486 scratchbox-devkit-svn scratchbox-devkit-git scratchbox-devkit-apt-https
in the terminal, first make user you are logged in as your default user. Not the root user. And type:
sudo /scratchbox/sbin/sbox_adduser $USER yesThis is optional, But I’d do it anyway just in case :
sudo ln -s /scratchbox/users/$USER/home/$USER /scratchbox/users/$USER/home/user sudo sh -c 'echo "nameserver 8.8.8.8" >> /scratchbox/etc/resolv.conf'
sudo sh -c 'echo "nameserver 8.8.4.4" >> /scratchbox/etc/resolv.conf'
You will need to ensure:
1. your group membership is registered in the current terminal
2. VDSO support is disabled,
to do so run these in the terminal: newgrp sbox
sudo sh -c 'echo 0 > /proc/sys/vm/vdso_enabled'
/scratchbox/login If this works, you will be inside of the scratchbox environment; and you will see something this in the terminal: [sbox->:~]>
sb-conf st FREMANTLE_X86 -c cs2007q3-glibc2.5-i486 -d perl:debian-etch:doctools:svn:git -t noneit is safe to ignore the warnings here.
sb-conf st FREMANTLE_ARMEL -c cs2007q3-glibc2.5-arm7 -d qemu:perl:debian-etch:doctools:svn:git -t qemu-arm-sb
wget http://repository.maemo.org/stable/5.0/armel/maemo-sdk-rootstrap_5.0_armel.tgz http://repository.maemo.org/stable/5.0/i386/maemo-sdk-rootstrap_5.0_i386.tgz
If networking doesn’t work inside of scratchbox, check your DNS server settings. Unfortunately there’s no `ping` inside of scratchbox so the only way to do this is to edit /scratchbox/etc/resolv.conf from OUTSIDE of scratchbox and paste the following:
nameserver 8.8.8.8From inside scratchbox, paste the same lines to “/etc/resolv.conf”
nameserver 8.8.4.4
sb-conf se FREMANTLE_X86
sb-conf rs maemo-sdk-rootstrap_5.0_i386.tgz
sb-conf in -edFL
You’ll need to do some apt trickery here for maemo related items. So first accept the EULA here and copy the URL, paste the it into /etc/apt/sources.list (inside scratchbox) and then:
apt-get updateKeep the url, you will need it later on in this installation
fakeroot apt-get install maemo-sdk-debug nokia-binaries nokia-apps
According to the instructions from maemo you will need to remove a symlink and replace it with a folder so do this in the terminal: rm /targets/FREMANTLE_X86/opt
mkdir /targets/FREMANTLE_X86/opt
At this point the x86 target is setup, you will need to do the same for the armel target.
edit the file /etc/apt/sources.list and paste the URL that you got previously after agreeing to the EULA
sb-conf se FREMANTLE_ARMEL
sb-conf rs maemo-sdk-rootstrap_5.0_armel.tgz
sb-conf in -edFL
apt-get update
fakeroot apt-get install maemo-sdk-debug nokia-binaries nokia-apps
rm /targets/FREMANTLE_ARMEL/opt
mkdir /targets/FREMANTLE_ARMEL/opt
export DISPLAY=:2And from OUTSIDE the scratchbox environment:
af-sb-init.sh start Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb & And you will be greeted with a very reassuring emulator-like environment emulating the Maemo 5 on a Nokia N900
DailyChilly recovery after pwned
Disclaimer: I’m not encouraging breaking and entering or defacing other peoples websites. Regardless of how dumb they may be or how tempted you are to show your l33t-ness
So the Daily Chilli was pwnd at sometime before Sun Feb 14.
I can’t imagine what the administrators must be thinking, doing this so publicly on a public website. The only thing I could deduce was that the sysadmins sucked. Which could only mean one thing. There will be a phpMyAdmin somewhere. So I looked for in the standard locations and found
Compaq CQ40 Wireless Driver
This did not work out-of the box for me with Kubuntu 9.10.
`lspci` showed me that the wireless device was:
03:00.0 Network controller: Broadcom Corporation BCM4312 802.11b/g (rev 01)
This is messed up. The driver provided by the manufacturer worked fine with the previous kernels and the previous releases of kubuntu (kernel 2.6.28 ). After some googling I found a broadcom driver in the Ubuntu ‘restriced’ repos which is provided by the package `bcmwl-kernel-source`.
So if you have the “restricted” repositories turned on in your machine this will work fine. You’ll just need a reboot sudo aptitude install bcmwl-kernel-source
What you need to know about the Nokia N900
Alright my full post on this is really long so here’s a minified version with links to the full text. I never wanted this to be a simple list, because I don’t feel it does justice to the product. So if something mentioned here is new to you, find time to read the full text.
1. the Nokia N900 is not a smartphone read more…
2. It’s not meant to give you “web-like” experience read more…
3. It is not sexay read more…
4. It uses a resistive screen read more…
5. The display is almost entirely landscape read more…
6. The Hardware Keyboard is pretty small read more…
7. Choices of available apps are small and scattered read more…
8. Social Media integration isn’t quite there yet read more…
9. TFT LCD and not AMOLED read more…
10. OGG support is not default read more…
11. The MyDocs partition is on vfat read more…
12. Pluging in the N900 to your laptop will unmount ‘MyDocs’ read more…
13. The Battery life is just as expected (approx 6 hours). read more…
14. It runs on the `armel` architecture and not `arm` read more…
15. Multitasking is awesome read more…
16. The peripherals included are of pretty high quality read more…
17. The hardware is deceptively great read more…
18. Almost anything from linux – now at your palm read more…
19. Yes a terminal comes preinstalled read more…
20. You really own your phone read more…
20 things to know about the N900 before buying one
Buyer Beware – What you should know about the n900 before buying one.
I’m writing this after a whole week of playing with my new toy (courtesy of WOMworld/Nokia). Most of what’s here are gotchas, which any new owner will learn within an hour. Some others by the end of the day. And some almost never until/unless you actually try it out. Hopefully this will ease any frustrations of a new user, but mostly I’m writing this down to manage expectations. Know what you’re buying before you get one. Most of what I’m writing is (for one reason or another) not provided by the Marketing Guys at Nokia anyway.
- The Nokia N900 is not a smartphone
- It’s not meant to give you web-like experience ..but…
- It is not sexay.
- It uses a resistive screen.
- The display is almost entirely landscape.
- The Hardware Keyboard is pretty small.
- Choices of available apps are small and scattered.
- Social Media integration isn’t quite there yet.
- TFT LCD and not AMOLED
- OGG support is not default.
- The MyDocs partition is on vfat
- Pluging in the N900 to your laptop will unmount ‘MyDocs’
- The Battery life is just as expected.
- It runs on the `armel` architecture and not `arm`
- Multitasking is awesome
- The peripherals included are awesome
- The hardware is deceptively great.
- Almost anything on linux – now at your palm
- Sure a terminal comes preinstalled
- You really own your phone
Unlike a lot of the other N series or the Androids or the iPhone, the N900 is not a Smart Phone. Nokia themselves call it a Mobile Computer, some call it a tablet. I’ll call it a PDA – that runs on GNU/Linux and has the capabilities of a mobile phone. So don’t expect a phone with the capabilities of a micromini computer, it’s a (pretty powerful) micromini computer with the capabilities of a phone. That said, there really is nothing else like it in the market, the iPhone is a sexy phone which fits in well with the Mac Lifestyle. The Nexus One is a good phone with a good amount of processing power available, but they are both primarily intended to be a phone. I will however include some comparison to both the iPhone and the Nexus One throughout this page as a benchmark.
The N900 isn’t meant to give you web-like experience with desktop apps, it is meant to give you the full-fledged web experience in your 3.7″ screen. The jury’s out on how good an idea that actually is; but for now i have no real reason to complain – except for the fact that Flash (macromedia) is a bitch to deal with.
There’s no streamlined sides as per the iPhone. Protruding hardware buttons are all over the place. It is about twice as bulky as the iPhone or the Nexus One. The camera protrudes a tiny bit which is enough to make one side look thicker than the other when placed on a flat surface. The glossy black housing is appealing to me, but that’s about it.
Most other smartphones (Nexus, iPhone) you will know uses Capacitive Screens. Capacitive screens require a Human Touch. Specifically from your fingers. Not your fingernails, not your thumbnails, not a stylus. Resistive screens are generally the exact opposite. In addition you will need to use a little more force. Resistive screens are not known to have multi-touch, so don’t expect one anytime soon. However as far as resistive screens are concerned, this one is pretty responsive. Plus I actually enjoy using the stylus sometimes. The resistive screen allows for things like these
This is hardly a hardware issue. Running Everything in portrait mode tops the wishlist, so I expect a patch to be available for Maemo 5 soon enough, but as of now the only thing you can actually run in both modes seems to be the Phone application as well as the Web Browser (hidden feature as off now). Even the Virtual Keyboard doesn’t work in portrait mode.
I can’t imagine being able to effectively use the keyboard without nails. The keys are really close to each other. This is something that cannot be fixed via a software upgrade (duh) so you’re pretty much stuck with it. There is a Virtual Keyboard available on the N900 which works way better for me as opposed to the hardware keyboard. The hardware keyboard and its layout is something that Nokia can learn from the HTC Dream (or HTC G1 depending on where you are).
You may find and install applications from 3 different locations:
1. Ovi Store – browse it from the web.
2. Application Manager – Basically some apt-like app with icons of the application, you can add different catalogs to access more application.
3. The Web – There are 3rd party independent app providers that allows you to install their applications, this includes Mozilla which provides Firefox for the N900
This is nothing compared to the 60 Trillion apps for iPhone, but it’s currently lean, and constantly growing. Also with more and more linux applications being ported – or rather recompiled – for the Maemo, brace yourself with the Linux problem of Too Many Application.
The Facebook app / widget only shows your your contacts status, if you want to comment you will need to browse to facebook.com. The only thing that works well is sharing pictures. I Haven’t found a good enough twitter widget although the Application Mauku is pretty good. I don’t see whats great about witter despite the ravings. The Twitter application is alright – read about it here. The application Hermes seems to have some great potential. But none of these comes default. Neither does the Yahoo or MSN IM Plugins. All these will have to be installed from the extras-devel repository which is relatively easy to install but not something I’d recommend to just any non-techie user.
Which makes the screen itself almost as thick as an iPhone. However I dare say I prefer TFT over AMOLED on a phone (based solely on what I see from a Nexus One). The Nexus screen is amazingly reflective and the colours look surreal, almost fake. The bulk that comes with a TFT however – thats a different story.
OK fine, so everybody uses MP3′s; but its plain rude to use a Debian derivative without including the defacto Free / Open Source standard for encoding music. Sure you can install the OGG support, but I take this as a sign of Nokia ignoring the FOSS crowd who are (IMHO) the first to jump at the chance to own and contribute to the N900
I don’t know why this was done this way; perhaps to simplify the process of using the phone as a Mass Storage device?. But this is 1. another sign of Nokia ignoring the FOSS crowd and 2. Just makes it that much more difficult to hack. It may be possible to reformat the partition to ext2 but I sure as hell ain’t gonna try. So to those of you who intend to install debian, take note of this gotcha first.
If you’re connecting the Phone as a Mass Storage device, the phone itself will unmount the partition /home/user/MyDocs which is where your 20 plus gigs of storage is. This is probably done to eliminate problems with 2 machines mounting the same device. But it (in all likelihood) will cause a problem when you try to install Debian. I can’t confirm this, it’s probably just a gotcha to take note of.
Normal usage (3G internet always on, some surfing, some widgets running, some maps, some chatting) gives you about 6 hours. Thats not really much difference from a Nexus or an iPhone with the same amount of productivity. While that is nowhere near my existing phone (Nokia 3110 or something) which gives me 3 days of normal usage, it is within current expectations – relative to the other options at least.
What this means is that you will need to look in debian’s armel repos instead or arm. If you don’t get what this means then it probably doesn’t concern you so don’t worry about it.
Thats right, no more rebooting the phone just because you accidentally turned on 3 *gasp* applications. Flash is a memory hog, so is Firefox (well whats new) but running about 5 different appilcations at the same time, and some widgets in the background and still being able to use Firefox is amazing enough to me.
Nokia definitely did not skimp on this one. The earpugs blocks out all sounds and there’s 3 cover sizes to choose from. The charger comes with an adapter which allows you to use any(?) existing Nokia charger. The data cable looks great. The composite TV cables (and all the cables in fact) are high quality material. Enough to make any iPhone or Nexus One owner red with envy.
Reading through the specifications does not do it justice. Make no mistake – there’s no Snapdragon (the current Holy Grail of ARMs) here, the CPU runs at about 600MHz as opposed to the 1GHz of a Snapadragon. The internal 0.3MP camera is horrible but I suppose good enough for video calls. Here’s where the fun start: there seems to be a dedicated GPU which supports OpenGL and a Digital Signal Processor both running at approx 450MHz which offloads the 600MHz Coretex from anything besides the OS and the Applications. There is 256MB of Dedicated RAM and 768MB Virtual Memory which seems to handle about 6 apps simultaneously pretty well. The resolution is the best I’ve seen so far – 267 PPI (Pixels Per Inch). Nexus One’s has 251 PPI which is really close; both make the iPhone’s 163 look pathetic. The 5MP camera with a Carl Zeiss lenses takes awesome pictures. And 32GB Internal Storage? That almost fits all my pr0n. Can’t argue with the TV out either.
I’ve installed aircrack-ng, nmap, openssh-server (yes. server.) and a shitload of other applications that I’m used to having on a regular Linux Desktop. You also have the ability to install Debian on a chroot environment and apt-get install everything. I haven’t actually tried this, but STFG and you’re bound to find someone who did. Just remember the vfat.
The shell is ash and runs BusyBox. There’s a few flaws though, like the fact that /usr/sbin is not a part of the $PATH which means simply typing `ifconfig` will not work – you will need to specify the full path. Also the virtual keyboard will not work because there’s no bloody [enter] button. That’s probably an oversight on Nokia’s part – or mine. I kinda doubt it’s mine. A virtual [tab] key is always available which allows for autocomplete. Sweet.
Rooting the n900 is Really Easy. This is admittedly not the first thing most people look at, nor is it that much simpler than rooting a Nexus One; but for those who want root, it takes 3 very easy steps to get there. This is not something you can say about the iPhone; the Android phones lie somewhere in between in this aspect. Also, there’s a debian chroot app in the store, all of which ensures you own the phone, and not the phone pwns you.
What you really need to know however is that Maemo as a platform is most likely every geeks wet dream. It’s a tinker toy with all the (barely realised) potential in the world. If you want a smartphone that works out of the box get a iPhone or a BlackBerry, if your life revolves around Google and specifically Google Apps, get the Nexus One.
If however – you want a gadget and the opportunity to contribute to the direction and the evolution of a new platform – this is for you.
If you want a tinkertoy that does almost anything you want, this is for you.
If you want the best hardware in a mini package, this is for you.
If you are a GNU/Linux user and are addicted to the power and freedom of FOSS, this is for you.
If you don’t mind putting in some effort and later feeling the rush of success, and having just as many ‘Eureka!!’ moments as ‘OMGWTF What were they THINKING’ moments, then this is for you.
If you want port scanners, vulnerability scanners and (almost) everything else you find on a Linux desktop on a mobile device then this is for you.
Most important – I have listed in full glory all the downsides of the phone. If you are still reading this, and still considering the n900, then this is for you.
I only hope that Nokia listens to its users (and developers)- especially the unpaid FOSS developers without whom Maemo will not even exist. There are small lil issues mentioned that will concern Linux hackers that needs to be fixed. @Nokia – you’re in FOSS grounds now, you can’t turn your backs on us.
Using the Nokia N900 as a modem
For those of you who don’t know, I was lucky enough to be selected to receive a Nokia N900 for trial courtesy of WOMworld Nokia. I will write about my experience using the phone as a first-time smartphone user soon enough; I don’t think I’ve had enough time to build a first impression
For now though, here’s a howto on the first thing anyone would want to do with a 3G phone: turning it into a modem. This applies to someone in my scenario who is connecting a Nokia N900 to a Linux machine (also known as tethering). However it should apply the same to any other machine using the same concepts. Which is that you can plug the phone in, expect it to register as a USB modem, and use a dialer to dial out.
Step 1: Connect Your Phone
Make sure your phone is connected to the machine via the US cable that comes packaged with the phone. Upon connecting your phone to the machine you will see a pop-up on the phone that asks how you would like to connect this device, with the options being “Mass Storage mode” or “PC Suite Mode”. Technically you should be able to use the phone as a modem even without making a choice here, but if you can’t connect without choosing, choose “PC Suite Mode”.
Step 2: Make sure the phone is recognised as a USB modem
Make sure the phone (Nokia N900 in this case) is recognised as a USB modem by the machine. To do so run lsusb from the terminal. Which should give you something along the lines of
Bus 002 Device 007: ID 0421:01c8 Nokia Mobile Phones Next run ifconfig from the terminal, you should see a new device “usb0″. This is where you know you’re good to go. If you don’t get this, well, unplug the phone from the machine and try again.
Step 3: Make sure your phone is no longer connected to the internet.
edit: this step is dependent on your provider. You may not need this
That means shut down your Internet Connection (generally your 3G) on the N900. And on the N900 this was a little more difficult than I expected; because I did initially set my phone to connect whenever it can. Turning the 3G services off did nothing to override the previous settings, the phone just tries to reconnect again. That means you will have to first make sure you turn off the settings to “Always Connect” and only then turn the Internet Connection off.
Step 4: Configure your dialer
I use wvdial and i recommend you do too. If you don’t have it, install it (ie “sudo apt-get install wvdial). For this step there’s one really important detail that you will need to know which is your APN (Access Point Name). This differs across carriers so google for your carrier / ISP’s APN first. The next thing to know will be the credentials required to login. I’m using DiGi where the APN is “diginet”; the username “guest” and the password “guest”. The rest of the settings aren’t too different from my 3G broadband settings identified here.
Note: the modem in my case is registered as /dev/ttyACM0 which IIRC is a standard USB modem, but you will want to confirm the location of your modem before actually configuring your dialer
Step 5: Dial
As mentioned I use wvdial, so all I need to do is to ensure I have configure the config file at /etc/wvdial.conf and from terminal type sudo wvdial. I have included the wvdial config file below which of course works for me. Your own config file shouldn’t look that much different with the exception of the APN, the Username, the Password and maybe the Phone number.
[Dialer Defaults] Modem = /dev/ttyACM0 Baud = 230400 Init1 = AT+CGDCONT=1,"IP","diginet" Init3 = Area Code = Phone = *99***1# Username = guest Password = guest Ask Password = 0 Dial Command = ATDT Stupid Mode = 1 Compuserve = 0 Force Address = Idle Seconds = 0 DialMessage1 = DialMessage2 = ISDN = 0 Auto DNS = 1 Check Def Route = 1







How to test your webcam in Ubuntu
Testing your webcam is done with mplayer, first though you’ll have to install mplayer as so:
then fire up mplayer as so but in one line:
And you SHOULD see your pretty face on the screen. Good Luck.