Skip to content

Instantly share code, notes, and snippets.

View byBretema's full-sized avatar
🎨
I make computers draw things!

Daniel Brétema byBretema

🎨
I make computers draw things!
View GitHub Profile
Get-ChildItem . -Directory | % { Write-Host "`n[!] $($_.FullName)`n$("-"*40)"; Get-ChildItem $_ -Directory | % { Write-Host "$(Test-Path "$($_.FullName)\.git") : $($_.BaseName)" } }; Write-Host ""
// Global
ivec3 gi_id = ivec3(gl_GlobalInvocationID);
// Group
ivec3 wg_id = ivec3(gl_WorkGroupID);
ivec3 wg_size = ivec3(gl_NumWorkGroups);
int wg_index = (wg_id.z * wg_size.x * wg_size.y) + (wg_id.y * wg_size.x) + wg_id.x;
// Local
ivec3 li_id = ivec3(gl_LocalInvocationID);
struct NanoCamera
{
float rotx = 0.f;
float roty = 0.f;
float zoom = 0.f;
float fovy = 75.f;
glm::mat4 view = glm::identity<glm::mat4>();
glm::mat4 proj = glm::identity<glm::mat4>();
@byBretema
byBretema / darray.c
Created February 28, 2024 16:30
Dynamic Array in C (WIP)
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int *array;
size_t size;
size_t capacity;
} darray;
void *safe_malloc(size_t size) {
@byBretema
byBretema / winget_is.ps1
Created February 26, 2024 11:41
Interactive WinGet search, just type the index of the package to install
function winget_is {
param ($inName)
$lines = winget search $inName
# Gather indices
$nameIdx = 0
$nameLen = -1
$idIdx = -1
$idLen = -1
$verIdx = -1
@byBretema
byBretema / png_to_web.ps1
Created February 21, 2024 21:58
replace png images in all subfolders by webp
# install cwebp from: https://developers.google.com/speed/webp/docs/precompiled, and add it to $env:PATH
# 1- Conver png to web
(Get-ChildItem . -Recurse -File) | ForEach-Object { $src = "$($_.DirectoryName)\$($_.Name)"; if ($src.EndsWith(".png")) { $dst = $src.Replace(".png", ".webp"); cwebp -q 60 -o $dst $_; } }
# 2- Cleanup converted png files
(Get-ChildItem . -Recurse -File) | ForEach-Object { $src = "$($_.DirectoryName)\$($_.Name)"; if ($src.EndsWith(".png")) { Remove-Item $_ } }
format = """
$time\
[ · ](fg:#FFF)\
$directory\
$git_branch $git_status\
$docker_context\
$cmd_duration\
[ · ](fg:#FFF)\
$character\
"""
@byBretema
byBretema / defer.cpp
Last active October 25, 2023 20:43
C++ : Cloning Go Defer keyword functionality
// Check playground in: https://www.mycompiler.io/view/7pXriajivQt
#include <iostream>
#include <memory>
#include <functional>
//--- CONCAT ----------------------------------------------
#define detail_CONCAT(a, b) a##b
#define CONCAT(a, b) detail_CONCAT(a, b)
#--- NOT ADMIN
# . SCOOP
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-Expression (new-object net.webclient).downloadstring('https://get.scoop.sh')
scoop install git gcc cmake make ninja openssh python sudo gow xming
#--- ADMIN
#pragma once
#include <chrono>
#include <functional>
#include <string>
#include <iostream>
#include <cstdint>
class DCTimer
{