Skip to content

Instantly share code, notes, and snippets.

View mykola2312's full-sized avatar

mykola2312 mykola2312

  • Saint-Brune 1147
  • 07:16 (UTC +03:00)
View GitHub Profile
@mykola2312
mykola2312 / rip.sh
Created August 18, 2024 02:48
bash script for CD/DVD music ripping
#!/usr/bin/env bash
# first, we need to determine type of disk
# this can be achieved by trying first mount_cd9660 and checking error
# if it returns "Device not configured" - we need to wait,
# otherwise its not CD9660 fs and we can move to next
#
# try mounting UDF, if it returns "Invalid argument" - it's not an UDF
#
# the last remaining disc type is CD audio disc, that we must
@mykola2312
mykola2312 / nm-fix-dns.sh
Created June 9, 2024 07:56
Make NetworkManager use proper DNS
#!/bin/sh
dns="1.1.1.1 8.8.8.8 8.8.4.4"
active_network=$(nmcli con show --active | awk 'NR==2 {print $2}')
nmcli connection modify uuid $active_network ipv4.ignore-auto-dns yes
nmcli connection modify uuid $active_network ipv4.dns "$dns"
echo "DNS fixed for ${active_network}"
@mykola2312
mykola2312 / mpv-socket-client.c
Created April 25, 2024 23:17
mpv ipc socket client
#include <sys/un.h>
#include <sys/unistd.h>
#include <sys/socket.h>
#include <stdio.h>
int main() {
int sockfd = socket(PF_UNIX, SOCK_STREAM, 0);
struct sockaddr_un addr = {0};
if (sockfd < 0) {
@mykola2312
mykola2312 / strhex.c
Last active March 31, 2022 14:59
text hex to binary data
int htoi(char h)
{
return h < 0x3A ? h - 0x30 : h - 0x57;
}
void strhex(const char* str, uint8_t* out)
{
for (unsigned i = 0; i < strlen(str) >> 1; i++)
out[i] = htoi(str[i<<1]) << 4 | htoi(str[i<<1|1]);
}
#include "chook.h"
CHook::CHook(DWORD Func,SIZE_T Size)
{
pFunc = Func;
DetourSize = Size;
OrigBytes = (PBYTE)malloc(Size);
}
#include "disas.h"
opcode_t arch[] = {
{'\x90',1},{'\x81',6},{'\xC7',6},{'\xA1',5},
{'\x74',2},{'\x33',2},{'\x89',7},{'\x6A',2},
{'\xE8',5},{'\xE9',5},{'\x50',1},{'\x51',1},
{'\x52',1},{'\x53',1},{'\x54',1},{'\x55',1},
{'\x56',1},{'\x57',1},{'\x0E',1},{'\x1E',1},
{'\x16',1},{'\x06',1},{'\x75',2},{'\xCC',1},
{'\xC2',3},{'\xC3',1},{'\xCD',2},{'\x58',1},
void dump_buffer(API::Buffer& buf, unsigned codepage = 0)
{
const char ascii_lup = 201, ascii_rup = 187,
ascii_lsp = 199, ascii_rsp = 182,
ascii_lbt = 200, ascii_rbt = 188,
ascii_up_cross = 209, ascii_bt_cross = 207,
ascii_cross = 197,
ascii_v_sp = 179, ascii_h_sp = 196,
ascii_v_border = 186, ascii_h_border = 205;