Skip to content

Instantly share code, notes, and snippets.

View ccschmitz's full-sized avatar

Chris Schmitz ccschmitz

View GitHub Profile
@ccschmitz
ccschmitz / capybara-selenium-chrome-config.rb
Last active June 1, 2018 14:07
Capybara Selenium Chrome Extension Configuration
Rspec.configure do |config|
# ... all our other config ...
Capybara.register_driver :selenium_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_extension(Rails.root.join('spec', 'chrome_extensions', 'react-devtools.crx'))
options.add_extension(Rails.root.join('spec', 'chrome_extensions', 'redux-devtools.crx'))
chrome_options = {
browser: :chrome,
@ccschmitz
ccschmitz / index.html
Created February 26, 2016 15:54 — forked from phil-pedruco/index.html
Plotting a bell (Gaussian) curve in d3
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Normal Plot</title>
<meta name="description" content="">
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style type="text/css">
@ccschmitz
ccschmitz / install-ssl-apache.md
Created April 19, 2015 19:48
How to install an SSL certificate on an Apache server.

Installing an SSL certificate on Apache

  1. Create a private key:
openssl genrsa 2048 > private-key.pem
  1. Create a Certificate Signing Request (CSR):
@ccschmitz
ccschmitz / data_migrations_in_rails.md
Created August 19, 2014 13:10
Some tips for handling data migrations in Rails

Data Migrations in Rails Apps

If you need to manipulate existing data when your code is deployed, there are two main ways to do it:

  1. Create a rake task to migrate the data after the code is deployed. This is ideal for more complex data migrations.
  2. Use ActiveRecord models in a migration. This is acceptable for smaller data manipulations.

Regardless of the method you use, make sure to test your migrations before submitting them.

Data Migrations in Models

@ccschmitz
ccschmitz / list.html
Created June 17, 2014 02:25
Angular Pagination Example
<ul class="some-list" ng-controller="someListController">
<li ng-repeat="item in items">{{item.name}}</li>
</ul>
<ul class="pagination-links">
<li ng-repeat="page in totalPages">
<a ng-click="getItems(page)">{{page}}</a>
</li>
</ul>
@ccschmitz
ccschmitz / 0_reuse_code.js
Created June 2, 2014 20:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/**
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/
@ccschmitz
ccschmitz / share-and-save.html
Last active September 18, 2017 06:55
Display content only after a user shares something via Twitter, Facebook or Google+
<div id="fb-root"></div>
<script>
function showDiscountCode(response) {
// if they unliked you...
if (response && response.state === 'off') {
hideDiscountCode();
} else {
$('.discount-code').slideDown('slow');
}
}
@ccschmitz
ccschmitz / spree_tools.rake
Last active October 11, 2016 08:18
A Rake task for creating Spree promo codes in bulk
namespace :spree_tools do
desc "Generate random coupon codes in bulk."
task :generate_coupons => :environment do
puts "How many codes would you like to generate?"
number_of_codes = STDIN.gets.strip.to_i
puts "\nHow much would you like this discount to be for?"
amount = STDIN.gets.strip.to_f
puts "\nWhat product should this promotion apply for? (use product name)"
@ccschmitz
ccschmitz / model_spec_structure.rb
Created July 20, 2013 15:22
How I typically structure my Rspec model specs.
require 'spec_helper'
describe Order do
describe '.responds_to' do
# attributes
it { should respond_to(:recipient_name) }
it { should respond_to(:shipping_to_address) }
it { should respond_to(:shipping_to_city) }
it { should respond_to(:shipping_to_state) }
it { should respond_to(:shipping_to_zip) }