Skip to content

Instantly share code, notes, and snippets.

View pior's full-sized avatar

Pior Bastida pior

View GitHub Profile
@pior
pior / etc init mongodb-localrs.conf
Created December 4, 2013 17:41
Install a local MongoDB replicaset with the 10gen APT repo (upstart). http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
start on runlevel [2345]
stop on runlevel [06]
pre-start script
start mongodb-node replset=rs_local_a port=27017
start mongodb-node replset=rs_local_a port=27117
start mongodb-node replset=rs_local_a port=27217
sleep 3
mongo localhost:27017 /etc/mongo-initiate-localrs.js
@pior
pior / KinesisKeeper.rst
Last active August 29, 2015 14:06
Analytics

Kinesis Keeper

Whole idea

  • deploy with deb packages
  • no daemon (rely on an external process manager)
  • log into syslog
@pior
pior / keybase.md
Created September 30, 2014 14:28
keybase.md

Keybase proof

I hereby claim:

  • I am pior on github.
  • I am pior (https://keybase.io/pior) on keybase.
  • I have a public key whose fingerprint is 5F09 D929 05A5 B510 0A7C 57A1 35B8 10EC AA42 DE4C

To claim this, I am signing this object:

Logstash 1.4.2 snippet
dev=# create table pior.event_stage (
event_id CHAR(56),
user_id VARCHAR(20),
session_id VARCHAR(32),
ts timestamp NOT NULL DEFAULT sysdate
) ;
CREATE TABLE
dev=# insert into pior.event_stage VALUES ('event_123', 'user_123', 'session_123');
INSERT 0 1
@pior
pior / pyramid_main.py
Last active April 12, 2017 15:37
Keep your deployment secrets out of your PasterDeploy configuration using Environment Variables
import os
from pyramid.config import Configurator
def main(global_config, **settings):
settings = {k: os.path.expandvars(v) for k, v in settings.items()}
config = Configurator(settings=settings)
config.include(__name__)
return config.make_wsgi_app()
@pior
pior / random_key.py
Last active August 29, 2015 14:17
Random Key in python
import base64
import random
from binascii import unhexlify, b2a_base64
def long_to_bytes (val):
"""
Use :ref:`string formatting` and :func:`~binascii.unhexlify` to
convert ``val``, a :func:`long`, to a byte :func:`str`.
def make_bcp47_language_tag_re():
"""
Reference: http://www.rfc-editor.org/rfc/bcp/bcp47.txt#
Validator: http://schneegans.de/lv/
"""
regular = (r"(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka"
"|zh-min|zh-min-nan|zh-xiang)")
irregular = (r"(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon"
"|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR"
"|sgn-BE-NL|sgn-CH-DE)")
@pior
pior / gevent_urllib3_connectionpool_issue.py
Last active June 17, 2020 19:05
Issue with urllib3 connectionpool under gevent. New HTTPS connection take an abnormally long time to instantiate.
from gevent.monkey import patch_all
patch_all()
import sys
import time
import gevent
import requests
import logging
@pior
pior / arc.py
Last active August 30, 2024 09:02
Adaptive replacement cache implementation in Python
"""
ARC implementation
Based on
http://code.activestate.com/recipes/576532-adaptive-replacement-cache-in-python/
Original Paper
https://www.usenix.org/legacy/events/fast03/tech/full_papers/megiddo/megiddo.pdf
Warning: patented by IBM