Skip to content

Instantly share code, notes, and snippets.

View peketamin's full-sized avatar
🐔
Hello world!

Yuki Yokoyama peketamin

🐔
Hello world!
View GitHub Profile
@peketamin
peketamin / contract.py
Created March 5, 2019 12:13
Example of Programming By Contract (契約プログラミングサンプル)
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 December 12, 2018 05:14
One of way to fix "Removed Records: Named range from /xl/workbook.xml"

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

@peketamin
peketamin / python_abc.py
Created November 29, 2018 04:04
Python Abstract class
"""
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 November 9, 2018 05:19
Example of Exception handling
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 October 31, 2018 16:46
Connect postgres db with postgres user.
$ 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 August 27, 2018 01:38
ログ: Rails Girls のチュートリアルをやる

ログ: Rails 入門をやる

Updated: 2018/08/25

開発環境

  • OS: macOS
  • Ruby environment manager: rvenv
  • Ruby version: 2.5.0
@peketamin
peketamin / port_forward_command.md
Last active August 2, 2018 03:32
ssh port forward database port
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'
```
@peketamin
peketamin / uninstall_java1.6_from_high_sierra.md
Created May 23, 2018 16:54
How to uninstall Apple Java 1.6 (Java 6) from macOS HighSierra (10.13.4)
$ sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
$ sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefpane
$ sudo rm -rf /Library/Java/JavaVirtualMachines/1.6.0.jdk
@peketamin
peketamin / my_class.py
Last active March 29, 2018 00:47
python mock, patch example
from third_party_lib import make_service, make_credentials
class MyClass(object):
@classmethod
def from_json(cls, json):
credentials = make_credentials(json)
return cls(credentials)