Skip to content →

Category: Mac

Kill process running on port

Frequently I’ll run into the case where my IDE (Intellij, Xcode/Vapor) will fail and leave a web server running on a port. I can’t start it again because it is already running. The only way to proceed is to restart your computer or find and kill the process.

To find the a process running on a port you can use the lsof command. You can filter with “-i”, which lists IP sockets.

$ lsof -i tcp:8080

The command will produce output like:

COMMAND  PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
Run     8299 ddiego   15u  IPv6 0xb2782dc730d0c751      0t0  TCP localhost:http-alt (LISTEN)

The PID is the process identification number. You can pass this to the kill command to kill the process:

$ kill -9 8299
Comments closed

Charles Proxy on iOS Simulator

Charles “is an HTTP proxy / HTTP monitor / Reverse Proxy that enables a developer to view all of the HTTP and SSL / HTTPS traffic between their machine and the Internet. This includes requests, responses and the HTTP headers (which contain the cookies and caching information).”

It is one of my favorite tools for debugging network applications. It supports Mac, Windows, Linux and even iOS.

The instructions on their website for SSL connections from within iPhone applications are not quite complete. Especially the last step which is tricky and I often forget. Here are complete instructions for SSL proxy connections on the iOS Simulator.

1. Add SSL Location. After launching Charles, open the menu:
Proxy > SSL Proxying Settings

The click the “Add Button”

Charles - Add Domain

Type in the location you want to add. You can use wildcards if you like. When you’re done, you should see you location in the list:

Charles - SSL Proxying Settings

2. Install Charles Root Certificate in iOS Simulators. Open the menu:

Help > Install Charles Root Certificate in iOS Simulators

Charles - Install Root Cert iOS

This will install the Charles Root Certificate on the Simulator.

3. Enable the Root Certificate. This is the step, they forget to document. And the last part of it is tricky.

On the Simulator, go to:

Settings > General > About > Certificate Trust Settings

Charles - iOS Trust Settings

Swipe the switch to enable the certificate. It will give a warning which you must choose “Continue”

Charles - iOS Trust Settings Enable

You’ll be placed back on the Certificate Trust Settings page with the switch on:

Charles - iOS Trust Settings Enabled

Now is the critical part. Quit the Simulator. Now run your application again and Charles will be able to decrypt your network communications.

Comments closed

macOS Word Breaks

macOS has a feature that lets you change the word delimiter.  By default it considers the “.” to be part of the word and selects the whole thing.  But you can change it to break on the period.

This feature used to be called “Word Break” in previous macOS release.  In macOS Sierra it can be found by going to “System Preferences” and selecting “Language & Region”.  Here you’ll see an option for “Region”.  If you’re in the United States, it should be set to “United States”.  You can change it to “United States (Computer)”.

Here’s what’s happening: ASCII special characters that are part of words between alphabetic ASCII characters:

  • '.:_ in Standard
  • '_ in English (United States, Computer)

 

Here is an example of “United States”

 

 

Here is an example of “United States (Computer)”

 

 

If you change the word break setting, you have to quit and reopen applications to apply the changes.

Note: I found this tip a few years ago and used it on my Mac. After getting a new Mac, it took me awhile to figure out how to do this again. This post is a reminder to myself for next time I need to remember how to do this.

Comments closed

Mac Lock

icon-512@xOne of my favorite features of Alfred 2 for Mac is typing “Lock” to lock the screen. When I switched back to using Spotlight, I missed this feature. I created a Mac app that would lock the screen when launched. You can now type “Lock” in Spotlight to lock the screen or put it in the Dock and lock the screen with one click.

Source: https://github.com/dougdiego/mac-lock

Download: Lock.dmg

Comments closed

WWDC 2015 – Wish list

Last year I made a WWDC 2014 Wish List. I got at least one thing I wanted. But Apple also gave me a whole bunch of things that I didn’t know I wanted.

Here is an updated list for WWDC 2015.

  • Bug Fixes – I’d be very happy if there were less new features and more bug fixes with the current products.  For example please fix the networking issues.  And I’m still having issues with Gmail in OS X Mail.
  • 3rd Party Complications on Apple Watch – Complications are awesome.  I’d like to be able to expose a complication from my app.
  • Complications on iOS Home Screen – Having complications on the Apple Watch, makes me want them on the iOS home screen.
  • Siri Extensibility – I’d like to see Apple open up Siri to third party apps.  For example if I have RunKeeper on my iPhone, I’d like to be able to tell Siri “Start my run”, “End my run”.  When Apple announced HomeKit in 2014, it allowed custom names for things in your house.  A step forward, but I’d like to see more.
  • AppleTV SDK – I’d love to be able to write apps for the AppleTV.
  • Sandboxing – I’m glad that Apple has sandboxing in the Mac App Store.  But it’s too restrictive.  Apps like Coda should be able to run.  Apple should start by sandboxing Xcode.
  • Filesystem – Mac OS X and iOS are due for a new filesystem. ZFS was rumored for awhile but fell through.
  • Extensions – I love extensions, but there are a few problems.  The difference between a share and action extension is confusing.  It’s hard to tell when new extension are available.   There should be more trigger points for extensions.
  • Default Applications on iOS – On OS X you can set a default application for things like mail and web browser.  I wish you could do the same on iOS.
  • Multiple profiles on iOS – It would be nice if iOS supported multiple users, so a family could share an iPad.
Comments closed

iTerm crashing on launch

I’ve recently been using iTerm on the Mac. I was happily using it, until it started crashing on launch. After searching around on the internet, I finally figure out what is wrong. The issue occurred because I was using an external display. When not connected to the external display the app would crash.

I found details in this bug here: http://sourceforge.net/tracker/index.php?func=detail&aid=2889711&group_id=67789&atid=518973

There are 2 easy ways to solve this problem.

1. In the normal terminal type:

defaults delete net.sourceforge.iTerm "NSWindow Frame iTerm Window 0"

2. Open ~/Library/Preferences/net.sourceforge.iTerm.plist and removed the following entry:
NSWindow Frame iTerm Window 0:

One Comment

WD My Book 1 TB Hard Drive – Partition Failed

I recently bought at Western Digital My Book 1 TB Hard Drive for my MacBook Pro. I wanted to use it for Time Machine backups, which meant that I needed for format it as Mac OS Extended. It came pre-formatted as FAT.

I used Disk Utility to partition it and got an error a few seconds into it.
wd-error
The error window said: “Partition failed. Partition failed with error: File system formatter failed”.

After pulling my hair out for a while, I finally figured it out…

I’m not exactly sure the reason why, but Mac OX has an issue with a “Master Boot Record” bigger than 512mb. Luckily the solution is easy.

1. Open up Disk Utility.

2. Select your drive on the left hand side.

3. Then click on the “Partition” tab.

4. Choose Volume Scheme: “1 Partition” and select the format: “Mac OS Extended (Journaled)”
wd-options

5. Then click on the “Options” button.

6. Here is the important part. Choose “GUID Partition Table” instead of “Master Boot Record”. Then click “OK”.
wd-partition

7. Now click “Apply” to start the partition process. That’s it!

2 Comments

Error 51: Unable to communicate with VPN subsystem.

Occasionally I see the following error when starting the Cisco VPN client on my mac.

The error message reads:
Error 51: Unable to communicate with VPN subsystem.
Please make sure that you have at least one network interface that is currently active and has an IP address and start this application again.

To fix this problem, simply run the following command from the Terminal:
sudo /System/Library/StartupItems/CiscoVPN/CiscoVPN restart

Running a command with sudo, means you’ll need to be an administrator and it will prompt you for your password.

Comments closed

MacOSX user Disappeared & Restored

The other day, I opened my MacBook Pro a few hours after closing the lid and putting it to sleep.  It wouldn’t wake from sleep.  I tried several things to get it to try and wake up, but had no success.  This has happened a couple times in the past, and I usually just hold down the power key to restart it.  So that is what I did.

When it started back up and loaded the login page, I noticed something strange, my user was missing.  I have 4 user’s registered on my computer and now only 3 of them were showing.  So I logged in as one of the other users who an admin.

Upon login, I could see that my user’s account still existed on disk:  /Users/doug  When I went to the System Preferences, I did not list my user.  I wasn’t sure what was wrong.

I began searching through the file system and found there is a file for each user in /var/db/dslocal/nodes/Default/users/  Example:

/var/db/dslocal/nodes/Default/users/doug.plist

I opened up doug.plist and found that it was a binary file.  I could read some of the text in there and saw some mention of “Kernel” and other thing that suggested a stacktrace or dump.  I opened up the plist for another user and found that it was standard XML.  

So I copied the doug.plist from my Time Machine backup and replaced it with the one on my laptop.  I rebooted and my account was restored.

I’m not exactly sure what happened, but the moral of the store is:

  1. Create a Time Machine Backup
  2. Have at least one other Admin user on your computer you can login to if all fails.
One Comment