Skip to content

Instantly share code, notes, and snippets.

View bookwyrm's full-sized avatar

Matt Vanderpol bookwyrm

View GitHub Profile
@bookwyrm
bookwyrm / account.rb
Last active May 24, 2023 11:04
Cleaning up Rails app signup with Devise and Reform
class Account < ActiveRecord::Base
has_many :users
end
@bookwyrm
bookwyrm / user_registration_spec.rb
Last active August 29, 2015 14:07
Integration test for user registration with Devise.
# /spec/features/user_registration_spec.rb
require 'rails_helper';
describe 'User registration' do
let(:user_email) { '[email protected]' }
let(:user_password) { 'registration_test_password' }
before :each do
visit new_user_registration_path
@bookwyrm
bookwyrm / functions.php
Last active August 29, 2015 13:57
Use Google's jQuery in WordPress
<?php
function qatab_scripts_styles() {
if ( !is_admin() ) {
wp_dequeue_script('jquery');
wp_deregister_script('jquery');
wp_enqueue_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js', array(), '1.11.0', true);
}
}
add_action('wp_enqueue_scripts', 'qatab_scripts_styles');
@bookwyrm
bookwyrm / _fonts.scss
Created February 19, 2014 13:55
_fonts.scss Sass include for managing Google web fonts with Sass
$lineheight-multiplier: 1.4;
$default-lineheight: -1;
// Must be the px font-size on your html element for proper rem calculation.
$base-font-size: 16px;
$base-font: arial, sans-serif;
/**
* Just specify font-size, don't override current font.
*/
@mixin font-size($fontsize, $lineheight: $default-lineheight, $base: $base-font-size) {
@bookwyrm
bookwyrm / hosts
Created January 29, 2014 13:13
Sample routes for local DNS configuration
192.168.0.55 www.qatab.dev
129.168.0.55 blog.qatab.dev
0.0.0.0 staging.domain.com
0.0.0.0 www.domain.com
@bookwyrm
bookwyrm / init-with-this.js
Created November 20, 2013 14:39
An example of using jQuery's onDOMReady shortcut with a simple component to get "this" in init to be the component context.
$(function() { SomeSiteComponent.init(); });
@bookwyrm
bookwyrm / main.js
Last active December 28, 2015 21:19
Example of how to organize JavaScript code for small-scale websites.
(function($, window, document) {
var SomeSiteComponent = {
init: function() {
if ($('.some-class').length > 0) {
SomeSiteComponent.setup();
}
},
setup: function() {
$(document).on('click', '.some-class .some-other-class', SomeSiteComponent.clickHandler);
},
@bookwyrm
bookwyrm / jquery-include.html
Created November 20, 2013 13:49
Sample jQuery include from Google CDN with a local fallback. Example adapted from HTML5 Boilerplate.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/js/libs/jquery-1.10.2.min.js"><\/script>')</script>