Skip to content

Instantly share code, notes, and snippets.

View tpdn's full-sized avatar
🇰🇵

tpdn

🇰🇵
View GitHub Profile
@tpdn
tpdn / hoge.py
Last active September 17, 2018 23:16
__author__ = 'KIM_TPDN'
from logitechlcd import LogitechLcd
from time import sleep
if __name__ == '__main__':
lcd = LogitechLcd('朝鮮民主主義人民共和国')
lcd.set_text(0, '文字数は全角1文字=半角2文字')
lcd.set_text(1, '換算で、1行あたり半角29文字')
lcd.set_text(2, '文字数が一定を超えるとはみ出る')
lcd.set_text(3, '김정일 【ハングル対応】金正日')
@dtheodor
dtheodor / listen_sqla.py
Last active February 17, 2025 19:04
Listen for pg_notify with SQL Alchemy + Psycopg2
import select
import datetime
import psycopg2
import psycopg2.extensions
from sqlalchemy import create_engine, text
engine = create_engine("postgresql+psycopg2://vagrant@/postgres")
@you21979
you21979 / loadbalance.md
Last active May 10, 2019 01:21
Websocketのロードバランス

Websocketのロードバランス戦略

問題

websocketに対応していないロードバランサを使うといくつか問題が起きる

  • upgradeヘッダを捨ててしまい接続できない(L7スイッチなど)
  • ポート番号枯渇により新規接続ができなくなる
  • タイムアウトの設定が短いと定期的に切断されてしまう
@mangelajo
mangelajo / URLs from app olympus share app
Last active September 17, 2025 08:01
Olympus Share E-M10 camera
Olympus Share APP control urls over E-M10 camera, still to investigate..
http://192.168.0.10
http://192.168.0.10/
http://192.168.0.10/clear_resvflg.cgi
http://192.168.0.10/exec_pwoff.cgi
http://192.168.0.10/exec_shutter.cgi?com=1st2ndpush
http://192.168.0.10/exec_shutter.cgi?com=1stpush
http://192.168.0.10/exec_shutter.cgi?com=1strelease
http://192.168.0.10/exec_shutter.cgi?com=2nd1strelease
@DmZ
DmZ / pre-commit
Last active July 25, 2023 13:40
Git pre-commit hook to search for Amazon AWS API keys.
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@chanks
chanks / gist:7585810
Last active July 22, 2025 01:00
Turning PostgreSQL into a queue serving 10,000 jobs per second

Turning PostgreSQL into a queue serving 10,000 jobs per second

RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.

On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.

So, many developers have started going straight t

@voluntas
voluntas / shiguredo_tech.rst
Last active January 18, 2026 10:56
時雨堂を支える技術

時雨堂を支える技術

日時:2025-05-13
作:時雨堂
バージョン:2025.3
URL:https://shiguredo.jp/

言語

@techniq
techniq / audit_mixin.py
Created March 16, 2013 01:05
Useful SQLAlchemy Mixins
from datetime import datetime
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declared_attr
from flask_security import current_user
class AuditMixin(object):
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
@akiatoji
akiatoji / _sns_description
Last active January 15, 2020 02:30
AWS SNS Sample code.
Notes on how to use AWS SNS:
1. Subscribe an HTTP endpoint (i.e. http://myhost/sns_endpoint) on AWS Console
2. AWS will send subscription confirmation right away
3. SNS_controller responds to subscription confirmation by sending confirmation using Fog.
4. Once AWS is happy, you can start sending notifications to your end point via SNS.