| # Basic key operators to query the JSON objects : | |
| # #> : Get the JSON object at that path (if you need to do something fancy) | |
| # -> : Get the JSON object at that path (if you don't) | |
| # ->> : Get the JSON object at that path as text | |
| # {obj, n} : Get the nth item in that object | |
| # https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE | |
| # Date | |
| # date before today |
| SELECT | |
| schema_name, rel_name, table_size, | |
| pg_size_pretty(table_size) AS size | |
| FROM ( | |
| SELECT | |
| nspname AS schema_name, | |
| relname AS rel_name, | |
| pg_table_size(pg_class.oid) AS table_size | |
| FROM pg_class, pg_namespace | |
| WHERE pg_class.relnamespace = pg_namespace.oid |
My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.
As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.
I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.
So, in order to profile your worker, add this to your Sidekiq configuration:
if ENV["PROFILE"]| The following is a list of places where you can find job offers as a Rails developer: | |
| https://twitter.com/currofile | |
| https://twitter.com/domestikaempleo #spain only | |
| http://www.workingwithrails.com/ | |
| https://weworkremotely.com/jobs/search?term=rails | |
| https://jobs.github.com/ | |
| http://trabajosrails.com/ # spain only | |
| http://www.indeed.com/q-Ruby-On-Rails-Developer-jobs.html |
| #!/bin/bash | |
| echo "Creating tags" | |
| for tag in `git branch -r | grep "tags/" | egrep -vw "svn/tags/(integration|production)" | sed 's/ tags\///'`; do | |
| git_tag_name=`echo "$tag" | sed 's/tags\///'` | |
| parents=`git show --format="%P" refs/remotes/$tag` | |
| real_parent=`echo "$parents" | cut -d' ' -f 2` | |
| git tag -a -m"Converting SVN tags" $git_tag_name $real_parent | |
| done |
NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
| # this forces dpkg not to call sync() after package extraction and speeds up install | |
| RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup | |
| # we don't need and apt cache in a container | |
| RUN echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache |
| source 'https://rubygems.org' | |
| # Follows the bundler group pattern described here: | |
| # http://iain.nl/getting-the-most-out-of-bundler-groups | |
| # Gemfile.mine in root dir allows locally custom gems. | |
| # NOTE: Doing this will change the Gemfile.lock - commit with care. | |
| eval File.read(File.join(File.dirname(__FILE__), 'Gemfile.mine')) if File.exists? File.join(File.dirname(__FILE__), 'Gemfile.mine') | |
| ruby '1.9.3' |
| module CacheHelper | |
| extend ActiveSupport::Concern | |
| included do | |
| extend Cacher | |
| include Cacher | |
| cattr_accessor :updated_column_name | |
| self.updated_column_name ||= :change_time | |
| cattr_accessor :file_location | |
| cattr_accessor :file_digest |