Make a bash script detect the directory it's stored in, to access data there

You may need to write a bash shell script that accesses data stored alongside the script, while your current working directory might be elsewhere. In my case the shell script needed to use Node.js scripts stored next to the shell scripts -- the shell script acting to simplify running the Node.js scripts. The "data" to be accessed in this case is the Node.js scripts, plus the support modules required to run them. You may have other data like a list of hostnames or who-knows-what.

The basic outline is

Easily import your CSV data into MySQL with Node.js

It's convenient to import a CSV file into a spreadsheet to crunch numbers. CSV's (comma-seperated-values) and it's brethren (TSV, for tab-separated, etc) are widely used to deliver information. You'll see CSV downloads available all over the place, whether it's your stock broker or bank, or a government agency, and on and on. Spreadsheet programs like LibreOffice Calc offer direct import of these files, and then as a spreadsheet you've got a zillion tools available to crunch numbers, make graphs, etc.

Canon introduces a new mirrorless digital camera, Canon EOS M5, 24 MPixels of goodness

eosm-hr-eos-m5-efm15-3q-hires-1000.jpg

Canon has expanded their line of mirrorless digital cameras, the Canon EOS M series, with a new entry, the Canon EOS M5. It has a 24 Mega Pixel APS-C sensor. Also introduced is the new Canon EF-M 18-150mm f/3.5-6.3 IS STM lens, offering a an almost 10x zoom ratio.

The Doctor, Harriet Jones, Donald J Trump, and Hillary Clinton

doctor-who-harriet-jones.jpgIt was David Tennant's first show as The Doctor, the Christmas Invasion. He spent most of the episode sleeping off the effects of a regeneration, while London was under threat from a big space ship full of bad guys threatening Planet Earth. The Prime Minister was Harriet Jones, who had previously met the Christopher Eccleston version of The Doctor (Doctor #9 or #10 depending on how you count it).

Fixing "Maximum call stack size exceeded" in async Node.js code

I've happily used the async module for Node.js for years to simplify asynchronous operations over arrays. This is a difficulty in the Node.js paradigm, since the "normal" way to process an array is with a simple for loop. But if the operation is asynchronous the for loop has no way of knowing when to iterate to the next item, or even when processing is finished. Instead the async.eachSeries function does the trick, because your code tells async.eachSeries when to go to the next item, when there's an error, and it knows when the last item is processed, etc. It's been great.

Deprecating buggy npm packages, dealing with deprecations

It seems several critical npm packages deprecated older releases. Installing the old version of some packages causes npm to print a warning saying the package was deprecated, and to use a newer version of the package. Sometimes the message suggests a way to figure out where the package is being required. Due to the way an npm package can pull in other npm packages, it can be tricky to figure out where the deprecated package version is being used.

Click here for more Node.js programming advice

Setting up LibreOffice to access MySQL database with JDBC driver

I wanted to try using LibreOffice Base on Mac OS X to play with a MySQL database. I thought it would be easy, just connect to the database and start doing queries, maybe even pull data into a LibreOffice spreadsheet for advanced data munging. But doing the obvious thing got me messages like "No Java Installation found" and "the driver class com.mysql.jdbc.Driver could not be found". Further, yahoogling with some obvious search phrases turned up nothing.

Upgrading or replacing battery pack, SSD and other parts on Acer C720 Chromebook's

I have owned an Acer C720 Chromebook for a couple years now and in many ways it's the best computer I've ever owned. It's small and light and is easy to carry around anywhere. The keyboard and trackpad are excellent. The screen field-of-view leaves something to be desired, but when viewed head-on the screen looks good and the sound quality is acceptible. I do a lot of writing and software development and web browsing and image editing and related work, and have solutions to do everything (including software development) on the Chromebook.

Examiner.com writers can save their work using this screen-scraper script written for the purpose

I've been writing for Examiner.com for over 7 years, and with the news that they're going to shut down I needed to retrieve over 540 articles to repost them on my own website. Lesson learned - it's better to own your own platform than to write for someone elses platform. Anyway, the result is a Node.js script I'm calling articlescraper. The purpose is to traverse an index page that might be split over multiple pages, then extract the articles from the pages linked from the index.

The demise of examiner.com, what's it mean for citizen journalism?

examiner-logo-blue.jpgIt wasn't that long ago that online news sites began killing off the traditional news services. Many newspapers and magazines have either shut down (costing many cities a vitally necessary check on local government), or else shrank, or else transitioned to an online service. A generation of writers and journalists are under turmoil in a time period where we desperately need a check on the powerful elite.

Pages

Subscribe to Front page feed