Category Archives: Technology

Learning Node.js

I’m slowly attempting to learn Node.js. To do that I’m reading Getting MEAN with Mongo, Express, Angular, and Node, playing around with apps on Glitch, and creating a mini-app. I learn best by jumping in head first so I’m finding it helpful to write code for a real app even though I feel lost half the time. 

Node.js has a pretty steep learning curve, so I’m planning to document some of the challenges that I face along the way, even if it’s a simple bug that takes me a few minutes to figure out. The primary purpose of writing these posts is for my own future reference and to help me internalize the lessons I’m learning.

Reset Mac OS X Dictionary

I’m heavily reliant on the Mac OS X spell checker, but I sometimes click Add to Dictionary instead of the correct spelling. For obvious reasons, that isn’t good, so it’s helpful to know where those new words are stored. Here’s an example:

Screen Shot 2016-09-01 at 10.22.04 PM

You can view the custom dictionary by opening Finder and navigating to:

Users/USER_NAME/Library/Spelling/

In that directory, you’ll see an en file and a LocalDictionary file. You can open each of those files with the TextEdit.app and view the words that were added to the dictionary. Embarrassingly, my Local Dictionary file currently looks like this:

Screen Shot 2016-09-01 at 10.33.01 PM

Delete any unwanted words and save the file. The changes will take effect once you reboot.

Current as of Mac OS X 10.11.6 (El Capitan)

AppleScript – Executing JavaScript in Safari and Chrome

I haven’t used AppleScript much, but I was recently working on a script to automate a workflow and I was surprised to discover that each browser uses different commands to execute JavaScript.

Specifically, Safari uses do JavaScript "add code here" in document X and Chrome requires execute javascript "add code here"

Here’s an example of each:

Safari

tell application "Safari"
	open location "https://google.com"
	if (do JavaScript "document.readyState" in document 1) is "complete" then set pageLoaded to true
	display dialog pageLoaded as string
end tell

Google

tell application "Google Chrome"
     open location "https://google.com"
     if (execute javascript "document.readyState") is "complete" then set pageLoaded to true
     display dialog pageLoaded as string
end tell

A couple notes:

  1. AppleScript.app autocorrects the second example to a lowercase JavaScript, but either should work.
  2. Safari requires that a document is specified
  3. If you’re using Firefox, it’s currently not possible to execute JavaScript with AppleScript

Chrome Redirect Cache

I recently created a new site, but I visited the domain before the site and was redirected to a cgi default page. And as a result Chrome cached the URL as http://example.com/cgi-sys/defaultwebpage.cgi

After I got the site up and running, Chrome continued to redirect the domains to the cgi default page even though it was working properly in other browsers and an incognito Chrome window.

After a week or so of this annoyance, I searched the web for a solution and I found one on Sal Ferrarello’s site. It turns out that Chrome caches redirects and there isn’t a clear way to clear the redirect cache.

The solution that worked for me was Sal’s first idea to disable the cache from the Chrome Developer Tools. The easiest way to open the Developer Tools is Command Option I

Once the Developer Tools are open, click on the settings icon shown here:

Once the settings modal opens, check the box next to Disable Cache (while DevTools is open) option as shown here:

disable-cache

Now visit the page that is cached and the old redirect cache should be permanently removed.

Check out Sal’s post for more details.

Karma Mobile WiFi

My brother-in-law turned me onto a WiFi hotspot device called Karma that’s being released in December. I work on the road a few weeks a year and if Karma works as advertised, I’ll be able to work in my car and I won’t have to rely on abysmally slow hotel/airport/cafe WiFi networks.

Karma previously sold a WiFi hotspot, but it didn’t run on LTE networks. Their new device is set to be shipped in December and can be pre-ordered now. If you pre-order one today you can get it for $99 instead of $149. And if you use this link you’ll get an additional $10 off (and I’ll get $10 of data credits):

https://yourkarma.com/invite/kevin23643

Other Details
– No contract
– Pay as you go data – $14/GB
– Runs over the Sprint LTE and CDMA network (view coverage)
– Your Karma connection is shared with other Karma users
– If other Karma users use your connection you get data credits

Karma kind of downplays the security risk of sharing a network connection, which concerns me a bit. Here’s a related response from one of Karma’s employees:

In order to minimize the security risk, I’ll just use a proxy or VPN whenever I’m connected to a Karma device.

I’m really looking forward to using it and I’ll add a review once I get a chance to use it.