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)

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
#!/usr/bin/python
# This is a template on how to add a CTRL-C handler in your Python script
#
# With this handler, you can include a proper cleanup before the script is terminated.
#
from signal import signal, SIGINT
from sys import exit
// typelog: a simple function to log the type and value of a variable
//
// This is a short function to show the type and value of a variable that i use in my JavaScript trainings.
// It helps students to understand what they are working with in JavaScript, since JavaScript does not
// require programmers to provide the data type for a variable.
//
// Example:
//
// typelog( "A string" );
// typelog( 42 );