Skip to content

Instantly share code, notes, and snippets.

View mkwiatkowski's full-sized avatar

Michal Kwiatkowski mkwiatkowski

View GitHub Profile
begin;
/*
Problem: I don't want the application to really care about how the data is
structured in the database. The application / view code needs to work
with the data in a sane format, without worrying about normalization, joins,
eager fetching, etc.
DB Schema Overview:
orders
# Helper for PostgreSQL Sequences
# USAGE:
# SequenceHelper.nextval('somenumber_seq')
# SequenceHelper.currval('somenumber_seq')
# SequenceHelper.reset('somenumber_seq', 10)
class SequenceHelper < ActiveRecord::Base
# Verify that the sequence exists or create it
def self.verify(name, create = true, initial_value=1)
name.downcase!
class WebRequest
MOBILE_USER_AGENTS = r/palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\.b|webos|amoi|novarra|cdm|alcatel|pocket|ipad|iphone|mobileexplorer|mobile/i
attr_reader :time, :ip, :referer, :user_agent
def initialize(time, ip, referer, user_agent)
@time = time
@ip = ip
@referer = referer
@user_agent = user_agent