Skip to content

Instantly share code, notes, and snippets.

@hungle00
hungle00 / exit_the_cloud.md
Created February 19, 2025 07:58 — forked from rameerez/exit_the_cloud.md
☁️ How I got off the cloud and migrated everything from AWS to a VPS in Hetzner

☁️ How I got off the cloud and migrated everything from AWS to a VPS in Hetzner

This is an opinionated handbook on how I migrated all my Rails apps off the cloud and into VPS.

This is how I manage real production loads for my Rails apps. It assumes:

  • Rails 7+
  • Ruby 3+
  • PostgreSQL
  • Ubuntu Server 24.04
  • Capistrano, Puma, Nginx
@hungle00
hungle00 / concurrency-ruby.md
Last active July 7, 2025 16:17
Ruby concurrency
@hungle00
hungle00 / Gemfile
Created October 26, 2024 04:10 — forked from ctalkington/Gemfile
Nginx, Sinatra, and Puma.
source :rubygems
gem "puma"
gem "sinatra"
@hungle00
hungle00 / index.js
Last active July 27, 2024 02:50
Vanilla JavaScript version of some JQuery effects.
HTMLElement.prototype.slideToggle = function(duration) {
if (window.getComputedStyle(this).display === 'none') {
_slideDown(this);
} else {
_slideUp(this);
}
};
HTMLElement.prototype.slideUp = function(duration) {
_slideUp(this)
@hungle00
hungle00 / block.md
Created June 8, 2023 03:00
Note about block, proc in Ruby

What a block is?

A block is a way of passing behavior rather than data to a method

Loosely speaking, every block in Ruby is a Proc object:

def my_method(&block)
  puts block.class
end
@hungle00
hungle00 / b-tree.go
Last active March 27, 2023 07:03
Some go snippets
package main
import (
"golang.org/x/tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@hungle00
hungle00 / Dockerfile
Last active April 14, 2023 08:38
Use docker-compose to dockerize rails app
FROM ruby:2.6.6-alpine3.12
LABEL maintainer="hungle"
# Minimal requirements to run a Rails app
RUN apk add --no-cache --update build-base \
linux-headers \
git \
postgresql-dev \
nodejs \
yarn \
# https://hakibenita.com/fast-load-data-python-postgresql
from typing import Iterator, Dict, Any, Optional
from urllib.parse import urlencode
import datetime
#------------------------ Profile
import time
@hungle00
hungle00 / postgres-cheatsheet.md
Last active April 2, 2020 03:57 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)