Skip to content

Instantly share code, notes, and snippets.

# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 1.0 (buildd@palmer) Fri Apr 9 10:35:18 UTC 2010
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection
resources :houses do
resources :members
end
# Gemfile
config.gem "liquid"
# routes.rb
get "/handlers/:action", :to => "handlers"
# view/handlers/liquid.html.liquid
testing 1..2..3
# lib/handlers.rb
@roy
roy / gist:809280
Created February 3, 2011 09:48
Correct way of doing initializing one instance
var TestClass = Class.create({
initialize: function(){
//fancy stuff here
}
});
document.observe("dom:loaded", function(){ new TestClass(); });
// or
(function(){
@roy
roy / gist:822276
Created February 11, 2011 12:29
To code smell, or not to code smell: that is the question
# old
def build_form_response
form_response = self.form_responses.new
self.questions.each do |question|
form_response.answers.build(:question => question)
end
form_response
end
@roy
roy / gist:822341
Created February 11, 2011 13:33
tap enhancement
class Object
def tap(method =nil, *params, &block)
block.call(self) if block
self.send(method, *params) if method
self
end
end
@roy
roy / meta_where 3
Created February 17, 2011 09:08
how to chain these scopes with or
# rails3 + meta_where
name_relation = Article.where(:title >> "name")
name2_relation = Article.where(:title >> "name2")
# how to get an sql query like: "select * from articles where (title = 'name') or (title = 'name2')
def top_articles_for(widget_page_title, current_user)
article_relations = widget_page_widgets_for(widget_page_title, current_user).all.collect(&:widget).collect do |widget|
widget.top_articles
end
article_relations.inject {|sum, x| sum | x}
end
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Index</title>
<style type="text/css">
style {
display: block;
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Pimp</title>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://pimp.maggie.test.royapps.nl">
<!-- <meta HTTP-EQUIV="REFRESH" content="0; url=http://plugin.mspsite.com/action/showservice.jsp?homePath=http://www.mspportal.com/community&serviceid=grimradiolist&res=1280x720">-->
</head>
<body>