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 'rails' | |
require 'action_controller/railtie' | |
require 'rspec' | |
require 'rack/test' | |
class JsonTestApp < Rails::Application | |
config.root = File.dirname(__FILE__) | |
config.session_store :cookie_store, key: '****************************************' | |
config.secret_token = '****************************************' | |
config.secret_key_base = 'yup' |
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
RewriteEngine on | |
RewriteCond %{HTTP_HOST} !^www.new-domain.com$ [NC] | |
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [L,R] |
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
def compare_hashes(hash_a, hash_b, parent_keys = []) | |
keys_in_both = hash_a.keys & hash_b.keys | |
parent_name = parent_keys.map{|k| "['#{k}']"}.join | |
keys_in_both.each do |key| | |
if hash_a[key] != hash_b[key] | |
if hash_a[key].is_a?(Hash) && hash_b[key].is_a?(Hash) | |
compare_hashes(hash_a[key], hash_b[key], parent_keys + [key]) | |
else |
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
1.8.7 :001 > Foo = Struct.new(:id) do | |
1.8.7 :002 > BAR = 5 | |
1.8.7 :003?> end | |
=> Foo | |
1.8.7 :004 > BAR | |
=> 5 | |
1.8.7 :005 > Foo::BAR | |
(irb):5: warning: toplevel constant BAR referenced by Foo::BAR | |
=> 5 |
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
CREATE TRIGGER ai_order_statuses AFTER INSERT ON orders | |
FOR EACH ROW UPDATE order_status_counts | |
SET total = total + 1 | |
WHERE status = NEW.status | |
AND order_type = NEW.type | |
AND (NEW.on_hold != 1 OR NEW.on_hold IS NULL) | |
CREATE TRIGGER ad_order_statuses AFTER DELETE ON orders |
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
var count = 2; | |
var loader = $('.infinite-loader'); | |
$(window).scroll(function() { | |
if($(window).scrollTop() == $(document).height() - $(window).height()) { | |
if(count > total) { | |
return false; | |
} else { |
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 'base64' | |
require 'openssl' | |
require 'cgi' | |
module HmacRequestSigning | |
def inject_signature_header(headers, signature) | |
headers['X-Hmac-Sha256'] = signature | |
headers | |
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
# From https://svn.boost.org/trac/boost/ticket/6165 | |
# Attempting to run passenger-install-nginx-module on a system with | |
# GCC 4.7 (like archlinux) will halt with BOOST thread errors. | |
# Update the file in ~/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/ext/boost/config/stdlib/libstdcpp3.hpp | |
Index: boost/config/stdlib/libstdcpp3.hpp | |
=================================================================== | |
--- boost/config/stdlib/libstdcpp3.hpp (revision 75635) | |
+++ boost/config/stdlib/libstdcpp3.hpp (working copy) | |
@@ -33,7 +33,8 @@ |
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
namespace :vlad do | |
namespace :assets do | |
remote_task :symlink, :roles => :app do | |
run <<-CMD | |
rm -rf #{latest_release}/public/assets && | |
mkdir -p #{latest_release}/public && | |
mkdir -p #{shared_path}/assets && | |
ln -s #{shared_path}/assets #{latest_release}/public/assets | |
CMD | |
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
# Input: | |
# choices = { | |
# 'color' => %w(blue red green), | |
# 'sizes' => %w(small medium large extra-large), | |
# 'style' => %w(tshirt longsleeve) | |
# } | |
# | |
# Output: | |
# [{"sizes"=>"small", "color"=>"blue", "style"=>"tshirt"}, | |
# {"sizes"=>"small", "color"=>"blue", "style"=>"longsleeve"}, |