Skip to content

Instantly share code, notes, and snippets.

View rails_assets_connection_refused.md

The Problem

bundle install
> Fetching source index from https://rails-assets.org/
> 
> Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rails-assets.org/
> Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rails-assets.org/
> Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rails-assets.org/
> Could not fetch specs from https://rails-assets.org/
@yevgenko
yevgenko / flatfile_io_json2csv.rb
Last active Jul 16, 2019
Convert flatfile.io output (key-value map) to CSV string.
View flatfile_io_json2csv.rb
require 'csv'
require 'json'
def flatfile_io_json2csv_string(data_as_string = '[{"sku_code": "123"}, {"sku_code": "321"}]')
CSV.generate do |csv|
json_data = JSON.parse(data_as_string)
csv << json_data.first.keys # header
json_data.each do |hash|
csv << hash.values
@yevgenko
yevgenko / single_message_listener.rb
Created May 1, 2019
GOOS: auction snipper, single message listener
View single_message_listener.rb
#
# https://github.com/yevgenko/ruby-auction_sniper/blob/master/spec/fake_auction_server.rb
#
# https://www.safaribooksonline.com/library/view/growing-object-oriented-software/9780321574442/ch11.html
#
class SingleMessageListener
include RSpec::Matchers
def initialize
@messages = SizedQueue.new(1)
@yevgenko
yevgenko / self_shunt_spec.rb
Created Mar 5, 2019
Self Shunt vs Fake Object in Ruby / RSpec
View self_shunt_spec.rb
module Fubarizable
def fubarize
"foobar-#{fubarizable}-foobar"
end
end
class FakeFoobar
include Fubarizable
def fubarizable
View docker-elastic.sh
#!/bin/sh
docker run -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/elasticsearch:5.4.1
View designing_end_to_end_test.txt
title Designing End To End Test
Test->ApplicationRunner: perform_foobar_for(order)
ApplicationRunner->OrderPage: perform_action(Order::ACTION_FOOBAR)
OrderPage->CapybaraPage: visit('/orders/order.id')
OrderPage->CapybaraPage: click(text)
Test->ApplicationRunner: has_shown_foobar_status_for(order)
ApplicationRunner->OrderPage: shows_status(Order::STATUS_FOOBAR)
OrderPage->CapybaraPage: visit('/orders/order.id')
OrderPage->CapybaraPage: assert_text(text)
View foobar.rb
def greeting
puts 'hello, world!'
end
@yevgenko
yevgenko / big_money_spec.rb
Last active Apr 3, 2018
Forcing monetization to produce money in specific currency only
View big_money_spec.rb
require 'money'
class BigMoney
class << self
attr_accessor :current_currency
def force_currency(currency_code)
self.current_currency = Money::Currency.new(currency_code)
yield
self.current_currency = nil
View active_record_spec_helper.rb
require 'active_record'
require 'database_cleaner'
require 'yaml'
connection_info = YAML.load(ERB.new(File.read("config/database.yml")).result)["test"]
ActiveRecord::Base.establish_connection(connection_info)
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
View bulk_avconvert.py
##
# Converts MTS files into m4v in a bulk
# with avconvert tool
#
# Usage:
# create directories ./in and ./out
# put files into in directory
# run the command:
# python bulk_convert.py
##
You can’t perform that action at this time.