This file contains hidden or 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
# lib/liquid_i18n_rails.rb | |
module LiquidI18nRails | |
def t(string) | |
I18n.t(string.to_sym) | |
end | |
end | |
# config/initializers/liquid.rb | |
require 'liquid_i18n_rails' | |
Liquid::Template.register_filter LiquidI18nRails |
This file contains hidden or 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
$.fn.extend | |
myplugin: (options) -> | |
self = $.fn.myplugin | |
opts = $.extend {}, self.default_options, options | |
$(this).each (i, el) -> | |
self.init el, opts | |
self.log el if opts.log | |
$.extend $.fn.myplugin, | |
default_options: |
This file contains hidden or 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
# | |
# Cookbook Name:: env_vars | |
# Recipe:: default | |
# | |
if ['solo', 'app', 'app_master', 'util'].include?(node[:instance_role]) | |
execute "reload-nginx" do | |
action :nothing | |
command "/etc/init.d/nginx reload" |
This file contains hidden or 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
# | |
# Cookbook Name:: whenever | |
# Recipe:: default | |
# | |
ey_cloud_report "whenever" do | |
message "starting whenever recipe" | |
end | |
if node[:instance_role] == 'solo' || | |
(node[:utility_instances].length > 0 && node[:utility_instances][0][:name] == node[:name]) || |
This file contains hidden or 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
describe "POST to #create" do | |
# Will use the file located at rspec/fixtures/files/test-document.pdf | |
let(:attachement) { fixture_file_upload('/files/test-document.pdf', "text/pdf") } | |
before do | |
post :create, attachment: {title: "Attachment Title", attachment: file_attachment} | |
end | |
it {should redirect_to some_path } | |
end |
This file contains hidden or 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 'benchmark' | |
require 'nokogiri' | |
n = 50000 | |
Benchmark.bm do |x| | |
x.report { doc = Nokogiri::HTML::DocumentFragment.parse("<p>Foo Bar</p> <p>bar bar bar</p> <p>bla</p>") ; doc.children.map{|node| node.to_s.strip}.compact.join } | |
x.report { doc = Nokogiri::HTML::DocumentFragment.parse("<p>Foo Bar</p> <p>bar bar bar</p> <p>bla</p>") ; doc.children.each { |node| next_node = node.next_sibling ; next_node.remove if next_node && next_node.text.strip == '' } } | |
x.report { doc = Nokogiri::HTML("<p>Foo Bar</p> <p>bar bar bar</p> <p>bla</p>") ; doc.search('p').each { |node| next_node = node.next_sibling ; next_node.remove if next_node && next_node.text.strip == '' } } | |
end |
This file contains hidden or 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
App.Example = DS.Model.extend | |
name: DS.attr 'string' | |
App.ExamplesController = Ember.ArrayController.extend() | |
App.Router.map -> | |
@resource 'examples', -> | |
@resource 'example', path: ':example_id' | |
App.ExamplesRoute = Ember.Route.extend |
This file contains hidden or 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
<script> | |
document.write('<script src=//' + ('__proto__' in {} ? 'cdnjs.cloudflare.com/ajax/libs/zepto/1.0rc1/zepto' : 'ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery') + '.min.js><\/script>') | |
</script> | |
<script> | |
if ('__proto__' in {}) | |
window.Zepto || document.write('<script src="assets/libs/zepto.min.js"><\/script>') | |
else | |
window.jQuery || document.write('<script src="assets/libs/jquery.min.js"><\/script>') | |
</script> |
This file contains hidden or 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
# encoding: utf-8 | |
# | |
class Account::CreditCardController < Account::BaseController | |
# GET /account/credit_card | |
def edit | |
@account = current_account | |
@credit_card = ActiveMerchant::Billing::CreditCard.new | |
end | |
# PUT /account/credit_card |
This file contains hidden or 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 get all queries that has not been used by the site id 1 ? | |
DROP TABLE IF EXISTS `queries`; | |
SET @saved_cs_client = @@character_set_client; | |
SET character_set_client = utf8; | |
CREATE TABLE `queries` ( | |
`id` int(11) NOT NULL auto_increment, | |
`created_at` datetime default NULL, | |
`updated_at` datetime default NULL, | |
PRIMARY KEY (`id`) |