Python で datatime の ミリ秒を変更したかったため以下のようなコードを実装した。
for elem in GistEntryPage.objects.all():
if elem.first_published_at.microsecond == 0:
elem.first_published_at.microsecond = 1
elem.save()| (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で↓を実行すると、現在の参加者からランダムで一人表示することができます |
| // 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' |
| // ==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 |
| 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 |
| // ==UserScript== | |
| // @name Copy page link for Chatwork | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description 閲覧しているブラウザのページをChatworkへの共有向けにコピーする | |
| // @author K.Sakurai | |
| // @run-at context-menu | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; |
| // ==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() { |
| // ==UserScript== | |
| // @name My BookMarklet | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description BookMarklet | |
| // @author mutter.monotalk | |
| // @match *://*/* | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; |
| 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: |
Python で datatime の ミリ秒を変更したかったため以下のようなコードを実装した。
for elem in GistEntryPage.objects.all():
if elem.first_published_at.microsecond == 0:
elem.first_published_at.microsecond = 1
elem.save()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?これは、コンストラクターの記述に問題がある場合に発生する。
具体的には以下の記述。