From Newsbeuter to Instapaper with the Ruby RicePaper library

March 3, 2009

I love Instapaper, a truly elegant solution without any needless over-architecting. I use it every day, for queuing up articles to read during a lull in the workflow around here.

However, I’ve had an extra step in my article reading, see I read my RSS feeds in Newsbeuter, so I normally have to open the feed in Newsbeuter, open it in the browser, use the bookmarklet to add it to instapaper, then close the tab (until I want to read the article later). Well no more!

Enough introduction, I haven’t posted nearly enough on here lately, so I wanted to share a little library I’m working on called RicePaper. It’s a simple Ruby library/cli tool for submitting URLs to Instapaper. I’ve started a github project for it, go check it out or download the file directly. RicePaper requires the HTTParty gem (which you can install using “sudo gem install httparty” on a system with Ruby installed) Ricepaper works extremely easily from the command line, like so:

% ./ricepaper.rb -u user@mydomain.com -p mypassword -t "The IWishI site" "http://iwishi.org"

The -t “<title>” option is optional, Instapaper will attempt to find a title for the article without it. You can also use ricepaper from any Ruby code (if you’re a Ruby scripter) as a library by using this little code:

require 'ricepaper'
rp = RicePaper.new(user@email.com, password)
rp.add("http://www.asdf.com", "The ASDF site")
rp.add("http://www.google.com")

It’s extremely simple to use.

Anyway, back to what I was originally going to use it for, bookmarking a URL directly from Newsbeuter, for that, we’ll need a “glue” script, like this (I named mine ricepaper.sh):

#!/bin/bash

# Change these to be your instapaper credentials
USERNAME=email@domain.com
PASSWORD=yourpassword
# Where the ricepaper executable is located
RICEPAPER=ricepaper

# If the title is non-empty, set it
if [ ${#2} -gt 0  ]; then
$RICEPAPER -u $USERNAME -p $PASSWORD -t "$2" "$1" > /dev/null &
else
$RICEPAPER -u $USERNAME -p $PASSWORD "$1" > /dev/null &
fi

# Exit correctly, either way
exit 0

Watch out for the quotes in the script above, sometimes wordpress makes them “special” quotes, which confuses the bash interpreter.

Replace the username and password to your Instapaper credentials and put the correct location to the ricepaper ruby executable, then save the script, chmod +x it and put it in your path somewhere.

Only one step left, which is to add this line to your ~/.newsbeuter/config file:

bookmark-cmd  ricepaper.sh

What happens now, is when you bookmark an article in Newsbeuter, it will call ricepaper.sh with the URL and Title of the article, so whatever you put the Title of the bookmark to be, that’s the title that will show up on Instapaper. Voila!

ip2

Feel free to email if you have any questions about using the script(s). Hope you enjoy!

Installing HyperEstraier Ruby bindings with Ruby 1.9.1 (RC1)

January 9, 2009

Lately I’ve been doing a lot of coding around an awesome database called Hyper Estraier, which allows me to create large inverted-index databases to search over very quickly.

I have also been playing around with the new Ruby RC release for version 1.9.1. In an effort to get some current code running, I found that hyperestraier doesn’t compile the native ruby bindings using 1.9.1 correctly. You’ll see this error when attempting to compile:

~/hyperestraier-1.4.13/rubynative$ make
( cd src && if ! [ -f Makefile ] ; then /usr/local/bin/ruby extconf.rb ; fi )
checking for estraier.h... yes
checking for main() in -lestraier... yes
creating Makefile
( cd src && make )
make[1]: Entering directory `/home/hinmanm/hyperestraier-1.4.13/rubynative/src'
gcc -I. -I/usr/local/include/ruby-1.9.1/i686-linux -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -DHAVE_ESTRAIER_H  -D_FILE_OFFSET_BITS=64  -fPIC -I. -I.. -I../.. -I/usr/include/estraier  -I/usr/include/qdbm -Wall  -O2 -g -Wall -Wno-parentheses -O3 -fomit-frame-pointer -fforce-addr  -o estraier.o -c estraier.c
estraier.c: In function ‘doc_make_snippet’:
estraier.c:354: error: ‘struct RArray’ has no member named ‘len’
estraier.c: In function ‘db_search_meta’:
estraier.c:767: error: ‘struct RArray’ has no member named ‘len’
estraier.c: In function ‘objtocblist’:
estraier.c:1192: error: ‘struct RArray’ has no member named ‘len’
estraier.c:1195: error: ‘struct RString’ has no member named ‘ptr’
estraier.c:1195: error: ‘struct RString’ has no member named ‘len’
estraier.c: In function ‘objtocbmap’:
estraier.c:1221: error: ‘struct RArray’ has no member named ‘len’
estraier.c:1227: error: ‘struct RString’ has no member named ‘ptr’
estraier.c:1227: error: ‘struct RString’ has no member named ‘len’
estraier.c:1228: error: ‘struct RString’ has no member named ‘ptr’
estraier.c:1228: error: ‘struct RString’ has no member named ‘len’
make[1]: *** [estraier.o] Error 1
make[1]: Leaving directory `/home/hinmanm/hyperestraier-1.4.13/rubynative/src'
make: *** [all] Error 2

This error comes from a not-so-great practice of using RSTRING(foo)->len and RARRAY(bar)->ptr in the code, which was removed in Ruby 1.9.1. The correct way to fix this is to make these changes:

RSTRING(foo)->len and RSTRING(foo)->ptr
becomes:
RSTRING_LEN(foo) and RSTRING_PTR(foo)

RARRAY(bar)->len and RARRAY(bar)->ptr
becomes:
RARRAY_LEN(bar) and RARRAY_PTR(bar)

For HyperEstraier, this is a pretty quick fix, there’s a link to the patch at the bottom of this post, after downloading, simply do:

[4:hinmanm@dagger:~]% cd hyperestraier-1.4.13/rubynative/src
[4:hinmanm@dagger:~/hyperestraier-1.4.13/rubynative/src]% patch < ~/hyperestraier-ruby191.patch
patching file estraier.c
[4:hinmanm@dagger:~/hyperestraier-1.4.13/rubynative/src]% cd ../
[4:hinmanm@dagger:~/hyperestraier-1.4.13/rubynative]% ./configure && make && sudo make install

And Hyper Estraier should be installed and ready to use in ruby 1.9.1 RC1! Enjoy!

Download the patch: [hyperestraier-ruby191.patch]

De-googling

December 10, 2008

This has been a post I’ve wanted to do for a while. I’ve finally started the slow transition away from Google’s tools.

Let me start off by saying I have nothing against Google at all. I find their tools incredibly useful and I think they’re an awesome company. I think so far they’ve done a pretty good job of following their “Don’t be evil” motto, I can imagine it’s quite difficult for a company that size. Anyway, suffice it to say that in the interest of privacy, I’ve decided to move as much as I can away from Google’s tools. I find it marginally creepy that a site can see example what I send in email, read in RSS feeds, put in my calendar, take notes on, etc. So what am I moving all this stuff to? Well, let’s take a look at each tool in turn: (Keep in mind that I am a console user who likes lightweight applications, and I like almost everything I use to have vi keybindings, hence the focus on console applications)

Email

Gmail is pretty awesome, and I do really enjoy the amount of space of Google is kind enough to lend us. However, I’m not a fan of anyone reading my email. I have moved all my email over to my hosting solution (the company that is hosting writequit.org). It’s going to take me a long time to go through all the accounts I have and update my email address, but I don’t think it’ll be too difficult. While I’m talking about email, I’d like to plug an awesome email client that I’ve been using, Sup. Sup is similar to Mutt, written in Ruby and has a gmail-esque feel to it (tags, archiving, fast search, not having the nightmare of contact management like Mutt). Here’s a screenshot (from Sup’s site, not my mail)

Search

I haven’t used Google search for quite a while, I have all my browsers set up to search through Scroogle over SSL (through a handy Firefox search plugin), part of this is privacy at coffeeshops (and at work), and part of it is because Scroogle’s results page is much cleaner and offers much easier links for Vimperator than Google’s. I encourage anyone who doesn’t want their search strings to be statistically correlated to check it out.

RSS

I’ve tried a lot of native client RSS readers over the last year, and I still didn’t find one that could compare to gReader until I finally stumbled onto Newsbeuter from a link in one of Zed Shaw’s rants. I have to say that after only a few hours, I was hooked. Newsbeuter’s claim to fame is being the “Mutt of RSS readers”, and it certainly is (it was much closer once I mapped j to ‘down’ and k to ‘up’ in the configuration). I have 200+ feeds, and I have to say I’ve actually spent less time reading feeds using Newsbeuter than I have using google-reader (which is a good thing), mostly because it’s easy to mark things read without actually reading the article, I don’t have to wait for images to load, etc. If you’re a fan of console applications, give Newsbeuter a try! Here’s a screenshot of what Newsbeuter looks like (again, from Newsbeuter’s site, not my setup):

Calendar

I shy away (far-far-far-far away) from using Outlook’s calendar in the office. Yes, I know this irritates the heck out of people because they never receive a little email stating that I’ve pledged an hour of my life to them, but I’m okay with that. Usually, I would receive an invitation, enter it into gCal and use that to track meetings and other requests (it works for me, I tend not to have a ridiculous amount of meetings anyway). Well, rather than Google’s knowing exactly where I am at all times, I’ve switched over to using Remind. Remind allows me to use a simple scripting language to set up reminders, send me reminders before meetings and so forth. Here’s an example of a simple reminder:

REM 17 Dec +2 AT 11:30 +15 DURATION 2:00 MSG Holiday pot-luck for work %b %

(On the 17th of December at 11:30-1:30 there’s a pot-luck, remind me +2 days before the potluck and also +15 minutes before it)

I use Wyrd (weird) as a really nice console gui for remind, which lets me see what I’m doing that day. Here are a couple of screenshots, one of remind and one of wyrd:

Notes

Well, this is an easy one, I tend to have plaintext notes, so if I want to store them, a flatfile works great, or a wiki for more complex note taking (I mostly only note things like what compilation flags I used for what, so flatfile it is for me!). Previously I was using Google notebook, so this is an easy switch.

Caveats

All this switching is not without caveats. Let me go over some of the difficulties of switching some of these things:

  • Google Code and Google Groups both *require* you be signed in, and use your gmail address for posting information, seeing as how I use both of these a lot, I have no choice but to keep my gmail address and forward email to my new address. At least, until OS projects move away from these products (don’t see that happening for quite a while).
  • Google’s Gmail spam filtering is awesome, I haven’t had spam in my inbox for over a year, I think I’ll be brushing up on my spamassassin configuration knowledge quite a bit now.
  • Gtalk is gone, yes, I did use gtalk occasionally over the last year, however it’s blocked at work anyway, so I won’t miss it much, I tend to use AIM, Yahoo or IRC anyway.
  • A web interface for everything. Yes, I do use more than one computer, so I need a way to sync my email, RSS, etc. I tend towards SSHing into my home computer and using screen helps. I can deal with the minor inconvienience :)
  • Calendar sharing, I share calendars with my wife and another friend of mine. Rest assured I’ll find a way to share my calendar, perhaps a cronjob for rem2html?
  • I’m sure there are other inconviences I’ve yet to encounter, but I’ll deal with them as well as I can.

Closing thoughts

Was I able to completely de-google my life? No. Do I hate Google? Not at all. Do I hate people you use Google’s products? Of course not! What I do hope sharing this has done is given you an idea of just what kind of information you’re sharing with <insert web company> when you use their tools. I was unable to completely separate myself (google groups and google code) from Google, but I was able to make a significant amount of headway in reduction of statisticaly marketing research. I encourage anyone interested in privacy to maybe look into switching to some different tools. Of course my tools might not be the same tools you pick, but at least I’ve given some alternatives :)

Good luck!

EDIT (1 minute later): I should also note that I use NoScript, and block javascript from google-analytics, I feel this helps a lot when trying not to become a statistic :)

Switching from MacBook Pro to an ASUS EeePC

December 3, 2008

Well, the display on my Macbook Pro finally decided to die on me, for no apparent reason (I was just sitting in bed, listening to some music when it died). So, I decided that rather than pay for a repair, I’d continue to use the MacBook as a desktop with an external display, and get a tiny netbook for day-to-day use (because I need a laptop to carry, go to coffeeshops with and generally use).

I ended up going with the EeePC (The 1000H model), because I could get the entire laptop for only a little more than repairing the screen of my MacBook (and a brand new Mac is terribly expensive). I’ve been playing with my new netbook for about a week now, and I thought I’d share some of my experiences.

The EeePC came with Windows XP preinstalled, so I promptly partitioned it down to 25g for Windows, 40g for Music and the rest (~90g) for Ubuntu-eee. I decided to go with Ubuntu-eee because of the custom kernel that supported the hardware out of the box without fiddling around. While I really really enjoy fiddling to get stuff to work, I don’t want to have to fiddle just to be able to get a working machine, especially when I’m somewhere I need to actually do some work. I almost immediately switched from the user-friendly Netbook remix interface to a classic Gnome interface, but I could see how it would be really nice for someone newer to Linux.

Here’s some of the key things (?) about my new EeePC (and Ubuntu-eee):

  • I like how portable this is, it’s definitely lighter than my MacBook Pro
  • It’s not ridiculously expensive like a Mac is ;)
  • I like Linux, since I tend to do all of my development on *nix systems, it’s great to have one as a main machine.
  • 1024×600 is very small, especially coming from 1440×900. This is helped by fullscreen mode in things like Firefox (with Vimperator for even more screen space) and Gnome Terminal.
  • Wifi and networking work great, this has always been shaky on Linux systems, I’m glad that I don’t have to fiddle for 20 minutes just to join a coffeeshop’s hotspot
  • Suspend and Hibernate work great, also a big feature, especially since Apple’s sleep feature spoiled me to never turn my Mac off.
  • I don’t like some of the trackpad stuff. It’s difficult to turn off the tap-to-click, attempting to install packages to manage it disable the vertical 2-finger scrolling, it’s _insanely_ sensitive (the pad, the buttons themselves are kind of stiff).
  • The keyboard is great, since I got the 10″, it’s not small enough to bother me during coding sessions, which I’m sure the 8.9″ would have.
  • This machine definitely has less power than I’m used to, but I make up for it by doing a lot of resource-intensive stuff on my home machine over SSH, which makes up for it.
  • Con: Linux twitter clients suck. Adobe AIR clients take a ton of resources also.
  • Con: Linux sound stuff still sucks, it struggles with 2 processes attempting to share the sound device using ALSA.

I would definitely _not_ recommend this device to anyone with ailing eyesight, I tend to use 8 or 9pt font for everything, and I could definitely see some eye strain for anyone who has vision trouble. Don’t get one for your grandparents unless you don’t play on much screen space being usable (or don’t do everything in the console, like I do :) ).

And, since I like pictures, here’s a few pictures of my new machine:

Compiling inavd server on FreeBSD

October 14, 2008

Just a short post, working through some of the modules I received, I ran into the inav module. Turns out that inavd doesn’t compile very nicely on FreeBSD, so I patched it. Previously when trying to compile you get:

c++ -ggdb -g3 -D INAV_VERSION= -c sniffer.cpp
In file included from sniffer.cpp:34:
/usr/include/netinet/ip.h:162: error: 'n_long' does not name a type
/usr/include/netinet/ip.h:165: error: 'n_long' does not name a type
*** Error code 1

So, download the inav-server-0.3.6-freebsd.patch into the directory where you untarred the server and issue the following commands:

cd <dir where you untarred INAV tarball>
patch -p1 < inav-server-0.3.6-freebsd.patch
cd server
make

Right now, the patch is very unclean and making the unitTests doesn’t work, but it does compile inavd and allow you to run the server on FreeBSD, enjoy!

NSM-Console moved to git

October 10, 2008

If you follow the nsm-console development tree, you might be pleased to know that I’ve switched over to git instead of working from the HeX svn repository. You can now check out the files from the NSM-Console github page, as well as download a tarball of the latest source anytime. If you’d like to check out the code to take a look, you can easily clone the repo with:

git clone git://github.com/dakrone/nsm-console.git

I really like git more than subversion, and I’m glad that any nsm-console changes that I check in aren’t going to break the version of nsm-console in Hex.

HeX 2.0, codename “Bonobo”, released!

October 5, 2008

After around 8 months of development, HeX 2.0, codename “Bonobo“, is released!

HeX is a liveCD developed by the rawpacket team that is based on FreeBSD 7.0 and designed to be used for network security monitoring.

There are a lot of new features and a lot of bugfixes that went into this release, but before we get into that, you can grab the iso here:

  • mirror 1 (Georgia Tech, USA) [iso] [md5] [sha]
  • mirror 2 (Rawpacket, USA) [iso] [md5] [sha] (md5 and sha are broken links right now, use the links from a different mirror until the files propagate)
  • mirror 3 (Rawpacket, Malaysia) [iso] [md5] [sha]

Some of the new features include:

  • Moved from FreeBSD 6.2 to 7.0 using the newer ULE scheduler instead of the 4BSD scheduler.
  • Integration with UnionFS.
  • Addition of many new tools like:
    • silktools
    • argus v3
    • dhcpdump
    • rtpbreak
    • pktstat
    • isic
    • tftpgrab
    • flowtag
    • yahsnarf
    • lots more!
  • Inclusion of zsh in addition to bash.
  • Lots of base package upgrades.
  • Additional signatures for fl0p, pads and tcpXtract.
  • Additional scripts for packet statistics and analysis.
  • NSM-Console updated to 0.8-dev.
  • Addition of Firefox plugins and bookmarks for network security.
  • New fluxbox themes and desktop wallpapers :)

Check out the HeX Trac page for the full list of what’s changed in this release. You can also check out some screenshots of the new release on Geek00l’s blog post. In addition to this release, we’ve begun working on the HeX Sensor project, for a drop-in NSM sensor, hopefully we’ll have a release of that soon!

Thanks to the development team for all the work that went into this awesome release! Feel free to leave a comment about any new features you’d like to see, or join us on the mailing list or irc (#rawpacket on Freenode) to hang out and talk about ideas for the next release. Enjoy!

Vim setup explained

September 14, 2008

Since my site is named after a Vim command. I figured that I should eventually write something talking about my favorite text editor, and how I like it configured. What follows is the explanation of my .vimrc, as well as a description of the plugins that I use. A lot of the credit for this configuration goes to Bart Trojanowski, who has an excellent Vim configuration. At the bottom I’ll have a link to download any of the files themselves if you so desire. I hope you find it useful (everything in fixed-width font is the actual text, everything else is comments about it):

My ~/.vimrc:

Modelines have been abused in the past, and while I haven’t heard of anything lately that would abuse them, it’s always better safe than sorry. This requires the securemodelines vim script

" ---------------------------------------------------------------------------
" first the disabled features due to security concerns
set modelines=0               " no modelines [http://www.guninski.com/vim1.html]
let g:secure_modelines_verbose=0 " securemodelines vimscript
let g:secure_modelines_modelines = 15 " 15 available modelines

Since these are all simple features, I won’t bother to explain them besides the inline comments:

" ---------------------------------------------------------------------------
" operational settings
syntax on
set ruler                     " show the line number on the bar
set more                      " use more prompt
set autoread                  " watch for file changes
set number                    " line numbers
set hidden
set noautowrite               " don't automagically write on :next
set lazyredraw                " don't redraw when don't have to
set showmode
set showcmd
set nocompatible              " vim, not vi
set autoindent smartindent    " auto/smart indent
set expandtab                 " expand tabs to spaces
set smarttab                  " tab and backspace are smart
set tabstop=6                 " 6 spaces
set shiftwidth=6
set scrolloff=5               " keep at least 5 lines above/below
set sidescrolloff=5           " keep at least 5 lines left/right
set backspace=indent,eol,start
set showfulltag               " show full completion tags
set noerrorbells              " no error bells please
set linebreak
set cmdheight=2               " command line two lines high
set undolevels=1000           " 1000 undos
set updatecount=100           " switch every 100 chars
set complete=.,w,b,u,U,t,i,d  " do lots of scanning on tab completion
set ttyfast                   " we have a fast terminal
filetype on                   " Enable filetype detection
filetype indent on            " Enable filetype-specific indenting
filetype plugin on            " Enable filetype-specific plugins
compiler ruby                 " Enable compiler support for ruby
set wildmode=longest:full
set wildignore+=*.o,*~,.lo    " ignore object files
set wildmenu                  " menu has tab completion
let maplocalleader=','        " all my macros start with ,
set foldmethod=syntax         " fold on syntax automagically, always
set foldcolumn=2              " 2 lines of column for fold showing, always

set dictionary=/usr/share/dict/words " more words!

I do like candycode for my terminals (which tend to be black) and I like macvim for my GUI, so I change schemes depending on which I’m using.

if !has("gui_running")
      colorscheme candycode   " yum candy
end
if has("gui_running")
      colorscheme macvim      " macvim == win
      set guioptions-=T       " no toolbar
      set cursorline          " show the cursor line
end

For the taglist plugin, I want it to appear on the right and to quick vim as soon as I close the last file I’m working on.

" Settings for taglist.vim
let Tlist_Use_Right_Window=1
let Tlist_Auto_Open=0
let Tlist_Enable_Fold_Column=0
let Tlist_Compact_Format=0
let Tlist_WinWidth=28
let Tlist_Exit_OnlyWindow=1
let Tlist_File_Fold_Auto_Close = 1

Misc TOhtml settings

" Settings for :TOhtml
let html_number_lines=1
let html_use_css=1
let use_xhtml=1

My status line is basically <filename> [<filetype>] [+] #<buffernum> <linenum>/<totallines>,<columnnum>

" ---------------------------------------------------------------------------
" status line
set laststatus=2
if has('statusline')
        function! SetStatusLineStyle()
                let &stl="%f %y "                       .
                        \"%([%R%M]%)"                   .
                        \"%#StatusLineNC#%{&ff=='unix'?'':&ff.'\ format'}%*" .
                        \"%{'$'[!&list]}"               .
                        \"%{'~'[&pm=='']}"              .
                        \"%="                           .
                        \"#%n %l/%L,%c%V "              .
                        \""
        endfunc
        call SetStatusLineStyle()

        if has('title')
                set titlestring=%t%(\ [%R%M]%)
        endif

endif

More simple search options, see inline comments

" ---------------------------------------------------------------------------
"  searching
set incsearch                 " incremental search
set ignorecase                " search ignoring case
set hlsearch                  " highlight the search
set showmatch                 " show matching bracket
set diffopt=filler,iwhite       " ignore all whitespace and sync

I *occasionally* use the mouse. If I have to.

" ---------------------------------------------------------------------------
"  mouse stuffs
set mouse=a                   " mouse support in all modes
set mousehide                 " hide the mouse when typing
" this makes the mouse paste a block of text without formatting it
" (good for code)
map <MouseMiddle> <esc>"*p

I prefer not to litter my current directory with backup files, so I put them all in ~/.backup. I also save a lot of line positions in the viminfo file.

" ---------------------------------------------------------------------------
"  backup options
set backup
set backupdir=~/.backup
set viminfo=%100,'100,/100,h,\"500,:100,n~/.viminfo
set history=200
"set viminfo='100,f1

I use ,ss to toggle between spellcheck on and spellcheck off.

" ---------------------------------------------------------------------------
" spelling...
if v:version >= 700

  setlocal spell spelllang=en
  nmap <LocalLeader>ss :set spell!<CR>

endif

Here are all the keyboard shortcuts I use most often:

" ---------------------------------------------------------------------------
" some useful mappings
" Y yanks from cursor to $
map Y y$
" for yankring to work with previous mapping:
function! YRRunAfterMaps()
    nnoremap Y   :<C-U>YRYankCount 'y$'<CR>
endfunction
" toggle list mode
nmap <LocalLeader>tl :set list!<cr>
" toggle paste mode
nmap <LocalLeader>pp :set paste!<cr>
" change directory to that of current file
nmap <LocalLeader>cd :cd%:p:h<cr>
" change local directory to that of current file
nmap <LocalLeader>lcd :lcd%:p:h<cr>
" correct type-o's on exit
nmap q: :q
" save and build
nmap <LocalLeader>wm  :w<cr>:make<cr>
" open all folds
nmap <LocalLeader>fo  :%foldopen!<cr>
" close all folds
nmap <LocalLeader>fc  :%foldclose!<cr>
" ,tt will toggle taglist on and off
nmap <LocalLeader>tt :Tlist<cr>
" ,nn will toggle NERDTree on and off
nmap <LocalLeader>nn :NERDTreeToggle<cr>
" When I'm pretty sure that the first suggestion is correct
map <LocalLeader>r 1z=

I use this one quite often, as I often forget to do “sudo vim file” in the first case, now I don’t have to exit vim to write the file with sudo.

" If I forgot to sudo vim a file, do that with :w!!
cmap w!! %!sudo tee > /dev/null %
" ruby helpers
iab rbang #!/usr/bin/env ruby
iab idef def initialize

I think candycode looks good in all the color modes, but it’s still nice to set it up for different terms.

" ---------------------------------------------------------------------------
" setup for the visual environment
if $TERM =~ '^xterm'
        set t_Co=256
elseif $TERM =~ '^screen-bce'
        set t_Co=256            " just guessing
elseif $TERM =~ '^rxvt'
        set t_Co=88
elseif $TERM =~ '^linux'
        set t_Co=8
else
        set t_Co=16
endif

Switch between tabs with ,tn and ,tp

" ---------------------------------------------------------------------------
" tabs
" (LocalLeader is ",")
map <LocalLeader>tc :tabnew %<cr>    " create a new tab
map <LocalLeader>td :tabclose<cr>    " close a tab
map <LocalLeader>tn :tabnext<cr>     " next tab
map <LocalLeader>tp :tabprev<cr>     " previous tab
map <LocalLeader>tm :tabmove         " move a tab to a new location

Load extensions we need and change some format options for markdown files.

" ---------------------------------------------------------------------------
" auto load extensions for different file types
if has('autocmd')
        filetype plugin indent on
        syntax on

        autocmd BufReadPost *
                \ if line("'\"") > 0|
                \       if line("'\"") <= line("$")|
                \               exe("norm '\"")|
                \       else|
                \               exe "norm $"|
                \       endif|
                \ endif

        " improve legibility
        au BufRead quickfix setlocal nobuflisted wrap number

        " improved formatting for markdown
        " http://plasticboy.com/markdown-vim-mode/
        autocmd BufRead *.mkd  set ai formatoptions=tcroqn2 comments=n:>
        autocmd BufRead ~/.blog/entries/*  set ai formatoptions=tcroqn2 comments=n:>
endif
And that’s the .vimrc
Here are some of the plugins that I used:
  • NERD Commenter – auto comment sections of code
  • NERD Tree – display file tree for directories, like a project view
  • Alternate – Alternate between implementation and header files
  • Compview – Search for a word and display a window with results
  • GetLatestVimScript – Get the latest version of scripts
  • Matchit – Extended % matching
  • Rails – Tons of RoR stuff
  • Securemodelines – Secure modeline support
  • Taglist – display a list of tags from the file
  • VCScommand – help with files under revision control
  • Vimball – install vimball plugins
  • Yankring – have a ring of copy/paste buffers for history pasting
  • C – A collection of helpful things for C (Although mine is heavily customized)
Enough with text, here’s a couple of screenshots of how it looks:


I maintain a pretty-up-to-date copy of most of my configuration files in my github dotfile repository, that’s the best way to get this configuration as well as all the plugins that I use, you can download a tarball of all the files from the github (direct link: here) page as well.

Well, hope someone out there finds these configuration files useful. I welcome any feedback :)

Soon to come: an explanation of the project that I’ve been working on that has taken me away from blogging for so long, an Intrusion Detection System based on Locality events.

Update 10/23/08: After some theme changes, updated screenshot (no NERDtree or taglist shown in the image):

Update 12/9/09: Been over a year, just for a teaser of what it looks like now:

cljjava

Firefox/Safari on OSX’s keyboard annoyances

August 21, 2008

I use keyboard shortcuts. A lot. So much in fact, that I find it incredibly annoying when websites create their own keyboard shortcuts for their pages. Most wiki-type pages (Wikipedia, Trac, Twiki) all use keyboard shortcuts on their sites.

I am a firm believer that application-level keybindings should always take precedence over website keybindings, no matter what. Not only is this in line with the conceptual view of how the two interact, but it’s better for security reasons, take, for example, the keyboard shortcuts to access the preferences for almost all applications on OSX: Apple+, (or CMD)

Why stop with usability features like focusing the find box? Why not overwrite the keyboard shortcut for accessing the preferences for a browser, trick the website user into clicking on something he or she should not be clicking on. (Note that it requires javascript. Firefox’s popup blocker will catch it, but Safari’s does not, it also looks more realistic in Safari).

Here’s an example, a page that I’m hosting (it doesn’t do anything malicious ;) )

Use CMD+, to open the preferences for either safari or firefox, I used firefox for this example, but I could just have easily used safari. I mocked this up in about 5 minutes, I could easily have opened a page instead of just an image also.

Did you see the fake preferences window? Now tell me how many people (non-technical users) would immediately know that this window was not the real preferences window for Firefox? What if the website had a “How-to” guide for setting a Firefox preference, and encouraged the user to “Press CMD+, to open the preferences, then click on <blah> and type <blah>”. If the website showed a picture of a false preferences panel and said “It’s perfectly normal for firefox preferences to ask for your password, enter it into the box on the ‘Security’ tab”, how many users might be tricked into doing that? You could write a guide for setting a preference that was actually a phishing site.

Comeon browser devs, don’t let javascript steal ALL the shortcuts, at least don’t pass browser-specific shortcuts to the site BEFORE handling them. (Or make it an option you have to turn on?)

Thoughts? What do you think, should websites have the ability to capture keystrokes? Should browser developers pass things through? What about a site-(white|black)list for keyboard shortcuts?

Flowtag FreeBSD port

July 14, 2008

I just finished up the FreeBSD port for Chris and Scholar’s flowtag. Flowtag is a neat tool for tagging network streams for collaboration and analysis. I’ve submitted the port to FreeBSD’s mailing list, so I’m hoping for upstream soon. In the meantime, you can download the port files on my miscellaneous page.

In other news, development on Hex 2.0 continues forward, we’re trying to get ports finished for inclusion in the ISO, (which is what spawns the flowtag porting), malware analysis took a backseat to sysadmin work due to a rather large project that just finished up. Hopefully I’ll have more time to post here soon, here’s what I’ve been working on:

– A simple C program to measure the index of coincidence of a file (for binary data instead of strings). This was going great until I tried it on a non-OSX OS, now I’m running into segfaults trying to get it to run on Linux (does read() behave differently or something?). I’ve also ported it to Windows (which works), but was a giant pain due to the fact that I don’t ever use Visual Studio.

– A binary file to hex string beautifier; basically, take binary data and print it in really nice strings for either a ruby or a C program. Why? Because I’m tired of manually formatting data for programs.

– A program to generate data with variable amounts of randomness (this is really used for work, but I might end up posting it here depending on whether I think it’s neat enough).

– Rewriting labview (our internal machine allocation management software). Okay, so Jon’s really doing most of the work, but that’s mostly because I don’t know how to do SQL “relations”, I’ll do more of the development soon enough.

– Biking to work. Yea, this isn’t technical, but I got a new bike so I’ve been trying to cut down on the commute, save gas, all that kind of stuff.

UPDATE: Just got an email the flowtag port has been committed, it should be showing up the next time you do a “cvsup” :)

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org