-
Dragon Astronauts Store Launch! đđ
We’re thrilled to announce that Dragon Astronauts is taking one small step for dragons, one giant leap for dragon-kind: We’re launching our very first merchandise store! For those of you who’ve been asking for ways to show your Dragon Astronauts pride, your wishes have been granted. Our new store features carefully selected items that let…
-
Why you should use Docker in development.
What is the point of containerizing something like a Rails app in a development environment? What do we get in return for learning Docker and how it works there? It used to be that if I started programming a new app in say, Ruby on Rails, the way I would setup my development environment (on…
-
Why we unit test.
Programmers write bugs (you didn’t think bugs wrote themselves right?). To deal with these logic regressions we write tests to keep ourselves honest. Test are both a way to ensure that the program really does what intended, and to communicate the programmers intent to the next person who looks at the code. But some of…
-
What is a Ruby block?
Ruby blocks are fairly easy to pickup, use, and make work if you just follow the common examples. But at some point you might realize that you don’t really understand what is going on in the same way as you might with variable assignment or a method call. Let’s start with a basic definition of…
-
Notes on the Rails 8 Keynote: “It’s More Fun to Be Competent”
David Heinemeier Hansson is back with the the Rails World keynote talking about the trends he is seeing in the industry and where he wants to take Rails 8. As usual, the keynote has lots of interesting ideas and the next version of Rails is giving us developers lots of new tools. I want to…
-
The differences between Ruby blocks, procs, lambdas and closures.
Grappling with the differences between Ruby blocks, procs, lambdas, and closures is confusing at first. To fresh eyes they looks kinda weird and complicated compared to other parts of Ruby which are more familiar. But once you get them down you realize how cool and useful they really are. We are here to walk you…
-
Better, faster code with test driven development.
People have pretty strong opinions on TDD (Test Driven Development). Some think that it is a pretty big waste of time while others think it is the only way to go. Off the bat, I will state that I lean more towards the latter camp, that TDD is a great tool for both writing code…
-
ChatGPT is still making lots of mistakes.
How reliable is it? Far from ChatGPT taking all the jobs of writers, programmers, spreadsheet wizards (and more) I have mostly seen it used so far as a research assistant. A programmer will ask it some question and then use that to help compose a larger program. This kinda works in programming if you ask…
-
The Safety Margin in Software Development Estimates
Accurately estimating the time required to complete tasks or “tickets” is a complex endeavor. Every time you break down and plot out how you are going to add a new feature to existing software what you are really doing isâŚ. making a wild-ass guess! Yes, I could say that adding a new rails controller is…
-
The Power of Play for better Team Meetings
Sometimes stand ups are soooo boring. The stand up. That once a day meeting where you: say what you did yesterday, say what you are doing today, say what is blocking you, and then tune out. It makes sense, we operate in a a world filled with deadlines, deliverables, data and procedures to make things…
-
What to Do When Youâre Laid Off
A guide for software engineers. Alright, youâve been laid off. Shit happens! But guess what? Itâs not the end. Everybody gets randomly punched in the face sometimes. This is just another challenge to overcome on the way to the next amazing job. 1. Feel All the Feels, Then Move On Mad? Sad? Feeling like crap?…
-
Should I fix the terrible app I inherited? Or totally rewrite it?
Assuming this app is larger than a one day to one week rewrite (for yourself or your team) then the question has to be asked: Do we completely rewrite this app as a new v2 or do we refactor the existing code base? Size and scope The biggest problem of an inherited app is that…
-
Should I use a Struct or an OpenStruct (Ruby)?
At first glace the choice between using a `Struct` or an `OpenStruct` is just preference. They are very similar and (mostly) behave the same way. Pretty similar, right? Actually there are some differences and these should inform your choice. The choice revolves around the specific characteristics of your data structure so lets look at those.…
-
Why do we Bundle exec (re-examined)
Why do we prepend so many commands with `bundle exec`? For example: Prerequisite knowledge What is Bundler Bundler is a dependency manager tailored for Ruby projects. Its primary role is to ensure the accuracy of gem versions within a given project. Bundler does this by creating a separate environment for each Ruby project on your…
-
JavaScript Hoisting intro
Hoisting is where a variable and function declaration is moved to the top of its scope during compilation. This means that variables and functions can be used before they are declared in the code. You should know that since the declaration is hoisted but not the initialization of the variable the variable will be undefined.…
-
How to get the min and max from an Array (Ruby)
Arrays have a couple methods to get the minimum and maximum. Three common ones are .min, .max, .minmax. .max will get you the maximum value. .min will get the minimum value. If you need both the minimum and the maximum from an array then the best solution is using the ruby method minmax. It will…
-
JSON Web Token basics
A JSON Web Token (JWT) is an internet standard for representing claims securely between two parties. JWTs contain three parts: the *header*, the *payload*, and the *signature*. They are joined together by `.` to create a JWT like: `aaaaaa.bbbbb.ccccc`. Example JWT Decoded Header Payload Signature Encoded When to use a JWT? – Authorization – After…
-
React Component Intro
React, a popular JavaScript library for building user interfaces, is known for its component-based architecture. A React component is essentially an independent, reusable piece of code that returns HTML to be rendered on the page. These components are the building blocks of React applications, enabling developers to create complex UIs from small, isolated pieces of…
-
Stimulus Intro
Stimulus is the Rails team JavaScript framework which intends to provide an elegant and simple solution to enhancing HTML interactivity without reaching for the complexity of a full Single Page Application (SPA). Itâs meant for developers looking to augment their normal Rails, server-rendered pages with just a bit of client-side JavaScript. Stimulus is used to…
-
Binstubs
Binstubs, short for “binary stubs,” are small executable scripts that act as wrappers around Ruby executables or scripts. They are commonly used in Ruby projects managed with Bundler to provide a convenient way to execute commands without needing to prepend them with bundle exec. When you run `bundle install –binstubs` Bundler will create a bin…
-
Ruby Benchmark
If you just want to see how fast a bit of code is you can use the Benchmark module which is part of the Ruby Standard Library. If you want to compare two or more bits of Ruby code that do the same thing and see how fast they are against each other then you…
-
Link_to and Link_to_unless
Building a navigation bar in Rails is pretty easy. You simply write up something like: And you get a set of urls for your link that look like this: However if you are on the “Docs” page already then you dont’t really need the “Docs” link to be a link. It could just be text.…
-
Using Service Objects to extract business logic.
The Rails defaults work really well. You start with really nice, clean models and controllers. You can view them all as one page of code and hold an idea of what they do in your head. Problem is that they keep getting bigger as you add features and eventually they balloon out of control. Giant…
-
Why do we bundle exec?
A common question I get is why do we need to prepend a command with bundle exec? Running the command by itself seems to work most of the time so what is difference? We know that rake db:migrate (for example) is the command we want to run. We know that bundle install is how you…
-
Ruby Case statements from if/else
Reading nested if statements making you sad? Case statements can be the answer. Refactoring your if statements can clear up complicated code and make spotting bugs much easier. Nested if statements often lead to complex and hard-to-read code. They can grow over time as new conditions are added, making it difficult to maintain and debug.…
-
Classes, Hashes, Structs and OpenStructs in Ruby
Intro If I am looking to maximize the performance of a Ruby app what should I be using? Hashes, Structs, OpenStruct, or Classes? New Ruby programmers love hashes. I love hashes. They are very flexible and tempting to add in everywhere. Even when refactoring a slow part of the system in Kafka microservices so that…
-
Pushing Rails validations down to the database?
Ever open up a Rails console to debug a problem and come away wondering how the data got so funky? Despite our best efforts, the database will accept plenty of garbage data if you let it. There are tons of methods to bypass the Rails callbacks and validations while still updating your database. If you…
-
Ruby Native Extensions
In Ruby, native extensions (also known as C extensions or native gems) allow you to write parts of your code in the C programming language, which can be linked and executed as part of a Ruby program. Native extensions are typically used for performance-critical tasks, interacting with low-level system libraries, or providing access to functionality…
-
Using Spaced Repetition to Learn Programming
Do you ever wish that you could memorize an entire programming language and all of the libraries and APIs that you use constantly? Want to become as fluent in the technical concepts and jargon as you are in your native language? Well, that is what spaced repetition is for. Spaced repetition will help you efficiently…
-
Organizing large Rails projects
Do you have a Rails app that has gotten so big it is getting hard to know what is going on? When you have a new Rails app it is easy to tell what the app does by looking at the files in the modelsâ folder, but as the app gets bigger you often lose…
-
Using Rails form objects
Update: User MelissaLiberty from Reddit pointed out how they would improve the form object and some of it faults. This post has been updated to reflect their excellent points. Often, when we start a new Rails app we start with simple controllers, and we start by generating everything with scaffolding. There is nothing wrong with…
-
Killing dead Rails controllers
So you’ve inherited an app. It is pretty well tested and doesn’t throw too many errors but the app is big enough that it is hard to tell what is going on most of the time. The original developers are long gone and you need to build new, mission-critical features into the app but writing…
-
What is a good first programming language?
There are loads of ways to get into programming and I think I have tried all of them. The first language I tried was Visual Basic because my father had an instructional book laying around and I was bored. Later I taught myself HTML and then JavaScript because I wanted to make websites on Geocities.…
-
Should you add Gemfile.lock to Git?
TLDR: Yes for apps. Yes for Gems. Do you use version control to keep track of changes to your codebase? Or do you think version control is for the cowardly and just change files in a shared team folder and hope no one else is changing it at the same time? Of course not. You…
-
Rails Benchmarking
So, you want to know fast your Rails app is going? If you just want to see how fast a bit of code is you can use the Benchmark module which is part of the Ruby Standard Library. If you want to compare two or more bits of Ruby code that do the same thing…
-
Cleaning up a messy Gemfile
Maintaining a clean and organized Gemfile is crucial for the long-term health and readability of your Rails application. As applications age, their Gemfiles can accumulate complexities and messiness. In this guide, we’ll explore some rules and best practices for crafting a clean, readable Gemfile that fosters maintainability. 1. Group Gems Effectively Divide your gems into…
-
Keyword (Named) Parameters
Introduced in Ruby 2.0, keyword parameters provide a way to pass arguments to a method by explicitly specifying parameter names and their corresponding values. This feature proves valuable, especially in scenarios involving methods with numerous parameters, as it significantly enhances code readability and clarity. Example Usage: Definition: When defining a method, keyword parameters can be…
-
Arrays in Ruby
Arrays are ordered collections of objects. They can hold any type of Ruby object: numbers, strings, other arrays, hashes, classes and methods. Here is what a basic array looks like and is used for: Arrays are created by placing a list of objects between square brackets. Accessing arrays The data in these arrays can be…
-
Looping in Ruby
Looping is one of the basic programming concepts that you will find in Ruby. It lets you to execute a block of code repeatedly. Ruby has a few ways to implement loops. First up: `.while`. The `.while` loop repeats a block of code over and over while the given condition remains true. When the condition…
-
Service Object (Ruby on Rails)
Service objects are Plain Old Ruby Objects used to extract code from a part of the application where it doesn’t really belong and isolate it in its own, testable file. They often look like: They can then be called like this: This simplifies your controller and makes it much more understandable. It also separates the…
-
Ranges with 2 or 3 dots
Ruby ranges with either two or three periods are valid ranges. However, the 2 dot and 3 dot formats produce different ranges. The 3 dot ranges exclude the end value (eg. they are not inclusive). While the 2 dot ranges are inclusive (they include the highest number). Here is a simple example:
-
Ruby Constants
Constants store values that cannot be changed during execution. For example: In this example, `PI` is a constant representing the value of Pi. Once assigned, the value of `PI` remains the same throughout the execution of the program. This leads to code clarity and prevents an inadvertent alteration of the value of PI in another…
-
Ruby String Basics
Strings are a core part of the Ruby language and are constantly used when programming in Ruby. They can be either single or double quoted: You can print out strings: Strings are commonly stored in a variable: Strings are concatenated like this: Ruby strings are commonly concatenated using the `+` operator. Ruby can also concatenate…
-
Ruby off Rails
So, Ruby is well known for its hugely popular gem Rails which greatly simplifies building websites. But what are some other programs built-in Ruby? Here are a few very popular examples. RubyMotion – Develop native apps for iOS (both iPhone and iPad) and OS X in Ruby. It is based on MacRuby which was developed…
-
Naming Ruby Gems
When it comes to naming a Ruby gem, the process involves a thoughtful consideration of community conventions, creativity, and uniqueness. In this context, let’s delve into the rationale behind naming my gem “tiedye.” Community Conventions Adhering to community conventions is a crucial first step in gem naming. The convention I followed involves using underscores in…
-
Tips to be a productive developer.
1. Eat your frogs. âEat a live frog every morning, and nothing worse will happen to you the rest of the day.â -Mark Twain Seriously. The first step is that you already know what you have to do. Just do the thing you are dreading. Defeat Bowser and then go back and smash those Koopa…