Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

Yuki Yokoyama peketamin

View GitHub Profile
@peketamin
peketamin / mono_repo.rst
Created Apr 8, 2019
モノリシックレポジトリ (単一レポ運用) についてリンク集
View mono_repo.rst
@peketamin
peketamin / report_celery_chunks_and_soft_time_limit_exceeded.rst
Last active Apr 2, 2019
Investigation: SoftTimeLimitExceeded occurred in task.chunks()
View report_celery_chunks_and_soft_time_limit_exceeded.rst

Experiment

Assuming: Using Celery with Django.

Target task is debug_task (in my_app.celery)

@peketamin
peketamin / maybe_number.isdigit.py
Created Mar 29, 2019
Check None, float('nan'), float('inf'): str(maybe_number).isdigit()
View maybe_number.isdigit.py
def zero_or_number(maybe_number):
if str(maybe_digit).isdigit():
return maybe_number
return 0
@peketamin
peketamin / contract.py
Created Mar 5, 2019
Example of Programming By Contract (契約プログラミングサンプル)
View contract.py
from logging import getLogger
import pandas as pd
from core.db import get_new_user_id
from user_management import tasks # celery tasks
logger = getLogger(__name__)
@peketamin
peketamin / a_way_to_fix_excel.md
Created Dec 12, 2018
One of way to fix "Removed Records: Named range from /xl/workbook.xml"
View a_way_to_fix_excel.md

Replace double-width parentheses "()" to single-width parentheses "()" of sheet's names.

@peketamin
peketamin / python_abc.py
Created Nov 29, 2018
Python Abstract class
View python_abc.py
"""
https://docs.python.org/3/library/abc.html
https://qiita.com/kaneshin/items/269bc5f156d86f8a91c4
https://stackoverflow.com/questions/13646245/is-it-possible-to-make-abstract-classes-in-python
https://docs.djangoproject.com/en/2.1/topics/db/models/
https://stackoverflow.com/questions/33335005/is-there-any-difference-between-using-abc-vs-abcmeta
"""
from abc import ABC
@peketamin
peketamin / example_of_exception_handling.rst
Last active Nov 9, 2018
Example of Exception handling
View example_of_exception_handling.rst
def greeting(user_id):
    """Parent func"""
    try:
        user_name = get_user_name(user_id)
    except User.DoesNotExists as e:
        logger.error("[greeting] user: {user_id} not found.")
        return None
    print(f"Hello, {user_name}")
@peketamin
peketamin / psql_postgres.md
Last active Oct 31, 2018
Connect postgres db with postgres user.
View psql_postgres.md
$ sudo -u postgres psql postgres
$ ssh -L 6432:localhost:5432 remote-server
$ pg_dump -Fc -U username -p 6432 -h localhost dbname > dbname.dump
$ pg_restore -h localhost -p 6432 -U username -d dbname dbname.dump
@peketamin
peketamin / log_rails_tutorial.md
Last active Aug 27, 2018
ログ: Rails Girls のチュートリアルをやる
View log_rails_tutorial.md

ログ: Rails 入門をやる

Updated: 2018/08/25

開発環境

  • OS: macOS
  • Ruby environment manager: rvenv
  • Ruby version: 2.5.0
@peketamin
peketamin / port_forward_command.md
Last active Aug 2, 2018
ssh port forward database port
View port_forward_command.md
If this error cause,
```
Received disconnect from UNKNOWN port 65535:2: Too many authentication failures
Disconnected from UNKNOWN port 65535
```
```
$ ssh host-name -o 'IdentitiesOnly yes'
```
You can’t perform that action at this time.