Skip to content

Instantly share code, notes, and snippets.

View Xrayez's full-sized avatar
🔱
Ukraine is winning

Andrii Doroshenko Xrayez

🔱
Ukraine is winning
View GitHub Profile
@Xrayez
Xrayez / fix_bluetooth_disconnect.md
Last active May 2, 2026 01:24
Fix Bluetooth gamepad trapped in connected/disconnected cycle

Ubuntu-based:

If you can't connect the gamepad at all, try changing/adding this to /etc/bluetooth/input.conf:

ClassicBondedOnly=false

then in /etc/bluetooth/main.conf, change/add:

FastConnectable = true
Privacy = device
@Xrayez
Xrayez / AI.md
Last active August 8, 2023 17:42
Problem-solving and research-oriented ChatGPT/AI prompts

Prompts

Added Complexity Justification

There exists a method known to solve a problem. However, it is not clear why the method is necessary to apply or whether using it justifies the added complexity. For learning purposes, provide a practical example that demonstrates a problem in detail without using the said method. After that, provide an example that incorporates the method, allowing the problem to be solved. Describe the reasons why it is beneficial to do so and suggest simpler alternative solutions, if necessary. Format the response in Markdown. The question is:

Given a statement, apply the "Five whys" technique. For each of the five questions, provide a detailed answer, nothing more. Format the entire response in Markdown, alternating questions and answers. The statement is:

@Xrayez
Xrayez / bresenham_circle.lua
Last active April 16, 2023 13:41
Basic Bresenham circle implementation in Lua
# Ported from https://www.daniweb.com/programming/software-development/threads/321181/python-bresenham-circle-arc-algorithm
-- Bresenham circle
function circle(radius)
local pixels = {}
local switch = 3 - (2 * radius)
local x = 0
local y = radius
while x <= y do
table.insert(pixels, {x, -y})
@Xrayez
Xrayez / gcd_lcm.lua
Last active April 16, 2023 12:53
Greatest Common Divisor (GCD) and Least Common Multiple (LCM) implemented in Lua
-- Greatest Common Divisor (Euclidean algorithm).
function math.gcd(a, b)
local t
while b ~= 0 do
t = b
b = math.fmod(a, b)
a = t
end
return a
end
@Xrayez
Xrayez / mingw-mxe.sh
Last active April 16, 2023 12:13
Build the latest MinGW toolchain
#!/bin/bash
#
# Build the latest MinGW toolchain
#
# WARNING: this is just a list of steps and not an actual script, some steps could work though...
#
# Download MXE
git clone https://github.com/mxe/mxe.git && cd mxe
@Xrayez
Xrayez / prepare-commit-msg
Last active April 16, 2023 12:09
An example git hook which shows how to append an arbitrary bit of information to a commit
#!/bin/sh
#
# An example git hook which shows how to append an arbitrary bit of information to a commit.
# The following appends some version number to a commit message.
#
VERSION=$(command --version) # `command` is any executable
BUILD="Xrayez" # Some arbitrary name
# Ensure that version contains some build name
@Xrayez
Xrayez / colors.lua
Last active April 16, 2023 12:01
Lua colors, 0.25 step
-- Uses 0.25 step between shades of color, a total of 23 colors.
-- Assumes `color` to be already implemented as a callable table or a function.
local colors = {
color(1.0, 0.0, 0.0),
color(1.0, 0.25, 0.0),
color(1.0, 0.5, 0.0),
color(1.0, 0.75, 0.0),
color(0.75, 1.0, 0.0),
color(0.5, 1.0, 0.0),
color(0.25, 1.0, 0.0),
@Xrayez
Xrayez / StateRecorder.gd
Created December 10, 2017 11:03
State recorder using AnimationPlayer in Godot
# This is a prototype of the state recorder that can be used in a replay system
extends AnimationPlayer
var nodes = []
var animations = {}
var properties = ["global_position", "global_rotation"]
func _init():
set_name("state_recorder")
@Xrayez
Xrayez / BreadthFirstIterator.java
Created February 8, 2022 13:35 — forked from deyindra/BreadthFirstIterator
BFS and DFS Iterator for Graph
import java.util.*;
public class BreadthFirstIterator<T> implements Iterator<T> {
private Set<T> visited = new HashSet<>();
private Queue<T> queue = new LinkedList<>();
private Graph<T> graph;
public BreadthFirstIterator(Graph<T> g, T startingVertex) {
if(g.isVertexExist(startingVertex)) {
this.graph = g;
@Xrayez
Xrayez / listdir_recurse.ps1
Last active June 6, 2020 09:23
Powershell commands
# Get a list of absolute directory paths starting from current directory recursively.
Get-ChildItem -Recurse -Directory | Select Fullname