Docker + VS Code

It was pretty easy to set up a docker workstation that resembles the kind of env I use for node dev. I just needed to make a Dockerfile like this:

FROM ubuntu:latest
# I don't remember why I needed to set up timezone, TBH . I probably just Googled it somewhere after some warning during build.
ENV TZ=America/Winnipeg
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# I've just always used aptitude on Ubuntu. ag is just so much better than grep. etc.
RUN apt update && apt install aptitude sudo git silversearcher-ag vim -y
# This creates a new user for me. I prefer working with my own user instead of root.
RUN useradd -rm -d /home/username -s /bin/bash -g root -G sudo -u 1000 username
RUN echo 'username:password' | chpasswd

Build the image

From there you build the image with docker build -t dannyb/my-dev . inside the dir with the Dockerfile. This takes a few minutes.

Start the instance

Run docker run -d dannyb/my-dev to start the instance. Now it’s ready to be connected to with VS Code.

Connecting with VS Code

For VS Code setup, I followed these instructions. Now I just open up VS code, press ctrl-shift-P and select the Remote-Containers: Attach to Running Container... option. In the box that opens it will have all your running containers listed, along with the image they were created from. Select the one that says dannyb/my-dev and it basically mounts it. Open up the terminal and you’re logged in as root into the docker instance! The first thing I run there is su username to switch to my user, and cd to go to the user’s home dir.

Setting up SSH key to be able to clone repos

You might well know how this is done. I tend to run ssh-keygen, then cat ~/.ssh/id_rsa.pub to copy my pub key. Then you add it to GitHub or Bitbucket or wherever the repo you’re gonna work is.

After this is done, you can clone the repo. Once you’ve cloned the repo, press the “Open Folder” button in the Explorer sidebar of VS Code, and select the cloned repo dir. This actually restarts your terminal session, so just run su username again to switch to your user.

Installing node

I tend to do this with nvm. The installation instructions are pretty short. You can then install whatever version of node you need.

That’s pretty much it

There are any number of other things I end up setting up, specific to my likes and needs of the project.

Farm At Hand Chapter

Ended Googling my name looking for something else funny, but found this little gem I wanted to preserve in case it gets removed at some point…

Super dry and all business…from a FAH team blog post.

What’s your name? My Name is Dan Bernardić.

I’ve been a Web developer since… 2007

How did you become a Web developer? I completed a Bachelor of Science degree in Applied Computer Science from the University of Winnipeg. Since then, I’ve been working on developing my skill set and self-teaching at home and at work.

Where are you located? I work in the FarmLink office in Winnipeg’s Grain Exchange District. I’ve been living in Winnipeg since 2001, when I immigrated from Croatia.

What do you do at Farm At Hand? I work with the development team to create new functionality in the Farm At Hand web app.

I’ve been in the farmily since… FarmLink and Farm At Hand merged in January 2016.

What’s your experience with farming or agriculture? I’ve been working as a programmer in the Agriculture industry since 2013. First I was part of the Farm Business Communications team ( Western Producer, Manitoba Co-operator, Country Guide, etc. ). Additionally, I have about 2 years experience with FarmLink Marketing Solutions and Farm At Hand. I do not have farming experience otherwise.

What is the biggest thing you’ve learned about farmers and/or Agriculture since you joined Farm At Hand? Agriculture is the backbone of industry on the Prairies. Coming to Winnipeg as an adult immigrant, I only recently noticed that Winnipeg probably wouldn’t exist if it weren’t for Agriculture.

What’s one of your favourite moments? Farm At Hand is headquartered in Vancouver. I have not been many places outside of Manitoba, so I enjoyed visiting there when I first joined the team. Their weather is much more mild than in Winnipeg. It was great meeting the team, and I enjoyed talking about programming over fancy burgers and beer.

Winnipeg Code Retreat 2019

TL;DR

We are having a code retreat on Friday November 15th. Please send me your name and email here: https://bernardic.ca/contact/ . You can just say “Code Retreat” in the message, or write me a longer message with some information about you. I look forward to spending the day with you.

Code Retreat

From the Code Retreat Website:

A code retreat is a day-long, intensive practice event, focusing on the fundamentals of software development and design, away from the pressures of ‘getting things done’

At a code retreat, the attendees split into pairs, for 45 minute session of coding. When the 45 minutes are up, we share some learnings, pair up with a new partner and start coding from scratch again.

Conway’s Game of Life

During each of the code retreat’s 45 minute pair programming sessions, we work on a program that implements Conway’s Game of Life.

From Wikipedia article on Conway’s Game of Life:

The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead, (or populated and unpopulated, respectively). Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  1. Any live cell with fewer than two live neighbours dies, as if by underpopulation.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies, as if by overpopulation.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed; births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick. Each generation is a pure function of the preceding one. The rules continue to be applied repeatedly to create further generations.

Global Day of Code Retreat

Every year the GDCR organization sets a date for the global day of code retreat, which gives us an opportunity to make a local event out of it. During this day developers around the world get together with others in their communities and learn and practice their craft.

Winnipeg Code Retreat 2019

We will have the code retreat at the FarmLink / Farm At Hand office – suite 110 at 93 Lombard Avenue on November 15th.

If this sounds like something you’d like to try, contact me to attend.

P.S.

November 15th is a Friday. From the code retreat website:

Traditionally, the Global Day of Coderetreat takes place on Saturdays, but we also want to invite companies to promote educational opportunities for their employees by hosting a public coderetreat on Friday.

PHP: Peridot and Propel

Wanted to share a little configuration I just finished making for some Peridot and Leo -based tests which work with Propel models.

A bunch of these tests write data to the database using the Propel models, and I need a clean slate DB before each test. I also need a clean slate HTTP session. Here’s some code ( from peridot.php ) that uses transactions to achieve that:

class MyScope extends Scope {
  function __construct( $emitter ) {
    $emitter->on( 'peridot.execute', function() {
      $this->conn = Propel::getConnection();
    } );

    $emitter->on( 'test.start', function() {
      self::destroySession();
      // have to rollback and begin here.
      // it was unreliable when I rolled back on test.end
      $this->conn->rollback();
      $this->conn->beginTransaction();
    } );
  }
  private static function destroySession() {
    session_start();
    $_SESSION =[];

    // If it's desired to kill the session, also delete the session cookie.
    // Note: This will destroy the session, and not just the session data!
    if (ini_get("session.use_cookies")) {
      $params = session_get_cookie_params();
      setcookie(session_name(), '', time() - 42000,
        $params["path"], $params["domain"],
        $params["secure"], $params["httponly"]
      );
    }

    session_destroy();
  }
}

return function($emitter) {
  $gmsScope = new GmsScope( $emitter );

  //add this scope into every suite
  $emitter->on('suite.start', function($test) use ($gmsScope) {
    $test->getScope()->peridotAddChildScope($gmsScope);
  });
};

Start learning to become a web developer with the Flatiron School Prework

I ran across the Flatiron School of programming a while back, and I thought it was pretty cool. They have a “pre-work” list of resources for their web development course. I expect it is quite good.

I ran across Flatiron school when I listened to a podcast the founder of the school did. I think it is pretty inspiring.

OK, enjoy learning to program. I’m pretty excited for you!

p.s. This post was based on an email reply I wrote to a reader of this blog who asked me for some resources to start learning Ruby on Rails.

“CSS for Beginners: How to style your website using CSS” – this Saturday

If you’ve been looking to learn how to use CSS, and you’re in Winnipeg, come out to a workshop that will teach you just that, this Saturday.

The workshop is put on by the great people behind Ladies Learning Code, so you can be sure that the atmosphere will be great, and your teachers and peers supportive.

Let me know what you learned if you go.

Job Search Update

Since the last post I made, I’ve done a few things as part of being unemployed. Here’s a selection.

I got in touch with a recruiter in Ontario who hires nationally, through a developer friend who lives in Ontario, and based on our conversation, I told the recruiter that I am not as concerned about the technology used or that they match dollar for dollar my previous salary, but rather that I am willing to take a chance with a company & team which is willing to go the extra mile to make their customers and employees happy. I also mentioned that my preferred technology stack at the moment is not PHP & WordPress, but rather full-stack JavaScript, and HTML5 hybrid mobile apps.

I met with a local recruiter, who pretty quickly came to the conclusion that I am probably often misunderstood by people, and offered to me some advice around maneurisms. Simple things like even maintaining eye contact. I asked him a bit about transitioning to a different technology stack, like .NET, and he said that it can be done, but there would initially probably be a salary penalty. I’ll keep it in mind for now.

I went to the orientation for the self-employment program offered by the YMCA-YWCA, where I got the application for joining the program. I think that program looks amazing, and I’ve already filled out the application, just didn’t get a chance to bring it in today, since I didn’t know whether the right person will be in the office, and they didn’t return my voice mail.

I also attended an orientation session at Opportunities for Employment. This is also pretty cool, and I even got a free suit there! Check me out:

dan-suit

Then there was the Ramp up Year Ender last night. Always a great and friendly group of people. I made sure to tell everyone I spoke with that I was unemployed and to keep me in mind for any opportunities they hear about. One person asked me to send them my resume, one asked to set up an appointment to explore what work we can do together, and another to email them my contact info so they can introduce me to people who might be interested in speaking with me. And all around good wishes and kind friends, and that means a lot.

Today I put up a WordPress plugin up on GitHub, and actually got contacted by someone looking for a developer! ( message me if you also wanna be considered for this job, and I will share the ad for the opportunity with you ). The CEO of the company who contacted me seems very cool, based on a video interview I found on-line.

Thanks for reading. Have a good one.

Today’s Job Search Efforts

I still plan to try to set up my computer further for work on WordPress websites, an initiative I’m hoping will provide lucrative self-employment opportunities, and perhaps even a product with passive income opportunities.