AWS query-instance_method docs
export AWS_ACCESS_KEY_ID=‘XXXX’
export AWS_SECRET_ACCESS_KEY=‘XXXX’
# ENV['AWS_ACCESS_KEY_ID']
# ENV['AWS_SECRET_ACCESS_KEY']
module ApplicationHelper | |
def event_autolink(event_parts) | |
event_parts.map do |part| | |
case part.content | |
when Hash | |
link_to part.content['name'], send("admin_#{part.content['class_name'].underscore}_path", part.content['id']) | |
else | |
part.content | |
end |
# If we save a record using ember-data's RESTadapter, and it fails, Rails | |
# returns the validation errors of the model as JSON hash: | |
# | |
# {"errors":{"name":["may not be blank"]}} | |
# | |
# This patches the RESTadapter to add these errors to the invalid record. It | |
# can be removed when the following Pull Request was merged into ember-data: | |
# https://github.com/emberjs/data/pull/376 | |
DS.RESTAdapter.reopen |
# -*- coding: utf-8 -*- | |
$:.unshift("/Library/RubyMotion/lib") | |
require 'motion/project/template/ios' | |
require 'rubygems' | |
require 'bundler' | |
Bundler.require | |
require 'sugarcube-repl' | |
Motion::Project::App.setup do |app| |
#!/bin/sh | |
# http://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommited-changes | |
require_clean_work_tree () { | |
# Update the index | |
git update-index -q --ignore-submodules --refresh | |
err=0 | |
# Disallow unstaged changes in the working tree | |
if ! git diff-files --quiet --ignore-submodules --; then |
AWS query-instance_method docs
export AWS_ACCESS_KEY_ID=‘XXXX’
export AWS_SECRET_ACCESS_KEY=‘XXXX’
# ENV['AWS_ACCESS_KEY_ID']
# ENV['AWS_SECRET_ACCESS_KEY']
require 'resque/tasks' | |
namespace :resque do | |
def del(key) | |
Resque.redis.keys(key).each { |k| Resque.redis.del(k) } | |
end | |
desc "Resque setup according to installation guide" | |
task :setup => :environment |
require "aws-sdk" | |
class Dynamo | |
attr_accessor :attributes | |
def initialize(hash) | |
raise ArgumentError, "argument passed to .new must be a Hash" unless hash.is_a? Hash | |
raise ArgumentError, "hash must contain key :#{self.class.hash_key}" unless hash.has_key? self.class.hash_key.to_sym | |
raise ArgumentError, "hash must contain key :#{self.class.range_key}" unless self.class.has_range_key? && hash.has_key?(self.class.range_key.to_sym) | |
@attributes = {} |
## Get FFMpeg working on heroku by building binaries using vulcan | |
gem install vulcan | |
vulcan create foo | |
git clone --depth 1 git://source.ffmpeg.org/ffmpeg | |
cd ffmpeg |
class Api::RegistrationsController < Api::BaseController | |
respond_to :json | |
def create | |
user = User.new(params[:user]) | |
if user.save | |
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
return | |
else |
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"]