Skip to content

Instantly share code, notes, and snippets.

Notes

This is the latest version of an email which I send periodically, offering customers the opportunity to pre-pay for SaaS in return for a discount. The benefits to the SaaS company are better cash flow and reduced churn rate. The benefits to the customer are, well, in the email. This genre of email has produced hundreds of thousands of dollars in pre-pays for some companies I work with, and it rarely requires any more work than this example.

I've put $79 is as a placeholder for the cost of the user's plan. We calculate that for each account, naturally, along with the billing contact's name.

Subject: Save $79 on Appointment Reminder (and get a tax write-off) Formatting: 100% plain text. Gmail automatically links up the central link. From: Patrick McKenzie (Appointment Reminder) patrick@appointmentreminder.org

@latortuga
latortuga / poodr.rb
Created February 17, 2015 21:10
ecoding5
$ ruby poodr.rb
poodr.rb:20:in `prepare_trip': undefined method `each' for nil:NilClass (NoMethodError)
from poodr.rb:6:in `block in prepare'
from poodr.rb:5:in `each'
from poodr.rb:5:in `prepare'
from poodr.rb:54:in `<main>'
@latortuga
latortuga / gist:ca7ed1d87593640f0d8f
Created April 20, 2015 18:48
Rails #18952 reproduction
require 'active_record'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Schema.define do
create_table :somethings, force: true do |t|
t.integer :age
t.integer :count
end
end
class Something < ActiveRecord::Base
# Imagine we have a form that only sets user name for verified users
class Form
include ActiveModel::Model
attr_accessor :name
def save(user)
user.name = name if user.verified?
end
end
@latortuga
latortuga / 1minitest.md
Last active August 29, 2015 14:27
ARGH-V

Run tests via Minitest how it's supposed to work

# manual way
Minitest.run(args)

# magic way
require 'minitest/autorun'
# or
Minitest.autorun
@latortuga
latortuga / 1_terrible.erb
Last active September 9, 2015 22:13
CSV Renderer/Helper
<%= CSV.generate do |csv| %>
<% csv << ["All Orders"] %>
<% csv << [] %>
<% total = 0.0 %>
<% orders.each do |order| %>
<% csv << [order.id, order.subtotal, order.tax, order.shipping, order.total] %>
<% total += order.total %>
<% end %>
<% csv << [] %>
<% csv << ["Total", total] %>
def method_name
state.thing_that_throws
rescue
state.error
ensure
state.thing
state
end
@latortuga
latortuga / gemfromgit.md
Created October 26, 2010 23:00
Install gem from git
$ git clone git://github.com/author/gem_name
$ cd gem_name

install dependencies, sudo gem install xxx

$ rake gem

$ sudo gem install pkg/gem_name-1.1.1.gem

@latortuga
latortuga / gitsvn.md
Created October 26, 2010 23:07
Git-svn tricks

Some of this is pulled directly from the git-svn man page.

Push a local git-branch to a new remote new-svn-branch

git svn branch new-svn-branch

now there is a new remote tracking branch, confirm with git branch -r to push local git-branch changes to the new svn branch git checkout git-branch git rebase --onto new-svn-branch OR from master (this seems to work better) git rebase --onto new-svn-branch master git-branch

@latortuga
latortuga / refresh_css.js
Created October 27, 2010 19:26 — forked from mikelikespie/refresh_css.js
CSS reload bookmarklet
/*
Add a bookmark to this
javascript:(function(){var c=document.getElementsByTagName("link");for(var d=0;d<c.length;d++){var a=c[d];if(a.type=="text/css"){var e="css_buster_"+Math.floor(Math.random()*1000000000);var g=a.href.split("?",1);var f;if(g.length>1){var b=g[1].indexOf("&")==-1;if(b){f=e}else{f=g[1]+"&"+e}}else{f=e}a.href=g[0]+"?"+f}}})();
*/
(function() {
var links = document.getElementsByTagName('link');
for (var i = 0; i < links.length; i++) {
var l = links[i];
if (l.type == 'text/css') {