Skip to content

Instantly share code, notes, and snippets.

View valignatev's full-sized avatar

Valentin Ignatev valignatev

  • Novi Sad, Serbia
View GitHub Profile
#include <stdio.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/extensions/XInput2.h>
static Window create_win(Display *dpy)
{
Window win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 200,
200, 0, 0, WhitePixel(dpy, 0));
Window subwindow = XCreateSimpleWindow(dpy, win, 50, 50, 50, 50, 0, 0,
@valignatev
valignatev / xcb_opengl.c
Last active August 11, 2023 22:08
setting up and using modern OpenGL 4.5 core context on X11 with EGL and xcb, without xlib or glx
// This is @mmozeiko's libx + EGL example ported to xcb + EGL
// Original code: https://gist.github.com/mmozeiko/911347b5e3d998621295794e0ba334c4
// It requires EGL_EXT_platform_xcb extension, so if your system is circa the end of 2021 or newer you should be fine.
// Also, I don't know if it works on nvidia. LMK if you test it
// example how to set up OpenGL core context on X11 with EGL
// and use basic functionality of OpenGL 4.5 version
// to compile on Ubuntu first install following packages: build-essential libxcb1-dev libgl-dev libegl-dev, then run:
@valignatev
valignatev / 8086.jai
Created June 5, 2023 23:19
First computerenhance.com homework with decoding some simple MOV instructions, written in Jai
// RTFM. Starting from page 160
// https://edge.edx.org/c4x/BITSPilani/EEE231/asset/8086_family_Users_Manual_1_.pdf
// NOTE: this leaks all the memory in the world, but maybe I don't care
// How to test: compile .asm files with NASM and then provide them to this program
// then compare the output to the asm source code. I'll make a proper testing harness
// in the future maybe.
main :: () {
args := get_command_line_arguments();
;; Meow experiments. Unfortunately didn't quite worked out for me for now,
;; so go back to trusty evil
(use-package meow
:init
(define-key input-decode-map (kbd "C-[") [control-bracketleft])
(global-set-key [control-bracketleft] 'ignore)
(global-set-key [control-bracketleft] 'meow-insert-exit)
(setq meow-expand-hint-counts
'((word . 0)
(line . 0)
@valignatev
valignatev / script.jai
Last active May 18, 2022 11:45
An example of compile-time script in jai without producing an executable. You can use it like that instead of bash or python
#!/path/to/jai-linux
#import "Basic";
#import "Compiler";
#run {
set_build_options_dc({.do_output = false});
print("Hello!\n");
}
@valignatev
valignatev / artix_s6_faq
Last active August 10, 2020 13:50
Artix s6 tldr
Q: Artix s6 wiki?
A: https://wiki.artixlinux.org/Main/S6
Q: How to get s6 service for a program?
A: instal program-s6 package
Q: Does the service get enabled after reboot?
A: No
Q: How to enable it then?
@valignatev
valignatev / pyproject.toml
Created June 5, 2019 21:47
pyproject.toml
[tool.poetry]
name = "packagename"
version = "0.1.0"
description = ""
authors = ["Valentin Ignatev <valentignatev@gmail.com>"]
[tool.poetry.dependencies]
python = "^3.7"
[tool.poetry.dev-dependencies]
@valignatev
valignatev / items.json
Created October 28, 2015 08:29
spider for oxygenboutique.com with results in json
[{"code": "Paula-Top", "description": "Paula Top by Related Apparel.\u00a0This classic cut tee has a boxy fit and comes in a beautiful black and grey wool blend filigree style patterned fabric. Wear over jeans or pair with the matching Margaux Skirt.", "gbp_price": "62.50", "sale_discount": 50.0, "gender": "F", "stock_status": {"UK6": 1, "UK10": 1, "UK14": 1, "UK12": 1, "UK8": 3}, "designer": "Related", "link": "http://www.oxygenboutique.com/Paula-Top.aspx", "raw_color": "black", "images": ["http://oxygenboutique.com/GetImage/cT0xMDAmdz04MDAmaD02MDAmUEltZz1hYTUzNTAyZS05YjA2LTRhZmMtOWQzZi0wZGQ4OGJlYjBjZGYuanBn0.jpg"], "type": "A", "name": "Related Paula Top"},
{"code": "Selena-Gown", "description": "Selena Gown by Related. This elegant show piece has a slim silhouette with a fitted bodice to enhance your waist. Cut from pale grey floral jacquard it has a subtle shimmer that's just right for your evening soirees.", "gbp_price": "125.00", "sale_discount": 50.0, "gender": "F", "stock_status": {"UK6": 1, "UK10": 1
@valignatev
valignatev / getopt.py
Last active November 24, 2016 21:09
Напишите простую реализацию функции для разбора параметров командной строки (getopt). Полагаем, что нам требуется структура данных, содержащая заранее известный допустимый набор параметров различного типа - строки, целые, числа с плавающей точкой и т. д., а также признак, является ли этот параметр обязательным. Полагаем, что параметры могут пере…
#! -*- coding: utf-8 -*-
import sys
# param_name: required
PARAMS = {
'--integer': True,
'--boolean': True,
'--string': False,
}
@valignatev
valignatev / divide_vector.py
Last active November 24, 2016 21:05
Имеется вектор размера N. Необходимо разделить его на M < N равных частей (то есть чтобы количество элементов в каждой части было одинаковым). Части не должны пересекаться и должны покрывать весь вектор (исключение - допускаются промежутки от начала вектора до начала первой части и от конда последней части до конца вектора, но в этом случае необ…
#! -*- coding: utf-8 -*-
def divide(n, m):
# Выходной список интервалов
intervals = []
# Количество элементов в каждой части
el_count = n / m
# Количество элементов вектора, не попадающих в части
rest_part = n % m