Skip to content

Instantly share code, notes, and snippets.

View hpsaturn's full-sized avatar
🏠
Working from home

hpsaturn

🏠
Working from home
View GitHub Profile
@hpsaturn
hpsaturn / prebuild.py
Created September 25, 2022 19:44
Workaround for LVGL config header on PlatformIO builds (lv_conf.h into hidden directory)
################################
# LVGL config loader
# @hpsaturn 2022
################################
# Put this file on the root of your PlatformIO LVGL project
# and add the next line on your env board in the platformio.ini file.
#
# extra_scripts = pre:prebuild.py
#
# The lv_conf.h file should be placed in the root lib folder
@hpsaturn
hpsaturn / virtual_screen_start
Last active May 5, 2023 21:32
Virtual Screen handler for expand your desktop to old laptops or Tablets. More info: https://hpsaturn.com/old-laptop-like-second-monitor/
#!/bin/bash
# Secondary display resolution
W=1920 # Virtual display width
H=1080 # Virtual display height
# Primary display config
P="HDMI-A-0" #is the main screen, it can be calle eDP-1 or eDP1 depending on the driver
O="DisplayPort-0" #can be a virtual (recommended if possible) or real output accepted by the xog driver.
#more info: https://wiki.archlinux.org/title/Extreme_Multihead#VNC
@hpsaturn
hpsaturn / platformio.ini
Last active March 9, 2021 08:54
Basic PlatformIO ini file for build Arduino .ino projects. (only put together ino file)
[platformio]
src_dir = .
[wifi]
; ssid = **s
; password = ***
ssid = ${sysenv.PIO_WIFI_SSID}
password = ${sysenv.PIO_WIFI_PASSWORD}
[common_env_data]
@hpsaturn
hpsaturn / temp.py
Created February 4, 2021 00:48
Micropython Raspberry Pico - Temperature test
import machine
import utime
sensor = machine.ADC(4)
factor = 3.3 / (65355)
led = machine.Pin(25,machine.Pin.OUT)
while True:
read = sensor.read_u16() * factor
temp = 27 - (read - 0.706)/0.001721
@hpsaturn
hpsaturn / bluetooth_serial.md
Created April 6, 2020 09:44 — forked from 0/bluetooth_serial.md
Connecting a Bluetooth device for serial communication on Arch Linux.

The following are instructions for connecting a Bluetooth device for serial communication on Arch Linux using BlueZ 5.31.

Prerequisites

The following packages are required:

  • bluez: bluetoothd
  • bluez-utils: bluetoothctl, rfcomm
@hpsaturn
hpsaturn / memof.sh
Created July 15, 2018 19:32
Get the total of memory from a procces and her threads
#!/bin/bash
cmd=$1
mem=`ps -eo %mem,cmd --sort=-%mem | grep -i $cmd | awk -F ' ' '{sum += $1} END {print sum}'`
memtotal=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`
memcmd=`awk 'BEGIN{printf "%.2f\n", (("'$mem'"*"'$memtotal'")/100000)}'`
echo "${memcmd} Mb (${mem}%)"
@hpsaturn
hpsaturn / ubuntu-cli-install-android-sdk.sh
Created April 25, 2018 03:37 — forked from xiaokangwang/ubuntu-cli-install-android-sdk.sh
Install Android SDK on headless Ubuntu linux machine via command line, so that you can compile open source Android apps.
#!/bin/bash
# Thanks to https://gist.github.com/wenzhixin/43cf3ce909c24948c6e7
# Execute this script in your home directory. Lines 17 and 21 will prompt you for a y/n
# Install Oracle JDK 8
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install -y oracle-java8-installer
apt-get install -y unzip make expect # NDK stuff
import sys
import time
import getopt
import alsaaudio
def usage():
sys.stderr.write('usage: recordtest.py [-c <card>] <file>\n')
sys.exit(2)
if __name__ == '__main__':
#!/usr/bin/env sh
set -e
if [ -z "$NDK_ROOT" ] && [ "$#" -eq 0 ]; then
echo 'Either $NDK_ROOT should be set or provided as argument'
echo "e.g., 'export NDK_ROOT=/path/to/ndk' or"
echo " '${0} /path/to/ndk'"
exit 1
else
NDK_ROOT="${1:-${NDK_ROOT}}"
#!/usr/bin/env sh
set -e
if [ -z "$NDK_ROOT" ] && [ "$#" -eq 0 ]; then
echo 'Either $NDK_ROOT should be set or provided as argument'
echo "e.g., 'export NDK_ROOT=/path/to/ndk' or"
echo " '${0} /path/to/ndk'"
exit 1
else
NDK_ROOT="${1:-${NDK_ROOT}}"