Skip to content

Instantly share code, notes, and snippets.

View hwatch_logviewer.py
#!/usr/bin/env python3
# -*- encoding: UTF-8 -*-
# Copyright(c) 2021 Blacknon. All rights reserved.
# Use of this source code is governed by an MIT license
# that can be found in the LICENSE file.
#
# User:
# blacknon
# Description: [hwatch](https://github.com/blacknon/hwatch)のlogをパースして出力するスクリプト
# =============================================
@blacknon
blacknon / aa.py
Created Feb 23, 2022
keyにlistを持つdictを組み合わせの配列にする
View aa.py
#!/usr/bin/env python3
# -*- encoding: UTF-8 -*-
import itertools
options = {
"x": ["a", "b"],
"y": [10, 20, 30]}
keys = options.keys()
values = (options[key] for key in keys)
@blacknon
blacknon / main.rs
Created Feb 9, 2022
regexでmatchした箇所をハイライト表示させるためのサンプルコード(rust版)
View main.rs
extern crate regex;
use regex::Regex; // 1.1.8
fn main() {
let seperator = Regex::new(r"is a").unwrap();
let splits: Vec<_> = seperator.split("this... is a, test").into_iter().collect();
for split in splits {
println!("\"{}\"", split);
}
@blacknon
blacknon / a.py
Created Feb 9, 2022
pythonでregex matchしたとこをハイライトさせる場合のサンプルコード(どっかからのコピペだった…はず)
View a.py
#!/usr/bin/env python3
# -*- encoding: UTF-8 -*-
import re
colourFormat = '\033[{0}m'
colourStr = colourFormat.format(32)
resetStr = colourFormat.format(0)
s = "This is a sentence where I talk about interesting stuff like sencha tea."
lastMatch = 0
View get_google_image_url.py
#!/usr/bin/env python3
# -*- encoding: UTF-8 -*-
import chromedriver_autoinstaller
import time
import re
import demjson
from bs4 import BeautifulSoup
from selenium import webdriver
View python_prompt_toolkit_test.py
#!/usr/bin/env python3
# -*- encoding: UTF-8 -*-
from prompt_toolkit import prompt
from prompt_toolkit.completion import FuzzyWordCompleter
# 単語の候補
my_completer = FuzzyWordCompleter(
["apple", "goole", "japan", "hoge", "hello world", "good morning"]
)
View example_p11_getsinger_bk4.go
// Copyright (c) 2020 Blacknon. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
// `github.com/miekg/pkcs11/p11`を使って、Yubikey内からsshのCryptoSignerを取得するサンプルコード
package main
import (
"crypto/rsa"
View example_p11_getsinger_bk4.go
// Copyright (c) 2020 Blacknon. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
// `github.com/miekg/pkcs11/p11`を使って、Yubikey内からsshのCryptoSignerを取得するサンプルコード
package main
import (
"crypto/rsa"
View example_p11_privprint.go
// Copyright (c) 2020 Blacknon. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
// `github.com/miekg/pkcs11/p11`を使って、Yubikey内からsshのCryptoSignerを取得するサンプルコード
package main
import (
"crypto/rsa"
View example_p11_getsinger.go
// Copyright (c) 2020 Blacknon. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
// `github.com/miekg/pkcs11/p11`を使って、Yubikey内からsshのCryptoSignerを取得するサンプルコード
package main
import (
"crypto"