Skip to content

Instantly share code, notes, and snippets.

View bburdiliak's full-sized avatar

Boris Burdiliak bburdiliak

View GitHub Profile
class CustomSearch < Spree::Core::Search::Base
protected
def add_search_scopes(base_scope)
statement = nil
search.each do |property_name, property_values|
property = Spree::Property.find_by_name(property_name.gsub("_any", ""))
next unless property
substatement = product_property[:property_id].eq(property.id).and(product_property[:value].eq(property_values.first))
puts current_url
require 'pry'; binding.pry
@bburdiliak
bburdiliak / load_model.rake
Created September 23, 2015 17:15
Environment: Mongoid v. 4.0.0.rc1. Solves problem when running db:mongoid:create_indexes or any other mongoid rake task doesn't take into account models defined in engines used by your main application.
# main_app/lib/tasks/load_model.rake
namespace :db do
namespace :mongoid do
# include models from engine
task :load_models do
Scraper::Engine.config.paths['app/models'].to_a.each do |path|
preload = ::Mongoid.preload_models
if preload.resizable?
files = preload.map { |model| "#{path}/#{model}.rb" }
@bburdiliak
bburdiliak / shell
Created October 7, 2015 09:01
remove images and headers of old kernels
echo $(dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p') $(dpkg --list | grep linux-headers | awk '{ print $2 }' | sort -V | sed -n '/'"$(uname -r | sed "s/\([0-9.-]*\)-\([^0-9]\+\)/\1/")"'/q;p') | xargs sudo apt-get -y purge
version of V8 used by current NodeJS
node -p process.versions.v8
@bburdiliak
bburdiliak / gist:2fc51e7c243754e55844c80759cd372d
Last active February 20, 2017 13:50
react native / android
* start android virtual device
android avd
* list all SDKs
android list sdk -a
* install 3rd SDK from that list
android update sdk -a -u -t 3
* Linux-based systems support VM acceleration through the KVM software package, check availability of KVM
chrome://serviceworker-internals/
chrome://appcache-internals/
@bburdiliak
bburdiliak / ubuntu.sh
Last active August 29, 2018 07:13
Useful commands
## Disk management
# how big is your apt cache:
du -sh /var/cache/apt/archives
# remove old kernels (if no longer required)
sudo apt-get autoremove --purge
# list all directories and sort by size
du -m --max-depth 1 | sort -rn