Archives For Web

I’m back to finding alternatives to the use of Java. Oracle is working to increase license collections on Java big time starting this year. I loath Oracle and all things Oracle, and the fact they now own Java and have gone after licensing fees for Java means, for me, that I have come to loath Java equally. It is for this reason I’ve once again flip-flopped toward finding and using any and all alternatives to Java on every platform I work with. An excellent example of an alternative is the image burner application Etcher from resin.io.

Etcher ticks a number of key boxes for me:

  • It can safely copy a Linux image from an image file (iso, img, etc) to a USB drive or SDHC device.
  • It can work on Windows, Linux, or macOS. In this example I tested it on macOS Sierra.
  • It’s open source and available via github.
  • It’s based on Electron, using CSS, HTML, and JavaScript.
  • I can use it to copy my Raspberry Pi images to micro SDHC cards simply and reliably on my MBP.

That last bullet is what makes it a full keeper for me, as well as the tool I now point novices towards who want to work with the Raspberry Pi and want to create their own micro SDHC cards. It is absolutely as simple as starting the application, pointing it towards the image, and then plugging in the device to be flashed. Etcher finds the device automatically, making it dead simple to click the button and start the image copy to the device. No more tricky and down-right dangerous CLI dances with mount, umount, and dd.

Other Electron-based applications I now use are Atom, the editor, and Slack. There’s a whole bunch more out there, and the tooling to write even more is available where-ever there’s tooling for writing web applications. Java isn’t going to die anytime soon as it has a lock on a lot of legacy software. But that’s the same formidable block that Microsoft Windows posed back in the day, and we’ve seen where Microsoft is today, especially in mobile. Rather than complain about how bad Oracle and Java have become, my energy would be better spent promoting Electron and other foundational products and tools as better solutions than Java, even Java 8. It really is time to move on.

The internet all too often serves as a huge amplifier of negative criticism. So-called social media influencers will decide, for whatever reason, that ‘X’ is bad for ‘Y’ reasons, at which point their followers (human and bot) mindlessly echo and amplify the influencers’ bad review. To make matters worse one influencer will influence other influencers, sending out negative reviews like a rapid rolling contagion across the web (the piling on effect). I’m seeing it happening in real time to Apple (“Apple is boring now; Apple has forgotten simplicity; etc”). I’ve seen this happen to too many good products, one of which is Firefox. The problem with Firefox is that this kind of mindless criticism has adversely affected Firefox usage across the web, driving down its overall usage numbers. Being contrarian I decided to download Firefox 46.0.1 and give it a whirl on my MPB.

The application is extremely easy to download and install on the Mac. Once downloaded, you single click the Download folder in the Doc, single click the DMG file to start the load, and then just drag and drop the Firefox app into the App folder. Extremely simple, foolproof, with just enough control to let you make that final installation decision.

Once “installed” Firefox starts up like any modern browser should on this platform and goes to work. During first time startup Firefox will ask if you want it to import other browser’s data it finds on your system. It asked me about Safari and Chrome, but interestingly enough, not Vivaldi. I chose to have it import all my Chrome links and data. It was supposed to also import my login passwords that I have for certain sites, but I went to one (my WordPress blog) and I still had to log in with username and password. Not such a big deal, but it’s interesting none-the-less.

Operationally it’s as fast and smooth as you’d like, and no different than any of the other browsers I currently run on my MBP. I will say that the MBP I own is a mid-2015 15 inch with a 2.8 GHz i7, 16GB of DRAM, and a 1TB SSD. On this platform nothing is truly slow. But it is nice to see applications that are designed and compiled to be as performant as reasonably possible. That’s what I find with the current Firefox, a reasonably performant web browser, on par with Vivaldi, and faster than Chrome.

There are several reasons for me to follow Firefox. The first is that Firefox does not carry a copy of Flash around like Chrome does (Vivaldi appears to not have that either). The second is that Firefox looks to be a target platform for Rust language development, Rust being another Mozilla Foundation project. According to the Rust blog:

Second, there’s Mozilla. They’ve long been developing Servo as a research browser engine in Rust, but their first production Rust code shipped through a different vehicle: Firefox. In Firefox 45, without any fanfare, Rust code for mp4 metadata parsing went out to OSX and 64-bit Linux users; it will hit Windows in version 48. The code is currently running in test mode, with its results compared against the legacy C++ library: 100% correctness on 1 billion reported executions. But this code is just the tip of the iceberg: after laying a lot of groundwork for Rust integration, Firefox is poised to bring in significant amounts of new Rust code, including components from Servo—and not just in test mode.

I have a personal interest in both Rust and Google’s Go language, as well as a renewed interesting in C++ via C++11 and C++14 standards. The fight between greedy Oracle and Alphabet/Google over the use of Java in Android has finally pushed me off my metaphysical rear to find, and use, anything but Java. We were warned about the non-free nature of Java over a decade-and-a-half ago, and I chose to shrug it off. Now I’m promoting every language alternative to Java I can comfortably support, as well as the product built with these languages. If you want to change the status quo for the better then you have to support that change every way you can. Installing, running, and writing about this new Firefox is an important part of that.

I’m not the only one intrigued by the latest Firefox. Infoworld has an article titled “10 things we love about the new Firefox browser.” I don’t normally promote any of the so-called technology blogs, but this one caught my eye because it’s on these tech blogs you used to find reasons not to use Firefox.

It’s tough to provide a deep review of any software product after its immediate installation. This is going to have to be one of those long-term intermittent style reviews of the browser. It’ll be interesting, as it appears on first blush that Vivaldi and Firefox are the two most competitive browsers on my MBP at the moment, with me spending the lion’s share of browser use on Vivaldi. The browser is still a vital part of the web, and the pace of development in this area seems to stepped up rather nicely. I’m willing to support that effort, at the very least by using and testing. Here’s to Firefox’s continued successful development going forward.

Since I’m on the subject of rejecting cultural “norms,” let’s talk about Facebook. Lots of folks have their knickers in a knot over Facebook’s behavior these days. The latest uproar is how Facebook is supposedly blocking outside conservative news from its trending topics. One of oh so many uproars, going back to the early days when Facebook was changing how it shared your private personal information with the rest of the world.

I’d get all hot and bothered too, except I’m not on Facebook. I haven’t been on Facebook for the last five years. That doesn’t mean I’ve never been on Facebook; I’ve been on Facebook not once, but twice. The first time was when it was new and my former company sent out an email that we should “study” social media platforms like Facebook and Twitter. So I went right out and signed up for both. After about a year I deleted my Facebook account, swearing I’d never go back. But I’m weak, and sometime about a year-and-a-half later I was back in, ostensibly to keep up with my children and close family members.

That second sign-up, unfortunately, wasn’t meant to be. I learned that no matter how much your children love you, they don’t like their parents as Facebook friends. And I certainly understand that. It was a brouhaha over the Affordable Care Act, a.k.a. Obamacare, between my oldest daughter and my sister, followed by histrionics between me, my parents, and my sister, that convinced me that Facebook wasn’t any good for that either. So I deleted that second account and I haven’t been back since.

It’s as this point I could launch into a sarcastic bombastic diatribe against the evils of Facebook. But I won’t. That’s because:

  1. No body held a gun to my head and forced me to sign up to Facebook. Either time. I signed up willingly.
  2. No money changed hands between me and Facebook to be a part of Facebook. It was all free. Granted, the real cost was mining my personal information and web habits that were sold to third parties that actually paid for my access…
  3. Nothing was stopping me from leaving, except laziness and stupidity on my part. Once I gained some degree of knowledge about what was happening I left.

There are people who like Facebook, who literally live on and by what happens on Facebook. They’re happy and I’m happy they’re happy. But Facebook isn’t for me, and I’ve moved on. Maybe a lot more folks, especially those doing all the vociferous complaining, should do the same.

Don’t know what happened, but when I went to sling out a few truly epic tweets I ran slap into this big blue page. Don’t know when something went technically wrong, so I have no idea how long it was wrong. I tried twice over a 15 minute period and got this message both times. Third time was the charm, about 30 minutes after I first came across the message. It’s been a very long time since I saw this. I can’t remember when it last was up, only that it was. So let this little post be another small marker on the Information Superhighway that nothing on the Web is ever perfect.

It’s been a while since I did anything with MongoDB, a NoSQL (Not Only SQL) open source database. My MongoDB rad skills[1] had gotten a little rusty as a consequence. So I moseyed on over to the MongoDB download site, grabbed a zipped up Windows x86-64 copy, plopped it down on my machine, and then started to follow the directions to “Building Web Applications with MongoDB: An Introduction.”

It’s a great little presentation, but it has a few little quirks that this posting is meant to smooth over. They are:

  1. His presentation is on Mac OS X. This update is for Windows 8.1 Update 1 64-bit.
  2. This update contains the full source code to the three web application files, with a few minor corrections.
  3. This update contains a MongoDB console correction.

This update is preparation to get everything set up on Windows 8.1 before running the presentation. When you run the presentation it will go a lot smoother for you. And you should run the presentation to get the full benefits of learning about MongoDB. But first the software we’ll need to install:

Software Version
Python 2.7.8
pymongo 2.7.2
bottle 0.12.7
MongoDB 2.6.4

Please note that these are the versions as of the time this post was published. If you come across this post at some point in the future, they may be different (i.e. higher).

First let’s install Python and the infrastructure tools for the MongoDB Python driver and web infrastructure you’ll need to run the presentation.

  1. Pick up the Python software from ActiveState’s ActivePython download page. Make sure to select a version 2.7 Python. Pick the 64-bit MSI installer, run the installer, and take the defaults. It will put all the binaries and tools into C:\Python27.
  2. After the Python installation open a command shell and cd into C:\Python27\Scripts. There you’ll find easy_install.exe and pip.exe. You can use either tool to install pymongo and bottle, but it’s easier to use easy_install. For pymongo type “easy_install pymongo” followed by “easy_install bottle”.

Next download the MongoDB database software from the MongoDB download page. Select the 64-bit zip file. What follows is how I have my sandbox set up for this. You can change it to suit your environment if you want.

  1. Create a local sandbox area. Mine is C:\Java (an historical artifact).
  2. Unzip the MongoDB zip file into C:\Java. My unzipped MongoDB application is located in C:\Java\mongodb-win32-x86_64-2008plus-2.6.4
  3. Create a directory structure for the MongoDB data store. Mine is C:\Java\data\db
  4. In the C:\Java\mongodb-win32-x86_64-2008plus-2.6.4\bin folder create a batch file called runmongo.bat
  5. In that batch file put the single line ‘mongod –dbpath C:/Java/data/db’. Now you can double click it in the file explorer and start up MongoDB pointing to where it should place all its data files.

Finally create a sub work folder to hold the application file. Mine is C:\Java\MongoDB. Place the following three files into that location. I use the MongoDB subfolder just to keep things straight, but you could call it Fred and it would still work. What follows are the three files to copy:

import bottle
import pymongo
import guestbookDAO

#This is the default route, our index page. Here we need to read the documents from MongoDB.
@bottle.route('/')
def guestbook_index():
    mynames_list = guestbook.find_names()
    return bottle.template('index', dict(mynames = mynames_list))

#We will post new entries to this route so we can insert them into MongoDB
@bottle.route('/newguest', method='POST')
def insert_newguest():
    name = bottle.request.forms.get("name")
    email = bottle.request.forms.get("email")
    guestbook.insert_name(name, email)
    bottle.redirect('/')

#This is to set up the connection.

#First, set up a connection string. My server is running on this computer, so localhost is OK.
connection_string = "mongodb://localhost"
#Next, let PyMongo know about the MongoDB connection we want to use. PyMongo will manage the connection pool.
connection = pymongo.MongoClient(connection_string)
#Now we want to set a context to the names database we created using the Mongo interactive shell.
database = connection.names
#Finally let our data access object class we built, which acts as our data layer, know about this.
guestbook = guestbookDAO.GuestbookDAO(database)

bottle.debug(True)
bottle.run(host='localhost', port=8082)

File: index.py

 

import string

class GuestbookDAO(object):

#Initialize our DAO class with the database and set the MongoDB collection we want to use.
    def __init__(self, database):
        self.db = database
        self.mynames = database.mynames

    def find_names(self):
        l = []
        for each_name in self.mynames.find():
            l.append({'name':each_name['name'], 'email':each_name['email']})

        return l

    def insert_name(self, newname, newemail):
        newdoc = {'name':newname, 'email':newemail}
        self.mynames.insert(newdoc)

File: guestbookDAO.py

 

<!DOCTYPE html>
<html>
    <head>
        <title>Welcome to MongoDB!</title>
        <style type="text/css">
            body { font-family: sans-serif; color: #4f494f; }
            form input { border-radius: 7.5px; }
            h5 { display: inline; }
            .label { text-align: right; }
            .guestbook { float: left; padding-top: 10px; }
            .name { width: 100%; float: left; padding: 3px; }
            .wrapper { padding-left: 25px; padding-top: 20px; }
        </style>
    </head>

    <body>
        <div class="wrapper">
            <h1>Welcome To MongoDB</h1>
            <div class="guestbook_input">
                <form method="post" class="form" action="/newguest">
                    Name: <input type="text" name="name"/>
                    Email: <input type="text" name="email"/>
                    <input type="submit" value="Add Guest"/>
                </form>
            </div>
            <div class="guestbook">
                <h3>Guests:</h3>
                %for name in mynames:
                <div class="name">
                <h5>Name:</h5> {{name['name']}},
                <h5>Email:</h5> {{name['email']}}
                </div>
                %end
            </div>
        </div>
    </body>
</html>

File: index.html

 

Copy these three files into C:\Java\MongoDB.

Go to the MongoDB presentation and follow along. When it comes time to start MongoDB double click the startmongo.bat file in the file explorer. When it comes time to start the MongoDB shell, double click mongo.exe. When it comes time to run the web application in C:\Java\MongoDB (comprised of those three files you should have copied there) open a command prompt, cd to C:\Java\MongoDB, and type ‘python index.py’ and hit return. Then follow the rest of the demo.

Note that when the demo talks about deleting records in your web application’s database, you should type ‘db.mynames.remove({})’ instead of ‘db.mynames.remove()’. MongoDB has advanced enough from the version used in the demo to cause some minor annoyance if you follow the speaker’s directions exactly.

[1] I guess I’m an old fart; I refuse to spell the plural of skills with a ‘z’.