Skip to content

Instantly share code, notes, and snippets.

View paulcook's full-sized avatar

Paul Cook paulcook

  • OSU TCO
  • Columbus, OH
View GitHub Profile
@paulcook
paulcook / mysql.rake
Created June 20, 2017 13:40 — forked from dfl/mysql.rake
rails rake tasks for dumping and reloading mysql databases
# mysql db backup and restore for rails
# by David Lowenfels <david@internautdesign.com> 4/2011
require 'yaml'
namespace :db do
def backup_prep
@directory = File.join(RAILS_ROOT, 'db', 'backup')
@db = YAML::load( File.open( File.join(RAILS_ROOT, 'config', 'database.yml') ) )[ RAILS_ENV ]
@db_params = "-u #{@db['username']} #{@db['database']}"
@paulcook
paulcook / jquery_ui.rb
Created April 24, 2017 13:18 — forked from mttdffy/jquery_ui.rb
Capybara / Poltergeist helpers for JQuery UI
module JSHelpers
module JQueryUI
# type inside an autocomplete field and pick a value.
#
# @param [String] field selector of the autocomplete field
# @param [Hash] options details about what to search and what to select
# @param options [String] :with the text to type in the autocomplete field
# @param options [String] :select the text value of the autocomplete resuilt you
# want to pick. If this option is not present, the first result will be picked.
{
"name": "manager",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"firebase": "^3.7.8",
// Shopmaster/frontend/app/routes/grocery-lists/new.js
import Ember from 'ember';
export default Ember.Route.extend({
setupController: function(controller, model) {
controller.set('model', model);
},
model: function() {
def save_card
# Stubbed method on the api wrapper
response = Api::save_card(card_info)
if response.success?
# do something because it was saved
else
# let user know it wasnt saved
end
@paulcook
paulcook / base_controller.rb
Created November 18, 2015 18:40 — forked from dhoelzgen/base_controller.rb
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
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'
// Preferred correct-incorrect-interactive
<div class="correct-incorrect-interactive">
<ol class="questions">
<li class="question">
<p><strong>This statement says the hospital can call your primary care doctor and talk with him/her about your treatment.</strong></p>
<ol class="choices">
<li class="choice correct"><i></i><strong>TRUE</strong></li>
<li class="choice incorrect"><i></i><strong>FALSE</strong></li>
</ol>
</li>
// REQUIRES JQUERY AND BACKBONE TO BE LOADED FIRST
//
// With additions by Maciej Adwent http://github.com/Maciek416
// If token name and value are not supplied, this code Requires jQuery
//
// Adapted from:
// http://www.ngauthier.com/2011/02/backbone-and-rails-forgery-protection.html
// Nick Gauthier @ngauthier
//
# In config/initializers/local_override.rb:
require 'devise/strategies/authenticatable'
module Devise
module Strategies
class LocalOverride < Authenticatable
def valid?
true
end
require 'net/dns/resolver'
# Custom Domain
#
# Require net-dns gem
#
# A Rack middleware to to resolve the custom domain to original subdomain
# for your multi telent application.
#
# It's all transperant to your application, it performs cname lookup and