Skip to content

Instantly share code, notes, and snippets.

View htsutsui's full-sized avatar

Hiroshi Tsutsui htsutsui

View GitHub Profile
@htsutsui
htsutsui / students.js
Created July 22, 2023 11:17
北大工学系ユグドラシル 大学院生指導教員入力の表から学生番号等を抜き出す
// https://yggdrasil.eng.hokudai.ac.jp/info_student/edu/
$("tr").map(function(){
if($(this).children().slice(3, 4).text().match("大鐘")){
return $(this).children().slice(0, 4).map(function(){
return $(this).text();
}).toArray().join(" ").replaceAll(" ", " ");
}
}).toArray().join("\n");
#!/usr/bin/env ruby
# frozen_string_literal: true
# Usage: pdfinfo input.pdf | ./pts2mm.rb
# This script converts "595.276 x 841.89 pts" to "210.00 x 297.00".
# 72pt = 1inch = 25.4 mm
print STDIN.read.scan(/(\S+) x (\S+)/).map { _1.map(&:to_f).map { |j| '%.2f' % (j / 72 * 25.4) }.join(' x ') + "\n" }.join
@htsutsui
htsutsui / amazon-orders.js
Created August 6, 2022 10:37
Get URLs and item names from the amazon order history page https://www.amazon.co.jp/gp/css/order-history .
/* -*- js-indent-level: 2 -*- */
(function (e, s) {
const re = /(?:.*?\/){0,1}(?:dp|gp\/product)\/([0-9A-Z]{10})/
e.src = s
e.onload = function () {
jQuery(document).ready(function ($) {
console.log(($.map($('a.a-link-normal'),
function (el) {
const line = el.attributes.href.textContent
const m = line.match(re)
@htsutsui
htsutsui / hu-student-list-parser.rb
Last active July 22, 2022 12:58
ELMS Moodle の参加者リストや『北海道大学 シラバス・成績入力システム』の履修者リストをいろいろするメモがてらRuby script.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'csv'
# Parse student lists from
# - ELMS Moodle and
# - "HOKKAIDO Univ. Entry System of Syllabi and Academic Records"
# and compare them. The script checks only names and student IDs.
#
@htsutsui
htsutsui / amazon.html
Last active August 6, 2022 08:58
amazon の URL から無駄な文字列を除去する
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Amazon URL Shortner</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(function () {
const re = /(https:\/\/www\.amazon\.co\.jp\/)(?:.*?\/){0,1}(?:dp|gp\/product)\/([0-9A-Z]{10})/