-
CSV のなかの第二欄
font-size
という名称が JavaScript の識別子として不適切なのでfont_size
に変更した.本当は Python で対応するべきだけれども,面倒だったので. -
SVG の DOM 木の構成は簡単だったけれども,最初,SVG が表示されなくて慌てた.いろいろ調べたところ,XML の名前空間というものがあって,HTML と SVG では名前空間が異なるらしい.細かいことはわからないけれども
createElementNS('http://www.w3.org/2000/svg', SVGタグ名)
を使わないといけないらしい.
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
#!/Users/wakita/.venvs/vis/bin/python | |
# Requirements: pandoc and imported Python modules | |
import json | |
import os | |
from pathlib import Path | |
import gspread | |
import pandas as pd |
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
# today | |
# today 1[d]: tomorrow, today 2[d]: the day after tomorrow | |
# today -1[d]: yesterday, today -2[d]: the day before yesterday | |
# today 1w: this day next week, 2w: two weeks later today, -2w: two weeks ago today | |
# today 1m: one month later today, 2m, -3m | |
# today 1y, -10y | |
snippet "today *(([+-]?[0-9]+)?)([dwmy]?)" "The date relative to today" r | |
`!p | |
import datetime | |
from dateutil.relativedelta import relativedelta |
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
#!/bin/zsh | |
# 以下のイニシャルは脇田のものです.自分(校正者)のイニシャルに変更して下さい. | |
initial=kw | |
dl() { | |
url=$1 | |
file=`echo $url | sed -e 's|.*vsj21-||' -e 's/\?.*//'` | |
comment=`date "+-%m%d-$initial"` | |
file=`echo $file | sed -e "s/.docx/$comment.docx/"` |
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
#!/bin/sh | |
# nginx について、研究室の scrapbox に書きました。 | |
# https://scrapbox.io/smartnovax/nginx#60b5828d93b2e9000065e3e4 | |
brew list nginx >& /dev/null || (echo "nginx が見つからないのでインストールします。"; brew install nginx) | |
# nginx の設定ファイルのなかの環境依存の部分を envsubst コマンドで変換したい。 | |
# Homebrew の gettext パッケージは envsubst コマンドを含んでいる。 | |
brew list gettext >& /dev/null || (echo "envsubst コマンドが見つからないので、gettext をインストールします。"; brew install gettext) |
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
from bokeh.io import output_file, output_notebook, show | |
from bokeh.models import * | |
from bokeh.layouts import * | |
output_notebook() | |
n = 0 | |
animate_cb = None | |
def plot(doc): |
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 logging | |
import pickle | |
import time | |
import numpy | |
from z3 import * | |
NODES, EDGES, LAYERS = None, None, None | |
def parse(edges, layers): |
加えて CustomJS を扱うためのツール (snjs.py
) を作成した.
Bokeh では Python のファイルのなかに文字列として JavaScript のコードを埋め込みます.でも,二種類の言語の文法が混在するのはやっかいです.
そこで,JavaScript のコードは独立したものを *.js
ファイルに関数として定義することにしました.たとえば,以下は普通の JavaScript の関数のように見えますが,本ツールを利用すると slider_on_change
という名前で,filter
と cds
という変数によって,Python のデータ構造を受け取るような CustomJS の定義として扱われます.
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
from bokeh.core.properties import String, Instance | |
from bokeh.models import HTMLBox, Slider | |
class Custom(HTMLBox): | |
__implementation__ = 'custom.ts' | |
text = String(default='Custom Text') | |
slider = Instance(Slider) | |
from bokeh.io import show | |
from bokeh.layouts import column |