Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
juanpabloaj / m5stack_unitv2_obj_detection.py
Last active September 11, 2024 01:06
m5stack unitv2 object detection and rectangles drawing
import subprocess
import json
import os
from datetime import datetime
import logging
import base64
from io import BytesIO
from PIL import Image, ImageDraw
@juanpabloaj
juanpabloaj / m5stack_unitv2_object_recognition.py
Created September 10, 2024 02:33
M5stack unitv2 object_recognition example
'''
it shows a log message when an object is detected.
references
https://medium.com/@sebastiaan.panasj/occupancy-counting-with-unitv2-by-m5stack-d35455037882
'''
import subprocess
import json
@juanpabloaj
juanpabloaj / main.go
Created August 26, 2024 19:47
Go slog, example with context handler
package main
import (
"context"
"log/slog"
"os"
)
type contextKey string
@juanpabloaj
juanpabloaj / .gitignore
Last active May 18, 2024 19:43
track ethereum token
.env
*.db
@juanpabloaj
juanpabloaj / main.py
Last active July 30, 2023 15:00
looking for job using Linkedin API
import os
import sqlite3
from linkedin_api import Linkedin
import logging
def extract_id(urn):
return urn.split(":")[-1]
@juanpabloaj
juanpabloaj / main.go
Created July 2, 2023 22:13
heartbeats example
// package main example of the book Concurrency in Go by Katherine Cox-Buday
// it includes the patterns: orChannel, orDone, take, and bridge.
// newSteward monitors a goroutine and restarts it if it stops sending heartbeats
package main
import (
"log"
"time"
)
@juanpabloaj
juanpabloaj / send_telegram_message.py
Last active March 26, 2023 13:26
python3 send telegram message
import os
import urllib.request
import urllib.parse
TELEGRAM_TOKEN = os.environ["TELEGRAM_TOKEN"]
TELEGRAM_CHANNEL_ID = os.environ["TELEGRAM_CHANNEL_ID"]
telegram_url = f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage"
telegram_url += f"?chat_id={TELEGRAM_CHANNEL_ID}"
@juanpabloaj
juanpabloaj / main.go
Created November 8, 2022 16:31
Channel example, channel as queue with discard of messages
// go playground
// https://go.dev/play/p/3HjtqJlbMnE
package main
import (
"log"
"time"
)
func main() {
@juanpabloaj
juanpabloaj / .gitignore
Last active August 14, 2022 14:53
download images with puppeteer
imgs
.DS_Store
node_modules
@juanpabloaj
juanpabloaj / gas_alert.sh
Last active January 7, 2024 14:59
ethereum gas telegram alert
#!/bin/bash
# get channel id
# https://api.telegram.org/bot<YourBOTToken>/getUpdates
# crontab
# */5 * * * bash /path/gas_alert.sh 2>&1 | logger -t gas_alert
cheapPrice="80"
url="https://api.etherscan.io/api?module=gastracker&action=gasoracle"