Skip to content

Instantly share code, notes, and snippets.

@krisf
krisf / gist:2344104
Created April 9, 2012 15:05
lol im a baddie
class ProfilesController < AuthorizedController
before_filter :extract_location, :only => :search
def search
search_terms = params[:profile].keep_if {|key, val| !val.blank? && val != '0'}
search_terms.each{|key, val| search_terms[key] = true if val == '1'}
if @location_params[:name]
@locations = Location.near(@location_params[:name], @location_params[:within], {:select => "locations.*, profiles.*", :units => :km}).joins(:profile).has_user_role.where(:profiles => search_terms)
current_hometown_filter_for_search(@locations)
profile_ids = @locations.map{|loc| loc.profile_id}.compact.uniq
@krisf
krisf / gist:1319972
Created October 27, 2011 15:57
registry fun in ruby
def create_registry_keys(data)
require 'win32/registry'
data.each do |key, value|
path = key.split("\\").delete_at(-1).delete_at(0).join("\\")
root = key.split("\\").first
key = key.split("\\").last
if root == "HKEY_CURRENT_USER"
hive = Win32::Registry::HKEY_CURRENT_USER.new
else
hive = Win32::Registry::HKEY_LOCAL_MACHINE.new
@krisf
krisf / setup.sh
Created July 23, 2011 18:25 — forked from huobazi/setup.sh
Ubuntu setup for Ruby, Nginx, Postgres 9, Rails
#!/bin/bash
# install dependencies
apt-get update && apt-get upgrade
apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
# install RVM
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
### as per RVM instructions (both files)