Skip to content

Instantly share code, notes, and snippets.

@discort
discort / two_queues.py
Last active May 18, 2016 06:05
Cannot to line up item from one queue to another
# -*- coding:utf8 -*-
import time
import threading
import logging
from Queue import Queue, Full as FullQueue
from random import randrange
logging.basicConfig(level=logging.DEBUG,
format='%s(asctime)s (%(threadName)-2s) %(message)s')
"Multiple dispatch in Python with configurable dispatch resolution"
_AUTHOR=["David Mertz (mertz@gnosis.cx)",]
_THANKS_TO=[
"Tim Hochberg (tim.hochberg@ieee.org)",
"Samuele Pedroni (pedronis@bluewin.ch)",
]
_COPYRIGHT="""
This file is released to the public domain. I (dqm) would
appreciate it if you choose to keep derived works under terms
@discort
discort / pandas_dbms.py
Created August 3, 2016 14:17 — forked from catawbasam/pandas_dbms.py
Python PANDAS : load and save Dataframes to sqlite, MySQL, Oracle, Postgres
# -*- coding: utf-8 -*-
"""
LICENSE: BSD (same as pandas)
example use of pandas with oracle mysql postgresql sqlite
- updated 9/18/2012 with better column name handling; couple of bug fixes.
- used ~20 times for various ETL jobs. Mostly MySQL, but some Oracle.
to do:
save/restore index (how to check table existence? just do select count(*)?),
finish odbc,
Dockerfile + Node.js Examples
@discort
discort / .travis.yml
Created August 31, 2016 11:10
Example of travis config - https://github.com/madflojo/blog
language: python
python:
- 2.7
services:
- docker
hosts:
- feed.bencane.com
- bencane.com
@discort
discort / amazonctl.py
Created August 31, 2016 12:55 — forked from jtpaasch/amazonctl.py
A collection of functions commonly used to do AWS stuff.
# -*- coding: utf-8 -*-
"""A simple tool to document how to control AWS resources.
AWS AUTHENTICATION
-------------------
In order to run any of the code below, you need a profile with AWS credentials
set up on your computer. It's very easy to do this. Google how to configure
your profile with boto3, or visit the docs:
#!/usr/bin/env bash
# more bash-friendly output for jq
JQ="jq --raw-output"
configure_aws_cli(){
aws --version
aws configure set default.region us-east-1
@discort
discort / hash_table.py
Created February 4, 2017 21:05
Implemention of the hash table with the open adressing
"""
Implemention of the hash table with the open adressing
"""
NIL = 'NIL'
DELETED = 'deleted'
C1 = 2
C2 = 3
INF = float('inf')
def merge(A, p, q, r):
L = A[p:q + 1]
R = A[q + 1:r + 1]
L.append(INF)
R.append(INF)
i = j = 0
for k in range(p, r + 1):
def merge(A, p, q, r):
L = A[p:q + 1]
R = A[q + 1: r + 1]
i = j = 0
for k in range(p, r + 1):
if i == len(L):
A[k] = R[j]
j += 1
elif j == len(R):
A[k] = L[i]