Saturday, December 14, 2013

Move it on down the line...i.e. learn the new.

I have noted that the postal mail delivery has been later than normal. No doubt that is due to the business and the volume of the season. What came to mind, and for whatever reason my memory had this ready for recall, was the old song by the the country band Alabama entitled Forty Hour Week (For A Livin') Here are the lyrics;

There are people in this country
Who work hard every day
Not for fame or fortune do they strive
But the fruits of their labor
Are worth more than their pay
And it's time a few of them were recognized.
The one who brings the mail
With a spirit you can't replace with no machine
Hello America, let me thank you for your time...

While I like what the song is trying to share, I really do think that just because the sentiment is there, does not mean that the current method of how a service or product is delivered should stay that way, frozen in time? Imagine the Pony Express rider lobbying for solidarity and the right to continue his trade when the telegraph machine comes into town? While the rider may be a great and honorable person, does that mean they should continue in their profession when it is made obsolete? Would not a better reaction to the new development be that the pony express rider seek to be trained in the use of Morris Code?

Monday, November 25, 2013

jQuery Sortable Table Rows Example

On the current project that I am working on the customer was wanting to be able to reorder table rows by dragging and dropping them in the desired order. Also the records' text would need update itself displaying the new order of the records. Here is the proof of concept code.

Here is the JSFiddle result. And, here is the JSFiddle code. Enjoy!

Thursday, September 19, 2013

Rrrrr! talkPirate Function

I found out via an advertisement that today is International Talk Like a Pirate Day. "Avast, Ye Mateys! Hoist Yer Colors for Talk Like a Pirate Day! Start savin' on a pirate's favorite language: R"

So, here is my brief talkPirate R function:

Monday, August 19, 2013

Do we want other humans?

At work I was listening to one of NPR’s TED Radio Hour Podcast entitled “Do we need humans?” This talk was a presentation by Sherry Turkle, a professor of the “social studies of science” at M.I.T. and was based on her book Alone Together
A quick search on Google turned up a statement from the book in a New York Times Book Review:
“Dependence on a robot presents itself as risk free. But when one becomes accustomed to ‘companionship’ without demands, life with people may seem overwhelming.” Then the author of the book review states, “A blind date can be a fraught proposition when there’s a robot at home that knows exactly what we need. And all she needs is a power outlet.” 
Do we prefer technology to one another since human relationships take work, can be messy, and cannot be controlled?

Wednesday, August 14, 2013

R for Your Foursquare History

I was looking through twitter posts and came across one dealing with a presentation at the Quatified Self Bay Area Meetup by John Schrom. Watching the video Mr. Schrom described how he acquired his personal checkin data from Foursquare via an R program. Looking further I noted that the information about the presentation included a link to his personal site included a link to his Github repository of the code that he used to gather his personal Foursquare history. With this information in hand I figured that I would attempt to data mine my own checkin data.

The repo's readme file contained the steps that he took to get a Foursquare app setup and obtain his access code to his checkin history. After following the steps I was ready for the next step.

Then, I installed R and proceeded to add the packages that John's code required. First you will need RCurl. I issued the following command in R:
install.packages("RCurl", dependencies = TRUE)

However, I found that I needed to install libcurl due to the following error: ERROR: configuration failed for package 'RCurl'
So here is what I did to remedy the problem:
sudo apt-get install libcurl4-openssl-dev

Next, I installed the rjson package via:
install.packages("rjson", dependencies = TRUE)

Then I pulled down the rpi.R and secrets.R files and per the Github readme I ran:
checkins <- getFoursquare('YOUR_ACCESS_TOKEN_HERE');

After this I wrote the function output to a CSV file:
out <- file("output.csv", "wt")
write.table(checkins, file=out)

Looking at the rpi.R code, I noted the getFoursquare function includes the createdAt attribute of the checkin object (of the Foursquare API which states the createdAt attribute is "Seconds since epoch when this checkin was created"). Since this element is in the form of the number of seconds, for example 1376335108, and it is a data item that I want, I will need to convert it into a human, readalbe format.
This was simple enough for me since I use Open Office to view CSV files in that I found this handy formula to convert the data to a human readable date/time: 

From the CSV file I can inspect the checkin history for correlations with other data or look for patterns that before the review I was unaware existed. 

Finally, next steps could also include learning more R to visualize the data via plotting the data into charts and graphs.

Monday, July 08, 2013

JavaScript replaceAll Example

I needed a JavaScript "replaceAll" function on a string. Note the global flag /g The output is:
John Jacob Jingleheimer Smith

Thursday, July 04, 2013

Example of Meteor using Facebook's Login API

Earlier today I finished up the Meteor Login sample app using Github's API and decided to attempt the same with Facebook's LoginAPI. Meteor makes it so easy that I was able to replicate the same results in two hours. The reason that it even took that long was because I was not accessing the Meteor.user JSON correctly.

For the code go my github repo at:

One thing to note is the setup of the Facebook Login App for testing at Meteor's default location of http://localhost:3000.

Of course, once you deploy the app, you will need to update the above settings to the correct domain and URL.


Repo Integrating User Logins with Github and Meteor

Messing with Meteor, an ultra-simple environment for building modern web applications, has been fun thus far. Here is a repo based on Chris Mather's video Customizing Login.

Thursday, June 27, 2013

Jasmine: A JavaScript Testing Framework

I have been experimenting more with JavaScript frameworks lately. Being fond of the Test Driven Development methodology, I came across Jasmine. Here is how the site defines it: Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.
If you have not already, download Jasmine from
After you decompress the downloaded file you see this directory structure.

As you can see, the SpecRunner.html file is your user interface that is simply run from a web browser. The spec folder will hold, as you guessed, your specification code—what you want your implementation to do. The src folder will contain the code you are testing.
The JavaScript includes in the SpecRunner.html file need to be set as such:

What I wanted to do was to test how to sort a JavaScript array based on a date element in the array. So let’s start with the spec file. I named my spec DateSortSpec.js and placed it in the spec directory. Here is the DateSortSpec.js:

Next, the source code file,DateSort.js, goes in the scr directory:

OK, with basic structure in place let's do a sanity check and make sure we get a failing test result:

Now let’s get the “should show Health for a Friend title with ascending sort” spec to pass. First, create a function that will sort ascending by date. What I did was to utilize the JavaScript array.sort method passing in a compare function.

Now reload the browser and the spec passes.

Next we will add the spec to sort descending.

Reload the browser and we see the spec fail as we have not implemented any code for the spec.

So, the next step is clear. Implement enough code to pass the spec. Here I again use the JavaScript array.sort method passing in a function for a descending comparator.

Refresh the browser again and bang!

As you can see using Jasmine is pretty straight forward. Setup is a matter of expanding the compressed file. Moreover, if one has a web browser and text editor you a ready to code the specs and source code.

Wednesday, June 26, 2013

Configuring SciTE for JavaScript on Ubuntu 12.04

At work I use the SciTE editor quite a bit. With that stated, at work we use Microsoft Windows XP, soon to move to Windows 7, as the standard operating system. In any event, during a break I created a JavaScript test file to determine the best way to sort via a JavaScript Date.

All well and good at this point. Then I brought the JavaScript file home where my entire house has nothing but Ubuntu as the choice of operating systems for both desktops as well as laptops and netbooks. I quickly realized that I did not have my SciTE editor configured to execute JavaScript files on my Ubuntu desktop. Doing some quick poking around I found that I could use my installation of Node.js for the JavaScript engine. So, here is what I did.

First, I opened the /usr/local/scite/ file. I then noted that at line 436 it was looking for the GTK cross platform tookit in the for of: if PLAT_GTK
I added the following config setting below that line:
command.go.*.js=node $(FileNameExt)

I then closed the /usr/local/scite/, open the SciTE editor, opened the JavaScript file, hit the F5 key to run the file and I was good.

Monday, June 24, 2013

What daily apps and devices do you use to help you daily?

For me, my day consists of a daily run, a time of scripture reading and prayer, eating breakfast, getting out the door and to work, and then the normal work day events, and then head back home.

For various steps in the events of the day, I use my Garmin watch, iPod Shuffle, fitbit, desktop computer, and smartphone. With these devices I use apps for the weather, spiritual and physical health, basic communications, and traffic for my daily commute. Here are the day’s events with the devices and the apps that are used.

Wake up:
  • Digital clock for the alarm and my smartphone in bedside mode for the time.

Morning Run:
  • Garmin watch to track time and pace
  • fitbit pedometer to track number of steps
  • Desktop computer, with Ubuntu 12.04 as the operating system, looking at and to map and store the day’s run stats
  • Ipod Shuffle with iTunes to download and organize the theology based podcasts and music that I listen too

Reading of scripture and prayer time
  • Desktop computer, smartphone, or Kindle Fire looking my personal prayer app built with Ruby on Rails and housed on

Morning communications
  • Desktop computer, smartphone, or Kindle Fire using gmail, Google calendar, facebook, and twitter

  • Record nutrition intake with that has already uploaded the calories burned from the earlier run.

Morning commute to work
  • Desktop computer, smartphone, or Kindle Fire using to see the current status of the traffic on I75 and I471 North bound. From there I determine which is the best route.

  • Desktop PC for software development
  • Smartphone for personal communications
  • Fitbit in which I note time to time the number of steps taken during the day

  • Record nutrition intake with

Evening commute to work
  • Desktop computer or smartphone using to see the current status of the traffic on I75 and I471 South bound. From there I determine which is the best route.

  • Desktop computer, smartphone, or Kindle Fire using to note the evening and next morning’s forecast.
  • Fitbit from which the day’s step count is uploaded and the amount of calories burned is compared to the day’s nutrition intake.
  • Desktop computer, smartphone, or Kindle Fire using gmail, Google calendar, facebook, and twitter
  • Roku streaming player, a cloud based video streaming device that interfaces with content providers such as Netflix and/or Amazon Prime, to watch great TV series and movies such as Dr. Who, Star Trek, The Goonies, Shaun the Sheep, etc.

Of course this list does not include other devices and personal tools such as the automobile or other home based appliances that rely on silicon-based technology to function. The pattern that I see is that my day is better organized and runs smoother as the result of the use of these devices/apps. Moreover, I am better informed off my health as well as keeping better track of appointments and obligations.

Wednesday, April 24, 2013

Poetry via Python

I was attending a weekend event and heard of a website that had some lofty poetry. Having the book of that poetry, I wanted the content for my own personal use.

I had played with Python before to scrape data from the web and thought I would give it a go again. Here is what I used to get the desired content and create HTML files that I could use on my own website:

Thursday, January 24, 2013

Create PostgreSQL Sequence for Ruby on Rails Apps on Heroku

I was attempting to add a record via my rails app on Heroku and got the following:
ERROR: null value in column "id" violates not-null constraint

Since as the date of this writing Heroku uses PostgreSQL, here are the steps I took.

My Postgres server version is PostgreSQL 9.1.7 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit. I also am using an Ubuntu Linux desktop running Rails 3.2.11.

Now to the steps I took to solve the problem.

In your rails app db/migrate folder create the following class and name it 201301081552_create_table_name_sequence.rb. Substitute the time signature in the name with your date and time and “table_name” with the name of the table you to which you are adding the sequence:

Then in your rails app db/migrate folder create the following class and name it 201301081552_add_sequence_to_table_name.rb. Again, substitute the time signature in the name with your date and time and “table_name” with your name:

Next, commit and push them to your github repository. After that push them to Heroku. If you have the Heroku toolbelt installed you can issue the following:
sudo heroku run rake db:migrate

This should run the database migration that will create the sequence as well as add it to the id column.