Skip to content

Instantly share code, notes, and snippets.

View luizbraga's full-sized avatar

Luiz Braga luizbraga

  • Mozio
  • Recife, PE
View GitHub Profile
@luizbraga
luizbraga / git-commit-template.txt
Last active March 9, 2020 18:52
Commit with branch name
# {{ BRANCH_NAME }}
# Extended commit message. (Optional)
# docs: (changes to documentation?)
# feat: (new feature?)
# fix: (bug fix?)
# refactor: (refactoring production code?)
# test: (adding missing tests, refactoring tests; no production code change):
# wip: (wip on feature branch?)
@luizbraga
luizbraga / dynamo_interface.py
Last active May 23, 2019 21:16
Python Dynamo Interface Class
from abc import ABC, abstractmethod
from copy import deepcopy
from boto3.dynamodb.conditions import Attr
class DynamoQuery:
def __init__(self, query_dict):
self.query_dict = query_dict
@luizbraga
luizbraga / agnoster.md
Last active November 7, 2017 15:35
Adding DOCKER_MACHINE_NAME and COMPOSE_FILE on zsh

Using Agnoster Theme:

Add the following on agnoster.zsh-theme:
prompt_docker_host() {
  if [[ ! -z "$DOCKER_MACHINE_NAME" ]]; then
    prompt_segment red default "\xF0\x9F\x90\xB3: '$DOCKER_MACHINE_NAME'"
  elif [[ ! -z "$DOCKER_HOST" ]]; then
 prompt_segment red default "\xF0\x9F\x90\xB3: '$DOCKER_HOST'"
@luizbraga
luizbraga / collection_size.py
Created October 4, 2017 14:43
List collections, size and count of documents on MongoDB
from pymongo import MongoClient
MONGO_URI = ''
DATABASE_NAME = ''
client = MongoClient(MONGO_URI)
db = client[DATABASE_NAME]
collections = db.collection_names()
def readable_size(file_size):
public String httpPost(String urlStr) throws IOException{
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
if (conn.getResponseCode() != 200){
throw new IOException(conn.getContentEncoding());
}
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();