Skip to content

Instantly share code, notes, and snippets.

View supairish's full-sized avatar
🏂
Shreddin

Chris Irish supairish

🏂
Shreddin
View GitHub Profile
@supairish
supairish / hooks_controller.rb
Created September 19, 2018 00:31 — forked from ryansch/hooks_controller.rb
Rails Controller for Chargify Webhooks
require 'md5'
class Chargify::HooksController < ApplicationController
protect_from_forgery :except => :dispatch
before_filter :verify, :only => :dispatch
EVENTS = %w[ test signup_success signup_failure renewal_success renewal_failure payment_success payment_failure billing_date_change subscription_state_change subscription_product_change ].freeze
def dispatch
event = params[:event]
@supairish
supairish / bypass_broken_images_middleware.rb
Created September 18, 2018 16:34 — forked from mcmire/bypass_broken_images_middleware.rb
Ignore requests for broken images in Capybara tests
# Instructions
# ------------
#
# * Save this as app/middlewares/bypass_broken_images_middleware.rb
# * Add the following inside of the Rails.application.configure block
# in config/environments/test.rb:
#
# config.middleware.insert_before(
#  ActionDispatch::DebugExceptions,
#  BypassBrokenImagesMiddleware,

Order of Rails Controller Callbacks

Rails 4.x

Started GET "/" for 127.0.0.1 at 2017-05-19 14:17:18 +0200
  Processing by WelcomeController#index as HTML
    prepend_around_action
    prepend_before_action
 before_action
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'rack', github: 'rack/rack'
gem 'i18n', github: 'svenfuchs/i18n'
gem 'sqlite3'
GEMFILE
@supairish
supairish / web-fonts-asset-pipeline.md
Created October 26, 2017 07:44 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
myService: Ember.inject.service()
});
@supairish
supairish / 20130822132243_change_product_long_description.rb
Created July 26, 2016 02:18 — forked from jenheilemann/20130822132243_change_product_long_description.rb
Rails migrations: String to Text and back again. It's kind of complicated to update a database column that is currently a "string" and convert it into "text." Well, it's not hard to update the column, but it can be dangerous if you need to rollback the migration - Postgresql and other databases don't like adding a limit to the column, and the `r…
class ChangeProductLongDescription < ActiveRecord::Migration
def up
# simple and straightforward
change_column :products, :long_description, :text
end
# but why cant it just be:
# change_column :product, :long_description, :string
# ???
# because effin databases don't like you, that's why.
@supairish
supairish / fuelux-repeater-dynamic
Created February 19, 2016 18:58 — forked from mbeard/fuelux-repeater-dynamic
Example of the Fuel UX repeater bound to a dynamic datasource (backed by an API).
<!DOCTYPE html>
<html class="fuelux">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Snippets</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- dependencies -->