Skip to content

Instantly share code, notes, and snippets.

View fanannan's full-sized avatar

SAWADA Takahiro / Gugen Koubou LLC fanannan

  • Gugen Koubou LLC
  • Tokyo, Japan
View GitHub Profile
@fanannan
fanannan / schema-model.js
Created September 4, 2025 02:30
Self-contained immutable dictionary with embedded schema
/*!
* schema-model.js
* (c) Gugen Koubou 2025 / MIT License
*
* Self-contained immutable dictionary with embedded schema (Strict & Clojure-inspired)
* Plain JavaScript / Zero dependencies / Single file / UMD / Browser & Node.js
*
* ──────────────────────────────────────────────────────────────────────────────
* Purpose
* - Embeds "hidden schema" in a dictionary for strict validation on all updates
@fanannan
fanannan / quest.md
Last active June 16, 2025 04:16
Claude Code command that performs automated code review and generates a CLAUDE_QUESTIONS.md file containing identified issues with unique IDs for tracking and resolution. CLAUDE_QUESTIONS.md may help Claude Code to understand the relevant files swiftly and efficiently.

File Review System Instructions for Claude Code

Purpose

  • Help the repository owner identify potential issues, inconsistencies, and areas for improvement
  • Document questions and concerns that may require clarification or refactoring
  • Provide a comprehensive review of code quality and architectural decisions
  • Read and understand Explanatory Files (if present) to learn about code rationales and implementation decisions before raising questions

Starting Point

  • The LLM should walk through all directories recursively from the specified starting path or $ARGUMENTS
@fanannan
fanannan / duplicate_instance.py
Created April 1, 2025 07:38
Duplicate a Django model instance
"""
# Django モデルインスタンス複製ツール - ドキュメント
## 使い方
```python
# インポート方法
from your_app.utils import duplicate_instance
# 基本的な使用方法(すべての関連オブジェクトを複製する)
@fanannan
fanannan / function_executor.py
Last active September 27, 2024 08:08
FunctionExecutor a robust, multi-threaded, non-blocking task execution utility
import queue
from typing import Callable, Any, Optional, List
import threading
import time
import atexit
import logging
import weakref
class FunctionExecutor:
@fanannan
fanannan / libpython_clj_snippet_pandas.clj
Last active April 2, 2020 10:49
iloc and loc functions for pandas DataFrame in Clojure
; Clojupyter Snippet
(require '[clojupyter.misc.helper :as helper])
(helper/add-dependencies '[cnuernber/libpython-clj "1.36"])
(require '[libpython-clj.require :refer [require-python]]
'[libpython-clj.python :refer [py. py.. py.- $. $.. $a $c
as-python as-jvm
->python ->jvm
get-attr call-attr call-attr-kw
get-item att-type-map
call call-kw initialize!
@fanannan
fanannan / make_heatmap_data.py
Created February 26, 2020 01:36
process 3d data for heatmap
; not fast, just straitfoward
def make_heatmap_data(xs, ys, zs, func, cutoff, num_grids, min_samples):
xmin = np.nanpercentile(xs, cutoff*100)
xmax = np.nanpercentile(xs, (1-cutoff)*100)
ymin = np.nanpercentile(ys, cutoff*100)
ymax = np.nanpercentile(ys, (1-cutoff)*100)
xm = (xmax-xmin)/num_grids
ym = (ymax-ymin)/num_grids
r = [[list() for _ in range(num_grids)] for _ in range(num_grids)]
for x, y, z in zip(xs, ys, zs):
@fanannan
fanannan / libpython_clj_snippet.clj
Last active April 2, 2020 00:27
Clojupyter Snippet for libpython-clj
; Clojupyter Snippet
(require '[clojupyter.misc.helper :as helper])
(helper/add-dependencies '[cnuernber/libpython-clj "1.36"])
(require '[libpython-clj.require :refer [require-python]]
'[libpython-clj.python :refer [py. py.. py.-
as-python as-jvm
->python ->jvm
get-attr call-attr call-attr-kw
get-item att-type-map
call call-kw initialize!
@fanannan
fanannan / embedding_vix.py
Created May 4, 2018 07:27
Embedding category labels to multiple dimensions
# coding: utf-8
import os
import shutil
import pandas as pd
import numpy as np
import math
import quandl
from fastai.structured import add_datepart, proc_df
from fastai.column_data import ColumnarModelData
@fanannan
fanannan / extension.py
Created August 1, 2017 10:32
build data bundles for zipline with yahoo-style csv files
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from zipline.data.bundles import register
from zipline.data.bundles.yahoo_csv import yahoo_csv_equities # yahoo_csv.py need to be placed in zipline.data.bundles
tickers = {
"SPY", "VXX", "VXZ"
}
register(
@fanannan
fanannan / gist:c03323f374688d1e3ac9f8c94b80d19a
Created May 23, 2017 11:43
supplimental fix to pandas-datareader
# supplimental fix to pandas-datareader-'0.4.1' (not yet pulled proposal)
#
#
#$ git clone https://github.com/rgkimball/pandas-datareader
#$ cd pandas-datareader
#$ git checkout fix-yahoo
#$ pip install -e .
def fetch_yahoo(ticker):
NUM_RETRY = 5