INCLUDE_DATA

Category ruby

December Mid-Month Top Commentators Update 5

Dec15

We’re halfway into December, and getting closer to Christmas with each passing day. I thought I’d take a minute and highlight some of the great contributors to this website.

So far, for the Month of December, the Top Commentators on my website are:
continue reading »

FIX: Blank webpage problems when first setting up Code Igniter, PHP, MySQL, and Apache 1

Oct29

Today, I created my first website using the Code Igniter PHP framework and, oh boy, do I like it a lot more than Ruby on Rails. But I’ll dig into that further in a future post.

The purpose of this post is to shed some light on a problem that I wracked my brain over for a few hours last night.

The problem: After installing Apache, PHP, and MySQL and configuring the Code Igniter framework, you get a blank web page when testing your first controller, model, and view.

What I discovered were two issues that, when combined, create the perfect storm of an installation problem:

  1. First, MySQL is no longer enabled by default with PHP 5. Says the PHP website of MySQL in PHP 5:

    MySQL is no longer enabled by default, so the php_mysql.dll DLL must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH.

    It’s been a LONG time since I’ve programmed in PHP let alone installed PHP, so this was news to me. Anyway, if check out the MySQL installation notes on the PHP website if you need help enabling MySQL.  

  2. Unfortunately, that was the easy part. Once I had an error message to work with, Google lead me to the PHP website, and I was in the clear. But, for the longest time, I wasn’t even getting an error page. Remember, all I was getting was a blank HTML page. So what was the cause? Code Igniter…
  3. Using some creatively placed die() calls, I found out that the application was dying when trying to connect to the database. (Previous to this, I had already double- and triple-checked my MySQL username and password in the Code Igniter configuration file, and had even tried out alternate accounts, like my MySQL root account.)What I found out was that the MySQL drivers in Code Igniter were suppressing errors when attempting database connections.

This is what the code looks like in the Code Igniter mysql_driver.php file:

function db_connect()
{
   if ($this->port != '')
   {
      $this->hostname .= ':'.$this->port;
   }
   return @mysql_connect($this->hostname, $this->username, $this->password, TRUE);
}
The “@” symbol before the mysql_connect() function call supresses any errors that may be returned. It is that symbol that wasted a good 2 hours of my life.Anyway, after I removed the “@” symbol from the code and re-tested my web application, PHP spit out the error message that I should have been presented with hours ago, and I was well on my way to fixing the problem.
 If you’re experiencing the same problem that I was, I hope this helps you correct it faster than I did! Best of luck.

Oh, and did I mention how much I prefer Code Igniter over Ruby on Rails? It’s messier, but with my C and Java background, it makes more sense than Ruby and Ruby on Rails does!

Battle in Seattle movie hits close to home 2

Oct20

The Vancouver International Film Festival has come and gone, and although I had a small list of films I intended to watch, I never ended up making it out to the theatre. I suppose there’s always next year. On a related note, another film festival flick that I want to catch is Battle in Seattle, which played at this year’s Toronto International Film Festival and opened in Vancouver, Montreal and Toronto this past week.

Having been in Vancouver at the time, I can vividly remember the news coverage of the street violence that erupted during the WTO protests in 1999. It’s these protests that the film Battle in Seattle centers upon, and by the looks of the trailer, the movie truly takes us back 9 years to those emotional days.

Back in 1999, the city of Seattle was host to the World Trade Organization, which was big news then, as it was the first time the ministerial conference was being held in America. Although intended to highlight the launch of new trade talks with developing countries, the 40,000 plus protesters that collapsed into the heart of Seattle saw the conference as a rallying cry for protesting the globalization and exploitation that multinational corporations engage in. On news footage at the time, I can remember the stand-offs between the protesters and the Seattle Police Department, as well as the destruction to storefronts which resulted. Definitely a conflict I’d never want to be in the middle of.

The movie has a star-studded cast that includes the likes of Charlize Theron, Woody Harrelson, and Ray Liotta, which only helps to bolster my interest in the movie. (Who doesn’t love Charlize!?) If you’re interested in learning more about the movie, you can do so here.

Resurrecting this blog and broadening it’s focus 1

Oct28

I started work at TELUS over 10 months ago, and since that time, I’ve barely written a stitch of Ruby, let alone learn anything more about Ruby on Rails. My TextDrive account is no longer active and the experimental websites I launched while actively learning Ruby on Rails have been shut down. Essentially, I’ve lost all connection and interest in RoR and the RoR community.

For that reason, I’m renaming my blog from “Rory on Rails” to simply, “Rory Hansen”, as I don’t foresee myself writing about Rails anytime in the near future. Who knows– maybe somewhere down the line, I’ll regain interest in RoR, but right now, my mind and my time are focused elsewhere.

At work, I program almost exclusively in ASP.NET and C#. For the type of development I do, ASP.NET is fine. I appreciate the power of the framework and, given my experience with it now, I can get new webapps up and running quickly and easily. Do I like ASP.NET? Actually, yes I do.

Outside of work, I’m constantly trying to better myself through learning new skills and improving existing abilities. As my buddy Jeff would say, I’m just trying to ”raise my NPV.” Whether it be by reading great business books like Blue Ocean Strategy or Good To Great, or by practicing my networking skills at various conferences around town, I’m consciously trying to improve myself, thus raising my “market value,” so that when I’m ready to find a great new job somewhere, I’ve positioned myself as best as I can to actually get that job.

So, with all of that said, future posts on my blog will be about many of my current interests, such as learning how to play the acoustic guitar, improving my communication and networking skills, making change happen in business, and futher developing my leadership abilities.

Stay tuned!

Rory

Web Business Idea: Online flash cards 14

Dec6

Here’s a business idea: Create a website that makes it easy for people to create and study using flashcards.

How could this website be profitable? Everyone can create flashcards for free for their own use. If they like, they can then “share” these flashcards with the public, so that others can benefit from their hardwork. But, as incentive to create quality flashcards and share those cards, others would have to pay to access them.

For example, Sam creates a deck of flashcards for his Biology 101 course. He chooses to share them with the public. Karen, who is in the same course at the same university as Sam wants to study using flashcards but doesn’t know Sam nor have the time to create her own deck. So she pays $2 to use Sam’s deck. The website keeps 50% of all payments and rewards Sam with the other 50%.

Throughout university, I’ve often found using flashcards useful for studying, but buying the flashcards from the store and creating them takes so much time that it becomes difficult to justify expending the energy to do so. If I had the chance to buy pre-made, university course-specific flashcards online, I actually might have!

The key idea is that these flashcards would be specifically catered to courses at various universities by students in those courses. This makes them so much more valuable then generic, pre-made flashcards that you can buy in stores, as they would test the exact types of information that you’d need for your course.

They could also be used for years to come, as courses usually change very little over even a number of years. This creates a passive income stream for the flashcard creators.

The website would be totally Web 2.0 centric, with the ability to “tag” flashcards with topics, relevant courses, etc. AJAX could be used to shuffle through the deck while studying. Separate stylesheets would need to be created so that the flashcards could be viewed online or printed for offline use.

The only difficult part would be the actual creation of the cards. Version 1.0 would probably only support text and HTML markup, but later releases would also have to support images (uploading and placement), formulas for physics and math, and perhaps even doodling using your mouse as a pen tool.

Lemme know if you are interested in making this happen!

Komodo 3.5 for Windows now available 0

Dec6

This news is now a week old, but better later than never, right?!

Anyway, the news: Kodomo 3.5 for Windows is now available. I’ve been using the beta version now for a few weeks, but the advanced features that I was hoping to take advantage of have been so buggy that it hasn’t been worth it. I’ve yet to take this non-beta version for a spin yet, but I plan to do so as soon as I can find the time.

I can’t wait to use the Kodomo debugger for my Rails development; I know it’ll help speed up my testing and debugging dramatically. I just hope that the performance issues that I experienced in the beta have now been addressed, as that was a major show stopper.

I did promise that I’d write up a full review on Kodomo in an earlier blog post, and if I can find the time to do so, I still will. But with Christmas just around the corner and a new job starting in the new year, it’s gonna be more difficult to fulfill that promise.

In the meantime, if you plan on using Kodomo as your development IDE for Ruby on Rails, check out Eric Promislow’s blog where he often posts about Ruby on Rails and Kodomo, such as How to work with rhtml files in Kodomo.

Zebra-striped tables using Rails 6

Nov30

Zebra-striped tables are tables where row colors alternate between a light color and a dark color and can be done both using server-side code (ie. Rails) or client-side code (ie. JavaScript). I posted a question asking for the most convenient way to create zebra-striped tables to the Rails newsgroup some weeks ago and the responses I received were actually quite scathing. I’ve normally done this type of thing using server-side code when working with other programming languages (ASP, PHP, JSP, ColdFusion, etc.), but many people feel that this is an extreme no-no (and aren’t afraid to tell anyone that’ll listen to them), as it muddles up the separation of business logic from presentation.

Anyway, my point is that, regardless of what others think, I want to continue doing this type of design using server-side code and a recent post on the Code Snippets website highlights a Rails helper tag called cycle that makes this very convenient. (The name will be familiar for those that have used the Smarty templating engine for PHP.) The cycle tag is exactly the type of suggestion I was looking for when I posted my initial question to the newsgroup. Before that, I’d been using some nasty combination of if statements and the mod operator to determine the row color and that had completely uglified my code.

This is how you use the cycle helper method:
<tr class="<%= cycle("even", "odd") %>">
... use item ...
</tr>

You can read more about the cycle helper method in the Rails API.

My thoughts on Kodomo 3.5 on hold 0

Nov13

I’ve been meaning to write a more meaningful review of Kodomo 3.5 beta for Windows, but have decided to hold off until I can evaluate a non-beta version. My reason for doing this is because of the fact that it is still in beta, and so, I think it’d be unfair if I critique a product that may still have its functionality changed before the real release.

For example, I have successfully been able to use Kodomo to debug one of my actions. But, because it was so incredibly slow to debug this action through Kodomo, I’ll never do it again. At least, until the speed issue is resolved. And I know that it will be resolved eventually, as it is noted as a problem here in Eric Promislow’s blog.

There are other issues that I’ve encountered that I’m not sure are actually issues with the IDE or just with me as a user of the IDE. For example, I could not get the intellisense to work with my Rails models.

Anyway, when I get my hands on a non-beta version of Kodomo 3.5, I’ll write up a better review. Until then, I may continue to use it to write my Rails apps, but only in the same way that I’d use any other text editor.

ActiveState releases Kodomo 3.5 (which now has support for Ruby) 0

Nov3

ActiveState, a local Vancouver company that I’d only previously known about because of ActivePerl, has just released Kodomo 3.5, an IDE that now supports Ruby. Sadly, Windows and Linux versions are still only in beta, but I’ve signed up to beta test the IDE as I’m eagerly trying to replace Dreamweaver as my Ruby on Rails text editor.

The ActiveState highlights the following Kodomo 3.5 features:

  • Fully-integrated Ruby support
  • Ruby on Rails debugging
  • Code intelligence
  • Cross-platform
  • Highly customizable
  • Supports multiple languages

Of these features, the two I’m most looking forward to using are code intelligence and debugging. My current method for debugging my Rails apps is pretty amateurish, I’ll admit, as usually I’ll just output values to the console window to see what’s going on. I know that Rails has the ability to set breakpoints and debug in a more structured manner, but it all reminds me too much of GCD. I hope that the debugging facilities in Kodomo are more like those contained within VisualStudio.NET, as I’ve come to appreciate the convenience of using a nice GUI for debugging.

Anyway, the 28MB download for my Windows version of Kodomo 3.5 beta is nearly complete, so I’ll end this post here. I hope to have a decently complete review of my opinions of Kodomo online in a few days, so check back then.

Starting on new Rails site; using Product Generator 1

Oct18

After taking *many* weeks off of Rails programming, I’ve decided to begin work on a couple new projects. One of them will be using Duane’s Product Generator so that I can “productize” it. Basically, here’s the concept: Using the Ruby/Amazon library, I can easily consume the Amazon web services. By leveraging the code reuse that Product Generator facilitates, I can create many small online stores that “sell” Amazon products, and for each product I sell, I’ll earn between 5% and 10% in commission. Each online store will be specialized to a specific niche, such as haunted houses or water polo, etc.

Sound okay? I think so.

I already have some experience using the Amazon Web Services, as I’ve used them on my lyrics website. But now, these stores that I create will use the web services in greater depth, as visitors will be able to add items to their shopping cart or their wishlist, etc.

Anyway, I’ll keep you updated with the progress I’m making with Product Generator and Amazon web services.