Skip to content

Instantly share code, notes, and snippets.

View ppcamp's full-sized avatar

Pedro Augusto Campos Dos Santos ppcamp

View GitHub Profile
@ppcamp
ppcamp / machanger.sh
Created May 19, 2024 17:32
MAC changer is a way to change the MAC address of your PC
if [ $# -lt 1 ];then
INTERFACE='enp2s0f0'
MAC='2C:76:8A:BB:D4:52'
else
INTERFACE=$1
MAC=$2
fi
sudo ifconfig $INTERFACE down & \
sudo ifconfig $INTERFACE hw ether $MAC & \
@ppcamp
ppcamp / setup.sh
Created May 19, 2024 17:30
Base linux config
#!/bin/bash
# This script configure ubuntu after installation
# i.e., install the programs
# Printf -----------------------------------------
# 38 --> foreground
# 48 --> background
# ------------------------------------------------------------------------------
# Script settings
@ppcamp
ppcamp / opencv-build.sh
Last active May 19, 2024 17:33
Build opencv
#!/usr/bin/env bash
set -ex
OPENCV_VERSION=3.4.7
pushd /media/PPCAMP/opencv/opencv-$OPENCV_VERSION
mkdir -p build
pushd build
RPI_VERSION=$(awk '{print $3}' < /proc/device-tree/model)
if [[ $RPI_VERSION -ge 4 ]]; then
NUM_JOBS=$(nproc)
@ppcamp
ppcamp / dumb_pack.cpp
Last active May 22, 2024 19:06
A collection of functions for cpp coding. It includes methods for split/join strings; cpf validations/gen; datetime validations; random gen; sorting; and math functions
#include <algorithm> // transform
#include <cstdlib> // atoi
// invalid_argument https://en.cppreference.com/w/cpp/error/exception
// see https://en.cppreference.com/w/cpp/error/out_of_range
// https://softwareengineering.stackexchange.com/questions/430984/what-are-the-best-practices-when-implementing-c-error-handling
#include <chrono>
#include <cmath> // pow, sqrt
#include <exception>
#include <fstream> // For file-based logging
#include <iostream> // cout
@ppcamp
ppcamp / README.md
Created May 15, 2024 16:05
Bash useful commands/tips

Moving everything, except

$ pwd
~/test/t

$ ls
a.t  aa.t  b.t  c.t

$ mv ./!(a*) .. # if you are using zsh, use ^
@ppcamp
ppcamp / Summary.md
Last active April 7, 2024 15:50
VScode configs and tips
@ppcamp
ppcamp / Zsh-Bash configs.md
Last active April 7, 2024 18:22
A curated list of configs for bash/zsh environment

Summary

This is a collection of my personal dotfiles. I use these files to configure my shell, git, and other tools. I have included a brief description of each file and a link to the file in this repository.

@ppcamp
ppcamp / PyErrorInsteadTryCatch.py
Last active April 7, 2024 18:44
Python error handling similar to Go (making it more explicit, instead of using trycatch blocks)
# it requires python 3.11+
from typing import Self, NewType
import inspect
# TODO: check for some error library that implements something similar to Go
class NewError:
__msg: str
__reason: Self | None
@ppcamp
ppcamp / nopasswd-for-user.md
Created November 15, 2023 13:43
No ask for password for current user

Store it in /etc/sudoers.d/nopasswd-for-user

PUT_YOUR_USER_HERE ALL=(ALL:ALL) NOPASSWD: ALL
@ppcamp
ppcamp / typing-props.svelte
Created November 13, 2023 12:53
Typing svelte props
<script lang="ts">
// SmuiType adds a "input$" prefix to a given html attribute, thus it's usefull when use restProps
type SmuiType<T> = {
[Key in keyof T & string as `input$${Key}`]?: T[Key];
};
// Add HTML smui attributes properties typings
type Props<T> = {
[Key in keyof T]: T[Key];
};