Knowledge7

The Linux and Mobile Solution Provider

  • About
  • Training
  • Services
  • Clients
  • In the news
  • Blog
  • Contact Us
You are here: Home / Blog

Picks of the Week #4

You want to receive our Picks of the Week every Monday morning?

Thank you for reading the fourth edition of the Knowledge7’s Picks of the Week.

Every week, Avinash Meetoo will make you discover interesting articles and websites to help you broaden your understanding of the world of open source software and information technology in general.


How to Install a Wireless Card in Linux Using Windows Drivers
Some years ago, life was tough for Linux fans who wanted to enjoy Wifi on their laptops as drivers were only available for a few chipsets. In 2011, things have greatly changed. People have written open source drivers for quite a lot of wireless chipsets from companies such as Atheros, Broadcom, Cisco, Intel, Lucent, Marvell, Ralink, Realtek and ZyDAS and, naturally, this means that Linux now supports Wifi out of the box. But, to be fair, there remains some more obscure chipsets which do not have corresponding open source drivers where the only solution is to use existing Windows drivers using a technology known as NDISwrapper. Yes, Linux can use Windows drivers! This article explains how to do that using the latest Ubuntu Linux.

The Java Tutorials: Concurrency
When Java 5.0 was released a few years ago, most people didn’t pay attention to a new standard library called Java Concurrency Utilities. This library allows a programmer to write concurrent programs easily by providing classes such as executors, futures and concurrent data structures. Here is a simple explanation for concurrency: a concurrent program is a program with parts which execute in parallel when run on a parallel computer. Running a non concurrent program on a parallel computer is stupid. But running a concurrent program on the latest multi-core processor is nice. When a programmer writes a Java program using classes from the Concurrency Utilities, she is being explicit about which parts are concurrent. Given that all computers now are parallel, this is a good thing to do.

Why You’re a Bad PHP Programmer
PHP is an excellent programming language. It wouldn’t be used by Facebook and Wikipedia if that wasn’t the case. But, to be fair, a lot of PHP programs are written by people who do not give a lot of importance to maintenance and, consequently, their PHP programs, while running well, exhibit a lot of “smells” (a term coined by Martin Fowler). Those smells are, for example, having no comments, writing brief code instead of being clear, not following standards, etc. In other words, trying to be too clever. The thing is that we are all guilty of that. We start with a quick and dirty solution and, as soon as it runs, release it to the wild without realising the maintenance nightmare that might result. This article explains how to be a good PHP programmer.

Managing Hierarchical Data in MySQL
The relational model as used in most relational databases including MySQL is not really intended to represent hierarchies. In fact, the relational model was a replacement for the hierarchical data model as used, for example, in the venerable IMS database developed in the 60’s by IBM. Unfortunately, the real world is full of hierarchies e.g. network of people, components in a machine, our solar system, blogging and forum software, etc. and, consequently, it’s tough to model such objects using MySQL. Tough but not impossible. The idea is to use adjacency lists and/or nested sets and then write special SQL queries. This article, by Mike Hillyer, explains in detail how one can use MySQL intelligently to represent such hierarchies.

Taking the Mystery out of Scaling a Company
It’s fun to run a startup. I know. I am. But, sometimes, some startups become large and then care must be taken to scale them properly. For instance, one must be ready to “give ground grudgingly”. Things that were easy to do when there were only two people in the company become hard when there are twenty employees. Specialists are frequently needed (e.g. accountants, HR people, etc). We must make sure that people communicate properly and that people do not misunderstand each other. In fact, the decision making process also becomes more complex as head count increases. Naturally, this implies that the company needs to change some of its processes. The thing is that we don’t want to address those concerns too early or else the startup will seem sluggish. On the other hand, waiting too long is bound to cause a lot of problems in the long run. This article shows what works, when and why.

Our forthcoming training courses

  • No training courses are scheduled.

Hardware and Architecture

System administrators should monitor Linux installations on a regular basis and detect if there is any hardware anomaly. For example, performance might not be optimal or resource clashes might be happening.

The various subsystems that need to be carefully monitored are:

  • BIOS settings
  • Buses, ports, IRQs, and DMA
  • Hard drives
  • Network devices
  • USB devices
  • PCI devices

Of course, legacy devices (serial ports, parallel ports) as well as more advanced devices (like SCSI devices) also need to be monitored.

Each subsystem has its own set of commands and configuration files.

Our forthcoming training courses

  • No training courses are scheduled.

Picks of the Week #3

You want to receive our Picks of the Week every Monday morning?

Thank you for reading the third edition of the Knowledge7’s Picks of the Week.

Every week, Avinash Meetoo will make you discover interesting articles and websites to help you broaden your understanding of the world of open source software and information technology in general.


Hacker Chat: Pinboard Creator Maciej Ceglowski Talks About Why Boring Architecture is Good, and More
Writing a web application in PHP is easy. But writing one which performs well when hundreds of users are accessing it concurrently is difficult. In this article, Maciej Ceglowski, creator of Pinboard, a very well known alternative to Delicious (which got rave reviews a few weeks ago when it would seem that Yahoo! was going to discontinue Delicious), explains that the KISS principle should apply to the architecture of PHP applications too. For instance, he mentions that having adequate RAM on servers is crucial, that dedicated hardware is always better than virtualised hardware, that it is important to optimise MySQL (see next pick) and that frameworks should be used with caution.

MySQL Performance Blog
If one wants to increase the performance of MySQL, the database server needs to be properly optimised: from key runtime variables (like key_buffer_size) to storage considerations. Then the database schema needs to be properly devised while taking into account current and future querying patterns. Specific SQL queries have to be written in such a way to perform as efficiently as possible and, if this is not possible, stored procedures might need to be used. Of course, indexing is always a possibility… if used judiciously. Buffering and caching possibilities also need to be explored. In other words, optimising MySQL is not trivial. Reading the MySQL Performance Blog provides excellent insights into the difficult art of MySQL optimisation.

The Scala programming language
The Java Virtual Machine (JVM) was originally devised to run bytecodes generated by a Java compiler. But Java is a very verbose programming language and some even say that it’s not very powerful as it lacks most of the expressive constructs found in functional and scripting programming languages. Scala is a new programming language which compiles to bytecodes which then run on the JVM. Scala is 100% compatible with Java and existing Java libraries, is fully object-oriented and supports functional programming. This allows programmers to write very powerful programs in just a few lines of code. A notable example of Scala in industry is Kestrel, the message queue server which forms the core of Twitter. Due to this high profile adoption, Scala has gained the respect it deserves and some people are even starting to believe that it’s the next big thing in programming.

GitHub
GitHub is an online service which hosts software developed using the Git source control system. A source control system allows multiple programmers to work on the same software concurrently. GitHub comes in two flavours: it is free for those who develop open source software and those who want to use it to host private repositories have to pay. Git was originally developed by Linus Torvalds to ease the development of the Linux kernel. Since GitHub was launched, a number of notable open source projects have switched to it. Examples include Erlang, Hibernate, jQuery, JUnit, Mozilla Labs, Perl, PHP and Ruby (including Ruby on Rails). One of the interesting aspects of GitHub is its ‘Explore’ facility which provides insights on the most active projects and programming languages in use (right now, it’s a tie between Javascript and Ruby).

How to Start a Startup
Paul Graham is one of my gurus. He co-created Viaweb, the first ever e-commerce website, which Yahoo! acquired for $50 million in 1998. Paul then created Y Combinator with the help of some friends to provide new startups with seed capital and advice. Some notable startups funded by Y Combinator include Reddit, Dropbox, Posterous and Justin.tv. So Paul knows what he is talking about when he says that the three most important things to get right when launching a startup is to begin with extremely competent people, to make something customers actually want and to spend as little money as possible. One thing I always tell people is that it’s not normal that only few young people in Mauritius want to emulate people like Bill Gates, Steve Jobs or Mark Zuckerberg when they finish school. Maybe “How to Start a Startup” needs to be taught in Mauritian schools…

Our forthcoming training courses

  • No training courses are scheduled.

Do you want to buy great books?

Would you like to buy carefully selected American edition books on Linux, web design, PHP, MySQL and Java? And, would you like to buy them cheaper than on Amazon.com?

Now you can!

We are happy to launch our book store. Nothing fancy. No e-commerce. No credit cards. Only solid books at affordable prices which you collect the books immediately after payment (cheque or cash).

What do you think of that?

Our forthcoming training courses

  • No training courses are scheduled.

Managing State

This topic is part of our Web Application Development in Java training

HTTP is stateless.

As many applications require requests coming from the same client to be associated, web applications have the responsibility to maintain this state in a special object called a session. Fortunately, Java servlets fully support sessions.

Within a servlet, a session of class HttpSession is obtained by calling the getSession() method of the HTTP request. A session object can then be manipulated with getAttribute()/setAttribute()/removeAttribute().

After some time, a session expires. To control the lifetime of a session, the following methods are used: setMaxInactiveInterval() and invalidate().

Implementing a shopping cart

Enhance the web application developed previously so that users can add specific songs to a shopping cart. Multiple users browsing from different computers should be able to have their distinct shopping carts. Each user should be able to clear his own cart at any time.

Back.

This topic is part of our Web Application Development in Java training

Our forthcoming training courses

  • No training courses are scheduled.

Picks of the Week #2

You want to receive our Picks of the Week every Monday morning?

Thank you for reading the second edition of the Knowledge7’s Picks of the Week.

Every week, Avinash Meetoo will make you discover interesting articles and websites to help you broaden your understanding of the world of open source software and information technology in general.


Top 100 of the Best (Useful) OpenSource Applications
For some people, Linux is only for servers. For people like me, Linux is also a great desktop operating system capable of being better than anything from Seattle or Cuppertino. For the past few years, Ubuntu Linux has really made Linux easy to install and easy to use at home. The latest version is rock solid and features myriads of open source applications especially developed for home users. Here is a list of the top 100 of the best and useful open source applications from various categories courtesy of UbuntuLinuxHelp.com: audio, 2D graphics, 3D graphics, video, utilities, software development, etc. Try them. They are all free. And powerful.

Dates in PHP and MySQL
PHP is a powerful server-side programming language for building web applications. Wikipedia and Facebook are both written in PHP. MySQL is a powerful relational database. Both are open source software and, arguably, power most of the websites in existence. One relatively complex issue when using MySQL with PHP is how to transfer dates to and from the database as MySQL has no less than three ways to store them (using the DATETIME, DATE, and TIMESTAMP types). This article explores the tradeoffs between the various solutions which exist.

jQuery Mobile Tutorial: Basics
Last week, I talked about jQuery Mobile, an advanced Javascript library based on jQuery (obviously) for building mobile web applications. This week, I have just stumbled upon this interesting introductory tutorial on CodeForest, a web development and programming blog. The tutorial explains how to create a basic jQuery Mobile page, use external and internal linking and, even, how to change the theme of your application. Interestingly, the title (i.e. Basics) would imply that other tutorials will shortly follow and I’m sure they’ll all be useful for developing jQuery Mobile applications.

Cofoja: Contracts for Java
Building software is hard. And building software without bugs is much harder. One of the way to master complexity is to use Object-Oriented Programming. Objects are abstractions and communicate by exchanging messages. One way to enhance the semantics of messages is to use contracts (in the same sense Bertrand Meyer used them in his Eiffel programming language.) Cofoja is a new open source software from Google which adds contracts to the Java programming language. With Cofoja it becomes possible to enforce that, for example, a method should take a parameter within a specific range. Google uses Java for its Web Toolkit which is used, for example, for building Gmail.

PhoneGap
PhoneGap is a (yet another) library to build mobile web applications. The idea is to build the application using HTML5 and Javascript and rely on the PhoneGap API to get full access to the underlying features of the mobile phone on which the application is running like the accelerometer, the camera, geo location, contacts, notifications and storage. PhoneGap works with a lot of different smartphones: Android, iPhones, BlackBerry, Windows and Symbian. Thanks to PhoneGap, it becomes possible to build powerful mobile applications which behave and have the same capabilities of native applications without having to learn Objective-C (iPhone) or Java (Android). Life is cool. And it’s cooler when you realise that PhoneGap is open source software.

Our forthcoming training courses

  • No training courses are scheduled.

Picks of the Week #1

You want to receive our Picks of the Week every Monday morning?

Thank you for reading the first edition of the Knowledge7’s Picks of the Week.

Every week, Avinash Meetoo will make you discover interesting articles and websites to help you broaden your understanding of the world of open source software and information technology in general.


Instapaper
Instapaper is “a simple tool to save web pages for reading later” and is 100% free. While browsing, I frequently come across interesting articles that I would like to read at a later time. Up to now, I generally bookmarked the articles… and forget about them later. Instapaper allows me to collect those articles in one central place and read them when I have some free time either on my laptop or using my mobile phone. Instapaper can also print excerpts from the articles so that I can peruse them while relaxing on the beach for example. Now that we’ll be doing this Knowledge7’s Picks of the Week regularly, you have a great incentive to try Instapaper 🙂

BSD for Linux Users
Ever asked yourself the difference between BSD Unix (FreeBSD, OpenBSD, Mac OS X, etc.) and Linux? Want to know the differences between the two main types of open source licences: GPL and BSD? Always wondered how the cathedral compares to the bazaar? Read this great set of articles by Matt Fuller to understand those deep philosophical and technical differences. Matt is a BSD user and the articles are written from his perspective but they are all very well written and straight to the point. As a bonus, you’ll also learn that “Windows Causes Stupidity” and that the “Stupidity” is not an insult.

StackOverflow
StackOverflow describes itself as “a programming Question & Answer site that’s free. Free to ask questions, free to answer questions, free to read, free to index, built with plain old HTML, no fake rot13 text on the home page, no scammy Google-cloaking tactics, no salespeople, no Javascript windows dropping down in front of the answer asking for $12.95 to go away.” And that’s precisely what it is! StackOverflow has really become THE place on the Internet where programmers can find solutions to complex problems by asking those who got the same issues before. It’s much better than fishing in the dark with Google Search (now that our Web is so polluted with spam blogs and websites).

Android-Powered Smartphones
I have a confession to make: I wrote this article myself for the TechKnow magazine. But, heck, why not telling you about it? In it, I explore the world of Android-powered smartphones (like my own Google Nexus One) and try to understand how a mobile platform which was launched in October 2008 has managed to be present on HALF of the smartphones being purchased in the USA at this very moment (the iPhone is at 23%). Is that because Android runs Linux inside? Or is it because it’s open source software which can be used and modified freely by any phone manufacturer? Or is it simply because it’s the best mobile platform ever?

jQuery Mobile
Speaking of smartphones, here is the jQuery mobile framework for building mobile websites having “a unified user interface across all popular mobile platforms” (Android, iPhone, BlackBerry, Symbian, Windows, etc). jQuery Mobile is obviously based on jQuery which is pretty much the standard Javascript framework in use by millions of popular websites all over the planet. Now that smartphones are so pervasive, one cannot develop a website for desktop computers only anymore and jQuery mobile seems to be a worthy candidate framework for building mobile websites. Note that jQuery Mobile is still an alpha release (so expect things to break from time to time) but it’s exciting news nevertheless.

Our forthcoming training courses

  • No training courses are scheduled.

Become a Linux, PHP/MySQL or Java expert

In just two weeks, we will start the following MQA-approved training courses at Knowledge7:

  • Linux System Administration
  • Web Development with PHP and MySQL
  • Web Application Development in Java

A few places are still available. Do not hesitate to call Liliane or myself on 5834-9001 if you need any additional information.

Topics to be covered during the Linux course include: Linux installation and package management, Hardware and architecture, Text editing and processing, Process management and automation, User management and file permissions, the File-system Hierarchy Standard, Devices and Linux File-systems, TCP/IP networking and the X Window system. The course is designed for Linux beginners.

During the PHP/MySQL course, we will cover: semantic W3C compliant web pages, CSS frameworks, using templates and filters in PHP, the MySQL database, using sessions and cookies, parsing XML and JSON documents, file access and performance tuning. The course is designed for people who know about HTML and CSS and who wish to master server-side software development.

Finally, the Java course covers installing and configuring a servlet/JSP web container, using servlets, Java Database Connectivity (JDBC), managing state, creating JavaServer Pages (JSP), using JSP Custom Tags, using Struts actions, adding workflow with interceptors, building views and using UI Component tags. This course is designed for people who are conversant both with the Java programming language as well as object-oriented programming and who wish to master Java for web development.

Our forthcoming training courses

  • No training courses are scheduled.

Object-Oriented Principles

This topic is part of our Object-Oriented Programming in PHP training

Developing software using object-oriented principles require a programmer to have a sound understanding of a number of important concepts:

  • Object-Oriented Analysis: what is the problem to be solved?
  • Object-Oriented Design: how are we going to solve the problem
  • Object-Oriented Programming: actually implementing the solution using an Object-Oriented Programming Language

The best way to learn Object-Oriented Analysis and Design is to read

where it is shown how to use the Unified Modeling Language (UML) and Design Patterns when developing software.

A Design Pattern is a solution which experienced software developers have been using over the years when they have to solve a given type of problem. The most popular book covering the fundamental Design Patterns is:

This topic is part of our Object-Oriented Programming in PHP training

Our forthcoming training courses

  • No training courses are scheduled.

Accessing MySQL with PHP

This topic is part of our Web Development with PHP and MySQL training

PHP can access MySQL databases using a number of libraries. Two of them are mysqli and PDO, both part of standard PHP. mysqli provides functions to manipulate data in a MySQL database. PDO, as stated on the PHP website:

The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.

PDO provides a data-access abstraction layer, which means that, regardless of which database you’re using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn’t rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility.

PDO ships with PHP 5.1

The work to do is to modify the web application being written to make it save orders to a MySQL database instead of in a text file. The first thing to do is to decide upon a schema (i.e. tables and columns). The application will use PDO.

Prepared statements

In order to increase performance and security, it is advisable to use prepared statements when this is possible.

The work to do is to add to the web application a second report. This report should give, for each customer, the amount of phones bought and the cost. In case, the amount is more than 20, that customer should get 20% for this phone. If the number of phones is between 10 and 19, the customer should get 10% off.

This topic is part of our Web Development with PHP and MySQL training

Our forthcoming training courses

  • No training courses are scheduled.
« Previous Page
Next Page »

Looking for something?

Want to know more?

Get our newsletter

Discover the latest news, tips and tricks on Linux, the Web and Mobile technologies every week for FREE

This work is licensed by Knowledge7 under an Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.