Skip to content

Instantly share code, notes, and snippets.

View RomanRobot's full-sized avatar

Jehanlos Roman RomanRobot

View GitHub Profile
@RomanRobot
RomanRobot / unreal_engine_md5.cpp
Created May 9, 2023 00:44
Calculate MD5 of a file in Unreal Engine
FString MD5(FString file_name)
{
std::ifstream file(std::string(TCHAR_TO_UTF8(*file_name)), std::ios::binary);
if (!file) {
return FString();
}
// Compute the MD5 hash of the file contents
FMD5 md5;
char buffer[4096];
@RomanRobot
RomanRobot / to_si_string.cpp
Created February 23, 2023 20:06
Converts a double to an SI string. Converted to C++ from https://stackoverflow.com/a/12181661/719528.
// Unicode `μ` for micro (10e-6)
std::wstring to_si_wstring(double number, int precision)
{
std::wostringstream ss;
ss << std::setprecision(precision);
if (number != 0.0)
{
static const std::array<wchar_t, 17> prefixes = { 'y', 'z', 'a', 'f', 'p', 'n', L'\u03bc', 'm', L'\u200b', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' };
static const size_t zero_degree_index = 8;
@RomanRobot
RomanRobot / synology.filestation.upload.ts
Last active March 17, 2021 09:25
Synology FileStation Upload function (TypeScript, Angular, Capacitor, Filesystem, Ionic, FormData, HttpClient)
import { HttpClient } from '@angular/common/http';
type Response<T> = {
data: T;
success: boolean;
error: {code: number, errors: []};
}
type API = {
name: string,
version: number,