Skip to content

Instantly share code, notes, and snippets.


Scott Meves stereoscott

View GitHub Profile
View gist:350759
class Stereo_Catalog_Block_Product_Featured extends Mage_Catalog_Block_Product_Abstract
protected $_productsCount = null;
protected function _beforeToHtml()
View gist:350766
* Magento
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
stereoscott / application.rb
Created Sep 5, 2012
Redirect Mobile User-Agent to Subdomain as Rack Middleware (in Rails)
View application.rb
module YourApp
class Application < Rails::Application
# ...
config.middleware.insert_before "Rack::Cache", "SubdomainRedirect"
# ...
stereoscott / application_controller.rb
Last active Jan 31, 2021
Returning mobile views from rails, either by using a custom view path ("views_mobile") or by setting a custom request format.
View application_controller.rb
class ApplicationController < ActionController::Base
before_filter :prepend_view_path_if_mobile
def mobile_request?
@mobile_request ||= (request.subdomains.first == domain_prefixes[:mobile])
helper_method :mobile_request?
def prepend_view_path_if_mobile
prepend_view_path Rails.root + 'app' + 'views_mobile' if mobile_request?
View gist:5584743
<body class="overview">
<section class="overview-section engage-section">
<h1 class="overview-section-header engage-section-header">xxx</h1>
<section class="overview-section measure-section">
<h1 class="overview-section-header measure-section-header">xxx</h1>
View gist:5620415
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
* Build:
;window.Modernizr=function(a,b,c){function A(a){j.cssText=a}function B(a,b){return A(m.join(a+";")+(b||""))}function C(a,b){return typeof a===b}function D(a,b){return!!~(""+a).indexOf(b)}function E(a,b){for(var d in a){var e=a[d];if(!D(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function F(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:C(f,"function")?f.bind(d||b):f}return!1}function G(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+o.join(d+" ")+d).split(" ");return C(b,"string")||C(b,"undefined")?E(e,b):(e=(a+" "+p.join(d+" ")+d).split(" "),F(e,b,c))}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),,k,l={}.toString,m=" -webkit- -moz- -o- -ms- ".split(" "),n="Webkit Moz O ms",o=n.split(" "),p=n.toLowerCase().split(" "),q={},r={},s={},t=[],u=t
View gist:5623005
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}] %{$fg[yellow]%}✗%{$reset_color%}"
stereoscott / active_admin.rb
Last active Mar 15, 2020
Stream CSV exports in ActiveAdmin in Rails 4
View active_admin.rb
# if you want to monkey patch every controller, put this in initializers/active_admin.rb
ActiveAdmin::ResourceController.class_eval do
include ActiveAdmin::CSVStream
stereoscott / active_admin_extensions.rb
Created Jan 12, 2014
Sample ActiveRecord model that uses paperclip to upload a csv report to s3
View active_admin_extensions.rb
module ActiveAdmin
module Reports
module DSL
def enable_reports
action_item only: :index do
link_to("Download", {action: :report, params: params}, {method: :post, data: { confirm: "Are you sure you want to generate this report?"}})
collection_action :report, method: :post do
stereoscott / copy_attachments.rb
Created Apr 6, 2014
Paperclip Copy Attachments
View copy_attachments.rb
module Paperclip
module CopyAttachments
def copy_attachments_from(source_obj, source_bucket = nil, destination_bucket = nil)
self.class.attachment_definitions.keys.each do |attachment_name|
source_attachment = source_obj.send(attachment_name)
next if source_attachment.blank?
destination_attachment = self.send(attachment_name)
connection = destination_attachment.send(:connection)