This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password | |
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'` | |
if [ -z "$REPO_URL" ]; then | |
echo "-- ERROR: Could not identify Repo url." | |
echo " It is possible this repo is already using SSH instead of HTTPS." | |
exit | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeController < ApplicationController | |
before filter :check_authorized | |
authorized_roles = ["platinum", "gold"] | |
def check_authorized | |
redirect_to no_way_sucka_path, :notice => "No Way!" unless authorized_roles.include? current_user.role | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/policies/court_policy.rb | |
``` | |
class CourtPolicy < ApplicationPolicy | |
attr_reader :user, :record | |
def initialize(user, record) | |
@user = user | |
@record = record | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.create_subscription(recurrance, recurly_token, paysysid) | |
response = Recurly::Subscription.create! plan_code: "premium-#{recurrance}", | |
account: { | |
account_code: paysysid, | |
billing_info: { token_id: recurly_token } | |
} | |
if response.is_a? Recurly::Subscription | |
return paysysid if response.state == "active" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="payment"> | |
<%= javascript_include_tag 'https://js.recurly.com/v3/recurly.js' %> | |
<%= stylesheet_link_tag "creditcard" %> | |
<section class="credit-card visa gr-visa"> | |
<header class="payment-top"> | |
This is a secure 128-bit SSL encrypted payment form | |
</header> | |
<!--- <div class="logo">Visa</div> ---> | |
<h2>Payment Details</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// Configure recurly.js | |
recurly.configure('<%= @recurly_public_key %>'); | |
//grab some dom | |
var form = $('form'); | |
//var methodRadio = $('input[name=payment-method-select]'); | |
var box = form.find('.payment'); | |
var inputs = form.find('input, select, button'); | |
var submit = form.find('button'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Open a command prompt and navigate to /etc/nginx/ssl | |
2. Issue "openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr" | |
3. Get your certificate issued - Go to your certificate authority and give them the CSR (server.csr) | |
4. Copy your new crt (that the certificate authority issued) to the /etc/nginx/ssl and give it read priveledges | |
5. Reconfigure your nginx.conf, here is mine. The first part redirects 80 to 443, the second part listens to 443 and is optimized to return Ruby on Rails application requests using gzip and unicorn. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f.collection_select :x, query, :y, :z | |
:x = the value of the select id and name | |
query = the query sent to the database to return values | |
:y = the values in the options | |
:z = what you want displayed in the drop down menu | |
So if you have a Model that has an alias and an ID you would render it like this |
NewerOlder