Skip to content

Instantly share code, notes, and snippets.

View omkz's full-sized avatar
🏠
Working from home

Kurnia Muhamad omkz

🏠
Working from home
View GitHub Profile
@omkz
omkz / Gemfile
Created June 25, 2020 14:20 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@omkz
omkz / backup.md
Last active June 25, 2020 02:27
Heroku postgres backup

Creating a backup

Use pg:backups:capture to create a backup.

➜  heroku pg:backups:capture --app staging-gtds
Starting backup of postgresql-spherical-26253... done

Use Ctrl-C at any time to stop monitoring progress; the backup will continue running.
Use heroku pg:backups:info to check progress.
Stop a running backup with heroku pg:backups:cancel.
@omkz
omkz / chmod.md
Last active June 19, 2020 01:10
Linux chmod command

chmod digunakan untuk mengganti permission dari sebuah file atau folder. setiap file dapat diakses 3 pengguna, yaitu user (u), group (g) and others (o).

contoh:

➜  test ls -l
total 0
-rw-rw-r-- 1 omz omz 0 Jun 19 08:04 test1
-rw-rw-r-- 1 omz omz 0 Jun 19 08:04 test2
-rw-rw-r-- 1 omz omz 0 Jun 19 08:04 test3
@omkz
omkz / deploy.md
Last active January 17, 2021 03:21
Deploy a Rails App to an EC2 Instance

Creating a Deploy user

Create a new user named deploy with a home directory of /opt/deploy:

sudo adduser deploy --home /opt/deploy

add user deploy to the sudo group.

adduser deploy sudo
@omkz
omkz / deployment.md
Last active June 18, 2020 05:46
deploy rails to ec2 on ubuntu 12.04

Login to the server

Type this command: (make sure the pem file location is correct)

ssh -i "imeducate-client.pem" [email protected]

Install Ruby

Since rvm is already installed, then just install ruby 2.5.8:

@omkz
omkz / user.md
Last active June 22, 2020 13:24
Add a new user on Amazon EC2 Ubuntu 12.04 instance

Create a new user named deploy with a home directory of /opt/deploy:

useradd -m -d /opt/deploy deploy
or
adduser deploy --home /opt/deploy

Create the deploy user and add them to the sudo group.

@omkz
omkz / autoloading.md
Created June 14, 2020 07:08
rails autoloading

Saya mendapatkan kesempatan update aplikasi Rails 4 ke Rails 6. Semua lancar jaya ketika di mesin development. Kemudian saya mendeploy aplikasi tersebut ke server dan mendapatkan error berikut:

ActionView::Template::Error (uninitialized constant SubscriptionsMixin::Subscriptioxxxxx
Did you mean?  SubscriptionsMixin):
    1: .purchase-details
    2:   = semantic_form_for [ line_item ], namespace: form_namespace do |f|
    3:     = f.inputs do
    4:       = f.input :duration_in_months, as: :select, collection: product.member_trial_options_for_select(current_member) + product.subscription_options_for_select, include_blank: false, label: label
 5: = f.input :product_id, as: :hidden, input_html: { value: product.id }

Backup the database:

pg_dump -U imeducate imeducate_production -f imeducate_production.sql -h localhost

Install Postgres 9.5

wget https://gist.github.com/petere/5893799/raw/d1b3a4a7e92e397e2c323ca9ce93ec958dcf6474/apt.postgresql.org.sh
chmod a+x apt.postgresql.org.sh
@omkz
omkz / apt.postgresql.org.sh
Last active June 12, 2020 09:03
script to add apt.postgresql.org to sources.list
#!/bin/sh
# script to add apt.postgresql.org to sources.list
# from command like
CODENAME="$1"
# lsb_release is the best interface, but not always available
if [ -z "$CODENAME" ]; then
CODENAME=$(lsb_release -cs 2>/dev/null)
fi
@omkz
omkz / rabbit.md
Last active November 27, 2024 18:21
How to Install RabbitMQ on Ubuntu 18.04

Copy the following script and save it in your server as rabbit.sh:

#!/bin/sh
## If sudo is not available on the system,
## uncomment the line below to install it
# apt-get install -y sudo
sudo apt-get update -y
## Install prerequisites
sudo apt-get install curl gnupg -y