Posts Tagged ‘Web Development’

How to watch a log file in realtime in Ubuntu Linux

November 13th, 2011

There are times when I’m debugging code on a linux box that I want to see what’s being logged by a Web Site or Web Application. What I used to have to do was do something on the website, then open up a terminal in Ubuntu (or any other linux distro for that matter) and view the logfile with either vim, nano, cat | less or gvim.

How I used text editors to do it
I use VIM as my default text editor on Ubuntu or any other linux distros (such as redhat, centos, debian, linux mint) that I work on.

A few weeks from now I used to use vim to open the log file, then the :e (edit) command to reload the new log entries.

Based on the entry, I make adjustments as required, then try again.  Back to vim, issue the edit command, review the changes, then run the script again. So on and so forth.

Now this is kind of did what I wanted it to do, but what I really wanted it to do was display the log in realtime so that I can just keep going back to the terminal and see what’s wrong without having to do the additional second step of running the edit command.

The way of opening up a log file in a text editor, then reloading the log file in the editor was very cumbersome. I needed a way of seeing the log file in realtime so that I did not have to keep reloading.

» Read more: How to watch a log file in realtime in Ubuntu Linux

Importing a SQL file directly from Command Line for MySQL

October 18th, 2011

I am writing this on the train, so I’ll be relatively quick.

It’s been a while since I wrote my import sql file via command line post and thought I’d post the updated version which I now use.

It is possible to execute an SQL file without logging into the mysql client first. Previously, I used login to mysql and use the source command to execute commands from an SQL text file.

Now, I execute it all straight from bash or windows shell without having to login to the MySQL client.

To import an SQL file by passing it as if it were an arguement, you need to use the < sign. So for example, say that I wanted to import an external database from production and wanted to import it into my development environment, I can do so by doing the following:

» Read more: Importing a SQL file directly from Command Line for MySQL

How to fix phpmyadmin error: “Connection for controluser as defined in your configuration failed”

January 3rd, 2011

“Connection for controluser as defined in your configuration failed” It’s one of those small, annoying messages that appear out of the way on your screen, but still catches your eye once in a while especially when you’re deep in thought about how to building a multi-join query in the SQL tab of phpmyadmin.

Well, it annoyed me today so much that I finally decided to do something about it and finally take a look. I opened up the PHPMyAdmin config file located at /etc/phpmyadmin/config-db.php  on Ubuntu Maverick Meerkat. There’s a default username and password in $dbuser and $dbpass variables.

Now my knee jerk reaction to this would have been “no problem I’ll just change that to my root username and password.” which will work by the way, but I decided against it since the control user for PHPMyAdmin did not really need to have access to all the other databases in my local cluster.

» Read more: How to fix phpmyadmin error: “Connection for controluser as defined in your configuration failed”

Analysis Paralysis: In a quest for perfection, I manage to achieve nothing

December 4th, 2010

This was supposed to be a live coding note, but it just turned into something else. No ground breaking news, no new concept which will make you go “hmmm”, just a guy kicking himself – you can safely ignore this frustrated post if you aren’t in the mood to read about how much an idiot I think I am :P

It’s been a mixture of Tunnel Vision, NIH Syndrom and Analysis paralysis that had me living in a haze of trying to implement DataMappers ala Zend Quickstart Guide on and off, for the past 4 weeks.

I even wrote the Unit Tests and everything for this project I’ve taken part in called “customember”: a sample project to help a few newbies I know (and to a certain extent myself) skill up through practical experience rather than going into a real world project and doing the floundering around when the gun is really loaded.

» Read more: Analysis Paralysis: In a quest for perfection, I manage to achieve nothing

Unit testing with Live Databases and/or How do I use Mock Objects?

November 30th, 2010

This is another live coding note. I’ve found my rhythm with TDD and currently bashing away at some unit tests for the Models and Service layers for a project I’m working on.

In tonights post, I’m going to write about how I get around with Unit Testing live databases.

Unit Testing with Live Databases

For my unit tests, I’m currently working with a live test database since I don’t fully understand the “power” of mock objects. If you have any links out there that’s worth noting, please be a friend and “link me”. I’m not going to pretend that I know everything and anything about Web Development. I know a lot, but the one thing that I do know is that I don’t know everything.

Mock Objects. WTF are you?

One thing which is mostly a mystery to me is the concept and practical application of Mock Objects in Unit testing. I’ve read several articles on Mock objects, but some of them delve into how to create Mock Objects rather than practical usage for mock objects in a live development setting. What problem exactly are mock objects trying to solve?

I get that it replaces other objects that the current class your testing will collaborate with, but I’m guessing that this is due to not having a setup like I currently have where I have the extra application code which easily gives me access to the db resource so that I can just as easily do this within my unit test as it would with mock objects… maybe? I’m confused.

» Read more: Unit testing with Live Databases and/or How do I use Mock Objects?