Skip to content

Instantly share code, notes, and snippets.

representation "text/html", "application/xhtml+xml" do
transitions do
view "Edit page", Site/Page/URL, "application/vnd.com.example.wiki.page.editable"
view "View raw contents", Site/Page/URL, "text/plain"
view "Show page history", Site/History/URL
view "Other pages under #{path}", Site/Pages/path
end
response_is("text/html") { processor.call request }
class Blog
include Waves::Resource::Server
resource :list, :expires => 3.days, [ ‘blogs’ ] do
get { model.find_all }
end
resource :element, :expires => 3.days, [ ‘blog’, :name ] do
get { model.find_by_name( captured.name ) }
desc "Stop agents from running background tasks"
task :stop do
if File.exist?( pidfile )
pid = File.read( pidfile ).to_i
if pid > 0
puts "Stopping agents (process #{pid})."
Process.kill('INT', pid.to_i ) rescue nil
end
`rm #{pidfile}`
else
class CompanySweeper < ActionController::Caching::Sweeper
observe Company, Comment, Document, Order, Trade
%w( create update destroy ).each do | action |
define_method( "after_#{action}") do | instance |
%w( index companies/* pages/home ).each { |p| `rm -rf public/cache/views/#{p}.html.cache` }
end
end
broadway:SharesPost danyoder$ git checkout controls
Switched to branch 'controls'
broadway:SharesPost danyoder$ git merge l2
Auto-merging app/controllers/asks_controller.rb
CONFLICT (content): Merge conflict in app/controllers/asks_controller.rb
Auto-merging app/controllers/bids_controller.rb
CONFLICT (content): Merge conflict in app/controllers/bids_controller.rb
Auto-merging app/controllers/orders_controller.rb
Auto-merging app/models/ask.rb
CONFLICT (content): Merge conflict in app/models/ask.rb
new function(_) { // create the closure
// create the package object
var shapes = new base2.Package(this, {
name: "shapes",
version: "1.0",
exports: "PI,Circle,Rectangle"
});
// evaluate the imported namespace
eval(this.imports);
module MetaHelper
# include this anywhere you want to refer to the model, controller, etc., generically
# all methods are prefixed with x_ to avoid name clashes with existing methods
def x_controller_class ; self.class ; end
def x_controller_name ; self.class.name.underscore.gsub('_controller', '') ; end
def x_model_name ; x_controller_name.singularize ; end
def x_model_class ; x_model_name.camelize.constantize ; end
def x_mailer_name ; x_model_name + "_mailer" ; end
book (
title: Why Pez Is Better Than You're Mom
author: Lonnie Tran
price: (19.95):usd
description: |-
Learn the fabulous stack-based language, Pez! Also,
you're Mom follows me on Twitter!
)
DELIMITERS = [ ['(',')'], ['{','}'], ['[',']'] ]
def match?( string, stack = [] )
return true if string.empty? and stack.empty?
first = string[0,1] ; DELIMITERS.any? do | open, close |
case first
when open then match?( string[1..-1], stack.clone.push( close ) )
when close then match?( string[1..-1], stack ) if stack.clone.pop == close
else false
end
end
require 'waves/foundations/compact'
module Foo
include Waves::Foundations::Compact
module Resources
class Server
on( true ) { "hello" }
end
end
end