Skip to content

Instantly share code, notes, and snippets.

View natanaeljr's full-sized avatar

Natanael Rabello natanaeljr

View GitHub Profile
#!/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
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"
@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)
@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 / 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 / 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) {}
BEGIN {
getline < "/tmp/cpu-usage-cache"
close("/tmp/cpu-usage-cache")
prev_idle = $1
prev_total = $2
getline < "/proc/stat"
close("/proc/stat")
idle = $5
total = 0
for (i=2; i<=NF; i++)
#!/bin/sh
# Module showing CPU load as a changing bars.
# Just like in polybar.
# Each bar represents amount of load on one core since
# last run.
# Cache in tmpfs to improve speed and reduce SSD load
cache=/tmp/cpubarscache
@natanaeljr
natanaeljr / guide-setup-raspberry-pi.txt
Created October 10, 2020 14:34
Guide to set up the Raspberry PI 3 with ArchLinux ARMv7, plus connect to serial console via telnet
1. Install ArchLinux ARMv7 on the SD card
Follow the guide lines in: https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3
2. Configure Serial UART0 to the Linux console
Only need to disable the bluetooth on UART0 to free it to operate as linux console:
Add the following to /boot/config.txt to disable the onboard bluetooth on UART0:
@natanaeljr
natanaeljr / 66-xrandr-monitors.sh
Created December 31, 2020 17:51
Automatic configuration of monitors for my vostro laptop + other monitors - Put this in /etc/X11/xinit/xinitrc.d
#!/bin/sh
# array of connected monitors
monitors=( $(xrandr | grep ' connected ' | cut -d' ' -f1) )
# for the integrated display, set a higher resolution
if [ ${#monitors[@]} -eq 1 ]; then
xrandr --output $monitors --mode 1366x768 --panning 1920x1080 --scale 1.41
# for multiple monitors, enable them all