Skip to content

Instantly share code, notes, and snippets.

@miyagawa
miyagawa / so-net-xmltv.rb
Created October 29, 2019 06:41
so-net XMLTV exporter
#!/usr/bin/env ruby
# coding: utf-8
require 'date'
require 'open-uri'
require 'nokogiri'
class Station
attr_accessor :id, :name, :channel
def xmltv_id
@miyagawa
miyagawa / google-speech2text.rb
Created February 22, 2019 08:06
preprocess google speech-to-text wordoffsets
#!/usr/bin/env ruby
# coding: utf-8
require 'json'
table = {
"じかん" => "時間",
"じ" => "時",
"ぱーせんと" => "%",
"えん" => "円",
"どる" => "ドル",
namespace :speech do
desc "Merge WAV files and encode to FLAC"
task :encode do |t|
wav = "podcast-ep#{ENV['EP']}.wav"
flac = "podcast-ep#{ENV['EP']}.flac"
channels = []
wavs = Dir["#{ENV['HOME']}/Music/GarageBand/Podcast ep#{ENV['EP']}-*.wav"]
wavs.each_with_index do |w, i|
mono = "podcast-ep#{ENV['EP']}-ch#{i+1}.wav"
@miyagawa
miyagawa / utcify.pl
Last active January 18, 2019 00:19
Convert local timestamps in text to UTC
#!/usr/bin/env perl
use strict;
use DateTime;
use Date::Parse qw(str2time);
my $pattern = qr/\d?\d:\d\d(:\d\d)?(?: ?[aApP][mM])?/;
while (<>) {
s/$pattern/utc(str2time($&), $1)/eg;
print;
@miyagawa
miyagawa / curl.rb
Created August 30, 2018 01:54
curl --resolve with typhoeus
require 'typhoeus'
require 'ethon'
resolve = Ethon::Curl.slist_append(nil, "example.com:443:1.2.3.X")
r = Typhoeus::Request.new(
"https://example.com",
resolve: resolve,
# verbose: true,
)
@miyagawa
miyagawa / README.md
Last active May 12, 2018 15:30
Rebuild チャプター

Rebuild のチャプターは ep181 以降からつけているため、ep180 以前のものにはついていません。膨大な数になり、手作業でつけることになるため、ボランティアでご協力していただける方を募集しています。

Show Notes と比較しながら早回し、スキップしてすすめると、1エピソードあたり5-20分程度の作業になります。Show Notes にあるリンクは非常に粒度が細かくなってしまうので、大きなトピックでまとめて1つのタグぐらいで構いません。

以下のフォーマットで .txt ファイルを作成し、

00:00 Intro
01:23 トピック1
32:44 トピック2
Delete Files
Files in directory authors/id/M/MI/MIYAGAWA
DeleteUndelete
Acme-DateTime-Duration-Numeric-0.01.meta 347 Tue, 15 Jan 2008 10:34:05 GMT
Acme-DateTime-Duration-Numeric-0.01.readme 618 Tue, 15 Jan 2008 10:33:36 GMT
Acme-DateTime-Duration-Numeric-0.01.tar.gz 33537 Tue, 15 Jan 2008 23:18:05 GMT
Acme-DateTime-Duration-Numeric-0.02.meta 385 Wed, 16 Jan 2008 01:16:27 GMT
Acme-DateTime-Duration-Numeric-0.02.readme 618 Tue, 15 Jan 2008 10:33:36 GMT
PERL_CPANM_OPT= cpanm --mirror-only --mirror file://$PWD/xt/mirror HTTP::Tinyish --info -v
cpanm (App::cpanminus) 1.7102 on perl 5.020001 built for darwin-2level
Work directory is /Users/miyagawa/.cpanm/work/1464108652.13740
You have make /usr/bin/make
You have LWP 6.15
You have /usr/bin/tar: bsdtar 2.8.3 - libarchive 2.8.3
You have /usr/bin/unzip
Searching HTTP::Tinyish on mirror file:///Users/miyagawa/dev/cpanminus/xt/mirror ...
Downloading index file file:///Users/miyagawa/dev/cpanminus/xt/mirror/modules/02packages.details.txt.gz ...
Uncompressing index file...
/var/folders/g2/fzfdvxhx5bvdq5y99syc4_fh0000gn/T/ruby-build.20151217020923.4369 ~/.rbenv/plugins/ruby-build
/var/folders/g2/fzfdvxhx5bvdq5y99syc4_fh0000gn/T/ruby-build.20151217020923.4369/ruby-2.2.4 /var/folders/g2/fzfdvxhx5bvdq5y99syc4_fh0000gn/T/ruby-build.20151217020923.4369 ~/.rbenv/plugins/ruby-build
config.guess already exists
config.sub already exists
checking build system type... x86_64-apple-darwin14.5.0
checking host system type... x86_64-apple-darwin14.5.0
checking target system type... x86_64-apple-darwin14.5.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
@miyagawa
miyagawa / sale.md
Last active January 25, 2021 07:49