Skip to content

Instantly share code, notes, and snippets.

View pacosw1's full-sized avatar
🎯
Working from Home

Francisco Sainz pacosw1

🎯
Working from Home
  • San Pedro Garza Garcia, Nuevo Leon, MX
View GitHub Profile
@pacosw1
pacosw1 / factory-checkin-brief.md
Created February 14, 2026 00:23
Kiosco de Escaneo en Planta β€” Brief para pasante

Kiosco de Escaneo en Planta β€” Dispositivo Edge

Resumen

Construir un kiosco de escaneo que corra en una Raspberry Pi (u Orange Pi) en el piso de la planta. Los trabajadores escanean el codigo de barras de su credencial. El kiosco registra el escaneo localmente y lo sincroniza con un servidor central. Eso es todo.

El kiosco es un dispositivo edge sin estado. No determina entrada vs salida, no calcula horas, ni administra empleados. Toda la logica de negocio vive en el servidor central (se proporcionara acceso). El kiosco tiene dos trabajos:

  1. Registrar escaneos β€” codigo de credencial + timestamp β†’ SQLite local
  2. Sincronizar datos β€” enviar escaneos hacia arriba, recibir actualizaciones de empleados hacia abajo
@pacosw1
pacosw1 / GeAllData.java
Created September 9, 2023 13:45
This is an abstract class I create to encapsulate the different api actions in a reusable and extendible manner. I created this structure to create a resolver handler for an GraphQL api I created using AWS CDK and appsync. This uses the template pattern to abstract what doesn't change into a single file. This also makes adding new api resolvers …
package com.birthdaybot.graphql.resolver.birthday;
import com.birthdaybot.client.DynamoClient;
import com.birthdaybot.graphql.resolver.ResolverHandler;
import com.birthdaybot.graphql.resolver.birthday.input.BirthdayGetAllDataInput;
import com.birthdaybot.storage.dynamodb.model.BirthdayData;
import lombok.extern.log4j.Log4j2;
import org.json.JSONObject;
import software.amazon.awssdk.enhanced.dynamodb.Key;
import software.amazon.awssdk.enhanced.dynamodb.model.QueryConditional;
@pacosw1
pacosw1 / ResolverHandler.java
Created September 9, 2023 13:38
This is an abstract class I create to encapsulate the different api actions in a reusable and extendible manner.
package com.birthdaybot.graphql.resolver;
import com.birthdaybot.client.DynamoClient;
import lombok.extern.log4j.Log4j2;
import org.json.JSONObject;
@Log4j2
public abstract class ResolverHandler<I, O> {
protected String userId;
@pacosw1
pacosw1 / redis.go
Last active March 30, 2022 03:57
redis.go
import "github.com/go-redis/redis/v8"
redis.NewUniversalClient(&redis.UniversalOptions{
Addrs: nil, // one if single db, multiple if cluster
OnConnect: nil, // a middleware function ran before each command
MaxRetries: 0, // max amount of retries
DialTimeout: 0, // ms to wait before giving up on connecting to db
ReadTimeout: 0, // ms to wait before giving up on a hanging read command
WriteTimeout: 0, // same as above but for read
PoolFIFO: false, // should connections be first in first out?
@pacosw1
pacosw1 / Makefile
Created March 30, 2022 03:12
makefile
include .envrc
## help: print this help message
.PHONY: help
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
.PHONY: confirm confirm:
@echo -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ]
@pacosw1
pacosw1 / go build
Created March 30, 2022 02:51
Go build
GOOS=linux GOARCH=amd64 go build -ldflags='-s' -o=./deployment/prod/linux_amd64 ./cmd/
//^ ^ ^ ^
//the os the architecture output file your project root
@pacosw1
pacosw1 / public.json
Created March 30, 2022 01:59
AWS policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::assets.tudicuando.com/*"
}
@pacosw1
pacosw1 / public.json
Last active March 30, 2022 01:40
AWS public bucket policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::assets.yourbucket.com/*"
}
class Vector2D {
private X: number;
private Y: number;
constructor(X,Y) {
this.X = X;
this.Y = Y;
}
//returns the magnitude of the vector
const removeItem = (itemID) => {
//create cartCopy
let cartCopy = [...cart]
cartCopy = cartCopy.filter(item => item.ID != itemID);
//update state and local
setCart(cartCopy);