This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :sync_directories, ["public/assets", "public/galleries"] | |
set :sync_backups, 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'action_view' | |
require 'active_support' | |
require 'mustache' | |
class Mustache | |
# TODO - Think about allowing to overwrite layout methods in subclassing views | |
# | |
# http://github.com/defunkt/mustache/blob/master/lib/mustache/sinatra.rb#L79-82 | |
# http://github.com/defunkt/mustache/blob/master/lib/mustache/sinatra.rb#L96-102 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
def download(url) | |
Thread.new do | |
thread = Thread.current | |
body = thread[:body] = [] | |
url = URI.parse url | |
Net::HTTP.new(url.host, url.port).request_get(url.path) do |response| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to re-use the menu partial for a submenu in Refinery CMS >= 0.9.8.5 and < 0.9.9.22 | |
# header menu (main menu) which hides its children. | |
<%= render :partial => "/shared/menu", | |
:locals => { | |
:dom_id => 'menu', | |
:css => 'menu', | |
:collection => @menu_pages, | |
:hide_children => true | |
} -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Filter payment methods in Spree depending on the shipping name, | |
# use the following snippet within your activation method to | |
# make it work: | |
# | |
# CheckoutsController.class_eval { include FilterPaymentMethods } | |
# | |
# The magic happens within the InstanceMethods module, change the | |
# regexp to fit your needs. | |
# | |
# Kai Krakow, http://github.com/kakra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Spree extension capistrano tasks | |
# -------------------------------- | |
# by Christopher Maujean | |
# | |
# These tasks depend on the existence of the extensions hash. | |
# The key is name of the directory in vendor/extensions. | |
# The value is the git url of the extension. | |
# | |
# set :extensions, { | |
# 'my_site' => "git@github.com:/username/spree-my-site.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AbilityDecorator | |
include CanCan::Ability | |
def initialize(user) | |
############################# | |
can :destroy, LineItem do |item| | |
item.order.user == user | |
end | |
############################# | |
can :read, Artwork do |artwork| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CML2 | |
# Includes to ProductCategory model | |
module ProductCategory | |
def import node_set | |
::ProductCategory.delete_all | |
::ProductCategory.import_categories \ | |
node_set.xpath('/КоммерческаяИнформация/Классификатор/Группы') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a role user (no perms). Fire up the console rails c | |
$> Role.create(:title=>'User') | |
# In your Gemfile add | |
gem 'oa-oauth', :require => 'omniauth/oauth' | |
# At the beginning of devise.rb. You can also create a yaml file and instantiate when Rails begin | |
# For shake of simplicity I added the credentials at devise.rb | |
Facebook = Rails.env.development? ? {:app_id => 2621xxx, :secret => 'e81f33d042xxxxx'} : | |
{:app_id => 1749xxx9, :secret => '13c11be6628dc1xxxx'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Capistrano deployment email notifier for Rails 3 | |
Do you need to send email notifications after application deployments? | |
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html. | |
Here is Rails 3 port of the notifier. | |
The notifier sends an email after application deployment has been completed. |
OlderNewer