Skip to content

Instantly share code, notes, and snippets.

View oliyoung's full-sized avatar

Oli Young oliyoung

View GitHub Profile
@oliyoung
oliyoung / gist:65707
Created February 17, 2009 11:52
grabbing the locale from the user's browser
before_filter :set_localization
def set_localization
# Set the language
I18n.locale = if session[:locale]
session[:locale]
elsif logged_in? && current_member.locale
current_member.locale.code
elsif !accepted_languages.empty?
accepted_languages.first.first
rescue_from ActiveRecord::RecordNotFound, :with => :missing_record
rescue_from ForbiddenError, :with => :unauthorised
def missing_record
render :status => 404, :file => '404', :layout => true
end
def unauthorised
render :status => 403, :file => '403', :layout => true
end
def f(ra,n)
r=0
ra.each {|x| r+=1 if x.include? n}
r
end
require 'rubygems'
require 'sinatra'
require 'httparty'
class Representative
include HTTParty
end
get '/' do
erb :form
end
get '/:username' do
@oliyoung
oliyoung / cruisecontrol.sh
Created November 13, 2009 05:41
installing LAMP stack with subversion, xdebug and phpUndeControl
#!/bin/bash
# belongs in /etc/init.d/cruisecontrol
PIDFILE=/opt/cruisecontrol/cc.pid
start() {
ebegin "Starting CruiseControl"
cd /opt/cruisecontrol/
./cruisecontrol.sh > /dev/null 2>&1
eend $?
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
run "rm README public/index.html public/favicon.ico public/robots.txt"
gem 'aws-s3', :lib => 'aws/s3'
gem 'geokit'
gem 'oauth'
gem 'factory_girl'
gem 'paperclip'
gem 'facebooker'
gem 'binarylogic-authlogic', :lib => 'authlogic', :source => 'http://gems.github.com'
oli@laptop]:project $ sudo gem uninstall geokit
Successfully uninstalled geokit-1.5.0
[oli@laptop]:project $ sudo gem install geokit
Successfully installed geokit-1.5.0
1 gem installed
Installing ri documentation for geokit-1.5.0...
Installing RDoc documentation for geokit-1.5.0...
Could not find main page README.txt
Could not find main page README.txt
@oliyoung
oliyoung / hevent.html
Created October 27, 2010 00:09
hEvent example
<div id="event_22" class="event vevent">
<h4 class="summary"><a class="url" href="/places/nepenthe/events/2010-11-07-sunday-sessions">Sunday Sessions</a></h4>
<p class="date"><span title="2010-11-07T13:00:00" class="dtstart"> 1pm</span> &mdash; <span title="2010-11-07T17:00:00" class="dtstart"> 5pm 07 November 2010</span></p>
<p class="location"><span class="fn">Nepenthe</span>, Jones Road, Balhannah, South Australia, 5242</p>
<div class="geo">
<abbr title="-35.006217" class="latitude">-35.006217</abbr>
<abbr title="138.825938" class="longitude">138.825938</abbr>
</div>
</div>
var xhr = Titanium.Network.createHTTPClient();
var url = 'http://greatsawineadventure.com.au/wineries/'+win.place.slug+'.json'
xhr.open('GET',url);
xhr.onload = function() {
var resp = eval('('+this.responseText+')');
}
xhr.send();