Temporarily Stopping McAfee AntiMalware Agent on the Mac

McAfee’s AntiMalware product can be a real resource hog for some people. Fortunately there’s a way to simply disable it via the command line. It can then be easily re-enabled the same way.

I made an alias in my profile to take care of that:

alias kill-mcafee='sudo /usr/local/McAfee/AntiMalware/VSControl stopoas'

Re-enabling it is just as easy:

alias unkill-mcafee='sudo /usr/local/McAfee/AntiMalware/VSControl startoas'

Mac OSX Yosemite Automation with Javascript

In Apple’s latest Mac OSX update, a new programming language support was added on the OS level without much advertising — Javascript. But Apple did provide documentation about it. A couple of nice folks published great resources on how to leverage them.

It’s really amazing seeing how far Javascript has come in the past few years, penetrating practically the entire stack of web application development cycle. It’s an exciting time to be a software developer.

Upgrading to Mac OSX Yosemite

Mac OSX Yosemite became publicly available today. Since my Mac is in-between projects, I decided to take a chance and upgrade.

I ran into three problems for my Ruby on Rails set up:

Other than those 3 things, pretty much everything else has worked as-is out of the box. I enjoy the crisp look of the fonts and icons in the new OS. And hopefully nothing crazy will happen going forward.

Speed Up Wake from Sleep Time on Mountain Lion

I bought a very beefy MacBook Air this summer. But I was frustrated with how slow the machine’s wake-from-sleep time was whenever it’s been in sleep mode for an extended period of time. For the longest time I just couldn’t figure it out. But as it turns out, it’s a new “feature” designed to make the batteries last longer.

Basically after certain number of hours, in order to save on energy, Mt. Lion saves most of the content in RAM to disk, thus making the wake up taking much much longer than desired. Here’s the blog I found with instructions to change that.

And here’s the instruction just in case. Open your Terminal via Applications > Utilities > Terminal.app, and issue the following command:

sudo pmset –a standbydelay 43200

43200 is seconds, which is 12 hours. I almost always never leave the laptop unused more than 12 hours, so I set mine to 86400, which is 24 hours. To find out what the current setting is, issue this command:

pmset -g

And there you have it!

Export SVN Repositories to Git on Mac OSX

Once you go git, you can never go back.

1. First, make a directory into which you want the newly minted git repo to live
2. cd into that directory
3. Then execute the following:

git svn clone file://localhost/Users/your-user-name/location/of/svn/repo

And that’s it!

Lives of .bashrc, .bash_profile, .profile, and Beyond

Before reading this article on the differences, I’d been stuffing all my export, alias and other things in either .bash_profile or .profile files on my Macs.

Though most settings will run just fine in either file, there is an important difference between .bash_profile and .profile:

If you need something to be executed or sourced (i.e. source ~/.profile) as you open a new terminal tab or terminal window, stick it inside of .bash_profile. Items in .profile only get run once when you login.

Postgresql Install Errors on OSX

Update 09/17/2014: I’ve pretty much deprecated use of MacPorts and gone exclusively to Homebrew since this post. And I haven’t run into this problem since this post.

Update 12/28/2012: There’s an easier way to run PostgreSQL! Mattt Thompson has written Postgres app for Mac OSX that allows the database to run completely self-contained! Hassle-free! Last week I was trying out Sinatra and Padrino with PostgreSQL. But for the life of me, I couldn’t get PostgreSQL to run. At first I thought it was an issue with using MacPorts again. But after some googling, it seems like others who used Homebrew also had similar issues.

1
2
3
could not connect to database postgres: could not connect to server: Permission denied
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

There are a couple of ways to deal with this. One of them is to include the PostgreSQL path on OSX’s commandline lookup chain. In your .bash_profile (or .profile for others) file, you could add the path to the PostgreSQL binaries:

 export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:/opt/local/lib/postgresql91/bin:$PATH

Make sure the version number on PostgreSQL matches the version you are running.

References
* Installation of Postgresql on MacOS X using Macports
* Installing PostgreSQL 9.0 on Mac OS X 10.6.8 via MacPorts

Segmentation Fault with Rails 3.2.6 on OSX

I was trying to create a new project with Rails 3.2.x. But every time as it runs bundle install, I get the following error:

1
2
3
4
5
6
/Users/home_dir/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
.
.
.
other crap

I tried gem uninstall and reinstalling Rails to no avail. It turns out that Ruby needs to find openssl but couldn’t find it at its preferred location. MacPorts handled all my 3rd party binary needs. But in this case, I wanted to use RVM to handle those packages for dependency reasons.

1
2
3
rvm pkg install iconv
rvm pkg install openssl
rvm reinstall 1.9.3 --with-openssl-dir=~/.rvm/usr --with-iconv-dir=~/.rvm/usr

And that solved the issue for me.

Update 02/22/2013: The lastest version of rvm 1.18.10 apparently will do all kinds of nice things in the background for you to solve the issue as well.

References:

Ruby on Rails Install with “Bad Interpreter” Errors

Today I decided to finally upgrade my Ruby on Rails setup at home. But upon running the rails -v command, I ran into this error:

bash: /opt/local/bin/rails: /opt/local/bin/ruby: bad interpreter: No such file or directory

Turns out for some reason there’s another (non-working) copy of rails in my /opt/local/bin/ directory. To fix the problem, I simply had to remove it (along with rake and other related executables out of there).

On a related note, I also tried upgrading rvm. But while trying to upgrade Ruby to the latest 1.9.3 with it using the rvm install 1.9.3, I kept getting this error:

curl: (7) couldn't connect to host

Finally, what worked was this:

curl -L get.rvm.io | bash -s stable --ruby

And to bind that to rails, similarly, do this:

curl -L get.rvm.io | bash -s stable --rails

That’s it.

Happy hacking.

References:
* Installing RVM
* RVM Repo

Mac OSX Lion Upgrade

After painstakingly backing my 27″ iMac, I upgraded to Mac OSX Lion. Not a whole lot changed total UX wise. But I do like what I see except for Launchpad.

Speaking of changes, one thing that broke was the driver for my old black & white Samsung ML-1710. I ended up having to install Splix-2.0.0 which worked decently… Well, it prints — and that’s really all I care about.

So yay.