Categories
Technology

Look out: Android in the kitchen

Recovered from the Wayback Machine.

I was a late comer to the legions of mobile device owners. However, when I finally crossed over with my purchase of the first generation Kindle Fire, there was no looking back. To the Kindle Fire has now been added an Android smart phone and other tablets —the number of which I’ll keep to myself, or I’ll mark myself an Android junkie.

I watch TV shows and movies on the devices, do most of my research on them (paging through PDFs is much simpler with a touch screen), scan products at the store for background information not listed on the can, navigate to new locations, and yes, play games. Where the crafty devices shine, though, is in the kitchen.

I have an old red binder filled with recipes (not *women) I’ve collected, modified, or created over the years. Recently, I purchased the Living Cookbook software to manage my collection, as well as back it up to Dropbox for safekeeping. What I didn’t want to do with the new software, though, was continue to use paper recipes. With paper, I’ll inevitably spill something on the page, and the large letter size paper actually takes up a lot of counter space.

What I needed was to transfer my recipes from the software to my Android tablet (my Samsung Galaxy Tab 2 7.0 inch tablet in this case—sorry Apple). Luckily, there really is an Android app for that (don’t sue me Apple).

I downloaded My Cookbook, a free/pay app that allows us to create our own cookbooks. Though the interface is rather primitive, what it lacks in gewgaws it makes up for by being able to parse recipe files from many cookbook software applications, including Living Cookbook.

The work flow goes as follows:

  1. Enter the recipe into Living Cookbook. Cry a little when I see how many calories per serving. Vow to eat less.
  2. Export the recipe in any of the supported formats. I use the Living Cookbook .fdx format. Ummm, XML. Long time no see.
  3. Create a synch folder on Dropbox using a built-in My Cookbook feature. Copy the exported recipe to this folder from my computer.
  4. In my tablet, import the recipe into the application and I’m ready to go.

I bought a little tablet stand at Amazon, so the device sits upright and stable on my counter (away from the oven and sink, of course).

When I’m ready to cook something, I pull up the recipe, gather my ingredients, and then follow the directions. I would prefer having both ingredients and directions on same page, but it’s simple to swipe the page to move between views.

If I’m feeling text weary, I can use the My Cookbook feature that allows audio output of the directions. For the most part, though, it’s easy enough to read the instructions.

Once the ingredient manipulation is complete, I can return to the summary page and click the little timer icon. This triggers another Android application that runs a timer, My Cooking Timer programmed with each recipe’s cooking time.

While the end product is boiling/steaming/baking, I can pick up the tablet and check my email, read an article using Pocket, or even make notes for my book using a speech to text application or sound recorder. The speech-to-text app ListNote sometimes results in an some interesting wording, but at least I have enough to work with.

None of the applications impact on the timer—an important feature, because I have been known to get distracted and burn things. Just to note: a smoke detector is not designed to be a food timer.

From a food safety perspective, the use of the tablet is a plus, because using it ensures that I’m washing my hands frequently so as not to smear up the device. Washing hands frequently while cooking is essential to prevent cross-contamination. Going from handling chicken to chopping lettuce can make an interesting science experiment, but not necessarily an enjoyable eating experience.

Of course, you don’t need an Android tablet to do all of this. You can use your iPad or iPhone—if you have money left over from buying the device to actually purchase food to cook.

Ingredients for Cooking in the Kitchen with Android:

  • Cloud storage helps when it comes to interfacing a PC to an Android to share data. I’m partial to Dropbox, primarily because so many Android apps support it. And it’s free for most uses.
  • You can input recipes directly using most Android cookbook apps, but I find an application like Living Cookbook to be simpler and more comprehensive. The key is the ability to export the recipe (unless the software has a comparable mobile app that supports your device, which Living Cookbook does not).
  • A mobile cookbook app, such as My Cookbook that allows recipe import and/or direct addition. Be careful when selecting an app. A cookbook app is not the same type of app as a recipe app, which provides access to existing recipes, but rarely allows you to input your own.
  • Timer software that either works with your cookbook app, or that you can use outside the application. The My Cooking Timers Android app works with the My Cookbook app. There are freeware and pay versions of both apps.
  • A tablet stand that makes it easy to read the recipe and that securely holds the tablet out of the way on the counter. If you’re clever you can probably make something.
  • Soap, water, hand towel—because egg and Android don’t mix.
Categories
Books JavaScript Technology

Finished tech review and the move to Node 0.8x

Just finished the final tech review of my Learning Node book. At 400 pages, it’s a big book. I must admit to being more than a little tired. Right now, I feel I could sleep for a week.

The big announcement in Node land is that unstable 0.7.x is being moved to stable 0.8.x next week. As a final act for my book, I put all the examples through a 0.7.10 tests. The results were better than I expected, not as good as I hoped.

I hit a couple of minor deprecation issues. For instance, path.exists has been deprecated in favor of fs.exists. I used the exit event with one child process application, and I needed to convert it to the new close event. This new event not only waits for the process to end, but all stdio pipes are closed.

Other modules ran into the same deprecation issues. Most of the testing modules in Chapter 14 won’t work with Node 0.8.x, but I think the changes to make them work will be minor.

Socket.IO didn’t work with 0.7.10 and the developers know it. I’m more than a little surprised at the reaction to people turning in issues related to the problem. Not to mention, closing the bugs without even attempting a fix. As I wrote in comments to the issues, today’s 0.7.x stable is about to become next week’s 0.8.x stable, and this bug is going to get very popular.

The db-mysql module also didn’t work with 0.7.10, and the highly popular jsdom module also had problems.

I noted the compatibility issues in the chapters, and provided alternative examples for those I could correct. That is the best I can do.

I’ve giv’n her all she’s got, Captain!

Categories
Technology Writing

Node: References and Resources

Recovered from the Wayback Machine.

During my explorations of Node.js, I came across many excellent resources, references, tutorials, and various other online publications related to the technology. I had planned on incorporating this material into an appendix for Learning Node but decided it would make a better online resource than a book chapter.

Every person interested in Node should start with the Node.js web site, as well as the web site for npm, the application that manages Node module installations:

If you’re interested in Node in a Windows environment, you might a little extra help in getting set up. I recommend the following resources:

There’s an enormous number of resources for the Node.js newbie, including basic tutorials and entire online books. I know there are more than what I discovered, but the following is a good start:

One person, Felix Geisendörfer, has provided several excellent online resources for new and experienced Node folks:

As you learn Node, you’ll hear about the Node event loop. The following are a couple of good articles on the event loop:

REPL is the Node interactive stand alone application. REPL stands for Read-Eval-Print-Loop. Following are good REPL resources:

Modules are the heart and soul of Node.js. It can be an interesting experience finding Modules, because you need to look carefully among the many available to see which are the ones currently supported, and which have, more or less, been abandoned. Luckily, there are good Node module resources:

A good rule of thumb about which module to use is check for recent activity in the module’s repository. Are there outstanding issues? Pull requests that have gone unanswered for a long time? Also do a Google search, see who is using the module, for what, and how recently.

For more on npm, itself, do check out the Developer guide. Also spend some time understanding the differences between global and local installation of modules.

Node is based on the CommonJS model. If you want to learn more about CommonJS, I recommend Taking baby steps with Node.js–CommonJS and creating custom modules.

The heart of the module system is the package.json file. Nodejitsu provides an article and a couple of good cheat sheets related to package.json and npm:

Peter Krumin did a great series of articles on Node.js Modules you should know about. Several of my favorite are included in the list.

If you work with Node, and you write modules, chances are you’re going to become intimately involved with EventEmitter. The following are good EventEmitter resources and references:

Control flow is a big topic of interest for Node developers:

There are good frameworks for Node, but I focused on Connect/Express. I felt that Express was more Node-like, and requires less upfront time than the other frameworks. That’s not to say there weren’t challenges with Express, as it went from Express 2.x to Express 3.x and then back down to Express 2.x, but one adapts. I focused on Express 3 in the book.

Connect is the middleware layer for Express. TJ Holowaychuk provides an introduction to Connect 2 at Connect 2.0. The Express web site is at Express.com, though note that the documentation is still focused on Express 2. For the Express 2 developer, check out the Migrating from 2.x to 3.x guide. Mike Valstar writes specifically about Express error handling and 404 pages.

I grew fond of Redis when working with Node.js. The Redis site is at redis.io. Redis is nicely documented, at the site and in the Little Redis Book.

Following are other articles and links of interest, in no particular order or grouping:

Hack Sparrow article on running Express application in a production environment http://www.hacksparrow.com/running-express-js-in-production-mode.html. Charlie Robbins provides a how-to on distributing Node.js apps with Hook.io at http://blog.nodejitsu.com/distribute-nodejs-apps-with-hookio. More on the Hook.io module at http://ejeklint.github.com/2011/09/23/hook.io-for-dummies-part-1-overview/.

Rasmus Andersson wrote a Template for setting up Node.js-backed web apps on EC2 at http://rsms.me/2011/03/23/ec2-wep-app-template.html. Another writing on setting up Node on Amazon EC2 from Ben Nadel at http://www.bennadel.com/blog/2321-How-I-Got-Node-js-Running-On-A-Linux-M….

A XSS (Cross Site Scripting) Cheat Sheet can be found at http://ha.ckers.org/xss.html. Another cheat sheet, this time on SQL Injection at http://ferruh.mavituna.com/sql-injection-cheatsheet-oku/.

Heroku provides instructions on how to create a self-signed SSL certificate at https://devcenter.heroku.com/articles/ssl-certificate-self. Another tutorial on the same subjec. at http://www.akadia.com/services/ssh_test_certificate.html.

I don’t cover backbone.js in the book, but an article on combing it with MongoDB, Mongoose, and Restify can be read at http://backbonetutorials.com/nodejs-restify-mongodb-mongoose/.

A comparison of Redis and Cassandra http://hammerprinciple.com/databases/items/redis/cassandra. More on Apache Cassandra at http://cassandra.apache.org/. Redis is compared with Memcached at http://webdevrefinery.com/forums/topic/8221-memcached-vs-redis/. The Memcached web site is at http://memcached.org/.

Guillermo Rauch’s Use Jade Blocks, not Layouts, at http://www.devthought.com/code/use-jade-blocks-not-layouts/.

Curl is your friend when testing RESTful applications. Some helpful examples at http://www.yilmazhuseyin.com/blog/dev/curl-tutorial-examples-usage/.
The Ruby on Rails routing guide applies equally well to Node: http://guides.rubyonrails.org/routing.html.

Charlie McConnell wrote an article on “How to use stream.pipe” at http://docs.nodejitsu.com/articles/advanced/streams/how-to-use-stream-pipe.

One of the better, more thorough answers I’ve seen at Stack Overflow is the answer to “What is the Difference between proxy server and reverse proxy server” at http://stackoverflow.com/questions/224664/difference-between-proxy-serve….

Guillermo Rauch wrote a multipart tweet filtering proxy, beginning with Part 1 at http://www.devthought.com/2012/01/24/filtering-tweets-for-your-favorite-….

Shravya Garlapati at LinkedIn, wrote a very helpful article, Blazing Fast node.js: 10 performance tips from LinkedIn Mobile http://engineering.linkedin.com/nodejs/blazing-fast-nodejs-10-performanc….

The Async module can be found at https://github.com/caolan/async. More on the creation of Async at http://caolanmcmahon.com/posts/asynchronous_code_in_node_js.

The Step module is located at https://github.com/creationix/step.
There is promise support in Node with Q at https://github.com/kriskowal/q, and deferred https://github.com/medikoo/deferred, as well as Futures https://github.com/coolaj86/futures.

Yes, you can use Node modules with client-side JavaScript with help from RequireJS at http://requirejs.org/. And you can scrape web pages using Node, jQuery, and Jsdom, with a little help from this article http://liamkaufman.com/blog/2012/03/08/scraping-web-pages-with-jquery-no….

Since Node is based on the CommonJS model, read more about CommonJS at http://www.commonjs.org/. An interesting article on Node, CommonJS, and custom modules by Jan Van Ryswyck can be found at http://elegantcode.com/2011/02/04/taking-baby-steps-with-node-js-commonj….

A Nodejitsu article on using the Process module can be found at http://docs.nodejitsu.com/articles/getting-started/the-process-module. More on Node and processes by at http://dailyjs.com/2012/03/22/unix-node-processes/.

More on TCP Socket Programming in Node.js at http://www.hacksparrow.com/tcp-socket-programming-in-node-js.html. A general article on TCP vs. UDP can be found at http://www.skullbox.net/tcpudp.php. More on UDP Networking at http://twistedmatrix.com/documents/current/core/howto/udp.html.

If you’re curious about the performance differences between using process.nextTick and setTimeout, you can view benchmark tests at https://gist.github.com/1257394.

Categories
Books Technology

Node’s the thing

I just finished my fourth chapter for my newest book for O’Reilly. I never feel a book is solid and real until the fourth chapter. By the fourth chapter, you have a book, not just an idea or outline.

My newest work is titled “Learning Node”, about Node, or Node.js for the purists among you. It’s a good fit with my other JavaScript books, and is focused on an interesting and rather fun technology.

I wasn’t sure about Node when it first came out. My very first JavaScript gig wasn’t client-side development, it was a server application for a company in Portland, Oregon. I can’t remember the name of the company, or even what the application was about (I have done a lot of contract work in the last 25 years) but I remember working with a contractor from Vietnam who is one of the nicest people I have ever worked with.

I also remember that server-side development with JavaScript died quickly, and there went another skill down the toilet. So when Node came around, I didn’t embrace it as profoundly as many people did.

In time, though, Node won me over. I like it—not in the giddy, bubbling-over-with-enthusiasm embrace I may have felt about server-side JavaScript (and Java, and EJB, and the earlier Cloud computing, and DHTML), but I like it. I think it’s useful. I think it is a very solid technology.

What won me over to Node? The fact that it’s based in JavaScript helped. I’m not going to join the effete in condemning JavaScript, because I like JavaScript. I think Dart is dead on arrival, and JavaScript is only going to get better over time. However, there’s also CoffeeScript for those who just can’t embrace JavaScript.

I like that we don’t have to worry about working with threads, that modules are the norm, and that Node doesn’t pretend to be the definitive solution for every problem. I also like the community support and how uncomplicated it is to create complicated applications. I don’t want to use “easy”, but Node doesn’t demand that the developer jump through an extraordinary number of loops to get a job done. For all the new geewhiz quality about Node, it’s a very pragmatic technology.

Node is also mature enough to last—no lost skills with it. The very fact that the creator of Node, Ryan Dahl, decided to step down as gatekeeper for Node, and his decision didn’t cause any earthquakes in the Node community, attests to the maturity of both the technology and the community.

The HTML5 community could learn a lot from the Node community in this regard.

If there’s a problem with Node is that many of the those who work with Node come from a Ruby/Rails/Extreme Programming background, and many of the concepts and explanations about Node reflect assumptions that can actually form a barrier to understanding. In some ways, Node can present itself as more complex than it really is, primarily because much of the terminology reflects a background that not everyone shares.

Another problem is that documentation is an interesting mix of the nonexistent, cryptic, and/or flippant—none of which is generally helpful. Then there’s the oddly peculiar “Node web style”, with web sites in dark gray backgrounds with pale gray writing, (or white background with pale tan/green/gray writing) where the only way you can see the text is by turning up the brightness of your monitor until your head hurts.

Still, times are a changing. Cloud9’s new new Node Manual web site is a solid start in the right direction, and I have high hopes for the official Node.js site, too.

Then there’s my book, which I’m sure you’ll want—if for no other reason in that it’s a nice break from me bitching about HTML5.

Categories
Browsers

Firefox: Continuous scrolling and continuous freezing

This morning I logged into Twitter, opened my HTML5 list, and started scrolling down the page to see what new outrage/toy/publication/conference was generating excitement today. Of course, I use “page” loosely, since Twitter uses the “continuous scrolling” technique to retrieve and display older tweets. You never actually get to the end of the page, you just keep getting more tweets.

I dislike the “continuous scrolling” technique with a passion that I usually reserve for governors who harass teenagers who tweet. Many times I have scrolled to an interesting looking tweet, which is suddenly moved out of view because of an awkwardly done “page” update that pushes the previously scrolled tweets out of view. The same happens, though not as abruptly, with Facebook and Google+—a less than clever use of technology to replace what the developers seem to think is beyond their users: to click the damn “More” link.

Worse than losing that tweet that piques my interest, though, is that lately when I’m using Firefox to scroll down the page of updates, the browser freezes up. At times, it can seem to unfreeze itself if I just patiently wait for it to deal with whatever internal upset it’s currently dealing with. Other times, I’ve had to kill the browser.

In the past few weeks, though, I’ve had Firefox freeze up to the point where I couldn’t use my Windows 7 system. I can’t bring up the task manager to kill Firefox. I don’t get any response from any key combination. The only recourse I’ve had in these circumstances is to hard boot my system.

Hard booting a system is not a good idea, and it’s one I shouldn’t have to be taking. However, when your system is frozen and your laptop fan is whirring like mad, you take desperate measures. Desperate measures that came close to losing my system today.

I hard booted up my less than one year old Toshiba laptop after a Firefox/Twitter freeze this morning, except that rather than the Windows prompt asking me if I wanted to start Windows in Safe Mode, I got the ominous message that the system could not find my hard drive. I tried again in a couple of minutes, but received the same message. Waiting a short time later, I was able to get to the Windows restore/repair dialog, and tried an automatic repair. This seemingly failed, and I was faced with having to restore my system using the Toshiba recovery program, which basically overwrites your disc with a brand new installation of Windows.

Before taking such a drastic step, I tried to restart my system one more time, and this time, success!

Right now, I’m backing up all of my writing research folders to my internet site, and various other files to external USB drives. I’m also using Google Chrome to write this, because, frankly, I’m wary of using Firefox for anything at this point.

It is not the browser company’s fault that web sites use JavaScript to create some chi-chi clever effect that taxes the browser’s resources, and that most of us don’t really need, and didn’t really ask for. However, it is the browser company’s fault when it can’t deal with whatever good or bad JavaScript it encounters. No browser should allow any JavaScript to freeze the application up so badly that it has to be forcibly closed. And no browser should ever be so badly coded that it can literally crash the OS.

The only extensions I use with Firefox are Firebug, AdBlocks, and Web Developer Toolkit. I suppose one of these three could be to blame for the freezing problem, but it’s the responsibility of the browser company to ensure that its extension environment is solid so that an extension can’t cause these kinds of serious problems.

Whatever happened to my favorite Firefox of bygone years? Whatever happened to the rock solid but still innovative browser I once depended on? In its desperation to beat out Chrome and it’s aggressively pushed schedule to release new browser versions seemingly every few weeks, Firefox has become increasingly erratic and unstable. I could live with the mouse cursor landing in the web page just below a form field when tabbing (and having to click on the field to realign), but I can’t live with the freezing and crashing.

After all these years, I’m going to have to switch to another browser. Right now, I’m typing this post using Chrome, but I’m not overfond of Chrome. It’s not a bad browser, but the same issue with Firefox also applies to Chrome: aggressive release schedules and seeming indifference to stability. (“Stability? We don’t need no stinken stability!”) Apple’s support for Safari on Windows seems tepid, at best, which leaves Microsoft IE and Opera. The newer versions of IE are actually fine products, and Opera seems to have found the right point between implementing the latest gewgaw and delivering a stable product—but dammit, I’m used to Firefox.