Skip to content

Instantly share code, notes, and snippets.

View terenceponce's full-sized avatar

Terence Ponce terenceponce

View GitHub Profile
@terenceponce
terenceponce / default.conf
Last active August 29, 2015 14:02
Typical Rails nginx configuration
upstream zealous-badger {
server 127.0.0.1:49224;
}
server {
listen [::]:80;
listen 80;
server_name zealous-badger.example.com;
location / {
proxy_pass http://zealous-badger;
proxy_http_version 1.1;
@terenceponce
terenceponce / application.html.gara
Created September 2, 2014 04:00
Gara / HAML comparison
content_for :content do
main(class: 'main-container', role: 'main') {
render 'shared/express_blog/sidebar'
div(class: 'content-body') {
render 'shared/express_admin/messages'
if content_for?(:page_header)
div(class: 'page-header') {
div(class: 'row') {
div(class: 'small-12 columns') {
yield :page_header
@terenceponce
terenceponce / Gemfile
Last active August 29, 2015 14:08
Creating an API with Rails, Doorkeeper, and Grape
source 'https://rubygems.org'
gem 'rails', '4.1.6'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
@terenceponce
terenceponce / curl1.sh
Created December 12, 2014 04:55
Resource Owner Credentials flow
curl -H “Content-Type: application/json" \
-d '{"client_id":"a11bbd9c339e6d8bd84368061089971398e23617d88a7c8dd060555b7cff1077","client_secret":"f079dadcca08a26d5967421f3849447e1e4519d6ba33cabdd4bdd0c86aebded3","grant_type":"password","username":"test@example.com","password":"passw0rd"}' /
-X POST http://localhost:3000/oauth/token
@terenceponce
terenceponce / omniauth_macros.rb
Created March 20, 2012 09:15 — forked from kinopyo/omniauth_macros.rb
Integration test with Omniauth. This example is using twitter, and assume you've installed rspec and capybara. Official document is here: https://github.com/intridea/omniauth/wiki/Integration-Testing
# in spec/support/omniauth_macros.rb
module OmniauthMacros
def mock_auth_hash
# The mock_auth configuration allows you to set per-provider (or default)
# authentication hashes to return during integration testing.
OmniAuth.config.mock_auth[:twitter] = {
'provider' => 'twitter',
'uid' => '123545',
'user_info' => {
'name' => 'mockuser',
@terenceponce
terenceponce / Console
Created April 3, 2012 08:36
Unit testing validatable module of Devise
Failures:
1) User when email address is already taken
Failure/Error: it { should_not be_valid }
expected valid? to return false, got true
# ./spec/models/user_spec.rb:73:in `block (3 levels) in <top (required)>'
@terenceponce
terenceponce / _article.html.erb
Created April 6, 2012 04:59
Link appears in the browser, but the test says it's not there
<% if user_signed_in? %>
<% if current_user.id == article.author.id %>
<%= link_to 'Edit article', edit_article_path(article) %>
<% end %>
<% end %>
@terenceponce
terenceponce / _article.html.erb
Created April 10, 2012 08:56
Having trouble in testing CanCan
<% if can? :update, article %>
<%= link_to 'Edit', edit_article_path(article) %>
<% end %>
<% if can? :destroy, article %>
<%= link_to 'Destroy', article_path(article), :confirm => 'Are you sure?', :method => :delete %>
<% end %>
@terenceponce
terenceponce / database.yml
Created May 17, 2012 08:34
Rails 3 MySQL2 sample config
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: projectname_development
pool: 5
host: localhost
username: username
password: password
@terenceponce
terenceponce / index.html
Created July 19, 2012 05:52
jQuery Sortable issue in IE9
<!--
Error: Object doesn't support property or method 'attr'
-->
<div class='popover' id='playlist_menu'>
<ul class='toplay' style='overflow:auto'>
<li class='playlist_item' data-id='27' data-order='1' id='videos_27'></li>
<li class='playlist_item' data-id='1' data-order='2' id='videos_1'></li>
<li class='playlist_item' data-id='52' data-order='3' id='videos_52'></li>
</ul>