Skip to content

Instantly share code, notes, and snippets.

View vpetrigo's full-sized avatar

Vladimir Petrigo vpetrigo

  • Poland, Kraków
View GitHub Profile
@vpetrigo
vpetrigo / remove-ports.ps1
Created November 30, 2021 13:18
Remove stale USB COM and LPT ports in Windows
Get-PnpDevice -Class "Ports" | select -property "Status","InstanceId" | where -property "status" -value "Unknown" -EQ | foreach { pnputil /remove-device $_.InstanceId }
@vpetrigo
vpetrigo / ffmpeg_g2m_covert.ps1
Created October 11, 2021 16:54
FFmpeg G2M recording convert with Nvidia CUDA to MP4
param(
[string]$in,
[string]$out
)
if ([string]::IsNullOrEmpty($in) -or [string]::IsNullOrEmpty($out)) {
write-host "Specify input and output filenames"
exit 1
}
@vpetrigo
vpetrigo / masquerade_rule.sh
Last active March 8, 2022 16:52
nft util masquerade rule
# eth0 interface to allow masquerading
nft add table ip nat
nft add 'chain ip nat postrouting { type nat hook postrouting priority 100 ; }'
nft add rule nat postrouting oif eth0 masquerade
@vpetrigo
vpetrigo / ffmpeg_mov_to_mp4.ps1
Created April 8, 2021 12:02
Change container type from MOV to MP4 and convert audio from PCM to AAC 320K
Get-ChildItem -Path <path/to/dir> -Filter "*.mov" |
ForEach-Object {
$new_name = $_.Name -replace '.mov','.mp4';
ffmpeg -i "$($_.Name)" -c:v copy -c:a aac -b:a 320k "$new_name";
}
@vpetrigo
vpetrigo / verify.sh
Created December 9, 2020 21:01
Verify file signature with a GPG ASC file
#!/bin/bash
# usage: verify.sh <ASC file name without extension> <signature filename> <file to verify>
# verify.sh 18A9236D file.sig file.txt
asc_filename="$1"
sig="$2"
file_to_verify="$3"
gpg -o ${asc_filename}.gpg --dearmor ${asc_filename}.asc
@vpetrigo
vpetrigo / mem_copy.S
Last active January 9, 2020 09:20
ARM assembler memory copy example
.thumb_func
.align 2
.globl mem_copy
.type mem_copy, %function
mem_copy:
cmp r1, r2
itte ne
ldrne r3, [r0], #4
strne r3, [r1], #4
beq 1f
@vpetrigo
vpetrigo / Test.proto
Created August 22, 2019 09:57
Pack repeated fields with Nanopb library
syntax = "proto3";
message SearchRequest {
string query = 1;
}
message Result {
repeated SearchRequest requests = 1;
}
@vpetrigo
vpetrigo / hex_str_to_byte.c
Created June 27, 2019 15:44
Convert HEX string without spaces into an array of bytes
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char s[] = "CAFEDEADBEEF010203040506";
size_t len = strlen(s);
unsigned char bytes[len / 2];
@vpetrigo
vpetrigo / run.bat
Created October 3, 2018 08:27
Rowley CrossWorks crossscript example
"<path/to/CrossWorks>\bin\crossscript.exe" -load "script.js" -verbose "count();"
// string_carryover.c : Defines the entry point for the console application.
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#define MAX_LINES 2
#define MAX_LINE_LENGTH 14
#define NULL_TERM_LINE_LENGTH (MAX_LINE_LENGTH + 1)
#define MIN_HYPHEN_CAP 4