Pusssh!

April 15th, 2009 § 0

No, the title makes no reference to labour and I hope you’re not reading this while you’re in labour, if you are though, please leave a comment, fact that even women in labour read my blog will look awfully good on my resume!

Anyway, the title refers to an analogy that I came across in Ready, Fire, Aim.

Getting a business (or new product) started is like moving a stopped train. It takes a lot of energy to break it free from its stationary physics, but once it is put in motion it accelerates with relative ease.

Keep this metaphor in mind when you begin your entrepreneurial venture. Imagine your challenge as an immense train, sitting dead still on a set of shiny new tracks that lead directly–and with a slight downward slope–to a Golden City. That city is waiting to welcome you as its newest citizen and shower you with its golden benefits.

You just have to get it moving.

Shiny train track.

Shiny train track.

As for my train, GizmoBooks, it’s moving very slowly. One user registration here, one there and pretty soon will be moving full speed, إن شاء الل (God Willing).

Update: I’m getting way too many spam comments from this post for some reason. Therefore, disabling comments just for this post.

  • Share/Bookmark

GizmoBooks.com – The Textbook Revolution

April 2nd, 2009 § 0

I started attending the University of Lethbridge in September 2004. In my first year I took some courses, and I only managed to find one used textbook–by luck–in the bulletin boards.

Can’t find textbooks!

After that first semester, I haven’t really been able to find cheap, or used textbooks. The reason is that the bulletin boards are chaotic at best and ‘searching’ for information in them is, well, madness.

Covered up

Covered up

Textbook Revolution?!!!

That’s right, textbook revolution :) . So, after sitting and doing absolutely nothing about this issue (except for complain about book prices), I decided to do something about it.

I was taking a database class and it had a project component. I proposed the idea of a book exchange site to the professor and he seemed to like it. For the next couple of months I went to work creating mockups and then the back end and of course, what’s a site without animation these days–who wants to look amateur!

The deadline came looming and the site, well, wasn’t where I wanted it to be, therefore I only got 13/15 on the project. Not to worry as I wasn’t really doing this for the class…the marks were a bonus! I kept working and working and on January 08, 2009, I release the first ‘version’ of the site which became ulethbooks.ca.

After introducing this idea to the university community and friends, feedback was phenomenal and it got me excited! Then I went working on GizmoBooks.comThe Textbook Revolution! I wanted to have this easy to use site accessable to students across North America and, although not sure about the concept, even outside North America!

Anyway, that’s my little story of how The Textbook Revolution :) came to be and I would love to hear from you with your ideas, feedback and comments.

Until next post!

Compete with that!

Compete with that!

  • Share/Bookmark

Reusable Apps in Django

March 14th, 2009 § 0

I just finished listening (actually still not finished but just watching the question period :) ) to this DjangoCon talk by James Bennet. Found it very motivating and useful. There are a lot of apps out there! Before you start to write some feature for a django site, ensure that you’re not rewriting something that someone already wrote. Here are a few site to look at:

  • Share/Bookmark

13 sentences for startups, and my reflections

February 27th, 2009 § 1

In the Name of God, Most Gracious, Most Merciful.

Although it looks like something designed by a high school student in ’99, Startups in 13 sentences has some great advise for new startups. Here are the 13 sentences:

1. Pick good cofounders.

Because this is so hard to do, no matter how good of a friend you have, I’ve avoided doing this at all. I’d rather go at it alone then face something really disastrous to the business. Not to mentioned, I’m not keen on sharing profits and control :) .

2. Launch fast.
3. Let your idea evolve.
4. Understand your users.

Excellent points, nothing to add.

5. Better to make a few users love you than a lot ambivalent.
…Initially you have to choose between satisfying all the needs of a subset of potential users, or satisfying a subset of the needs of all potential users….

I think if you do focus on meeting all the needs of a subset of potential users, you will naturally meet a subset of the needs of all potential users, in most cases. I think Apple focuses a lot of their energy and resources on this. The non-expert users of OS X, for example get most of what they want in it, although the expert users wish they had more control.

6. Offer surprisingly good customer service.
7. You make what you measure.
8. Spend little.

Excellent advise, emphasized time and time again by people who have been there and done that.

9. Get ramen profitable.

This is what I seek the most. Once your leash is a little long and you no longer need to work to support yourself you can go all out and focus all your energy and resources in making something great.

10. Avoid distractions.
11. Don’t get demoralized.
12. Don’t give up.

I need to pay heed to these, for sure. Having friends and possibly associates that support you and believe in you will help you a great deal in 11 and 12. However, they might become a distraction if not managed well :D .

13. Deals fall through.

So, deal with it!

  • Share/Bookmark

ulethbooks.ca – textbook revolution is LIVE

January 8th, 2009 § 5

Another all-nighter dedicated to it and it’s finally here–ulethbooks.ca.

As I kept working on it, features kept creeping in (and some out). This was interesting to see as we tend to blame our bosses or clients for feature creep. Here I had no one to blame except myself. So what did I decide to do about it? Just make it “good enough”.

Over the coming weeks there will more work done on this.

In an effort to market this, I also created a facebook group. Feel free to join.

Anyway, I should head to sleep as I’m rambling all over the place here. Perhaps I’ll write a more cohesive post some time this week.

  • Share/Bookmark

The Beauty of Object Relational Mapping

December 30th, 2008 § 5

I wanted to blog about this issue a while ago, however I didn’t get a chance until now, thanks to Dreamhost. You see, I rely on subversion (hosted on my dreamhost account) for my revision control and my repositories are unaccessible for the second time in 9 days! With the exception of this latest issue I’ve been happy with dreamhost. Update: they fixed this issue about 16 hours after I contacted them.

The Problem

Now, getting back (or starting) on topic. A long time ago (dinosaurs used to roam the streets then) I was faced with the issue of designing Object Oriented Code (OOC, hmm haven’t seen that acronym before. Yeah, I just made it up on the spot :) . Yah, I’m that good). Normally we’re taught that in OOP the classes you create should represent (or go as close to it as possible) real world objects (containing information in fields and defining possible action in the methods). For example, a car class could have model, manufacturer, and owner as fields and driveTo(…) as a method. This is all fine and dandy for little school assignments where your objects are all created in the code and nothing is stored on databases or even flat files. However as soon as you start thinking about using a database a problem arises. When an object is created and manipulated and all that fun stuff, it needs to live somewhere after the program stops executing (can’t live on RAM, obviously) so a database is often needed to store the existing objects. In other words these fields (or the state of an object needs to be stored in a database). So, long ago, I was working on a project and needed to represent members (of a website). I had come up with the database and fields for my class (see Figure 1).

Figure 1 - Representation of my class and the DB table of it

Figure 1 - Representation of my class and the database table for it. Don't pick on my UML diagram as I still don't know how to properly make one. I make them so I understand them, just like my code :)

The table columns simply mirrored the fields of my member class and there were methods to retrieve member information such as getAge(), etc. and I could nicely do this (PHP):

$newMember = new member(5)
echo $newMember->getAge()

Now that looks okay, except for one problem. Problem is that every time you have a new class or object you have to:

  • create the database table to represent that object
  • create the class in code (using language of choice, of course)
  • and define methods to link the two, including the necessary SQL

That’s a lot of work.

One Solution

My friend Milot, on his blog post Code Structure and OOP Concepts Implementation, talks about one method of easing this pain. He proposes three layers:

  • DataAccess layer–deals with querying the database and making the results available to the object
  • DataTransferObjects layer–like the member class in Figure 1
  • and the GUI layer–can interact directly with the object we are dealing with and doesn’t have to worry about the database

This method might work for some people but my main criticism for it was that code duplication would have to happen much like my initial solution (this was one of the problems with the initial solution) and second, the resulting code in the GUI methods wasn’t very object-oriented looking:

Products p = new Products() { Name = txtName.Text, ... };
ProductsOperations products_op = new ProductsOperations();
bool isRegistered = products_op.Register(p);

In addition, I don’t find that easy to read. What I’d rather have is something like this:

Products p = new Products() { Name = txtName.Text, ... };
bool isRegistered = p.isRegistered(); // this is more like it :)

The best solution

It turns out this problem has existed for a while (I guess I don’t get credit for finding the problem, let alone the solution!). The nice solution that will allow you to just relax a bit more (see Figure 2 for a demonstration) is Object-relational mapping (or ORM). 

Figure 2 - Relax.

Figure 2 - Relax.

ORM simply maps your class (or object, if you will) to a database table(s) and if the ORM system you’re dealing with is powerful enough, it’ll handle even the relationships between your objects! Sweet, right? Okay, I’m beginning to sound like a snake oil salesman, so let’s look at Django’s ORM implementation (I looked at some PHP ORMs such as propel and repose but they didn’t seem nearly as nice as Django’s ORM implementation).

In Django you first define a model (this is all python):

from django.db import models

class Member(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)


 
Then you simply execute this command: python manage.py syncdb and Django creates all the necessary tables for the database that you’re running (could be sqlite, MySQL, or PostgreSQL).

Once Django creates the database, you’ll be able to use the Model in normal python code and not even worry about the database communication and so on. The ORM even protects you from SQL injection attacks as you won’t be executing SQL commands directly.

So, now we have this:

newMember = Member("John", "Smith")
newMember.save()
# This creates a person with first name John and last name Smith. It's that simple.

or for Milot’s problem:

#define the model
from django.db import models

class Product(models.Model):
    # The ID is auto-generated as the primary key,
    # so we don't have to create it.
    name = models.CharField(max_length=30)
    description = models.CharField(max_length=100)
    price = price = models.FloatField()

then we can access Product information like this:


newProduct = Product("Audio R8", "Only the awesomest car in the World!", 110000.00)
newProduct.save()

#then we could retrieve the recored we just created
sameProduct = Product.objects.get(name="Audio R8")

I should mention that Django is a python based Web framework, or as its developers claim The Web framework for perfectionists with deadlines. Who am I to argue :)

Thanks for reading. Your comments or corrections are much appreciated.

  • Share/Bookmark

XML Indentor

December 18th, 2008 § 0

I was playing around with an Amazon API and needed a way to indent the XML it was returning in order to make any sense of it.

A google search came up with this awesome tool. A great thanks goes to Jon Aquino :D .

  • Share/Bookmark

I can’t spell, the browser can’t tell

December 10th, 2008 § 0

I spent about half an hour trying to figure out why this code wouldn’t do what I wanted it to do, which is just create a div element and position it at a specific coordinate in the page:

var contactInfoDiv = document.createElement('div');
m = $(linkStr).positionedOffset();
contactInfoDiv.style.cssText = "background-image: url('{{MEDIA_URL}}images/nav_pointer.png'); width: 29px; height: 16px;"
contactInfoDiv.style.cssText += "position: abolute; top: " + (m.top - 70) + "px; left: " + (m.left - 85) + "px;";

document.body.appendChild(contactInfoDiv);

Don’t know if you caught it or not, but position: abolute is actually supposed to be position: absolute.

Don’t you wish the browser was a bit more unforgiving? So, instead of having my code kinda-work, it would have choked telling me that abolute is not a recognized position, and it would have taken me 5 seconds to resolve the issue, instead of half an hour.

Or maybe, just maybe, I can learn to spell—yeah, not happening.

  • Share/Bookmark

HCI (Scratch Input)

November 29th, 2008 § 0

An amazing technology that allows a user to interact with a computer (including phone, of course) by scratching surfaces. I wonder if such technology can be used record the blackboard content as a teacher writes on it (thus scratching it). This is brilliant, either way.

  • Share/Bookmark

MVC pattern and web development

November 29th, 2008 § 0

I came across and incredible piece on MVC and web development:

it should be abundantly clear that the traditional “MVC” is back with a vengeance: the blurred lines between which bits of code are responsible for “Model business logic” validation are gone, and the blurred lines regarding which bits of code are responsible for generation of the “View” are also gone – but not completely. It’s up to the developer to decide how far they want to deviate from the traditional ‘HTML’ style of display / information rendering. Not everybody is comfortable with the use of Widgets that are executed as Javascript to do the job that HTML used to do (even if it’s behind a javascript framework such as mochikit, extjs or prototype), and fortunately, both the GWT and the Pyjamas frameworks do an extremely good job of supporting and interacting with straight HTML (investigate the HTMLPanel widget, for example, for details).

Wouldn’t it be cool to be able to replace Javascript as the only way to manipulate the DOM in browsers. Wouldn’t it be cool if instead of Javascript you could throw Java, python, into an HTML document! Let the dreams begin.

  • Share/Bookmark