Tuesday, December 06, 2011

Pagination in PHP

As a developer, once in a while you come across a requirement in a project that requires you to go that extra mile. I recently moved from desktop development to web applications and have been enjoying the experience.

However, there are a few things we are used to on the desktops that are not available on web applications - like pagination, tabbing, portability and ease of development.

Whilst there are tons of examples of PHP Pagination online, only a few of them have a complete example that demonstrate how it actually works. The rest just show a little piece of code and  tells you to figure out the rest yourself...nothing of real substance that you can adapt to fit your need.

That said, I came across a nice jQuery version which does almost what I needed - problem is that I would need to learn to use jQuery to use this example. So, what this means is that I need to learn a new framework to learn to use another. Hmm, that's online tutorial for you.

If you know of any good example of PHP Pagination, please leave a comment below and share it with us all.

Sunday, November 20, 2011

You Should Get Yourself One of These Amazon Kindle Fire

After spending a few days with the Kindle Fire I have been very impressed. I don't think it will ever replace my e-ink kindle but it is a great little deice. I have owned multiple Kindles including the 2nd, 3rd, and 4th generation devices. I have also read on android Smartphones, an iPod touch, kindle for pc, and the cloud reader.

PHYSICAL: I love the size of the Fire, it can be held with one hand although after a while the weight forces some positioning adjustments. It is about the size of the past (non DX) kindles and around the size of a DVD case. The power button seems to be poorly placed in the center of the bottom of the device; Right where I want to put my hands. I frequently hit/hold the power button unintentionally. The speakers are surprisingly good for a device of this size although the max output could be louder. I miss the physical page forward/backward buttons of the earlier kindles and volume up/down buttons would make a nice addition. Overall, none of these problems are great enough to cause me to down-rate the device.

SOFTWARE: The carousel on the home screen is interesting. It is a good idea but can be too sensitive and spin when I intend to select an item. The favorites on the home screen remain stationary and are easier to navigate than the carousel for frequently accessed items. I currently have my favorite apps and the books I am currently reading as well as those on the top of my list.

NEWSSTAND: The pages of magazines are a little scrunched on the Fire's screen but zooming in helps a lot. I found that nearly half of my favorite magazines aren't available at all (yet). I don't tend to read magazines as much as I read books so this isn't a huge problem but for people looking at the Fire for magazine reading should check availability first.

BOOKS: The functionality of the reading is more like reading on a cell phone than reading on a kindle. The biggest missing feature seen on e-ink kindles and missing here are collections. There is very little ability to organize your books here. You can view all books you own (Cloud) or all books on the device. You can sort these listings by title, author, or most recently viewed. Kindle.amazon.com has a way rating books, listing books as want to read/reading/read/abandoned. It would be great if the Fire accessed this data and allowed for better user management of the list. My list contains just under 200 books and over time that number will only grow. Once you find the book you are looking for (I keep the ones I am currently reading and plan to read next in my favorites) reading is a simple and pleasant experience. The title of the current book is written at the top of the screen and other than that the only thing displayed during reading is text. A single tap in the center of the screen brings up the time, battery, network status, how far you have read, and various other buttons. The display color, margins, spacing, font size, and typeface can be changed through the menu. Font size cannot be changed by pinching.

MUSIC: The music plays well and can be organized into playlists. The music features are most useful if your music is on the amazon cloud drive. But music, and everything else in the cloud, can't be accessed when outside of wireless.

VIDEO: Watching free and purchased videos is a great experience on the Fire. Keeping track of the free Prime videos I want to watch is much more difficult. There is no queue or to watch list so every time you want to watch you have to search around for what you are looking for.

APPS: What's not to love about a free app every day? Some great android apps are still missing here but there are a lot of great options available and hopefully the list will grow.

Overall the Fire is a great product at a great price. A 3G options would be very nice.

Boomerang: Travels in the New Third World

Boomerang: Travels in the New Third World - Michael Lewis spins an entertaining yarn, traveling about the world and joking about the personality traits that led to the varying economic disasters of 2008. One can learn a certain amount about what transpired in each country, but the strictly factual material in this book could probably be spelled out in less than ten pages.

The bulk of the book is composed of amusing vignettes and Lewis's attempts to define each country's travails in terms of broad cultural stereotypes. The Icelandic crash, for example, follows from the that that Icelandic men think they are Vikings and don't listen to women.

The Greek crash results from their inability to trust each other. The German problem comes from their trust in process and their fascination with fecal matter (I am not making that up).

I don't know that my understanding of the world has been advanced by this book, though the book is an enjoyable, quick read.

Saturday, October 29, 2011

My Review of Steve Jobs by Walter Isaacson

I just finished reading Steve Jobs. Wow! I must say I'm breathless (once again). With the number of reviews already published, I'll focus on a few key points that made an impression.

1. Walter Isaacson tells a very engaging story. His narrative captivated me from the get-go. He elegantly wove the various angles of Jobs's work through the time-line, which wasn't an easy task when you consider all the projects that were developed concurrently. It's a magnificent read.

2. I found it interesting to read "Jobs in his own words." It was hilarious to discover how much he and Bill Gates cursed - something I could have guessed but was never made explicit in other works about him.

3. There wasn't all that much new information. I don't know if it's because of my interest in Steve over the past few years, but I already knew most of the content presented in the book. There were not that many "Damn, I was wondering about that!" moments during my read.

4. The book lacked a lot in terms of Jobs's personal life. I expected to read a lot more about it, given that Isaacson was an "authorized" biographer. I believed I would find more extensive interviews with the children and his wife. They appear to be completely peripheral to Jobs's life, although the book doesn't allow me to conclude that at 100%.

In summary, it's a great book on Steve Jobs. If you want to know more about the showmanship of Steve, there will be more interesting options on the market. I give it 5 stars because it is truly a fantastic read.

Thursday, October 27, 2011

Clean Code: A Handbook of Agile Software Craftsmanship

There is nothing particularly new in this book. It just discusses how to write "clean code" -- the code that is really easy to understand and maintain. Nevertheless this book is worth reading just to remind you another time how important "clean code" is!

This book provides lots of concrete advice how to make your code "cleaner". It discusses importance of proper naming, code formatting and testing. It stresses importance of constant refactoring and provides several extended refactoring examples. But the most important advice the book gives is to always commit better code then you have checked out.

Some advices given in the book can be disputed. Some chapters are weaker (in particular chapters on concurrent programming are quite superficial). Still overall book is definitely worth time spent reading it.

Thursday, October 13, 2011

JBuds J4 Rugged Metal In-Ear Earbuds Style Headphones with Travel Case

I have owned numerous "midrange" earbud headphones over the years, ranging from Sonys to Sennheisers. All of these earbuds delivered the same things: great sound quality for the price, and flimsy construction. I estimate that none of these products, no matter how many buzzwords adorned their packaging, lasted more than 1 year with normal use.

Finally, after my latest pair dropped a channel due to an internal cord break, I deliberately searched for something with rugged construction, and came across the JBuds J4 model. The words "kevlar-reinforced cord" sounded great to me, so I ordered up a set, hoping I would not have to get another for at least 2 years.

Like every other earbud in this price range, the JBuds arrived in a plastic blister pack with several different sizes of rubber tip pieces. My ear openings seem to be rather small, so the smallest tips are usually the ones I end up using, and these were no exception. I did not care for the double-style rubber tips, but I find that the noise isolation from the single-style are more than sufficient.

Sound quality is as good as any competing earbud. Having never listened to "high-dollar" ($150+) earbuds, I have no idea what sort of auditory experience I am missing out on, though I hope to try some soon. Regardless, these earbuds are not lacking compared to the others on the market in this price bracket.

The cord is undoubtedly the best feature of these earbuds, and was the main reason I chose them. It is a standard Y-style cord, which I strongly prefer to the asymmetrical type, with no adjustable slider. Cord length is ideal for me (6' 2" tall) to keep my iPod/phone in my pants pocket and still have enough slack to do workouts at the gym without any binding or catching. The cord's flat design is ingenious in that it does indeed prevent tangling as claimed. The two separate channels may get tangled around each other, but they are easily undone, and most of the time the cord just shakes out. That alone is probably the most notable feature of the J4. In addition, I have now been using these in my normal (moderate) fashion for over 7 months, and they have not missed a beat. I will be sure to update the review periodically to reflect how they hold up compared to prior sets, but they seem promising.

Now, the big downside: The headphones are not very comfortable. This is obviously a huge factor in the earbud market, and sadly the J4's suffer a minor and seemingly easily corrected design flaw which causes discomfort and/or frequent adjustment in the ear canal. The body of the earbuds, rather than having a somewhat half-spherical shape like many others, is a long cylinder with an end cap, that tapers on the ear side to the speaker port. The transition between the straight and tapered sections is a sharp, hard edge, and this edge tends to rub against the ear, causing significant discomfort. Over time, I have gotten more used to the earbuds, but unlike others that I never had to touch, I find myself frequently shifting these around to get that sharp edge off of my ear. I compared them side-by-side with my older broken earbuds and noted that those ones were smooth and curved, preventing such issues.

Two other details about the earbuds are worth noting. First, the cord is quite bulky. I don't mind, especially since the bulk is largely due to the kevlar reinforcing fabric, for which I am grateful, but it's not easy to see how thick it is in the pictures. Second, the plug is straight, not 90 degrees. This is no problem either, but a detail that some people wish to know.

Overall, I am happy with the JBuds J4 earbuds, but their unfortunate sharp-edged design really detracts from their overall rating, due to the discomfort it causes in the ear. If JBuds could reshape the J4 to more resemble the J3, or the Sennheiser CX300, this would solve the only problem I have with them, and would earn the J4 earbuds a 5 star rating in my book.

Sunday, September 11, 2011

Java EE 6 Development with NetBeans 7

In any technical work, the author's primary problem is to target an audience, and to maintain that focus throughout. This is every bit as important as accuracy.

With the title of this book, you expect that the operational pieces in the Java EE 6 spec will be explained within the context of the Netbeans IDE. That's all well and good, but how much prior knowledge of both these Java standards should be assumed? Here one must avoid too many screenshots, with a singular focus on step-by-step procedure. At the same time, it must be assumed that a really seasoned developer is probably already familiar with Netbeans and would just want an in-depth focus on the somewhat newer Java EE 6 spec.

In view of this, some coverage of the UI of the IDE, with due attention given to the whys and wherefores of the Java EE 6 components, is in order. It's reasonable to expect an substantial audience for a practical guide that explains how this IDE can help a developer who wishes to stick with the facilities provided in the EE 6 spec. Additionally, one can expect the reader has a technical bent but could use help integrating the technologies in the Java spec. In other words, a reader in the moderate knowledge range.

So now I have to say that I'm a member of the above target audience, and I really liked this book.

I won't re-list the table of contents here, but I have to mention some highlights here. It's my opinion that JSF has evolved to the point where it is a serious contender; especially since PrimeFaces hit the scene. So I was really happy with chapters 4 and 5. It's wonderful to see such a concise Facelet template explanation. PrimeFaces is there because it is included with Netbeans 7. Although one sees a lot of Hibernate, it's cool to have JPA included- and the author sails right on into session beans. There is a great discussion of Web Services development to wrap up.

The book has a good selection of topics; and is approachable- but it isn't a lightweight in that it really explores, to some depth, what the current iteration of Java EE can do. After reading it, you definitely gain a new respect for Netbeans, too.

Don't expect coverage of things outside of Java EE 6 (except for PrimeFaces)- there is only so much room in one book. Given the title, this isn't a surprise or really a problem. Just be advised.

This book promises to be practical in approach; to integrate Java EE and Netbeans; to be concise and comprehensive; and for a wide range of developers. I think it pulls it off. I have to recommend this one.

Reviewed by: Kenneth Tindle

Sunday, September 04, 2011

Trend Stetting: Hail to the Editor in Chief

Regardless of your contribution to Barack Obama’s approval rating, you have to admit one thing: The man can give a speech. And to the delight of professional wordslingers the world over, toiling under deadlines and character counts, he tends to write much of each address himself (like another fellow who’s spent some time on Pennsylvania Avenue used to say, he “feels our pain”).

To figure out why the 44th president’s speeches have such an explosive impact on listeners across the party spectrum, seasoned political analysts Mary Frances Berry and Josh Gottheimer tackled the impressive task of parsing his language. Their forthcoming book, Power in Words, walks us slowly through 18 of candidate Obama’s major addresses during his ascent to the White House.

It’s a fairly wonky read, as you’d imagine, with plenty of citations and endnotes and an occasionally excruciating level of detail: “After a few days in the country spent traveling with a twelve-car motorcade, Obama and his entourage flew to the rural area of Kolego in the Siaya District of Nyanza Province, about 175 miles east of Nairobi.” But Berry and Gottheimer temper their academic approach with lively anecdotes about backstage tension and last-minute rewrites, as well as insight into the symbiotic relationship between Obama and his head speechwriter, Jon Favreau (not the guy behind Cowboys & Aliens—look for his younger, prettier Googleganger).

Here’s what I learned from their efforts: The president’s political savvy and famous preacherlike cadence play a big role in his ability to stun a crowd, but delivery only goes as far as what’s in the package. Berry and Gottheimer close every chapter with the full text of the speech they’ve just analyzed, and the placement is apt. It drives home the force of the words themselves—clean and precise and startlingly emotional, even on a two-dimensional page. You may or may not agree with them, but they’re impossible to ignore.

Monday, August 29, 2011

Scriptin' with JavaScript and Ajax

There are lots of JavaScript and AJAX books out there now, but few really combine both skills into one book. A few books that do, are huge books (700+ pages) and really are impossible to read through and actually get through all the 'techo-jargen' to really get anything out of the book. Most people need a easy-to-understand, to the point with real-world examples book.

This book by Charles Wyke-Smith is the book you are looking for if you want to quickly get started learning JavaScript with all the latest features (including libraries) and how to incorportate AJAX features as well. Since AJAX is not a separate technology, but incorporate sepecific JavaScript objects to create AJAX-enabled websites.

The author assumes no previous JavaScript experience and goes through the basics of JavaScript covering variables, if statements, loops, arrays and how objects/classes work. Then the author goes into explaining the DOM works in modifying and referencing HTML elements of a web page as well as modifying CSS styles of elements (and child elements) of a page. This of course is the foundation of how to use AJAX properly and explained very nicely by the author will great examples to get anybody up and running easily.

The author then goes into explaining JavaScript events inrelation to how they affect an HTML page with window and mouse and keyboard events. The author also covers the Event object in talking about event delegation and working with the DOM in creating some complex JavaScript examples.

Then various JavaScript libraries such as jQuery, Adobe Spry, Prototype are explained with some really cool examples of using multiple libraries together which is very unique for most JavaScript books.

Finally, the author very nicely explains how the objects that work with AJAX work and how to create some really useful AJAX web pages with PHP.

Lots of good stuff to learn from this book and the author does a fabulous job doing it a relatively short book (300 pages).

A great book and worth buying if you want to learn JavaScript and AJAX the proper way!!!

The Linux Programming Interface

If your nose is a bit sensitive, the physical book might smell of chemicals, or at least the original copy that I received did. I was able to get a less strongly smelling copy from the publisher, which helped a lot. The hardcover edition is fat and pricey but worth it - looking at the sample code from the kindle version it came with it was kind of hard to keep track of what's going on while flipping through screens.

Also - I was confused on this point for a little bit - if you're looking for coverage of user space processes like systemd or command-line filters like less or grep, this is not the book for you - it covers only the underlying kernel system calls and C API which those filters are written with.

That said, I'm learning a lot about Linux through this book - and C as well. I learned C++ before I learned Linux, in some programming class where we used it to build a simple calculator and similar tasks. Learning C a bit later was a pain because it seemed so archaic and there was no proper motivation. Reading this book, though, made me realize how C actually makes a lot of sense in its proper context as a tool primarily for systems programming, for which it was created.

It's still slow and dense to read and digest (I still have a long ways to go with it), but I don't think there's any way around that - there's a lot of subtle and good information here, and it builds up the foundations progressively.

Be sure to get a copy if you are a serious Linux hacker.

Thursday, August 25, 2011

Logo Design Love: A Guide to Creating Iconic Brand Identities

I've done some graphic and web design in the past as part of a different job, but I'm now changing careers and will eventually be doing mostly freelance design. There are a lot of books out there that show you great designs, or that discuss only the more technical aspects of design.

But this book is unique in that it not only shows you brilliant works of design and branding, but shares the creative process behind them, focusing specifically on the critical task of creating brand identities that are lasting, relevant, and pleasing to any given client.

This book is visually inspiring while also being a great read... the perfect blend of eye candy and rich information! I'm about halfway through right now, and even if this was the end of the book, I would think it was worth picking up. But just when I think it can't get any better, I read a few pages more and love it even more.

David Airey just does a great job of demystifying some of the more daunting aspects of branding. Obviously I'm a beginner, but I have to believe that even seasoned designers who aren't as experienced in branding would find this very useful. Anyway, enough gushing. Get it. Love it.

Saturday, August 13, 2011

PHPList 2 E-mail Campaign Manager

Since I swapped my Java programming skill for Python in 2009, things have been going very well. In fact, it's turned out to be one of the best decisions I've made in my programming careers ever since I stopped developing in VB6. One cool thing about Python is the brilliant community out there that are working to make it one of the best languages for developers.

The first time I tried the Django framework I was hooked. There's nothing out there in the Java landscape that compares to the ease, less cluttered and well-documented power that Django provides. If like me you've used Java long enough, you will have noticed how bloated it quickly became with different people coming out with all sorts of frameworks - making an already crowded landscape into an XML-polluted jungle. Luckily, I discovered Python, saw the light and switched.

Talking about switching, we just started a new project last week which focuses on developing mailing applications for one of our clients. Unfortunately, they want it developed in PHP and not Python meaning that some of the folks on the team will have to either brush up on the PHP or start learning. As luck would have it, I bumped into this PHPList 2 E-mail Campaign Manager at the bookshop on my way home, so I picked up a copy.

PHPList 2 E-mail Campaign Manager is some of the best books out there on developing your very own mailing list. I have only read the first 3 chapters an can already see the amount of useful information that will come in very useful for my current project.

One of the problems with managing a self-hosted application like mailing list is that it requires an on-going security audit and protection from spammers. With this book, you will not only get to see ways to install and maintain it seamlessly, you will also get to opportunity to choose which of the many open source mailing list meets your need. There's no need in installing a 900 pound application on a server that will not stand the load, so knowing what works where and how they scale really matters.

I have just installed two of the many applications and can already see how they will cut down on our development and maintenance time. The other cool thing about this book is that I was able to apply some of the tips to Python.

Have you got a copy, did you find it equally useful? Would like to hear what others think about it. If, however you are looking for a great book to manage any sort of mailing list on your own, this book is a must. Internet marketers will hugely benefit from it as well. I can't recommend PHPList 2 E-mail Campaign Manager enough. Click here to get a copy now!

Tuesday, August 02, 2011

Jenkins: The Definitive Guide

Streamline software development with Jenkins, the popular Java-based open source tool that has revolutionized the way teams think about Continuous Integration (CI). This complete guide shows you how to automate your build, integration, release, and deployment processes with Jenkins—and demonstrates how CI can save you time, money, and many headaches.
Ideal for developers, software architects, and project managers, Jenkins: The Definitive Guide is both a CI tutorial and a comprehensive Jenkins reference. Through its wealth of best practices and real-world tips, you'll discover how easy it is to set up a CI service with Jenkins.
  • Learn how to install, configure, and secure your Jenkins server
  • Organize and monitor general-purpose build jobs
  • Integrate automated tests to verify builds, and set up code quality reporting
  • Establish effective team notification strategies and techniques
  • Configure build pipelines, parameterized jobs, matrix builds, and other advanced jobs
  • Manage a farm of Jenkins servers to run distributed builds
  • Implement automated deployment and continuous delivery

About the Author

John Ferguson Smart, director of Wakaleo Consulting, helps organizations optimize their Java development practices and infrastructure. He provides training and mentoring in agile development and testing practices such as Continuous Integration, Test Driven Development, Build Automation, and Continuous Deployment.

Saturday, July 30, 2011

Dive Into Python 3

Mark Pilgrim's Dive Into Python 3 is a hands-on guide to Python 3 (the latest version of the Python language) and its differences from Python 2. As in the original book, Dive Into Python, each chapter starts with a real, complete code sample, proceeds to pick it apart and explain the pieces, and then puts it all back together in a summary at the end.

Dive Into Python 3 is a Python book for experienced programmers. Whether you're an experienced programmer looking to get into Python 3 or grizzled Python veteran who remembers the days when you had to import the string module, Dive Into Python 3 is your 'desert island' Python 3 book. If you've never programmed before, Python 3 is an excellent language to learn modern programming techniques. But this book should not be your starting point.

Get "How to Think Like a Computer Scientist: Learning with Python" by Allen Downey, Jeffrey Elkner, Chris Meyers and learn the basics. Then dive into this book. Dive Into PYTHON 3 was written by Mark Pilgram, and this edition is distributed under the terms of the Creative Commons Attribution Share-Alike License 3.0. * Money raised from the sale of this book supports the development of free software and documentation.

About the Author: By day, Mark Pilgrim is a developer advocate for open source and open standards. By night, he is a husband and father who lives in North Carolina with his wife, his two sons, and his big slobbery dog. He spends his copious free time sunbathing, skydiving, and making up autobiographical information.

Saturday, July 16, 2011

Syma S107/S107G R/C Helicopter - Yellow

I don't know about you, but my little boy likes one of these awesome toys. We got him a nice Syma S107/S107G R/C Helicopter - Yellow. The last time we bought him something of that sort, it ended up in the bin within days of buying it.

However, this particular one seems to last much longer. It does feel like the best of the Syma toys on the market right now for those with children especially boys. If you have a child and would like to treat him to a nice toy, I would recommend you get them this top of the range Syma S107/S107G R/C Helicopter - Yellow


Sunday, July 10, 2011

Using Sep in Python

If you have been working with the latest Python 3 to a degree, chances are that you will have come across some very tricky and trivial piece of code that would run easily on Python 2.* but not on Python 3. This is one of the huge number of changes that was introduced in this Python 3 version, and sometimes you need to go back to the documentation to really work out how to use them. Below is a quick example on how you could use the new Sep.

Here's simple example of that in action:

place = "London"
print("Hello from ", place, '!');

If you run that, you will get
Hello from London !

The new print() method by default inserts a space at the end of its arguments. To avoid that space you will need to explicitly specify the 'sep' keyword.

print ("Hello from ", place, "!", sep="") # Note the explicit " " after "Hello"
Another goodie is that you can easily get useful information about modules, classes, keywords, and functions, e. g.

>>> help(print)

I will find time over the weekend to update this post and add a lot more examples here. I see lots of people searching for how to use sep - and it's important to have various examples that demonstrate how to effectively use it.

However, if you have a much bigger text than the one shown above, you will need to concatenate them before printing. Here's an example of how you might also want to use it:
output = "".join(["Hello ",name,"!"])  # thats an empty string to start 

print(output)
As I have always said, use the >>> prompt to experiment to find which works best for you. It is one of the most powerful methods to learn how to use Python's huge collection of modules.

Monday, June 20, 2011

Skipping tests in Python unittests

There are situations when writing unittests in Python you want to skip some tests - for example, you don't want to initiate process that could take some time to finish, e.g parsing huge XML.

In that case, Python's unittest allows you to annotate which of your methods in your test case you'd like to skip. Starting from Python 2.7, you could use any of these skip decorators in your code:

1. @unittest.skip
2. @unittest.skipIf
3. @unittest.skipUnless

Here's an example on how to use them -
import sys
import unittest

class TestSample(unittest.TestCase):
    @unittest.skip('Unconditional skipping of the test method')
    def test_skip_unconditional(self):
        self.assertTrue(True)

    @unittest.skipUnless('-smoke' in sys.argv,\
                         'Skipping the smoke test')
    def test_skip_unless_conditional(self):
        self.assertTrue(True)

    @unittest.skipIf('-quick' in sys.argv,\
                     'Skipping a time consuming test')
    def test_skip_if_conditional(self):
        self.assertTrue(True)

if __name__ == '__main__':
    # don't pass the args to unittest module
    try:
        sys.argv.remove('-quick')
    except ValueError:
        pass

    try:
        sys.argv.remove('-smoke')
    except ValueError:
        pass

    unittest.main()

The test test_skip_unconditional is skipped all the times. The test test_skip_unless_conditional is run only if the unittest is invoked with -smoke option while the test test_skip_if_conditional is skipped if the unittest is invoked
with -quick option.

Here's the result of running the code above:

$ python sample_tests.py -v
test_skip_if_conditional (__main__.TestSample) ... ok
test_skip_unconditional (__main__.TestSample) ...
skipped 'Unconditional skipping of the test method'
test_skip_unless_conditional (__main__.TestSample) ...
skipped 'Skipping the smoke test'

-------------------------------------------------------------
Ran 3 tests in 0.000s

OK (skipped=2)

As you can see from the result, it shows how many of our tests were skipped and if the test was successful or not. Apart from these commonly used decorators, the unittest module has more and equally useful ones you should check out.

Since discovering Python in the last couple of years, I continue to be blown away at how flexible and refreshing it is to program in a language as cool as this. Unlike Java and other languages, testing modules come as default with your standard Python installation. Apart from this default testing module, you might want to see another one. Pytest.org provides another awesome testing framework that is quite easy to use. The site has a huge documentation to get you started - so check that sites out to learn how to do more with testing your Python code.

But if like me you prefer not to download additional testing framework, then check out Unittest tutorial on Python site for more on how to write Python test code.

Monday, June 13, 2011

My Experience Learning A New Programming Language

Since I left university several year ago, I have been programming heavily in Java and Python. In fact, my main language right now is Python. I have talked really well about it in this blog; and how I got into it in the first place.

If you came through any sort of university route, you will have been taught Java as well during your time there. But as you get into the industry proper, it soon becomes clear that you need more than Java to compete. You need more than just one programming language under your belt to get you anywhere as a software professional. What you learnt as part of your course is nothing compare to what you will be faced with in your day job. So, that's why it is important to have a good idea of what it takes to succeed as a software professional.

One of the best qualities of a professional software developers is the ability to adapt, learn and use the right tool or language for the task in hand.

We recently started working on a Windows-based project and we were all give a copy of Beginning C# Object-Oriented Programming to get us up to speed with C#. Although I have been programming for as long as I care to remember, I had never do any Microsoft Windows based development at all. Most of my work have been on Linux or Mac-OSX which will make this project a nice opportunity to explore Windows proper.

I spend the weekend on this Beginning C# Object-Oriented Programming and was surprised to see how easy it is to work with the .NET framework. If you already know Java and other Object Oriented programming, you can easily skip some of the chapters in this book. The first few chapters cover the logic and intro into .NET programming while the rest move deeper into designs along with more than 30 fully hands-on activities, you'll discover how to transform a simple model of an application into a fully-functional C# project, including designing the user interface, implementing the business logic, and integrating with a relational database for data storage. Along the way, you will explore the .NET Framework, the creation of a Windows-based user interface, a web-based user interface, and service-oriented programming, all using Microsoft's industry-leading Visual Studio 2010, C#, Silverlight, the Entity Framework, and more.

I totally recommend this book if you are getting into Object oriented development for C# and .NET. I didn't think I would like it, but was blown away at the pace, content and style of the writing. You won't be surprised to learn that the author, Daniel Clark, is a trainer.

Wednesday, June 08, 2011

Pro Python by Marty Alchin - Book Review

Pro Python - This is one of those books you need to really spend time on to seriously appreciate what a great technical book should be.

I received this book a while ago, other than the quick flip through the chapters, I didn't spend time reading it until now. I bought it during a project we were working on and needed something that would give me real practical ways on how to use Python. Most of the books I started with only touched on the basics as listed in the free Python book.

But Pro Python is entirely different. It contains one of the full description of decorator patterns in Python I've seen in any books. Despite spending countless hours on the web, no one actually explained those patterns. It might be that they don't know it or can't be bothered to go that deep. That's exactly where this book shines - it addresses some of the topics you will find useful for real life projects like the credit card processing application we were working on.

Despite being a pro book, it breaks down advanced topics into basics, functions, classes, meta programming, and includes distribution, not always covered by other texts.

This book does more to explain the Python mindset needed for clear, concise code, than some of the explanations I have read that seem to favor dictating a “Python Way” to the reader. Therefore, once you have learned Python basics, this book is a must for your library.

Bon Apetit!

Sunday, June 05, 2011

Western Digital My Book Essential 3 TB USB 3.0/2.0 Desktop External Hard Drive

My Book Essential 3 TB
I've been working with computers since 1994, back when there were no personal or micro-computers. Back when a 300 baud modem was hot stuff. My first 60MB hard drive cost $600 (back when $600 actually meant something) and measured about a foot long or more, about 8 inches high and six inches wide. So you can imagine my delight when this little 2TB drive showed up. It's no more than a tenth of the size of that first 60MB hard drive. Imagine, two thousand gigabytes.

There's an old saying in computing (or at least those old enough to remember it) that, no matter the size of your hard drive, you'd only have about 1MB of free space. Well, not no more. Given the performance of our other Western Digital drives, I'm pretty confident that the My Book drive will last until, well, until we don't need to preserve our professional, historical files anymore.

Now, before I buy things like terabyte drives or printers or laptops, I always check PC Magazine's Editor's Choice collection, and this one was highly recommended. Its speed, size, and simplicity make it a real standout. Furthermore, we've been using Western Digital's drives for over ten years and have been very pleased with them.

Unfortunately, though, Robin's Rule #2 is: all drives fail eventually, as do computers. (Robin's Rule #1 is: never pass a law you can't enforce, but we'll skip that one here.) My sturdy old Pentium 4 Micron computer is finally dying, after putting in several years of hard service, so it's time to move on to the laptops, especially now that we're retired and I'm no longer doing interface or other design work that really does need a large monitor. And moving to the laptops means it's time to transfer all our historical, professional data off the old machines, which is why I bought the My Book drive.


The real beauty of the Western Digital My Book isn't just its thundering capacity, it's the size and portability. Using a simple USB cable, I can move my main development data from one computer to the next in less than five minutes (Gee, just like the old days of moving SCSI drives on the Macs). So now every one of our computers with a USB port can become my main development and writing computer. Just as soon as I transfer that 1.5GB of old emails from clients and contact information for everyone I know (I used to use Outlook Express, but now I just let Yahoo take care of the mail), and things like my book-selling database files. The total data transfers have now taken up barely a fraction of the My Book's space. Out of a readable 1.81TB, I still have 1.78TB left. And that represents over fifteen years of developing database applications for clients like California state agencies and medical research projects.

Meanwhile, the My Book drive just sits quietly in the background, taking up almost no space and storing our entire professional history of database development. Yes, it's a ridiculously huge drive for a small company, but all those historical files are critical and, what with the recent tornado warnings (tornadoes in California? Really? Weird.), it's nice to know that all I need to do is unplug this one little drive and our critical data is safe. Or, at least, it will be safe just as soon as I finish transferring the data from the other computers sitting around here. That's an awful lot of reassurance for about $130.
Related Posts with Thumbnails