“...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 who are based in Denmark...”

Rob Lacey
Senior Software Engineer, Copenhagen, Denmark

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

OnePassword account reset

I appear to have forgotten my OnePassword password again, and having reset everything I couldn’t work out how to force the deletion of the old credentials that clearly I wasn’t able to login with. I went round and round, I could even see a list of accounts but with no way to reset them. Turns out it’s rather expertly hidden under Help > Troubleshooing.

Not exactly where I was expecting but hey hey.

What language is this?

Just because I am incredibly mean. I put together this little Quiz Round.

Question 1

You’re basic.

05 REM ON VALUE GOTO LINE1,LINE2,LINE3.. demo
10 TEXT : HOME
20 INPUT "Enter number 1,2 or 3: ";A
30 IF NOT(A=1 OR A=2 OR A=3) GOTO 10
40 ON A GOTO 100,200,300

100 PRINT "LINE 100" : GOTO 500
200 PRINT "LINE 200" : GOTO 500
300 PRINT "LINE 300" : GOTO 500

500 END

.
.
.
.
.

Question 2

I’ll give you anything you want, but I’ll always get my take.

import re
for test_string in ['555-1212', 'ILL-EGAL']:
    if re.match(r'^\d{3}-\d{4}$', test_string):
        print (test_string, 'is a valid registration for a snake')
    else:
        print (test_string, 'rejected')

.
.
.
.
.

Question 3

Hopefully this one doesn’t fuck with your brain.

--<-<<+[+[<+>--->->->-<<<]>]<<--.<++++++.<<-..<<.<+.>>.>>.<<<.+++.>>.>>-.<<<+.

.
.
.
.
.

Question 4

Wake me up.

<script>
var x = 5;
var y = 6;
var z = x + y;
document.getElementById("coffee").innerHTML =
"The value of z is: " + z;
</script>

.

.
.
.
.
.

Question 5

Drink this, it will make you feel better.

true = String.ends_with?("Youth.", ".")

# True if any of list values match:
true  = String.ends_with?("Youth.", [".","?"])
false = String.ends_with?("      !", [".","?"])

.
.
.
.
.

Question 6

I like to pummel it until it’s proper mashed up.

#!/bin/bash

string1="Linux"
string2="Hint"
echo "$string1$string2"
string3=$string1+$string2
string3+=" is a good place to fight"
echo $string3

.
.
.
.
.

Question 7

Well it’s been 40 years of silence, it’s been 40 years of pain.

class Cat
  def can_claw_your_face_up?
    true # dat
  end
  
  def empathise_with_your_existential_crisis?
    !really?
  end

  private

  def really?
    true
  end
end

.
.
.
.
.

Question 8

A, B, D, E, F, G, H, I , J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z

#include <stdio.h>
int main() {
   int year;
   printf("Enter a year: ");
   scanf("%d", &year);

   // leap year if perfectly visible by 400
   if (year % 400 == 0) {
      printf("%d is a leap year.", year);
   }
   // not a leap year if visible by 100
   // but not divisible by 400
   else if (year % 100 == 0) {
      printf("%d is not a leap year.", year);
   }
   // leap year if not divisible by 100
   // but divisible by 4
   else if (year % 4 == 0) {
      printf("%d is a leap year.", year);
   }
   // all other years are not leap year
   else {
      printf("%d is not a leap year.", year);
   }

   return 0;
}

.
.
.
.
.

Question 9.

Queer eye for the the interwebs.

.cascading {
  border: 1px solid blue
}
.style {
  height: 100px
}
.sheets {
  border-radius: 5px
}

.
.
.
.
.

Question 10

I’ve come to see the Oracle, I need answers.

procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
    Image1.Picture.LoadFromFile(OpenDialog1.FileName);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Image2.Canvas.CopyRect(
    Rect(0,0,Image2.Width,Image2.Height),
    Image1.Canvas,
    Rect(
      0,
      0,
      Image1.Picture.Width-50,
      Image1.Picture.Height-50));
end;

.
.
.
.
.

No more RI / RDoc

In 10 years I have never once used installed RI or RDoc documentation, so let’s not bother installing it.

Adding this to ~/.gemrc will mean it is never built

gem: --no-document

And then nuke all currently installed documentation.

rm -rf `gem env gemdir`/doc

Boom.