Skip to content

Instantly share code, notes, and snippets.

View Aphellirus's full-sized avatar
👽
May the forks be with you

Matheus Moreira Aphellirus

👽
May the forks be with you
View GitHub Profile
@Aphellirus
Aphellirus / aws_delete_default_vpc.sh
Created March 6, 2023 06:59
Script to delete all AWS default VPCs from all regions using AWS CLI
#!/usr/bin/env bash
REGIONS='us-east-1 (N. Virginia)
us-east-2 (Ohio)
us-west-1 (California)
us-west-2 (Oregon)
eu-central-1 (Frankfurt)
eu-west-1 (Ireland)
eu-west-2 (London)
eu-west-3 (Paris)
@Aphellirus
Aphellirus / package_filetype.go
Created October 27, 2022 19:05
How to know the file extension from byte array in golang
//contents []byte
//package filetype
kind, err := filetype.Match(contents)
@Aphellirus
Aphellirus / custom_middleware_echo.go
Created October 16, 2022 20:58
Custom Middleware Echo Golang
package middlewares
import (
"net/http"
"github.com/labstack/echo/v4"
)
// ServerHeader middleware adds a `Server` header to the response.
func MubashirMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
@Aphellirus
Aphellirus / download_protected_google_drive_pdf.go
Created December 16, 2021 19:17
Code to download a protected google drive pdf
let jspdf = document.createElement("script");
jspdf.onload = function () {
let pdf = new jsPDF();
let elements = document.getElementsByTagName("img");
for (let i in elements) {
let img = elements[i];
console.log("add img ", img);
if (!/^blob:/.test(img.src)) {
console.log("invalid src");
continue;
@Aphellirus
Aphellirus / goroutines.go
Created October 17, 2021 21:55
Goroutines are lightweight threads
// Goroutines are lightweight, costing little more than the allocation of stack space.
// The stacks start small and grow by allocating and freeing heap storage as required.
// Internally goroutines act like coroutines that are multiplexed among multiple operating system threads.
// If one goroutine blocks an OS thread, for example waiting for input, other goroutines in this thread will migrate so that they may continue running.
// -----------------------------------------------------------------------------------------------------------------
// You can start a new thread of execution, a goroutine, with the go statement.
@Aphellirus
Aphellirus / google_drive_file_downloader.py
Created August 30, 2021 19:26
Helps to download google drive files with ease 🎉
# Installing the Package:
pip install googleDriveFileDownloader
# Sample code:
from googleDriveFileDownloader import googleDriveFileDownloader
gdownloader = googleDriveFileDownloader()
gdownloader.downloadFile("https://drive.google.com/uc?id=1O4x8rwGJAh8gRo8sjm0kuKFf6vCEm93G&export=download")
@Aphellirus
Aphellirus / ruby_bundler_inline.rb
Created August 25, 2021 07:12
bundler/inline for automation in Ruby
=begin
With bundler/inline there is no need to use external gems
it lets you download/install/activate gems directly in the script
skipping the need to handle bundle install or call it through bundle exec
=end
require 'bundler/inline'
@Aphellirus
Aphellirus / build.md
Last active July 29, 2021 08:10
Docker Cheat sheet
Command Description
docker build -t myimage:1.0 Build an image from the Dockerfile in the current directory and tag the image
docker image ls List all images that are locally stored with the Docker Engine
docker image rm alpine:3.4 Delete an image from the local image store
@Aphellirus
Aphellirus / object-control.cs
Created July 27, 2021 07:24
Controling an Object's movement through Keyboard input
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class objectControl : MonoBehaviour
{
public float speed = 3.0f;
void Update()
{
@Aphellirus
Aphellirus / object-transform.cs
Created July 27, 2021 07:21
Every object in a Scene has a Transform. We can use it to store and manipulate the position, rotation and scale of the object.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectTransform : MonoBehaviour
{
// Start is called before the first frame update
private Vector3 startPosition;
public bool changePosition, moveInCircles;