Archive for the ‘Internet/Web’ Category

Kindle Touch landscape mode – Ubuntu / Linux fix (my solution…)

December 5, 2011

I got my Kindle Touch Wi-Fi with special offers last week. More info on this nice device at the Amazon Kindle Touch page, the Kindle Wikipedia article page, and of course Google searches will do you lots of good.

Granted I’m busy so I’ve not been able to maximize its use yet but I’ve been able to play with it and organize my books and personal documents already. Overall I like the look and feel and functionality of the Kindle Touch (or KT) and I believe you can search reviews with Google, including this good Kindle Touch review by CNET. For reading novels in the native formats accepted by Kindle (e.g. .mobi, .azw files) the pinch-and-zoom as well as the swipe (or just tap) to go to the next/previous page, among other features of KT, are great.

As a researcher though I have lots of PDFs to read, many of which have text formatted in mathematical notation (such as those made using LaTeX). Of course KT can handle PDFs, and even though you could pinch-and-zoom as well as swipe to pan through a page or through pages, reading a PDF  file this way can be really cumbersome especially since the default orientation of viewing in KT is portrait mode. It would be nice if we can rotate the KT to landscape orientation to better read PDF files. However, according to an official statement from a Kindle Customer Support representative, landscape mode is not available on KT. Bummer. I immediately emailed Amazon at kindle-feedback@amazon.com (all of you should! 🙂 ) asking for future software/firmware update to automatically change orientation in KT, and when might this be.

Right now, a sort of “hack” is possible to allow Ubuntu (and other GNU/Linux distros) users like myself to read our PDF books and files in landscape mode in the KT. An answer is to use the pdftk commandline tool which I made a post about some time ago. You can also refer to the man page of your GNU/Linux distribution after installing pdftk. In Ubuntu, a simple and quick apt-get or Synaptic installation should  do the installation job for you (check my post about pdftk above, or search this blog). The “hack” goes like so:

Say you have a PDF file named mydoc.pdf. To rotate the entire PDF file (assuming it is in portrait orientation by default) 90 degrees counterclockwise (so now the mydoc.pdf is now in landscape orientation) fire up a terminal and type:

$ pdftk mydoc.pdf cat 1-endW output tmp.pdf

Where tmp.pdf is the desired output filename of the re-oriented (now in landscape) version of mydoc.pdf. Now you can copy or email the file tmp.pdf to your KT and read your PDF file in landscape mode. 🙂 I’ve yet to check if pdftk works in Mac OS (I won’t be surprised if it does) though I believe this pseudo-hack might turn out to be more “graphical” or point-and-click in nature than my commandline solution above. 🙂 A user from the Amazon KT support page above mentioned using a professional version of Adobe reader to graphically do this, perhaps in Windows and in Mac OS as well. I’d appreciate if somebody would post a link on how to do this graphically in Ubuntu (GNU/Linux), Mac OS, and even in….Windows… 😉 🙂

Happy hacking and Kindling. 🙂

Thoughts on Ubuntu/Kubuntu 9.10

December 2, 2009

After more than a month since Ubuntu/Kubuntu 9.10 codename Karmic Koala was released, here are some thoughts and noteworthy things about it:

Grub2

Ubuntu 9.10, among other recent Linux distros, now uses Grub2. I didn’t read all the release notes, and when I suddenly became curious at taking a look at my menu.lst to see what Grub2 has in store for me, I was in for a surprise. Grub2 doesn’t use menu.lst anymore. It seems menu.lst is already part of legacy Grub. Initially I disliked this, having used menu.lst since I started Linux (6 years ago). The menu.lst has now been superseded by the /boot/grub/grub.cfg file. However, the grub.cfg file is preferably not to be edited by the user, as it is automatically generated by other scripts such as grub-mkconfig. Now I think it’s a good idea to have this boot file editable by a script, which has rigid syntax and rules in order to properly create a boot config file. Of course, nobody is really stopping the hacker inside any of us to not edit the file, nor to create our own menu.lst, or even to revert to legacy Grub versions.

source/s:

Xorg

Ubuntu 9.10 also uses the updated version of Xorg  (as of typing this I use version 1.6.4) doesn’t use an xorg.conf anymore. As Ben Grim/The Thing puts it, “What a revoltin’ development!”. Again initially I was irked by this, but later I also realized it was for the better, since xorg.conf was becoming too cryptic for newer users of Linux. Now the xorg.conf tasks are being handled by several other config files and scripts.

Which got me thinking, since xorg.conf has already been deprecated, what of the ctrl+alt+backspace that we (or at least I) have grown to love when restarting X? It turns out, the ‘dontzap’ option didn’t work anymore, I tried it. The ‘dontzap’ directive worked for 9.04, but apparently not so for 9.10 onwards.  As a result, one way to turn on ‘ctrl+alt+backspace’ back in Kubuntu via graphical method is as follows:

Enabling Ctrl-Alt-Backspace for Kubuntu

  • Click on the Application launcher and select “System Settings”
  • Click on “Regional & Language”.
  • Select “Keyboard Layout”.
  • Click on “Enable keyboard layouts” (in the Layout tab).
  • Select the “Advanced” tab. Then select “Key sequence to kill the X server” and enable “Control + Alt + Backspace”.

Or, for command line folks like me, by doing

setxkbmap -option terminate:ctrl_alt_bksp

source/s:

Deprecation of hal

Several scripts, including devkit-power and devkit-disks are being used as replacements for hal. So far no issues here, and I think so far power as well as disk management in 9.10 is doing great. I do still see hald running in my machine, wonder why that is.

Some caveats and surprises

I’ve had several issues regarding my initial install of Kubuntu 9.10 32 bit desktop. One was Dolphin crashed a few times while I was dragging and dropping files to VLC’s playlist window. These crashes happened in the first 2 to 3 weeks of my installation, regardless of my constant updating of the system. The great thing however is that KDE wallet, coupled with the revamped bug reporting of KDE 4.3.X/Kubuntu 9.10 makes it so much easier to report bugs nowadays. Eat your heart out Micro$oft. 🙂 I do wish they’d fix and close the bug soon. 🙂

I haven’t really been using Konqueror a lot lately since Kubuntu 9.10 now has an ‘Install Mozilla Firefox browser’ option included, even in the live version of the OS, which is nice. In the KDE 3.5.X era I used Konqueror a lot, not as a browser but as a very useful file, ssh, ftp, samba, whathaveyou browser. Nowadays Dolphin is all that except a browser. I can still use Konqueror as my main file browser though, I might try that some time. But I’ve grown to slowly accept Dolphin in my day to day computing tasks. The previews, zoom in/out sliders,  different panels, and the widget make of Dolphin make it a delight to use. So so far no issues with Konquer in 9.10 yet.

Dolphin also makes management of drives a breeze, whether they be internal (IDE, SATA etc.) or external (USB drives, media players etc.). The Oxygen theme also looks very sleek and futuristic.

As with my installation of Ubuntu 9.04, ext4 was a marvel to behold, more so since the 9.10 version uses ext4 by default. Even with apache2 and mysql running at boot, my boot time is well under 30 seconds, even with older single core procs.  Scripts like ureadahead make booting much faster.

Conclusion – for now

Other than perhaps minor setbacks I forgot to mention, plus the introduction of some new technologies I listed above, the 9.10 version of Ubuntu/Kubuntu is a marvelous piece of work, stability, dependability,  and usability wise in my opinion. So far. Can’t wait for 10.04/Lucid Lynx.

IPCop Linux, route command, and network routing

September 16, 2009

This short post is about the dilemma a coworker of mine just had this morning regarding network packets, and a not fully functional IPCop Linux installation.

The Dilemma

The server runs IPCop, which allows a PC to run as a firewall appliance. The IPCop server has 2 NICs, eth0 and eth1. Eth0 is connected to a Class A private LAN while eth1 uses a Class C address to connect to the public Internet. The problem however is that the Internet is accessible (Google, Yahoo! etc.) but not private LAN machines and addresses.  The private LAN’s gateway return ping replies, but not the DNS server.

Detective Work (i.e. Troubleshooting)

What I did was to check all possible causes for this problem: restart the network, checked logs for error messages and others, though some of these had already been done, but I just want to be doubly sure myself. I next checked the firewall using the iptables command. There were tens of lines of firewall rules, along with numerous chains. Since I was in a hurry at that time, I decided to skip the detailed checking of the firewall rules for the moment, even hough I have experience dealing directly with iptables, and not with the higher level application firewalls that just modify it. Next I tried to ping again the DNS server. Adding a -v in the ping command to make it more verbose, I noticed that packets were being successfully sent to the DNS server, but no packets were coming back. I thought to myself that the iptables firewall is one good suspect for this, but I’ll try a few more checks before I go to the nitty gritty of iptables firewall rules. I did ifconfig ethX up and then  down but to no avail. Replace the X with the NIC number you wish to up/down.

The Fix

I next checkd the routing table using the very useful route command. The static IP route looked fine, but I noticed that it was rathe incomplete, given that it has 2 NICs. What I mean by incomplete is that the route from the public, Class C network has routes for going in and out of the destination network and host, but the private LAN doesn’t have a route for traffic going into the IPCop server. It only has a route for traffic coming from the Class A private LAN NIC. Bingo was its name-o. 🙂 Apparently the reason why ping packets weren’t making their way back to the IPCop server was that they weren’t being routed correctly back to the IPCop server itself. This was further supported by using the traceroute command. I traceroute-ed the private LAN DNS server and as expected, the routing of the packet was all messed up. The traceroute packets for the private LAN DNS server were exiting through eth1, and out to the public Internet already. No wonder it doesn’t have a private LAN connection! 🙂

So the fix was to add a correct route to the routing table using the route command. The new route should, well, route the packets correctly from the  private LAN back to the IPCop server, and to make sure that the class A private LAN traffic enters/exits via the eth0 NIC. To do this the command

route add -net NETWORK netmask NETMASK gw GATEWAY

was used. Just replace NETWORK, NETMASK, and GATEWAY with the appropriate values for your network. In our case, NETWORK was the destination host ( the local machine, given by 0.0.0.0) and GATEWAY was the gateway of the Class A network of the private LAN.

Sure enough, after adding that static route, the Class A private LAN became accessible. 🙂

route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4

Estimating Distances Technique – A Detailed Inspection

September 14, 2009

This post is about a web article which mentions a technique that allows you to estimate, to a relatively good degree, your distance from another object. I’ll then explain the minor error which the article has, as well as the assumptions of the technique which the web article did not mention.

The Technique

I came across this neat trick from lifehacker.com about estimating distances using your arm and thumb. It is quite useful, but below I will outline a relatively minor error of the article, particularly the diagram used. It was a minor error but it still strikes me as something that should be brought to light, since it’s pretty trivial too. The original article btw was taken from the almanac.com article of the same name. Both articles were quite short so they only took me a small amount of time to read through them and to quickly notice that there was something wrong with the diagram.

The articles emphasize the fact that one’s arm (held straight) is approximately 10 times longer than the distance between your eyes. The articles also mention that with a bit of applied trigonometry, one can estimate distances between you and an object which you have a reliable width knowledge of. Unfortunately the article writer/s might have focused on the trigonometry part too much, overlooking their basic geometry when they created the diagram.

Here is the original almanac.com diagram showing a man estimating his distance from a barn which he originally knows the approximate width.

how-to-estimate-distances

How The Technique Works

In case you haven’t read the original article yet, it basically says that (again from almanac.com):

  • Hold one arm straight out in front of you, elbow straight, thumb pointing up.

  • Close one eye, and align one edge of your thumb with one edge of the barn.

  • Without moving your head or arm, switch eyes, now sighting with the eye that was closed and closing the other.

  • Your thumb will appear to jump sideways as a result of the change in perspective.

How far did it move? (Be sure to sight the same edge of your thumb when you switch eyes.)

  • Let’s say it jumped about five times the width of the barn, or about 500 feet.

  • Now multiply that figure by the handy constant 10 (the ratio of the length of your arm to the distance between your eyes).

Now you get the distance between you and the barn—5,000 feet, or about one mile. The accompanying diagram should make the whole process clear (shown above).

The Error In The Original Diagram

The error comes from the fact that the original diagram, whether it be the vertical one from almanac.com or the horizontal, modified version from lifehacker.com, show the distance line not being parallel to one line common to both triangles formed. To see this more clearly, I’ve created a little more technical and descriptive diagram below. The new diagram shows, correctly, that the distance line (containing the 5000′ and 20” distance markings) is parallel to the line connecting the observer’s left eye to the barn’s new location. That’s it. That’s the error 🙂 It may seem trivial, and it actually is, but I couldn’t help noticing it, especially since apparently no one has commented about it, and some people I know who should have noticed it, didn’t. 🙂 The original diagram shows the left-eye-new-barn-location line to be non-parallel to the distance line, which is wrong, and which quickly caught my skeptical eye. Basic geometry will tell you that my new diagram below is the more correct one.

wp-blog-post-estimating distances 2009-09-13

Assumptions Which Were Left Out

The assumptions which the article does not mention include:

  1. One knows a relatively precise measurement of the object’s width, or that one should know a good deal about the object’s width before attempting to estimate distance with this technique. To see how this can become a problem if not entirely taken into consideration, suppose you estimated or falsely remembered that the barn was 400ft instead of 500ft. That would translate to your estimated distance of 4000ft, which is 1000ft shorter than the correct 5000ft! 🙂 You’d then get a nasty surprise since you left out 1000ft. In other words, since the ratio of the object’s width to the distance between it and you is 10, your width estimation errors (again, could be from wrong estimation or remembrance of the object’s width) get translated to a distance error multiplied by 10.
  2. The topography of the terrain. This technique assumes or works best in a plain, since if you were say in a hilly or mountainous region, the distance you’ll get from this technique is the straight line distance from you to the object. But it does not take into consideration the slope, nor the crests or troughs of the land. You may get a distance of 1000ft between you and the object, but if there are hills and such between you and the object, you know it will be more than 1000ft. 🙂

Gracias a mis amigos Rudolf y Aaron. Thanks to my friends Rudolf and Aaron for their quick help in confirming this error, since I wanted to be triply sure. 🙂

Default WordPress (Kubrick) stylesheet romantic poem :)

August 20, 2009

I was actually backing up my WordPress (WP) posts, tags, comments, etc. via the Export option in the Administration page when I stumbled into this poem. The backup was just in case I set up my own WP installation, say in my own domain. Nevertheless, I also tried downloading some pages of my blog that had images, particularly logos, which weren’t really stored in my WP blog but were instead taken from other sources in the web, via the HTML tag <img> and its parameter src.

Then came a surprising revelation: if you try using the current version of WP, Kubrick, and then you check the style sheet: you’ll be confronted with this nice, witty and funny poem (at least in my opinion) about a guy probably wanting to marry a girl:

/* “Daisy, Daisy, give me your answer do. I’m half crazy all for the love of you.
It won’t be a stylish marriage, I can’t afford a carriage.
But you’ll look sweet upon the seat of a bicycle built for two.” */

It’s at the bottom of the file style.css, which you can get by saving any page from a WP site using the Kubrick theme (and perhaps other themes made by Michael Heilemann, the maker of the Kubrick theme). You can actually see it for yourself by saving the page you are viewing now. Check the source code of the page you just saved (i.e. my web blog page) and then view the contents of style.css. Voila! The short poem above appears at the bottom, perhaps written by Michael Heilemann himself. 🙂

Of course this poem might be very famous and well-known already even though I’ve only found out about it just now. You’ll have to excuse my not so wide ‘circle’ of information sources. 🙂

I should try adding poetry sometime in the source codes of my software projects. Maybe I’ll do so now… 🙂

Fixing the PHP error/warning “Cannot modify header information – headers already sent “

August 18, 2009

This will be a quick post/note-to-self since I’m pretty occupied. Actually, the title of this post should have been “How to bloody fix the deceptively easy but hard to find confounding error in PHP headers: “warning Cannot modify header information – headers already sent”. But that’s too bloody long (though it would be interesting to find out in the future how WordPress concatenates long URLs…). The reason why I call it deceptive will be clarified at the 3rd entry below 🙂

The 2 primary parts of an HTTP request response are the headers and the body, which should be sent separately. Now in PHP sometimes some programmers, not just novice ones but long time ones (ehem…like me…) forget that we’re modifying them programmatically, which can sometimes cause errors. The header must always be sent first before the body, wherein both are coming from the web server. This is highlighted in this Wikipedia HTTP request example. For example, the php function header() can modify some of the (obviously) header parameters, most/all of which are listed in this Wikipedia list of HTTP headers. The above PHP error occurs because the body (or part of it) has already been sent by the server to the client, afterwhich a change of header values follows, either from the client or server.

Now, to finally fix the deceptively easy to fix but hard to find source of the error

Warning: Cannot modify header information – headers already sent by (<some of your PHP source files should be listed here>)

You can check the following:

1) If you’re using the header() function or some PHP function that modifies the header or controls the flow of action of your pages (e.g. from one page to another), you should inspect those. Usually it’s better to use conditional statements (e.g. IF or ELSE) to isolate the execution of one part of your code from another. It is quite likely that the error comes before or at the line of this function.

2) Make sure you don’t output/print/echo anything to the client (body) before sending/changing the headers. Again, conditional statements are useful here.

3) Finally, and the easiest to overlook, is to remove any white space outside the PHP start and end tags (<?php ?>). This is quite often the easiest thing to miss (for me at the least). The reason for this deceptive white space causing an error in PHP is that the white space is still interpreted as an echo statement printing a blank line, which interrupts the format of the HTTP header (see Wikipedia header format example above).

Of course the disclaimer here is that you are to most likely encounter this error if you’re more or less building your PHP application from the ground up, or without using web frameworks. It’s more unlikely and unusual to receive this error while you’re using an MVC based PHP framework.

warning Cannot modify header information – headers already sent But

Vulcan salute ASCII art

August 10, 2009

As you all know, a lot of people, creative in art or not so much, create and use ASCII art ranging from the complex (machines, sceneries, human faces) to the trivial ones (faces, smileys: 😉 (^)__(^) d(o)_(o)b ). Now I’ve been looking around the Internet for a Vulcan salute ASCII art that really appeals to me. I mention appeal because the Vulcan salute ASCII arts I’ve seen so far are not so convincing, i.e. they don’t really look very much like the real salute (of course this is obviously a subjective thing).

Some of the Vulcan salute ASCII arts I’ve found are the following:

This one involves an underscore followed by 2 forward and backward slashes (source: http://www.geocities.com/dronak/smileys.html)

_\\//

This next one has one version similar to the above art, while the other version uses a “les than” symbol ‘<‘ to introduce the thumb (source: http://en.allexperts.com/e/e/em/emoticon.htm)

<\V/ or \V/_

As I’ve mentioned, I’m quite displeased with the above Vulcan salute ASCII art and so I created my own versions. The following are my two versions with specifications describing them and how they are made:

My version 1

_\\//()

\V/,

Specifications: This version uses backward and forward slashes to represent the pinky and the index finger, respectively, while the capital letter ‘V’ represents the ring and middle finger. Lastly, a comma represents the thumb. I used the comma for the thumb, and not an underscore like the above versions, since the thumb is usually not angled that much from the index finger in a usual Vulcan salute. In my version the forward slash (index finger) has a much smaller angle/opening with respect to the comma (thumb) compared to using a forward slash with an underscore. The smaller angle/opening is in my opinion, the correct form of the Vulcan salute as shown by Spock in this image.

My version 2

\\//,

Specifications: This is quite similar to the first  version I mentioned at the start of this post. That is, slashes represent the four fingers with the exception of the thumb. The differentiator is also the comma representing the thumb, which again has a look closer to the way a Vulcan salute is done.

License

Finally, I license my 2 ASCII art versions of the Vulcan salute under the following Creative Commons licenses listed here:

  • Attribution Attribution (by): Licensees may copy, distribute, display and perform the work and make derivative works based on it only if they give the author or licensor the credits in the manner specified by these.
  • Non-commercial Noncommercial or NonCommercial (nc): Licensees may copy, distribute, display, and perform the work and make derivative works based on it only for noncommercial purposes.
  • Share-alike ShareAlike (sa): Licensees may distribute derivative works only under a license identical to the license that governs the original work. (See also copyleft.)

That is, under the Attribution + Noncommercial + ShareAlike (by-nc-sa) licenses of Creative Commons.

Comments and suggestions are welcome as long as they are calm and ruly.

And, as is the customary farewell among Vulcans,

Live long and prosper \V/,

Quite Quotable Quotes: The Big Bang Theory

July 29, 2009

The Big Bang Theory (TBBT) is undoubtedly my favorite sitcom so far. I’ve never really been into sitcoms actually. Some of the last few ones I watched were (believe it or not) Seinfeld, Fraser, and Friends, and I didn’t really get into them that much. I just watched a few episodes here and there, usually with my dad or with my sister when we were much younger. TBBT has fervently rekindled my attention towards sitcoms, in such a magnitude I can only describe as the energy needed to accelerate an electron to 0.99% the speed of light 🙂

Needless to say, there are quite a lot of sources on the Internet for what TBBT is all about. Wikipedia or a simple Google search or a quick visit to the official site should do fine for a start. What it is to me however, is a brilliant show that combines geeks, nerds, comic books, sci-fi, technology, physics , science, and jokes together, and still be absolutely entertaining and humorous. In other words, much as what the Gay Liberation has done to reinvigorate gay pride, TBBT has reinvigorated the geek pride in me. The writers and producers are themselves geeks and nerds, watch Star Trek and Battlestar Galactica and read comic books. But they also treat the characters in the show with such respect that even if you’re not one of “them” (or in this case, one of “us”), you’d still find respect for them (or “us”). TBBT has I think, no doubt inspired many reluctant geeks and nerds, not just in America but across the globe where TBBT is being shown, to go out and be really proud to be geeks.

Without further ado, here are some of my favorite quotes from the first season:

From the season 1 Pilot episode:

Leonard: We need to widen our circle.
Sheldon: I have a very wide circle. I have 212 friends on myspace.
Leonard: Yes, and you’ve never met one of them.
Sheldon: That’s the beauty of it!

And yet another from the same episode:

Penny: I’m a Sagittarius, which probably tells you way more than you need to know.
Sheldon: Yes, it tells us that you participate in the mass cultural delusion that the sun’s apparent position relative to arbitrarily defined constellations at the time of your birth somehow affects your personality.
Penny: (puzzled) Participate in the what?

And another:

Sheldon: Okay, look, I think you have as much of a chance of having a sexual relationship with Penny as the Hubble telescope does of discovering that at the center of every black hole is a little man with a flashlight searching for a circuit breaker. Nevertheless, I do feel obligated to point out to you that she did not reject you. You did not ask her out.

another:

Leonard: (talking about him and Penny) Our children will be smart and beautiful.

Sheldon: Not to mention imaginary.

And from the succeeding episodes:

Sheldon: You have to check your messages, Leonard! Leaving a message is one-half of a social contract, which is completed by the checking of the message. If that contract breaks down, then all social contracts break down and we descend into anarchy.
Leonard: It must be hell inside your head.
Sheldon: At times.

Wolowitz: If it’s “creepy” to use the Internet, military satellites, and robot aircraft to find a house full of gorgeous young models so I can drop in on them unexpected, then FINE, I’m “creepy”.

😀

Ubuntu, Ubuntu 9.04 Jaunty Jackalope, MSI Wind netbook, and everything in between

April 30, 2009

I just downloaded Ubuntu 9.04 codename Jaunty Jackalope (let’s call it Jaunty for brevity’s sake). I’ve been very occupied the past few days with my morning and afternoon/evening work that’s why it took me this long to sit down and check out Jaunty.  And this post is a quick overview of what’s it like to experience Jaunty, specifically over my MSI Wind U100x.

Aesthetics

Jaunty looks much sleeker and more streamlined than previous Ubuntu incarnations, as shown by the loading splash image.

The login screen has also been revamped and kind of feels more like KDE (which isn’t bad in my opinion).

The geeky stuff

Jaunty gives you the option to install your system using the new ext filesystems, ext4. I tried it out and though I haven’t done any timing tests, the bootup from a clean install seems to be slightly faster. Of course, ext4 has been released for quite a while now and one more reason to use it other than it improves upon the performance of ext3 is that Ubuntu usually never releases/allows untested software (filesystems not the least of these) so you can be pretty sure ext4 is a safe bet. Plus, there’s support from Canonical.

I’m still plowing through Jaunty but the news is that ctrl+alt+backspace, used for restarting the X server, doesn’t work by default. To turn it on, edit your xorg.conf and add:

Option "DontZap" "false"

to the ‘ServerFlags’ section which you should also create/add. The result should look something like

Section "ServerFlags"
    Option         "DontZap" "false"
EndSection

and can also be quickly resolved via a quick Google search. If you want to turn off the restarting effect of ctrl+alt+backspace, then change ‘false’ to ‘true’. More info here.

The boys and girls at the MSI Wind forums have been talking about how Jaunty works in MSI wind. The MSI Wind wiki even has an entry for Jaunty found here, though I must say I didn’t really need much or even all of it to make everything run on my Wind. I’m also quite surprised that that wiki is pretty updated, last updated April 30 when I checked last. The webcam, wi-fi (which is quite surprising since it’s been plagued with problems since Hardy and Intrepid, the 2 previous Ubuntu releases before Jaunty) and others work after a fresh install. Of course for the web cam, you’d have to install a web cam softwaree like Cheese for example, which is readily available in the list of availabe software for download. No config whatsoever as written by the links I gave above. That hassle free setup is kind of scary (at least for me) since I usually like fiddling with my *nix box via the console, but then again nothing is really stopping me right?

Ubuntu 8.04.X (Hardy Heron) wi-fi on Wind

As for making wi-fi run on Hardy, I essentially followed what’s been written here in this part of the MSI Wind forum, particularly this section:

First, you need a proper build environment with the appropriate kernel headers. This is done fairly easily:

Code:
sudo apt-get install build-essential linux-headers-`uname -r`

Next, download and unpack the modified driver sources:

Code:
wget http://scopeboy.com/things/rtl8187se_linux_26.1012.0331.2008_modified.tar.gz
tar xvzf rtl8187se_linux_26.1012.0331.2008_modified.tar.gz

Now build them. Note that you’ll need to set an environment variable in order to avoid a certain problem:

Code:
cd rtl8187se_linux_26.1012.0331.2008
export KBUILD_NOPEDANTIC=1
./makedrv

Now, assuming everything compiled without errors, try starting it all up using the wlan0up script. This will insert the appropriate modules and enable the wireless device. You should then be able to use it with Ubuntu’s network manager.

Code:
sudo ./wlan0up

One other thing to note here is that the person who wrote the piece above was using 8.04.1, and not just 8.04, so it may not necessarily work for you. What you do is just download (from the same forums) the tar.gz driver appropriate for your Hardy version. I myself was using 8.04.2 so I used a .1016.0331 driver package instead of the .1012.0331 shown above. The you can install programs like wi-fi radar (to install it just run ‘apt-get install wifi-radar’) to scope out existing wifi networks around you.

The cool commandline tool I like using is iftop  (apt-get install iftop). The tool iftop shows you what networks/hosts/IP addresses you are connecting to or they to you. It also shows you all the traffic that goes your network card’s way. You run it via

    sudo iftop

which by default let’s you view your first NIC which is usually your wired connection so you do a

    sudo iftop -i wlan0

to view the traffic passing through your wireless card (just replace wlan0 with whatever the command ifconfig gives you as the device name for your wifi card). Then assuming you followed the steps above correctly and you didn’t encounter an error, you should be seeing arrows pointing to and from your IP address coupled with the download and upload speeds (in Bytes, KB or even MB depending on how fast your wireless connection is).

Verdict

So if you really want to stick with Ubuntu’s current LTS (i.e. Hardy) since it gets software updates till 2011, then try the trick above to make your wifi run. Otherwise if you don’t really mind updating your system every 12 months or so, then go for Jaunty. Look and feel and performance is topnotch. So far 🙂 But knowing Ubuntu’s history on software updates and support, plus the huge community and industry support/help you can get, it’s more than enough I think to make you switch from the ‘other’ popular operating system with 4 colors 🙂

Pretty Practicable PDF Tricks In Linux

March 23, 2009

I still don’t have quite a lot of time to write a more or less decent technology or philosophy or science/math related post, but I just want to put this on my blog for the sake of reference  again (as most, if not all, of my blog entries).

My Dilemma

I have a copy of a pdf file from which I want to share some parts only to my lab exercise partner (for reasons I can’t exactly divulge in the public Internet). So I Google around how to manipulate, specifically to  pluck/extract specific pages from a pdf file, and still output the extracted files as pdf file/s themselves. Then I found pdftk. Fantastic tool. Really.

Why Is It Fantastic?

Here are a few reasons why:

For such a small (more or less) package (3408kB in my Ubuntu 8.10 installation) you can:

Pdftk can join and split PDFs; pull single pages from a file; encrypt and decrypt PDF files; add, update, and export a PDF’s metadata; export bookmarks to a text file; add or remove attachments to a PDF; fix a damaged PDF; and fill out PDF forms. In short, there’s very little pdftk can’t do when it comes to working with PDFs.

Also,

Developer Sid Steward describes pdftk as the PDF equivalent of an “electronic staple remover, hole punch, binder, secret decoder ring, and X-ray glasses.”  Pdftk can join and split PDFs; pull single pages from a file; encrypt and decrypt PDF files; add, update, and export a PDF’s metadata; export bookmarks to a text file; add or remove attachments to a PDF; fix a damaged PDF; and fill out PDF forms.

Swiss army knife of PDF files anyone? And thankfully, it’s free and open source. The above quotes are from linux.com, and a lot of us know that once something gets posted on linux.com, it’s more or less worthwhile to learn, more so to read at the very least. pdftk is a command line tool (sorry, but check out my further references below).

And installing it is just simply

sudo apt-get install pdftk

in my Ubuntu 8.04 and 8.10 installations. Again, quoting from linux.com, here are some very useful (at least to me) things you can do with pdftk. Of course, with a bit of knowledge in scripting or programming (bash, php, python etc) you can work wonders with this tool:

Joining files

Pdftk’s ability to join two or more PDF files is on par with such specialized applications as pdfmeld and joinPDF (discussed in this article). The command syntax is simple:

pdftk file1.pdf file2.pdf cat output newFile.pdf

cat is short for concatenate — that is, link together, for those of us who speak plain English — and output tells pdftk to write the combined PDFs to a new file.

Pdftk doesn’t retain bookmarks, but it does keep hyperlinks to both destinations within the PDF and to external files or Web sites. Where some other applications point to the wrong destinations for hyperlinks, the links in PDFs combined using pdftk managed to hit each link target perfectly.

Splitting files

Splitting PDF files with pdftk was an interesting experience. The burst option breaks a PDF into multiple files — one file for each page:

pdftk user_guide.pdf burst

I don’t see the use of doing that, and with larger documents you wind up with a lot of files with names corresponding to their page numbers, like pg_0001 and pg_0013 — not very intuitive.

On the other hand, I found pdftk’s ability to remove specific pages from a PDF file to be useful. For example, to remove pages 10 to 25 from a PDF file, you’d type the following command:

pdftk myDocument.pdf cat 1-9 26-end output removedPages.pdf

Updated Man page

For all the geeks and geekettes out there (no this sub heading is not sexist), here’s an updated man page from my Ubuntu 8.10 server installation:

PDFTK(1)                                                                                                                          PDFTK(1)

NAME
pdftk – A handy tool for manipulating PDF

SYNOPSIS
pdftk <input PDF files | – | PROMPT>
[input_pw <input PDF owner passwords | PROMPT>]
[<operation> <operation arguments>]
[output <output filename | – | PROMPT>]
[encrypt_40bit | encrypt_128bit]
[allow <permissions>]
[owner_pw <owner password | PROMPT>]
[user_pw <user password | PROMPT>]
[flatten] [compress | uncompress]
[keep_first_id | keep_final_id] [drop_xfa]
[verbose] [dont_ask | do_ask]
Where:
<operation> may be empty, or:
[cat | attach_files | unpack_files | burst |
fill_form | background | stamp | generate_fdf
dump_data | dump_data_fields | update_info]

For Complete Help: pdftk –help

DESCRIPTION
If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses.
Pdftk is a simple tool for doing everyday things with PDF documents.  Use it to:

* Merge PDF Documents
* Split PDF Pages into a New Document
* Rotate PDF Documents or Pages
* Decrypt Input as Necessary (Password Required)
* Encrypt Output as Desired
* Fill PDF Forms with X/FDF Data and/or Flatten Forms
* Generate FDF Data Stencil from PDF Forms
* Apply a Background Watermark or a Foreground Stamp
* Report PDF Metrics such as Metadata and Bookmarks
* Update PDF Metadata
* Attach Files to PDF Pages or the PDF Document
* Unpack PDF Attachments
* Burst a PDF Document into Single Pages
* Uncompress and Re-Compress Page Streams
* Repair Corrupted PDF (Where Possible)

OPTIONS
A summary of options is included below.

–help, -h
Show summary of options.

<input PDF files | – | PROMPT>
A list of the input PDF files. If you plan to combine these PDFs (without using handles) then list files in  the  order  you
want  them  combined.  Use – to pass a single PDF into pdftk via stdin.  Input files can be associated with handles, where a
handle is a single, upper-case letter:

<input PDF handle>=<input PDF filename>

Handles are often omitted.  They are useful when specifying PDF passwords or page ranges, later.

For example: A=input1.pdf B=input2.pdf

[input_pw <input PDF owner passwords | PROMPT>]
Input PDF owner passwords, if necessary, are associated with files by using their handles:

<input PDF handle>=<input PDF file owner password>

If handles are not given, then passwords are associated with input files by order.

Most pdftk features require that encrypted input PDF are accompanied by the ~owner~ password. If the input PDF has no  owner
password,  then  the  user  password  must be given, instead.  If the input PDF has no passwords, then no password should be
given.

When running in do_ask mode, pdftk will prompt you for a password if the supplied password is incorrect or none was given.

[<operation> <operation arguments>]
If this optional argument is omitted, then pdftk runs in ’filter’ mode.  Filter mode takes only one PDF input and creates  a
new PDF after applying all of the output options, like encryption and compression.

Available operations are: cat, attach_files, unpack_files, burst, fill_form, background, stamp, dump_data, dump_data_fields,
generate_fdf, update_info. Some operations takes additional arguments, described below.

cat [<page ranges>]
Catenates pages from input PDFs to create a new PDF.  Page order in the new PDF is specified by the order  of  the  given
page ranges.  Page ranges are described like this:

<input PDF handle>[<begin page number>[-<end page number>[<qualifier>]]][<page rotation>]

Where  the  handle  identifies one of the input PDF files, and the beginning and ending page numbers are one-based refer‐
ences to pages in the PDF file, and the qualifier can be even or odd, and the page rotation can be N, S, E, W, L,  R,  or
D.

If the handle is omitted from the page range, then the pages are taken from the first input PDF.

The  even  qualifier  causes  pdftk  to  use only the even-numbered PDF pages, so 1-6even yields pages 2, 4 and 6 in that
order.  6-1even yields pages 6, 4 and 2 in that order.

The odd qualifier works similarly to the even.

The page rotation setting can cause pdftk to rotate pages and documents.  Each option sets the page rotation  as  follows
(in  degrees):  N:  0,  E: 90, S: 180, W: 270, L: -90, R: +90, D: +180. L, R, and D make relative adjustments to a page’s
rotation.

If no arguments are passed to cat, then pdftk combines all input PDFs in the order they were given to create the  output.

NOTES:
* <end page number> may be less than <begin page number>.
* The keyword end may be used to reference the final page of a document instead of a page number.
* Reference a single page by omitting the ending page number.
* The handle may be used alone to represent the entire PDF document, e.g., B1-end is the same as B.

Page Range Examples w/o Handles:
1-endE – rotate entire document 90 degrees
5 11 20
5-25oddW – take odd pages in range, rotate 90 degrees
6-1

Page Range Examples Using Handles:
Say A=in1.pdf B=in2.pdf, then:
A1-21
Bend-1odd
A72
A1-21 Beven A72
AW – rotate entire document 90 degrees
B
A2-30evenL – take the even pages from the range, remove 90 degrees from each page’s rotation
A A
AevenW AoddE
AW BW BD

attach_files <attachment filenames | PROMPT> [to_page <page number | PROMPT>]
Packs  arbitrary  files  into  a  PDF  using PDF’s file attachment features. More than one attachment may be listed after
attach_files. Attachments are added at the document level unless the optional to_page option is given, in which case  the
files are attached to the given page number (the first page is 1, the final page is end). For example:

pdftk in.pdf attach_files table1.html table2.html to_page 6 output out.pdf

unpack_files
Copies  all  of  the attachments from the input PDF into the current folder or to an output directory given after output.
For example:

pdftk report.pdf unpack_files output ~/atts/

or, interactively:

pdftk report.pdf unpack_files output PROMPT

burst  Splits a single, input PDF document into individual pages. Also creates a report named doc_data.txt which is the same  as
the  output  from dump_data.  If the output section is omitted, then PDF pages are named: pg_%04d.pdf, e.g.: pg_0001.pdf,
pg_0002.pdf, etc.  To name these pages yourself, supply a printf-styled format string via the output section.  For  exam‐
ple,  if  you  want  pages  named: page_01.pdf, page_02.pdf, etc., pass output page_%02d.pdf to pdftk.  Encryption can be
applied to the output by appending output options such as owner_pw, e.g.:

pdftk in.pdf burst owner_pw foopass

fill_form <FDF data filename | XFDF data filename | – | PROMPT>
Fills the single input PDF’s form fields with the data from an FDF file, XFDF file or  stdin.  Enter  the  data  filename
after fill_form, or use – to pass the data via stdin, like so:

pdftk form.pdf fill_form data.fdf output form.filled.pdf

After  filling  a  form, the form fields remain interactive unless you also use the flatten output option. flatten merges
the form fields with the PDF pages. You can use flatten alone, too, but only on a single PDF:

pdftk form.pdf fill_form data.fdf output out.pdf flatten

or:

pdftk form.filled.pdf output out.pdf flatten

If the input FDF file includes Rich Text formatted data in addition to plain text, then the Rich Text data is packed into
the form fields as well as the plain text.  Pdftk also sets a flag that cues Acrobat/Reader to generate new field appear‐
ances based on the Rich Text data.  That way, when the user opens the PDF, the viewer will create the Rich Text fields on
the  spot.   If the user’s PDF viewer does not support Rich Text, then the user will see the plain text data instead.  If
you flatten this form before Acrobat has a chance to create (and save) new field appearances, then the plain  text  field
data is what you’ll see.

background <background PDF filename | – | PROMPT>
Applies  a  PDF  watermark  to the background of a single input PDF.  Pass the background PDF’s filename after background
like so:

pdftk in.pdf background back.pdf output out.pdf

Pdftk uses only the first page from the background PDF and applies it to every page of  the  input  PDF.   This  page  is
scaled and rotated as needed to fit the input page.  You can use – to pass a background PDF into pdftk via stdin.

If  the input PDF does not have a transparent background (such as a PDF created from page scans) then the resulting back‐
ground won’t be visible — use the stamp feature instead.

stamp <stamp PDF filename | – | PROMPT>
This behaves just like the background feature except it overlays the stamp PDF page on top of the  input  PDF  document’s
pages.  This works best if the stamp PDF page has a transparent background.

dump_data
Reads  a  single, input PDF file and reports various statistics, metadata, bookmarks (a/k/a outlines), and page labels to
the given output filename or (if no output is given) to stdout.  Does not create a new PDF.

dump_data_fields
Reads a single, input PDF file and reports form field statistics to the given output filename or (if no output is  given)
to stdout.  Does not create a new PDF.

generate_fdf
Reads  a single, input PDF file and generates a FDF file suitable for fill_form out of it to the given output filename or
(if no output is given) to stdout.  Does not create a new PDF.

update_info <info data filename | – | PROMPT>
Changes the metadata stored in a single PDF’s Info dictionary to match the input data file. The input data file uses  the
same  syntax  as  the  output from dump_data. This does not change the metadata stored in the PDF’s XMP stream, if it has
one. For example:

pdftk in.pdf update_info in.info output out.pdf

[output <output filename | – | PROMPT>]
The output PDF filename may not be set to the name of an input filename.  Use  –  to  output  to  stdout.   When  using  the
dump_data  operation,  use output to set the name of the output data file. When using the unpack_files operation, use output
to set the name of an output directory.  When using the burst operation, you can use output to  control  the  resulting  PDF
page filenames (described above).

[encrypt_40bit | encrypt_128bit]
If an output PDF user or owner password is given, output PDF encryption strength defaults to 128 bits.  This can be overrid‐
den by specifying encrypt_40bit.

[allow <permissions>]
Permissions are applied to the output PDF only if an encryption strength is specified or an owner or user password is given.
If permissions are not specified, they default to ’none,’ which means all of the following features are disabled.

The permissions section may include one or more of the following features:

Printing
Top Quality Printing

DegradedPrinting
Lower Quality Printing

ModifyContents
Also allows Assembly

Assembly

CopyContents
Also allows ScreenReaders

ScreenReaders

ModifyAnnotations
Also allows FillIn

FillIn

AllFeatures
Allows the user to perform all of the above, and top quality printing.

[owner_pw <owner password | PROMPT>]

[user_pw <user password | PROMPT>]
If  an  encryption  strength  is  given but no passwords are supplied, then the owner and user passwords remain empty, which
means that the resulting PDF may be opened and its security parameters altered by anybody.

[compress | uncompress]
These are only useful when you want to edit PDF code in a text editor like vim or emacs.  Remove PDF page stream compression
by applying the uncompress filter. Use the compress filter to restore compression.

[flatten]
Use  this  option  to merge an input PDF’s interactive form fields (and their data) with the PDF’s pages. Only one input PDF
may be given. Sometimes used with the fill_form operation.

[keep_first_id | keep_final_id]
When combining pages from multiple PDFs, use one of these options to copy the document ID from either  the  first  or  final
input  document  into the new output PDF. Otherwise pdftk creates a new document ID for the output PDF. When no operation is
given, pdftk always uses the ID from the (single) input PDF.

[drop_xfa]
If your input PDF is a form created using Acrobat 7 or Adobe Designer, then it probably has XFA data.  Filling such  a  form
using  pdftk  yields  a PDF with data that fails to display in Acrobat 7 (and 6?).  The workaround solution is to remove the
form’s XFA data, either before you fill the form using pdftk or at the time you fill the  form.  Using  this  option  causes
pdftk to omit the XFA data from the output PDF form.

This  option  is  only  useful  when  running pdftk on a single input PDF.  When assembling a PDF from multiple inputs using
pdftk, any XFA data in the input is automatically omitted.

[verbose]
By default, pdftk runs quietly. Append verbose to the end and it will speak up.

[dont_ask | do_ask]
Depending on the compile-time settings (see ASK_ABOUT_WARNINGS), pdftk might prompt you for further input when it encounters
a  problem, such as a bad password. Override this default behavior by adding dont_ask (so pdftk won’t ask you what to do) or
do_ask (so pdftk will ask you what to do).

When running in dont_ask mode, pdftk will over-write files with its output without notice.

EXAMPLES
Decrypt a PDF
pdftk secured.pdf input_pw foopass output unsecured.pdf

Encrypt a PDF using 128-bit strength (the default), withhold all permissions (the default)
pdftk 1.pdf output 1.128.pdf owner_pw foopass

Same as above, except password ’baz’ must also be used to open output PDF
pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz

Same as above, except printing is allowed (once the PDF is open)
pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz allow printing

Join in1.pdf and in2.pdf into a new PDF, out1.pdf
pdftk in1.pdf in2.pdf cat output out1.pdf
or (using handles):
pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf
or (using wildcards):
pdftk *.pdf cat output combined.pdf

Remove ’page 13’ from in1.pdf to create out1.pdf
pdftk in.pdf cat 1-12 14-end output out1.pdf
or:
pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

Apply 40-bit encryption to output, revoking all permissions (the default). Set the owner PW to ’foopass’.
pdftk 1.pdf 2.pdf cat output 3.pdf encrypt_40bit owner_pw foopass

Join two files, one of which requires the password ’foopass’. The output is not encrypted.
pdftk A=secured.pdf 2.pdf input_pw A=foopass cat output 3.pdf

Uncompress PDF page streams for editing the PDF in a text editor (e.g., vim, emacs)
pdftk doc.pdf output doc.unc.pdf uncompress

Repair a PDF’s corrupted XREF table and stream lengths, if possible
pdftk broken.pdf output fixed.pdf

Burst a single PDF document into pages and dump its data to doc_data.txt
pdftk in.pdf burst

Burst a single PDF document into encrypted pages. Allow low-quality printing
pdftk in.pdf burst owner_pw foopass allow DegradedPrinting

Write a report on PDF document metadata and bookmarks to report.txt
pdftk in.pdf dump_data output report.txt

Rotate the first PDF page to 90 degrees clockwise
pdftk in.pdf cat 1E 2-end output out.pdf

Rotate an entire PDF document to 180 degrees
pdftk in.pdf cat 1-endS output out.pdf

NOTES
pdftk uses a slightly modified iText Java library (http://itextpdf.sourceforge.net/) to read and write  PDF.  The  author  compiled
this Java library using GCJ (http://gcc.gnu.org) so it could be linked with a front end written in C++.

The pdftk home page is http://www.accesspdf.com/pdftk/.

AUTHOR
Sid Steward (ssteward@accesspdf.com) maintains pdftk.

September 18, 2006                                                    PDFTK(1)

Comments, questions, and suggestions are always welcome as long as they’re calm and ruly 🙂

Further References

>>linux.com reference article

>>Main site for pdftk (including manual/documentation), a bit dated though

>> GUI for pdftk