Skip to content

Instantly share code, notes, and snippets.

#include "pt.h"
#include <iostream>
#include <vector>
#include <string>
using namespace std;
static int bid = 0;
double cost(int items, double price = 0.8);
@cassc
cassc / pn532-uart-reader.py
Created April 20, 2021 10:11
Read PN532 UID from uart
# https://www.waveshare.com/wiki/PN532_NFC_HAT
# PN532 UART
import serial
import time
_port = '/dev/ttyUSB0'
_baudrate = 115200
_timeout = 2
package main
import (
"fmt"
"time"
)
func timeroutTimer() {
fmt.Println("Waiting for timer")
c := time.After(10 * time.Second)
package main
import (
"fmt"
"time"
)
func timeroutTimer() {
fmt.Println("Waiting for timer")
c := time.After(10 * time.Second)
@cassc
cassc / tcp_ledou_led.py
Last active August 10, 2021 13:50
Control Ledou / keelight through TCP
# Ledou LED Light / Keelight
# Search gateway and lights and show sample colors
import socket
import time
import traceback
import sys
from itertools import cycle
import binascii
PORT = 41330
@cassc
cassc / tcp_hokuyo.py
Last active February 6, 2025 02:14
Hokuyo UST 10LX Lidar Sensor, plot realtime distance in python
# MIT License
#
# Copyright (c) 2020 cassc
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@cassc
cassc / gsock-scroll.html
Created August 26, 2021 10:00
ScrollMagic and GreenSock for parallax scroll animation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.3/TweenMax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/animation.gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
@cassc
cassc / lax-scroll.html
Created August 26, 2021 10:01
Parallax scroll animation with lax.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/lax.js" ></script>
</head>
<body>
<div class="container">
@cassc
cassc / hid.py
Created September 3, 2021 12:21
Search HID devices by name and listen keyboard events
# Get event id and names for connected HID devices:
# cat /proc/bus/input/devices | grep -P '^[NH]: ' | paste - -
#
# To allow current user to run this script without root:
# sudo usermod -a -G input $USER
import evdev
from evdev import InputDevice, categorize # import * is evil :)
import time
import traceback
import sys
@cassc
cassc / fs005.py
Last active September 11, 2021 04:18
福申FS005甲醛传感器
# FS005009 Formaldehyde (HCHO) sensor
# 0 1 2 3 4 5 6 7 8
# 起始位 设备类型 单位 小数位数 气体浓度高位 气体浓度低位 满量程高位 满量程低位 校验值
# ff 17 04 00 00 1b 07 d0 f3
#
# 气体浓度值=气体浓度高位*256+气体浓度低位, 单位:mg/m3
# Sample output:
# ff 17 04 00 00 1b 07 d0 f3