“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay...”

Rob Lacey (contact@robl.me)
Senior Software Engineer, Brighton, UK

I'm a bit Rust(y), thought I'd learn summat new

use std::io::stdin;

struct Visitor {
    name: String,
    greeting: String
}

impl Visitor {
    fn new(name: &str, greeting: &str) -> Self {
        Self {
            name: name.to_lowercase(),
            greeting: greeting.to_string(),
        }
    }

    fn greet_visitor(&self) {
        println!("{}", self.greeting);
    }
}

fn main() {
    println!("Hello, what's your name?");
    let your_name = what_is_your_name();

    if your_name == "bert" {
        println!("Hello, {:?}", your_name);
    } else {
        println!("No, {}, Just no", your_name)
    }

    let visitor_list: [&str; 2] = ["bert", "ernie"];

    for i in 0..=10 {
        println!("{}", i);
    }

    let mut allow = false;

    for v in 0..visitor_list.len() {
        if visitor_list[v] == your_name {
            allow = true;
            println!("Yeah, whatever {}", your_name);
        }
    }

    if allow {
        println!("OK, {}. After much debate. You smell!", your_name)
    }
}

fn what_is_your_name() -> String {
    let mut your_name = String::new();
    stdin().read_line(&mut your_name).expect("FAAIIIILLLED!!!");
    your_name.trim().to_lowercase()
}

MySQL OpenSSL missing?

Ever had this one?

rails aborted!
LoadError: dlopen(/Users/b/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 9): Library not loaded: libssl.1.1.dylib
  Referenced from: /Users/b/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/b/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle
/Users/b/rails_projects/ring/config/application.rb:29:in `<top (required)>'
/Users/b/rails_projects/ring/Rakefile:4:in `require_relative'
/Users/b/rails_projects/ring/Rakefile:4:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)

I get the impression this is the solution.

gem install mysql2 -v 0.5.3 -- --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib

How many routes does my Rails app have?

Simple.

::Rails.application.routes.routes.size

I don't normally do Python, but...

Needs must, as all the best cool kids are making Constraints Solvers in Python. Shall I rewrite Practical Python AI Projects: Mathematical Models of Optimization Problems in Ruby? Might be funs.

Anyway, Chapter 1 introduced a simple solver, but this is even simpler.

A Whole Lotta Ruby

Trying to clean up this machine and it would appear I’ve got 21Gb of just Ruby.

I mean I like Ruby, sure. But I don’t need 4billion versions.

Styling broken images like a boss

Found this little gem for styling broken images so they don’t look all of the wrong.

I am not here. No really I am not.

Really liking this, the empty images default is just awful.

img {  
  position: relative;
}

/* style this to fit your needs */
/* and remove [alt] to apply to all images*/
img[alt]:after {  
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  font-family: 'Helvetica';
  font-weight: 300;
  line-height: 2;  
  text-align: center;
  content: attr(alt);
}

The Big Learn - Elixir

1. Elixir is not Ruby

2. It’s not quite Erlang either, Elixir is different

3. Assignment is not assignment, it’s making sure stuff matches

iex(18)> a = 1
1
iex(19)> 1 = a
1
iex(20)> 2 = a
** (MatchError) no match of right hand side value: 1
    (stdlib) erl_eval.erl:453: :erl_eval.expr/5
    (iex) lib/iex/evaluator.ex:257: IEx.Evaluator.handle_eval/5
    (iex) lib/iex/evaluator.ex:237: IEx.Evaluator.do_eval/3
    (iex) lib/iex/evaluator.ex:215: IEx.Evaluator.eval/3
    (iex) lib/iex/evaluator.ex:103: IEx.Evaluator.loop/1
    (iex) lib/iex/evaluator.ex:27: IEx.Evaluator.init/4
iex(20)> a = 2
2
iex(21)> 2 = a

_why this is the only book you ever need

If you’ve never heard of why the lucky stiff perhaps you’ve been living under a rock for the past 10 years and hitting your Ruby apps with a blunt tuna. They wrote a ton of stuff in Ruby such as Hpricot, Shoes, Syck, Camping, I could go on I won’t.

_why also wrote an online book called why’s (poignant) guide to ruby, it’s inspirational and funny and bat shit silly. You should read it. I managed to get a physical copy because someone decided to put lots of effort into making it so.

If you ever find this, buy it, read it, code till your fingers are a bit sore.

Copying S3 objects around, even between buckets.

Saved some bandwidth and moved stuff around to get our house in order. Need to remember this example.

source = 'downloads.bigblindmedia/download/files/files/000/000/929/original/Banded_Sandwich_by_Iain_Moran_Download.mp4'
target = 'download/videos/files/000/000/929/original/Banded_Sandwich_by_Iain_Moran_Download.mp4'

s3 = Aws::S3::Client.new(
  region: 'eu-west-2',
  access_key_id: '********',
  secret_access_key: '********'
)

s3.copy_object(
  copy_source: source, 
  bucket: 'downloads.bigblindmedia',
  key: target
)

That Hayball

A very good friend of ours James Hayball produced some great artwork for an online RPG, using my likeness for inspiration. He wanted a haggerred, bitter, fearful man, drenched in existential turmoil and who forgot to take the bins out. He came to the right place.

NB. I look think I look 25 because I am deluded