Skip to content

Instantly share code, notes, and snippets.

View markets's full-sized avatar
🚀
Shipping things

Marc Anguera markets

🚀
Shipping things
View GitHub Profile
@markets
markets / unicode_irb_rvm
Created December 17, 2012 18:03
Avoid corrupt unicode input in IRB with rvm and ruby 1.9.3
$ rvm get latest
$ rvm pkg install readline
$ rvm reinstall 1.9.3-p327 --with-readline-dir=$rvm_path/usr
@markets
markets / chat_publisher.rb
Last active December 19, 2015 14:09
Ruby methods to publish content into some chat systems. No API clients or gems required, just curl.
# Publish messages to Hipchat https://www.hipchat.com
def publish_to_hipchat(room_id, msg, from, format, color, auth_token)
`curl -X POST -d "room_id=#{room_id}&message=#{msg}&from=#{from}&message_format=#{format}&color=#{color}" \
"https://api.hipchat.com/v1/rooms/message?auth_token=#{auth_token}"`
end
# Publish messages to Talker http://talkerapp.com
def publish_to_talker(room_id, msg, auth_token)
`curl -H 'Accept: application/json' -H 'Content-Type: application/json' \
-H 'X-Talker-Token: "#{auth_token}"' \
@markets
markets / migrate_s3.rake
Created November 12, 2015 15:09
Migrate Paperclip assets from filesystem to AWS S3
namespace :attachments do
task migrate_to_s3: :environment do
require 'aws-sdk'
# Define Paperclip models
models = [
[Attachment, :data],
[Image, :data],
[MediaAppearance, :media_logo],
[Testimonial, :avatar_logo]
@markets
markets / mini_i18n_benchmark.rb
Created August 31, 2018 17:46
MiniI18n gem benchmarking
require 'benchmark/ips'
require 'mini_i18n'
require 'i18n'
translations_path = File.expand_path('./spec/fixtures/locales/*')
# Init MiniI18n
MiniI18n.load_translations(translations_path)
# Init I18n
@markets
markets / tonic_random_collection.rb
Last active October 24, 2022 19:44
Creates random collections for https://github.com/Subgin/tonic
require "yaml"
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "faker"
end
items = []
categories = 10.times.map { Faker::Company.industry }