Skip to content

Instantly share code, notes, and snippets.

View Pacheco95's full-sized avatar
🤓
Building awesome things

Michael Pacheco Pacheco95

🤓
Building awesome things
View GitHub Profile
@Pacheco95
Pacheco95 / VulkanDoubleCallWrapper.hpp
Created November 11, 2023 00:32
Helper wrapper function to avoid the doubled calls for vulkan functions like vkEnumerateDeviceExtensionProperties
#ifndef VULKAN_DOUBLE_CALL_WRAPPER_HPP
#define VULKAN_DOUBLE_CALL_WRAPPER_HPP
#include <vulkan/vulkan.h>
#include <tuple>
#include <vector>
namespace engine {
@Pacheco95
Pacheco95 / struct.py
Last active December 21, 2022 18:14
Python serializable type that allow dot notation access
import json
from json import JSONEncoder
from typing import Iterator, Mapping
class StructEncoder(JSONEncoder):
def default(self, o):
return o.__dict__ if isinstance(o, Struct) else super().default(o)
@Pacheco95
Pacheco95 / terminator-config.properties
Created October 22, 2021 12:59
Terminator configuration file (copy content to ~/.config/terminator/config)
[global_config]
window_state = maximise
borderless = True
title_hide_sizetext = True
inactive_color_offset = 1.0
title_use_system_font = False
title_font = Fira Code Semi-Bold 10
[keybindings]
[profiles]
[[default]]
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void keyEventCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
// settings
const unsigned int SCR_WIDTH = 800;
@Pacheco95
Pacheco95 / react-boilerplate-cra-template-error.log
Created December 8, 2020 22:47
react-boilerplate-cra-template ERESOLVE unable to resolve dependency tree
$ npx create-react-app --template cra-template-rb cra-boilerplate-ts
Need to install the following packages:
create-react-app
Ok to proceed? (y) y
Creating a new React app in /home/user/repositories/cra-boilerplate-ts.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template-rb...
@Pacheco95
Pacheco95 / urlQueryParamParser.js
Created November 7, 2020 17:07
Schema based query string parser
const assert = require("assert");
const objectify = (o, [k, v]) => ({ ...o, [k]: v });
function parseFromURL(schema, url = window.location.search) {
const searchParams = new URLSearchParams(url);
return Object.entries(schema)
.map(([par, { def }]) => [par, searchParams.get(par) ?? def ?? undefined])
.map(([par, val]) => [par, schema[par].transform?.(val) ?? val])
@Pacheco95
Pacheco95 / pagination.hook.jsx
Created November 6, 2020 01:57
A hook to sync URL pagination
import React from "react";
function parsePagination() {
const searchParams = new URLSearchParams(window.location.search);
return {
page: parseInt(searchParams.get("page") || 1),
pageSize: parseInt(searchParams.get("pageSize") || 10),
};
}
@Pacheco95
Pacheco95 / AvatarUpload.js
Created October 24, 2020 04:58
Example of avatar uploading with React.js, Material UI and Styled Components
import { Avatar, Button as MuiButton, Typography } from "@material-ui/core";
import { grey } from "@material-ui/core/colors";
import {
CloudUpload as MuiCloudUpload,
Delete as MuiDelete,
} from "@material-ui/icons";
import { spacing } from "@material-ui/system";
import React, { createRef, useState } from "react";
import styled from "styled-components";
❯ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
entrada = require('prompt-sync')();