Install nginx:
$ brew install nginxUse custom launchctl plist (see homebrew.mxcl.nginx.plist below):
| # Enables {command,ctrl}+enter on all textareas | |
| # Author: Nick Giancola (@patbenatar) | |
| $ -> | |
| $("textarea").keydown (e) -> | |
| if (e.ctrlKey or e.metaKey) and e.keyCode is 13 | |
| $("textarea").closest("form").submit() |
| class MyModel < ActiveRecord::Base | |
| private | |
| # Allow mass-assignment of the type attribute | |
| def self.attributes_protected_by_default | |
| super - %W[ type ] | |
| end | |
| end |
| module Admin::TicketsHelper | |
| def admin_tickets_table(tickets) | |
| Tabular.build(tickets) do |table| | |
| # If we're simply adding a few columns where the header would be the | |
| # humanized attribute name and the row would contain the attribute `.to_s` | |
| # then we can use the simple `#columns` method. | |
| table.columns :id, :title | |
| # If the column has custom logic for row values, we can use the `#column` | |
| # method to define it |
| require "benchmark" | |
| Benchmark.bm(7) do |bench| | |
| bench.report("single") do | |
| 1_000_000.times do | |
| 'This is a string of substantial length. I doubt you will have many string | |
| literals in your code that are longer than this, but if there are actually | |
| costs to parsing double quoted strings this should exacerbate that.' | |
| end | |
| end |
| # config/routes.rb | |
| MyApp::Application.routes.draw do | |
| devise_for :users, controllers: { | |
| registrations: "users/registrations" | |
| } | |
| end |
| @FBootloader = new class FBootloader | |
| callbacks: [] | |
| isReady: false | |
| ready: -> | |
| callback() for callback in @callbacks | |
| bind: (callback) -> | |
| if @isReady | |
| callback() |
| class Admin < ActiveRecord::Base | |
| attr_accessor :invite | |
| devise :database_authenticatable, :registerable, :recoverable, :rememberable, | |
| :trackable, :validatable | |
| def self.new_invited(attributes) | |
| new(attributes.merge(invite: true)) | |
| end |
| projects $ lein -v | |
| Leiningen 2.0.0-preview7 on Java 1.6.0_33 Java HotSpot(TM) 64-Bit Server VM | |
| projects $ lein new test | |
| Generating a project called test based on the 'default' template. | |
| To see other templates (app, lein plugin, etc), try `lein help new`. | |
| projects $ cd test/ | |
| projects $ vim project.clj | |
| test $ cat project.clj | |
| (defproject test "0.1.0-SNAPSHOT" | |
| :description "FIXME: write description" |
The following before filter looks for any Hash parameters where all the keys are integers and turns them into Arrays. It searches recursively to allow the used of nested attributes within nested attributes. This is necessary to circumvent a bug in the strong_parameters gem which was reported in April 2012. Given params like:
{
"person" => {
"dogs_attributes" => {
"0" => {
"name" => "Fido"