Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
MODES = { "0" => "---",
"1" => "--x",
"2" => "-w-",
"3" => "-wx",
"4" => "r--",
"5" => "r-x",
"6" => "rw-",
"7" => "rwx" }
def permissions(num)

From http://www.cse.ohio-state.edu/~neelam/courses/788/lwb.pdf

A type specification contains the following information:

  • The type's name
  • A description of the type's value space
  • For each of the type's methods:
    • its name
    • its signature (including signalled exceptions)
  • its behavior in terms of preconditions and postconditions
class Parser
rule
string
| a_or_cs abb
| abb
;
a_or_cs
: a_or_cs a_or_c
| a_or_c
;
class Parser
rule
string
| a_or_cs abb
| abb
;
a_or_cs
: a_or_cs a_or_c
| a_or_c
;
# Defines a parser roughly equivalent to the regular expression
# pattern /(a|c)*abb/
#
# To try it out, run the following commands:
#
# $ gem install racc
# $ racc parser_example.y -o parser
# $ ruby parser abb
# $ ruby parser acccaaaabb
# $ ruby parser zaaa
this_is.a_really_really.really.really.really.really.really.really
.long.method_chain # continuation of the line above
this.is_some +
math.split_across_lines
this(is: "some",
keyword_args: "across lines")
Start every day coding, end every day thinking.
1. Warmup exercise (30 mins)
Make sure to have these ready the night before, pick stuff
that you can work on right away without having to study
in advance.
They can either be book exercises or stuff
from other sources, but they should be self-verifiable
class Proxy
def initialize(document, style)
@document = document
@style = style
end
def text(string, params)
params[:size] ||= @style[:font_size]
params[:color] ||= @style[:font_color]
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,
Greeter = Object.new
class << Greeter
def greet(name)
"HELLO, #{normalize(name)}!"
end
private
def normalize(name)