Skip to content

Instantly share code, notes, and snippets.

View macedd's full-sized avatar
🐋
Data centric developer

Thiago Macedo macedd

🐋
Data centric developer
View GitHub Profile
@macedd
macedd / CalculateStatisticsCommand.php
Created June 22, 2022 02:53
Laravel test for aggregating analytical data on software
<?php
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Cache;
/**
* Laravel command to calculate and cache logs statistics
*/
class CalculateStatisticsCommand extends Command {
@macedd
macedd / printer.py
Created June 24, 2020 22:08
Python Epson Printer on Windows
import os, sys
import win32print
import StringIO
printer_name = win32print.GetDefaultPrinter()
hPrinter = win32print.OpenPrinter(printer_name)
def prn_txt(text):
if sys.version_info >= (3,):
@macedd
macedd / Dockerfile
Created May 4, 2020 02:27
Docker X11 Forwarding
FROM debian:jessie
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y x11-apps
@macedd
macedd / balancing.py
Last active March 4, 2020 22:32
Python Brackets Balancing Excercise
class UnbalancedBlockException(Exception):
pass
'''Representation of a brackets block and a node in the tree'''
class Block(object):
def __init__(self, char, parent):
self.initiator = char
self.children = []
self.parent = parent
# attach to the parent block
@macedd
macedd / app.py
Created March 2, 2020 14:01
Flask Ensure Domain (redirect) Middleware
import flask
import middleware
app = flask.create_app(os.path.dirname(__file__))
app.wsgi_app = middleware.EnsureDomainMiddleWare(app.wsgi_app)
@macedd
macedd / lambda_deploy.yml
Created February 18, 2020 05:03
Github Actions and Lambda Deployment (CD)
on:
push:
branches:
- master
paths:
- '**.py'
- '.github/workflows/lambda_deploy.yml'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@macedd
macedd / Job.php
Created November 6, 2019 22:07
Laravel Queue Instrumentation Trait
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Log;
@macedd
macedd / dumm.md
Created June 26, 2019 17:11
Design Responsive e Mobile-first

Design Responsivo

O conceito de design responsivo, originalmente cunhado pela Ethan Marcote em 2010, descreve uma técnica na qual o design de um site é ajustado automaticamente com base no tamanho das telas dos usuários.

Dica rápida: você pode determinar se um site é ou não responsivo ao ampliar ou reduzir manualmente a janela do navegador.

Exemplos de Responsividade:

@macedd
macedd / helpers.py
Last active March 24, 2019 11:29
Normalize nested Json into Flat dict structure
def json_flat(item, nest=''):
new = {}
for k,v in item.iteritems():
key = '%s_%s' % (nest, k) if nest else k
if isinstance(v, dict):
new.update(json_flat(v, k))
else:
new[key] = v
return new
@macedd
macedd / Dockerrun.aws.json
Created February 6, 2019 22:31
AWS ECS / Beanstalk Docker syslog LogDriver
{
"AWSEBDockerrunVersion": "1",
"dnsServers": [ "8.8.8.8" ],
"Volumes": [
{
"HostDirectory": "/var/app/current",
"ContainerDirectory": "/usr/src/app"
},
{
"HostDirectory": "/tmp",