Skip to content

Instantly share code, notes, and snippets.

View willnaoosmith's full-sized avatar
🐧
Torvalds take the wheel 🙏🏻

William Brochensque Júnior willnaoosmith

🐧
Torvalds take the wheel 🙏🏻
View GitHub Profile
@willnaoosmith
willnaoosmith / Linux Compiler
Created March 24, 2022 19:46
Compile Python script to Linux binary using Cython
pip install cython
cython main.pyx --embed
gcc main.c -I /usr/include/python3.10/ -L /lib/x86_64-linux-gnu/ -l python3.10 -o main
chmod +x main
@willnaoosmith
willnaoosmith / console.log in php
Created June 10, 2022 17:33
Debug with console.log in php
echo "<script>console.log('Debug Objects: " . $output . "' );</script>";
@willnaoosmith
willnaoosmith / Javascript FizzBuzz
Created July 12, 2022 16:38
Yet another FizBuzz in JS
number = 0
switch(true){
case number % 3 == 0 && number % 5 == 0:
console.log("FizzBuzz")
break
case number % 3 == 0:
console.log("Fizz")
break
@willnaoosmith
willnaoosmith / gist:552d5d4f570aa25f5a85de8c1bdf6c98
Created October 18, 2022 20:22
Command that can help on searching manuals for a command. Put this on your ~/,bash.rc and run as follow: man commandhere.
man(){
curl cheat.sh/$1
}
@willnaoosmith
willnaoosmith / selenium basic setup
Last active December 8, 2023 12:31
selenium basic setup
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
from selenium import webdriver
from time import sleep
import os
try:
options = Options()
options.add_argument("--headless")
@willnaoosmith
willnaoosmith / smtplib simple setup
Last active November 9, 2023 11:17
smtplib simple setup
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formataddr
import smtplib
msg = MIMEMultipart()
msg['Subject'] = "Subject"
msg['From'] = formataddr(('from name here', 'from@from.com'))
msg['To'] = "addresstoreceive"
@willnaoosmith
willnaoosmith / DownloadWebsite
Created February 6, 2023 18:50
Using wget to download an entire website without downloading any unecessary links and making it work offline.
wget --recursive --no-clobber --page-requisites --html-extension --convert-links --domains websitehere.org --no-parent https://websitehere.org
@willnaoosmith
willnaoosmith / FreeSpaceCleanerCommand
Created April 13, 2023 10:43
Set Linux system log size to 50 MB, clear it, and delete the cache
sudo sed -i "s/#SystemMaxUse=/SystemMaxUse=50M/" /etc/systemd/journald.conf && sudo systemctl kill --kill-who=main --signal=SIGUSR2 systemd-journald.serviceudo systemctl restart systemd-journald.service && sudo systemctl restart systemd-journald.service && rm -rf ~/.cache/*
@willnaoosmith
willnaoosmith / metaupdate.sh
Created April 13, 2023 11:59
bash script to automatically download an Metabase version and reload the instance running as a Service.
#!/usr/bin/env bash
if [[ $1 == "" ]] ; then
echo 'Incorrect command. Make sure to pass the version as a parameter. USAGE: metaupdate VersionHere'
exit 0
fi
cd /usr/share/metabase/
sudo systemctl stop metabase
rm metabase.jar
@willnaoosmith
willnaoosmith / RunAsService.txt
Last active May 25, 2023 12:20
How to run any script or command as a service on linux
1. Create your .service file using:
sudo nano /lib/systemd/system/YourServiceNameHere.service
2. Inside your .service file, write the following:
[Unit]
Description=YourDescriptionHere
[Service]
WorkingDirectory=YourWorkingDirectoryHere