Skip to content

Instantly share code, notes, and snippets.

View ForNeVeR's full-sized avatar
🦑

Friedrich von Never ForNeVeR

🦑
View GitHub Profile
@ForNeVeR
ForNeVeR / FalseSharing.cs
Last active February 21, 2020 10:11
False sharing test in C#.
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace ConsoleApplication2
{
class Program
{
struct Fuck
@ForNeVeR
ForNeVeR / CreateStaticClass.cs
Last active January 12, 2018 13:39
Static class creation test.
using System;
using System.Reflection;
class Program
{
static void Main(string[] args)
{
var allocate = typeof(RuntimeTypeHandle).GetMethod("Allocate", BindingFlags.NonPublic | BindingFlags.Static);
var math = allocate.Invoke(null, new[] { typeof (Math) });
using System;
using System.Reflection;
interface ILoveCats
{ }
class Program
{
static void Main(string[] args)
{
@ForNeVeR
ForNeVeR / main.cpp
Created February 14, 2014 14:32
"ЩИ!!!Симулятор жестокости" - http://www.gamedev.ru/projects/forum/?id=160897
#define WIN32_LEAN_AND_MEAN // just say no to MFC
#define INIT_GUID
#include "hge.h"
#include <hgesprite.h>
#include <hgefont.h>
#include <hgecolor.h>
@ForNeVeR
ForNeVeR / Diagnose-ChocolateyError.ps1
Created March 7, 2016 07:39
Search registry errors to fix them manually.
$local_key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
$machine_key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*'
$machine_key6432 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
$items = Get-ChildItem @($local_key, $machine_key, $machine_key6432)
$ErrorActionPreference = 'Stop'
foreach ($item in $items) {
Write-Output $item.PSPath
$null = Get-ItemProperty $item.PSPath
}
@ForNeVeR
ForNeVeR / Barbeque.cs
Created October 21, 2016 07:32
Bool not equal to true neither to false.
using System;
using System.Runtime.InteropServices;
namespace ConsoleApplication2
{
[StructLayout(LayoutKind.Explicit)]
internal struct Barbeque
{
[FieldOffset(0)] public int Barbe;
[FieldOffset(0)] public bool Que;
@ForNeVeR
ForNeVeR / w3g_actions.txt
Last active November 11, 2019 08:48 — forked from stattrak-dragonlore/w3g_format.txt
WarCraft III Replay file format description
*******************************************************************************
* WarCraft III Replay action format description *
* *
* document version: 1.01 *
* document date : 2006-03-25 *
* document authors: blue, nagger *
* *
* For more informtion about w3g file format, please visit: *
* http://w3g.deepnode.de *
* *
@ForNeVeR
ForNeVeR / DelegateConverter.fs
Last active April 27, 2022 16:22
Mystical delegate converter in F#
open System
type Del = delegate of int -> int
let convert1 (d: Func<int, int>): Del = (# "" d : Del #)
let convert2 (d: Func<int, int>): Del = Del(fun x -> d.Invoke x)
[<EntryPoint>]
let main argv =
let x = Func<int, int>(fun x -> x)
@ForNeVeR
ForNeVeR / InterfaceMaps.cs
Last active April 27, 2022 16:17
Shows how interface maps work for implicit and explicit interface implementations in C#.
using System;
using System.Reflection;
public interface ITest
{
void TestFun(int arg);
}
public class TestClass : ITest
{
@ForNeVeR
ForNeVeR / DeclareAsMath.cs
Last active April 27, 2022 16:16
Declare an object as an instance of System.Math.
using System;
using System.Linq;
using System.Reflection;
class Program
{
class MyClass
{
}