Skip to content

Instantly share code, notes, and snippets.

View devlights's full-sized avatar
🤧
hay fever....

devlights devlights

🤧
hay fever....
View GitHub Profile
@devlights
devlights / display_only_directory_with_ls.md
Last active April 15, 2018 16:58
[linux][mac] ls コマンドでディレクトリのみを表示する (ls, directory)

以下で表示される

$ ls -ld */

もしくは

$ ls -d */
@devlights
devlights / retrieve_physmemory_on_mac.md
Created April 15, 2018 16:34
[mac] メモリ量をコマンドラインから取得 (top, grep, memory physmem)

Mac で 使用メモリ量 を コマンドライン から取得

$ top -l 1 | grep -i physmem

出力例

PhysMem: 6359M used (1524M wired), 1832M unused.
@devlights
devlights / rxpy_example.py
Created April 13, 2018 09:26
[python][rxpy][reactive python] RxPYのサンプル
"""
Reactive Python (RxPy) のサンプル
2018/04/13:まだ途中
REFERENCES::
https://auth0.com/blog/reactive-programming-in-python/
https://github.com/ReactiveX/RxPY
"""
import threading
@devlights
devlights / sentry_logging_example.py
Last active April 5, 2018 08:31
[python][sentry] Sentryとloggingモジュールの組み合わせサンプル
"""
Sentry と logging の組み合わせのサンプル
DSN は 環境変数 SENTRY_DSN に設定してから起動します。
(*) Windowsの場合、一時設定するには以下のようにします。
$ set SENTRY_DSN=xxxxx
REFERENCES::
https://docs.python.jp/3/library/logging.config.html#logging-config-dictschema
https://docs.sentry.io/clients/python/integrations/logging/
@devlights
devlights / logging_config.json
Last active April 6, 2018 06:58
[python] logging.config.dictConfigのサンプル
{
"version": 1,
"disable_existing_loggers": "true",
"formatters": {
"console": {
"format": "[%(asctime)s][%(levelname)s] %(name)s %(filename)s:%(funcName)s:%(lineno)d | %(message)s",
"datefmt": "%Y/%m/%d %H:%M:%S"
}
},
"handlers": {
@devlights
devlights / fd_cat.py
Last active April 4, 2018 09:31
[python] subprocess.popen で ファイルディスクリプタを渡して別プロセス側でも同じファイルを同一 fd で読み取るサンプル (pass_fds)
"""
起動引数で指定された fd (ファイルディスクリプタ) を使ってデータを読み取り表示します。
(注意) subprocess.popen経由で呼び出されることを想定しています。
"""
import itertools
import os
import sys
def go():
@devlights
devlights / find_file_command_on_windows.md
Created April 2, 2018 08:36
[windows] windows で linux の find コマンドのようにファイルを検索するコマンド

where コマンドを利用する

> where /r ベースフォルダ 検索対象ファイルパターン(ワイルドカード指定可能)

現在のフォルダから再帰的に *.ini にマッチするファイルを検索する

@devlights
devlights / cmder_japanese_settings.md
Created March 30, 2018 08:48
[cmder] 日本語を表示するための設定

Cmder の日本語対応

以下の対応で日本語表示できた。

  • 設定でMonospaceのチェック外す。
  • メインフォントを FiraCode Medium に設定する
  • Alternativeのフォント設定する MeiryoUI
  • Environmentで set LANG=ja_JP.UTF-8 を設定する。
@devlights
devlights / icecream_sample.py
Created March 27, 2018 05:40
[python] icecream ライブラリのサンプル (debug, print, ic, configureOutput)
"""
icecream ライブラリのサンプル
REFERENCES::
https://github.com/gruns/icecream
"""
import collections
import contextlib as ctx
import datetime
@devlights
devlights / tokei.py
Created March 22, 2018 02:42
[python] コンソールに現在日時を表示し続けるスクリプト
import datetime as dt
import time as tm
import sys
def go():
while True:
d = dt.datetime.now()
now = d.strftime('%Y/%m/%d %H:%M:%S')
sys.stdout.write(f'\r{now}')