Skip to content

Instantly share code, notes, and snippets.

@lettas
lettas / weekly-shonen-jump-plus-kb-shortcuts.js
Created December 13, 2021 08:37
ジャンプ+で週刊少年ジャンプを読んでるときに便利なショートカットキーを提供する([↓]次の連載 [↑]前の連載 [N]次の号 [P]前の号)
// ==UserScript==
// @name Weekly Shonen Jump Keyboard Shortcuts for Jump plus
// @namespace https://shonenjumpplus.com/
// @version 0.1
// @description ジャンプ+で週刊少年ジャンプを読んでるときに便利なショートカットキーを提供する([↓]次の連載 [↑]前の連載 [N]次の号 [P]前の号)
// @author me
// @match https://shonenjumpplus.com/magazine/*
// @grant none
// @run-at document-idle
// @require https://code.jquery.com/jquery-3.6.0.slim.min.js
@startuml
Alice -> Bob : Hello
Alice <- Bob : Ignore
@enduml
@lettas
lettas / cars.rb
Created April 30, 2015 07:15
TripleTriadのカードを全パターン生成しちゃう
#!/usr/bin/env ruby
[
{level:1, pmin:10, pmax:13, nmin:1, nmax:6},
{level:2, pmin:12, pmax:15, nmin:1, nmax:7},
{level:3, pmin:15, pmax:18, nmin:1, nmax:7},
{level:4, pmin:18, pmax:20, nmin:1, nmax:7},
{level:5, pmin:20, pmax:22, nmin:1, nmax:7},
{level:6, pmin:20, pmax:23, nmin:1, nmax:8},
{level:7, pmin:23, pmax:25, nmin:1, nmax:8},
@lettas
lettas / seeds.rb
Last active December 3, 2018 07:32
Railsでマスターデータの管理にCSVを使うときのseeds.rb
require 'csv'
Dir.glob('db/seeds/*.csv') do |file|
puts file
table_name = file.gsub(/^.*\/([\w\d_]+)\.csv/, '\1')
model_class = Module.const_get(table_name.classify)
models = CSV.read(file, headers: true).collect{|r| model_class.new(r.to_hash)}
update_columns = model_class.accessible_attributes.to_a.reject{|s| s.empty?}
model_class.record_timestamps = false if %w(created_at, updated_at).any?{|t| update_columns.include?(t)}