Skip to content

Instantly share code, notes, and snippets.

View macedd's full-sized avatar
🐋
Looking for growth opportunities

Thiago F Macedo macedd

🐋
Looking for growth opportunities
View GitHub Profile
@macedd
macedd / CalculateStatisticsCommand.php
Created June 22, 2022 02:53
Laravel test for aggregating analytical data on software
View CalculateStatisticsCommand.php
<?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
View printer.py
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
View Dockerfile
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
View balancing.py
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
View app.py
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)
View lambda_deploy.yml
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
View Job.php
<?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
View dumm.md

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
View helpers.py
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
View Dockerrun.aws.json
{
"AWSEBDockerrunVersion": "1",
"dnsServers": [ "8.8.8.8" ],
"Volumes": [
{
"HostDirectory": "/var/app/current",
"ContainerDirectory": "/usr/src/app"
},
{
"HostDirectory": "/tmp",