This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 任意の自然数maxまでの自然数についてコラッツ予想が正しいかを確かめるプログラム | |
# 収束しない値(予想に反する値)が現れた場合はスタックオーバーフローでエラーになる。(とはいえスタックが足りないだけでいつか収束するのかもしれない。) | |
# コラッツ予想とは | |
# 「どんな正の整数も、偶数なら2で割り、奇数なら3倍して1を足す。この操作を繰り返せば、必ず最後は1になるだろう」 | |
# see: https://digital.asahi.com/articles/ASP937HM6P8ZULBJ00T.html | |
require 'tempfile' | |
def collatz(n) | |
$tempio.print n | |
if (n % 2) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 例:https://www.smfemdom.net/gr-143-%e3%80%90%ef%bc%a6%ef%bc%ad%e3%80%91%e3%81%82%e3%82%84%e3%81%ad%e9%81%a5%e8%8f%9c%e3%81%ab%e3%81%8f%e3%81%99%e3%81%90%e3%82%89%e3%82%8c%e3%83%aa%e3%82%af%e3%82%a8%e3%82%b9%e3%83%88/ | |
document.querySelectorAll('p').forEach( | |
function(e){ | |
if (e.innerText.indexOf("subyshare:") >= 0 ){ | |
console.log(e.querySelector('a').getAttribute('href')); | |
} | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by https://anond.hatelabo.jp/20210604154733 | |
CHAR_BOX=%w|ワ ク チ ン| | |
TARGET_STR="ワクワクチンチン" | |
current_str_a = [] | |
current_str = "" | |
while true do | |
current_str_a.shift if current_str_a.size >= TARGET_STR.size | |
c = CHAR_BOX.sample | |
current_str_a << c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.box = "bento/ubuntu-18.04" | |
config.vm.network "private_network", ip: "192.168.33.10" | |
config.vm.provision "shell", inline: <<-SHELL | |
apt-get install ruby -y | |
gem install bundler | |
curl -fsSL https://get.docker.com -o get-docker.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.box = "bento/ubuntu-18.04" | |
config.vm.network "private_network", ip: "192.168.33.10" | |
config.vm.provision "shell", inline: <<-SHELL | |
curl -fsSL https://get.docker.com -o get-docker.sh | |
sh get-docker.sh | |
usermod -aG docker vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Semaphore(max) { | |
var counter = 0; | |
var waiting = []; | |
var take = function() { | |
if (waiting.length > 0 && counter < max){ | |
counter++; | |
let promise = waiting.shift(); | |
promise.resolve(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Semaphore(max) { | |
// 排他制御のためのセマフォ | |
// https://gist.github.com/Gericop/e33be1f201cf242197d9c4d0a1fa7335 | |
var counter = 0; | |
var waiting = []; | |
var take = function() { | |
if (waiting.length > 0 && counter < max){ | |
counter++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'psych' # to_yamlを使うため | |
def table_name(line) | |
line.scan(/create_table :(.+), comment: \"(.+)"/) | |
$LOCALE["ja"]["activerecord"]["models"][$1] = $2 | |
$LOCALE["ja"]["activerecord"]["attributes"][$1] = {} | |
$1 | |
end | |
def column_name(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dir.glob("./*.csv") do |f| | |
p f | |
`mv #{f} #{f}.bak` | |
`nkf -W -s #{f}.bak > #{f}` | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tempfile' | |
require 'fileutils' | |
tables = %w| | |
table1 | |
table2 | |
table3 | |
table4 | |
table5 | |
table6 |
NewerOlder