Skip to content

Instantly share code, notes, and snippets.

View showa-yojyo's full-sized avatar
💭
I may be slow to respond.

プレハブ小屋 showa-yojyo

💭
I may be slow to respond.
View GitHub Profile
# \_\_main\_\_.py memo
## coverage
```
__main__.py => coverage.cmdline.main() => CoverageScript().command_line(argv)
```
## nose
```
__main__.py => nose.core.run_exit() => main() => TestProgram() (ctor)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" mkrefresh.py -- Generate redirecting HTML files.
"""
from jinja2 import Environment
import re
from glob import iglob
URL='https://showa-yojyo.github.io/notebook/'
@showa-yojyo
showa-yojyo / scrape-graph-glossary.py
Created November 21, 2014 15:34
Scrape "Appendix: Glossary of graph theory" (Wiktionary).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Scrape "Appendix: Glossary of graph theory" (Wiktionary)
Example:
$ scrape-graph-glossary.py | sort -d | uniq
"""
import re
import urllib.request
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""dq8pot.py: demonstrate MultiDiGraph and related features.
"""
import networkx as nx
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
from matplotlib.text import Text
from itertools import groupby
@showa-yojyo
showa-yojyo / mst.py
Created December 13, 2014 17:13
Demonstration of NetworkX (minimum_spanning_tree)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""mst.py: demonstrate NetworkX (minimum_spanning_tree)
"""
import networkx as nx
import numpy as np
def main():
G = setup_graph(5)
dump_spanning(nx.minimum_spanning_tree(G))
@showa-yojyo
showa-yojyo / mahjongscoring.py
Created December 25, 2015 14:08
An unused script.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""mahjongscoring.py: Output a scoring table to look up the score of
a Mahjong hand.
Usage:
mahjongscoring.py
"""
from itertools import chain
@showa-yojyo
showa-yojyo / ipython-history-recall-demo.txt
Created August 15, 2016 14:51
How to use %history and %recall in IPython.
In [12]: %history?
Docstring:
::
%history [-n] [-o] [-p] [-t] [-f FILENAME] [-g [PATTERN [PATTERN ...]]]
[-l [LIMIT]] [-u]
[range [range ...]]
Print input history (_i<n> variables), with most recent last.
@showa-yojyo
showa-yojyo / sankeydemo_mahjong.py
Created September 1, 2016 14:16
Demonstrate mpl.sankey.Sankey
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""sankeydemo_mahjong.py:
Usage:
sankeydemo_mahjong.py
"""
import numpy as np
import matplotlib.pyplot as plt
@showa-yojyo
showa-yojyo / dq6-prob-treasure.ipynb
Last active September 19, 2016 14:23
A demonstration of Jupyter Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@showa-yojyo
showa-yojyo / mahjongscoring.ipynb
Last active September 26, 2016 13:34
A demonstration of Jupyter Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.