2015-04-14

caps lock as ctrl and esc

Map your caps lock button to control when held down, and esc if pressed.

This is perfect for vim, and still keeps caps lock as control for any other program that isn't esc centric.

http://askubuntu.com/questions/196277/can-i-map-a-key-caps-lock-so-it-does-one-thing-pressed-alone-and-another-when

https://github.com/alols/xcape

.Xmodmap
remove Lock = Caps_Lock
keysym Caps_Lock = Control_L
add Control = Control_L

$ xmodmap ~/.Xmodmap

then run
$ xcape

2015-04-13

from sublime to vim

So I've decided to try learning vim one more time.

I did one unit in uni on vi, but the lecturer was so monotone and repetitive that the only thing I learned was.
Press esc to exit command mode, to exit command mode press esc. The command mode can be exited by pressing the esc key.

At my first job a few people used vim, but when I asked why they didn't use a modern IDE, they just shrugged and said, "I'm used to it and it's efficient"

The unique concept in vi that no one ever mentioned (or I just didn't understand) was composable commands, especially when combined with modes:

https://medium.com/@mkozlows/why-atom-cant-replace-vim-433852f4b4d1

http://ferd.ca/vim-and-composability.html

Whenever I used vi, the normal/insert/command modes felt like a burden, because I was always in insert mode, and ctrl-s is much easier than esc :w

I learned a couple of normal mode things like :wq :q! r x i d dd dd y p / and regex search and replace, but that's a really awkward way to edit text. I thought of them as unrelated and obscure commands, when really they are verbs. I never bothered to learn about the nouns; text-objects and movements, let alone adjectives.

I used eclipse as and IDE, and actually spent time learning the shortcuts, so I was much more effective with that. ctrl to move over words, shift to select, ctrl+alt to move selected blocks etc.
Almost every editor/IDE I've used since have a similar set of actions with the same keys, and most OSs have them built into every text box, (even blogger).

I used emacs for a few years, after a colleague showed me some of the power and extensibility, compared to IntelliJ IDEA. I was writing macros, had my own custom key-bindings that worked properly with my dvorak keyboard, and I was processing text faster than ever.

I then started working on both an iphone app and a .net web app. both of which required the use of xcode and visual studio respectively.
I stopped using emacs every day, as 3 editors/IDEs was too many to be using every day.

After that I started looking into rails again, and everyone was using sublime text 2. So I thought I'd give that a go.
It seemed to have the power of emacs, with the navigation/editing keys of everything else.

ctrl-P and multiple cursors just blew my mind. (which I hadn't seen before)

I've been using sublime 2/3 for a few years now, and was getting annoyed a little things all the time, but nothing bad enough to look for alternatives.

Then I read this:
https://advancedweb.hu/2015/03/31/why-you-should-care-about-vim/

I finally grokked vim.

If you're always in normal mode, it's easier to diw than it is to ctrl-left ctrl-shift-right del
Being in the normal mode means you don't need all the modifier keys.

Now, it seems weird that I can only enter "normal mode" in other editors by holding down ctrl!

Because it's a language (diw=delete inside word), it ends up being easier to remember than the sequence of ctrl commands.

And if you learn a new modifier y (yank/copy), or a new text-object like p (paragraph), you're extending the knowledge you already have, rather than remember a new combination, or just repeating and existing key.
eg
yip or up, up, up, up, shift+ctrl+up, ctrl+c
yis or ctrl+[left, left], shift+ctrl+ [right, right], ctrl+c

I'm no longer holding down 2,3 (4 on the laptop of end) keys at once to copy a section of text, I just type three letters.

It does help my hand and wrist pain, and it's less keys; sure.
But the more important thing is that I can think about my edits at a higher level of abstraction.
Instead of just characters, lines and pages, I can think about characters, words, WORDS, sentences, blocks, paragraphs, indented sections, tags; All the things that I actually think about when I'm working on code.
eg
delete this html tag = dat
copy the body of a coffeescript function = yii

Just like any programming language, you have methods of combination and methods of abstraction.

http://www.billthelizard.com/2009/10/sicp-notes-from-lecture-1a_04.html

Lots of editors have methods of abstraction: plugins and macros,
and simple methods of combination: ctrl+shift+alt with arrow/home/end/pageup/pagedown keys

but nothing compares to vims verb/adjective/noun form of combining search, editing or movement, with all types of things on the screen.

It's got me thinking about what other kinds of nouns I could add with a plugin.
But I really need to learn the basics before I start learning vimscript.

If you're used to an IDE, vim is something that really needs to be set-up before you start,
as the defaults are based on compatibility rather than state of the art.

This is a great way to learn the basic concepts, and set up a basic config
http://inside.github.io/vim-presentation/#/


I've really only just started learning vim (properly this time)
so where's some links to resources that I've found helpful at this early stage.

This was awesome fun, but US$25 is a bit much for only 6 months
http://vim-adventures.com/

This is almost as fun, and I'm actually learning a lot very quickly US$5 for just vim is a decent price
https://www.shortcutfoo.com/app/dojos/vim

Here's a cheat sheet that's actually compact enough to be useful
http://sheet.shiar.nl/vi

http://stevelosh.com/blog/2010/09/coming-home-to-vim/
http://benmccormick.org/learning-vim-in-2014/

Here's some ways to help vim feel more IDE like, a softer way to make the transition
http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/
http://yannesposito.com/Scratch/en/blog/Vim-as-IDE/

Some issues that I haven't noticed yet
http://andre.arko.net/2013/09/11/vim-is-the-worst-editor/

I'm liking this color scheme at the moment, twilight:
http://www.vim.org/scripts/script.php?script_id=1677

in file search:
https://github.com/ggreer/the_silver_searcher

coffeescript
https://github.com/majutsushi/tagbar/wiki#coffeescript

2015-04-02

new laptop for development

Sony Vaio Pro 13 black
8gb RAM
3.0ghz i7
256GB SSD
13.3" 1920x1080

It came with win 8, which I upgraded to 8.1.
It's fun to use, but to get any real work done I need *nix.

I've always preferred debian based distros of linux, and ubuntu's the current favorite.
I don't have any issue with unity, mainly because all I use it for is to press the super key, then type programs names.

ubuntu 13.10
After creating an ubuntu live usb disk, desktop 64bit.
I completely wiped the HD, and let the install setup it's preferred partitions.
It refused to boot, regardless of UEFI settings, and after trying a bunch of things I found the first comment here https://spicious.com/sony-vaio-pro-11-with-ubuntu.html
essentially it won't boot unless a kernel parameter is set : libata.force=noncq
I had to boot again with the usb stick, edit /etc/default/grub, chroot the target drives, sudo update-grub

arrg, what a pain.

14.04 update:
sudo parted -l

shows sda1 is boot and sda2 is root

in BIOS set : non-secureboot with uefi
boot from the usb drive 14.04 iso

install and run boot-repair
https://help.ubuntu.com/community/Boot-Repair
with default options

then run the following commands
sudo mount /dev/sda1 /mnt
cd /mnt/EFI
sudo mkdir -p Microsoft/Boot
sudo cp ubuntu/* Microsoft/Boot/*
sudo cp Microsoft/Boot/shimx64.efi Microsoft/Boot/bootmgfw.efi
cd ~
sudo umount /mnt
sudo mount /dev/sda2 /mnt
sudo gedit /mnt/etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash libata.force=noncq"
from http://steffankarger.nl/2013/12/10/ubuntu-13-10-on-the-sony-vaio-pro-13


make the fan quiet
cat /sys/devices/platform/sony-laptop/thermal_control
balanced
performance
silent
echo silent | sudo tee /sys/devices/platform/sony-laptop/thermal_control

Time to setup apps:

run software updater

install chrome and login with google account.

install packages:
sudo apt-get install
  kde-config-touchpad # setup the trackpad
  git
  xclip # with alias clip='xclip -se c'
  vlc
  compizconfig-settings-manager # mostly to set super+left windows snapping
  steam

Install using Ubuntu Software Centre:
'Unity Tweak Tool'
'Tweak Tool'

themes:

sudo add-apt-repository ppa:noobslab/themes
sudo apt-get update
sudo apt-get install zoncolor-themes nouvegnome-gray delorean-dark ambiance-crunchy

http://craazyt.deviantart.com/art/Black-Out-GTK-Theme-v1-290897730
http://alecive.deviantart.com/art/ANewStartBLOOD-1-0-273905913
http://gnome-look.org/content/show.php/?content=154296



I like the dark and monochrome themes and icons:
zencolordarknight theme, with noucegnome-gray icon set and zencolor cursor

set caps-lock to be an extra control key:
in tweak-tool, under typing

install:
sublime text 2
jdk
grails ggts

install ruby and rails:
http://ruby.railstutorial.org/chapters/beginning#sec-rubygems


install haskell !!!:
sudo apt-get install haskell-platform


sublime text setup;

package control
https://sublime.wbond.net/

packages
* sublimeREPL
* fileDiffs

make sublimeREPL ruby actually work
* rvm  all do gem install pry

edit SublimeREPL.sublime-settings:
{
    "filter_ascii_color_codes": true,

    "default_extend_env": {
    "PATH": "/usr/local/bin:{HOME}/.rvm/rubies/default/bin/:{PATH}",
    "GEM_PATH": "{HOME}/.rvm/gems/ruby-2.0.0-p247"
    }
}

make bluetooth actually work:
sudo usermod -a -G bluetooth $USER
restart



coming terms

In Rich Hickey's talk The Database as a Value he introduces some specific definitions the following terms, as they'll be used during the rest of his talk.

I think understanding data through these definitions will become more and more important.

Rails app

notes from 2014

Rails app
Rails 4.0
Coffee script
Sass
Backbone front end mv*
Json rest api
Github
Jenkins
Aws
Heroku
Postgres
Newrelic
Airbrake
Cucumber ui tests
Jasmine coffee tests
Rspec unit tests
Gems
User admin devise and cancan
Oauth https://github.com/intridea/omniauth

sublime text 2 editor

notes from 2013

sublime text 2

I recently started using sublime text as my main editor.

It seems to be the main goto editor for ruby devs, so it's worth a shot.

I've used emacs previously, and I've heard that sublime text is extensible but still friendly to use.

ctrl-p is a damn powerful search tool!

rails again

notes from 2013

I've started learning ruby and rails again.
I did a couple of small projects a few years ago, and I've spent the last 6 months or so doing groovy/grails; which has copied a lot from ruby and rails.

http://railsinstaller.org/
2.2.1
ruby 1.9
rails 3.2

http://www.sublimetext.com/

http://ruby.railstutorial.org/chapters

extras needed:
http://nodejs.org/download/
http://stackoverflow.com/questions/4269922/permission-denied-publickey-when-deploying-heroku-code-fatal-the-remote-end


reading:
http://git-scm.com/book