Skip to content

Instantly share code, notes, and snippets.

View samukasmk's full-sized avatar

Samuel Sampaio samukasmk

View GitHub Profile
@samukasmk
samukasmk / README.md
Last active November 13, 2025 17:46
Simple soketi usage samples

Soketi - Simple usage samples

Soketi is used as a websocket server to handle notifications from backend in this simple case python to frontend. Using websocket protocol.

This simple gist explain how to use it in practice.

1. Define files bellow

  • compose.yaml: to run socketi server using docker compose
  • webpage.html: the HTML page with JS code to bind socketi events
  • send_soketi_event.py: the python script to send socketi events to socketi server that will be arrived in webpage.html
@samukasmk
samukasmk / slow-running-queues.js
Created October 31, 2025 19:12
[javascript] Sample of runner queue to ensure which async function will run non parallel just after another
// Helper: wait for a given number of milliseconds
function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Simple FIFO queue with O(1) enqueue/dequeue (amortized)
class Queue {
constructor() {
this.items = [];
this.head = 0;
@samukasmk
samukasmk / Loading - Spinning.html
Created October 29, 2025 18:01
Sample of loading spinning
<!-- https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_loader -->
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.loader {
border: 5px solid #f3f3f3;
border-radius: 50%;
@samukasmk
samukasmk / mongodb-slow-queries-monitor.py
Created August 8, 2025 15:00
Simple script in python to get slow queries in mongodb
import re
import datetime
from pymongo import MongoClient
from bson import json_util
# define settings
mongodb_uri = "mongodb://<mongodb-user>:<mongodb-password>@<mongodb-host>:<mongodb-port>"
secs_running = 3
db_prefix = 'my-db'
@samukasmk
samukasmk / taro-simples.sh
Last active June 27, 2025 14:59
Do fundo do baú: Puxando Cartas de Tarot em Bash Script avançado (de 2012, a 13 anos atrás)
#!/bin/bash
#
# Desenvolvido por: Samuel Maciel Sampaio [2012.05.01]
# Contato: <[email protected]>
# Aka: SamukaSmk
# Clube do Viva Linux:
# - https://www.vivaolinux.com.br/script/(Brincando-com-Aleatoriadade)-Tarot-Randomico
# - https://www.vivaolinux.com.br/scripts/download.php?codigo=5395 (download)
@samukasmk
samukasmk / mongodb-query-filter.py
Created June 6, 2025 14:19
Python tool to execute MongoDB query filter by command line
#!/usr/bin/env python3
#
import json
import argparse
from pymongo import MongoClient
parser = argparse.ArgumentParser(
prog='mongodb_query_filter.py',
description='Execute mongodb queries'
@samukasmk
samukasmk / ssh-commands-by-python-asyncssh.py
Last active June 6, 2025 13:38
Execute commands using SSH protocol by python script with AsyncSSH library
#!/usr/bin/env python3
#
# https://github.com/ronf/asyncssh
import argparse
import asyncio
import time
import asyncssh
@samukasmk
samukasmk / ssh-commands-by-python-paramiko.py
Last active June 6, 2025 13:37
Execute commands using SSH protocol by python script with Paramiko library
#!/usr/bin/env python3
#
# https://docs.paramiko.org/en/stable/
# https://didatica.tech/paramiko-com-python-aprenda-a-utilizar-com-exemplos-praticos/
import argparse
import sys
import time
@samukasmk
samukasmk / Pandas - read_parquet - s3.md
Created February 20, 2025 14:42
Pandas (read parquet files from s3)

Pandas examples of read_parquet files from s3

Credentials (from enviroment variables)

import os
import pandas as pd

# define aws credentials by os enviroment variables
os.environ['AWS_ACCESS_KEY_ID'] = '...'
os.environ['AWS_SECRET_ACCESS_KEY'] = '...'
@samukasmk
samukasmk / Grep Matcher.md
Last active February 1, 2025 14:35
Grep Matcher: wait to match first case and exit

grep_matcher.sh

#!/bin/bash
#
# grep matcher: wait to match first case and exit

grep_expression="$1"
grep_file="$2"
__matched=1