Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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
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 / 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
#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 / clojure-java-getter.clj
Created February 16, 2019 03:25
Call java no-arg getter in clojure
(defn invoke-get [obj ^String field]
(.. obj
(getClass)
(getDeclaredMethod (str "get" (clojure.string/capitalize field)) (into-array Class nil))
(invoke obj (into-array Class nil))))
(invoke-get (java.util.Date.) "time")