Devisms #5

Ruby on Rails

People & Practices

Front-end

  • FullCalendar - A JavaScript powered calendar with different views, theming, locales and time zones.
  • Awesome StimulusJS - I have to admit, Stimulus JS has been one of the more suprising additions to Rails. I never gave it a second look until a few months ago.

Tools

  • Cozette - A programming font designed for coziness.

Devisms #4

Ruby on Rails

People & Practices

Tools

Devisms #3

Ruby on Rails

People & Practices

Front-end

Snippets

  • Vanilla web projects - A collection of web applications built entirely with HTML, CSS and JavaScript. No frameworks or libraries.
  • Splitting a commit - 99% of the time, I’m merging commits together, but there are times when you might want to split a commit.

Tools

  • Geometry ZSH - A customisable ZSH prompt theme. Bit too minimal for my liking, but, each to their own.
  • Powerlevel10k - Another theme for ZSH. This is more my kind of thing. I like have the extra info in my ZSH prompt.

Devisms #2

Ruby on Rails

People & Practices

  • Software is about people, not code - A reminder of what’s important when it comes to software. Hint, it’s not the software itself.

    Most people don’t know or care about the code. (If they did, they’d likely be a developer.) They’re just trying to get something done. The most beautiful, well tested, flexible, configurable, documented, future proofed codebase that does the wrong thing is useless.

  • Monoliths are the future - I have to admit, I’m a huge fan of monolith code bases, but there are times when a microservice makes sense. It’s not as often as people think though.

    So a lot of people get addicted to all the flourishment of money, and marketing, and it’s just a lot of buzz that people are attaching their assignment to, when honestly it’s not gonna necessarily solve their problem.

Front-end

  • Simple Image Placeholders with SVG - A Javascript library for generating image placeholders. I find this a much better replacement for the multiple placeholder services that you have to call on a URL.

Mobile

  • React Native is the Future of Mobile at Shopify - I have taken an interest in mobile app development and have been looking into React Native as well. I’d like to build an app for different platforms, but re-use the source code for each platform. Shopify’s deep dive into their decision to use React Native is well worth a read if you’re new to mobile development.

Snippets

Devisms #1

Devisms is going to be my weekly drop of links that I’ve found interesting over the last week. I’ll aim to drop this every Friday morning. Most of the links will be aimed at Ruby on Rails, but expect it to include other topics as well relating to web development.

Ruby on Rails

People

  • When Management Clicks - Adam Keys has what you want to hear as a manager of teams:

    Stacking repeated positive outcomes yields trust in people and teams. That yields agency to tackle future projects in creative, potentially better ways. That usually leads to even more positive outcomes. Even more importantly, it makes for teammates who are excited and satisfied by their work.

Front-end

  • React Nice Dates - I’m fairly late to the front-end framework hype, but it’s only now that I’m starting to see the benefits. This datepicker for React is definitely something that I could see me using.
  • How To Pass Data Between Components In Vue.js - I must admit, I did like my brief time using VueJS. Passing data between components is something that you will eventually need to do, so it’s good to know how.
  • StimulusReflex - If you’re quite happy with Rails, Turbolinks and Stimulus, this would be a good natural step before considering something like React or VueJS.
  • Design tips for developers - You can put me firmly in the category of not having good design skills. Which is why I am thankful for posts like this.

Snippets

  • Minimum viable favicon code - How to get favicons working across multiple devices and browsers with just a few lines of HTML and a few files.

Tools

  • JetBrains Mono - A new free typeface for developers. I tried it, but you’ll probably have to wrestle Iosevka out of my cold dead text editor preferences.
  • BitBar - Put anything in your macOS menu bar including server statuses and snippets.

API authentication with a token in Rails

There are times when you’re building web applications and just the basics is enough for your initial needs. Take tonight when I needed a single API end point that was protected by a token.

Rather than go down the road of utilizing web tokens or another authentication method, I decided to use the authenticate_or_request_with_token method that rails provides.

What it does is it takes the token from the request and we can then use it to match against an existing record or environment variable in our application. For this scenario, I need just to do a check on an environment variable.

module Api
  class EventsController < ApplicationController
    before_action :authenticate

    def index
      # Do some action here
    end

    private

    def authenticate
      authenticate_or_request_with_http_token do |token, _options|
        token == ENV['API_TOKEN']
      end
    end
  end
end