Skip to content

Instantly share code, notes, and snippets.

@litetex
litetex / Description.md
Last active March 2, 2024 03:12
Serilog (C#): How to get current MethodName, FileName/Path and LineNumber without reflection

Serilog (C#): How to get the current MethodName, FileName/Path and LineNumber without reflection

This is a simple setup for reflectionless logging with serilog using caller information (and a single static class).

See also https://stackoverflow.com/a/46905798

Log.cs

Create your own Log.cs in your Root-Namespace (you can use the class below).

This class is required to detect where the call is coming from; it uses Caller-Information to speed up the program execution, because the attributes are resolved at compile-time.

@vurdalakov
vurdalakov / ImageSharpExtensions.cs
Last active May 20, 2023 11:18
SixLabors.ImageSharp extensions: convert Image<TPixel> to byte array and System.Drawing.Bitmap etc.
namespace Vurdalakov
{
using System;
using System.IO;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
@heardk
heardk / OneNote-to-MD.md
Last active May 11, 2024 14:28
Convert notes from OneNote into Markdown

Converting One Note to Markdown

This is an example of how to convert notes from OneNote into Markdown to use in other, less annoying Note applications. I am using PowerShell on Windows here, but other shell/scripting environments would work as well. If you want separate .md files, you'll need to export your OneNote pages separately. Exporting a section, or a selection of pages creates a single .docx file.

  • Download and install Pandoc
  • Export each of your note pages to a .docx (Word) format using OneNote export from the File menu
  • Gather all of these .docx files into a directory
  • Open directory in File Explorer
  • Open Powershell from the File Explorer using File -> Open Windows Powersell
  • Run the following command:
@b-anand
b-anand / AsyncReaderWriterSpinLock.cs
Created July 16, 2018 03:29
Async Reader Writer Spin Lock
using System;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// The async reader writer spin lock.
/// </summary>
public class AsyncReaderWriterSpinLock
{
/// <summary>
@ErikAugust
ErikAugust / spectre.c
Last active May 16, 2024 10:27
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@ivanskodje
ivanskodje / youtube-dl-download-pluralsight-videos.md
Last active October 1, 2023 07:47
youtube-dl for downloading pluralsight videos

Downloading Videos from Pluralsight

Disclaimer

Pluralsight do not permit users to download their videos.
If you are an user of pluralsight you have agreed with their ToS,
and are thusly refrained from doing so.
Use this knowledge at your own risk.

youtube-dl for Windows

@vbfox
vbfox / LibGit2SharpForLinqPad.cs
Last active May 20, 2019 18:32
Helps libgit2sharp to find it's native dll in LINQPad when loaded via NuGet
static class LibGit2SharpForLinqPad
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern bool SetDllDirectory(string lpPathName);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetDllDirectory", SetLastError = true)]
static extern uint GetDllDirectoryPInvoke(uint length, StringBuilder lpPathName);
static string GetDllDirectory()
{
@peter-leonov
peter-leonov / bomb.sh
Last active November 22, 2019 03:46
docker fork bomb
docker run ruby ruby -e 'loop { fork { fork { sleep 0.1 } } }'
@xvitaly
xvitaly / remove_crw.cmd
Last active March 16, 2024 16:12
Remove telemetry updates for Windows 7 and 8.1
@echo off
echo Uninstalling KB3075249 (telemetry for Win7/8.1)
start /w wusa.exe /uninstall /kb:3075249 /quiet /norestart
echo Uninstalling KB3080149 (telemetry for Win7/8.1)
start /w wusa.exe /uninstall /kb:3080149 /quiet /norestart
echo Uninstalling KB3021917 (telemetry for Win7)
start /w wusa.exe /uninstall /kb:3021917 /quiet /norestart
echo Uninstalling KB3022345 (telemetry)
start /w wusa.exe /uninstall /kb:3022345 /quiet /norestart
echo Uninstalling KB3068708 (telemetry)
@topheman
topheman / git-notes.md
Created June 29, 2015 17:39
Git notes cheat sheet