reprogramming myself

Mar 05

Checklist to install multiuser development environment in OS X Mountain Lion

This list in not exhaustive, just my bare minimum for frontend purposes. I’m not dealing with Rails, PostgreSQL, MongoDB or other server tools since it’s not my day-to-day use. Just yet. It’s surprising that you need so many console tools these days to do frontend, but things fall apart, and most of them really improve your performance in many ways.

Installation for one or multiple users would be the same, but there are tasks we will perform as admin user so that we can share part of the environment across multiple users, who will only need to configure personal data (Git, $PATH, Sublime or other editor, …). We are using Mountain Lion but the following should work the same in older systems, down to at least Leopard or Snow Leopard.

Developer environment installation by admin user:

which gcc

(it should return /usr/bin/gcc)

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
brew install git
brew update
brew install rbenv

To use Homebrew’s directories rather than ~/.rbenv add to your profile:

export RBENV_ROOT=/usr/local/var/rbenv

Then

brew install ruby-build
sudo gem install compass
brew install node

We recommend prepending the following path to your PATH environment variable to have npm-installed binaries picked up: /usr/local/share/npm/bin

npm install -g grunt
brew install phantomjs
sudo gem install nanoc

If we need the preview server of nanoc we need to install it::

sudo gem install adsf

We can use other preview servers, like Apache from our system, MAMP or even a LiveReload server.

Developer environment config for each non admin users:

We have most of the environment set up ready, we just need some personal configurations. These will be performed by each non-admin user of the machine:

defaults write com.apple.finder AppleShowAllFiles -bool YES
killall Finder
git config --global user.name "Your name"
git config --global user.email your@email.com
mkdir ~/bin
ln -s ~/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl ~/bin/subl
subl
“~/Library/Application Support/Sublime Text 2/Packages/Color Scheme - Default”
export PATH=~/bin:/usr/local/share/npm/bin:/usr/local/share/npm/lib/node_modules/grunt/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export MY_BIN_PATH="~/bin"
export PATH="$MY_BIN_PATH:$PATH"
export NPM_BIN_PATH="/usr/local/share/npm/bin"
export PATH="$NPM_BIN_PATH:$PATH"
export GRUNT_BIN_PATH="/usr/local/share/npm/lib/node_modules/grunt/bin"
export PATH="$GRUB_BIN_PATH:$PATH"

Other programs you may like:

I don’t work nor get anything from the following, I just think they are awesome apps:

Feb 03

iOS phone number styling

iOS has an automatic feature to detect phone numbers and link them to a phone call by clicking on them.

The problem with this is twofold:

  1. Many false positives 
  2. Style for these numbers is really ugly (ugly as in default link style).

OPTION 1

If you want to avoid this feature you can add the following meta in your pages:

<meta name = "format-detection" content = "telephone=no">

which will avoid the phone to make calls to ALL phone numbers in your page. To reactivate this key functionality in some of the numbers, you need to add a link around each telephone number in your page, manually, using tel: as the beginning of the href, as in:

<a hef="tel:1234567890">1234567890</a>

Then we just need to style the special links:

a[href^="tel:"] {color: inherit !important; background-color: inherit !important;}

OPTION 2

Since in some projects you will not be able to wrap numbers manually and you still want to style what iOS uses as phone numbers, you can do it the other way around. Let’s leave the OS add the special link for us (will not add the special meta that avoids this feature) and style how it looks. First you need to know how iOS links the numbers to the phone. Before:

1234567890

After:

<a hef="tel:1234567890" x-apple-data-detectors="true" x-apple-data-detectors-result="1">
1234567890</a>

As you can see iOS wraps the number into a link with special attributes. Now you can just style them using attribute selector:

a[x-apple-data-detectors=true] {color: inherit !important; background-color: inherit !important;}

Jan 03

Add custom poster frame to youtube video without the API.

The trick is adding the iframe in a comment. Javascript reads comment contents and saves iframe definition to a var. When user clicks on the image, javascript overwrites container innerHTML using the iframe defined in the comments.

https://gist.github.com/4438876

This code is also valid in browsers not supporting window.postMessage (API uses postMessage).