Skip to content

Instantly share code, notes, and snippets.

@AndreiCherniaev
AndreiCherniaev / README.rst
Last active September 11, 2021 05:03 — forked from tkf/README.rst

https://live.staticflickr.com/65535/51444924253_7a5783b9cd_k.jpg

@AndreiCherniaev
AndreiCherniaev / gist:18cd6fa4c769c527bb5e177467226091
Created June 23, 2022 22:28
customize-image.sh with auto mount flash driver to /media/usb
#!/bin/bash
# this is part for armbian
# путь к этому файлу XunlongA/userpatches/customize-image.sh
# arguments: $RELEASE $LINUXFAMILY $BOARD $BUILD_DESKTOP
# This is the image customization script
# NOTE: It is copied to /tmp directory inside the image
# and executed there inside chroot environment
# so don't reference any files that are not already installed
@AndreiCherniaev
AndreiCherniaev / CP1251_to_UTF8
Last active October 5, 2023 11:51
CP1251 to UTF-8
# Устанавливаем https://github.com/nijel/enca
sudo apt-get install enca
# Заходим в папку с исходниками
cd ПутьКПапкеСИсходниками
# Запустим скрипт перевода всего, что в русских кодировках (russian: KOI8-R CP1251 ISO-8859-5 IBM866 maccyr) в UTF-8.
find ./ -name "*.c" -o -name "*.h" -type f | while read file; do enca -L ru -x UTF-8 "$file"; done;
@AndreiCherniaev
AndreiCherniaev / safe_dd.sh
Last active October 6, 2023 11:16
safe dd check does usb drive size == 32GB and after dd .img
# never use this if you have 32 GB hard drive
# never use this if you mount 2 or more 32GB usb flash card in one time
varvar=`blockdev --getsize64 /dev/sda`
# 32GB == 30765219840
if [ $varvar -eq 30765219840 ]; then
dd if=disk.img of=/dev/sda bs=4M conv=fsync status=progress
fi
@AndreiCherniaev
AndreiCherniaev / elmsof_C99.h
Last active January 7, 2024 08:59
Возвращает количество элементов массива, а не размер в байтах как sizeof()
#define elmsof(arr) sizeof(arr)/sizeof(arr[0])
#!/bin/bash
# there are FFmpeg_fixing/build and FFmpeg_fixing/src folders
# $ cd FFmpeg_fixing/build/
# $ ../src/configure >> conflog.txt
# copy part of conflog.txt to demuxers.txt
# since (exclude) "Enabled demuxers:"
cd /home/a/Downloads/myGitHub/FFmpeg_fixing/ffmpeg_config/
rm -f new.txt
@AndreiCherniaev
AndreiCherniaev / text2u8.c
Last active June 1, 2023 02:15
text to uint8_t
#include <stdio.h>
#include <stdint.h>
#include <string.h>
int main()
{
char str[] = {"43074401014501014601014701014807314900044A004B019303FC07E7080C07F203DA087802E34C01014C756D69722D54312043756265536174202F2044657369676E6564206279204C756D69722853656F2053616E4A756E2C4C6565204A756E2C5061726B204A756E546165292020202020202020202020202020000020C24D"};
if(strlen(str) % 2 == 0){
printf("uint8_t arr[%lu]= { 0x", strlen(str)/2);
uint32_t i=0;
@AndreiCherniaev
AndreiCherniaev / main.c
Created October 17, 2023 00:51
How hardcoded arguments in main
std::vector<char*> varguments;
{
varguments.push_back(argv[0]);
// Source
varguments.push_back("./big_buck_bunny_short.mp4 ");
// Destination
varguments.push_back("./big_buck_bunny_short-processed.mp4");
}
#define elmof(arr) ( sizeof(arr[0])==0? 0 : sizeof(arr)/sizeof(arr[0]) )
sudo journalctl --since="- 2 minutes"