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 / 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 / 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 / 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 / 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 / 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
@Xrayez
Xrayez / github-branch-rename.sh
Last active April 29, 2020 23:12 — forked from ccopsey/gist:9866a0bcb0b39ade04fe
Rename master branch on GitHub
git branch -m master newname
git push origin newname
# Change "Default Branch" in settings/options in GitHub
git push --delete origin master
@Xrayez
Xrayez / get-pr.sh
Last active April 21, 2019 18:18
A simple bash function to fetch and checkout pull request using Git
get-pr() {
git fetch origin pull/"$1"/head:pr-"$1";
git checkout pr-"$1";
}
@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 / 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 / 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