Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
/* http://meyerweb.com/eric/tools/css/reset/ | |
v2.0 | 20110126 | |
License: none (public domain) | |
*/ | |
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
font-size: 100%; |
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
end | |
end |
The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render
in a controller when we want to respond within the current request, and redirect_to
when we want to spawn a new request.
The render
method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form'
or render @post.comments
, but here we'll focus on usage within the controller.
// migration.rb | |
class AddTransactionsToRsvp < ActiveRecord::Migration | |
def change | |
add_column :rsvps, :transactions, :string, array: true, default: [] | |
end | |
end | |
// gig_post_helper.rb | |
def duration_tag_collection |
#(Ruby - Using class_eval to define methods)[http://stackoverflow.com/questions/9561072/ruby-using-class-eval-to-define-methods] | |
class Class | |
def attr_accessor_with_history(attr_name) | |
attr_name = attr_name.to_s # make sure it's a string | |
attr_reader attr_name | |
attr_reader attr_name+"_history" | |
class_eval %Q" | |
def #{attr_name}=(value) | |
if !defined? @#{attr_name}_history | |
@#{attr_name}_history = [@#{attr_name}] |