Skip to content

Instantly share code, notes, and snippets.

View t2y's full-sized avatar

Tetsuya Morimoto t2y

View GitHub Profile
@t2y
t2y / typeorm-paging.md
Last active July 14, 2021 04:23
TypeORM Paging behavior
結合 Repository
.find({take: x, skip: y})
QueryBuilder
.take(x).skip(y)
QueryBuilder
.limit(x).offset(y)
無し DISTINCT 無し DISTINCT 無し DISTINCT 無し
有り DISTINCT 有り DISTINCT 有り DISTINCT 無し
@t2y
t2y / results.md
Last active July 12, 2021 07:40
TypeORM RelationId benchmark results

経過時間の単位はミリ秒。

Repository.find()

取得
件数
post1
(RelationIDあり, lazy=true)
post2
(RelationIDなし, lazy=true)
post3
(RelationIDなし, eager=true)
20 12 3 8
40 20 2 8
80 47 4 11
160 144 4 25
@t2y
t2y / pie_charts_percent.py
Created February 10, 2021 14:51
pie chart with datalabellist
import pandas as pd
from openpyxl import Workbook
from openpyxl.chart import PieChart, Reference
from openpyxl.chart.label import DataLabelList
wb = Workbook()
ws = wb.active
df = pd.read_csv('population.csv')
ws.append(df.columns.tolist())
@t2y
t2y / dump_chart_dataLabels.py
Created February 9, 2021 00:35
chart のデータラベルの表示
import sys
from openpyxl import load_workbook
from pprint import pprint
if len(sys.argv) < 2:
print(f'{__file__}の後にExcelファイルを指定してください')
sys.exit(0)
filename = sys.argv[1]
wb = load_workbook(filename)
@t2y
t2y / result
Created November 19, 2020 12:37
ast.unparse sample for hy ast
(py39) $ python unparse_hy_ast.py
def add(hyx_xXcommaX, y):
return hyx_xXcommaX + y
print(add(3, 5))
(py39) $ python -c "$(python unparse_hy_ast.py)"
8
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
{{- if .Get "link" -}}
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{- end }}
<img src="{{ .Get "src" }}"
{{- if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
{{- end -}}
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
@t2y
t2y / test.go
Created July 15, 2017 11:42
buil insert test for genmai
package main
import (
"fmt"
_ "github.com/mattn/go-sqlite3"
"github.com/naoina/genmai"
)
type testData struct {
@t2y
t2y / async_comprehension_example_kai1.py
Created January 22, 2017 00:27
asynchronous comprehensions
# -*- coding: utf-8 -*-
"""
pep 530 -- asynchronous comprehensions
https://www.python.org/dev/peps/pep-0530
"""
import asyncio
from random import choice
@t2y
t2y / async_for_example_pep492_kai1.py
Created January 22, 2017 00:03
async for and async iterable example
# -*- coding: utf-8 -*-
"""
pep492 aiter using queue before pep 525
https://www.python.org/dev/peps/pep-0492
https://www.python.org/dev/peps/pep-0525
"""
import asyncio
@t2y
t2y / producer-consumer-pattern.py
Created January 21, 2017 13:21
producer consumer pattern sample
# -*- coding: utf-8 -*-
"""
implement Producer-Consumer pattern using asyncio
http://www.hyuki.com/dp/dpinfo.html#ProducerConsumer
"""
import asyncio
from random import choice