Skip to content

Instantly share code, notes, and snippets.

@anoopprasad
anoopprasad / colima-docker-apple-silicon.md
Created February 7, 2025 06:44 — forked from mbiemann/colima-docker-apple-silicon.md
Using colima and Docker Engine on Apple Silicon (M1 Chip)

Using colima and Docker Engine on Apple Silicon (M1 Chip)

This tutorial uses Homebrew to install colima and Docker.

It was tested on Apple MacBook Pro (13-inch, M1, 2020) 8G and macOS Monterey version 12.1 (21C52).

Uninstall any Docker version

Make sure you have fully uninstall any versions of Docker. You can check using:

@anoopprasad
anoopprasad / database.yml
Created July 26, 2024 07:15 — forked from arthurchui/database.yml
Custom mysql2 adapter for connecting Rails via ProxySQL
database: &default
host: 127.0.0.1
adapter: proxy_mysql2
...
@anoopprasad
anoopprasad / 0_Gemfile
Created June 21, 2024 06:41 — forked from rokumatsumoto/0_Gemfile
Stubbing the AWS SDK S3 (bucket.object, bucket.object.exists? methods and bucket.object.exists? responses)
# Gemfile
gem 'aws-sdk-s3'
# Check server process is using jemalloc
# ref. [Japanese] https://tech.studyplus.co.jp/entry/2019/09/09/094140
class AppController < ActionController::Base
def show
r = `strings /proc/#{Process.pid}/maps | grep jemalloc`
render plain: "<h1>#{ENV['LD_PRELOAD'].presence || 'empty'}</h1><pre>#{r}</pre>"
end
end
@anoopprasad
anoopprasad / 1. ELK.install
Created August 20, 2023 18:28 — forked from PavloBezpalov/1. ELK.install
ELK Stack with Rails (Elasticsearch, Logstash, Kibana) on Ubuntu VPS
INSTALL JAVA
$ sudo apt-get update && sudo apt-get install default-jre
INSTALL ELASTIC SEARCH https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html
$ wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
$ echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
$ sudo apt-get update && sudo apt-get install elasticsearch
$ sudo update-rc.d elasticsearch defaults 95 10
$ sudo service elasticsearch restart
$ sudo service elasticsearch status
class Tree
attr_reader :raw_data, :nodes, :tree
def initialize(string)
@raw_data = string
@tree = {}
end
def format_data
@nodes = raw_data.split("\n").map{ |d| n= d.split(','); { name: n[0], id: n[1], parent_id: n[2] } }
@anoopprasad
anoopprasad / README.md
Created April 4, 2022 06:13 — 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:

@anoopprasad
anoopprasad / nginx.conf
Created December 7, 2021 05:39 — forked from sansmischevia/nginx.conf
nginx http proxy to s3 static websites
##
## This nginx.conf servers as the main config file for webflow reverse proxy
##
## RCS:
## https://gist.github.com/sansmischevia/5617402
##
## Hardening tips:
## http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html
##
@anoopprasad
anoopprasad / README.md
Created February 24, 2021 12:11 — forked from DocX/README.md
Connect to bash inside running ECS container by cluster and service name
@anoopprasad
anoopprasad / find_zero_dates.rb
Created January 28, 2021 21:15 — forked from jdvkivu/find_zero_dates.rb
Ruby on Rails script to check mysql zero dates
#
# Check for every table with temporal columns if there are records that have dates set to '0000-00-00'
conn = ActiveRecord::Base.connection
# get a list of tables and columns with a date type excluding merge tables
query = "select concat(`table_schema`,'.',`table_name`) as table_name,`COLUMN_NAME` from information_schema.`columns` where data_type like '%date%' AND concat(`table_schema`,'.',`table_name`) not in (select concat(`table_schema`,'.',`table_name`) from information_schema.tables where engine='mrg_myisam');"
list = conn.select_all( query )
# transform the list a bit for later querying