Skip to content

Instantly share code, notes, and snippets.

View gynvael's full-sized avatar

Gynvael Coldwind gynvael

View GitHub Profile
@gynvael
gynvael / gradientgpt3.py
Created March 16, 2023 14:47
JS to Python GPT-3.5 conversion
# original:
# https://github.com/gynvael/zrozumiec-programowanie/blob/master/018-Czesc_IV-Rozdzial_12-Format_BMP_i_wstep_do_bitmap/show.cpp
# this was converted to JS by GPT4, and then to this PY by GPT3.5
import pygame
# Initialize Pygame
pygame.init()
# Set up the canvas
W, H = 256, 256
@gynvael
gynvael / gradient.py
Created March 16, 2023 14:33
C++ to Python GPT-4 conversion
# original:
# https://github.com/gynvael/zrozumiec-programowanie/blob/master/018-Czesc_IV-Rozdzial_12-Format_BMP_i_wstep_do_bitmap/show.cpp
import tkinter as tk
from PIL import Image, ImageTk
def create_gradient(width, height):
gradient = Image.new('RGBA', (width, height))
pixels = gradient.load()
for y in range(height):
@gynvael
gynvael / go.py
Created February 20, 2023 14:39
Some QRcode solver
from PIL import Image
from glob import glob
res = bytearray(1920 * 1080)
cnt = 0
dmpcnt = 0
for i in range(290, 4489):
fn = f"1/output_{i:05}.png"
cnt += 1
@gynvael
gynvael / brute.py
Created February 5, 2023 07:58
BBCTF 2023 Visionary Cipher solver
#!/usr/bin/python3
# BBCTF 2023 Visionary Cipher solver by Gynvael Coldwind
from string import ascii_lowercase, digits
from random import choices
from hashlib import md5
import sys
alphabets = ascii_lowercase + digits + "_{}"
def pos(ch):
return alphabets.find(ch)
@gynvael
gynvael / myway.c
Last active May 26, 2022 15:23
And yet one more way to do it
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define ARR_SZ 1024
#define _TOSTR(a) #a
#define TOSTR(a) _TOSTR(a)
int main()
{
@gynvael
gynvael / simpler.c
Created May 26, 2022 15:08
A bit more idiomatic way to do longest word in the file...
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define ARR_SZ 1024
#define _TOSTR(a) #a
#define TOSTR(a) _TOSTR(a)
int main()
{
@gynvael
gynvael / simple.c
Created May 26, 2022 15:03
Find the longest word in the file
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define ARR_SZ 1024
int main()
{
FILE *f = fopen("ctext.txt", "r");
if (f == NULL) {
@gynvael
gynvael / cache_test.c
Last active February 19, 2021 12:36
Looking for a cache boundary
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <x86intrin.h>
int main() {
volatile uint8_t *arr1 = malloc(4096 * 16);
for (size_t i = 0; i < 4096 * 16; i++) {
@gynvael
gynvael / cursor_on_top.cc
Created February 11, 2021 23:56
Fake cursor always shown on top of all other windows.
// Show a triangle at mouse position, always on top.
// Warning: This was coded in 40 minutes, so the quality isn't the greatest :shrug:
// Blame: Gynvael Coldwind (2021)
// Known issues:
// - The "cursor" doesn't change between a normal arrow / text arrow / etc. It's just a triangle.
// - There is a minor lag to the "cursor" changing position.
// - Size probably doesn't adjust to DPI. Didn't test.
// - The "cursor" is a pixel off - that's kinda a workaround to not block the actual cursor's hot point.
// How to compile:
// g++ cursor_on_top.cc -Wall -Wextra -lgdi32 -o cursor_on_top.exe
@gynvael
gynvael / devpath_check.cc
Created February 3, 2021 21:27
Check if device path exists on Windows
#include <Windows.h>
#include <stdio.h>
#include <string>
using std::string;
void testdev(string devname) {
string path = "\\\\?\\Global\\GLOBALROOT\\Device\\" + devname;
printf("----------------- %s\n", devname.c_str());