Skip to content

Instantly share code, notes, and snippets.

# First configure your models to use Amazon s3 as storage option and setup the associated S3 config.
# Then add the classes your want to migrate in the klasses array below.
# Then run rake paperclip_migration:migrate_to_s3
# Should work but this is untested and may need some tweaking - but it did the job for me.
namespace :paperclip_migration do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
klasses = [:product] # Replace with your real model names. If anyone wants to this could be picked up from args or from configuration.
klasses.each do |klass_key|
@tompesman
tompesman / indexer.rb
Created October 10, 2014 12:45
Sidekiq worker for Elasticsearch with connection pool
module Search
class Indexer
include Sidekiq::Worker
sidekiq_options queue: :low, retry: false, backtrace: true
LOGGER = Sidekiq.logger.level == Logger::DEBUG ? Sidekiq.logger : nil
SEARCH_POOL = ConnectionPool.new(size: SEARCH_UPDATE_POOL, timeout: 5) do
Elasticsearch::Client.new host: ELASTICSEARCH_URL, logger: LOGGER
end
@tompesman
tompesman / snippet.php
Created November 4, 2014 09:42
Omega Ghost Swatch fix
<?php
$options = get_option( THEME_SHORT . '-swatch-list' );
var_dump($options);
unset($options[""]);
update_option( THEME_SHORT . '-swatch-list', $options);
var_dump(get_option( THEME_SHORT . '-swatch-list' ));
$options = get_option( THEME_SHORT . '-swatch-files' );
var_dump($options);
unset($options[""]);
@tompesman
tompesman / circle.yml
Created March 14, 2017 09:36
CicleCI config for Elixir with Phoenix Framework and deployment to Heroku
machine:
node:
version: 6.2.0
environment:
PATH: "$HOME/.asdf/bin:$HOME/.asdf/shims:$PATH"
MIX_ENV: "test"
services:
- postgresql
database:
@tompesman
tompesman / lib-pushr-stats_processor.rb
Created September 15, 2017 13:40
Stats processor file for Pushr
require 'librato/metrics'
require_relative 'metrics'
module Pushr
class StatsProcessor
# name, start, finish, id, payload
def call(_, start, finish, _, payload)
messagetype = payload[:type]['Pushr::Message'.size, payload[:type].size].downcase
hsh = { measure_time: Time.now, value: ((finish - start) * 1000) }
Pushr::Metrics.queue.add "#{payload[:app]}:message:#{messagetype}:time" => hsh
FUNCTION CALLS % TIME [uS / CALLS]
-------- ----- ------- ---- [----------]
gen:start/5 2 0.00 0 [ 0.00]
gen:init_it/6 2 0.00 0 [ 0.00]
application:get_all_env/1 1 0.00 0 [ 0.00]
sys_core_bsm:bsm_do_an/4 1 0.00 0 [ 0.00]
sys_core_bsm:bsm_do_an_var/4 1 0.00 0 [ 0.00]
otp_internal:obsolete_type_1/3 2 0.00 0 [ 0.00]
erl_internal:is_type/2