Skip to content

Instantly share code, notes, and snippets.

@ag88
ag88 / pstop.py
Last active May 6, 2024 07:48
Linux check cpu hog processes
#!/usr/bin/env python3
#
# requires psutil (pip3 install psutil)
#
# This script runs ps_util.cpu_percent(interval=0.5) for each process to calc
# the cpu utilization percentage
# It does so concurrently as otherwise each calls sleeps 0.5 secs to sample the data
# to run it faster use more threads in ThreadPoolExecutor(max_worker=x or
# reduce the interval for cpu_percent(interval=x
# To make readings more 'accurate' use a longer interval e.g. 1.0 for 1s.
@ag88
ag88 / sdimage-u-boot-patcher.py
Last active April 27, 2024 08:38
linux sd image u-boot patcher - e.g. Armbian etc
#!/usr/bin/env python3
#usage: sdimage-u-boot-patcher.py [-h] [--nobak] [--ignimgsize] [--bkname BKNAME] image uboot_bin
#
#patch u-boot binary into image
#
#positional arguments:
# image image file
# uboot_bin u-boot bin file
#
#options:
@ag88
ag88 / hostapd.conf.md
Last active April 16, 2024 06:38
hostapd.conf for 2.4g or 5g 802.11ac on Orangepi Zero 3
  • install hostapd
    apt install hostapd  
    
  • configure hostapd
    /etc/hostapd/hostapd.conf
# the interface used by the AP
interface=wlan0
@ag88
ag88 / armbbnspawn.md
Last active January 16, 2024 10:50
Building Armbian using Ubuntu (jammy) in a systemd-nspawn container

Building Armbian using Ubuntu (jammy) in a systemd-nspawn container

These are some steps for building armbian using Ubuntu (jammy) in a systemd-nspawn container. This is an alternative for building armbian from a Linux system (as like docker containers).

However this method requires the PREFER_DOCKER=no build flag as docker engines cannot be run within a systemd-nspawn container.

@ag88
ag88 / WebdavFileSystem.java
Last active March 2, 2023 20:19
webdav-nio-filesystem-provider
/*
Copyright 2012-2013 University of Stavanger, Norway
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@ag88
ag88 / Makefile-stm32duino-stm32f407ve-black-marlin
Last active August 14, 2021 04:15
Makefile for stm32duino for board STM32F407VE black for Marlin firmware 2.0
# version 0 (alpha)
#
# This make file for stm32duino core and Marlin 2.0 is possibly *dangerous*
# i.e. it compiles the sources (in src, Marlin, Arduino_Core_STM32, variants and CMSIS_5) directory
# and overwrite all the stuff in $(out_dir)
# $(out_dir) is the binary directory where the object files are dumped there
#
# make clean *deletes* the *$(out_dir)* (coded here as build )
#
# this is a relative path makefile
@ag88
ag88 / Makefile-stm32duino-stm32f407ve-black
Last active August 11, 2021 11:23
Makefile for stm32duino for board STM32F407VE black
# version 0 (alpha)
# this is only tested in linux
# this is for this board https://stm32-base.org/boards/STM32F407VET6-STM32-F4VE-V2.0.html
#
# This make file for stm32duino core is possibly *dangerous*
# i.e. it compiles the sources (in src and Arduino_Core_STM32) directory
# and overwrite all the stuff in $(out_dir)
# $(out_dir) is the binary directory where the object files are dumped there
#
# make clean *deletes* the *$(out_dir)* (coded here as build )
@ag88
ag88 / RTClock.cpp
Last active March 11, 2021 09:55
stm32duino libmaple f4 backup registers
/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 LeafLabs LLC.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
@ag88
ag88 / gist:7da790bb0c2473a08aeeba2cd883bf49
Last active November 27, 2020 14:35
deploy tomcat webapp.war from command line using curl
curl --request PUT --upload-file webapp.war --basic --user user:password \
http://hostname:port/manager/text/deploy?path=/web_path\&update=true
@ag88
ag88 / stm32usb-serial-esp8266.ino
Last active December 16, 2019 10:05
stm32duino (libmaple core) usb-serial with connectivity to ESP8266
/* distribution: MIT lic*/
#include "Arduino.h"
#include <usb_serial.h>
#include <HardwareSerial.h>
#include <libmaple/usart.h>
#include <libmaple/usb_cdcacm.h>
void docmd();
bool chkcmd();
void setserial();