Skip to content

Instantly share code, notes, and snippets.

View Austio's full-sized avatar

Austin Story Austio

View GitHub Profile
#/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
@Austio
Austio / gist:34e44ca30ba9a3ee8275
Created August 11, 2014 16:44
Simple Multi-tenancy
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
app/policies/court_policy.rb
```
class CourtPolicy < ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
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"
<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>
<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');
=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')
@Austio
Austio / NGINX on Ruby on Rails with Unicorn and GZIP assets
Last active September 3, 2018 19:22
Configure NGINX for SSL using unicorn and gzip assets optimizations
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.
@Austio
Austio / f.collection_select
Created June 4, 2013 18:52
f.collection_select explained
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