Skip to content

Instantly share code, notes, and snippets.

Avatar

Allen Chun ChunAllen

  • Manila / Singapore
View GitHub Profile
View gist:f3dea073a2bf5115b1f1

TODO: make gem for this

This was tested using Rails 3.2 and Rails 4.0 on Ruby 2.0.0.

Bower

  1. Set the install directory for Bower components:

// .bowerrc

View add-option-to-dropdown.js
$("#selectBox").append('<option value="option6">option6</option>');
View gist:03d8cb580b54efe10ee4
##
Lets say we have YoloFont.otf
1. We add it to vendor/assets/fonts/ folder
2. Me personaly creates a file named fonts.css.scss in app/assets/stylesheets
In it I have
@font-face{
font-family: 'YoloFont';
View google_analytics.coffee
class @GoogleAnalytics
@load: ->
# Load the analytics code
window['GoogleAnalyticsObject'] = 'ga'
window['ga'] = window['ga'] || ->
(window['ga'].q = window['ga'].q || []).push arguments
window['ga'].l = 1 * new Date()
# Add the script
@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
View index.html
<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>
View digitalocean.md

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

View DigitalOcean-BasicRailsSetup.md

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
@ChunAllen
ChunAllen / nginx.conf
Last active August 29, 2015 14:18
Deploying Rails application with Phusion Passenger (Nginx)
View nginx.conf
Please refer Ruby on Rails installation in this link
https://gorails.com/setup/ubuntu/14.10
Please refer phusion passenger installation in this link:
https://www.digitalocean.com/community/tutorials/how-to-install-rails-and-nginx-with-passenger-on-ubuntu
TLDR; Install phusion passenger to ubuntu server using:
- gem install passenger
- rvmsudo passenger-install-nginx-module
@ChunAllen
ChunAllen / google_analytics.js.coffee
Created April 15, 2015 09:32
Google Analytics for Ruby on Rails
View google_analytics.js.coffee
class @GoogleAnalytics
@load: ->
# Load the analytics code
window['GoogleAnalyticsObject'] = 'ga'
window['ga'] = window['ga'] || ->
(window['ga'].q = window['ga'].q || []).push arguments
window['ga'].l = 1 * new Date()
# Add the script
@ChunAllen
ChunAllen / .bashrc
Last active August 29, 2015 14:25
Displaying branch name and computer name in terminal
View .bashrc
PS1='${c_user}\h${c_reset}:${c_path}\w${c_reset}$(git_prompt)\$ '
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset=`tput sgr0`
c_user=`tput setaf 2; tput bold`
c_path=`tput setaf 4; tput bold`
c_git_clean=`tput setaf 2`
c_git_dirty=`tput setaf 1`
else
c_reset=