Ruby Related Thoughts2014-12-14T14:08:28+00:00http://alex-frost.github.ioNikolaialex.frost.dev@gmail.comRemote Pairing2014-04-23T00:00:00+00:00http://alex-frost.github.io/2014/04/23/remote-paring<p>When paring it is nice to make sure the commits are assigned to the correct names.<br />
In fact, when you go back over the git log (or use blame) then seeing an accurate portrait can<br />
be really important.</p>
<p>I’ve been working remotely for a few weeks and thought I’d note down my set-up. Firstly, I made a<br />
file ‘~/.ssh/config’ with:</p>
<pre><code>Host nameForRemote
HostName your_host_ip
ForwardAgent yes
</code></pre>
<p>This means I can log onto the remote with <code>ssh nameForRemote</code> and commit using my local ssh key on the remote server.</p>
<p>Next I made a few alias to simplify pairing (and unparing) following this post on <a href="http://thepugautomatic.com/2013/11/git-pairing/">git paring</a>.<br />
I use <a href="https://github.com/skwp/dotfiles">YADR</a> and this comes with a great prompt but I wanted to add the initials of the pair.<br />
The default prompt ‘skwp’ uses <code>git-info</code> and I changed line 412 to</p>
<pre><code class="language-sh">git_info[$info_format]="$REPLY`git config user.pair`"
</code></pre>
<p>Note: this is a simplest thing I could do, you might want to do something a bit more comprehensive.</p>
<p>Finally, on the remote server in tmux in vim (phew!) the colours were all messed up. I love having<br />
clear colours for quick scanning of code so I had to force tmux to use colours properly. <br />
The <code>-2</code> option is meant to do this but tmux is very very picky about what <code>$TERM</code> is<br />
set as, this alias worked for me:</p>
<pre><code class="language-sh">tmux='TERM=screen-256color-bce tmux -2'
</code></pre>
<p>I’m on Debain, the other devs are on Macs and the server is on Ubuntu - and everyone is happy!</p>
YADR in Terminator2014-03-08T00:00:00+00:00http://alex-frost.github.io/2014/03/08/yadr-terminator
<p>I’m been using GNU/Linux for almost 10 years and helping friends install it on<br />
their computers. Recently I tried out Lubuntu for something lightweight. The<br />
stability hasn’t been so good for me and it even crashed a few times.<br />
Seemed time to switch distros, I went for Debian jessie. When I switch<br />
distros I find one of the most painful things is transferring my settings /<br />
dot files. I’ve been pairing with a friend on his Mac and he used YADR so I thought I<br />
should try it out.</p>
<h3 id="yadr-yet-another-dot-repo">YADR (Yet Another Dot Repo)</h3>
<p>YADR is a collection of dot files which adds great<br />
functionality to your shell (if it was Bash then soon you’ll be on Zsh), vim and git.<br />
YADR didn’t work out of the box so I’m mainly writing this to make the<br />
installation process easier in future and help any one else who has the same issues.</p>
<p>I use Terminator because of its split screen feature and it has all the<br />
options I need. Except… on my friends’ iTerm if you command click on a stack<br />
trace you are taken to the file and line number in your editor of choice: vim!</p>
<h4 id="before-installing-yadr">Before installing YADR</h4>
<p>Make sure you have ruby working. I use <a href="https://github.com/sstephenson/rbenv">rbenv</a> so (copied from the rbenv readme) :</p>
<pre><code class="language-sh">git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 2.1.1
rbenv global 2.1.1
</code></pre>
<p>also make sure you have a modern version of vim with lua enabled for <a href="https://github.com/Shougo/neocomplete.vim#requirements">neocomplete</a> to work. With lua support is included in packages: vim-nox (for command line use), vim-gtk (for graphical vim in KDE environments), vim-gnome (for graphical vim in GNOME) and vim-athena (for graphical vim in <a href="http://en.wikipedia.org/wiki/Project_Athena">Athena</a>).</p>
<h4 id="after-installing-yadr">After installing YADR</h4>
<ul>
<li>
<p>the colours in vim are messed up so I went to Preferences -> Profiles -> Colors<br />
and set the scheme as “Solarized Dark” and the pallet as “Solarized”</p>
</li>
<li>
<p>the powerline fonts didnt install with YADR. I tried following the readme docs<br />
and installing the “for Powerline” fonts and patching fonts but the status bar still had<br />
little squares with numbers inside and not the nice powerline symbols. Turns out I<br />
I just needed to install them:
<code>mkdir -p ~/.fonts && cp ~/.yadr/fonts/* "$_" && fc-cache -vf ~/.fonts</code></p>
</li>
<li>
<p>the default font in gvim was bad, really bad so in “~/.vimrc.after” I added:</p>
</li>
</ul>
<pre><code>if has('gui_running')
set guifont=Monospace\ 10
endif
</code></pre>
<p>After that YADR was good to go.</p>
<h4 id="extra-tweaks">Extra tweaks</h4>
<p>All added to the “~/.vimrc.after” file</p>
<ul>
<li>
<p>Setting gvim to save when focus is lost on a window (e.g. you click away) stops you<br />
having to type <code>:w</code> :
<code>:au FocusLost * :wa</code></p>
</li>
<li>
<p>I like to have NERDTree open by default so I also add:
<code>:au VimEnter * NERDTree | wincmd p</code></p>
</li>
<li>
<p>To use the linux system clipboard <code>set clipboard=unnamedplus</code></p>
</li>
<li>
<p>it is a bit annoying that the Sneak plugin remaps ‘S’ so I also deleted these lines (295-297)<br />
from “.yadr/vim/bundle/vim-sneak/plugin/sneak.vim”</p>
</li>
</ul>
<pre><code class="language-diff">-if !hasmapto('<Plug>SneakBackward') && !hasmapto('<Plug>Sneak_S', 'n') && mapcheck('S', 'n') ==# ''
- nmap S <Plug>Sneak_S
-endif
</code></pre>
<p>this is definitely not the best way of unmapping something but <code>unmap S</code> didn’t seem to work of me.</p>
<p>On Debian I also wanted to remap the keyboard so CapsLock and Escape are switched. I needed to
<code>apt-get install console-common console-data</code> then add <code>XKBOPTIONS="caps:swapescape"</code> to “/etc/default/keyboard”.<br />
To get the configuration to work I <code>sudo dpkg-reconfigure console-setup</code> AND restarted (the restart might have been enough).<br />
You might not need the console packages as I was using Xfce.</p>
<p>Hope this has been of some use.</p>
Postgres install on Debian jessie2014-03-01T00:00:00+00:00http://alex-frost.github.io/2014/03/01/postgres-install
<p>Heroku only uses postgresql and this was the first reason I wanted it installed.</p>
<p>In Debian jessie I needed to</p>
<p><code>apt-get install postgresql postgresql-contrib libpq-dev</code></p>
<dl>
<dt>(without the postgresql-contrib package I got</dt>
<dt>~~~~~~~~~~~~~~~~~~~~~</dt>
<dt>PG::UndefinedFile: ERROR: could not open extension control file “/usr/share/postgresql/9.3/extension/hstore.control”: No such file or directory</dt>
<dd>CREATE EXTENSION IF NOT EXISTS “hstore”).<br />
~~~~~~~~~~~~~~~~~~~~~</dd>
</dl>
<p>Then I needed to add a super-user to the db:
<code>sudo -u postgres createuser YOUR.USERNAME -s</code></p>
<p>The defaults in Debian jessie postgresql are set to be secure. This is great if<br />
you are serving something in the scary internet world but if you are developing<br />
locally on a single login machine its a bit of a pain as it won’t work if your<br />
superuser has no password. I edited my <code>/etc/postgresql/9.3/main/pg_hba.conf</code> to<br />
use the <code>trust</code> instead of the <code>md5</code> connection method, e.g.</p>
<pre><code># TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
</code></pre>
<p>Then restarted postgres <code>/etc/init.d/postgresql restart</code> and off I went to get the pg gem…</p>