Skip to content

Instantly share code, notes, and snippets.

View natanaeljr's full-sized avatar

Natanael Rabello natanaeljr

View GitHub Profile
@natanaeljr
natanaeljr / window_properties.cpp
Last active May 15, 2020 01:06
Turn runnable code into property objects [Example with GLFW window]
#include <cstdio>
#include <utility>
#include <GLFW/glfw3.h>
#include <unistd.h>
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {}
static void error_callback_glfw(int error, const char* description) {}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height) {}
@natanaeljr
natanaeljr / xrandr-vostro.txt
Last active April 18, 2020 18:08
Monitor resolutions tips with xrandr for Linux
#
# Set FullHD resolution (1920x1080) into a HD monitor of native resolution 1366x768.
#
xrandr --output eDP1 --mode 1366x768 --panning 1920x1080 --scale 1.41
#
# Set a scaled down resolution of 1920x1080 to 21:9 monitor (2560x1080)
$
xrandr --output HDMI1 --mode 1920x1080 --panning 1920x1080
@natanaeljr
natanaeljr / GLAD.cmake
Last active February 24, 2019 17:41
Integrating GLAD into a CMake project - (option: automatically download and build GLAD or use the GLAD generator from system if available)
cmake_minimum_required(VERSION 3.5)
include(ExternalProject)
#########################################################################################
# GLAD
#########################################################################################
option(DOWNLOAD_GLAD "Download and build GLAD" OFF)
# Build settings
set(GLAD_PREFIX ${CMAKE_BINARY_DIR}/GLAD)
@natanaeljr
natanaeljr / glfw3.cmake
Last active February 24, 2019 17:37
Integrating GLFW3 into a CMake project - (option: automatically download and build glfw3 or use it from system)
cmake_minimum_required(VERSION 3.5)
include(ExternalProject)
#########################################################################################
# GLFW3
#########################################################################################
option(BUILD_GLFW3 "Download and build GLFW3" OFF)
# Use GLFW from system
if(NOT BUILD_GLFW3)
cmake_minimum_required(VERSION 3.5)
include(ExternalProject)
#########################################################################################
# GLEW
#########################################################################################
set(GLEW_PREFIX ${CMAKE_BINARY_DIR}/glew)
set(GLEW_INCLUDE_DIR ${GLEW_PREFIX}/include CACHE STRING "GLEW Include Directory")
set(GLEW_LIBRARY ${GLEW_PREFIX}/lib64/libGLEW.a CACHE STRING "GLEW Static Library")
set(GLEW_LIB_DEPENDENCIES CACHE STRING "GLEW Library Dependencies"
#!/bin/bash
## Setup GTest/GMock
set -Eeuxo pipefail
# Require root
[ "$UID" -eq 0 ] || exec sudo "$0" "$@"
# Check required packages are installed
dpkg -s libgtest-dev
@natanaeljr
natanaeljr / ble_config.c
Created April 7, 2018 00:16 — forked from heiko-r/ble_config.c
ESP32 BLE GATT server example
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "esp_system.h"
#include "esp_log.h"
#include "bt.h"
#include "bta_api.h"
#include "esp_gap_ble_api.h"
#include "esp_bt_main.h"
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "driver/gpio.h"
#include "driver/i2c.h"
#include "driver/spi_master.h"
#include "esp_err.h"
#include "esp_log.h"

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@natanaeljr
natanaeljr / git_submodules.md
Created March 12, 2018 16:52 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of advantages of using submodules:

  • You can separate the code into different repositories.