Skip to content

Instantly share code, notes, and snippets.

View matheusfillipe's full-sized avatar

Matheus Fillipe matheusfillipe

View GitHub Profile
@matheusfillipe
matheusfillipe / metacritic_search.sh
Last active April 19, 2024 21:05
Metacritic scrapper with bash and htmlq
#!/usr/bin/env bash
query="Final%20Fantasy"
user_agent='user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'
results=$(curl "https://www.metacritic.com/search/$query/?page=1&category=3" -H "$user_agent" | htmlq 'div.c-pageSiteSearch-results a' -a href | xargs printf "https://www.metacritic.com%s\n" % '_')
item () {
name="$1"
@matheusfillipe
matheusfillipe / gist:1d907272717201501eafe0e91b858176
Created October 28, 2023 19:50
Unreal Engine nvim wrapper for ue4cli (Completion + Debugger with vimspect)
# #!/usr/bin/env bash
# Based on https://gist.github.com/chillpert/1a76ae8e9cfafb36d3bf9e343d32fedc
# Expand ue4cli
ue() {
ue4cli=$(which ue4)
engine_path=$($ue4cli root)
UPROJECT_PATH=$(realpath $(find . -name *.uproject))
DEBUG_BINARY_PATH="/Users/Shared/Epic Games/UE_5.3/Engine/Binaries/Mac/UnrealEditor-Mac-DebugGame.app/Contents/MacOS/UnrealEditor-Mac-DebugGame"
project_name=$(basename "$UPROJECT_PATH" | sed 's/.uproject//')
@matheusfillipe
matheusfillipe / pydantic_crash_course.py
Last active November 25, 2022 23:20
A python crash course demo for how to parse, validate, convert fields data, convert field names and serialize json/dicts using pydantic.
from datetime import datetime, timedelta
from pydantic import BaseModel, Field, validator, ValidationError
# Random json data or something
person_json = {
"name": "John Doe",
"age": 30,
"address": {
"street": "Main Street",
"city": "New York",
@matheusfillipe
matheusfillipe / aurpdate.sh
Last active June 29, 2023 13:22
Update AUR packages automatically
#!/bin/bash
set -e
git pull
ver=$(git describe --tags --abbrev=0 | sed 's/-/_/g')
echo "Version is $ver"
update () {
sed -i "s/^pkgver.\+\$/pkgver=$ver/g" PKGBUILD
git remote set-url origin "$(git remote get-url origin | sed 's#^https://#ssh://aur@#')"
@matheusfillipe
matheusfillipe / apache2_access_log_analizer.py
Last active October 25, 2022 17:05
Parse the logs from apache access log and count the most acessing ip while the script it is running
#!/usr/bin/python3
import subprocess
from os import system
import re
from dataclasses import dataclass
from datetime import datetime
from collections import Counter
LOGFILE = "/var/log/apache2/live-access_log"
@matheusfillipe
matheusfillipe / leibniz_pi.lisp
Last active July 15, 2022 00:26
Compute pi with common lisp using leibnix formula
;; Way to compute pi in common lisp using Leibniz formula
(defun ^ (x n)
(if (> n 0)
(* x (^ x (- n 1)))
(if (< n 0)
(* (/ 1 x) (^ x (+ n 1)))
1)))
(defun oddnum (n) (+ (* 2 n) 1))
@matheusfillipe
matheusfillipe / autorertart.sh
Last active July 9, 2022 06:25
Auto restart process on high cpu or if check command is failing
#!/usr/bin/env bash
# YPTSOCKET
TOP=20
YPTSOCKET=/var/www/html/AVideo/plugin/YPTSocket/server.php
MAXCPU=80.0
CPUSERVICE=ytsocket.service
# APACHE
@matheusfillipe
matheusfillipe / main.dart
Last active June 8, 2022 21:20
Irc client in dart with null safety
import 'dart:convert';
import "package:irc/client.dart";
import "dart:io";
// This stores our configuration for this client
var config = Configuration(
host: "irc.dot.org.es",
port: 6697,
ssl: true,
@matheusfillipe
matheusfillipe / portfoward.go
Last active May 3, 2022 05:31
Go port fowarding
package main
import (
"os"
"bufio"
"fmt"
"log"
"net"
)
@matheusfillipe
matheusfillipe / proofOfWork.js
Last active April 26, 2022 23:49
Simple proof of work concept using javascript
// Proof or work
const difficulty = 3
async function sha256(message) {
const msgBuffer = new TextEncoder().encode(message);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
return hashHex;
}