Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / gist:966615
Created May 11, 2011 14:59
Database design snapshots
Designers need fleshed out pages to do properly design a screen.
In the past, we've loaded test fixtures in development to give them that.
But test fixtures are not a good fit for this.
They're designed to make testing easy, not designing.
What we need instead is a way for a designer to create a dataset
that'll work great for design and then save that as a snapshot.
This snapshot can be named and reloaded as often as desired.
I envision it'll work like this:
@dhh
dhh / gist:966575
Created May 11, 2011 14:43
Mailbag feature
class NotesController < ApplicationController
def create
@note = @project.notes.create params[:note].merge(
creator: current_user, subscribers: extract_subscribers(params[:note]))
@note.subscribers.each { |subscriber| Subscriptions.note(@note, subscriber).deliver }
end
end
class Subscriptions < ActionMailer::Base
def revoke(user)
proxy_association.owner.tap do |project|
# You can't remove the last user with access (someone has to have access to the project!)
if project.users.many?
if user.pending? && user.projects.one?
user.destroy
else
project.users.delete(user)
user.touch
end
Hi David,
My name is Jeff Morse. I'm a Recruiter at a super-charged start-up called Mixbook www.mixbook.com I came across your profile on workingwithrails and have a full-time Sr. Ruby on Rails opening working onsite in our Palo Alto, California office that is a great match for your background/experience. Would you be ready to make the move to Silicon Valley, the most innovative place for web start ups which offers superior growth opportunities for talented ruby developers like yourself? Mixbook will pay for all relocation costs.
Would you be open to taking a phone/Sykpe call from our CTO, Aryk Grosz (see attached LinkedIn profile) to discuss the position further? If interested, email me your Skype ID and I’ll coordinate the call with Aryk.
Cheers,
Jeff Morse
Sr. Recruiter
Hi,
My name is Charles Bernoskie and I noticed that XYZ Corp is looking
for a LAMP developer. Many of the qualifications you are looking for in a
developer (e.g. PHP, Python, MySQL, Java) are identical to those of a
daily Stack Overflow user.
Stack Overflow is the largest programming community(Over 20mm visitors
per month) with the fastest growing career section for developers on the
internet. We offer a satisfaction guarantee. If you are not completely
arrogance:
inbox: feedback
conversation: arrogance
sender: hater (Contact)
subject: Less arrogance!
excerpt: You guys really shouldn't be so arrogant!
bug:
inbox: security
conversation: bug
@dhh
dhh / gist:7226428
Created October 30, 2013 02:40
Recruiter spam
Attention Talented Ruby on Rails Coders,
My new client is an exciting startup in the SF Bay area which has just closed on VC
funding and is actively seeking to hire several senior-level RoR coders with 3+ years of experience. They are a web and mobile platform solution allowing artists (singers, film-makers, etc.) to sell digital content directly to the consumer. They have already established multiple celebrities as members and are rapidly acquiring more. The position offers competitive salary, benefits, and pre-IPO stock options.
We are not looking for any contractors, telecommuters, or people who wish to work from remote locations. This situation may change after the company becomes more mature, but there is a strong consensus that on-site, full-time employees are required at this early stage.
We have actually already filled the CTO and CIO positions with the company in record time, largely because qualified candidates were immediately aware of the unique market-position of this company and the dynam
@dhh
dhh / redmine_timelog_controller_create.rb
Last active May 13, 2016 13:36
Partial refactoring of https://github.com/redmine/redmine/blob/master/app/controllers/timelog_controller.rb#L104. That whole controller would need a serious amount of work to be whipped into shape, but this is a start.
class TimeEntriesController < ApplicationController
before_action :set_project, :set_issue
def create
@time_entry = container.time_entries.build time_entry_params.merge(user: User.current)
if @time_entry.save
respond_to do |format|
format.html { redirect_back_or_default created_time_entry_url, notice: l(:notice_successful_create) }
format.api { render :show, status: :created, location: @time_entry }
# app/views/posts/new.html.erb
<%= form_for(Post.new) do |form| %>
Title: <%= form.text_field :title %>
Body: <%= form.text_field :body %>
<% end %>
...would produce a signature field that can be used to automatically untaint:
<input type="hidden" name="signature" value="....">
  1. First-use of the message template
<% renders messages/_message.html.erb %>
<%= render @messages %>
  1. Form submitting via Ajax
<%= form_for @project.messages.new, remote: true do |form| %>
 ...