Category Archives: software

Ubuntu wireless/WiFi connection does not work

Ubuntu is a very popular Linux operating system which has many functions that are equivalent to those provided by Windows, such as web browsing, playing music and videos, and support for office applications like writing letters and spreadsheets.  Ubuntu and several other Linux operating systems are free to use, so they can give new life to old computers.  Now that it is possible to get a new laptop for less than $300 dollars, it does not make economic sense to take for repair a laptop with a crashed hard drive and then spend about $200 dollars more to buy a Microsoft Windows operating system and Microsoft Office.  The cost of the repair plus the software will exceed the cost of a brand new computer, but it would be a shame to throw away such a piece of technology if it can be reconditioned cheaply.  The smart thing to do is to replace the hard drive by yourself and install a free Linux operating system that will perform all the functions of the old computer.

This is exactly what I did with a Sony VAIO computer with a crashed hard drive.  Ubuntu 14.04 installed without any problems and I was able to network the VAIO computer with a Windows computer using a wired Ethernet Local Area Network (LAN).  However, when I disconnected the Ethernet cable and tried to connect to the network wirelessly, Ubuntu could see the WiFi access point, but it could not connect.  I went through the Ubuntu Wireless Troubleshooting Guide, but none of the suggestions worked.

Finally, I came across a blog where one user said that he had solved this problem by using a USB wireless adapter.  I happened to have such an adapter that I had used on a Windows 95 computer a long time ago.  I plugged it into the USB port of the Ubuntu machine, and lo and behold, the connection worked, but only at 54Mbps which was the rate limit of the old wireless adapter.  I went back into the Ubuntu wireless configuration panel to see what the difference was between the USB wireless connection that worked and the one of the built-in wireless connection that did not work.  I copied the configuration, and everything worked fine, but at a higher speed.  Below is the configuration that worked for me.  The Ubuntu installation had originally set the WEP index to 2 and I had to change it to 1.   It was a simple change, but it was crucial.

Solitaire Game in JavaScript

Computer hacking has increased in recent years.  Criminals can profit from the personal and financial information stolen from the victims they have hacked.  In some cases, weaknesses in Java Applets have been exploited to infect computers with malware.  Web browsers now warn users of the potential risk.  The following discussion describes the differences between Java, Java Applets and JavaScript.

Java is a general programming language that can run on Windows, Linux or Mac computers regardless of computer architecture.  This versatility is accomplished by converting the Java computer programs into bytecodes that are interpreted by a virtual machine.  The Java Virtual Machine (JVM) is a computer program tailored for the specific hardware and operating-system platform.  When you download Java software, the package contains the JVM and Java Plug-in software that enables browsers to execute Java Applets.

A Java Applet is a small application written in the Java language and stored as bytecodes.  When a browser encounters a web page containing a Java Applet, the browser uses the Java Plug-in to decode the instructions indicated by the applet.  The result is usually an interactive web page that the user can use to play a game or perform calculations.  Weaknesses in the web browsers can be exploited by malicious Java applets, and for this reason some mobile browsers do not run Java applets at all, or they issue a security warning that asks for confirmation before allowing Java applets to be executed.  The warnings may discourage users from using particular web pages even when they pose no danger. It is possible that in the future, browsers will not run Java Applets at all.

JavaScript is an interpreted computer programming language that is used by web browsers to interact with the user and control the display of the web page. Except for a similarity in the name, JavaScript is not related to the Java programming language.  Although JavaScript can have some security problems, it does not have the vulnerabilities of Java Plug-ins.  The use of JavaScript is now ubiquitous in many web applications such as Gmail and Google Maps that use Ajax (Asynchronous JavaScript and XML).  The following links let you compare the implementation of a FreeCell Solitaire game implemented as a Java Applet and as a JavaScript application.

FreeCell Solitaire Java Applet

FreeCell Solitaire in JavaScript

Flash Player spyware in your computer

The video camera and microphone of your computer can be controlled remotely by web sites if you installed the Flash player using the default settings. This is a great invasion of privacy because most computer users do not know how to change the settings to avoid this type of intrusion. In addition, the Flash player allows web sites to store information on your computer that can be used to track your activities on the web.

Adobe’s Flash Player is used extensively on web pages to provide dynamic web content. Web sites like YouTube rely on the Flash Player or Shockwave Flash plugin to display movies and video clips on a user’s terminal. In January of 2010, Steve Jobs announced that Apple would not support Flash because it was so buggy that it caused most of the crashes in Mac computers, but the Flash player is a very common component of Windows computers. Beginning with Flash Player 10.1, the Flash Player integrates with web browsers to automatically clear stored data in accordance with the browser’s private browsing settings.

When installing Flash, the first concern is that the download screen has a checkbox for McAfee security scan that is checked by default. If you click the “Download now” button without unchecking the box, you are going to end up with extra software in your computer that you may not want and will have to uninstall later.

Once you install the Flash player, you have to set the privacy settings. Open a web page like YouTube.com that uses Flash and right click on a Flash object. A pop-up panel like the one below appears. Click on Global Settings…

If you don’t want to be tracked through the Flash player, click on the option to block all sites from storing information. The interface may give you a warning that some sites may not work properly. Click OK to set your choice.

Next, click on the “Camera and Mic” tab and set the option to block all sites from using the camera and microphone. If you will only be using the Flash player to watch videos, there is no reason to allow any site to eavesdrop or spy on you.

The following link invokes the Flash Player settings manager for your computer with the web interface below. Needless to say, you have to go through this procedure for each computer on which you have installed the Flash player.

Global Privacy Settings panel

HTML web pages for mobile devices

The iPhone and other smart phones have become very popular because in addition to making telephone calls they can also access the Internet, play music, take photographs and record videos.  Tablets like the iPad are also increasing in popularity because they are lightweight and eliminate the need for a keyboard, but they can perform many of the functions of a computer.  Before tablets were introduced, “mobile devices” were telephones with small screens that could only handle small web pages.  Web programmers were encouraged to redirect traffic from mobile devices to a mobile subdomain containing streamlined web pages that would load fast and format data for the small screens.

Telephone manufacturers reacted to the need for accessing the Internet by introducing bigger screens with higher resolution and by developing pinch-in and pinch-out zoom gestures to make the text more readable.  The variety of mobile devices and the way in which the pixels of web pages are mapped to the screens has made it difficult to design optimum mobile web pages, particularly with the introduction of tablets with displays equivalent to a laptop or a desktop computer.

The increasing number of tablets means that it may not be appropriate to automatically redirect mobile devices to web pages for small screens.  A more practical approach is to let the user decide which format to access by providing a button such as the following that is displayed close to the top of the page for mobile devices only.


The following code sets up a non-display <div> element containing the image.  The JavaScript code that follows checks the screen width and the userAgent to allow the display of the button for screens with a width smaller than 500 pixels or for web browsers used by mobile devices.  The BMI web page (http://www.scientificpsychic.com/health/Body-Mass-Index-BMI.html) uses this code. View the page with a desktop computer and with a mobile device to see this technique in action.

<div id="mobile" style="display:none;">
  <a href="http://m.domain.com/webpage.html">
    <img src="mobile-page.gif" width="100" height="71" alt="view mobile page"/>
  </a>
</div>

<script type="text/javascript"><!--
if (screen.width < 500 || 
    navigator.userAgent.match(/Android/i) || 
    navigator.userAgent.match(/iPhone/i) || 
    navigator.userAgent.match(/BlackBerry/i) || 
    navigator.userAgent.match(/webOS/i) || 
    navigator.userAgent.match(/iPod/i) ) {
      document.getElementById('mobile').style.display = "block";
}
//-->
</script>

Standards compliance vs. cross-browser functionality

Webmaster’s Dilemma.

The World Wide Web Consortium (W3C) provides defines for coding HTML and provides a validator to check the markup of HTML and other types of Web documents (http://validator.w3.org/). The advantage of complying with the W3C standards and having error-free code is that the web page will have cross-browser compatibility, facilitate analysis of the web pages by search engines, and ultimately enhance search engine ranking.

Standards are moving targets, and web browsers face tough competition. In the past, Netscape and Internet Explorer battled for supremacy to act as the gateways of the Internet. Each of the browsers introduced unique features that gave them an advantage over their competitor, but this created chaos for web programmers who had to provide alternative code for the browsers and their different versions.

As the number of browser competitors increased, customized browser coding lost favor and there was a clamor for HTML standards. The battle was only partially won, because the browser developers still had to support old HTML coding conventions while trying to meet the majority of the new standards. Today, five browsers dominate access to the internet: Internet Explorer (IE) from Microsoft, Safari from Apple, Chrome from Google, FireFox (FF) and Opera. Both FireFox and Opera obtain revenue from Google by setting it as the default search engine.

Most of the browsers update themselves automatically when newer versions become available. Microsoft originally tightly bundled the IE browser with its ubiquitous operating system in order to get marketplace dominance, but this turned out to be a bad decision because the newer versions of the browser cannot be installed in the older operating systems. Windows XP is locked into using version 8 of IE because the browser is used to apply updates to the operating system. Consequently, versions 6 through 9 of IE are still out in the field, and the browser has lost significant usage share. IE usage was over 70 percent in 2005, but it has dropped to about 20 percent in 2012.

The HTML5 standards, which are still under development, have the potential to standardize web applications of the future. In the meantime, web developers still have to code using some of the old conventions to get the required cross-browser functionality. A case in point is the HTML5 error message for the following applet element: “The applet element is obsolete. Use the object element instead.”

<applet code=”AudioBox.class” height=”0″ name=”AudioBox” width=”0″>
<param name=”ab0″ value=”laugh.au#bark.au#meow.au#”/>
</applet>

The correct HTML5 code should be:

<object type=”application/x-java-applet” height=”0″ width=”0″ name=”AudioBox”>
<param name=”code” value=”AudioBox.class” />
<param name=”ab0″ value=”laugh.au#bark.au#meow.au#”/>
Applet failed to run. No Java plug-in was found.
</object>

Unfortunately, the object element for AudioBox.class works for FF, IE version 9, and Opera, but not for Safari or Chrome, whereas the applet element works on all five browsers. Other applets work fine when converted to the object element on the Safari and Chrome browsers, but not this particular one. There must be some subtle point of incompatibility. Hence the dilemma: 1) comply with the standards and lose support for two browsers which have a combined usage share of about 40 percent, or 2) disregard the standards in favor of code that works in the five major browsers. From a business perspective, the decision to disregard standards and support the majority of customers is easy. Perhaps later, when the specification of the HTML5 is finalized and all the major browsers are compliant, there will be a time when it will be possible to meet standards and support all users.

The convergence to HTML5 will eventually reduce web site maintenance, but the diversification of web-enabled devices, such as smart phones and tablets, is already making it harder for webmasters to serve all users with common code. The small screens of the phones require customized display formats to be useful, and these web pages are usually kept in a separate mobile subdomain and have completely different code.

Problems Coding Games with HTML5, CSS and JavaScript

Applications coded for the Adobe Flash player are ubiquitous on the Internet.  Many web sites exist only as flash implementations.  Flash provides a rich environment that can render interactive graphics and sound.  The problem with Flash is that it is controlled by a private company that cannot react to the demands of the great diversity of devices that access the Internet today.  In April of 2010, Steve Jobs wrote an open letter explaining why Apple was not supporting Flash in its line of products.  Among the reasons was that Flash does not perform well on mobile devices and that it is the number one reason why Mac computers crash.  He also suggested that Adobe should focus more on creating great HTML5 tools which are completely open and controlled by a standards committee.

In my opinion, HTML5 still has a long way to go to equal the functionality of Flash.  One of the problems that I have consistently encountered in writing web pages is cross-browser compatibility.  What works on one browser may not work in another.  The most persistent problem is providing sound to an application.  HTML5 defines the <audio> element as a standard way to embed an audio file on a web page, but of the five major browsers, only Google Chrome can play all three of the supported file formats (MP3, Wav, and Ogg).  The only way to provide audio on all browsers is to use something like the AudioBox applet, but this does not work for the 5 percent of users who turn off JavaScript to avoid advertisements.

I implemented a Sudoku game with HTML5, CSS and JavaScript to test the level of support provided by various browsers.  I found several surprises.  When adapting the JavaScript code obtained from dhtmlgoodies.com, the command to provide a hint placed a graphic box in the wrong place.  The reason was that the getLeftPos() and getTopPos() functions in JavaScript provided a value that was offset by the left and top margins specified in the <div> element with absolute position that contained the game.  The JavaScript expressions had to be modified to subtract these values.  I cleaned up the code by processing the JavaScript with javascriptlint.com and added curly brackets that were missing and removed multiple declarations of variables.

While testing locally on my Windows 7 system, I left the browser while I switched to work on another application; when I returned to the Sudoku game, the browser was frozen.  This happened for FireFox and Internet Explorer, but not for Safari.  This was not caused by buggy JavaScript code, but was the result of a missing Java applet for which Safari issued the proper diagnostic.  Once the problem was fixed, all the browsers worked properly.

Another concern is the way that browsers handle asynchronous events, such as keyboard input and mouse clicks.  It is possible that these unseen processes implement rules that are different from what a user intends.  A case in point is the ambiguity of the arrow keys.  The Sudoku game can use the arrow keys for navigation around the 9×9 matrix.  If only the game matrix is displayed and the browser does not need to use scroll bars to display the web page, everything works fine.  The user can navigate the matrix using the arrows without any problem.  However, if the game matrix is in a page with additional text that requires the browser to show a vertical scroll bar, then there is an ambiguous situation.  The game application uses the down arrow to move the cursor within the matrix, but simultaneously, the web browser interprets the down arrow as a command to scroll the web page down one line.  The result is that the whole Sudoku matrix moves when it should stay fixed.  Programmers need to use the preventDefault() function for keystrokes to avoid the unwanted browser action, but then the page can only be scrolled with the mouse.  Developing games with HTML and JavaScript requires being aware that special coding may be required depending on how the browser renders the web page.

Try the JavaScript Sudoku Game

WordPress wp-admin/install.php gives blank page

The installation of the WordPress content management system is straightforward with very clear installation instructions. The basic steps consist of 1) downloading the WordPress package, 2) creating a MySQL database and establishing a MySQL user with all privileges for accessing and modifying the database, 3) setting up a configuration file wp-config.php that identifies the database, user, and password, and 4) running the installation script by accessing wp-admin/install.php.

I wanted to install a local copy of WordPress on my Windows Vista computer to develop a WordPress theme.  My computer had the required Apache web server, PHP, and MySQL database programs.  Using phpMyAdmin, I set up the database and the user ID for the blog without problems.  However, when I ran the WordPress installation script, I got a blank page.

To get some diagnostic messages, I changed the WP_DEBUG variable from “false” to “true” in the wp-config.php file.

define('WP_DEBUG', true);

This produced the following messages:

Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\www\wordpress\wp-includes\wp-db.php on line 1037

Fatal error: Maximum execution time of 60 seconds exceeded in C:\www\wordpress\wp-includes\wp-db.php on line 1037

About one year earlier, I had a problem establishing a connection with a MySQL database from a Perl program.  The problem was finally resolved when I used the numeric IP address of the localhost instead of just “localhost”.  This same solution worked for WordPress by specifying 127.0.0.1 for my localhost in the wp-config.php file.

/** MySQL hostname */
define('DB_HOST', '127.0.0.1');  /* localhost */

My Perl programs accessing local MySQL databases look like this:

#!/usr/bin/perl
# Access MySQL database "names"
use DBI;
$database = 'names';
$hostname = '127.0.0.1';  # localhost
$port = '3306';
$dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
$user = 'user1';
$password = 'xxxxx';

$dbh = DBI->connect( $dsn, $user, $password )
|| die "Cannot connect to $database: $DBI::errstr";

$query = 'show tables;';
$sth = $dbh->prepare($query);
$sth->execute();
my $numRows = $sth->rows;  # number of rows
print "Number of Tables=$numRows\n";
while (my $row = $sth->fetchrow_arrayref) {
print join("\t", @$row), "\n";
}
print ' * * * *',"\n\n";
...

How to publish an eBook for Kindle

Amazon.com announced that the sale of electronic books for the Kindle reader surpassed the sale of printed books in April 2011. There are many reasons for the shift from print to electronic media, including the fact that thousands of books are available in electronic form. Books in Kindle format can be read on Amazon’s Kindle and also in other devices such as the iPad, iPhone, Android phone, and personal computers. The Kindle reader can store more than one thousand books and can download those books via Wi-Fi wherever you are. Kindle readers also have a built-in web browser and text-to-speech so that you can listen to your books. Paper books can’t do that!

Publishing an electronic book for the Kindle is as easy as formatting a Microsoft Word document or developing an HTML web page, but there are additional requirements for HTML. You can prepare your text and images using Microsoft Word or OpenOffice Writer and save the text as HTML in a new folder. The text can also be prepared using HTML editors such as Microsoft FrontPage or SeaMonkey Composer. Once your source material is ready, you need to format the file for the Kindle, and prepare a book cover and table of contents. These are some of the steps you need to take:

– Read the Kindle publishing guidelines. https://kdp.amazon.com/self-publishing/help
– Create an account for Kindle Direct Publishing. https://kdp.amazon.com/self-publishing/signin
– Create a book cover JPG image (600 by 800 pixels) using Irfanview, Gimp, Photoshop, etc.
– Write a short description about the book, similar to what would be in a book jacket.
– Download the free software from Amazon to build and preview Kindle books:
http://www.amazon.com/gp/feature.html?docId=1000234621

KindleGen is a command line tool used to build eBooks.  KindleGen will accept as input an HTML file or an .opf file which is an XML file that has the title of the book, the author, the location of the cover, the location of the table of contents, and the sequence in which the HTML files should be organized. The table of contents is an .ncx file also in XML format. KindleGen has a sample book with .opf and .ncx files that can be used as a guide. The KindleGen application integrates all the HTML files, the images and the table of contents to create a Kindle book file with a .mobi extension.

The Kindle Previewer can read a .mobi file and emulate how the book will display on Kindle devices. This is a useful tool to check the appearance of the book on the Kindle, Kindle DX, iPhone, and iPad.

Amazon also provides a free Kindle for PC application that allows you to read Kindle books on your PC or laptop.
http://www.amazon.com/gp/feature.html/ref=kcp_pc_mkt_lnd?docId=1000426311

You will need to decide whether you want to assign an ISBN number to your book before you submit it to Kindle Direct Publishing. The ISBN is not required by Amazon, but you may want to get one if you plan to promote your book actively. The ISBN is used by libraries and book sellers as an identification for published items. An electronic book has to have a different ISBN from a printed book with the same contents. You can get an ISBN for $125 Dollars or a set of 10 ISBNs for $250 Dollars from https://www.myidentifiers.com/ The ISBN is contained in the .opf file, so you have to obtain it before you can produce the final version of your kindle book.

If you do all the book development and formatting yourself, the cost of the ISBN is your only expense. Once you have built your book and tested it, you are ready to publish it. For Kindle books that sell between $2.99 and $9.99, Amazon will pay 70% of the revenue to the publisher. When the eBook has been accepted, it will be listed in the Amazon.com web site and will also be available in ads such as this:

Lorton meteorite ownership is disputed

On January 18, 2010 a small stony meteorite weighing 308 grams punched a hole in the roof of a doctor’s office in the Washington, D.C. suburb of Lorton, Virginia.  There was some damage to the office, but nobody was hurt.  The doctors, Marc Gallini and Franc Ciampi who were in the adjacent room, thought the noise was caused by a falling bookshelf.

The doctors donated the meteorite to the Smithsonian National Museum of Natural History, and the Smithsonian officials planned to give them $5,000 dollars in compensation.  The Smithsonian planned to display the meteorite, and the doctors wanted to use the money for the earthquake relief efforts in Haiti.

The owners of the building objected, and said that they were the rightful owners of the meteorite.  The landlords informed the museum officials that they were going to take possession of the meteorite with the objective of selling it to pay for the damage to the building.  The doctors got a lawyer to bar the museum from releasing the stone until ownership is determined. In the past, U.S. courts have ruled that a meteorite becomes part of the land where it arrives through natural causes, and therefore is the property of the landowner.  The Smithsonian is keeping the meteorite until the dispute is settled.

Recent Meteorite Impacts on the Earth

Pictures of female Body Mass Index (BMI)


I recently mentioned the interesting digital human modeling work being done at the University of Washington.

From a published video, I was able to get images corresponding to several important BMI points for a male model, but the video did not have a full range of proportions for a female going from a very thin body to a very fat body.  I contacted Professor Brian Curless at the Department of Computer Science & Engineering at UW and he kindly provided female images for BMI points corresponding to the start of anorexia, minimum normal BMI, middle normal BMI, highest normal BMI, obesity, and morbid obesity.

Although every individual is different, the pictures provide representative images of how a person with a specific BMI might look.  When you compute your BMI, you can refer to the pictures and ask yourself: “Do I really look like that?”  The answer is usually “Yes.”

Try the Body Mass Index (BMI) Calculator