Skip to content

Instantly share code, notes, and snippets.

Adam Wróbel amw

Block or report user

Report or block amw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@amw
amw / assets.rake
Last active Aug 29, 2015
Preparing compressed (gzipped) Rails assets for Nginx mod_gzip_static
View assets.rake
# lib/tasks/assets.rake
namespace :assets do
ManifestPattern = /^manifest-[0-9a-f]{32}\.json$/
ExtensionsToCompress = %w{.js .css .json}.freeze
desc "GZip assets"
task :compress do
files = Pathname.glob(Rails.root.join('public/assets/**/*')).map do |file|
next unless file.extname.in? ExtensionsToCompress
@amw
amw / binary-encoding.rb
Created Jul 11, 2015
BSON::Binary error when data is non-utf8 compatible string
View binary-encoding.rb
require "bson"
require "digest/sha2"
d = Digest::SHA256.new
d << "test"
string = d.digest
puts string.encoding
binary = BSON::Binary.new string
puts binary.to_bson
@amw
amw / database.yml
Created Dec 21, 2010
Standard rails database.yml with additional definition of live database
View database.yml
development:
adapter: mysql2 # must =~ /mysql/
database: adamDb # required
username: your_user
password: keep_secret
live:
ssh_user: # optional, use if live system user differs from your dev user
host: example.com # required, can be IP
adapter: mysql2 # must =~ /mysql/
@amw
amw / ar_patch.rb
Created Jan 19, 2011
A patch that allows lambda arguments to default_scope in rails ~> 3.0.0
View ar_patch.rb
module ActiveRecord
class Base
class << self
def default_scope(options = {})
reset_scoped_methods
default_scoping = self.default_scoping.dup
previous = default_scoping.pop
if previous.respond_to?(:call) or options.respond_to?(:call)
View default scope for uniqueness validator
module SharedDatabase
module UniquenessValidator
def self.included(validator)
validator.class_eval do
def setup_with_subdomain_account(klass)
return unless klass.table_exists?
if klass.column_names.include? 'subdomain_account_id'
scope = [:subdomain_account_id]
View spree-tests-fail-on-ruby-1_9_2
spree[fix-order-scopes]$rake spec
(in /Users/amw/Projects/spree)
########################### api #########################
rm api/Gemfile*
cd api && /opt/local/bin/rake test_app
(in /Users/amw/Projects/spree/api)
run rake spree_core:install from "./test_app"
(in /Users/amw/Projects/spree/api/spec/test_app)
run rake spree_auth:install from "./test_app"
(in /Users/amw/Projects/spree/api/spec/test_app)
View after "require faker"
$rake spec
(in /home/amw/spree)
########################### api #########################
rm api/Gemfile*
cd api && /var/lib/gems/1.8/bin/rake test_app
(in /home/amw/spree/api)
run rails new test_app --database=sqlite3 -GJTq --skip-gemfile from "./spec"
run rake spree_core:install from "./test_app"
(in /home/amw/spree/api/spec/test_app)
run rake spree_auth:install from "./test_app"
View "require faker" patch
$git diff
diff --git a/auth/spec/spec_helper.rb b/auth/spec/spec_helper.rb
index 2d271e6..825c2d2 100644
--- a/auth/spec/spec_helper.rb
+++ b/auth/spec/spec_helper.rb
@@ -3,6 +3,7 @@
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../test_app/config/environment", __FILE__)
require 'rspec/rails'
+require 'faker'
@amw
amw / before "require faker"
Created Apr 15, 2011
before "require faker"
View before "require faker"
$rake spec
(in /home/amw/spree)
########################### api #########################
rm api/Gemfile*
cd api && /var/lib/gems/1.8/bin/rake test_app
(in /home/amw/spree/api)
run rails new test_app --database=sqlite3 -GJTq --skip-gemfile from "./spec"
run rake spree_core:install from "./test_app"
(in /home/amw/spree/api/spec/test_app)
run rake spree_auth:install from "./test_app"
@amw
amw / Gemfile.lock
Created May 30, 2011
Sprockets encoding trace
View Gemfile.lock
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.0.rc1)
actionpack (= 3.1.0.rc1)
mail (~> 2.3.0)
actionpack (3.1.0.rc1)
activemodel (= 3.1.0.rc1)
activesupport (= 3.1.0.rc1)
builder (~> 3.0.0)
You can’t perform that action at this time.