Posts tagged OS X

How to use mdfind to search for every file on OS X

Spotlight is great, but it has some mom-friendly rules that limit the results. Since I’m a power user, I typically want to search the entire computer and see all results. Therefore, I use the mdfind command to search OS X.

Just pop open Terminal and type:

mdfind "income tax"

This will search for all files with the metadata words “income tax.”

How to bind Vagrant to port 80 on OS X

First, stop Apache. Apache listens on port 80. If it’s running, Vagrant won’t be able to bind a VM to listen on port 80.

Then, just add a forwarded port to your Vagrantfile:

config.vm.network "forwarded_port", guest: 80, host: 80

And boot up Vagrant as sudo:

sudo vagrant up

How to start and stop Apache in OS X

How to start Apache:

sudo apachectl start

How to stop Apache:

sudo apachectl stop

How to restart Apache:

sudo apachectl restart

N.B. I am on OS X Mavericks. It ships with Apache 2.

How to run Javascript code on Mac OS X

When developing Javascript, you may wish to run code outside the browser. Luckily OS X comes with a world-class Javascript engine, which features a command-line interpreter.

Since it’s hidden deep inside a framework, create a symbolic link:

sudo ln -s /System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc /usr/local/bin/js

Now, you can enter the interpreter by simply typing:

js

The interpreter can be quit by typing quit(); or ctrl+c.

How to check if Bash is vulnerable to Heartbleed

Run this line in your Bash console:

env x='() { :;}; echo vulnerable' bash -c "only this line should appear"

If you see this, your Bash is vulnerable to Heartbleed:

vulnerable
only this line should appear

If you see this, your Bash is secure from Heartbleed:

only this line should appear

The best PGP tutorial for Mac OS X, ever

When I decided to set up my Mac with PGP encrypted communications, I could not believe how hard it was – not just to set up the software, but to understand how to use PGP properly. There was no “PGP for Dummies” tutorial for OS X on the internet. So I decided to write one. This is my über simple, nerd-free tutorial for anyone on Mac. In it, I will:

  1. Cover exactly how to install and configure PGP on OS X
  2. Demonstrate how to use PGP in real life
more...

Creating a ruby launchd task with RVM in OS X

In the last few years, ruby has taken the world by storm. With different projects dependent on different versions of Ruby, many Rails, Jekyll, and Sinatra programmers have installed RVM to manage their ruby versions in OS X. I am one of them.

While RVM is awesome, it can make some previously simple tasks difficult. One such example is creating a launchd daemon that invokes a ruby script. If your gems are installed with RVM, you will need to use RVM to write your daemon. That’s where it gets complicated.

This tutorial teaches you how to schedule a ruby task on OS X using launchd. You can schedule any ruby file to be run. It will be executed using the RVM ruby version of your choice.

more...

Where to put custom bash scripts in OS X

If you make a custom bash script in OS X, and you want everyone on the system to be able to access it, this is the directory where you should save it:

/usr/local/bin

How to show hidden files in Finder OS X

To show hidden files in Finder, type this into the Terminal:

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

To set things back to normal, type this:

defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder