「TEST」を含む日記 RSS

はてなキーワード: TESTとは

2018-06-03

UserScriptアップデート

もっと良い書き方があったらご指摘ください

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;

}

}).length > 0;

}).length > 0;

if(contain){ section.style.display = 'none'; }

});

}

自前のユーザースクリプト更新

増田タイトルにのNGワードが含まれているケースに対応

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) {

if(/安倍/.test(p.innerHTML)) {

return true;

} else if(/低能|低脳/.test(p.innerHTML)) {

return true;

}

}).length > 0;

if(contain){ section.style.display = 'none'; }

});

}

2018-06-02

低能先生安倍bot非表示にするuserscript

下記を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) {

if(/安倍/.test(p.innerHTML)) {

return true;

} else if(/低能|低脳/.test(p.innerHTML)) {

return true;

}

}).length > 0;

if(contain){ section.style.display = 'none'; }

});

}

2018-04-11

PyQt5でクリップボード画像を送る

相変わらず投稿するような場を持ってないのでここに。

PyQt5のアプリ上で外部から取得したPNG/JPEGクリップボードに送りたかったが、

期待するサンプルが見当たらなかったのでメモ

期待する動作は、Officeに元の形式として貼り付け可能であること。

失敗1

web上のいろんな情報から再構成してみた。

QClipboardなのかclipboardなのかで相当手間取った。

というかQApplicationがいまいちわからん。これでいいのだろうか。

ともあれ、クリップボードはいろいろ格納されたようだが、Office上ではビットマップとしてしか貼り付けられなかった。

import sys
from PyQt5.Qt import QApplication, QImage

img = QImage('test.png')

app = QApplication(sys.argv)
app.clipboard().setImage(img)


失敗2

失敗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とかいうのも使えたのだろうか。

ただ画像を送るとなると結局情報が少ないので、どのみち手間取りそう。

2018-04-02

見積り

要件: 「test」でも「test」でも検索できること: +100万

test」と「test」は同じでしょ?何いってんの?

おかし

ログイン ユーザー登録
ようこそ ゲスト さん