Skip to content

Instantly share code, notes, and snippets.

View kroa38's full-sized avatar
๐Ÿ˜ƒ

blop kroa38

๐Ÿ˜ƒ
View GitHub Profile
@kroa38
kroa38 / time_resync.bat
Created June 19, 2024 16:16
Windows 11 Time resync
# Windows 11 Time resync script
# Place this batch script inside your home directory
# Use Task scheduler and create a simple task with Max Elevation Priority that start with windows session
echo start sync
net start w32time
w32tm /resync
echo sync complete
@kroa38
kroa38 / available_mem.py
Created December 9, 2022 17:56
Python Psutil for available memory
import psutil
def mem_info():
a= psutil.virtual_memory().available* 100 / psutil.virtual_memory().total
print("percent of available memory :",a)
if __name__ == "__main__":
mem_info()
@kroa38
kroa38 / gist:77cfa1146cfba30a6dce1d03cde22e01
Created April 26, 2022 13:26
install a list of packages using apt-get
https://askubuntu.com/questions/541781/how-to-install-a-list-of-packages-using-apt-get
'pkglist' is a file containning the list of package to install
sudo apt-get -y install $(cat pkglist)
or
while read -r line; do sudo apt-get -y install "$line"; done < /path/to/the/packages/pkglist
@kroa38
kroa38 / gist:90671b5a2fb21d4814c3e910f08e76d0
Last active January 20, 2022 18:03
standard deviation
// Calculate the diff of two SD.
// the data tab as 12 value and the 6 first values produce the same
// SD as the 6 last
#include <math.h>
#include <stdio.h>
#define tsize 12
unsigned int data[tsize]={3894,3894,3865,3865,3807,3807,388,288,231,231,201,201};
@kroa38
kroa38 / gist:fc2af2af90ef827e17ce9e6f8b9ec183
Created January 13, 2021 17:01
Invert bitwise left shift operation
// Online C compiler to run C program online
// https://www.programiz.com/c-programming/online-compiler/
// print the bit set of a number
#include <stdio.h>
int main() {
// 1, 2, 4, 8, 10, 20, 40, 80
printf("Start \n\r");
unsigned int i;
unsigned int N = 0xFD; // 32-bit word to find the log base 2 of
# Cal Fibonaci number and display calculation time
# For n=2000000 takes 44s on my W10 I5-2500K PC
import time
def fibo(n):
a=0
b=1
for N in range(n):
b, a = a+b, b
return b
@kroa38
kroa38 / gist:60c334dbbbf40c5d2dfaa810d7ada41e
Created November 9, 2020 08:08
Jump to Application (example for STM32)
typedef void (*pFunction)(void);
pFunction JumpToApplication;
uint32_t JumpAddress;
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
JumpToApplication = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
@kroa38
kroa38 / gist:8dffa5f277b15590ebfae266133e9e4f
Created November 9, 2020 07:58
Convert a string to an integer
/**
* @brief Convert a string to an integer
* @param p_inputstr: The string to be converted
* @param p_intnum: The integer value
* @retval 1: Correct
* 0: Error
*/
uint32_t Str2Int(uint8_t *p_inputstr, uint32_t *p_intnum)
{
uint32_t i = 0, res = 0;
@kroa38
kroa38 / gist:5ee8e1aa57fdc4603600dd348182a5df
Created November 9, 2020 07:55
Convert an Integer to a string
void Int2Str(uint8_t *p_str, uint32_t intnum)
{
uint32_t i, divider = 1000000000, pos = 0, status = 0;
for (i = 0; i < 10; i++)
{
p_str[pos++] = (intnum / divider) + 48;
intnum = intnum % divider;
divider /= 10;
@kroa38
kroa38 / gist:0b55f368cdf98ed25f471df93acf8656
Created October 30, 2020 16:54
STM32 Store firmware version and date in Flash ( linker option )
// STEP 1
/* First edit the compiler file *.ld */
/* Example with a STM32(128K/36k) in the compiler file add to memories definition */
/*****************************************************************************************************/
/* Memories definition */
MEMORY