Skip to content

Instantly share code, notes, and snippets.

@rentalcustard
rentalcustard / 01_readme.markdown
Created October 25, 2010 11:20
Fix tmux bootstrap
View 01_readme.markdown

The author of this patch is 'toby' from the MacPorts project, and the original commit containing this diff can be found at https://trac.macports.org/changeset/58563. The trac ticket prompting the commit (and with additional context) is at https://trac.macports.org/ticket/18357.

Toby, if you're reading this, apologies for not attributing the gist originally; I put this up quickly while experimenting with tmux under Leopard and abandoned it when it didn't solve the problem at hand. It's only fair now that other people are looking at the gist to give you credit.

View sprints response.md

I read I Don't Believe in Sprints yesterday and found myself disagreeing with almost all of the article, while agreeing strongly with its headline. Here's my attempt to collect my thoughts about why.

The worst thing you can do in software development

The worst thing you can do in software development is building the wrong thing. If you build the wrong thing, you have to pay three costs:

  1. you pay the cost of delay for the valuable thing that you could have been building while you spent your time building the wrong thing;
  2. you pay the cost of maintenance on the software you've built, every moment up until the point you realize it's the wrong software and you delete it (and you pay the cost of deleting it, which may not be negligible by the time you get around to deleting it);
  3. you pay the frustration cost of realizing that the thing that you spent your time and effort building was
@rentalcustard
rentalcustard / gist:5524668
Last active January 13, 2022 14:21
Removing all literals from Ruby
View gist:5524668

Literals are ugly. Let's remove them.

True/false:

2.0.0p0 :001 > !Date
=> false
2.0.0p0 :002 > require Date.to_s.downcase
=> true

Integers and floats:

View gist:1170796
class Foo
def some_method
puts "In some_method"
def some_other_method
puts "In some other method"
"Foo"
end
"Bar"
end
end
View gist:d3bd2250409de20790254a7caf86e1c3
~> rails new binstubs_test
create
create README.md
create Rakefile
create config.ru
create .gitignore
create Gemfile
run git init from "."
Initialized empty Git repository in /Users/tomstuart/binstubs_test/.git/
create app
@rentalcustard
rentalcustard / fixpraisepres.js
Last active June 1, 2016 14:58
Small improvements thing
View fixpraisepres.js
var nameWithAvatar = function(person) {
return person.name + ' (' + person.logo + ')';
}
var buildMessageText = function(message) {
return [message.title, message.message].join(" - ");
}
var buildMessage = function(message) {
return 'Praise from ' + nameWithAvatar(message.author) + ' for ' + message.recipients.map(nameWithAvatar).join(" and ") + ': ' + buildMessageText(message);
View gist:6778183
11:30 < txus> what does "cis" mean??
11:30 < jkleske> mortice: no, definitely not.
11:30 < medk> 10:37 piman_ ➤ if you are comfortable with your birth sex/gender assignment, you are cis.
11:30 < fwg_> now we need the bot
11:32 < piman_> Just, in general, I don't like comparisons of "well, X is more diverse than Y", because it always seems to ignore some axes.
11:32 < mortice> fair
11:33 < mortice> i also don't think it's relevant; saying "berlin is more diverse than X" doesn't mean we don't have to work to improve diversity
11:33 < fwg_> well it can only be said as a subjective perception
11:33 < gkarekinian> Most meetups in Berlin are just white males
11:34 < jkleske> full ack
View gist:6165204
#if I have...
A.new(B.new(C.new(D.new)))
#is there some way (some inject sorcery?) to construct this from a list of the classes?
list = [A, B, C, D]
@rentalcustard
rentalcustard / gist:6112853
Created July 30, 2013 13:23
Show the contents of all files changed in a commit at the time of the commit
View gist:6112853
git show --name-only REVISION --pretty="format:" | while read file
do
echo $file:
git show REVISION:$file
done | cat
View Doing it in Ruby
1.9.3p448 :007 > Resource.all.sort_by(&:average_rating)
Resource Load (0.4ms) SELECT "resources".* FROM "resources"
Rating Load (0.3ms) SELECT "ratings".* FROM "ratings" WHERE "ratings"."resource_id" = $1 ORDER BY "ratings"."id" ASC LIMIT 1 [["resource_id", 1]]
Rating Load (0.2ms) SELECT "ratings".* FROM "ratings" WHERE "ratings"."resource_id" = $1 [["resource_id", 1]]
Rating Load (0.2ms) SELECT "ratings".* FROM "ratings" WHERE "ratings"."resource_id" = $1 ORDER BY "ratings"."id" ASC LIMIT 1 [["resource_id", 2]]
Rating Load (0.2ms) SELECT "ratings".* FROM "ratings" WHERE "ratings"."resource_id" = $1 [["resource_id", 2]]
=> [#<Resource id: 2, title: nil, summary: nil, link: nil, created_at: "2013-07-29 13:53:52", updated_at: "2013-07-29 13:53:52", user_id: nil>, #<Resource id: 1, title: nil, summary: nil, link: nil, created_at: "2013-07-29 13:52:36", updated_at: "2013-07-29 13:52:36", user_id: nil>]