Showing posts with label mac. Show all posts
Showing posts with label mac. Show all posts

Monday, December 03, 2012

OS X Open With Out-of-date

On my Mac system I’ve noticed that, for some reason, multiple versions of a program, or even programs I no longer have installed, will show on the “Open with” menu in finder. Something like what you see in the screenshot.

http://content.screencast.com/users/TroyMurray/folders/Snagit/media/68ddf734-f134-4350-bcc3-db668d17bf12/2012-12-03_10-48-47.png

Turns out this list is a sort of internal database that needs to be cleaned once in a while, but I’m not sure why the system fails to do this on it’s own. Regardless, this can be corrected by triggering a refresh of the database system and then re-launching the Finder.

Open Terminal and paste the following exactly, it should be all on one line:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user

After that command finishes, hold down the Control + Option keys on your keyboard, then click on the Finder icon and select “Relaunch” http://content.screencast.com/users/TroyMurray/folders/Snagit/media/066851e9-1340-425a-ae07-959e3665e6b7/2012-12-03_10-54-25.png

Monday, July 30, 2012

Adding ANT SCP task support to Mac OS X

My ANT build script for a web application I’m working on is using the SCP task to use a secure shell copy from my local system to the remote server. After upgrading to Mac OS X 10.7 “Lion” and Mac OS X 10.8 “Mountain Lion” I lost my ability to use this task. I found this post comment by a member of the ANT team that pointed out that when Apple compiled the version of ANT in Mac OS X they didn’t include the optional JAR files needed for additional tasks. This means that, for me, the baked in version of ANT is missing ant-jsch.jar

To restore this functionality, first I opened a Terminal prompt (I use iTerm2, then determined the version of ANT installed on my version of Mac OS X by typing ant -version. On Mac OS X 10.8 “Mountain Lion” it reported that I was using Apache Ant(TM) version 1.8.2 compiled on June 20 2012.

Next I downloaded from the Apache ANT website the 1.8.2 binary distribution of ANT located at http://archive.apache.org/dist/ant/binaries/. After the download completed I extracted the archive and found the file ant-jsch.jar that I needed.

To determine the correct path to place this file, I executed ant -diagnostics | grep ant.home to find the path, which for me was ant.home: /usr/share/ant. I then copied the ant-jsch.jar file to the /usr/share/ant/lib directory.

I now needed the actual JSch JAR file that has the tasks. I was able to download the file jsch–0.1.48.jar from http://www.jcraft.com/jsch/index.html. I created a directory to store this in my root by using the mkdir -p ~/.ant/lib command and copying the jsch-0.1.48.jar file to that ~/.ant/lib location.

Now I’m able to use the scp task in my ANT build files, yea!

Without this I would continue to receive the message "Not Available (the implementation class is not present)"

Monday, July 02, 2012

Sync Sublime Between Multiple Macs

I’ve been using Sublime Text 2 since way, way back when it was just starting to be developed. I’ve used it since and still love it. It’s light, fast and extensible. However, something that I wanted was the ability to have it in sync between my two Macs. I know, first world problem, but something I wanted a solution to nonetheless. I have an iMac at home and a MacBook Air that I use at the office, when I’m not working remotely from my home office. Using Dropbox I was able to easily accomplish this. Please note that this is for Mac OS X, and should also work on Linux, but probably not on Windows (possible solution here)

Install Sublime Text 2

This should be obvious, but if you haven’t installed Sublime Text 2 already, you’ll want to do this first. You can grab your copy here and I’d encourage you to purchase a license to support the developer.

Install Dropbox

I’m using Dropbox to keep my settings, packages and other supporting files in sync between my two Macs. Now I’m sure you have Dropbox already, but if you’re the 1 person left on the planet that doesn’t, then please use this link so that both you and I receive an extra 500MB free for our accounts.

You’ll want to make sure you have Dropbox installed on all of the Mac’s you’ll want to have your settings in sync.

Setup Sync on First System

Here are the steps I took to setup the sync. I did this on my iMac desktop first, then my MacBook Air second (shouldn’t matter which one you do first, just one at a time). Note that this requires you to use the Mac OS X Terminal, or the excellent iTerm2.

  1. Quit Sublime Text 2 if it’s running
  2. Open the Terminal or iTerm2
  3. Change to your Dropbox folder
    cd ~/Dropbox
    
  4. I recommend creating a new folder for Sublime Text 2 to organize everything. I created one for the Application Support folder and one for the Preferences file. This is what I did, but you can use a different path if you want:
    mkdir -p ~/Dropbox/Applications/Sublime\ Text\ 2/Application\ Support
    mkdir -p ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences
    
  5. Now we move your current Preferences file to the new Dropbox folder
    mv ~/Library/Preferences/com.sublimetext.2.plist ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/
    mv ~/Library/Preferences/com.sublimetext.2.plist.lockfile ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/
    
  6. Now we need to create a symlink for each of those files. The symlink will be in the ~/Library/Preferences folder where Sublime Text 2 looks for the Preferences file, and will point to the actual copy that’s stored in your Dropbox folder
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/com.sublimetext.2.plist ~/Library/Preferences/com.sublimetext.2.plist
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/com.sublimetext.2.plist.lockfile ~/Library/Preferences/com.sublimetext.2.plist.lockfile
    
  7. As you probably guessed, we need to do the same thing with the Application Support folder, move it then symlink it.
    mv ~/Library/Application\ Support/Sublime\ Text\ 2 ~/Dropbox/Applications/Sublime\ Text\ 2/Application\ Support/
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Application\ Support/Sublime\ Text\ 2 ~/Library/Application\ Support/Sublime\ Text\ 2
    

At this point your first computer should be setup to use the Preferences file and Application Support folder (contains your packages, key-bindings, etc) stored in your Dropbox. Go ahead and launch Sublime Text 2, it should open just like before, nothing should be different.

Setup Sync on Second System

Now go to your second system. Install Dropbox if you haven’t already, At this point it’s important to wait for Dropbox to finish it’s sync. If you haven’t already installed Sublime Text 2, go ahead and do that as well, but don’t launch it.

Now let’s setup this second computer to point to the Dropbox versions of the Preference file and Application Support folder.

  1. Quit Sublime Text 2 if it’s running
  2. Open the Terminal or iTerm2
  3. Change to your Dropbox folder
    cd ~/Dropbox
    
  4. If you’ve run Sublime Text 2 on this second computer before, we’ll rename the current Preference file and Application Support folder so that these are saved, but not used. If you’ve never run Sublime Text 2 on this second computer, skip to the numbered step
    mv ~/Library/Preferences/com.sublimetext.2.plist ~/Library/Preferences/old-com.sublimetext.2.plist
    mv ~/Library/Preferences/com.sublimetext.2.plist.lockfile ~/Library/Preferences/old-com.sublimetext.2.plist.lockfile
    mv ~/Library/Application\ Support/Sublime\ Text\ 2 ~/Library/Application\ Support/Old\ Sublime\ Text\ 2
    
  5. Now let’s setup the symlink for the Preference file
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/com.sublimetext.2.plist ~/Library/Preferences/com.sublimetext.2.plist
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/com.sublimetext.2.plist.lockfile ~/Library/Preferences/com.sublimetext.2.plist.lockfile
    
  6. Then the Application Support folder
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Application\ Support/Sublime\ Text\ 2 ~/Library/Application\ Support/Sublime\ Text\ 2
    

At this point you should be able to launch Sublime Text 2 on the second computer and have all of your same Preferences, packages and key-bindings setup and installed. Note that I haven’t run Sublime Text 2 on both computers at the same time, so I can’t comment on what this may or may not do.

Wednesday, April 11, 2012

Installing activerecord-sqlserver-adapter on Mac OS X Lion

I’m on Mac OS X 10.7.3 “Lion” and want to develop a Ruby on Rails 3.2.2 application using a MS SQL Server 2008 database. To do this I needed to install the activerecord-sqlserver-adapter which requires TinyTDS. While the gem install activerecord-sqlserver-adapter worked fine, the gem install tiny_tds failed to compile. It required a freetds component.

This took me a while and I ended up having to install Homebrew to get it to work. Here are the steps I took to get this working, hopefully it’ll save others the hour or so I spent trying to get it working.

  1. Install Homebrew Package Manager by using these instructions
  2. Install the FreeTDS component
    brew install freetds
  3. Install the TinyTDS gem
    gem install tiny_tds -- --with-freetds-include=/usr/local/include --with-freetds-lib=/usr/local/lib --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
  4. Now install the SQL Server ActiveRecord gem
    gem install activerecord-sqlserver-adapter

You’ll need to then setup your database.yml file accordingly:

development:
  adapter: sqlserver
  host: 10.1.1.100
  database: mydb
  usernane: user
  password: s3cr3t
  

Wednesday, January 11, 2012

Move Mac OS X Users folder to secondary hard drive

I recently purchased a new 27" iMac and had it built with both an internal SSD disk and internal HD disk. I wanted to keep all of my applications and OS on the SSD while my user folders on the HD since it has so much more capacity. Here's how I was able to do this:

Restart Mac to Recovery Partition, use Terminal to copy Users folder to secondary drive and then add symlink on primary drive to secondary drive. In my directions below you need to aware of the following:

  • The primary disk drive was renamed to “Macintosh SSD”
  • The secondary disk drive was renamed to “Macintosh HD”
  • My user account short name is troym
  • My user account was the first one created on the system, so the system ID is 501

OK, so here’s the steps that I performed to complete this task:

  • Restart Mac, holding down Command + R on the keyboard (I had to do this four times before it worked)
  • Select your language
  • Click on the “Utilities” menu
  • Click on the “Terminal” menu option
ditto /Volumes/Macintosh\ SSD/Users /Volumes/Macintosh\ HD/Users 
rm -rf /Users
ln -s /Volumes/Macintosh\ HD/Users /Volumes/Macintosh\ SSD/Users
cd /Volumes/Macintosh\ HD/Users
chown -R 501:staff troym

Thursday, January 05, 2012

Updated Twitter Bootstrap OmniGraffle Stencil

I updated my Twitter Bootstrap CSS ToolKit OmniGraffle stencil with a number of changes.

  • Complete replaced the tables
  • Added helper text below form fields
  • Added a stacked-form section
  • Added a radio button control
  • Made sure all form labels are right-aligned
  • Set all stacked-form labels are left-aligned
  • Added a date range control
  • Increased the size of the textarea
  • Resized the navigation bar to be 940px wide
  • Grouped the pagination control

You can grab the stencil now from my GitHub repo, along with directions on how to update to the latest stencil if you're using the previous version.

Wednesday, October 12, 2011

Changing Fonts in Sublime Text 2

I’ve been using the Sublime Text 2 app for this past week and really like it. One of the things I wanted to change though was the font used in the editor. A font I’ve liked in the past was Consolas but I couldn’t find that. I did find one named Inconsolata, which is almost identical from what I can tell, on Google Web Fonts. Here’s how I set everything up on my Mac

Get the font(s)

  • Head over to Google Web Fonts and search for “Inconsolata”, or any other font that you like (other suggestions are Ubuntu Mono or Varela Round)
  • Click the “Add to Collection” button to the far right of the font name
  • Click the “Download your Collection” link on the top-right.
  • Click the “Download the font families in your Collection as a zip-file” link on the pop-up dialog
  • Open the zip-file that’s downloaded
  • Double-click on each .ttf file
  • Select to “Install Font”

Configure Sublime Text 2

  • Open Sublime Text 2
  • Click on the “Sublime Text 2” application menu
  • Select “Preferences”
  • Select “File Settings - User”
  • In the file that opens, add the following line along with the name of the font you installed:
    "font_face": "Varela Round"
    Be sure to include a comma “,” if you’re adding this to a line already within the file, like a color scheme selection.

You can also change the font size using the following:

"font_size": 16
Notice that the number for the font size isn’t in quotes. Once you save the file you should see the results immediately as the configuration file you’re working in is redrawn using your selections.

Here’s my current complete configuration file

{
    "color_scheme": "Packages/Color Scheme - Default/Indy Merbivore Soft.tmTheme",
    "font_face": "Varela Round",
    "font_size": 16
}

Using Sublime Text 2 as ColdFusion Editor

I’ve tried a lot of different editors for writing my ColdFusion code, but never found one that really worked well for me until now. Now I think I’ve found the one that works best for me, Sublime Text 2.

In the past I’ve tried:

  • Coda by Panic = does a really good job with handling the auto-completion of quotes and parenthesis. Has tabs for multiple file editing and does CSS, has a web preview and a Terminal tab. It’s a Panic app, which has a tradition of working really well. However I started to run into these I’d really like, like code folding, easier code colouring and speed seemed to decrease with each release. Coda 2 is “in the works”, but no one really knows when it’ll show up.
  • CFEclipse = I like how extensible the Eclipse platform is, it’s much more of a Integrated Developer Environment (IDE) then Coda. With extensions like Subclipse (Subversion), eGit (GIT) and Mylyn, it can be a pretty sweet tool. However like any Eclipse based environment that I’ve used it suffers two serious problems that over-time frustrate me. It seems to get slower and slower, and the way that it auto-completes of quotes and parenthesis easliy gets confused.
  • ColdFusion Builder 2 = same as CFEclipse, except it costs money to run slow, and if I’m correct in what I’ve found, only runs in 32-bit mode and not 64-bit mode in Mac OS X.
  • TextMate = from what I’ve read this application is pretty “long in the tooth”, but it seems to have a good sized and very faithful following. There is a ColdFusion bundle available. It’s very fast, you can define projects to see all of the code in your directories and has tabs. It works very well with the auto-completes of quotes and parenthesis. TextMate charges for a license, which I paid, but I just had a hard time getting into how to use it and didn’t find much in the way of documentation or screencasts that explained it well to me.

Sublime Text 2

I’ve been using a beta copy of the Sublime Text 2 editor for the Mac and really like it so far. Some of the key things I like about it after a week are:

  • It’s fast
  • Auto-completes the use of quotes and parenthesis correctly.
  • Good code syntax colouring, that can be modified, although I’m using the “Merbivore Soft” theme by Indynagpal.
  • Can open a folder so I can see multiple files at once
  • For file contents that are taller then the screen, a “code overview” of sorts displays on the right to quickly jump to another locatio in the file.
  • Code-folding
  • Tabbed interface for files, and interestingly when you click on a file it will show the contents but not open it as a tab unless you start to edit the file or double-click on it, great for a “quick peek” of the contents!

As I work with Sublime Text 2 more, and as it evolves from it’s beta form, I’ll post more on how I’m using it and what I find benefical.

Monday, October 03, 2011

Lion Mail Crashes When Searching

I’ve had a very frustrating problem with searching in Mac OS X 10.7 “Lion” Mail app since I upgraded. After installing Lion after release, searching in Mail using the keywords like “subject:” and “from:” weren’t being honored and the search results weren’t correct. I was able to resolve this by one of the Apple engineers pointing me towards a bad index and rebuilding my mailbox indexes. This resolved that issue.

After that I started to see a problem where randomly when I’d type anything into the Mail search field the app would freeze, then crash. I was able to do the searches through Spotlight with the keywords, but it was kind of annoying. This became a consistent, reproducable problem after Mac OS X 10.7.1 was installed.

Earlier today I was able to talk again with one of the Apple engineers and he pointed me towards a corruption problem with the “Previous Recipients” list in Mail. Sure enough when I’d try “Window -> Previous Recipients” the window wouldn’t show, and when it finally did after a number of times and restarts, it was only half drawn on the screen.

Since I wasn’t able to clear this list using the GUI, I dig around and found I could do it from Terminal. Since doing this I’m able to search in Mail now without crashing, and it’s so nice

To fix this we need to open the “Previous Recipients” database, which is a sqlite database. First, close your Mail app if it’s running. Next, open Terminal and type:

sqlite3 ~/Library/Application Support/AddressBook/MailRecents-v4.abcdmr

Next we need to clear out all of the “Previous Recipients” addresses in this database. To do that, type:

DELETE FROM ZABCDMAILRECENT

To exit sqlite press CONTROL + Z.

Open Mail and you should now be able to search!

Friday, May 06, 2011

11" MacBook Air SSD Upgrade

My current system is a Late 2010 11.6" MacBook Air that I absolutely love!  The size, the weight, the snappiness of the system, I just love it.  Combined with my 24" Cinema LCD at home or 27" Cinema LCD at work and it's spectacular.
The system currently has a 128GB SSD drive, of which I'm using 90GB now.  Although I'm not that close to capacity fo the drive, I was curious if there were any upgrades possible as I know it's pretty much all soldered together.  Turns out that the SSD is user replaceable and is really easy to upgrade.  Note that I haven't upgrade it yet, but Other World Computing (OWC) has upgrade kits along with video guides for installation.  The whole process looks like it would be a no brainer, for the day that I need to upgrade.   You can watch the short video on how to do this at http://eshop.macsales.com/installvideos/macbook_air_11_2010_ssd_h/