Skip to content

Instantly share code, notes, and snippets.

View VictorQueiroz's full-sized avatar
🏠
Working

Victor Queiroz VictorQueiroz

🏠
Working
View GitHub Profile
@VictorQueiroz
VictorQueiroz / get-abbreviation-from-string-start-similarity.ts
Created June 28, 2023 00:51
Get abbreviation from the string by comparing start of the string. Useful for creating convenient TypeScript enum names.
const s = [
"ApiAuthTypeFacebook",
"ApiAuthTypeGoogle",
"ApiAuthTypeLinkedIn",
"ApiAuthTypeGithub",
];
function getAbbreviationFromStartSimilarity(s: string[]) {
let match = "";
for (const n of s) {
@VictorQueiroz
VictorQueiroz / gist:33a44cf3d0c679047cdec3e2ad21b1dc
Last active December 18, 2022 00:01
OpenGL coordinates struct
#pragma once
struct GLCoordinates {
static constexpr glm::vec3 topLeft = {-1.0,1.0f,0.0f};
static constexpr glm::vec3 topRight = {1.0,1.0f,0.0f};
static constexpr glm::vec3 bottomLeft = {-1.0f,-1.0f,0.0f};
static constexpr glm::vec3 bottomRight = {1.0f,-1.0f,0.0f};
};
@VictorQueiroz
VictorQueiroz / AES_ige_encrypt.c
Last active February 21, 2022 19:51
Working example of AES_ige_encrypt usage
#include <assert.h>
#include <openssl/aes.h>
#include <openssl/ssl.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
/**
* Interestingly enough, using `iv` and `userKey` directly will
* result in corrupted encrypted data, so we need to copy iv and userKey to temporary
@VictorQueiroz
VictorQueiroz / gist:5ca05e02dc9fc3db5a8d7fbbf68d2a42
Created April 7, 2021 06:04
Matching patterns in all commit diffs
git rev-list --all | xargs git grep "pattern"
@VictorQueiroz
VictorQueiroz / gist:355b211efc47015800098cac62f5ccfd
Created January 20, 2021 14:30
Check largest folders on Linux
du -h /home | sort -hr | head -n 20
@VictorQueiroz
VictorQueiroz / vulkan-framebuffer-coordinates.ts
Last active November 4, 2020 16:39
Convert framebuffer normalized coordinates into pixel screen position
/**
See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/chap26.html#vertexpostproc-viewport
The viewport transformation is determined by the selected viewport’s width and height in pixels, px and py, respectively, and its center (ox, oy) (also in pixels), as well as its depth range min and max determining a depth range scale value pz and a depth range bias value oz (defined below). The vertex’s framebuffer coordinates (xf, yf, zf) are given by
xf = (px / 2) xd + ox
yf = (py / 2) yd + oy
zf = pz × zd + oz
The viewport parameters shown in the above equations are found from these values as
ox = x + width / 2
oy = y + height / 2
oz = minDepth
@VictorQueiroz
VictorQueiroz / gist:84980dd2820f78bf6b80d4a4d833e681
Created July 18, 2019 03:23
Output of plasmashell --replace on Arch Linux
No protocol specified
qt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: wayland-org.kde.kwin.qpa, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
@VictorQueiroz
VictorQueiroz / gist:7eceef680b68678188b48ad70475b0ab
Created May 19, 2019 12:04
Installing default Ubuntu theme on Debian (Stable/Unstable)
sudo apt install libgtk-3-dev git meson sassc
git clone https://github.com/ubuntu/yaru.git
cd yaru
meson build
cd build
sudo ninja install
sudo cp -rv /usr/share/gnome-shell/theme/Yaru /usr/share/themes/Yaru/gnome-shell
@VictorQueiroz
VictorQueiroz / gulpfile.js
Created July 31, 2017 18:53
Transform several files inside a folder but keep the architecture
gulp.task('jsx_extension_is_bad',function() {
gulp
.src('./src/**/*.jsx')
.pipe(rename({extname: '.js'}))
.pipe(gulp.dest('./src', {pwd: './'}));
});
@VictorQueiroz
VictorQueiroz / get-next-node.js
Created November 16, 2016 23:41
Simple recursive function to get the next DOM node matching a selector
function getNextNode(current, selector){
if(current && current.nodeType != Node.ELEMENT_NODE && current.nextSibling) {
return getNextNode(current.nextSibling, selector);
}
if(current && current.nextSibling && !current.matches(selector)){
return getNextNode(current.nextSibling, selector);
}
if(current.nodeType != Node.ELEMENT_NODE) {
return null;