Skip to content

Instantly share code, notes, and snippets.

View WilliamSampaio's full-sized avatar

William Sampaio WilliamSampaio

View GitHub Profile
@WilliamSampaio
WilliamSampaio / calcula_tempo_medio_em_segundos.sh
Created November 5, 2025 01:35
Filtra o tempo de duração dos logs gerados pelo Apache Hop e calcula a média em segundos.
#!/usr/bin/env bash
for file in ~/integracao_*.log; do tail -n 1 $file | awk '{print $9}'; done | awk '{ sum += $1 } END { if (NR > 0) print sum / NR }'
@WilliamSampaio
WilliamSampaio / index.html
Created July 30, 2025 12:04
Websocket SSH Go
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://unpkg.com/xterm/lib/xterm.js"></script>
<link rel="stylesheet" href="https://unpkg.com/xterm/css/xterm.css" />
<style>
body, html { margin: 0; height: 100%; background: black; }
#terminal { width: 100%; height: 100vh; }
</style>
package main
import (
"bufio"
"fmt"
"os"
"os/signal"
"sync"
"syscall"
"time"
@WilliamSampaio
WilliamSampaio / ssh_remote_terminal.go
Created July 16, 2025 17:10
Example of how to access the terminal via SSH with Go
package main
import (
"log"
"os"
"os/signal"
"golang.org/x/crypto/ssh"
"golang.org/x/term"
)
@WilliamSampaio
WilliamSampaio / convert.sql
Created February 27, 2025 19:48
Convert latin1 to UTF8 (MySQL)
SELECT
convert(cast(convert(t.field using latin1) as binary) using utf8)
FROM table t;
@WilliamSampaio
WilliamSampaio / xpath_with_javascript.html
Created August 25, 2024 03:19
An example of DOM manipulation with XPath and pure javascript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.male {
background-color: lightblue;
@WilliamSampaio
WilliamSampaio / canvas_fullscreen_responsive.html
Created July 2, 2024 18:56
Canvas Fullscreen Responsive
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canvas Fullscreen Responsive</title>
<style>
body {
margin: 0 !important;
@WilliamSampaio
WilliamSampaio / index.html
Created January 22, 2024 15:13
disable-f5-browser-refresh-js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Disable F5</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
@WilliamSampaio
WilliamSampaio / take_a_screenshot.py
Created December 4, 2023 00:23
Scripts to take a screenshot
# pip install pillow pyautogui
import pyautogui
from PIL import ImageGrab
def take_a_screenshot(filename):
try:
size = pyautogui.size()
ss_region = (0, 0, size[0], size[1])
@WilliamSampaio
WilliamSampaio / take_a_picture.py
Last active December 4, 2023 00:23
Scripts to take a pictures from webcam
# pip install opencv-python
import cv2
def take_a_picture(filename):
try:
cam = cv2.VideoCapture(0)
cv2.imwrite(filename, cam.read()[1])
except Exception as e: