Skip to content

Instantly share code, notes, and snippets.

View ricardodeazambuja's full-sized avatar

Ricardo de Azambuja ricardodeazambuja

View GitHub Profile
@ricardodeazambuja
ricardodeazambuja / ARMonQEMUforDebianUbuntu.md
Created September 29, 2024 22:54 — forked from luk6xff/ARMonQEMUforDebianUbuntu.md
Emulating ARM with QEMU on Debian/Ubuntu

You might want to read this to get an introduction to armel vs armhf.

If the below is too much, you can try Ubuntu-ARMv7-Qemu but note it contains non-free blobs.

Running ARM programs under linux (without starting QEMU VM!)

First, cross-compile user programs with GCC-ARM toolchain. Then install qemu-arm-static so that you can run ARM executables directly on linux

If there's no qemu-arm-static in the package list, install qemu-user-static instead

@ricardodeazambuja
ricardodeazambuja / work-with-multiple-github-accounts.md
Created July 21, 2024 12:46 — forked from rahularity/work-with-multiple-github-accounts.md
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@ricardodeazambuja
ricardodeazambuja / setup.py
Created May 15, 2023 22:58 — forked from juancarlospaco/setup.py
setup.py Template, Generic but Complete, with instructions to Release to PyPI, DEB, RPM, PKGBUILD, EXE, EGG, ZIP, PYZ, and more.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#
# To generate DEB package from Python Package:
# sudo pip3 install stdeb
# python3 setup.py --verbose --command-packages=stdeb.command bdist_deb
#
#
# To generate RPM package from Python Package:

GCC compiler optimization for ARM-based systems

2017-03-03 fm4dd

The gcc compiler can optimize code by taking advantage of CPU specific features. Especially for ARM CPU's, this can have impact on application performance. ARM CPU's, even under the same architecture, could be implemented with different versions of floating point units (FPU). Utilizing full FPU potential improves performance of heavier operating systems such as full Linux distributions.

-mcpu, -march: Defining the CPU type and architecture

These flags can both be used to set the CPU type. Setting one or the other is sufficient.

@ricardodeazambuja
ricardodeazambuja / add_repo_commit_to_hex.patch
Created March 8, 2023 14:36
INAV 6 patch to add repository name and commit to the generated hex file
# To apply this patch:
# git apply add_repo_commit_to_hex.patch
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 04623c677..7a8005eea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,20 @@
cmake_minimum_required(VERSION 3.13...3.18)
# Cache sudo password
sudo -v
# Enable installation of 32-bit packages
sudo dpkg --add-architecture i386
# Install Adobe Reader
wget ftp://ftp.adobe.com/pub/adobe/reader/unix/9.x/9.5.5/enu/AdbeRdr9.5.5-1_i386linux_enu.deb
sudo dpkg -i AdbeRdr9.5.5-1_i386linux_enu.deb
@ricardodeazambuja
ricardodeazambuja / opencv_raw_capture_v4l2.py
Last active January 12, 2023 16:18
How to capture a raw frame using OpenCV (python, should be "almost" the same with C++ besides creating a Mat first) compiled with V4L2 support
# $ v4l2-ctl --list-formats-ext
# It shows my webcam supports MJPG and YUYV
# More details https://www.kernel.org/doc/html/v4.8/media/uapi/v4l/pixfmt-013.html
# And here we have some explanations about the flags available
# https://docs.opencv.org/4.x/d4/d15/group__videoio__flags__base.html
import cv2
cap = cv2.VideoCapture(0, cv2.CAP_V4L2) # I don't really need the CAP_V4L2 since it's the default
@ricardodeazambuja
ricardodeazambuja / Usage_Example_CrossEntropyLoss_and_BCELoss.py
Last active December 29, 2022 14:52
Usage Example for PyTorch CrossEntropyLoss and BCELoss (Binary Cross Entropy Loss) with Images (e.g. semantic segmentation)
# https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html
# https://pytorch.org/docs/stable/generated/torch.nn.BCELoss.html
import torch
from torch.nn import CrossEntropyLoss, BCELoss
# For this example:
# batch size = 1
# number of classes = 2
# size of tensors = 2x2
@ricardodeazambuja
ricardodeazambuja / using-google-takeout.md
Created December 5, 2022 13:39 — forked from chabala/using-google-takeout.md
Merge and extract tgz files from Google Takeout

Recently found some clowny gist was the top result for 'google takeout multiple tgz', where it was using two bash scripts to extract all the tgz files and then merge them together. Don't do that. Use brace expansion, cat the TGZs, and extract:

$ cat takeout-20201023T123551Z-{001..011}.tgz | tar xzivf -

You don't even need to use brace expansion. Globbing will order the files numerically:

$ cat takeout-20201023T123551Z-*.tgz | tar xzivf -
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.