Skip to content

Instantly share code, notes, and snippets.

View namazso's full-sized avatar
😂
👌

namazso

😂
👌
View GitHub Profile
@namazso
namazso / prompt.cpp
Last active January 9, 2021 19:16
win32 text prompt box, like MessageBox but for text
INT_PTR PromptText(const wchar_t* title, wchar_t* text, size_t len)
{
__pragma(pack(push, 1)) struct alignas(DWORD)
{
DLGTEMPLATE hdr{
WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTER,
0,
1,
100,
@namazso
namazso / mbrpart.c
Last active December 25, 2022 20:00
quick raw mbr partition editor
#define _CRT_SECURE_NO_WARNINGS
#define _FILE_OFFSET_BITS 64
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
enum { kSectorSize = 512 };
@namazso
namazso / large_files.c
Created January 23, 2020 05:17
Some helpers to handle large files with pure C
#define _CRT_SECURE_NO_WARNINGS
#define _FILE_OFFSET_BITS 64
#include <stdint.h>
#include <stdio.h>
/* while these are standard C functions used properly, your platform may require additional macros or
* settings to enable proper handling of files larger than 2 or 4 GB */
uint64_t large_getsize(FILE* fp)
{
fseek(fp, 0, SEEK_END);
@namazso
namazso / diskid32.cpp
Created January 15, 2020 17:20
DiskId32 updated, fixed, modernized
// diskid32.cpp - display the details of hard drives in a command window
//
// Modernized version that compiles under VS2019 by namazso at 2020-01-15
// Additional fixes and changes:
// - Rewrote MAC address part to not crash on 0 NICs and support 16+ NICs
// - Removed "ComputerId" and the relevant primitive hash method and parts
//
// 06/11/00 Lynn McGuire written with many contributions from others,
// IDE drives only under Windows NT/2K and 9X,
// maybe SCSI drives later
@namazso
namazso / monstercat_gold_downloader.ps1
Last active December 15, 2019 05:01
Monstercat Gold mass downloader
# use https://addons.mozilla.org/en-US/firefox/addon/export-cookies-txt/ for making cookies.txt
# downloading as zip is broken at the time of writing, therefore per-track downloading is used.
# getting tracks for all releases is also broken at the time, so releases without catalog id
# are still downloaded as zips because you can get zips without the track ids or catalog id.
$format = "flac";
$args = @{
skip=0
limit=50
@namazso
namazso / blake2sp.c
Created July 10, 2019 16:55
Portable single .h + .c BLAKE2sp implementation
// Public domain
// Based on public domain 7zip implementation by Igor Pavlov and Samuel Neves
#include "blake2sp.h"
// Set this if your processor is unaligned little endian
#define LITTLE_ENDIAN_UNALIGNED
#ifdef LITTLE_ENDIAN_UNALIGNED
#define GetUi32(p) (*(const uint32_t *)(const void *)(p))
@namazso
namazso / pdb_parser_lite.cpp
Created April 18, 2018 17:49
A lightweight PDB parser that retrieves type and symbol CodeView streams.
/* MIT License
*
* Copyright (c) namazso 2018
*
* 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 of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
@namazso
namazso / cx_compile_time_unix.hpp
Created July 10, 2017 05:01
Get the compilation time in unix time
namespace cx
{
constexpr bool cx_strcmp_part(const char* const a, const char* const b)
{
return *b ? (*a == *b && cx_strcmp_part(a + 1, b + 1)) : true;
}
constexpr unsigned month_str_to_int(const char* const str)
{