Skip to content

Instantly share code, notes, and snippets.

View ChunAllen's full-sized avatar

Allen Chun ChunAllen

  • Singapore
View GitHub Profile
@ChunAllen
ChunAllen / how-to-copy-aws-rds-to-local.md
Created December 15, 2017 09:59 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@ChunAllen
ChunAllen / Capistrano Commands
Created November 19, 2017 13:56 — forked from clara101/Capistrano Commands
Deploy Rails 4 to AWS EC2(Ubuntu 14.04.4 LTS). Nginx, Puma, Capistrano3, PostgreSQL, RVM.
Capistrano::Rails::Db
cap production deploy:db:abort_if_pending_migrations # Run rake db:abort_if_pending_migrations
cap production deploy:db:create # Run rake db:create
cap production deploy:db:drop # Run rake db:drop
cap production deploy:db:migrate # Run rake db:migrate Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
cap production deploy:db:migrate:down # Run rake db:migrate:down Run the "down" for a given migration VERSION
cap production deploy:db:migrate:redo # Run rake db:migrate:redo Rollback the database one migration and re migrate up (options: STEP=x, VERSION=x)
cap production deploy:db:migrate:reset # Run rake db:migrate:reset Reset your database using your migrations
cap production deploy:db:migrate:status # Run rake db:migrate:status Display status of migrations
cap production deploy:db:migrate:up # Run rake db:mi
@ChunAllen
ChunAllen / host_your_rails_app_on_ec2.md
Created November 9, 2017 03:48 — forked from the-dvlpr/host_your_rails_app_on_ec2.md
Deploy and Reroute Traffic from Purchased Domain Name to your Rails App on a self-hosted EC2 Server

Punchlist for Serving your Rails App on an EC2 Instance

Run through this list to setup your EC2 instance and host your rails app. This list makes a few assumptions (make changes as necessary)

  • You have github repo with a rails app pushed to it that we'll just pull down to the new server
  • You're using Rails 5.1

If not, see very bottom for steps to build a quick example app.

Launching EC2 instance

  • Use the basic Linux AMI distro: Amazon Linux AMI 2017.09.0 (HVM), SSD Volume Type - ami-8c1be5f6
  • Select a size: t2.micro is fine for this, unless you need larger for a production app
@ChunAllen
ChunAllen / chosen-bootstrap.css
Created August 6, 2017 03:23 — forked from koenpunt/chosen-bootstrap.css
Bootstrap 3.0 theme for Chosen
select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
@ChunAllen
ChunAllen / API.md
Created April 5, 2017 03:33 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@ChunAllen
ChunAllen / gist:359de08af46d632584ce
Last active August 29, 2015 14:27 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@ChunAllen
ChunAllen / capybara cheat sheet
Last active August 29, 2015 14:27 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')

Basic Rails App on Digital Ocean / Ngnix / Unicorn

Most of this I got from the DigitalOcean file.

  1. Sign up for an account at digitalocean.com. Create a droplet using the pre-configed Ubuntu 12.10/Rails/Ngix/Unicorn option and using an ssh key if you set one up first. [An overview can be found here.] (https://www.digitalocean.com/community/articles/how-to-set-up-ssh-keys--2) If you don’t set up an SSH key, that's okay, DigitialOcean (DO) will send you one to your email.
  2. Once setup with an IP, point your domain or subdomain to the IP from wherever you are hosting as an A record. Log in using ssh root@ip.address.of.server. Enter your password if needed.
  3. Type passwd into the console to change the password of root to something you can remember.
  4. If you want add a new user so you don’t have to use root then type adduser [username] in the console. Feel free to fill out the Fu

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@ChunAllen
ChunAllen / index.html
Last active August 29, 2015 14:14 — forked from anonymous/Sort-Dropdown-list-alphabetically-jquery.markdown
Sorting values asc and desc on multiple dropdowns
<select class="ddlList">
<option value="3">Three</option>
<option value="1">One</option>
<option value="1">one</option>
<option value="1">a</option>
<option value="1">b</option>
<option value="1">A</option>
<option value="1">B</option>
<option value="0">Zero</option>
<option value="2">Two</option>