Skip to content

Instantly share code, notes, and snippets.

View lacco's full-sized avatar

Kai Schlichting lacco

  • Germany, Berlin
View GitHub Profile
source ~/.git-completion.sh
alias gco='git co'
alias gci='git ci'
alias grb='git rb'
namespace :yard do
desc "Generate yard documentation of controllers and models"
task :doc do
`yardoc app/models/**/*.rb app/controllers/**/*.rb config/routes.rb --output yardoc --protected`
puts "Generated doc to yardoc/index.html"
end
desc "Generate UML graph (requires dot, download Graphviz from http://www.graphviz.org/)"
task :graph do
#TODO use --db to specify specific yardoc db, but this doesn't seem to work with current version of yard-graph
begin
require_dependency 'application_controller'
rescue LoadError => e
puts e
puts e.backtrace.join("\n")
require_dependency 'application'
end
[...]
>> HistoryItem.new(:historytype => "Foo").valid?
Foo
[]
=> true
>> HistoryItem.new(:historytype => "Foo").valid?
Blub
["Foo"]
=> true
kschlichting@debian:/home/jmueller/.cruise/projects/ticketsystem/work$ sudo rake gems:install
(in /home/jmueller/.cruise/projects/ticketsystem/work)
kschlichting@debian:/home/jmueller/.cruise/projects/ticketsystem/work$ sudo gem list
*** LOCAL GEMS ***
actionmailer (2.3.4, 2.3.3, 2.3.2)
actionpack (2.3.4, 2.3.3, 2.3.2)
activerecord (2.3.4, 2.3.3, 2.3.2)
activeresource (2.3.4, 2.3.3, 2.3.2)
require 'factory_girl'
Dir["spec/factories/*"].each{|f| require f}
Factory.create :product
#=> new product with id=12
Product.first.update_versioned(:charge_interval => 'daily')
#=> new product with id=13
Product.all(:conditions => "id IN (select id from abstract_products group by name, edition having max(version))")
#=> Finds 12 instead of 13
Product.all(:conditions => 'version = (SELECT MAX(version) FROM abstract_products AS inner_abstract_products WHERE inner_abstract_products.name = abstract_products.name)')
#=> Finds 13 correctly
/**
* Registering callbacks on property setters.
*/
for(var prop in object){
// Ignore functions
if(typeof object[prop] !== 'function'){
(function(obj, attr) {
// If object does not already have a getter
if (!object.__lookupGetter__(prop)) {
// This variable will hold the value of the property
## Heckle for Rails
# Calls heckle for each method of each model
# Idea: Instead of exluding ActiveRecord methods, grep model file for existing methods
# Load all models
Dir['app/models/**/*.rb'].each {|f| require_dependency f}
# Search all model classes
klasses_to_heckle = ActiveRecord::Base.send(:subclasses)-[ActiveRecord::SessionStore::Session]
@lacco
lacco / tribute.rb
Created February 24, 2010 00:25 — forked from burke/tribute.rb
def dsl &b
Class.new{
def r&b;instance_exec &b
end; def method_missing s,*_
@m=[s,*@m];end}.new.r &b
<?xml version="1.0" encoding="UTF-8"?>
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
<!-- Unroll the form (theme, components, inclusions) -->