Skip to content

Instantly share code, notes, and snippets.

View Justasic's full-sized avatar
🏍️
Making computers do things they don't want to

NightShadow Justasic

🏍️
Making computers do things they don't want to
View GitHub Profile
@Justasic
Justasic / tlo.hexpat
Last active May 1, 2023 16:00
ImHex (https://imhex.werwolv.net/) Telegram TLO object decoding (TLO schema v2 should match what Telegram uses)
#include <std/mem.pat>
#include <std/io.pat>
#include <std/sys.pat>
enum ConstructorIDType : u32 {
CID_TLSTYPE = 0x12eb4386,
CID_NATCONST = 0x8ce940b1,
CID_NATVAR = 0x4e8a14f0,
CID_EXPRNAT = 0xdcb49bd8,
CID_EXPRTYPE = 0xecc9da78,
@Justasic
Justasic / TLCRC.py
Created March 24, 2022 22:27
Calculate the CRC32 values of Telegram's Type Language constructor IDs
#!/usr/bin/env python3
import sys, re
from zlib import crc32
from typing import Tuple
from PyQt5.QtWidgets import QWidget, QLineEdit, QApplication, QLabel, QVBoxLayout, QHBoxLayout
class Calculator(QWidget):
def __init__(self):
super().__init__()
@Justasic
Justasic / .clang-format
Created July 14, 2021 10:59
My personal clang-format file for C++ (and maybe other languages)
---
#BasedOnStyle: WebKit
TabWidth: '4'
IndentWidth: '4'
UseTab: 'ForContinuationAndIndentation'
AlignOperands: 'AlignAfterOperator'
AlignAfterOpenBracket: 'Align'
AlignConsecutiveAssignments: 'AcrossEmptyLinesAndComments'
AlignConsecutiveBitFields: 'AcrossEmptyLinesAndComments'
AlignConsecutiveDeclarations: 'AcrossEmptyLinesAndComments'
@Justasic
Justasic / .gitconfig
Created August 27, 2020 01:18
my git config
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
@Justasic
Justasic / message.md
Last active December 22, 2022 22:10
.run() is bad for libraries

.run() is bad for libraries

As a developer I have noticed a trend in libraries where the library developer will write this amazing library that does everything you need it to except that it has a .run() or .start() method. The intent is for the user of said library to do the initialization code in the application entry point and then do something like return app.run();. Whether it's in Python, Java, C++, or Rust they all abstratct away the application's main event loop.

What is an event loop?

# Color shortcuts
RED=$fg[red]
YELLOW=$fg[yellow]
GREEN=$fg[green]
WHITE=$fg[white]
BLUE=$fg[blue]
RED_BOLD=$fg_bold[red]
YELLOW_BOLD=$fg_bold[yellow]
GREEN_BOLD=$fg_bold[green]
WHITE_BOLD=$fg_bold[white]
commit 0e30377471bb47e5600ca544049fd912b8fd6f1f
Author: Justin Crawford <Justin@stacksmash.net>
Date: Sun Jun 7 05:33:08 2020 +0200
Musl-libc patches
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 8254c937c9f4..0636c2aa487c 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java
index ce39fb90889..b82ca3d83b3 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java
@@ -52,7 +52,7 @@ public class FODCircleViewImpl extends SystemUI implements CommandQueue.Callback
// do nothing
}
mDisableNightMode = SystemProperties.getBoolean("persist.fod.night_mode_disabled", true);
- mDisableGrayscaleMode = SystemProperties.getBoolean("persist.fod.grayscale_mode_disabled", true);
+ mDisableGrayscaleMode = SystemProperties.getBoolean("persist.fod.grayscale_mode_disabled", false);
exit # Dont run this as a script
# LLVM seems to work great on Musl, there only seems some build errors
# when trying to build the sanitizers. So sanitizers have been disabled.
# This is rougly based on this:
# https://wiki.musl-libc.org/building-llvm.html
# But updated for LLVM 10
# We are also focusing on making a GNU-less toolchain, as there is
# no libgcc and no libstdc++, instead we favor LLVM's own compiler-rt
@Justasic
Justasic / drm_test.c
Created October 30, 2019 02:06 — forked from uobikiemukot/drm_test.c
dirty and small example of libdrm
/* please refer better example: https://github.com/dvdhrm/docs/tree/master/drm-howto/ */
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <xf86drm.h>