Sumar días a una fecha

$fecha_inicial = $presupuesto->getDateTimeObject('fecha_inicio');
$fecha_final = clone $fecha_inicial;
$fecha_final->modify('+6 day');

Symfony - Include partial

<?php include_partial('global/messagebox', array(
  'msg_type' => 'success',
  'text' => 'Accepted terms. Wellcome.')); ?>

Git - Undo last commit

git reset --soft HEAD~1

Javascript - Default value for argument

 function foo(a, b)
 {
   a = typeof a !== 'undefined' ? a : 42;
   b = typeof b !== 'undefined' ? b : 'default_b';
   ...
 }

And in coffeescript

foo = (container, liquid) ->
     container ?= "mug"
     liquid ?= "coffee"

Change window number in tmux

In order to change a window's number, go to te desired window, then press the prefix (Ctr-B by default) and then type:

:move-window -t 4

Where 4 is the new window number

Thanks to: http://superuser.com/questions/343572/tmux-how-do-i-reorder-my-windows

tmux config file

This is my basic tmux config file.

Features:

  • Pane switching with Alt-Arrow keys.
  • Select pane with mouse click.
  • Reload configuration without restarting tmux.
  • More intuitive keybindings for splitting.
  • Cute statusbar, see attached screenshot for an idea of the resulting statusbar.

.tmux.conf

# set prefix key to ctrl+o
unbind C-b
set -g prefix C-o
bind-key C-o last-window

# reload config without killing server
bind r source-file ~/.tmux.conf

# more intuitive keybindings for splitting
unbind %
unbind '"'

bind - split-window -...

Compile tmux in ubuntu

This recipe is for compiling from source the latest version of tmux. Tested on ubuntu 11.04

Install prerequisites

aptitude install libncurses5-dev

Install libevent

Get latest version from: http://libevent.org/

Configure for installation in an alternate location:

tar xvfz libevent-2.0.21-stable.tar.gz 
cd libevent-2.0.21-stable
./configure --prefix=$HOME/bin/libevent
make
make install

And now, tmux

Get latest version of tmux from [http://tmux.so...

tmux commands

Ctrl+b ?
: List keys

Operations on sessions

Ctrl+b d
: Detach current session

Ctrl+b s
: Show all sessions

To reatach a live session on tmux start:

tmux attach

Operations on Windows

Ctrl+b c
: Create new window

Ctrl+b p
: Go to previous window

Ctrl+b n
: Go to next window

Ctrl+b l
: Last window

Ctrl+b %
: Split window vertically

Ctrl+b "
: Split window horizontally

Ctrl+b &
: Kill current window with all it's panes

Ctrl+b w
: List windows

`C...