Friday, February 11, 2011

My vimrc

set encoding=utf8

set textwidth=0
set tabstop=4       " Number of spaces to expand tab (messy)
set softtabstop=4   " Number of spaces for insert for tab
set shiftwidth=4    " Number of spaces for << or >>
set expandtab

set ruler
set autoindent
set nocompatible        " use Vim defaults (much better!)
set bs=2                " allow backspacing over everything in insert mode
set ai                  " always set autoindenting on
set vb          " turn off bell
set guifont=Monospace\ 12   " determined with 'set gfn'
syntax on               " switch syntax highlighting on

" searching options
set nowrapscan
set ignorecase

" use ALT key to treat wrapped text as new line when traversing
map gj
map gk
imap gki
imap gji

" disable indentation for pasting with f2
nnoremap :set invpaste paste?
set pastetoggle=
set showmode

" for working with Windows line endings
autocmd BufReadPost * nested
      \ if !exists('b:reload_dos') && !&binary && &ff=='unix' && (0 < search('\r$', 'nc')) |
      \   let b:reload_dos = 1 |
      \   e ++ff=dos |
      \ endif



" Protect large files from sourcing and other overhead.
if !exists("my_auto_commands_loaded")
  let my_auto_commands_loaded = 1
  " Large files are > 10M
  " Set options:
  " eventignore+=FileType (no syntax highlighting etc
  " assumes FileType always on)
  " noswapfile (save copy of file)
  " bufhidden=unload (save memory when other file is viewed)
  " undolevels=-1 (no undo possible)
  let g:LargeFile = 1024 * 1024 * 10
  augroup LargeFile
    autocmd BufReadPre * let f=expand("") | if getfsize(f) > g:LargeFile | set eventignore+=FileType | setlocal noswapfile bufhidden=unload undolevels=-1 | else | set eventignore-=FileType | endif
    augroup END
  endif



Tuesday, November 9, 2010

Amazon EC2

Steps for setting up a free ec2 micro account:
  • Sign up for a free ec2 account
    • You will need to create a new AWS account if you already have one
  • Log into the AWS Management Console
  • Create a micro Linux account - choose an EBS backed AMI (Official Ubuntu AMI's are uploaded by user 099720109477)
  • Make sure security group has SSH access
  • Download pem file (can store in same directory or ~/.ssh/identity - ~/.ssh/id_dsa for newer ssh versions)
  • chmod 400 [KEY].pem
  • From folder of pem file connect with: ssh -i [KEY].pem ec2-user@[ID].compute-1.amazonaws.com (user name may be root or ubuntu, depending on instance)
  • Send files with: scp -i [KEY].pem file [USER]@[ID].compute-1.amazonaws.com:
  • Mount filesystem: sshfs [USER]@[ID].compute-1.amazonaws.com: ~/mnt -o IdentityFile=[KEY].pem
  • Unmount: fusermount -u ~/mnt

Format harddrive

ls -l /dev/disk/by-id/

Look for required harddrive

sudo mkfs.ext3 /dev/sdb1 -L "Buffalo"

Monday, August 30, 2010

Grep-fu

How to display list of files with given extension with given text:
grep -lr --include="*.py" "firefox_" *

Sunday, July 11, 2010

Installing Crunchbang

  • Download Crunchbang development torrent
  • Format USB as FAT32
  • Download recent version of unetbootin
  • Create Debian Unstable HDMedia environment on USB
  • Copy Crunchbang ISO to USB at root
  • Boot from USB to install

Post install:
  • Add account to sudoers with visudo
  • Add http://ftp.debian.org/debian/ and http://www.debian-multimedia.org/ to /etc/apt/sources.list
  • Add "setxkbmap us &" to ~/.config/openbox/autostart.sh to set US keyboard
  • install ttf-* packages for foreign fonts (Chinese: arphic-uming, Korean: unfonts-extra)
  • Install vim, codecs, etc
  • Customize .vimrc, .bashrc

    Monday, July 5, 2010

    iso install

    1. Find path to USB with: ls -l /dev/disk/by-id/*usb*
    2. Format USB to FAT32: sudo umount /dev/sdx && sudo mkfs.vfat -I -n "custom name" /dev/sdX
    3. Replug USB
    4. Write ISO to usb with: sudo dd if=/path/to/iso of=/dev/sdX bs=4M;sync (or use UNetbootin)
    5. Make USB first in BIOS boot order (hit F2 or Del at startup)

    Thursday, July 1, 2010

    OCR for Linux

    I tried a few solutions to extract text out of a clear image containing alan0@hotmail.com:
    Install with: sudo apt-get install gocr tesseract ocrad

    $ gocr -i email.png
    aIan0hdmaiI.com

    $ convert email.png email.tif # requires tif
    $ tesseract email.tif out
    $ cat out.txt
    Ina rrykeeg a

    $ convert email.png email.ppm # requires p[bgp]m
    $ ocrad email.ppm
    alano_no_mall.


    Upscaling the image slightly improved the results but still none were correct.
    Disappointing ...