Aaron Van Bokhoven / aaronvb

I am a Software Developer and a Portrait Film Photographer.
  • I love coding with Ruby and Ruby on Rails, and I love shooting with film.
  • I currently live in Honolulu, Hawaii, but frequent Chicago and California.
  • I believe that programming is a form of art, like painting and photography, where you can express your ideas and logic and see it transform into something real.
Aaron Van Bokhoven
photo: kipkeston
Email me at bokhoven@gmail.com. View my Photography Portfolio and my Photo Blog (tumblr). I'm also on Twitter.

My current work:

Hawaii Photo Rental
http://www.hawaiicamera.com
Buoy Alarm
http://buoyalarm.com
Flux Hawaii Magazine
Summer 2011, Fall 2011, Winter 2011(cover) issues
http://fluxhawaii.com

Open source contributions:

Coffee-Resque (my fork)
https://github.com/aaronvb/coffee-resque
Pow
http://pow.cx (github)
My Gists
http://gist.github.com/aaronvb

You can also find me at:

Github
http://github.com/aaronvb
Photography portfolio
http://aaronvb.com/photo
Junkparty
http://junkparty.com
Flickr
http://flickr.com/photos/aaronvb

Oct 24, 2009

Prototyping a site in Ruby on Rails and need to add a simple search feature in less than 5 minutes?

Note: This should be for smaller projects because I'll be using regular SQL queries for searching. If you're looking for something more advanced, try thinking_sphinx(sphinx engine) or sunspot_solr(java lucene solr engine).

I'll be using Searchlogic and will_paginate in this demo.


#install searchlogic
sudo gem install searchlogic

#install will_paginate
gem sources -a http://gemcutter.org
sudo gem install will_paginate

Then add the gem to the environment file.


#config/environment.rb

config.gem "binarylogic-searchlogic", :lib => "searchlogic"
config.gem 'will_paginate', :version => '~> 2.3.11'

If you prefer to use github or the plugin version, check out their docs. I also suggest reading their docs to learn more about all the neat functions Searchlogic can do. It's a very powerful and useful plugin.

We'll be adding the search to Posts, so let's start by adding the search route to our posts.


#config/routes.rb

map.resources :posts, :collection => { :search => [ :post, :get ] }

This will give you the path /posts/search GET and POST.

Next add the search method to the PostsController.


#app/controllers/posts_controller.rb

class PostsController < ApplicationController

def index
@posts = Post.paginate(:all, :order => 'created_at desc', :per_page => 25, :page => params[:page])
end

def search
if request.post?

#pass the post into a get with the 'q' param
redirect_to search_posts_path(:q => params[:search][:query])

elsif request.get?

unless params[:q].blank?

#Searchlogics title_like_all to search within titles in the Post model for any of the words in the query.
#words in the string are split into an array by spaces
search = Post.title_like_all(params[:q].to_s.split).descend_by_created_at

#paginate the results
@posts = search.paginate(:per_page => 25, :page => params[:page])

#pass the query object to the view to let the user know what they searched for
@query = params[:q]

end

#render the Post index.html.erb
render 'index'

end
end

end

The last part is the search form in your view.



<% form_for :search, :url => { :controller => 'posts', :action => 'search' } do |f| %>
<%= f.text_field :query, :value => @query%>
<%= f.submit "Search", :disable_with => "Searching..." %>
<% end %>


Oct 19, 2009

I have the Voigtlander Nokton 50/f1.1 for the next week and I'm planning on running several rolls side-by-side against my Zeiss Planar 50/f2.

I'm considering replacing the Planar with this so we'll see. I'm a little skeptical though, since Zeiss bokeh is pretty hard to beat imo.

Stay tuned for results and photos!

Zeiss 50/f2 Planar vs Voigtlander 50/f1.1 Nokton - time to play!


Sep 05, 2009

I've become so normalized to formatting and wiping my OS clean every year/update during my Windows days that I decided to do the same with Snow Leopard. I also decided it would be a great time to upgrade the harddrive in my laptop to the WD 320gb 7200rpm.

After finishing that I followed the guides over at Hivelogic to get everything setup and running again. One thing to note was installing a ruby 1.8.6 since Snow Leopard by default installs 1.8.7 and my production server is running on Ruby Enterprise(1.8.6).

Compiling Ruby, RubyGems, and Rails on Snow Leopard
Compiling MySQL on Snow Leopard
Compiling Git on Snow Leopard



© Aaron Van Bokhoven