Skip to content

Instantly share code, notes, and snippets.

View Mart-Bogdan's full-sized avatar
🤘
|m/

Bohdan Mart Mart-Bogdan

🤘
|m/
View GitHub Profile
@Mart-Bogdan
Mart-Bogdan / 1_MarshalBench.cs
Last active July 13, 2023 19:40
Dotnet overhead of P/Invoke with ref arguments
using System.Runtime.InteropServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace net_array_bench_app.Benches
{
// [SimpleJob(RuntimeMoniker.NetCoreApp31)]
// [SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net70)]
@Mart-Bogdan
Mart-Bogdan / c_nostd.txt
Created May 29, 2023 19:09 — forked from tcoppex/c_nostd.txt
Writing C software without the standard library [Linux Edition] - Franc[e]sco's Gopherspace
###################################################################
Writing C software without the standard library
Linux Edition
###################################################################
There are many tutorials on the web that explain how to build a
simple hello world in C without the libc on AMD64, but most of them
stop there.
I will provide a more complete explanation that will allow you to
build yourself a little framework to write more complex programs.
@Mart-Bogdan
Mart-Bogdan / android-llama-alternatives.md
Created January 3, 2023 18:52 — forked from bmaupin/android-llama-alternatives.md
Alternatives to Llama for Android

Goal

Find a replacement for Llama (R.I.P. 😢)

Conclusion

🦙 Keep using Llama! 🦙

  • Llama still works and no other application seems to match Llama in terms of ease of use and cell-tower location (Llama's killer feature)
  • Cell-tower location UX seems to be unmatched by the alternatives (training new locations, ignoring towers, seeing location events)
@Mart-Bogdan
Mart-Bogdan / ksp_debugging.md
Created December 19, 2022 00:51 — forked from gotmachine/ksp_debugging.md
Debugging and profiling KSP plugins

This guide applies only to KSP 1.8 and latter. It covers modifying a KSP installation to allow :

  • In IDE debugging of KSP plugins by using breakpoints, inspecting runtime variables, doing step-by-step execution, etc. Both Visual Studio (including VS for Mac) and JetBrains Rider support debugging Unity games, and by extension KSP plugins.
  • Using the Unity editor profiling tools, which include great tools to measure and analyze CPU/GPU usage and memory allocations.

This guide is extensively tested for a Windows / Visual Studio scenario. However, it is theoretically possible to make all that work under MacOS or Linux, either with the Rider IDE or Visual Studio for Mac. This guide has limited details about those scenarios. I encourage you to leave a comment if you have additional information / experience.

Modifying KSP for profiling/debugging

Downloading the Unity editor

@Mart-Bogdan
Mart-Bogdan / attch_vs_code.rs
Created November 19, 2022 01:29
Rust snippet to attach VS Code debugger to current running process
// can be used to attach to existing running app.
// If you need to run app from shell, for example, passing in stdin or command line args, or whatever else.
#[allow(unused)]
fn attch_vs_code() {
use std::time::Duration;
let url = format!(
"vscode://vadimcn.vscode-lldb/launch/config?{{'request':'attach','pid':{}}}",
std::process::id()
@Mart-Bogdan
Mart-Bogdan / counting_allocator.rs
Created November 19, 2022 01:27
Rust allocator to debug allocations
use std::alloc::{System, GlobalAlloc};
static SYS_ALLOC: System = System;
struct CountingAlloc {
bytes_allocated: AtomicIsize,
bytes_used: AtomicIsize
}
@Mart-Bogdan
Mart-Bogdan / experiments.rs
Created November 19, 2022 01:25
windows file size experiments
#![allow(unused_imports, unused)]
use std::error::Error;
use std::ffi::c_void;
use std::fs::{File, OpenOptions};
use std::iter::once;
use std::os::windows::ffi::OsStrExt;
use std::path::Path;
use std::process::exit;
use std::{io, mem};
@Mart-Bogdan
Mart-Bogdan / test.rs
Created April 10, 2022 20:32
Snippet to run SetUp/TeadDown in Rust Unit Tests
// Kudos Eric Opines https://medium.com/@ericdreichert/test-setup-and-teardown-in-rust-without-a-framework-ba32d97aa5ab
// This is bit modified post from his blog post.
#[cfg(test)]
mod tests {
use std::fs::read_dir;
use std::panic;
#[test]
fn it_works() {
run_test(|| {
@Mart-Bogdan
Mart-Bogdan / md5chunks.py
Last active October 18, 2020 12:20 — forked from fmarani/md5chunks.py
calculate md5 hashes of chunks of a file, configurable block size
#!/usr/bin/env python
from optparse import OptionParser
from pathlib import Path
import hashlib
import sys
parser = OptionParser()
parser.add_option("-b", "--blocksize", dest="blocksize", type=int, default=1024,
help="Specify blocksize", metavar="blocksize")
@Mart-Bogdan
Mart-Bogdan / SmartMigrationsTable.cs
Created September 1, 2020 12:15
EF track migration apply time
public partial class SmartMigrationsTable : Migration
{
protected override void Up(MigrationBuilder builder)
{
builder.Sql("alter table \"__EFMigrationsHistory\" add column IF NOT EXISTS id serial;");
builder.Sql(
"alter table \"__EFMigrationsHistory\" add column IF NOT EXISTS created_ts timestamptz default now();"
);
}