Categories
Looking glass
Navigate/Search

Archive for the 'software' Category

Ack!

Saturday, October 4th, 2008

_   /|
\'o.O'
=(___)=
   U    ack!

find . -name “*.some_ext” | xargs grep ’some_pattern’

Man does this not age very well when you do it al lot. Yeah yeah, you’re a smart-ass and you can write a shell script and make that easier. But what if there was a tool you could use to do it smartly? With highlighting and a slew of other features? Enter ack.

I’ve been ignoring my homies on #pso with a stupid kind of ‘i got fingers and i can type’ smugness. So wrong was I. His name is Bill, he’s my new friend.

Rails: to_prepare executing code before each request

Friday, August 22nd, 2008

I have found little or no documentation on this on the net, so here I’m trying to give back a little from what I learnt. Hopefully that will be the beginning of a solution for others.

Rails version: 2.1.0

The problem:

I have certain ActiveRecord models that I want to monkeypatch (i.e. inject functionality to an existing class on runtime). That’s the beauty of dynamic languages, poor Java sods, no need for an AbstractFactoryFactory for j00!

My first approach was to write a script in ./config/initializers that would be invoked on initialization. However, as it turns out, while this works fine for an immediate use of the said monkeypatched object, this wouldn’t work for later instances of this class. In my case, an ActionController method, when calling one of the monkeypatched functionality would raise a NoMethodException.

It took me a bit to realize what was going on and how rails was actually running through its initialization process.

The solution:

Rail’s initialization code has a method called to_prepare which can be invoked in the initialization block. Now looking at the rails source code for initialization, the method requires dispatcher which loads ActionController::Dispatcher and invokes the method to_prepare. Bingo!

What to do next is simple. In my script found in ./config/initializers, the only change i needed to do is to require 'dispatcher' and to monkeypatch as follows:

Done. Profit.

Introducing Fotofolio

Tuesday, May 15th, 2007

Instead of reading programming.reddit, dreaming up topics and posting articles on my blog, I have instead opted to work on a CMS for my sweetheart Kristel, both to serve as her online portfolio and to be a fun small project for me to code.

Rationale

The reason why I decided to code a CMS from the ground up is obviously because there aren’t enough CMS’s in the world; who really cares about Joomla!, Drupal, Plone, Alfresco and Ion? Some even have the magic word “enterprise” thrown in there somewhere. CMS, ERP, CRM, MRP… for free?? Pffscht, let’s make another one of those 3 letter acronym software.

Kevin Barnes at Codecraft gives 3 reasons to reinvent the wheel. My personal favourite: reinventing the wheel causes reinventors to understand wheels. Additionally, having a custom made CRM out of love is unbeatable. For me, this application is an opportunity to learn a thing or two, have fun and do other things like working too hard at the office.

Fotofolio

Fotofolio is the name given to my CRM. The focus of this application is to provide designers with a simple solution to obtaining a online portfolio. As the name suggests, there is a heavy emphasis on displaying images and the application allows for much of that.

The interface and features are sparse, both to make it a straightforward and easy to use web application. A user has the ability to create and manage multiple worksets. Each workset can consist of multiple workpieces and each workpiece has an associated image. The published portion of the web application will allow the user to organize the layout according to these conceptual rules.

Technology

I decided to implement Fotofolio using Ruby On Rails. After flirting with the framework quite a bit, it was obvious that all that hype surrounding it is not unwarranted. Other candidates were Django, Turbogears and even Spring. In my opinion, for the scope of my application, only Django stood a chance. However, Rails still won out, whatever you may say, Pythonistas. Migrations rule!

Release

The first release is planned for soon, soon after Kristel’s portfolio is delivered. I do not plan to have features such as skin packs available right away. So far, the bare minimum of features is expected; i.e. putting some pictures in, displaying them on the other side. It is currently 65-70% complete.
It is expected to be an executable pile of source code rather than being an online service, and it will be open source. The license has yet to be determined.

Request

I admit that I’m a bit of a doosie with making up names. I need advice from you 3 people reading my blog about another name to give to this baby. Please let me know of any suggestions you may have.

Ubuntu 6.10 Edgy Eft Upgrade plus Compiz goodness on AIGLX

Saturday, October 28th, 2006

Geeks with not much to say talk about their tools. Here’s an eft:

Today, I talk about my experience upgrading the FREE Linux distribution Ubuntu from 6.06 LTS (Dapper Drake) to 6.10 (Edgy Eft). The leap (check this link out if you’re geeky like me) from 6.06 to 6.10 was hyped up to bring lotsa “cutting edge” updates to the distribution. This release happened on time, according to the schedule, on October 26th, unlike Fedora Core 6 which slipped a couple of times. So, hats off Canonical!

In any case, these distributions are maintained by volunteers and/or very little actual paid staff (probably paid peanuts… its about the passion man). Good stuff, somebody should hire them (or not, otherwise we wouldn’t have anybody to do the distro’s!).

Amongst the touted updates are Firefox 2.0, Xorg 7.1 (featuring AIGLX), Gnome 2.16.1, KDE 3.5.5 only to cite some. Pretty spiffy, isn’t it?

Well, apparently on the Internet, people have having trouble upgrading. I had the exact same problem people have described and I’m going to describe steps to take to resolve them.

Killing 2 birds with 1 stone, I’ll explain as well how to get you some Compiz eye-candy. Actually, Compiz is not just eye-candy; in addition to giving you a 3D accelerated desktop interface with wobbling windows (it sounds weird, but looks pretty cool) and other desktop effects, it is also very useful with regards to usability. It supports a bunch of neat features; here’s an expose copycat for instance:

Upgrade problems

Symptom:
1. You just upgraded Ubuntu 6.06 LTS by running

gksudo “update-manager -c -d”

2. You curse yourself because you left this running overnight without realizing you’d actually need to click a few times before everything is installed and set up.

3. You are greeted with the new “high-res” 1280×1024 splash screen, with the new web-2.0-ized Ubuntu logo.

4. Your X server does not want to start.

Cure:

Have you read the README’s and whatnot when you were installing video drivers? I’m not sure about Nvidia drivers, but FGLRX, ATI’s (or should I say ATI/AMD. The red has been replaced by an ugly green… isn’t green Nvidia’s colour?) proprietary drivers have certain dependencies on the current kernel version you have installed.

First, you need to remove anything that’s related to those drivers. If you’re using FGLRX, especially if you made your own .deb packages then installed them, you’re gonna have to remove them.

Reboot, go in recovery mode and run:

dpkg -r xorg-driver-fglrx fglrx-control

Note that if you made .deb packages the package names might be a bit different.

Now if you have 2 choices, either to install the latest version of FGLRX or use the open source drivers. I recommend the second option because you’ll gain AIGLX support which will allow you to get some Compiz or Beryl goodness.

For option 1, simply do:

apt-get install fglrx fglrx-control

To use the open source drivers with 3D rendering, you need to re-install the openGL libraries. Do:

apt-get install –reinstall libgl1-mesa

I highly recommend this guide, which I find can be really useful.

Getting Some Eye-Poppin’ Candy

Rotating cube

Now that you’ve installed/re-installed the open source drivers (or beta drivers if you’re an Nvidiot), head over to gandalfn’s Compiz-AIGLX-on-Edgy page for guidance. And follow the instructions.

Fudge around with your /etc/X11/xorg.conf and after multiple edit/restart X server/reboot cycles, you’ll get it up and running. If you’re that far, I don’t think you’ll need any guidance… trust me =) You would’ve abandoned long ago.

Congratulations! You’re running Ubuntu 6.10 with Compiz on AIGLX!

Here are things to ponder before upgrading:

  1. Its gonna take you some time.
  2. You’re going to have to mess with your xorg.conf, which can be some pretty messy affair if you don’t know what you’re doing.
  3. Dual monitor support? Fuhgetdhaboutit! X-server is pretty anal about dual monitor setups, at least for ATI people. FGLRX made that a little bit easier, with BigDesktop support and all… but with open source drivers you’re quite at a loss.

In any case, for people trying to get a good dual monitor setup with at least 1 CRT (running non eye-bleeding refresh rates), with X-server 7.1, open-source ATI drivers and Compiz, I pity thy fool! If you’re successful, I’d be interested in getting your xorg.conf! I gave up the 2nd monitor for now as well as the Logitech G5 buttons & tilt wheel.
Here’s mine: xorg.conf

Nvidia using people I heard over the forums have an easier time with a pretty nifty configuration utility. Oh I envy you. I threw away days of my life cumulatively, setting this up!
Have fun and good luck!

Internet in the 21st Century

Wednesday, October 18th, 2006

Today I swung by my alma mater to attend a lecture hosted by Vint Cerf, without whom we wouldn’t be surfing the Internet today, entitled “Internet in the 21st Century“. An illustrious figure indeed, and very well spoken as well, Vint is currently the Chief Internet Evangelist and vice president over at Google. A title like that is wicked cool I reckon… evangelising the Internet…

The father of the internet evangelising

With such a prestigious speaker, the room was obviously packed; a computer science junkie gala of sorts. Notably, amongst the crowd was Steve Bourne, whom I shook hands with without realizing it was THE Steve Bourne. Phew, what an honor. In any case, the topic of the day was about the Internet and what better person to talk about it other than the man dubbed “the father of the internet”?

Computer Science?

As one of the first topics, Vint brought up a series of points in view of “uncovering the science in Computer Science”. I found this to be rather amusing, because after taking a few psychology & phsyics courses in university, I was also wondering where the “science” in CS came from! A “science” gets its name from the application of the scientific method; i.e. the best way to establish that something is a fact is by predicting a result through a hypothesis, and proving it by a defined and consistently repeatable procedure. Computer Science (CS), on the other hand encompasses more than the factual and predictable data; in CS, one of the things we learn is how to prove that we cannot predict that a computer program will halt. Ironic indeed! Like mathematics, CS is largely dependent on proofs rather than empirical evidence.

The design of the Internet

The next topic was about the historics of the Internet. Vint explained good software engineering decisions taken in the beginning, such as the layered design and low coupling between those layers was at the base of TCP/IP. Such thoughts burgeoned while working on the ARPANET. He also went over the ignorant nature of packets, which I have mentioned in a previous post presumptiously called “The unified theory… of bits and bytes over the internet & law” (written under the influence I must admit!). As he went on talking about the profound impact upon regulations, and how current ones aren’t very well prepared for the current EXPLOSION (purportedly a factor of 20 from 1997!) of internet use; I could sense a tint of network neutrality hippiness (yes hippiness). Very nice indeed to hear first hand such an important figure speaking out on this topic.

The next topics were about the shortcomings and downfalls of the initial design; such as security, mobility and persistence. Mobile IP’s, authentication, encryption, sensor networks and other solutions (or rather stand-ins before solid solutions are implemented) were discussed. An interesting observation on his part is that most security problems are a matter of configuration; as there is no way to verify configurations. A very tough problem indeed, in view of our current quasi-total dependence on configuration.

The state of the Internet nowadays (without buzz words)

Somebody explained Web 2.0 without using the buzz word! Hurray! Rather, he used the catch-all term “User Oriented Paradigms”, composed of the notions of:

  1. Self Service
  2. Announce-Share, Collaborate
  3. Search, discover, transact

Vint explained the premises of Google Adsense as well (without mentioning the name of it), explaining that the democratization of the Internet makes contextual advertising even more powerful. Taking another stab at network neutrality, he went on to say that Amazon, Google, eBay amongst others could never have started without that basic premise of network neutrality. He reiterated the observation that the new Internet is on the verge of significantly altering anything from regulations to social behavior and evidently business.

On another topic, Vint explained that these shenanigans are changing information management significantly. Geolocational indexing is becoming more and more in demand and time indexing is becoming harder to achieve. He postulates that information decay may be akin to tooth decay; i.e. requiring some brushing everyday.

Things to be (In managementese: Moving forward)

About the future of science & engineering in general, he predicts that a boom in interest, similar to the Sputnik chain of events, is looming, having as primary vehicle global warming. Interesting problems will need to be solved and predicted, causing a hypothetical raise in interest in Computer Science. Since the dot-crash enrollment in this field is at a low, and keeps dipping.

The future of the Internet lies in space. A project called InterPlaNet (IPN) is in the works to attempt to solve the problems of communication over astronomical (literally!) distances. Because of the huge delays, variations of distance and signal strength, TCP/IP does not hold up very well in those applications. Fortunately, due to the layered architecture, TCP/IP can be used in smaller scales and another layer can be used to handle inter planetary communications, using a mechanism similar to messaging. This is being tested in environments with similar constraints, such as in the military, and in Sameland. Interestingly, this attempts solves the mobility and persistence problems cited before as well as solving the latency issues.

Epilogue

In the end, my opinion is that this lecture was very entertaining. It was quite an honor to hear THE man talk, in the company of other distinguished computer scientists. Thanks Elliot (our head honcho @ Tucows) for introducing Glenn (my co-worker) and myself to both Vint and Steve. Others, be there next time!