This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Brainfuck | |
attr_reader :data, :data_pointer, :instruction_pointer, :code | |
def initialize(code) | |
@data = Hash.new(0) | |
@data_pointer = 0 | |
@instruction_pointer = 0 | |
@code = code | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def weekday(day, month, year) | |
day_names = %w(Saturday Sunday Monday Tuesday Wednesday Thursday Friday) | |
century = (year.to_f / 100.0).floor | |
year_of_century = year % 100 | |
month += 12 if month < 3 | |
h = (day + | |
((13 * (month + 1)) / 5.0).floor + | |
year_of_century + | |
(year_of_century / 4.0).floor + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; An Introduction to Emacs Lisp | |
;;; Harry Schwartz, 2014 | |
;; What we'll be covering: | |
'(atoms | |
functions | |
lists | |
variables | |
defining-functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 | |
french | |
2 | |
chat | |
cat | |
papillon | |
butterfly | |
spanish | |
2 | |
gato |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The key difference between public and private methods is that you | |
# can call public methods on instances of the class, but you can't | |
# call private methods on instances of the class. | |
# You can only call private methods *inside* the class. It's fine for | |
# a public method to call a private method, but you can't call a | |
# private methods directly on an instance. | |
class Wombat | |
def eat_bacon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# attr_reader/writers/accessors are handy shortcuts for creating | |
# getter and setter methods. That's all they're for. | |
# An attr_reader creates a getter method. For example, the following | |
# two classes have identical effects: | |
class NamedWombat | |
attr_reader :name | |
def initialize(name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am hrs on github. | |
* I am hrs (https://keybase.io/hrs) on keybase. | |
* I have a public key whose fingerprint is 1B41 8F2C 23DE DD9C 807E A74F 841B 3DAE 25AE 721B | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p (0..1000000).count{rand<Math.sqrt(1-rand**2)}/250000.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class SayRepl | |
attr_reader :voice | |
def initialize(voice) | |
@voice = voice | |
end | |
def go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class UnixProcess | |
attr_reader :uid, :pid, :ppid, :cmd | |
def initialize(uid:, pid:, ppid:, cmd:) | |
@uid = uid | |
@pid = pid | |
@ppid = ppid | |
@cmd = cmd |
OlderNewer