Terminal Focus in Mac OS X

I really like to have the Terminal.app to focus on the window without me having to click on it to make it active..

I found the following command:

defaults write com.apple.terminal FocusFollowsMouse -string YES

Source: osxdaily.com

How to install Google Authenticator under Debian Squeeze

The Two way authentication from Google is very cool! I found a post describing how to install it under sid, but I have modified it to apply to the current version of Debian stable.

  1. Download the libpam-google-authenticator package from http://packages.debian.org/wheezy/libpam-google-authenticator. (It is not available in Squeeze stable, so I downloaded the following manually: http://ftp.se.debian.org/debian/pool/main/g/google-authenticator/libpam-google-authenticator_20110413.68230188bdc7-1.1_amd64.deb)
  2. Run:
    sudo aptitude install libqrencode3
    sudo dpkg -i libpam-google-authenticator_20110413.68230188bdc7-1.1_amd64.deb
  3. Configure google-authenticator by running
    google-authenticator
  4. Scan the barcode from the Google Authenticator app on your mobile device.
  5. Edit /etc/ssh/sshd_config and set :
    ChallengeResponseAuthentication yes
  6. Edit /etc/pam.d/sshd and add at the very beginning of the file :
    auth required pam_google_authenticator.so
  7. Restart the service :
    service ssh restart
  8. Done

 

Sources:

Mac: Run Script before or after Wake from Sleep

I have a few scripts that I want want my macbook to run just before I put it to sleep (by simply closing the lid).

To achive this I did the following:

  1. I installed sleepwatcher via brew
    brew install sleepwatcher
  2. Then I copied the launchd files to the ~/Library/LauchAgents directory
    cp /usr/local/Cellar/sleepwatcher/2.2/de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist ~/Library/LaunchAgents
  3. I restarted my Macbook and created the ~/.sleep script which contains the commands that will run before sleep.. (You could also create a ~/.wakeup script that runs when the mac wakes up.)

Source: EchoDitto Labs, Stack Overflow

Enforce HTTPS with a .htaccess file

Start by enabling mod_rewrite then create an .htaccess file in the directory that you want to force HTTPS.

The content of the .htaccess-file:

RewriteEngine On RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} somefolder 
RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]

Now if you go to http://www.domain.com/somefolder you will be redirected to https://www.domain.com/somefolder.

How to force TotalTerminal to always display on top of the dock

I have been using TotalTerminal for a while now. But since the latest 1.1.1 the visor is displayed under the dock. (I have my dock on the left side of my screen) This is both annoying and renders the TotalTerminal useless.

This is all due to a bug fix in 1.1.1. There is a way to fix this issue.

Open a new terminal.app window and enter the following line:

defaults write com.apple.Terminal TotalTerminalVisorWindowOnHighLevel -bool YES 

Restart Terminal.app with TotalTerminal.

The TotalTerminal visor is now shown on top of the dock.

Source: GetSatisfaction

Enable Clipboard Copy and Paste in vSphere Client 4.1

First enable local or remote TSM from the vSphere Client on every ESXi host:

  1. Select the host and click the Configuration tab.
  2. Click Security profile > Properties.
  3. Click Local Tech Support or Remote Tech Support (SSH) and click Options.
  4. Choose the desired startup policy and click Start, then click OK.
  5. Verify that the daemon selected in step 3 shows as running in the Services Properties window

Next enable Clipboard Copy and Paste on every ESXi host:

Log in to the ESX/ESXi host as a root user and open the /etc/vmware/config file using a text editor.
Add these entries to the file:

isolation.tools.copy.disable="FALSE" 
isolation.tools.paste.disable="FALSE"

Save and close the file. The Copy and Paste options are only enabled when the virtual machines restart or resume the next time.

Source: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026437

Source: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1017910

Mac Tweak: Lose Name When Copying Email Address

I found this the other day! It’s just awesome.

Great post at maclife.com!

If you frequently copy email addresses out of Mail using the Control-click contextual menu. By default, Mail.app includes the user’s real name as well as their email address — that is, until you take a visit to Applications > Utilities > Terminal and type in the following with Mail.app closed: defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool NO — goodbye, real name, hello email address only!

Source: maclife.com | 6 Secrets of the Mac OS X Mail App

Linked: Remove the “host currently has no management network redundancy” warning from your whitebox HA enabled ESX cluster

I found a great post on how to remove the Host <ESXi Hostname> currently has no management network redundancy warning that you get on a typical ESXi whitebox installation. Due to the fact that most whitebox machines don’t have multiple nics..

For more info and screenshots, checkout the original post.

When you completed building your ESX cluster from so called whitebox machines, you might see a warning sign at the cluster level. It will tell you the management network has no redundancy. This is probably correct because whitebox clusters usually don’t have 2 NIC’s for the management network.

To loose this irritating warning message do the following.

  1. Go to the properties of your cluster
  2. Select HA from the left pane
  3. Click the ‘Advanced Options’ button
  4. Fill in the first column of the first row by double clicking and typing the value ‘das.ignoreRedundantNetWarning’
  5. Fill in the second column of the same row by double clicking and typing the value ‘True’
  6. Close the Advanced Options window
  7. Now deselect the option ‘Enable HA’ and press OK
  8. HA will be disabled, this will take some time
  9. Go back to the options and select ‘Enable HA’ and press OK
  10. HA will be enabled and the warning will be gone

Linked: How To Rebuild LaunchServices to Remove Duplicates from “Open With” Menu

Have you ever used the right-click “Open With” feature in Finder when opening a specific type of file?  While this feature is usually pretty handy, if you install and remove applications on a regular basis there may still be traces of those applications that have been long-gone from your Mac. In this how-to, we’ll show how you can rebuild this list so it remains up-to-date and only shows what you currently have on your hard drive.

Basically you open a terminal and run the following command…And wait.

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

Source

Logging my work to a text file and making it readable in VIM

I use VIM to edit text-files on my mac. Or I use VIM to edit a couple of text-files containing my my worklogs. So I can keep track of what I have done on different projects and at what time.

Creating a quick log entry

I have edited my .bash_profile with the following line
alias wl='vim + ~/Dropbox/NV/worklog.txt; clear'

This in combination with quick access to terminal.app using Visor makes appending to my worklog almost instant.

  1. Visor keyboard shortcut, in my case Alt + § (On a Swedish keyboard It makes sense)
  2. I type wl and press enter
  3. VIM opens the last line in my worklog
  4. To enter insert mode and append to the end of the line i type A.
  5. I type enter -> nnow ,which is my TextExpander abbreviation for inserting a date and time stamp, on the new line. (Example: 2011-04-12 20.20 [Tuesday] )
  6. The I write a short log of what I’m doing at the moment.
  7. I save and exit the worklog file by typing Esc (to exit insert mode), then wq -> enter.

Done.

Making the text file readable in VIM

To make this logfile more readable I use a customized color formatting.

Edit the ~/.vimrc file

This is the content of my .vimrc file.

colorscheme desert
syntax on

au BufRead,BufNewFile *.txt set filetype=txt
au! Syntax newlang source ~/.vim/syntax/txt.vim

Create the ~/.vim/syntax/txt.vim

Source

I downloaded Tomasz Kalkosinski’s universal syntax script for all txt docs. But I added a couple of changes of my own:

syn match logDate /^\d\{4}-\d\{2}-\d\{2}/
syn match logTime /\d\{2}:\d\{2}:\d\{2},\d\{3}/

And later in the file:

HiLink  logDate Comment
HiLink  logTime Todo

You can download my vim.txt file here.

HTTPS Everywhere

HTTPS Everywhere is a Firefox extension produced as a collaboration between The Tor Project and the Electronic Frontier Foundation. It encrypts your communications with a number of major websites.

Many sites on the web offer some limited support for encryption over HTTPS, but make it difficult to use. For instance, they may default to unencrypted HTTP, or fill encrypted pages with links that go back to the unencrypted site.

This plug-in is an absolute must-have.

Download it here.