07 May 2012

Slick ZSH Trick for Vi-Mode

Found a neat trick today for making the commandline vi-mode much more friendly.

Back-story: As I’ve been spending more time programming, I find myself more comfortable on the commandline and in VIM. Also, there’s a setting that can be placed in .bashrc and/or .zshrc to allow vi style editing of the commandline. This is all well and good but without any visual indicator of whether I’m in INSERT MODE or NORMAL MODE… well, it’s disorenting.

So the neat trick is to add code in your .zshrc to insert a right-hand side prompt (RPROMPT) that will show a notifier depending on what mode you’re in.

Add the following code (and thank you to wherever I found this trick online)

    function zle-line-init zle-keymap-select {
        RPS1="${${KEYMAP/vicmd/--NOR--}/(main|viins)/--INS--}"
        RPS2=$RPS1
        zle reset-prompt
    }
    zle -N zle-line-init
    zle -N zle-keymap-select

Have another nice trick for your .zshrc, please share it in the comments!

29 Apr 2012

Easier Directory Navigation

Source: http://stackoverflow.com/questions/3986760/cd-1-2-3-etc-in-z-shell

While looking for a zsh compatible way to replace AutoJump with a ZSH compatible option, I found the following: setopt autocd setopt AUTO\_PUSHD The first option allow moving into a new directory by directly typing it’s name without ‘cd DIRECTORY’.

The second option allows easier navigation using ‘dirs -v’ to check for recent directories or cd ~+<tab> for tab completion jumping :).

Another little way to save small repetitions!

As a side note: I’m quite sad not to have the flexibility of AutoJump in my repetoire with ZSH. It’s the only feature I find lacking compared to BASH. Hopefully it works better in ZSH in the near future, or hopefully I can look into why it doesn’t work and learn how to patch it.

28 Apr 2012

My Kingdom for a Good Fuzzy Finder

I’ve been working on my VIM configurations recently which involved cleaning out cruft from when I hadn’t transitioned to using Pathogen. While doing so I realized that I wanted to take the advice of DestroyAllSoftware.com and switch away from Nerdtree to something that doesn’t involve a context switch. CtrlP to the rescue! Slick addon that I’m happy to have in my arsenal. Plus, it didn’t necessitate installing and configuring VIM with Ruby 1.8.7 as Command-T did :).

28 Apr 2012

Switching to VIMRepress

I’ve been looking for a way to lower the friction involved in blogging. Since I’m spending much of my free time on the commandline, I looked for a VIM solution. The plugin is called VimRepress and it allows you to revise, edit and post blog postings in VIM! The installation process was simple using ‘pathogen’: just a git clone of the repository into my ~/.vim/bundle, install the python-markdown module, and add a few configuration & authorization lines to my ~/.vimrc.

Add the following to your ~/.vimrc let g:vimrepress\_tags\_completable = 'true' let VIMPRESS=[{'username':'BLOG\_USER', 'password':'SECRET', 'blog\_url':'http://blog.xargs.io/'}] Now open up VIM and the blog commands start with :Blog[List, New, etc]. Source and Thanks to : Conner McD

25 Apr 2012

Converting Images of Documents to Near Scanned Quality

I’m working on a project at the moment where we’re handling large quantity of documents that have been photographed in less than ideal circumstances. These photographs are high resolution color photos of typed and handwritten documents that need to be transformed into scan quality documents.  The steps involved are:

  • Convert color to grayscale (128 shades or less)
  • Remove background noise and speckles/flecks/etc
  • Reduce size of images for easier distribution and lower bandwidth usage (currently ~40 GB for set of images) After a few days of working on the problem and learning about the technologies involved… here’s the script I came up with, along with notes about sources and inspirations (note much of the heavy lifting is done by ImageMagick and   Fred’s ImageMagick Scripts[gist id=2494870]

25 Apr 2012

Converting to Arch Linux

It’s been about 4 months now since I switched my HP Tm2t to ArchLinux.  This came after using my laptop for work  with necessary proprietary programs on Windows and dual booting into Crunchbang Linux (Debian based). Well, I upgraded the work laptop to a Vaio workstation replacement i7 w/ nVidia dedicated GPU which freed up my Tm2t! In my excitement, I swapped out the 500GB spinning platter drive for a 60GB 3Gbps SSD, installed ArchBang Linux, and couldn’t be happier. ArchBang is based on the style and concept of Crunchbang Linux (Openbox Minimalism with high utility) but based on the packaging system and system structure of Arch Linux.  This 2-3 yr old laptop is very quick and a nice environment for evening Ruby programming & development. I replaced Openbox with XFCE because my minimalism doesn’t run quite that deep, installed RVM, Chromium, gmrun, configured keyboard shortcuts for Terminator, spacefm (slick file manager), and then spent the next few weeks working on final optimizations (feeling pretty good about the 3+ hours of battery life under Linux). Now if only my touchpad had the quality of a MacBook Pro under Linux (or even the quality of the touchpad under W7), the battery lasted 5+ hrs like W7, and a high resolution screen.  I’m on the lookout to upgrade from this laptop once a decent high resolution ultra portable comes out, preferably from Lenovo’s Thinkpad line.

25 Apr 2012

Label every image with its filename in one fell swoop

Here’s a one off Ruby script to wrap up some ImageMagick labeling magic. This script takes all the JPG images in folder and applies the file’s name, as a label, to the bottom of the image. [gist id=2495001]

20 Feb 2012

Fixing 'Disk Not Found' Error in Grub after apt-get upgrade

One of my development virtual machines went belly up after a recent system upgrade. After tinkering around at the grub> prompt to no avail, I booted a LiveCD, followed the instructions here: http://sazeit.com/articles/repair-or-reinstall-grub-with-boot-repair, and was up and running in minutes. Moral of the story; sometimes it’s more important to solve the problem than understand the underlying issues…not often, but sometimes :).

19 Feb 2012

Absence

Dear spammers, You’ll be relieved to know that i am planning to get back to blogging more.  Thus you’ll have fresh tech posts where you can vainly attempt to post about Viagra and knockoff phones. PS, to human readers… I’ve been very busy with work and getting up to speed on web scraping, ruby, active record & SQLite3, Sinatra, and GIS. It’s an exciting time but a it mellows I’ll get back to blogging.

06 Oct 2011

More Adventures in Puppet

   Thursday, 2010-08-12. More adventures in Puppet: Fix this: err: /Stage[main]/Sudo/File[/etc/sudoers]: Could not evaluate: Could not retrieve information from source(s) puppet:///modules/sudo/files/etc/sudoers at /etc/puppet/modules/sudo/manifests/init.pp:11

By changing your file request (genuinely located at /etc/puppet/modules/sudo/files/etc/sudoers) from:

class sudo {
        package { sudo:
        ensure => present,
        }
        file { "/etc/sudoers":
                owner => "root",
                group => "root",
                mode => 0440,
                source => "puppet:///modules/sudo/files/etc/sudoers",
                require => Package["sudo"],
                }
}
To this:

``` bash
class sudo {
        package { sudo:
        ensure => present,
        }
        file { "/etc/sudoers":
                owner => "root",
                group => "root",
                mode => 0440,
                source => "puppet:///modules/sudo/etc/sudoers",
                require => Package["sudo"],
                }
}

This is using Puppet 2.6.2