Skip to content

Instantly share code, notes, and snippets.

View maatthc's full-sized avatar

Alexandre Andrade maatthc

  • MaaT Tech
  • Melbourne
View GitHub Profile
@maatthc
maatthc / aws-websockets-api-gw-mock.yaml
Last active April 30, 2024 18:13
Basic WebSocket mock in AWS ApiGateway using CloudFormation in AWS
AWSTemplateFormatVersion: '2010-09-09'
Description: |
AWS CloudFormation template for Mock WebSocket API Gateway. When deploying this stack please remember to check the option:
- I acknowledge that AWS CloudFormation might create IAM resources.
This template can help you to solve issues like:
- CloudWatch Logs role ARN must be set in account settings to enable logging
- Execution failed due to configuration error: statusCode should be an integer which defined in request template
- This custom domain name cannot map to WEBSOCKET protocol APIs
- Error during WebSocket handshake: Unexpected response code: 500
@maatthc
maatthc / add_usb_drive_to_retroarch_media_folder_install.sh
Last active March 29, 2024 06:27
LG WebOStv - Play games on RetroArch from USB drive
#!/bin/bash
# === For rooted LG TVs with WebOsBrew installed only ===
#
# On LG WebOStv, RetroArch only have access to a few jailed folders so to run games on a usb drive,
# we need to 'merge' the USB mounting point with one of those jailed folders using OverlayFS.
# The scripts on folder '/var/lib/webosbrew/init.d/' will run after every tv boot.
# Remove the $STARTUP_FOLDER/$SCRIPT_TO_RUN_AFTER_BOOT and reboot to revert the change.
#
# Tested on 7.3.0-03.30.72
#
@maatthc
maatthc / api-gw-template.yml
Last active October 13, 2023 14:52
AWS CloudFormation template example for allowing uploading files to S3 via API Gateway
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
ApiGatewayStack:
Description: The stack where the api gateway rest api is defined
Type: String
Default: dev-maat-apigw-app
EventBucket:
Type: String
Default: dev-maat-bucket
CorsAllowOrigin:
@maatthc
maatthc / url.test.ts
Created August 30, 2021 04:05
TypeScript Jest Window Location mocking
import urlBuilder from './url'
let location: Location
describe('urlBuilder', () => {
beforeEach(() => {
location = window.location
jest.spyOn(window, 'location', 'get').mockRestore()
})
@maatthc
maatthc / async_tasks.py
Created February 8, 2020 11:16
Running asynchronous functions (coroutines) with Python 3 - similarly with JavaScript Promise.all
import asyncio
import random
loop = asyncio.get_event_loop()
async def execute_task():
time_out = random.uniform(0.5, 5)
print("Starting {:1.2f}..".format(time_out))
await asyncio.sleep(time_out)
print("Stoping {:1.2f}..".format(time_out))
version: "3.7"
x-vars:
- &TZ
TZ=Australia/Melbourne
- &DnsRestart
restart: always
extra_hosts:
- "tv.home:192.168.0.99"
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
if [[ $AWS_SESSION_TOKEN ]]; then
AWS="$FG[208] [AWS]$reset_color ";
fi
PROMPT='%{$fg[$NCOLOR]%}%n%{$reset_color%}@%{$fg[cyan]%}%m\
%{$reset_color%}:%{$fg[magenta]%}%~\
$(git_prompt_info) \
@maatthc
maatthc / sad.js
Last active November 19, 2022 09:25
Search and Destroy - Free up disk space deleting "node_modules" folders recursively
#!/usr/bin/env node
// Search and Destroy
//
const path = require('path')
const fs = require('fs')
const createPackageJson = () => {
const packageJsonContent = `
{
"name": "sad",
@maatthc
maatthc / eachine-ex4-bond-ip.py
Last active May 9, 2022 07:27
To connect to Eachine EX4 using Qgroundcontrol/MAVlink running on a computer, first run this script.
import socket
from time import sleep
DRONE_IP = '172.50.10.1'
DRONE_BOND_PORT = 4646
RESET_CMD=b'{"CMD":0,"PARAM":-1}\n'
BOND_CMD=b'{"CMD":89,"PARAM":1}\n'
EXPECTED_SERVER_RESPONSE = '{ "CMD": 89, "PARAM": -1, "RESULT": 1 }'
@maatthc
maatthc / Dockerfile_Python_Mysql_Django
Created June 12, 2016 16:16
Dockerfile to build Python / Django / Mysql small container images . Based on Linux Alpine.
############################################################
# Dockerfile to build Python / Django / Mysql small container images
# Based on Linux Alpine
############################################################
# Set the base image
FROM alpine
# File Author / Maintainer
MAINTAINER Alexandre Andrade aleandrade@gmail.com