Skip to content

Instantly share code, notes, and snippets.

View josuebrunel's full-sized avatar

Josue Kouka josuebrunel

View GitHub Profile
from dateutil.parser import parse as dateutil_parse
from lxml import etree, objectify as xobject
def is_clean(element):
if not element.getchildren() and element.text is None:
return False
return all(is_clean(child) for child in element.iterchildren())
@rkrzr
rkrzr / auto_tags.py
Last active August 12, 2025 21:23
Automatically generate ansible tags of the same name for each role in a playbook
"""
This module implements an Ansible plugin that is triggered at the start of a playbook.
The plugin dynamically generates a tag for each role. Each tag has the same name as its role.
The advantage of this is that it saves you some boilerplate, because you don't have to wrap
all tasks of a role in an additional block and assign a tag to that.
Additionally, it works automatically when you add new roles to your playbook.
Usage is exactly the same as without this plugin:
@xmlking
xmlking / docker-compose.yml
Last active March 24, 2023 01:12
cassandra healthcheck and dependency for docker compose
version: '2.1'
services:
cassandra:
image: cassandra:latest
networks:
- reactive-network
volumes:
- cassandra_data:/var/lib/cassandra
# - ${PWD}/data/cassandra/data:/var/lib/cassandra
@asfaltboy
asfaltboy / conftest.py
Last active March 30, 2022 23:52
A pytest fixture to test Django data migrations
# based on https://gist.github.com/blueyed/4fb0a807104551f103e6
# and on https://gist.github.com/TauPan/aec52e398d7288cb5a62895916182a9f (gistspection!)
from django.core.management import call_command
from django.db import connection
from django.db.migrations.executor import MigrationExecutor
import pytest
@vasanthk
vasanthk / System Design.md
Last active August 14, 2025 19:13
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@fmasanori
fmasanori / QEduAvancada2.py
Last active October 22, 2019 17:11
QEdu exemplo de Busca Avançada: escolas, em funcionamento, sem água, energia e esgoto, mostrando alguns detalhes
#The context of this program is a course of an hour to journalists who know nothing about programming in a lab with Python 3 only.
import urllib.request
import json
def analisa_detalhe(cod):
url = 'http://educacao.dadosabertosbr.com/api/escola/'
resp = urllib.request.urlopen(url+str(cod)).read()
resp = json.loads(resp.decode('utf-8'))
if int(resp['salasExistentes']) > 1:
print ('Salas Existentes:', resp['salasExistentes'])
raise error("bad character range")
sre_constants.error: bad character range
@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 28, 2025 12:54
Golang landmines

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@josuebrunel
josuebrunel / mylogger.sh
Last active August 29, 2015 14:16
Time added to log message
##################################################
#
# Author : josue
# Filename : mylogger.sh
# Description : custom logger for my shell scripts
# Creation Date : 26-02-2015
# Last Modified : Mon 09 Mar 2015 12:29:41 PM CDT
#
##################################################
@josuebrunel
josuebrunel / python_db_logger.py
Last active August 29, 2015 14:11
Python : Logging into Database
import logging
import traceback
import logging.handlers
from logging import Handler, Logger
import sqlalchemy
from sqlalchemy.sql import func
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, DateTime