Skip to content

Instantly share code, notes, and snippets.

View tokibito's full-sized avatar

Shinya Okano tokibito

View GitHub Profile
@tokibito
tokibito / main.py
Created May 21, 2020 05:14
get active window title
import win32gui
import time
while True:
handle = win32gui.GetForegroundWindow()
title = win32gui.GetWindowText(handle)
print(handle, title)
time.sleep(1)
@tokibito
tokibito / main.md
Last active May 9, 2018 21:03
Delphiとテストコードの話

テストコードの話

テストコードとは

  • プログラムの動作をテストするコード

どうしてテストコードが必要か

  • 既存のソースコードを変更した際、動作確認が必要となるが、手作業と目視で毎回確認するのはコストがかかる
  • 人間は間違えたり見落としたり、サボったりするから
@tokibito
tokibito / test_sendfds.py
Created December 14, 2016 15:23
from multiprocessing.reduction import sendfds, recvfds
import socket
import time
import os
import sys
import tempfile
from multiprocessing.reduction import sendfds, recvfds
import unittest
from unittest import TestCase
@tokibito
tokibito / recipe.md
Last active November 26, 2016 11:19
パイのレシピ

パイのレシピ

サンマとトマトソースのフィリング

材料(1個分)

  • サンマ
    • サンマの開き(1匹分)
    • 牛乳(臭み消し用)
    • オリーブオイル 大さじ2
    • にんにく 1かけ(チューブのやつでもok)
  • トマトソース
@tokibito
tokibito / main.py
Last active November 24, 2016 15:24
thriftpy performance test
import thriftpy
from thriftpy.thrift import TProcessor
class AppServiceHandler:
def echo(self, message):
return message
main_thrift = thriftpy.load("main.thrift")
@tokibito
tokibito / PythonClient.py
Created November 4, 2016 06:21
Thrift Tutorial (using thriftpy)
import thriftpy
from thriftpy.rpc import make_client
tutorial_thrift = thriftpy.load(
'tutorial.thrift', module_name='tutorial_thrift')
Calculator = tutorial_thrift.Calculator
Work = tutorial_thrift.Work
Operation = tutorial_thrift.Operation
InvalidOperation = tutorial_thrift.InvalidOperation
@tokibito
tokibito / pipe6.py
Created October 20, 2016 15:16
forkとpipeモジュールのサンプル(fd閉じるようにしたやつ)
import os
import time
import fcntl
import select
read_fd, write_fd = os.pipe()
pid = os.fork()
if pid:
# 親プロセス
# 読み込み側のfdは使わないのでclose
@tokibito
tokibito / pipe4.py
Created October 19, 2016 16:43
selectorsモジュールのサンプルコード
import os
import time
import fcntl
import selectors
read_fd, write_fd = os.pipe()
pid = os.fork()
if pid:
# 親プロセス
write_pipe = os.fdopen(write_fd, 'wb')
@tokibito
tokibito / main.py
Last active October 20, 2016 15:19
forkとpipeとepollのサンプルコード
import os
import sys
import time
import select
READ_ONLY = select.EPOLLIN
def main():
read_fd, write_fd = os.pipe2(os.O_NONBLOCK)
pid = os.fork()
@tokibito
tokibito / os-module.txt
Last active September 27, 2016 02:25
subprocess call
tokibito@ubuntu:~$ cat main.py
import os
import subprocess
subprocess.call([os.environ['_'], "-V"])
tokibito@ubuntu:~$ python main.py
Python 2.7.6
tokibito@ubuntu:~$ tmp/venv/bin/python main.py
Python 3.4.3