27Jul/14
Lucy

Lucy

I saw Lucy this weekend, at the Marcus Saukville cinema.  Lucy (played by Scarlett Johansson) is tricked into delivering experimental narcotics to an international drug lord (played by Min-sik Choi).  She is then forced to mule it back to the US.  While doing so, she is accidentally exposed to it.  The drugs trigger an extraordinary reaction in her.

I was honestly expecting the storyline to go in a different direction.  It was a very good movie.  I can see buying it once it’s available.  I would recommend it.

27Jul/14
Wayback Machine Logo

Use the Wayback Machine to archive your site

Tell the Wayback Machine to save your site right nowIf you do not already know, the Internet Archive‘s Wayback Machine is a service that crawls the internet and saves a cache of websites.  This provides the ability to look at what a website used to look like.  The problem is that smaller sites would only get crawled occasionally.  The service is operated by a non-profit and they focused their limited resources on the most popular sites.

Well, now you can manually trigger a crawling of your website.  Just look for “Save Page Now” on the website.

24Jul/14
Transformers: Age of Extinction

Transformers: Age of Extinction

This past weekend, I saw Transformers: Age of Extinction at the North Shore cinema.  It is the forth movie in this series.  This movie takes place five years after the last one.  The autobots are being hunted by an alien bounty hunter and the US government.  They are forced to join up with a failed inventor (Mark Wahlberg), to survive.

I had only seen fragments of the first three movies, but that does not matter.  This one had an all-new cast.  It is definitely not going to win any awards but it was very entertaining.  The fight scenes were well done.  Kelsey Grammer as a villain was amusing.

It is not necessarily worth the price of a ticket but it was not a bad movie.  I would recommend waiting for it to come out on blue-ray.

22Jul/14
CouchDB Logo

CouchDB: How to enable CORS in CouchDB

I was playing around with consumption of a CouchDB JSON feed when I received the familiar “Cross-Origin Request Blocked” error.  The question is, “How do you enable CORS in CouchDB?”

If you open the ‘Configuration’ tool, you will find ‘enable_cors’ under ‘httpd’.  You want to change that value to ‘true’.

Enable CORS - CouchDB - Part 1

 

Next, if you scroll down to the bottom of the page, you will find an ‘Add a new section’ link.  You want to click on that and add an ‘origins’ option with the value of ‘*’ in the ‘cors’ section.  You can set the ‘origins’ value to an actual URL but this will enable CORS for everybody.

Enable CORS - CouchDB - 2

 

I would like to give a ‘tip of the hat’ to RichITExperience for having this answer.  It looks like nobody else had any good info about this.

 

14Jul/14
CouchDB Logo

CouchDB: Requiring users of your database be valid users

So, you just created a CouchDB database, added a user to it, and want access to be limited to that user?  There is a simple way of doing this.  Let’s use a previous example, for this demo.

As you can see below, by default, you do not need to be authenticated, in order to interact with a database.

Secure Couch DB 1

 

You can use the “Configuration” tool, on the right sidebar, to do that.  If you look under “couch_httpd_auth”, there is a boolean called “require_valid_user”.  By default, the value is “false”.  You can change that to “true”.

Secure Couch DB 2

 

Once the value is set to “true”, it will require you to do an http authentication for your requests.

Secure Couch DB 3

 

This is definitely an unrefined, blunt way of securing your databases.  It works, though.

11Jul/14
CouchDB Logo

CouchDB: Creation, population, and querying of a DB

If you are like me, you probably have not had much of a reason to use NoSQL but you have been interested in it.  I recently decided to check out CouchDB.  CouchDB is an Apache project that was created in 2005 by Damien Katz.  CouchDB is interesting in that it stores your data with JSON documents and allows you to query via HTTP.  This means that CouchDB provides it’s own web service.

For my tests, I used Iris Couch.  Iris Couch is a free CouchDB hosting service.  CouchDB offers a web-based administrative console called Futon.  Once I created my Iris Couch account, I opened Futon.  The first time you open Futon, you must secure your server.  By default, out of the box, CouchDB give the whole world read/write permissions.

Once you set up an administrative account, you can look at creating your first Database.

Create CouchDB 1

Create CouchDB 2

Once you create your new database, you can start creating records (aka documents).

Create CouchDB 3

Rows do not have a predefined schema, so you can really put whatever you want.  You can create each document with completely different field names, if you really wanted to.

Create CouchDB 4

For my example, I decided to store parts of my Resume.

Create CouchDB 5

With the skills section populated, the record listing looks like this:

Create CouchDB 6

So, how do you query this DB?

All records in the ‘resume_skills’ database

The record with the key ’1cbc470249c58bf6c40abd73f6001cc1′

Now, these aren’t the easiest ways to view the database.  How can we make this nicer?  We could create view.

Create A View

Create A View 2

Views in CouchDB are done purely with JavaScript.  With the emit() function, the first parameter is the key and the second parameter is the value.  In the above example, ‘Name’ is the key and the entire record is the value.  You can save the view for later use.

Create A View 3So, now that we have a ‘all_skills’ view, how do we query it?

JSON for the view

So, what if we only care about my ColdFusion experience?

JSON for the query

This technology is cool for a number of reasons.  The reason that immediately grabs me is that you don’t need to write any server-side code to create a JSON API.  CouchDB does it for you.

06Jul/14
Snowpiercer

Snowpiercer

I saw this yesterday at the AMC Mayfair 18.  It is a Korean-American science fiction action film, based upon a French graphic novel.

In the story, there is a failed global-warming experiment that plunges the earth into a second ice-age.  The only remaining life, on earth is aboard a train called the Snowpiercer.

The story begins 18 years into the train continually circling the earth.  A class system has developed aboard the train and the passengers in the back of the train formulate a plan to fight their way to the front of the train.

This movie got my attention because of the very unique storyline.  The fight between classes are something that has been covered in movie after movie.  This is the first movie that I can think of that does so in this way.  You have to experience all of civilization, in order to get from one end of the train to the other.

I can see this becoming a cult classic, very easily.  It’s a great movie but it doesn’t have a very wide distribution.  I was only able to find it in one theater in Milwaukee.  If you can find it, I would suggest seeing it.

06Jul/14
PHP Logo

PHP: Using PDO to insert and update data

Previously, we looked at how to read data from a MySQL database, using PDO.  So, how do you add records and update them?

Let’s start with how to add a record

<?php

	// What are we inserting into the database table?
	$FirstName = 'Steve';
	$LastName = 'Ollinger';
	$Username = 'sollinger';

	// Create a DSN for MySQL 
        // (Syntax: 'mysql:host=[server];dbname=[database]')
	$MySQLDSN = 'mysql:host=localhost;dbname=TestDatabase';

	try {
		// Create a new (MySQL) PDO object 
                // (Syntax: 'PDO([DSN], [UserName], [Password]')
		$db = new PDO($MySQLDSN, 'TestUser', 'TestPassword');
		// What is your intended query?
		$sql = 'insert into users 
                        (vcFirstName,vcLastName,vcUsername) 
                        values (:FirstName,:LastName,:Username)';
		// Prepare the statement
		$query = $db->prepare($sql);
		// Execute the statement
		$query->execute(array(':FirstName'=>$FirstName, ':LastName'=>$LastName, ':Username'=>$Username));

		// Store any resulting errors
		$errorInfo = $db->errorInfo();
		// If there were any errors, assign them to the error variables
		if (isset($errorInfo[2])){
			$error = $errorInfo[2];
		}

	} catch (PDOException $e) {
		// Catch any PDO exceptions
		$error = $e->getMessage();
	}

	// Did an error occur during the above operation?
	if (isset($error)) {
		// Display the error
		echo $error;
	} else {
		// Indicate that all went well
		echo 'OK';
	}

?>

As you can see, above, it looks very similar to our demo for ‘Using PDO to query a database’.  There are a few new things, though.  We are using prepare() to get a statement object.  We then use execute() to execute the prepared statement.

So, now that we have added a new record, how do we update a preexisting record?  As you would expect, you can use the same syntax as above but let’s check out an alternate syntax.

<?php
	
	// What is the new data for Steve's record?
	$FirstName = 'Steven';
	$LastName = 'Ollinger';
	$Username = 'ollinger';
	// What record are we updating?
	$id = 6;

	// Create a DSN for MySQL 
	// (Syntax: 'mysql:host=[server];dbname=[database]')
	$MySQLDSN = 'mysql:host=localhost;dbname=TestDatabase';

	try {
		// Create a new (MySQL) PDO object 
		// (Syntax: 'PDO([DSN], [UserName], [Password]')
		$db = new PDO($MySQLDSN, 'TestUser', 'TestPassword');
		// What is your intended query?
		$sql = "update users set vcFirstName=?,vcLastName=?,vcUsername=? where intID_pk=?";
		// Prepare the statement
		$query = $db->prepare($sql);
		// Execute the statement
		$query->execute(array($FirstName,$LastName,$Username,$id));

		// Store any resulting errors
		$errorInfo = $db->errorInfo();
		// If there were any errors, assign them to the error variables
		if (isset($errorInfo[2])){
			$error = $errorInfo[2];
		}

	} catch (PDOException $e) {
		// Catch any PDO exceptions
		$error = $e->getMessage();
	}

	// Did an error occur during the above operation?
	if (isset($error)) {
		// Display the error
		echo $error;
	} else {
		// Indicate that all went well
		echo 'OK';
	}

?>

I like the first syntax more than the second.  There is less likelihood of making a dumb mistake.