Archive for the ‘tech’ 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. 🙂

Find files before/after/in between specific dates

February 14, 2011

Hello folks. \\//,

Well here I am, reading a technical research paper on membrane computing and Petri nets when I decided to download some of the reference materials, conference/journal technical papers, of the paper I’m currently reading.  So I download the reference materials from IEEE Xplore, plus other non-reference materials but still related to the topic I’m reading.

Eventually, I download around 10 PDF files, with filenames made up of purely integers and of course the .pdf extension. Problem is, I’m too lazy (not that much really, I just don’t want to keep doing this manually over and over) to specify each PDF filename, then add them to a compressed archive (this case a RAR file) and then send them to another machine or person or account of mine for archiving.  Essentially, I just want that: to get those PDF files I recently downloaded for this specific topic I’m currently in, not include other PDF files in the same directory, and then compress them into a single RAR file.

How to go over doing this?

Luckily there are for loops and the nifty find command in *nixes like my Ubuntu box. 🙂 So what I simply do is

for i in `find . -type f -cnewer startdate ! -cnewer enddate`; do rar a myrarfile.rar $i; done

which means given 2 reference points, files startdate and enddate, I loop over all files in between the modification times of these two files and then add them to the RAR file myrarfile.rar.

Presto. Problem solved, learned something new. Now, back to reading research papers. 🙂

\\//,

Reference/s:

http://unixhelp.ed.ac.uk/CGI/man-cgi?find

SVN over HTTP

January 31, 2011

Hello there true believers, been a while since I’ve written something here.


A quick FYI on those wanting to use SVN but are restricted to use it from within a network with a proxy.
If you try using SVN over HTTP, it most likely won’t work by default since SVN uses a different network port (usually 3690 for *nixes) and HTTP proxies by default use 80 or 8080 as their ports.
If you try checking out or updating or committing to/from an SVN repo by default, you’ll run into a problem saying SVN couldn’t connect. Uh oh spaghetti-oh. 🙂
In my Ubuntu 10.04 machine, what I do is open (with sudo/root properties) the file:

/etc/subversion/servers

and uncomment (or add, if the following are not present) these parameters:

http-proxy-host = yourproxy.com
http-proxy-port = port

e.g.

http-proxy-host = 10.10.10.10
http-proxy-port = 8080

I save the file, then try SVN again. Voila. I’m back to coding again. 🙂

Reference/s:

Virtualbox shared folder access: Mac OS X host with Ubuntu 10.04 as guest

November 13, 2010

Whew. It’s been a while since I’ve done anything here. 🙂 Now time to do some geeky blogging (and so much more soon) once again mis amigos y amigas. 🙂

Tech specs of the setup

(Host)

Mac OS X Version 10.5.8

$uname -a

Darwin theorylabs-P-System-iMac.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

VirtualBox (non-OSE version, but still free) Version 3.2.10 r66523

(Guest)

Ubuntu Lucid Lynx 10.04 32bit

Setting it up

Essentially just add a shared folder using VirtualBox, whether a VM is running or not. In the guest OS, create a directory where you want your host OS’s files to be mounted (with R or R/W permissions).

Then in the guest OS make sure that the guest additions are successfully installed already. This step is easily and quickly done by mounting the ISO into the guest OS, then allowing Ubuntu 10.04 to detect an autorun script. It will warn you that the running of certain scripts can pose a threat to your system, so we go ahead knowing that the ISO is from Oracle. Otherwise, you can run the script by double-clicking on it or using a terminal.

Once the guest additions have been successfully installed, the following command should mount the host OS’s folder onto the newly created folder in the guest OS which we just created from above:

sudo mount -t vboxsf virtualbox_shared_folder_name guest_os_directory_path

Where virtualbox_shared_folder_name is the name of your host OS’s folder which you entered in the VirtualBox shared folder setting, which may not necessarily be the real directory name of the directory you want to share from your Mac OS X.  guest_os_directory_path is the newly created folder from above awhile ago.

A note on the virtualbox forums, several users say that changing one’s directory in the guest OS to / (root directory of the filesystem) helps, although this wasn’t the case for me.

Hope that helps ladies and gents. Questions are very much welcome. 🙂

Reference/s:

Short review on ‘The Big Bang Theory’ episode ‘The Einstein Approximation’

February 3, 2010

Warning: For those who haven’t seen this episode, spoiler alert!

This is the first, and hopefully won’t be the last, of a series of short reviews I’ll try doing each week for ‘The Big Bang Theory’.

This week The Big Bang Theory (TBBT) episode ‘The Einstein Approximation’ came out,  and is the 14th episode of the show’s 3rd season.
Let me just start this quick and short review of the episode by further stating what the guys there and I have in common, apart from the quite obvious facts that we’re all geeks/nerds by heart.
Even before TBBT, I’ve admired and idolized Einstein myself, because of his great mental feats (which were of course, backed up by other physical theories and experiments at his time). Great because by just the power of his mind Einstein was able to revolutionize our lives and the 20th century, paving ways for faster transportation, not to mention telecommunication and computing, which drove and is still driving the information revolution today. And of course, so much more benefits which we more or less take for granted in our daily lives. In fact, Einstein is oftentimes synonymous with the word ‘genius’.
Einstein was also very much interested in philosophy and politics, not just physics. He’s written several books, articles, letters to people outside the scientific community. He also has a quirky sense of humor, as seen from this  picture of him. At first I thought this photo of Einstein was edited. But as it turns out it was really him, tongue hanging out and all. 🙂 It was at the time he was making fun of people taking pictures of him. Great stuff.

Silly Einstein
Of course Einstein is not without criticisms. Great and accomplished a scientist he maybe, history tells us he left much to be desired when it came to being a father or a husband.

Now, back to the episode review of TBBT. At this point I shall establish a partially objective, partially subjective point system of each episode based on the earlier 2 seasons (which I have watched at least 2 times…).
Let me just start off by saying this is a classic Sheldon episode, which is great in itself. Again we expected lots of ‘weird’ humor: Sheldon’s ability to complicate relatively simple things, as well as him belittling his friends, most noticeably Penny. Hilarious stuff once again. Bravo to TBBT production team.
Not a lot of scifi or comic book references were made though. But lines such as:

Howard: How long has he been stuck? (referring to Sheldon)
Leonard: Umm…intellectually about 30 hours, emotionally about 29 years.

And

Howard: Have you tried rebooting him? (referring to Sheldon)
Leonard: No I think it’s a firmware problem.

Are classics. 🙂

The part where Leonard and Sheldon were arguing inside the ‘ball play room’, with Sheldon going ‘bazinga’ everytime, was also hilarious.

Sheldon, and of course the rest of ‘the guys’ are fans of Einstein no doubt. Sheldon of course thinks he’s at the same level with Einstein so he tries to do what Einstein did in order to come at the epiphany that is the special theory of relativity: to work for a menial job so he can occupy his basal ganglia with a routine task so he can apparently free his pre-frontal cortex to solve his physics problem.

Another classic moment in this episode is the guest starring of Yeardley Smith, the not so well known voice actor behind the famous cartoon character Lisa Simpson (yes, in The Simpsons fame). Absolutely entertaining piece of the episode.

Another classic dialog is again with Sheldon and Penny:

Penny: What are you doing here?
Sheldon: A reasonable question. I asked myself, what is the most mind-numbing, pedestrian job conceivable? And 3 answers came to mind: toll booth attendant, an Apple Store “Genius”, and “What Penny does”. Now, since I don’t like touching other people’s coins, and I refuse to contribute to the devaluation of the word “genius”, here I am (meaning at the cheesecake factory).

Lines like these make me think of the real meaning and application of LOL. 🙂

I suppose myself and those guys, as well as the show’s production team, can’t help cracking jokes at Apple. 😀

Overall I’d give this episode the following scores:

* reference to sci-fi, comic books, and other geek/nerd pop culture: 6/10

* reference to physics and other fields of science: 9/10

* dialog humor factor: 9/10

* techie/technology factor: 8/10

which gives an overall score of: 8/10

🙂

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

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

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”.

😀