Skip to content

Instantly share code, notes, and snippets.

View kevgathuku's full-sized avatar

Kevin Gathuku kevgathuku

View GitHub Profile

Instead of using a custom implementation to get the state of a process:

defmodule MyModule do
 use GenServer

  def report(server) do
    GenServer.call(server, :report)
  end
@kevgathuku
kevgathuku / multiple_rails_versions.md
Created May 3, 2026 20:20
Managing Multiple Rails Versions in Development

You can have multiple Rails versions installed at the same time.

To install the rails version you need:

gem install rails --version=5.2.8

How to specify the rails version to use

@kevgathuku
kevgathuku / PythonVersionDirenv.md
Created July 1, 2025 09:14
Create python venv with specific python version

To specify the specific python version to use, you can specify it as follows in the .envrc file

layout python /usr/bin/python3.11

I also needed to install the python-venv package for python 3.11


❯ sudo apt install python3.11-venv
let () = print_endline "THIS" in
let () = print_endline "IS" in
print_endline "3110";;
(* Can also be written as *)
print_endline "THIS";
print_endline "IS";
print_endline "3110"
(* Source: https://courses.cs.cornell.edu/cs3110/2021sp/textbook/basics/printing.html *)

Using direnv + opam via the following .envrc

export OPAMSWITCH="$HOME/path/to/opam/switch"
eval $(opam env)

Source

 FAIL  _build/default/test/test/test/Leap_test.js
Leap
✕ year not divisible by 4 in common year (30ms)
✕ year divisible by 4, not divisible by 100 in leap year (28ms)
 ● Leap › year not divisible by 4 in common year
expect(received).toBe(expected) // Object.is equality
Expected: false
@kevgathuku
kevgathuku / linux-setup.sh
Created May 18, 2024 16:57 — forked from dhh/linux-setup.sh
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl btop \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev mupdf mupdf-tools \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils
@kevgathuku
kevgathuku / dummy_controller.rb
Created August 9, 2022 06:51 — forked from psobocinski/dummy_controller.rb
Asserting on a JSON response in a Rails controller test with MiniTest
class DummyController < ApplicationController
def do
render json: { balance: 50 }
end
end
@kevgathuku
kevgathuku / how-to-add-image-to-gist.md
Last active June 21, 2022 08:17 — forked from mroderick/how-to-add-image-to-gist.md
How to add an image to a gist

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh
@kevgathuku
kevgathuku / yarn.config
Created May 14, 2021 12:16 — forked from sealocal/yarn.config
Install Yarn and NodeJS on AWS Elastic Beanstalk EC2 Instance with Amazon Linux Ruby Platform, prior to precompiling assets for a Rails app
files:
# If this file is edited, it must be removed from EC2 instance prior to deploy.
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_yarn_install.sh" :
mode: "000775"
owner: root
group: users
content: |
#!/usr/bin/env bash
set -xe