Skip to content

Instantly share code, notes, and snippets.

Avatar

Takeshi KOMIYA tk0miya

View GitHub Profile
View nullable.rb
# frozen_string_literal: true
module Ransack
module Nullable
# Ransack で NULL を含む IN クエリを組み立てるためのヘルパ
#
# 利用方法:
# Ransack::Nullable.build(User, params[:q], nullable: %i[user_id])
#
# 注意点:
View ransackable.rb
# frozen_string_literal: true
# ActiveYaml の association を Ransack で検索可能にする
module ActiveHash
module Ransackable
def ransackable_attributes(_auth_object = nil)
data.first.keys
end
def ransortable_attributes(auth_object = nil)
@tk0miya
tk0miya / tbls.yml
Last active May 11, 2022
Rails: DB スキーマの変更がマージされたら自動的に tbls を実行して main ブランチに push する
View tbls.yml
on:
push:
branches: [main]
paths:
- db/schema.rb
- .tbls.yml
permissions:
contents: write
View README.md
@tk0miya
tk0miya / gist:8a376ae67d3bca7d10f4c80ca5cd86f8
Created Aug 9, 2020
broken help is shown if the signature of lambda has return_annotation
View gist:8a376ae67d3bca7d10f4c80ca5cd86f8
$ python
Python 3.8.2 (default, Mar 2 2020, 00:44:41)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> foo = lambda x = 1: 1
>>> help(foo)
Help on function <lambda> in module __main__:
<lambda> lambda x=1
>>> import inspect
View layout.html
{% extends "!layout.html" %}
{% block content %}
<div class="notice" style="width: 100%; height: 24px; background-color: #ffe761; padding: 8px 20px 8px 20px;">
このページは新しめのやつなので気をつけておくれやす。 っ[ぶぶづけ]
</div>
{{ super() }}
{% endblock %}
View 0001-doc-Fix-messages-in-extensions-are-not-translated.patch
From 551ad9efa5cc60a50e6f280e9aecdd12220693f1 Mon Sep 17 00:00:00 2001
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
Date: Mon, 16 Mar 2020 00:38:21 +0900
Subject: [PATCH] doc: Fix messages in extensions are not translated
So far, custom extensions for python-doc have accessed internal data
structure of sphinx.locale module directly. But, it does not work at
present because the structure has changed since Sphinx-1.8 release.
This uses public translation APIs of Sphinx instead to get translated
messages.
View conf.py
latex_elements = {
'extrapackages': r'\usepackage{titlesec}',
'preamble': '\n'.join([
# 字下げ (なんでデフォルトで動かないんだろ?)
r'\setlength{\parindent}{1zw}',
# 段落調整、箇条書きの行間調整
r'\setlength{\parskip}{0ex}',
# 見出しの装飾
# ref: https://qiita.com/krtx/items/deeec0843caf37b66054
r'\definecolor{teal}{RGB}{0,128,128}',
View README
preface and appendix for Sphinx
View ext.py
"""
autodoc: show default value of arguments as is
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:license: Same as Sphinx
"""
import ast
import inspect
from typing import Any, Dict