Skip to content

Instantly share code, notes, and snippets.

View coseos's full-sized avatar
🏢
Working

coseos coseos

🏢
Working
View GitHub Profile
@coseos
coseos / pycal.py
Created October 28, 2023 13:22
Print calendar for current month from python
#!/usr/bin/env python3
# Print calendar for current month from python
import calendar
import datetime
(lambda d : print(calendar.month(d.year,d.month)))(datetime.datetime.now())
@coseos
coseos / config.txt
Created June 25, 2023 20:45
Use I2C-6 on GPIO 22 and GPIO 23
dtoverlay=i2c6
@coseos
coseos / config.txt
Created June 25, 2023 20:44
Enable GPIO shutdown on GPIO3/GND
dtoverlay=gpio-shutdown
#!/bin/bash
# A script to start the h2 console in a docker container
# $1 is the container id
# $2 is the database
# $3 is the user (sa would be the default)
docker exec -it $1 Java -cp h2.jar org.h2.tools.Shell -url jdbc:h2:tcp://localhost/$2 -user $3
#!/usr/bin/python3
import sys
import json
def print_json(file_path):
with open(file=file_path, mode='r') as read_file:
object = json.load(read_file)
pretty_object = json.dumps(object, indent=4)
@coseos
coseos / DX.bin
Last active November 4, 2022 09:00
Patched
{"timestamp": "2022-11-04T09-00-01_00-00", "state": "U2FsdGVkX1+AyIV8Mkc/W/uc3THqGxYRDVfu0XJwtEA="}

JPA @Identity Stragey values

Just to remember the strategies available in JPA for id generation. In most cases, AUTO will work fine as in

@Id
@GeneratedValue(strategy=GenerationType.AUTO)

Sometimes AUTO does not work. Use IDENTITY for a database that supports autoincement columns and SEQUENCE for a database that supports sequences. Few databases require TABLE

# Simple Python Script to flash LED on Raspberry Pi Pico
from machine import Pin
import time
led = Pin(25, Pin.OUT)
while True:
led.toggle()
time.sleep_ms(100)
#!/usr/bin/env bash
#
# Credits for this script to:
#
# https://www.willhaley.com/blog/raspberry-pi-wifi-ethernet-bridge/
#
# Run this script on your Raspberry Pi (Bullseye) to turn it into a bridge.
#
# You can now connect a network printer to the ethernet port of your
This file has been truncated, but you can view the full file.
{ 'timestamp': '21/07/2022 21:19:52', 'state': '_' }
{ 'timestamp': '21/07/2022 21:24:08', 'state': '_' }
{ 'timestamp': '21/07/2022 21:28:23', 'state': '_' }
{ 'timestamp': '21/07/2022 21:32:37', 'state': '_' }
{ 'timestamp': '21/07/2022 21:36:52', 'state': '_' }
{ 'timestamp': '21/07/2022 21:41:07', 'state': '_' }
{ 'timestamp': '21/07/2022 21:45:22', 'state': '_' }
{ 'timestamp': '21/07/2022 21:49:37', 'state': '_' }
{ 'timestamp': '21/07/2022 21:53:54', 'state': '_' }