Skip to content

Instantly share code, notes, and snippets.

View minskmaz's full-sized avatar

minskmaz

  • San Francisco
View GitHub Profile
@minskmaz
minskmaz / logstash_logger.py
Created October 28, 2015 16:46
python logstash logger with LogstashFormatterV1
formatter = LogstashFormatterV1()
log_path = '/tmp/es-client-info.log'
logger = logging.getLogger('elasticsearch')
logger.propagate = False
logger.setLevel(logging.INFO)
consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(formatter)
fileHandler = logging.handlers.RotatingFileHandler(log_path,
maxBytes=0.5*10**9,
backupCount=3)
{
"builders":[{
"type": "docker",
"image": "ubuntu:14.04",
"export_path": "image.tar"
}],
"provisioners":[
{
"type": "shell",
"inline": [
@minskmaz
minskmaz / gist:64a5ba5764e4b09ca6be
Last active October 20, 2015 20:40
Packer upload of "playbook_dir" to packer-provisioner-ansible-local folder fails
2015/10/20 13:29:04 ui:  docker: x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/DES.o -o build/lib.linux-x86_64-2.7/Crypto/Cipher/_DES.so
2015/10/20 13:29:04 ui:  docker: building 'Crypto.Cipher._DES3' extension
2015/10/20 13:29:04 ui:  docker: x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -Isrc/libtom/ -I/usr/include/python2.7 -c src/DES3.c -o build/temp.linux-x86_64-2.7/src/DES3.o
2015/10/20 13:29:04 ui:  docker: x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g
@minskmaz
minskmaz / pooled_memcache_connection.py
Created September 26, 2015 23:49
pooled memcache connection with zope utility for dependency injection
import Queue, memcache
from contextlib import contextmanager
from zope.interface import implements, Interface
from zope.component import getGlobalSiteManager
gsm = getGlobalSiteManager()
memcache.Client = type('Client', (object,), dict(memcache.Client.__dict__))
# Client.__init__ references local, so need to replace that, too
from hashlib import sha1
import hmac
import base64
import time
import random
import sys
import collections
import ConfigParser
import urllib
import random
@minskmaz
minskmaz / 0_reuse_code.js
Last active August 29, 2015 14:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@minskmaz
minskmaz / gist:7207f994a8a28451aeaa
Last active September 29, 2015 05:56
basic role based delegation of env object in python's Fabric - (untested but should work)
import os
import fabric
from fabric.api import *
from fabric.api import run, roles, execute
from fabric.operations import sudo
if env.ssh_config_path and os.path.isfile(os.path.expanduser(env.ssh_config_path)):
env.use_ssh_config = True
{
"layers": {
"0": {
"class": "ava",
"src": "results\/ava_Napa_County\/ava_Napa_County.shp"
},
"1": {
"class": "parcels",
"src": "results\/PARCELS_PUBLIC\/PARCELS_PUBLIC.shp"
}
@minskmaz
minskmaz / gist:8754062
Created February 1, 2014 15:56
Pika/tx publisher (broken - don't use)
import pika
from pika.adapters.twisted_connection import TwistedConnection
from pika.adapters.twisted_connection import TwistedProtocolConnection
from pika.connection import ConnectionParameters
from pika import BasicProperties
from twisted.internet.task import LoopingCall
from twisted.python import log
import logging
@minskmaz
minskmaz / gist:6708498
Created September 26, 2013 01:11
TWISTED LOGGING WITH PYTHON LOGGING LEVELS
import twisted
import logging
from twisted.python import log
### http://stackoverflow.com/questions/13748222/twisted-log-level-switch
class LevelFileLogObserver(log.FileLogObserver):
def __init__(self, f, level=logging.INFO):
log.FileLogObserver.__init__(self, f)