Implement and Test in One File with bundler/inline and rspec/autorun

Sometimes I want to create a tiny one-off script that intended to run on a sandbox environment like a Docker container and needs only one file. Most of the time, I also need test frameworks to do some refactoring. It can be done with bundler/inline and rspec/autorun. require 'bundler/inline' gemfile do source '' gem 'rspec' end def doit 'return a string' end require 'rspec/autorun' RSpec.describe '#doit' do example do expect(doit).to be_a(String) end end Usually, Bundler reads the dependencies from Gemfile.

Read more →

Variables with Shell-Style Default in docker-compose.yml

Today I learned that in docker-compose.yml, a variable interpolation with a default can be expressed as ${VAR1:-default value} like shell-style parameter expansion. With parameter expansion, you can do more than setting a default value such as modifying the parameter. However, the supported features in docker-compose.yml are limited to two of them: to set a default variable or to make the parameter mandatory. Let's define VAR_ALPHA with a default value for the example service.

Read more →

Kind: Kubernetes in Docker

While I was playing with act the other day, I found a tool called kind (Kubernetes in Docker) in that repository. With kind, Kubernetes clusters can easily be created in a Docker container. According to the official document, being an alternative to Docker Compose out of scope for kind. That said, the home page also suggests kind may be used for “local development”. kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI.

Read more →

What is MySQL's Online DDL

Today I learned a MySQL term: online DDL. The online DDL lets you alter tables efficiently, without making tables unavailable during the entire operation and exclusive table locks. The behavior of a DDL operation can be specified using the ALGORITHM and LOCK clauses. You don't have to get overwhelmed by the mysterious terms. Actually, you may have used it before without knowing because MySQL will try to use it by default when you execute ordinary alter table statements.

Read more →

change_table with Bulk Option Combines Multiple alter-table Statements

Today I learned that when doing database-migration on Rails, change_table :#{table_name}, bulk: true let us combine multiple alter-table statements and it could reduce the cost of the whole alteration. That is, instead of executing multiple alter-table separately, def change add_column :users, :first_name, :string, null: false add_column :users, :last_name, :string, null: false end we can run a single alter-table statement by change_table like as follows. def change change_table :users, bulk: true do |t| t.

Read more →

Gentaro "hibariya" Terada

Otaka-no-mori, Chiba, Japan
Email me

Loves Ruby, Internet, and Programming.