Category Archives: Technology

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.

Removing Game Center from OS X Yosemite

October 16, 2015 Update: If you’re running OS X 10.11 (El Capitan), you’ll need to disable the System Integrity Protection functionality if you want to hide or remove Game Center.

One of the first things I noticed when looking around OS X 10.10 (Yosemite) was the Game Center icon in the Applications folder.

Game Center has been in Mac OS X since 10.8 (Mountain Lion), but the icon recently changed to match the bubbly iOS icon:

Screen Shot 2014-10-20 at 10.30.59 PM

I never really use Game Center on iOS and am always annoyed with the spammy friend requests. I’ve turned off Game Center friend requests multiple times, but it always seems to get turned back on.

Once I saw Game Center in Yosemite, I immediately tried to drag the icon to the Trash. No luck:

Screen Shot 2014-10-16 at 9.08.37 PM

It took a couple minutes, but I figured out how to remove it. Here’s how your remove Game Center:

Warning! Don’t do this unless you’re comfortable with the command line and have a recent backup of your hard drive. If you don’t know what sudo means, then please don’t proceed. A simple mistake with sudo rm could cause major issues.

– Open Terminal
– Navigate to the Applications folder
– Enter the following:

sudo rm -rf "Game Center.app"

That’s it!

After removing Game Center, I restarted my computer. Game Center didn’t reappear and everything is seems fine. So far. There are probably some ramifications if you try to play Mac App Store games that support Game Center, but I’m not sure. And now I’m wondering if Game Center will reappear then next time I update OS X. Regardless, it’s nice to be rid of that extraneous icon ­čÖé

Otherwise, I really like Yosemite. It’s really snappy (on a wiped 2012 MacBook Air).

Learn Python the Hard Way – Lesson 15

Mac Terminal Python Commands

I’m going through Zed Shaw’s online course Learn Python the Hard Way and I ran into a study drill that gave me some trouble.

In lesson 15 the seventh study drill is a little tricky if you’re not familiar with┬áthe command line. Instead of opening a Python file, you’re instructed to enter the commands from the Python prompt.

Just running open(example.txt) may not work because the Python interpreter only looks in the current folder to find the file. If you don’t start Python in the same folder, you need to tell the interpreter exactly where the file is is located. Here’s one way to do this:

$ python
>>> txt = open("/Users/Kevin/Dev/example.txt")
>>> print txt.read()

If you’re not sure if you’re in the right directory, you can double check your directory. First start Python:

$ python

Then type these two commands:

>>> import os
>>> os.getcwd()

Remember to always import the os module before calling any os commands/functions.

Your result should look like this:

Mac terminal commands to get current directory

Coda 2 Tab Between Split Windows

I just spent about an hour searching the internet trying to figure out the keyboard shortcut to tab (or move) between the split windows within a tab in Coda 2. After looking through the Apple shortcuts, I finally found one that works:

Control + Tab

It’s so simple. But there’s a catch. To get this to work you first must open another tab before opening the Terminal window.

Steps:

1. Create a new tab/document
2. Add a new split Document or Preview window
3. Add a new split Terminal window
4. Close the second Document or Preview

At this point you should be able to Control + Tab between the Document window and the Terminal window. It’s not ideal, but it works when needed.

On a related note, I’m interested to see what Panic has up their sleeve for Coda 2.5. It should be released soon.

Retiring my iPhone 3GS

I bought the iPhone 3GS on October 6, 2009. That’s 1378 days ago. I’ve put it through the ringer and I didn’t any major problems with it until a few months ago. Now unless it’s plugged in, it will randomly shut off even with a fully charged battery. I was hoping to keep it for a couple more months, but since it’s barely functional, I decided to upgrade. My iPhone 5 arrived in the mail today.

iPhone 3GS

Before I bought the 3GS back in 2009, I used a cheap flip phone. It did the basics, texting and phoning, but that’s it. Upgrading to an iPhone was a game changer. Instead of just carrying around a phone/messaging device, I now had portable computer in my pocket. A camera, maps, weather, internet browser, games, email, calendar, and more were always within reach. For better or for worse it changed my life. Of course, there were forerunners of the iPhone like the Sidekick or BlackBerries, but for me, my first taste of a multifunctional phone was the iPhone.

RIP 3GS.