Skip to content

Instantly share code, notes, and snippets.

View clemens's full-sized avatar
:octocat:
Getting sh*t done

Clemens Kofler clemens

:octocat:
Getting sh*t done
View GitHub Profile
class SectionsCell < BaseCell
tracks_cache_references :recent_articles, :track => ['@section', '@articles']
exposes_states :recent_articles => {
:name => 'Recent articles',
:description => 'A cell containing a given number of recent articles, optionally from a certain section.'
}
def recent_articles
# TODO make these before filters
def has_authorized_tag(*args)
# @response.body.should have_authorized_tag(*args)
has_tag "span[class^=newsletter_stats]" do
has_tag *args
end
end
def have_authorized_tag(*args)
have_tag('.newsletter_stats') # { |tag| tag.should have_tag(*args) }
end
applyOrRemoveFCKeditors = function() {
filter = $$('select.columnsFilter').first();
// transform all textareas to FCKeditors, but only if filter is set to plain HTML
if(filter && $F(filter) == '') {
// by default, apply FCKeditor to all textareas
$$('textarea.use-wysiwyg').each(function(t) {
// some calculations
height = t.getDimensions()['height'];
if(height == 0) height = 200; // default height = 200px
Processing UsersController#update (for 127.0.0.1 at 2009-02-10 20:50:19) [PUT]
Parameters: {"user"=>{"profile_attributes"=>{"dog_color"=>"gold", "race_id"=>"1", "dog_preferences"=>"nix", "dog_age"=>"4", "dog_name"=>"Coba", "picture"=>#<File:/tmp/CGI.9218.9>, "dog_gender"=>"f"}}, "step"=>"1", "commit"=>"Speichern!", "action"=>"update", "_method"=>"put", "authenticity_token"=>"ffb9373e16afccea668e046c96acd7f8c2b1e1bc", "controller"=>"users", "locale"=>"de"}
Site Load (0.7ms) SELECT * FROM "sites" WHERE ("sites"."host" = 'hunde-date.local') LIMIT 1
Section Load (0.9ms) SELECT * FROM "sections" WHERE ("sections"."parent_id" IS NULL) AND ("sections".site_id = 1) ORDER BY lft, lft LIMIT 1
Theme Load (0.3ms) SELECT * FROM "themes" WHERE ("themes".site_id = 1 AND (active = 1)) 
User Load (0.5ms) SELECT * FROM "users" WHERE ("users"."id" = 1) LIMIT 1
CACHE (0.0ms) SELECT * FROM "sites"
clemens-koflers-computer:url_history clemens$ rg test/all.rb
Loaded suite test/all
Started
.F..FFF...F.F..
Finished in 0.086139 seconds.
1) Failure:
test_registers_the_after_filter(UrlHistoryActMacroTest)
[./test/act_macro_test.rb:17:in `test_registers_the_after_filter'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:94:in `__send__'
SELECT * FROM locations
WHERE (
SELECT COUNT(*) FROM taggings
WHERE tag_id IN (
SELECT tags.id FROM tags
WHERE tags.name = 'Bar' OR tags.name = 'Restaurant'
) AND taggable_type = 'Location' AND taggable_id = locations.id
) > 1
{
:en => {
:salutation => {
:gender => {
:male => "Mr",
:female => "Mrs",
:female_unmarried => "Ms"
}
:full => lambda { |attributes|
gender_salutation = I18n.t(:"salutation.#{attributes[:gender]}")
# UNTESTED!
# spec
it_should_require_admin_for_actions :new => :get, :create => :post, :edit => :get, :update => :put, :destroy => :delete
# macro
def it_should_require_admin_for_actions(actions={})
actions.each do |action, method|
it "#{action} action (with method #{method}) should require admin" do
send(method, action, :id => 1)
response.should redirect_to(login_url)
# highly experimental Capistrano recipe for adva-cms-based apps
# UNTESTED
set :adva_cms_repository, "git://github.com/svenfuchs/adva_cms.git" # set this to something different if you want to use a fork
set :adva_engines, :core # list desired engines as array or use :all to install all engines
set :adva_plugins, [] # list desired plugins as array or use :all to install all plugins
namespace :adva do
desc "Install selected engines."
task :install do
def calendar_proc
lambda do |day|
content = returning '' do |content|
content << content_tag(:span, day.day)
content << "<ul>"
Event.all.select { |e| e.on_day?(day) }.each do |event|
content << content_tag(:li, link_to(event.title, event_path(event))
end
content << "</ul>"
end