Original Author: Rui Ueyama (creator of the mold linker)
Translated by @windowsboy111
Minimally edited by @lleyton
This file contains hidden or 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
| Measure = Data.define(:amount, :unit) do | |
| def diff(other) | |
| raise ArgumentError.new("other must be same class") unless other.is_a?(self.class) | |
| members.inject({}) do |memo, key| | |
| thisVal, otherVal = send(key), other.send(key) | |
| memo[key] = [thisVal, otherVal] unless thisVal == otherVal | |
| memo | |
| end |
This file contains hidden or 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
| # Using OpenStruct to mimic an object with the 'posts method' | |
| user = OpenStruct.new(posts: [:post1, :post2]) | |
| # Using if user as a nil checker | |
| user.posts if user | |
| # => [:post1, :post2] | |
| # Can be replaced with the safe navigation operator | |
| user&.posts | |
| # => [:post1, :post2] |
You're taking your first steps into Ruby
A good introduction to programming in general. Easy on newer programmers.
- Do you have an Github account ? If not create one.
- Install required tools
- Latest Git Client
- gpg tools
# Ubuntu
sudo apt-get install gpa seahorse
# MacOS with https://brew.sh/
This file contains hidden or 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 | |
| require 'pdf/reader' # gem install pdf-reader | |
| # credits to : | |
| # https://github.com/yob/pdf-reader/blob/master/examples/text.rb | |
| # usage example: | |
| # ruby pdf2txt.rb /path-to-file/file1.pdf [/path-to-file/file2.pdf..] | |
| ARGV.each do |filename| | |
| PDF::Reader.open(filename) do |reader| |