Sign in

Full Stack Dev. Data Scientist. Ruby, Python, React, AWS. Toronto. “at”

Updated thoughts on why you should use factories instead of classes in JavaScript

Photo by Pixabay from Pexels

Public properties on class instances present a security concern (and how to avoid it)

class Car { constructor(maxSpeed){ this.maxSpeed = maxSpeed; } drive(){…

The best way to create a type attribute on your ruby on rails models

Photo by Karolina Grabowska from Pexels

Enums are constant mappings of values to integers

An enum example, as defined in a model

enum item_type: {
fruit: 0,
vegetable: 10,
meat: 20,
bread: 30

An alternative: constant hashes

Skip the library and roll your own hot keys

Photo by Pixabay from Pexels

Add an event listener


Write a function to be called by the listener

From infinite scrolling to manipulating the DOM to printing variables

Photo by fauxels from Pexels
  • Represents the current tab of a browser.
  • Includes the document and screen objects, which represent a site’s content and the shape of a device’s screen.
  • Contains global variables and functions.

Learn why you should use JavaScript factories over classes with an example

Photo by Pixabay from Pexels

Build a Class-Based Rocket Ship

Do you know when to use Ruby’s each, select, map and collect methods?

Photo by Edmond Dantès from Pexels


[1,2,3].each {|x| puts x + 1 }
=> 2
=> 3
=> 4
a = [1,2,3].each {|x| x + 1}
puts a.inspect

What you need to know and what you can do with “..” and “…”

Photo by Archie Binamira from Pexels

We’ll cover:

  1. What you need to know about ranges
  2. The most common ways to use ranges

What you need to know about ranges

Inclusive vs exclusive ranges

puts (1..5).to_a.inspect
=> [1, 2, 3, 4, 5]
puts (1...5).to_a.inspect
=> [1, 2, 3, 4]

A range is not an array

puts (1..5)
=> 1..5
puts (1..5).class
=> Range

Know when to use each, depending on the situation

Photo by Negative Space from Pexels

Case 1: On arrays in memory

arr = ['a','b','c','c']
puts arr.length #=> 4
puts arr.count #=> 4
puts arr.size #=> 4
$ arr.count('c') #=> 2
$ arr2 = [1,2,3,4,5,6,7]
$ arr2.count …

3 algorithm questions you may be asked in Ruby interviews

Photo by Christina Morillo from Pexels

Question 1: FizzBuzz


  1. Given n, return a list of all integers from 1 through n.
  2. If an integer is divisible by…

A tutorial on deploying a ReactJS frontend and Rails API backend on the same dyno

Create and setup the app

$ rails new fe-be-app --api --database=postgresql -T $ cd fe-be-app $ bundle install $ rake db:create $ rails s…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store