Skip to content

Instantly share code, notes, and snippets.

View iTrooz's full-sized avatar
💭
CODE

iTrooz

💭
CODE
View GitHub Profile
@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
@iTrooz
iTrooz / README.md
Last active December 1, 2022 19:58
Huawei Matebook 16 Battery not charging or low CPU frequency on charging (reset battery system)

There previously was a support page with the answer, but since Huawei removed it, here I go (I think it was https://consumer.huawei.com/en/support/content/en-us00692700/)

I had a issue with my ArchLinux KDE computer where sometimes (when I used cpupower-gui I think), my computer would enter a "mode" where charging the computer would reduce the frequency of every core to 400MHz The issue would then appear everywhere, even in the UEFI (and yes, the lag was noticable, even there)

From what I remember, here are the instruction that were on the Huawei support page : (computer on)

  • plug the charging cable
  • Shutdown the computer by force, by holding the power button for 10+ seconds (continue even when it's off !)
@iTrooz
iTrooz / AppRun
Last active December 3, 2022 20:12
AppImage Custom AppRun for multiple executables
#!/bin/sh
# This is a sample AppRun that can be adapted for building your own
# AppDirs. It contains several interesting features, some of which may
# or may not be useful to you.
# Much of the code to build and run the application was taken from
# the AppRun script for ROX-Session, by Thomas Leonard.
# Modified by iTrooz
# INSPIRED BY https://www.skepticats.com/rox/wrappers.html#template
@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 / 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 / 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 / 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 / tmate.yml
Last active February 20, 2023 15:49
TMate workflow
# license: CC0 / public domain
# https://gist.github.com/iTrooz/4dd70aea9debf80a59f3491601b40a26
# feel free to use !
name: TMate
on:
workflow_dispatch:
inputs:
runner:
@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 / 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')