Skip to content

Instantly share code, notes, and snippets.

import datetime
def get_last_sunday(dt: datetime.datetime) -> datetime.datetime:
"""
ある時刻が与えられたとき、その時刻を前回の日曜の15時に変換する
>>> get_last_sunday(datetime.datetime(2022, 12, 13, 2, tzinfo=datetime.timezone.utc))
datetime.datetime(2022, 12, 11, 15, 0, tzinfo=datetime.timezone.utc)
>>> get_last_sunday(datetime.datetime(2022, 12, 18, 14, 0, tzinfo=datetime.timezone.utc))
const fetch = require('node-fetch')
const { JSDOM } = require('jsdom')
const nodeEval = require('node-eval')
const xmlParser = require('fast-xml-parser')
const DEFAULT_LANG = 'ja'
function extractTracksFromHTML(body) {
const dom = new JSDOM(body)
import re
import operator
import json
import requests
import lxml.etree
import lxml.html
def collect_global_vars(doc):
#!/bin/sh
set -eu
SELECT_SCHEMA_SQL=<<EOF
SELECT SCHEMA_NAME FROM information_schema.SCHEMATA
WHERE SCHEMA_NAME NOT IN ("information_schema", "performance_schema");
EOF
mysql -u root -N -e "${SELECT_SCHEMA_SQL}" | while read dbname; do
@knzm
knzm / index.md
Last active August 18, 2020 06:18

django-cms ライブラリ調査資料

Chapter. 1 使用ライブラリ調査

1-1. django-cms を djangocms-installer でインストールした場合にインストールされるライブラリ一覧

django 関連

  • django
  • django-classy-tags
$ go version
go version go1.12.5 darwin/amd64
$ go test -bench .
goos: darwin
goarch: amd64
BenchmarkContainsUint64-4 500000 2286 ns/op
BenchmarkContainsUint64Unroll2-4 1000000 1988 ns/op
BenchmarkContainsUint64Unroll4-4 1000000 1589 ns/op
BenchmarkContainsUint64Unroll8-4 1000000 1795 ns/op
PASS
@knzm
knzm / 00-README.md
Last active July 20, 2019 05:52
build tesserocr for Python 2.7 on Windows
@knzm
knzm / gist:149fdda292a03caa7a49498bcff4fdb2
Created May 4, 2019 14:42
Fix firefox's disabled extensions related to the certificate issue occured at May 4, 2019
cd ~/Library/Application Support/Firefox/Profiles/<profile folder>
mv extensions.json extensions.json-20190504
cat extensions.json-20190504 | jq '(.addons[] | select(.signedState == -1)) |= (.signedState = 1 | .active = true | .appDisabled = false)' > extensions.json
@knzm
knzm / gist:6447ffb745e21d97d16ff3460935d095
Last active March 12, 2019 09:35
Replace style.css in Jasper.app to fix broken layout
# install asar
npm install -g asar
# extract, patch, then pack
mkdir out
asar extract /Applications/Jasper.app/Contents/Resources/app.asar out/
cd out
curl -s https://patch-diff.githubusercontent.com/raw/jasperapp/jasper/pull/85.diff | patch -p1
cd ..
asar pack out app.asar
$ VIRTUALENV_VERSION=16.2.0 virtualenv .
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 704, in main
options, args = parser.parse_args()
File "/usr/lib/python2.7/optparse.py", line 1384, in parse_args
values = self.get_default_values()
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 579, in get_default_values
return optparse.Values(defaults)