Skip to content

Instantly share code, notes, and snippets.

View kieetnvt's full-sized avatar
👋

Kiet Nguyen kieetnvt

👋
  • Ho Chi Minh City
View GitHub Profile
@kieetnvt
kieetnvt / docker-pry-rails.md
Created October 5, 2023 11:42 — forked from briankung/docker-pry-rails.md
Using pry-rails with Docker

First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails

gem 'pry-rails', group: :development

Then you'll want to rebuild your Docker container to install the gems

@kieetnvt
kieetnvt / ec2-ftp-tutorial.md
Created April 3, 2021 02:48 — forked from tylermakin/ec2-ftp-tutorial.md
Tutorial for configuring FTP access to an EC2 server
@kieetnvt
kieetnvt / nginx-passenger-ssl.conf
Created March 25, 2021 15:47 — forked from rkjha/nginx-passenger-ssl.conf
Nginx/Passenger config when using SSL with a Ruby/Rails Application.
# for redirecting hhtp traffic to https version of the site
server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
# for redirecting to non-www version of the site
server {
listen 80;
@kieetnvt
kieetnvt / README.md
Created December 25, 2020 09:15 — forked from bazzel/README.md
Webpacker and I18n
$ rails new my-i8n --webpack

Gemfile

gem 'i18n-js'
@kieetnvt
kieetnvt / ArrayObjectDemo.coffee
Created June 12, 2020 04:28 — forked from frane/ArrayObjectDemo.coffee
Traversing arrays and objects in CoffeeScript
# Traversing arrays and objects in CoffeeScript
# The array and object we use for testing
arr = [1, 2, 3, 4, 5]
obj = {a: 1, b: 2, c: 3, d: 4, e: 5}
# 'in' has a different meaning in CoffeeScript than in JavaScript
# CS: element in array -> JS: array.indexOf(element) >= 0
console.log '5 in arr: ' + (5 in arr)
@kieetnvt
kieetnvt / Get Unused Routes of Large Rails App
Created November 8, 2019 09:41
Get Unused Routes of Large Rails App
Rails.application.eager_load!
unused_routes = {}
# Iterating over all non-empty routes from RouteSet
Rails.application.routes.routes.map(&:requirements).reject(&:empty?).each do |route|
name = route[:controller].camelcase
next if name.start_with?("Rails")
controller = "#{name}Controller"
@kieetnvt
kieetnvt / mac-build-pgmodeler.md
Created October 25, 2019 16:52 — forked from jdforsythe/mac-build-pgmodeler.md
Build pgmodeler on Mac with Homebrew-installed pg and openssl

Building pgmodeler for Mac

Check requirements at https://pgmodeler.io/installation.

You will need Qt 5.9.x installed, full XCode installed, and homebrew installation of postgres and openssl.

The example below is v10.5 of PG and v5.9.6 of Qt, modify accordingly. Also, replace {{USERNAME}} with you Mac username.

The installation is the same as the instructions at the link above. There are a few path differences due to homebrew installation locations.

@kieetnvt
kieetnvt / webp.markdown
Created June 6, 2019 09:16
Configure WebP NGINX with Fallback to native images

Configure WebP

Make sure the mime.types has type webp

/etc/nginx/mime.types

include

image/webp webp;

@kieetnvt
kieetnvt / rails_5_ar_dirty_sp.md
Created May 20, 2019 17:58
Rails > 5 AR Dirty

Rails 5.0 Rails 5.1+ changed? → saved_change_to? _was → _before_last_save changed? → saved_changes? changed_attributes → saved_changes.transform_values(&:first)

Model callbacks behavior After Rails 4.x release, some changes were made on callbacks to split update on the model before and after writing data to the database. We had to be careful to use the correct helpers: _changed? for after_save callbacks, and previous_changes[:] for after_commit callbacks:

@kieetnvt
kieetnvt / expanding_volume_ec2.md
Created May 20, 2019 17:13
Expanding volume size of EC2 AWS Instance

Steps

--- AWS Dashboard EBS Step ---

  1. Log into your AWS account and navigate to EC2

  2. View Instance Details looking for the Root Device and Block Devices to identify the volume you want to resize

  3. Click the storage Device and select the EBS ID