Skip to content

Instantly share code, notes, and snippets.

View whitmanc's full-sized avatar

Chris Whitman whitmanc

View GitHub Profile
@whitmanc
whitmanc / product_decorator.rb
Created October 18, 2016 00:25
Spree - Skip / exclude a model's attribute validation
Spree::Product.class_eval do
...
_validators.reject!{ |key, value| key == :shipping_category }
_validate_callbacks.each do |callback|
callback.raw_filter.attributes.reject! { |key| key == :shipping_category } if callback.raw_filter.respond_to?(:attributes)
end
...
end
@whitmanc
whitmanc / user_sessions_decorator.rb
Last active September 23, 2016 23:48
Spree (3.1.0) - Custom redirect after admin login
Spree::UserSessionsController.class_eval do
def redirect_back_or_default(default)
if spree_current_user && spree_current_user.has_spree_role?("admin")
redirect_to(admin_products_path)
# Commenting out line below to allow redirecting to
# admin/products page
#redirect_to(session["spree_user_return_to"] || default)
session["spree_user_return_to"] = nil
else
redirect_to(default)
@whitmanc
whitmanc / spree_backend_install.md
Created September 9, 2016 23:41 — forked from huoxito/spree_backend_install.md
Spree backend install

Set up a Spree backend only install

rails new store-backend

Gemfile

gem 'spree_backend', github: 'spree/spree'
@whitmanc
whitmanc / gist:48f01d77a45169bbb1d3
Created February 26, 2016 20:05
Hide status bar in ios - 2 methods
Method 1-
Add following to MainViewController.m
-(BOOL)prefersStatusBarHidden{
return YES;
}
Method 2-
Within your project target in xCode, configure these settings:
class App.Views.SectionTabsView extends Backbone.View
template: JST['clients/section_tabs']
events:
'click li': 'menuItemClicked'
render: ->
@$el.append @template()
menuItemClicked: (e) ->
##
# Main view of app with left/right slide panels.
# The dashboard also houses the message list
# and new message form. To access anything other
# than a list of messages, we navigate to a new
# page
#
# @class DashboardView
#
define [
@whitmanc
whitmanc / align.rb
Last active August 29, 2015 14:05
To use, run `ruby align.rb "path_to/audio.wav" "For J and C, with all my love"`
regExp = /\(([^)]+)\)/;
times = []
timesPretty = ""
if ARGV.length < 2
puts "Needs 2 args input to parse: 1. audio path and 2. text that matches audio"
else
# Make variables from parameters
audioPath = ARGV[0]
text = ARGV[1]
@whitmanc
whitmanc / gist:3943844
Created October 24, 2012 04:32
MP3 File Recognizer
package recognizer;
/*
* Copyright 1999-2004 Carnegie Mellon University.
* Portions Copyright 2004 Sun Microsystems, Inc.
* Portions Copyright 2004 Mitsubishi Electric Research Laboratories.
* All Rights Reserved. Use is subject to license terms.
*
* See the file "license.terms" for information on usage and
* redistribution of this file, and for a DISCLAIMER OF ALL
widgetAtPoint: (point) ->
widgetWithHighestZ =
_.max @widgets, (widget) ->
if widget.getIsVisible() and widget.isPointInside(point)
return widget.getZOrder() unless typeof widget.getZOrder isnt "function"
return widgetWithHighestZ if widgetWithHighestZ
for widget,i in @widgets
if widget.getIsVisible() and widget.isPointInside(point)
$('#c9_android_or_ios button').removeClass('active')
$('#c9_android_or_ios button:nth-child(2)').addClass('active')