Skip to content

Instantly share code, notes, and snippets.

View tpdn's full-sized avatar
🇰🇵

tpdn

🇰🇵
View GitHub Profile
@e000
e000 / donotuse.py
Created June 13, 2011 23:30
How to NEVER use lambdas.
##########################################################
# How to NEVER use Lambdas. An inneficient and yet educa-#
# tonal guide to the proper misuse of the lambda constru-#
# ct in Python 2.x. [DO NOT USE ANY OF THIS EVER] #
# by: e000 (13/6/11) #
##########################################################
## Part 1. Basic LAMBDA Introduction ##
# Well, it's worth diving straight into what lambdas are.
# Lambdas are pretty much anonymous "one line" functions
@yumike
yumike / blocks.py
Created December 8, 2011 06:45
Thoughts about RSpec for Python
# codec: blocks
describe('articles.views.ArticleView'):
context('when user has permissions'):
it('should add new article'):
# some code
it('should delete existing article'):
@dahlia
dahlia / hstore.py
Created February 18, 2012 14:58
PostgreSQL hstore + SQLAlchemy
""":mod:`hstore` --- Using PostgreSQL hstore with SQLAlchemy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. note::
I released it under Public Domain. Feel free to use!
It provides :class:`Hstore` type which makes you to store Python
dictionaries into hstore columns in PostgreSQL. For example::
@afair
afair / gist:3803895
Last active August 7, 2023 07:43
PostgreSQL and Pgpool Architecture

Hey! I saw this has been indexed by the search engines. It is a first draft of a post I ended up publishing on my blog at: Scaling PostgreSQL With Pgpool and PgBouncer

Thanks for stopping by!

PostgreSQL and Pgpool Architecture

@msykiino
msykiino / Howto-XtraBackup.md
Created October 3, 2012 05:48
Doc - How to use XtraBackup
anonymous
anonymous / gist:4323919
Created December 18, 2012 00:51
SNAC用の記事

「旅の恥は掻き捨て」ではないですが,過去の恥を書き捨てるつもりで書きます. だから,今回はgistに載せます.

今回は,就活で全敗した話と博士進学を決心した後に起こったイベントについて話します. 「就活で全敗」と書きましたけど,ワイドショーで取り上げられるような「50社以上を受けた」というレベルではなく,数社を受けたレベルなので,全敗という字面ほど重くはないです. 最初に,僕の主張を述べておくと,

  • 就活やるなら就職するつもりでやらないと時間の無駄
  • 博士課程進学の相談は,早めに,丁寧に.

ということです.

@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.
@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)
@voluntas
voluntas / shiguredo_tech.rst
Last active November 10, 2024 05:11
時雨堂を支える技術

時雨堂を支える技術

日時:2024-11-10
作:時雨堂
バージョン:2024.5
URL:https://shiguredo.jp/

時雨堂クラウドサービスを支える技術

@chanks
chanks / gist:7585810
Last active September 17, 2024 11:55
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