Skip to content

Instantly share code, notes, and snippets.

View alexandrule's full-sized avatar

Alex Leasenco alexandrule

View GitHub Profile
@alexandrule
alexandrule / README.md
Created February 14, 2024 12:36 — forked from jesster2k10/README.md
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

@alexandrule
alexandrule / postgres.md
Created November 3, 2023 11:07 — forked from phortuin/postgres.md
Set up postgres + database on MacOS (M1)

Based on this blogpost.

Install with Homebrew:

$ brew install postgresql@14

(The version number 14 needs to be explicitly stated. The @ mark designates a version number is specified. If you need an older version of postgres, use postgresql@13, for example.)

@alexandrule
alexandrule / install_pg_gem.md
Created October 17, 2023 09:33 — forked from tomholford/install_pg_gem.md
Install postgresql gem `pg` on macOS

Installing pg gem on macOS

If you're trying to install the postgresql gem pg and it is failing with the following error message:

Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: ~/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/pg-1.2.3/ext
~/.rbenv/versions/3.0.0/bin/ruby -I ~/.rbenv/versions/3.0.0/lib/ruby/3.0.0 -r ./siteconf20210125-97201-pycpo.rb extconf.rb
@alexandrule
alexandrule / foo.service
Created July 18, 2023 11:34 — forked from rennex/foo.service
Example of a systemd service file to start a Sinatra app.
# /etc/systemd/system/foo.service
[Unit]
Description=Foo service
Wants=nginx.service
Requires=postgresql.service
After=postgresql.service
[Service]
Type=simple
User=foo
@alexandrule
alexandrule / app.DockerFile
Created July 4, 2023 15:02 — forked from satendra02/app.DockerFile
docker+rails+puma+nginx+postgres (Production ready)
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran:
@alexandrule
alexandrule / how-to-tmux-background-process.md
Created December 15, 2022 09:30 — forked from davydany/how-to-tmux-background-process.md
Using TMUX for running processes after you log off

How to Run a Process in the Background with TMUX

There are times when you need to log off your Linux Desktop, and you want a process to run in the background. TMUX manages this very well.

For this example, let's suppose you're running a long running task like running rspecs on your project and it is 5pm, and you need to go home.

Run Your Process

@alexandrule
alexandrule / configure-ec2-instance.md
Created December 13, 2022 14:56 — forked from linuxdevops-34/configure-ec2-instance.md
Complete guide for deploying rails application to aws ec2 instance, using capistrano as deploying tool with nginx & puma server

Deploy Rails Application to AWS EC2

Creating AWS EC2 Instance

- login to 'AWS Management Console' (https://aws.amazon.com/console/)
- from 'Services'(in navbar) choose 'EC2'
- from 'Create Instance' section, click on 'Launch Instance'
- then select 'AMI' (Amazon Machine Image), we will be using 'Ubuntu Server 16.04 LTS (HVM)' as example
- select 'Instance Type' as per your requirement
- then click 'Next:Configure Instance Details' to continue
  change 'Configure Instance Details' or used as default settings
@alexandrule
alexandrule / moment-js-timezones.txt
Created October 11, 2022 09:11 — forked from diogocapela/moment-js-timezones.txt
List of All Moment.js Timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
@alexandrule
alexandrule / Dockerfile
Created September 16, 2022 06:37 — forked from erdostom/Dockerfile
Good starter Dockerfile + docker-compose.yml for Rails 6.
FROM ruby:2.6.5-alpine
RUN apk add --update --no-cache bash build-base nodejs sqlite-dev tzdata postgresql-dev yarn
RUN gem install bundler:2.1.4
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn install --check-files
@alexandrule
alexandrule / .dockerignore
Created September 15, 2022 11:35 — forked from yizeng/.dockerignore
An example .dockerignore file for Rails
.git
.gitignore
# Created by https://www.gitignore.io/api/git,ruby,rails,jetbrains+all
# Edit at https://www.gitignore.io/?templates=git,ruby,rails,jetbrains+all
### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig