c:\dev\go-sandbox\jsonstore>go test -bench . -count 10
goos: windows
goarch: amd64
BenchmarkJsonstore-4 2000 897051 ns/op
BenchmarkJsonstore-4 2000 885050 ns/op
BenchmarkJsonstore-4 2000 1131564 ns/op
BenchmarkJsonstore-4 2000 839048 ns/op
BenchmarkJsonstore-4 2000 919052 ns/op
BenchmarkJsonstore-4 2000 838547 ns/op
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Requires matplotlib for plotting. Tested with python 27. If you want to try this | |
without plotting, remove the final two lines and the pylab import. The guts only | |
depends on math and will work with vanilla python. | |
""" | |
import math | |
import pylab | |
def probabilities(posn): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
`@beartype` decorator, implementing a rudimentary subset of PEP 484-style type | |
checking based on Python 3.x function annotations. | |
See Also | |
---------- | |
https://stackoverflow.com/a/37961120/2809027 | |
Stackoverflow answer introducing the `@beartype` decorator. |
Mastodon が他のインスタンスと情報交換をする OStatus API の使い方。使ってるだけのユーザは知る必要がない裏側の話。
Mastodon インスタンスに対して、RFC6415 が規定する /.well-known/host-meta
というパスを要求すると以下の XML が返ってくる.
<?xml version="1.0"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" type="application/xrd+xml" template="https://[MASTODON_HOST]/.well-known/webfinger?resource={uri}"/>
</XRD>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
ctx := context.Background() | |
// trap Ctrl+C and call cancel on the context | |
ctx, cancel := context.WithCancel(ctx) | |
c := make(chan os.Signal, 1) | |
signal.Notify(c, os.Interrupt) | |
defer func() { | |
signal.Stop(c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## NHKのネット配信サービスであるらじる★らじる。 | |
# 従来は https://gist.github.com/riocampos/5656450 のように rtmpdump を使う必要がありましたが、 | |
# 2017年9月から m3u8 による配信へ変更になったようです。m3u8 なので10秒単位での録音になります。 | |
# また 2021年4月に更新され、以前の M3U8URL は2022年2月末で廃止されました。 | |
## 録音コマンド(m4a) | |
ffmpeg -i M3U8URL -c copy outputfilename.m4a | |
# ファイルサイズ的に m4a が最も小さくなる | |
# m4a ファイルのときだけ "-c copy" オプションが使える。 |
この文章は、 Steve Losh 氏の記事 "A Road to Common Lisp" の翻訳です。
原文はこちらです: http://stevelosh.com/blog/2018/08/a-road-to-common-lisp/
A Road to Common Lisp (Common Lisp への道)
これまで、「最近のCommon Lispをどう学ぶとよいでしょう?」と助言を求めるメールをたくさん受け取ってきました。そこで私は、これまでメールやソーシャルメディアに投稿した全てのアドバイスを書き下すことにしました。これが誰かに有益ならば幸いです。
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
def gzip_search(query: str, candidate_chunks: list[str], top_k: int=1): | |
""" | |
文字列ベースで類似したテキストチャンクを推定するアルゴリズム. | |
`query`, `chunk`, および`query + " " + chunk`をそれぞれgzipで圧縮し、編集距離のようなものをベースに評価する. | |
Parameters: | |
query (str): 検索クエリとして使用する文字列. | |
top_k (int, optional): 返される類似チャンクの上位k個を指定する (default: 1). |