はてなキーワード: TESTとは
もっと良い書き方があったらご指摘ください
const ngWords = [ /安倍/, /低能|低脳/, /麻生太郎はすごいあほだ/ ] ;
if(document.location.href.startsWith("https://anond.hatelabo.jp")) {
sections = document.getElementsByClassName('section');
Array.prototype.slice.call(sections).forEach(function(section, i, all) {
contain = Array.prototype.slice.call(section.children).filter(function(child, j, all) {
return ngWords.filter((ngWord) => {
if(ngWord.test(child.innerText)) {
return true;
}
if(contain){ section.style.display = 'none'; }
});
}
if(document.location.href.startsWith("https://anond.hatelabo.jp")) {
sections = document.getElementsByClassName('section');
Array.prototype.slice.call(sections).forEach(function(section, i, all) {
contain = Array.prototype.slice.call(section.children).filter(function(p, j, all) {
return true;
} else if(/低能|低脳/.test(p.innerHTML)) {
return true;
}
if(contain){ section.style.display = 'none'; }
});
}
下記をscript.user.jsなど適当な名前で保存し、Chrome機能拡張に突っ込んでおく
Vanilla JSで書いてみたが、書き慣れていないのでエレガントではないかもしれない
if(document.location.href.startsWith("https://anond.hatelabo.jp")) {
sections = document.getElementsByClassName('section');
Array.prototype.slice.call(sections).forEach(function(section, i, all) {
ps = section.getElementsByTagName('p');
contain = Array.prototype.slice.call(ps).filter(function(p, j, all) {
return true;
} else if(/低能|低脳/.test(p.innerHTML)) {
return true;
}
if(contain){ section.style.display = 'none'; }
});
}
これかな
Shohei Ohtani’s blister test will be a ‘full gorilla’ bullpen session
https://nypost.com/2018/04/21/shohei-ohtanis-blister-test-will-be-a-full-gorilla-bullpen-session/
アーバン・ディクショナリでは
https://www.urbandictionary.com/define.php?term=full%20gorilla
相変わらず投稿するような場を持ってないのでここに。
PyQt5のアプリ上で外部から取得したPNG/JPEGをクリップボードに送りたかったが、
期待する動作は、Officeに元の形式として貼り付け可能であること。
QClipboardなのかclipboardなのかで相当手間取った。
というかQApplicationがいまいちわからん。これでいいのだろうか。
ともあれ、クリップボードにはいろいろ格納されたようだが、Office上ではビットマップとしてしか貼り付けられなかった。
import sys from PyQt5.Qt import QApplication, QImage img = QImage('test.png') app = QApplication(sys.argv) app.clipboard().setImage(img)
失敗1から一回QMimeDataを経由してみた。結果何も変わらず。
# -*- coding: utf-8 -*- import sys from PyQt5.Qt import QApplication, QImage, QMimeData img = QImage('test.png') data = QMimeData() data.setImageData(img) app = QApplication(sys.argv) app.clipboard().setMimeData(data)
以前C#にて、画像生成してクリップボードに送るアプリを作ろうとしていたときの残骸を参考にトライ。
無事期待する動作が得られた。
JPEGの場合はsetData('JFIF', img)になる。
# -*- coding: utf-8 -*- import sys from PyQt5.Qt import QApplication, QMimeData with open('test.png', 'rb') as fo: img = fo.read() data = QMimeData() data.setData('PNG', img) app = QApplication(sys.argv) app.clipboard().setMimeData(data)
今回はPyQt5ベースだったので試さなかったが、pywin32のwin32clipboardとかいうのも使えたのだろうか。