Skip to content

Instantly share code, notes, and snippets.

View christopherstyles's full-sized avatar

Chris Styles christopherstyles

View GitHub Profile
@christopherstyles
christopherstyles / guard 'spork'
Created June 27, 2012 01:58
a sample guard watcher configuration for spork, in rails
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber }
@christopherstyles
christopherstyles / deploy-fail
Created October 14, 2012 06:20
logfile from failed staging deployment
git update-ref refs/heroku_san/deploy HEAD
git push git@heroku.com:tedcity2-staging.git --force refs/heroku_san/deploy:refs/heads/master
Counting objects: 84, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (60/60), done.
Writing objects: 100% (60/60), 7.02 KiB, done.
Total 60 (delta 44), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
$.fn.vAlign = ->
@each (i) ->
ah = $(this).height()
ph = $(this).parent().height()
mh = (ph - ah) / 2
$(this).css "margin-top", mh
((window, $, App, undefined_) ->
App.homePage =
initialize: ->
# exit if we're not on the correct page
return if !$(document.body).hasClass('pages-home-view')
@bindElements()
bindElements: ->
$("#stories_list li").mouseenter ->
expandingClone = $(this).clone()
thisStory = $(this);
thisStory.addClass('original_story')
thisStoryWidth = thisStory.width();
thisStoryHeight = thisStory.height();
thisStoryWidthDouble = thisStory.outerWidth() * 2;
#stories_list {
position: relative;
min-width: 960px;
li {
position: relative;
.item.cf {
padding: 0 5px;
.image {
margin-top: 5px;
}
@christopherstyles
christopherstyles / tire-search.rb
Last active December 19, 2015 02:09
Tire configuration for partial word matching.
tire.search(tire_params, load: true) do
query do
# Assumes +term+ is the text you're searching for
string term, default_field: 'title', default_operator: 'AND'
match :title, term, type: 'phrase_prefix', max_expansions: 10
end
end
<script type="text/javascript" id="">$(function(){$(".btn.btn-large.btn-action.btn-red").click(facebookTrackingSendClick)});function facebookTrackingSendClick(c){c.preventDefault();(function(){var a=document.createElement("script");a.async=!0;a.src="//connect.facebook.net/en_US/fp.js";a.onload=function(){};var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b)})()};</script>
<script type="text/javascript" id="">$(function(){$(".btn.btn-large.btn-action.btn-red").click(googleTrackingSendClick)});function googleTrackingSendClick(c){c.preventDefault();(function(){var a=document.createElement("script");a.async=!0;a.src="//www.googleadservices.com/pagead/conversion.js";a.onload=function(){};var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b)})()};</script>
@christopherstyles
christopherstyles / invitations_controller.rb
Last active August 29, 2015 13:59
Move Clubs application invitation responsibilities to a controller
# app/controllers/admin/clubs/applications/invitations_controller.rb
module Admin
module Clubs
module Applications
# InvitationsController allows an application invitation to be sent, and
# to trigger subsequent actions, such as setting state on the application
# or sending an invitation email.
class InvitationsController < Admin::ApplicationController
respond_to :js
before_filter :set_application
@christopherstyles
christopherstyles / notifications.rb
Created June 13, 2014 04:03
Nested classes versus compact style
# app/models/clubs/notification/invitation.rb
module Clubs
class Notification
class Invitation < Clubs::Notification
# snip
end
end
end
# Alternate