Skip to content

Instantly share code, notes, and snippets.

<%= form_tag registration_index_path do %>
<%= fields_for User.new do |u| %>
<%= u.label :phone %>
<%= u.text_field :phone %>
<% end %>
<p>
<%= label_tag :workout %>
<%= check_box_tag :workout %>
</p>
<p>
@danneu
danneu / home
Created February 21, 2012 01:02 — forked from anonymous/home
home
<% @posts.each do |post|%>
<div id="recentpost">
<%= post.name %><br/><br/>
</div>
<% end %>
@danneu
danneu / ios.c
Created August 17, 2012 05:16 — forked from mahemoff/ios.c
iOS example
// Async web fetch with JSON parse
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"url"]]
queue:nil completionHandler:^(NSURLResponse *r, NSData *d, NSError *e) {
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:d
options:0
error:nil];
}];
// Using the camera
@danneu
danneu / passwords_controller.rb
Created October 23, 2012 05:26 — forked from kazpsp/passwords_controller.rb
StrongParameters with Devise
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
private :resource_params
end
@danneu
danneu / gist:4049606
Created November 10, 2012 02:33 — forked from JFickel/gist:4049601
Procfile
# Procfile
web: bundle exec rails server -p $PORT
faye: bundle exec thin -p 8081 -R faye_config.ru start
# config/routes.rb
namespace :api, defaults: {format: "json"} do
namespace :v1 do
resources :wines
end
end
# wines_controller
class WinesController
def index
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
begin;
create table user_ratings (
id serial primary key,
user_id integer not null,
rating integer not null check (rating >= 0 and rating <= 5),
ratable_id integer not null
);
create function random_int(max integer) returns integer as $$
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix.
;;
;; * :use makes functions available without a namespace prefix
;; (i.e., refers functions to the current namespace).
;;
;; * :import refers Java classes to the current namespace.
;;
(In views/layouts/application.haml)
%html
= yield :application_with_nested_layout
= yield