Skip to content

Instantly share code, notes, and snippets.

View maurobaraldi's full-sized avatar

Mauro Navarro Baraldi maurobaraldi

View GitHub Profile
@maurobaraldi
maurobaraldi / README.md
Created June 11, 2020 20:23 — forked from DocX/README.md
Connect to bash inside running ECS container by cluster and service name
@maurobaraldi
maurobaraldi / docker-stats-json.md
Last active July 30, 2021 16:48 — forked from KyleBanks/docker-stats-json
Returns Docker stats as a JSON Object

Docker Status Command Line Mode

docker stats --no-stream --format "{\"container\": \"{{ .Container }}\", \"memory\": { \"raw\": \"{{ .MemUsage }}\", \"percent\": \"{{ .MemPerc }}\"}, \"cpu\": \"{{ .CPUPerc }}\"}"

Docker Status Command Line Mode + Date - JSON format

docker stats --no-stream --format "{\"container\": \"{{ .Container }}\", \"name\": \"{{ .Name }}\", \"memory\": { \"raw\": \"{{ .MemUsage }}\", \"percent\": \"{{ .MemPerc }}\"}, \"cpu\": \"{{ .CPUPerc }}\"}###" | sed "s/}###/, \"date\": $(date \"+%d\/%m\/%Y %H:%M\")},/g" >> /home/mauro/docker_homolog_status.json

@maurobaraldi
maurobaraldi / Makefile
Created December 4, 2019 17:06 — forked from prwhite/Makefile
Add a help target to a Makefile that will allow all targets to be self documenting
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
# Everything below is an example
target00: ## This message will show up when typing 'make help'
@echo does nothing
FROM python:2.7-alpine
MAINTAINER Nick Janetakis <[email protected]>
ENV INSTALL_PATH /bsawf
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
COPY requirements.txt requirements.txt
RUN apk add --no-cache --virtual .build-deps \
@maurobaraldi
maurobaraldi / tweepy_runner.py
Created October 28, 2019 02:06 — forked from MihaiTabara/tweepy_runner.py
Script to download Twitter timeline for a user and store it to MongoDB
# script to download up to <= 3200 (the official API limit) of most recent tweets from a user's timeline
from pymongo import MongoClient
import tweepy
import json
#Twitter API credentials
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN = ''
@maurobaraldi
maurobaraldi / BracketsUtils.java
Created May 28, 2019 20:33 — forked from caandradeduarte/BracketsUtils.java
BairesDev test - Given a string with brackets. If the start index of the open bracket is given, find the index of the closing bracket
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Stack;
public class BracketsUtils {
private static final char OPENING_BRACKET = '[';
private static final char CLOSING_BRACKET = ']';
public static int findClosingBracket(String text, int openingBracketIndex) {
@maurobaraldi
maurobaraldi / simpletree.py
Created February 27, 2019 22:41 — forked from jsbueno/simpletree.py
Simple example of ranged binary tree in Python, able to perform slice retrieval
# coding: utf-8
class EmptyClass(object):
def __repr__(self):
return ""
Empty = EmptyClass()
class Node(object):
def __init__(self, value, key=None):
@maurobaraldi
maurobaraldi / bubble.py
Created September 19, 2018 23:25 — forked from jootse84/bubble.py
Bubble sort recursive implementation in Python
def bubble(l_elems, is_sorted, step):
if step is 1 or is_sorted:
# base case: l_elems is already sorted or we pass through the list len(l_elems) times
return l_elems
else:
is_swapped = False
for i in range(len(l_elems) - 1):
# compares each pair of adjacent items and swaps them if they are in the wrong order
if l_elems[i] > l_elems[i + 1]:
is_swapped = True
@maurobaraldi
maurobaraldi / product.py
Created August 13, 2018 15:48 — forked from gregglind/product.py
Recursive python "product"
"""
this has a lot of list / tuple casting, and doesn't use
native python list properties to full advantage.
It mimics Little Schemer style coding quite well though.
"""
import itertools
@maurobaraldi
maurobaraldi / LRU.py
Created June 21, 2018 14:09 — forked from reterVision/LRU.py
LRU algorithm implemented in Python.
from datetime import datetime
class LRUCacheItem(object):
"""Data structure of items stored in cache"""
def __init__(self, key, item):
self.key = key
self.item = item
self.timestamp = datetime.now()