Skip to content

Instantly share code, notes, and snippets.

View richpeck's full-sized avatar

Richard Peck richpeck

View GitHub Profile
@mathias
mathias / buttons.coffee
Created January 30, 2012 15:31
Haml + Coffeescript Tweet button and Like button
((d, s, id) ->
js = undefined
fjs = d.getElementsByTagName(s)[0]
return if d.getElementById(id)
js = d.createElement(s)
js.id = id
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"
fjs.parentNode.insertBefore js, fjs
) document, "script", "facebook-jssdk"
@roberocity
roberocity / gist:3750808
Created September 19, 2012 17:03 — forked from madrobby/gist:3733875
Fade out elements on WebKit and Firefox and IE 9+
<style>
#mask_demo {
background: #d0d0d0;
width: 80%;
padding: 10px;
position: relative;
}
/* this may not be a better way to do it, but it is a different way.
it still used the svg for the background on browsers that don't
@robneu
robneu / reverse-post-order.php
Last active December 19, 2015 10:29
Reverse the post order for the Genesis Framework
<?php
add_action( 'pre_get_posts', 'prefix_reverse_post_order' );
/**
* Reverse Post Order for Post Archives
* on the Genesis Framework
*
* @author FAT Media
* @link http://youneedfat.com/reverse-post-order-genesis-framework/
* @param object $query data
*
@karmi
karmi / post-receive-deploy.rb
Created June 17, 2010 13:21
Example script to deploy a Rails application via Git post-receive hook
#!/usr/bin/env ruby
# Example script to deploy a Rails application via Git post-receive hook
#
# INSTALL
#
# $ curl http://gist.github.com/442106.txt -o post-receive
# $ mv post-receive path/to/to/your/repo.git/hooks/post-receive
# $ chmod +x post-receive
module ApplicationHelper
# get the name of the current layout in views
# http://stackoverflow.com/a/9438314/2535178
def current_layout
layout = controller.send(:_layout)
if layout.instance_of? String
layout
else
File.basename(layout.identifier).split('.').first
end
@douglascorrea
douglascorrea / app.styl
Last active October 27, 2016 18:23
Angular Directive for Particles JS - https://github.com/VincentGarreau/particles.js
.particleJs
background-color transparent
width 35%
height 100%
display block
position absolute
top 0px
left 0px
@unixmonkey
unixmonkey / load_sass_variables.rb
Created March 5, 2010 21:45
initializer to load a yaml file into sass variables
# Throw this in config/initializers and add
# @import variables.sass to the top of application.sass
# to have all variables in app_config.yml
# available as variables in your sass stylesheets
sass_variables = []
app_variables = YAML.load_file("#{Rails.root}/config/app_config.yml")
app_variables.each do |key, value|
sass_vars << "!#{key} = #{value}"
@richpeck
richpeck / default
Last active September 10, 2017 07:20
NGinx Setup
# /etc/nginx/sites-enabled/default
##########################################
##########################################
## General Server Setup ##
##########################################
##########################################
@bastien
bastien / content.rb
Created July 6, 2012 09:58
Paperclip processor to convert PDF to JPG to go around problems with the old versions of imagemagick and ghostscript available on Heroku. This file is located in [APP_ROOT]/lib/paperclip_processors/ghostscript.rb
# Model using the ghostscript processor
class Content < ActiveRecord::Base
has_attached_file :resource,
:styles => { :preview => ["725x1200>", :jpg], :thumb => ["100x140>", :jpg] },
:processors => [:ghostscript, :thumbnail],
:convert_options => { :all => '-colorspace RGB -flatten -density 300 -quality 100' },
:path => ":page_path/:class/:id/:resource_token/:style/:filename"
end
@richpeck
richpeck / application.rb
Last active August 4, 2018 22:02
CONTROLLER Exception Handling In Rails
# config/application.rb
# This can be put in any of the "environment" files - config/application.rb is just the main
config.exceptions_app = ->(env) { ApplicationController.action(:exception).call(env) }
# If you want custom exceptions, you need to add new rescue_responses:
# http://guides.rubyonrails.org/configuring.html#configuring-action-dispatch
config.action_dispatch.rescue_response["Your::Exception"] = :bad_request