Skip to content

Instantly share code, notes, and snippets.

View iTrooz's full-sized avatar
💭
CODE

iTrooz

💭
CODE
View GitHub Profile
@iTrooz
iTrooz / main.cpp
Created February 19, 2022 00:57
SDL2 Hello World Square Hardware
/*
* Based from https://gist.github.com/cicanci/b54715298ab55dff2fbcd0ca3829d13b
* Basic SDL2 program to render a square using the hardware framework.
* Hope it helps you
*/
#include <SDL2/SDL.h>
int main(){
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
SDL_Log("SDL_Init Error: %s\n", SDL_GetError());
@iTrooz
iTrooz / glRectF.cpp
Created February 19, 2022 22:57
OpenGL - GLUT square drawing hello world
// See the first file for useful comments
// check other files for useful comments, I may not have left them everywhere (mostly in the first file)
#include <GL/glut.h>
void displayMe()
{
glClearColor(1.0f,1.0f,1.0f,0);
glClear(GL_COLOR_BUFFER_BIT);
@iTrooz
iTrooz / mouseScroll.py
Last active February 28, 2022 09:19
Simple window with mouse scrolling (PyQt5) (based on https://gist.github.com/acbetter/e7d0c600fdc0865f4b0ee05a17b858f2)
import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys
import traceback
def exception_hook(exctype, value, a):
@iTrooz
iTrooz / KDE_X11_Wayland_Font.txt
Last active March 2, 2022 21:15
Quick gist : KDE X11 to Wayland Back to X11 cause font problems
Disclaimer : this is a "Quick gist", meaning I won't describe everything that happened precisely. I had a problem, found a solution, here it is
Cause :
Was on ArchLinux KDE 5.23.3 X11, went to Wayland then back to X11, and fonts seemed to be bigger, imgages and panel parts (like the app launcher) too
When creating a new user, they also had these weird settings. Not sure if caused by Wayland changing something system-wide or an recent update in KDE on new sessions
Resolution :
Managed god-know-how to get an user to have a smaller font+images+widgets size
File ~/.config/kdeglobals seems to manage KDE settings
@iTrooz
iTrooz / README.md
Created June 1, 2022 07:18
Github markdown custom heading ID on anchor

I recently spent an hour on Googl trying to figure out how to have a custom ID on an anchor, because titles like this

Hello I am a very long title. Why ? Because I wanted to

are quite annoying to reference then

What is what I learned : apparently, there's no way to do it in Github's markdown. There seems to have been a way to do it in the past using ### Some title {#custom-id}

@iTrooz
iTrooz / BONUS.md
Created June 1, 2022 07:20
What are circular imports ?

NOTICE : This is a bonus chapter of the article (to understand header guards). If you are reading this by scrolling past the end of the article... Well you should not do this

Header guards

Now, let's imagine this example (notice I removed the mySecondClass object)

main.cpp

#include "myClass.h"
#include "myUtils.h"
@iTrooz
iTrooz / pause.c
Created July 6, 2022 20:05
`pause` command C
// Simple program to simulate the `pause` command from Windows. Compile with `gcc -o pause pause.c`
// I'm ofc not going to put a licence on that, do whatever you want with it
#include "stdio.h"
int main(){
printf("press any key to continue\n");
getchar();
return 0;
}
@iTrooz
iTrooz / main.c
Created July 8, 2022 17:00
Linux XSI message Hello World (msgget msgsnd msgrcv)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/msg.h>
int main(){
char* buf = "Hello world !";
unsigned long len = strlen(buf);
char* buf2 = alloca(len);
@iTrooz
iTrooz / README.md
Last active August 5, 2022 13:27
Signing Drivers on Windows

// Note : this is a scrapped README edit I did for maharmstone/btrfs#503 We then took another approach

Signing

To install a built-from-source or a nightly (from github actions) driver, you need to sign it In this section, I will show how to disable driver signature enforcement, or how to sign the driver using test-signing Warning : both of these solutions aren't perfect, if you are looking for a everyday-use it is recommanded to use the release builds, which are signed with a Microsoft-trusted key.

@iTrooz
iTrooz / main.cpp
Created October 20, 2022 13:04
TCP socket server with multi-client support with poll()
// NOTE : you need the library fmt to format strings
// Command to use : `g++ server.cpp -o server -lfmt`
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <vector>
#include <string>
#include <iostream>