Skip to content

Instantly share code, notes, and snippets.

@CamonZ
CamonZ / gist:180122
Created September 3, 2009 03:47 — forked from linojon/gist:180120
before_filter :newer_browser_required
def newer_browser_required
# ref http://pastie.org/203799
# reject MSIE 5.0 and MSIE 6.0
browser_access_denied if request.user_agent =~ /msie\s+[5,6]\.\d+/i
end
def browser_access_denied
@CamonZ
CamonZ / _form.html.haml
Created September 8, 2009 00:27
Polymorphic Autosave Associations with Paperclip
= f.error_messages
%div{:style=>"padding-bottom:20px"}
%div
= f.label :name, 'Nombre del producto'
%br
= f.text_field :name, :size => 70
#clientdesc
%div
= f.label :excerpt, 'Resumen del producto'
%br
@CamonZ
CamonZ / my.god
Created September 8, 2009 07:07 — forked from nofxx/my.god
#
# God please,
#
# Generic Monitor
#
def generic_monitoring(w, options = {})
w.interval = 30.seconds # default
w.start_if do |start|
start.condition(:process_running) do |c|
c.interval = 10.seconds
@CamonZ
CamonZ / url_dsl.rb
Created December 14, 2009 20:05 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
- # app/views/posts/_post.html
%h1= post.title
...
%p Actions:
%ul
- # checking the authorizations on the view...
%li= edit_post_path(post) if current_user.can?(:update, post)
%li= post_path(post) if current_user.can?(:read, post)
recent_photographs GET /photographs/recent(.:format) {:action=>"recent", :controller=>"photographs"}
photographs GET /photographs(.:format) {:action=>"index", :controller=>"photographs"}
photograph GET /photographs/:id(.:format) {:action=>"show", :controller=>"photographs"}
if RAILS_ENV == 'production'
Paperclip.options[:command_path] = "/usr/bin"
else
Paperclip.options[:command_path] = "/usr/local/bin"
end
describe "should return a string as a latitude and longitude csv" do
it {should respond_to(:latlong)}
@p = Factory.create(:store)
@p.latlong.should equal("10.502792,-66.842322")
end
// geo-location bridge
function getLocation(callback){
if (getLocation.cache) return callback(getLocation.cache);
if (Modernizr.geolocation) {
var geocallback = function(position) {
callback(getLocation.cache = {
"lat": position.coords.latitude,
"lon": position.coords.longitude,
namespace :deploy do
task :start do; end
task :stop do; end
desc "restart passenger server"
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end