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 / write-stdin.sh
Created February 1, 2016 12:27
Write to STDIN of running Process
## Alternative 1: write to file descriptor (not usable)
input='testing'
pid=1212
echo $input > /proc/$pid/fd/0
## Alternative 2: Pipe fifo to the app
fifo_file=/tmp/fifo
@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 / 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 / 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 / websocket-heartbeat-client.js
Created January 18, 2019 16:04
WebSockets heartbeat implementation (nodejs + browser)
/**
* Tracks server pings for determining if the connection dropped.
* Will terminate non-responsive connections.
* This close event should initiate the process of recreating the connection in the ws module manager (eg ws/user.js and modules/ws-user.js)
*/
function setupWsHeartbeat(ws) {
// will close the connection if there's no ping from the server
function heartbeat() {
clearTimeout(this.pingTimeout);
@macedd
macedd / yaffey-qt5.patch
Created June 11, 2014 23:38
Yaffey Patch for QT5 Compilation (ubuntu 12, 13, 14)
diff -rupN yaffey-orig/main.cpp yaffey-qt5/main.cpp
--- yaffey-orig/main.cpp 2014-06-11 20:01:50.155769286 -0300
+++ yaffey-qt5/main.cpp 2014-06-11 20:24:07.659482714 -0300
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
-#include <QtGui/QApplication>
+#include <QApplication>
@macedd
macedd / SessionTest.php
Last active October 29, 2021 08:30
Laravel Unit Testing with persistent SessionID
<?php
class ApiTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->session_id = session()->getId();
@macedd
macedd / git_stats_generate.sh
Last active September 21, 2021 06:43
Generate Stats for a Git Repository
# Tools installation
pip install gitinspector
gem install git_stats
# Generate the reports
cd git_proj
git_stats generate
gitinspector -f php,js,less -F html > git_stats/inspector.html
# Generate time-sheets
@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 / 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