- curl
- jq
This script requires NICKNAME environment variable.
Before run this script, define it like export NICKNAME=satoryu on bash.
| N = 30 | |
| BOARDS = (N * N).times.map { |n| [n / N, n % N] } | |
| NEIGHBORS = BOARDS.map { |(i, j)| [ [i, j], ((-1..1).to_a.product((-1..1).to_a).map { |(x, y)| [(i + x) % N, (j + y) % N] } - [[i, j]]).to_set ] }.to_h | |
| def print_cells(cells) | |
| BOARDS | |
| .each_slice(N) | |
| .map { |row| row.map { |cell| cells.include?(cell) ? '0' : '.' }.join } | |
| .join("\n") |
| { | |
| "alarms": [ | |
| { | |
| "hours": 16, | |
| "minutes": 11, | |
| "message": "残りあと1時間" | |
| }, | |
| { | |
| "hours": 16, | |
| "minutes": 32, |
| # frozen_string_literal: true | |
| # set_trace_func lambda { |event, file, line, id, binding, klass| | |
| # if binding.receiver.to_s == 'main' | |
| # puts "#{file}:#{line}: #{event} #{id} #{binding.receiver} [#{binding.local_variables.map(&:to_s).join(',')}]" | |
| # end | |
| # } | |
| # trace = TracePoint.new(:call, :c_call) do |tp| | |
| # puts "#{tp.lineno}: #{tp.binding.receiver}##{tp.method_id}" |
| puts (b = 'ボジョレーヌーボー'.split(//)).permutation(b.length).uniq.map(&:join).reject { |s| s =~ /ー+{2,}/ || s =~ /\A[ーョ]/ }.select { |s| s.include? 'ジョ' } |
| require 'matrix' | |
| require 'tf-idf-similarity' | |
| class Token | |
| def initialize(mecab_node) | |
| @node = mecab_node | |
| end | |
| def valid? | |
| @node.feature.start_with?('名詞') |
| require 'matrix' | |
| require 'tf-idf-similarity' | |
| class Token | |
| def initialize(mecab_node) | |
| @node = mecab_node | |
| end | |
| def valid? | |
| @node.feature.start_with?('名詞') |
| module Hoge | |
| class ArrayBase | |
| class << self | |
| attr_accessor :type | |
| end | |
| def type | |
| self.class.type | |
| end |
| def hash_from(obj, keys, options={}) | |
| keys.inject({}) do |h, key| | |
| v = obj.send(key) | |
| h[key] = v unless options[:ignore_nil] && v.nil? | |
| h | |
| end | |
| end | |
| klass = Struct.new(:a, :b, :c) |