Skip to content

Instantly share code, notes, and snippets.

View tk42's full-sized avatar
💭
changed from @jimako1989

tk42 tk42

💭
changed from @jimako1989
View GitHub Profile
@tk42
tk42 / EM_algorithm.ipynb
Last active December 20, 2015 15:03
Clustering using the EM algorithm
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tk42
tk42 / Fitting_data_with_python.ipynb
Last active August 29, 2015 14:09
Fitting data with Python の和訳
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tk42
tk42 / mymap.py
Last active February 19, 2021 20:46
shared memory example with multiprocessing.manager
from multiprocessing import Process, Manager
class MyMap():
def __new__(cls):
self = Manager().dict()
return self
def f(d):
d[1] += '1'
d['2'] += 2
@tk42
tk42 / dotted_dict.py
Created February 19, 2021 19:50
dotaccess dictionary
class dict2(dict):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__dict__ = self
@tk42
tk42 / redis_conn.py
Last active June 24, 2021 03:01
async connection pool class to Redis
import logging
import aioredis
class RedisConn:
_pool = {}
# Singleton
def __new__(cls, *args, **kwargs):
if not hasattr(cls, "_instance"):
@tk42
tk42 / mytype.dhall
Created September 16, 2021 11:48
parameter template in dhall
{
Type = {
key : Text,
},
default = {
key = "default",
}
}
@tk42
tk42 / 1.dhall
Created September 17, 2021 05:02
higher-order-function
λ(n : Natural) -> [ n, n + 1 ]
@tk42
tk42 / App.tsx
Created February 4, 2022 13:33
createAppContainer
import React from 'react';
import AppContainer from './appcontainer';
export default function App() {
return (
<AppContainer />
)
}
@tk42
tk42 / cleanarchitecture.md
Last active September 22, 2022 13:26
CleanArchitecture Memo
@tk42
tk42 / engine.py
Created May 7, 2022 06:50
Connection to MySQL in PlanetScale with SQLAlchemy
#!/usr/bin/env python3
import os
from sqlalchemy import create_engine
## assertion
for key in ['USERNAME', 'PASSWORD', 'HOST', 'DATABASE']:
assert os.getenv(key), f'{key} is empty'