Skip to content

Instantly share code, notes, and snippets.

Avatar

Emanuele Palazzetti palazzem

View GitHub Profile
@palazzem
palazzem / docker-compose.yml
Created Mar 22, 2020
Traefik in network_mode: host
View docker-compose.yml
version: "3.7"
services:
traefik:
image: "traefik:v2.2"
container_name: "traefik"
command:
- "--accesslog=true"
- "--api.insecure=true"
- "--entrypoints.web.address=:80"
@palazzem
palazzem / agent-install.sh
Last active Jan 9, 2020
Datadog Agent ARMv7 post-build
View agent-install.sh
# Install the Datadog Agent
mkdir -p /opt/datadog-agent/
mkdir -p /var/log/datadog/
mv ~/agent-armv7-package/agent /opt/datadog-agent/
mv ~/agent-armv7-package/dist /opt/datadog-agent/
mv ~/agent-armv7-package/datadog-agent /etc/
# Create dd-agent user and set permissions
addgroup dd-agent
adduser --system --no-create-home --disabled-password --ingroup dd-agent dd-agent
View pygotham_talk_handler.py
class Handler(object):
async def handle_request(self, request):
# set the current context
ctx = {}
set_current_context(ctx)
ctx['username'] = request.get('username', 'Anonymous')
result = await retrieve_user_data()
return result
@palazzem
palazzem / pygotham_asyncio_full_app.py
Created Oct 5, 2017
pygotham_asyncio_full_app.py
View pygotham_asyncio_full_app.py
import asyncio
def set_current_context(ctx, loop=None):
# retrieves the current Task
loop = loop or asyncio.get_event_loop()
task = asyncio.Task.current_task(loop=loop)
# attach the Context to the task!
setattr(task, '__current_ctx', ctx)
@palazzem
palazzem / datadog_kickstarter_metrics.py
Created May 25, 2017
[datadog] kickstarter_metrics.py
View datadog_kickstarter_metrics.py
import requests
from datetime import datetime, timedelta
from datadog import initialize, statsd
options = {
'api_key':'your_datadog_key_here',
}
# don't use a trailing slash
View keybase.md

Keybase proof

I hereby claim:

  • I am palazzem on github.
  • I am palazzem (https://keybase.io/palazzem) on keybase.
  • I have a public key ASCRinl2svThLRKvJf0vYiwH9MD2-ReufZWfDBN5uVvMIwo

To claim this, I am signing this object:

@palazzem
palazzem / pygotham_context_propagator.py
Last active Oct 5, 2017
pygotham_context_propagator.py
View pygotham_context_propagator.py
import asyncio
def set_current_context(ctx, loop=None):
# retrieves the current Task
loop = loop or asyncio.get_event_loop()
task = asyncio.Task.current_task(loop=loop)
# attach the Context to the task!
setattr(task, '__current_ctx', ctx)
def get_current_context(loop=None):
View server.py
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function, \
unicode_literals
from concurrent.futures import ThreadPoolExecutor
from ddtrace import tracer
from ddtrace.contrib.tornado import trace_app
from random import uniform
from time import sleep
View runinenv.sh
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
if [ -f ${VENV}/bin/postactivate ]; then
. ${VENV}/bin/postactivate
@palazzem
palazzem / ca_selfsigned_server.sh
Last active Aug 29, 2015
Generate a self-signed certificate with a custom CA
View ca_selfsigned_server.sh
#! /bin/bash
# Bash script to create a self signed CA and a server certificate
# This script is unattended and (for this reason), the CA key
# doesn't require any password to be used. This is __NOT__ a good
# behaviour in a production environment so USE IT AT YOUR OWN RISK!
# Configure CA structure
mkdir -m 0700 -p \
./demoCA/private \