Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
-module(bowling).
-export([score/1, test/0]).
test() ->
9 = score([{7, 2}]),
% 4 6 8 9 5 0 3 1 0 4
40 = score([{1,3},{2,4},{3,5},{5,4},{2,3},{0,0},{1,2},{1,0},{0,0},{1,3}]),
% 4 6 8 12 5 0 3 1 0 4
-module(chopstick).
-export([start/1, loop/2]).
start(Number) ->
spawn(chopstick, loop, [Number, nobody]).
loop(Number, Owner) ->
receive
{take, Owner} -> loop(Number, Owner);
{take, NewOwner} when Owner =:= nobody ->
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - X X X X X X X X X X X X - - - - - - -
- - - X X - - - - - - - - - - - - X X - - - - -
- - - X - - - - - - - - - - - - - - - X - - - -
- - - X - - - X X X - - - X X X - - - - X - - -
- - X X - - - - - X X - X X - - - - - - - X - -
- - X - - - - - X X X - X X - - - - - - - X - -
- - X - - - - - X X X - - X - - - - - - - X - -
- - X X - - - - - - X X - X X - - - - - X - - -

I appreciate all form of contribution, but for some contributors a greater sense of awareness about how OSS works would go a long way. The more you leave undone in a pull request or the more you leave unanswered in a bug report, the more “work in progress” your contribution adds to a project.

So for example, say you report a bug, but you only explain it with a sentence or two of english -- no stack trace, no minimal example reproducing the problem, and no tests. At that point, there’s nothing I can do except ask you to provide more information to help me investigate further, unless your problem is very obvious the moment I look at it.

Once we at least have the means to reproduce a bug, we need to make sure it’s isolated and not coming from some lower level problem. That means writing further sets of examples, and poking around in the source until we’re fairly sure where the bug is coming from.

Once that source of the problem has been identified, we need to work on a fix, but we need to take care to make

require_relative "helper"
### Parse the sections of the document into a params dictionary
parser = FormLetter::Parser.new
parser.rewrite(:emails, :deadline)
parser.rewrite(:date) { Date.today.strftime("%b %d, %Y") }
# this would come from a database or other source,
module PrawnCalender
module DocumentExtensions
def calender(*a)
draw CalenderWidget.new, *a
end
end
class CalenderWidget
# ...
end

Establish a quality-centric mindset

Having high quality standards for your project is a matter of practicality, not pride. To understand why, it helps to remember that "bad code" is typically hard to understand, hard to test, hard to change, and hard to reuse. Regardless of how useful your project is to the world right now, these problems will get in the way of its future progress.

Any one of these negative traits of bad code can make a maintainer's job painful, but when you combine all four of them it is like wearing a pair of lead boots while trying to run a marathon. Even if you are capable of supporting your project in its current state, these hindrances will gradually chip away at your ability to be responsive to the needs of your users while simultaneously eating up time and energy that you could be using to improve your project's strengths rather than fighting against its weaknesses. Once you head down this road, your project stops being fun to work on, and starts feeling more like a burden.

Once

module Greeter
def greet(name)
"HELLO, #{Name.normalize(name)}!"
end
module Name
def self.normalize(name)
name.strip.upcase
end
end
Greeter = Object.new
class << Greeter
def greet(name)
"HELLO, #{normalize(name)}!"
end
private
def normalize(name)
Hello Practicing Rubyist!
This is just a quick question for you about something I'm working on.
It should only take you a few seconds to answer, so please give
me feedback if you can.
I'm currently experimenting with the idea of building self-guided
courses for Practicing Ruby's readers, which will consist of
recommended readings from our archives as well as from
around the web, practice exercises, discussion questions,