Skip to content

Instantly share code, notes, and snippets.

View alexpchin's full-sized avatar

Alex Chin alexpchin

View GitHub Profile
@alexpchin
alexpchin / restful_routes.md
Last active May 30, 2025 09:46
7 Restful Routes
URL HTTP Verb Action
/photos/ GET index
/photos/new GET new
/photos POST create
/photos/:id GET show
/photos/:id/edit GET edit
/photos/:id PATCH/PUT update
/photos/:id DELETE destroy
@alexpchin
alexpchin / express_intro_css.css
Created March 31, 2015 06:46
Expres Intro CSS
body {
text-align: center;
margin: 0;
}
header {
height: 60px;
line-height: 60px;
width: 100%;
background: #7fbd42;
@alexpchin
alexpchin / cors_rails_4.rb
Last active April 30, 2020 11:09
CORS Rails 4
# ApplicationController
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
headers['Access-Control-Allow-Headers'] = 'Origin, Content-Type, Accept, Authorization, Token'
headers['Access-Control-Max-Age'] = "1728000"
@alexpchin
alexpchin / fade_in_backgroun_image
Created April 28, 2015 10:05
Fade in background image
// HTML
<div class="background-image"></div>
// CSS
@-webkit-keyframes fade-in {
0% { opacity: 0; }
100% { opacity: 1; }
}
.background-image {
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
{{ user.name }} | Business Card Generator
</a>
</div>
</div>
</nav>
<div class="container-fluid">
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@alexpchin
alexpchin / irb-pimping.md
Last active August 29, 2015 14:25
Pimping irb

gem install irbtools

Optional.

require 'irb/completion'
require 'map_by_method'
require 'what_methods'
require 'pp'
IRB.conf[:AUTO_INDENT]=true
@alexpchin
alexpchin / useful-sqlite3-commands.md
Created July 22, 2015 12:34
Useful sqlite3 commands

List the tables in your database:

.tables

List how the table looks:

.schema tablename

Print the entire table:

@alexpchin
alexpchin / authentication_with_bcrypt_in_rails_4.md
Last active August 29, 2015 14:26 — forked from thebucknerlife/authentication_with_bcrypt_in_rails_4.md
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@alexpchin
alexpchin / gist:b42343922a96698abd18
Last active August 29, 2015 14:27 — forked from liamcurry/gist:2597326
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})