Skip to content

Instantly share code, notes, and snippets.

@kemsakurai
kemsakurai / get_one_person_from_participants.js
Last active January 14, 2024 11:19 — forked from willnet/sample_from_atendees.js
google meet参加者から誰か一人をランダムで選択するスクリプト|参加者をランダムにシャッフルするスクリプト
(function() {
let facilitator;
if (document.querySelector("[aria-label='参加者']")) {
const names_array = document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((word) => !word.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))
const names_set = new Set(names_array)
const names_uniq_array = Array.from(names_set)
facilitator = names_uniq_array[Math.floor(Math.random() * names_uniq_array.length)]
}
if (!facilitator) {
// chromeを利用して、ユーザ一覧を表示しつつconsoleで↓を実行すると、現在の参加者からランダムで一人表示することができます
@kemsakurai
kemsakurai / ExportKindle.js
Last active March 9, 2024 06:17 — forked from usayamadx/ExportKindle.js
Amazon Kindle Export Cloud Readerから、kindleの書籍一覧をTSV形式で取得して、クリップボードへコピーする。Chrome dev tools の console で実行する
// init
let xhr = new XMLHttpRequest()
let domain = 'https://read.amazon.co.jp/'
let items = []
let tsvData = ""
// function
function getItemsList(paginationToken = null) {
// https://read.amazon.co.jp/kindle-library/search?query=&libraryType=BOOKS&paginationToken=19&sortType=recency&querySize=50
let url = domain + 'kindle-library/search?query=&libraryType=BOOKS' + ( paginationToken ? '&paginationToken=' + paginationToken : '' ) + '&sortType=recency&querySize=50'
@kemsakurai
kemsakurai / ConvertTSVToRedmineTicketDescription.user.js
Last active January 5, 2022 16:33
Spreadsheet のセルの値(TSV)を、Redmineのチケットのdescription欄の記載内容っぽくクリップボードに貼り付けるユーザースクリプト
// ==UserScript==
// @name TSV to Redmine Ticket description
// @namespace         http://tampermonkey.net/
// @version 0.1
// @author K.Sakurai
// @resource   CSS1 https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css
// @require https://cdn.jsdelivr.net/npm/toastify-js
// @match http*://*/*
// @run-at context-menu
// @grant GM_addStyle
@kemsakurai
kemsakurai / Convert-spreadsheet-value-to-markdown-table.bookmarklet.js
Last active January 1, 2022 09:24
スプレッドシート の表形式のデータをmarkdwonに変換するTampermonkey のUserScript
javascript: (function(e)%7Bvar t%3D%7Beval:%27"!function()%7Bvar n%3Dwindow.prompt(%5C%5C"SpreadSheet の値を markdownのtableに変換%5C%5C")%3Bnull!%3Dn%26%26%5C%5C"%5C%5C"!%3Dn%26%26(!function(n)%7Bvar e%3Ddocument.createElement(%5C%5C"div%5C%5C")%3Be.appendChild(document.createElement(%5C%5C"pre%5C%5C")).textContent%3Dn%3Bvar t%3De.style%3Bt.position%3D%5C%5C"fixed%5C%5C",t.left%3D%5C%5C"-100%25%5C%5C",document.body.appendChild(e),document.getSelection().selectAllChildren(e),document.execCommand(%5C%5C"copy%5C%5C"),document.body.removeChild(e)%7D(function(n)%7Bvar e%3Dn.split(/%5B%5C%5C%5C%5Cn%5C%5C%5C%5Cu0085%5C%5C%5C%5Cu2028%5C%5C%5C%5Cu2029%5D%7C%5C%5C%5C%5Cr%5C%5C%5C%5Cn%3F/g).map((function(n)%7Breturn console.log(n),n.split(%5C%5C"%5C%5C%5C%5Ct%5C%5C")%7D)),t%3De%5B0%5D.map((function(n,t)%7Breturn function(n,e)%7Breturn Math.max.apply(null,n.map((function(n)%7Breturn n%5Be%5D.length%7D)))%7D(e,t)%7D))%3Bconsole.log(t)%3Bvar o%3De.map((function(n,e)%7Breturn%5C%5C"%7C %5C%5C"%2Bn.map((function(n,e)%7Breturn n%2B
@kemsakurai
kemsakurai / copy-page-link-for-chatwork.user.js
Created October 18, 2020 11:28
WebページをChatworkへ共有する形式でコピーする Tamplermonkeyの UserScript
@kemsakurai
kemsakurai / Copy-Chatwork-room-members.user.js
Created October 17, 2020 14:07
Chatwork のルームのメンバーの一覧を取得する Tampermonkeyスクリプト
// ==UserScript==
// @name Copy Chatwork room members
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Chatwork のルームメンバーをクリックボードにコピーする
// @author K.Sakurai
// @match https://www.chatwork.com/*
// @run-at context-menu
// ==/UserScript==
(function() {
@kemsakurai
kemsakurai / my.safari.user.js
Created October 16, 2020 13:32
ブラウザSafari で使っているTampermonkey スクリプト
// ==UserScript==
// @name My BookMarklet
// @namespace http://tampermonkey.net/
// @version 0.1
// @description BookMarklet
// @author mutter.monotalk
// @match *://*/*
// ==/UserScript==
(function() {
'use strict';
@kemsakurai
kemsakurai / LICENSE.txt
Last active October 18, 2020 02:22
Redmineの入力補助をする Tåmpermonkeyスクリプト https://github.com/kemsakurai/redmine-tampermonkey-userscript の元ソース
MIT License
Copyright (c) 2020 Ken Sakurai. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@kemsakurai
kemsakurai / Python datetime のミリ秒を変更する.md
Created May 23, 2020 08:51
Python datetime のミリ秒を変更する.m

Python で datatime の ミリ秒を変更したかったため以下のようなコードを実装した。

for elem in GistEntryPage.objects.all():
    if elem.first_published_at.microsecond == 0:
        elem.first_published_at.microsecond = 1
        elem.save()
@kemsakurai
kemsakurai / sqlalchemy.orm.exc.UnmappedInstanceError.md
Created May 13, 2020 14:33
sqlalchemy.orm.exc.UnmappedInstanceError.m

SQLAlchemy のModel を使っている際に、表題のエラーが発生した。
全文は以下の通り、

sqlalchemy.orm.exc.UnmappedInstanceError: Class 'flask_sqlalchemy.model.DefaultMeta' is not mapped; was a class (models.HtmlStats) supplied where an instance was required?

これは、コンストラクターの記述に問題がある場合に発生する。
具体的には以下の記述。