Skip to content

Instantly share code, notes, and snippets.

@ikoba
ikoba / execute_external_command.rb
Last active July 19, 2023 08:05
Execute external command and output STDOUT, STDERR in real time.
require 'open3'
Open3.popen3('seq 100000') do |stdin, stdout, stderr, wait_thr|
stdin.close_write
loop do
IO.select([stdout, stderr]).flatten.compact.each do |io|
io.each do |line|
next if line.nil? || line.empty?
puts line
@ikoba
ikoba / dummy
Last active May 2, 2023 15:13
Generate a dummy video or an image on macOS
#!/usr/bin/env bash
#
# Generate a dummy video or an image.
#
# The caption text and size (width x height) are drawn on the video or image.
# The countdown timer is drawn in the upper right corner of the video.
#
# This script is intended to be run on macOS.
# And it depends on the following packages.
# - imagemagick
@ikoba
ikoba / gitgrep.rb
Last active December 19, 2022 10:14
'git grep' with functionalities to output GitHub permalinks and authors
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'cgi'
require 'csv'
require 'optparse'
SUPPORTED_GIT_GREP_OPTIONS = <<~MSG
-i --ignore-case
-I