Skip to content

Instantly share code, notes, and snippets.

View iTrooz's full-sized avatar
💭
CODE

iTrooz

💭
CODE
View GitHub Profile
@iTrooz
iTrooz / example.png
Last active June 16, 2023 20:09
reorderable QListWidget with up/down buttons on items, using setItemWidget()
example.png
@iTrooz
iTrooz / main.py
Last active March 7, 2023 17:33
Working Flask-SQLAlchemy hello world, with models compatible with pure SQLAlchemy, and support for database disconnections
# CC0 / Public domain
import os
from flask import Flask
from sqlalchemy.orm import declarative_base
from sqlalchemy import Column, Integer, String
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import engine as eg
@iTrooz
iTrooz / snowflake.py
Last active February 8, 2023 15:04
discord snowflake data dump script
# discord snowflake data dump script
# specialised for attachement links but you should be able to input a snowflake for anything
import datetime
def ts_to_str(ts):
return datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S.%f')
def print_data(sf: int):
@iTrooz
iTrooz / bezier3d.py
Last active March 1, 2023 18:38
Bezier curves graph in 3D
#!/bin/env python
# Bezier curves graph in 3D -- CC0 / Public Domain
import matplotlib.pyplot as plt
from matplotlib.ticker import AutoMinorLocator, MultipleLocator
import math
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
@iTrooz
iTrooz / timer.py
Created January 27, 2023 23:31
Simple Python timer module
import time
def dec(fun):
def decorator(*args, **kwargs):
return call(fun, *args, **kwargs)
return decorator
def call(fun, *args, **kwargs):
print(f"----- Function '{fun.__name__}' started!")
start = time.time()
@iTrooz
iTrooz / change_authors.py
Last active February 24, 2023 14:22
Randomly change authors in git commits
# !/usr/bin/env python
import sys
import os
import random
authors = (
("user1", "user1@xyz.com"),
("user2", "user2@xyz.com"),
)
@iTrooz
iTrooz / client.py
Created January 4, 2023 10:13
Flask-SocketIO rooms hello world
import socketio
sio = socketio.Client()
sio.connect('http://localhost:5000')
sio.emit('join', {"username": "iTrooz", "room":"myroom"})
@sio.on('chat')
def on_message(data):
@iTrooz
iTrooz / Dockerfile
Last active December 26, 2022 15:49
PoC partial upgrade ArchLinux Dockerfile
# https://gist.github.com/iTrooz/251d085c5fb2d852533c37edcd5f3d08
# PoC a ArchLinux partial upgrade and its damage
# Working as of 2022/12/26, might not work on the future due to ArchLinux repositories changes
# Image from 2022/06/26
FROM archlinux:base-devel-20220626.0.64095
# Try to upgrade all packages, but then cancel
# this also works by running `pacman -Sy`
RUN echo "n" | pacman -Syu || true
@iTrooz
iTrooz / chatgpt.py
Last active November 7, 2023 09:01
basic ChatGPT terminal client
#!/bin/python3
import sys
from openai import OpenAI
myPrompt = ' '.join(sys.argv[1:]).strip()
if not myPrompt:
print("Syntax : ", sys.argv[0], "prompt")
exit(1)
print("Me:", myPrompt, file=sys.stderr)
@iTrooz
iTrooz / MainJ8.java
Created November 11, 2022 18:48
modify String object value in Java
public class MainJ8 {
public static void main(String[] args) throws ReflectiveOperationException {
String someVariable = "My String";
String aSecondVariable = "My String";
modifyString("My String", "new value !");
System.out.println(someVariable); // new value