- Search for the desired t-shirt:
commercelayer resources:get skus -w name_i_cont_all=t-shirt,pink -w name_not_i_cont_all=women,whiteExample ID of t-shirt selected: NzWOpOSyBx.
| def paginate(scope, default_per_page = 20) | |
| collection = scope.page(params[:page]).per((params[:per_page] || default_per_page).to_i) | |
| current, total, per_page = collection.current_page, collection.num_pages, collection.limit_value | |
| return [{ | |
| pagination: { | |
| current: current, | |
| previous: (current > 1 ? (current - 1) : nil), | |
| next: (current == total ? nil : (current + 1)), |
| class ApplicationController < ActionController::Base | |
| protect_from_forgery with: :exception | |
| around_action :global_request_logging | |
| def global_request_logging | |
| http_request_header_keys = request.headers.env.keys.select{|header_name| header_name.match("^HTTP.*|^X-User.*")} | |
| http_request_headers = request.headers.env.select{|header_name, header_value| http_request_header_keys.index(header_name)} | |
| puts '*' * 40 | |
| pp request.method |
| #!/bin/sh | |
| if [ $# -ne 2 ]; then | |
| echo "Usage: $(basename $0) <heroku-app-name> <local_database_name>" | |
| exit -1 | |
| fi | |
| if heroku pg:backups capture --app $1 ; then | |
| if curl -o latest.dump `heroku pg:backups public-url --app $1` ; then | |
| pg_restore --verbose --clean --no-acl --no-owner -h localhost -U $USER -d $2 latest.dump |
| function party_background_color() { | |
| $("html, body").css("background-color", getRandomColor()); | |
| var all = document.getElementsByTagName("*"); | |
| for (var i = 0, max = all.length; i < max; i++) { | |
| $(all[i]).css("color", getRandomColor()); | |
| $(all[i]).css("background-color", getRandomColor()); | |
| } | |
| } | |
| function getRandomColor() { |
liblinear-ruby: Ruby interface to LIBLINEAR using SWIG
classifier-reborn: Bayesian and LSI classification
dependencies: GSL
| brew install apple-gcc42 openssl libyaml libffi | |
| xcode-select --install | |
| export CC=/usr/local/bin/gcc-4.2 | |
| export CFLAGS='-g -O2' | |
| export RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` | |
| export CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` | |
| rbenv install 1.8.7-p375 |
| array_and = (ary1, ary2) -> | |
| result = [] | |
| seen = {} | |
| i = 0 | |
| length = ary1.length | |
| while i < length | |
| item = ary1[i] | |
| unless seen[item] | |
| j = 0 | |
| length2 = ary2.length |
| What's new in Ruby on Rails 4 | |
| A RoR 4 press review | |
| Silvio Relli @ Florence On Ruby | |
| Bibliography and related resources | |
| 1) Rails queue | |
| http://reefpoints.dockyard.com/ruby/2012/06/25/rails-4-sneak-peek-queueing.html | |
| http://blog.remarkablelabs.com/2012/12/rails-queue-rails-4-countdown-to-2013 | |
| https://github.com/rails/rails/commit/adff4a706a5d7ad18ef05303461e1a0d848bd662 |
| # Inside User Observer | |
| def after_touch(user) | |
| user.run_callbacks :save | |
| end |