View encrypt_with_ssh_public_key.sh
# The secret info we want to send (for us, this is the SFTP private key)
ruby -e '500.times { print "secret " }' > secret.unencrypted
# Generate the password
openssl rand 128 -out password.unencrypted
# Encrypt the secret with the password
openssl enc -aes-256-cbc -salt -in secret.unencrypted -out secret.encrypted -pass file:./password.unencrypted
# Get the public key we'll use to encrypt the password (this uses my public key, swap it for whoever you want to send the message to)
View obj_model_intro_gamut.md

The Ruby Object Model (intro) aka "How Ruby Works"

What

The underlying structures that Ruby uses to interpret your code

Why

More effective (explains more, simpler) than whatever you're otherwise doing

View implementable_examples.md

What is an implementable example?

I'll omit generalizations and make this overly concrete as I think it will be easier to understand what I'm looking for here.

An implementable example is a small example of a programming library that uses the core ideas of of the library. Its purpose is to make the interface very explicit, so that someone can say "if I didn't have this library, how would I make the example actually work?" and then go implement their solution and see it

View parse_otf.rb
# WOFF spec https://www.w3.org/TR/2012/REC-WOFF-20121213/
# OTF spec https://www.microsoft.com/en-us/Typography/OpenTypeSpecification.aspx
# Really nice inspector https://opentype.js.org/font-inspector.html
# unpack instructions http://www.rubydoc.info/stdlib/core/String#unpack-instance_method
# Font programming instruction definitions https://developer.apple.com/fonts/TrueType-Reference-Manual/RM05/Chap5.html#WS
# Font forge has some useful info, too, get it with homebrew cask
FONT_FILE = '/Users/xjxc322/gamut/bots/pxgamut_regular.woff'
require 'zlib'
View tco.c
#include <stdio.h>
int square(int n) {
return n * n;
}
int main(int argc, char const *argv[]) {
int a = 3;
int b = 2;
square(a);
View what_is_a_poro.rb
# There is no official definition, this is the one I propose:
# Something is a PORO if it inherits from Object.
# The further you stray from that, the murkier it gets.
# Note that "A inherits from B" is basically the same thing as "A's superclass is B"
# Explicitly inheriting from Object
class Poro1 < Object
end
Poro1.superclass # => Object
View generating_bytecode.rb
def cancel
authorize OrderIssue
order_issue = OrderIssue.find(params[:id])
order_issue.cancel!
render_results(:results => order_issue,
:status => :ok,
:serializer => OrderIssueSerializer)
end
code = File.read(__FILE__).lines[0...__LINE__-1].join
View sql_injection_and_parameterizing_queries.rb
require 'active_record'
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
ActiveRecord::Base.logger = Logger.new $stdout
ActiveSupport::LogSubscriber.colorize_logging = false
ActiveRecord::Schema.define do
create_table(:users) { |t| t.string :name }
end
# Create some users
User = Class.new ActiveRecord::Base
View rule_n.rb
require 'graphics'
require 'set'
class RuleN < Graphics::Simulation
def initialize(pixel_size, w, h)
self.pixel_size = pixel_size
self.rule_index = 30
self.needs_draw = true
self.cursor_pixel_offset = 0
self.initial_pixel_offsets = Set[0]
View ruby_parsing_and_vm.rb
code = <<-RUBY
class A
def whatevz
if 1
2
else
3
end
end
end