Skip to content

Instantly share code, notes, and snippets.

@aensidhe
aensidhe / 00.results.md
Last active April 4, 2020 08:02
Compiler still can't write if for me. M3 variant - all credits to @Ilchert
BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18363
Intel Core i7-8750H CPU 2.20GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
.NET Core SDK=3.1.100
  [Host]     : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT
  Job-TJOYHS : .NET Core 2.2.8 (CoreCLR 4.6.28207.03, CoreFX 4.6.28208.02), X64 RyuJIT
  Job-OVZXZY : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT
@aensidhe
aensidhe / 01. Program.cs
Created June 20, 2019 06:10
stackalloc valuetuples
using System;
namespace Unsafe
{
class Program
{
static unsafe void Main(string[] args)
{
var v = stackalloc (int, int)[]
{
@aensidhe
aensidhe / 01. Program.cs
Created May 30, 2019 13:34
NLog example
using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using NLog.Web;
using Serilog;
namespace WebApplication1
{
public class Program
@aensidhe
aensidhe / 01. Program.cs
Last active May 29, 2019 15:08
Logging into relative path
using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Serilog;
namespace WebApplication1
{
public class Program
{
@aensidhe
aensidhe / keybase.md
Created December 29, 2018 11:50
keybase.md

Keybase proof

I hereby claim:

  • I am aensidhe on github.
  • I am aensidhe (https://keybase.io/aensidhe) on keybase.
  • I have a public key ASDtJML5IofQ_pGIhkVynRAROmoQ5gZc7JNVRNGl3cFd4go

To claim this, I am signing this object:

@aensidhe
aensidhe / msgpack.cs
Created July 17, 2018 20:38
Nice code
public static bool TryReadExtension(ReadOnlySpan<byte> buffer, out byte type, out IMemoryOwner<byte> extension, out int readSize)
{
extension = null;
return TryReadExtensionHeader(buffer, out type, out var length, out readSize)
&& length <= int.MaxValue
&& TryReadExtension(buffer, (int) length, ref extension, ref readSize);
}
@aensidhe
aensidhe / imagemagick.cs
Created December 21, 2017 22:09
Trying to write a wrapper to ImageMagick
var histogram = GetImageHistogram(this.wand, out var lenPtr);
var len = lenPtr.ToUInt32();
var result = new Dictionary<MagickColor, int>();
try
{
for (var i = 0; i < len; i++)
{
var ptr = histogram + i * IntPtr.Size;
Console.WriteLine($"{i} iteration, ptr: {histogram}, cur: {ptr}");
@aensidhe
aensidhe / 1.lua
Last active July 1, 2018 18:23
reload
function reload ()
log.info(' module reloading started ...')
if my_module ~= nil then
-- hot code reload using tarantoolctl or dofile()
-- unload old application
my_module.stop()
-- clear cache for loaded modules and dependencies
package.loaded['my_module'] = nil
end
@aensidhe
aensidhe / log.txt
Last active November 11, 2016 21:07
tarantool.error
2016-11-11 19:42:20.080 [1] main/105/applier/10.31.200.12:3301 I> authenticated
2016-11-11 19:42:20.081 [1] main/105/applier/10.31.200.12:3301 I> can't read row
2016-11-11 19:42:20.081 [1] main/105/applier/10.31.200.12:3301 xrow.cc:265 E> ER_CLUSTER_ID_MISMATCH: Cluster id of the replica fa84c44b-176f-40dc-a63c-40b1346f173f doesn't match cluster id of the master b43b1197-f087-4945-8e4b-fb83aff5cb74
2016-11-11 19:53:21.933 [1] wal/102/wal I> creating `/var/lib/tarantool/00000000000000031719.xlog.inprogress'
2016-11-11 20:10:47.001 [1] main/108/snapshot_daemon I> making snapshot...
@aensidhe
aensidhe / sample.cs
Last active August 3, 2016 10:32
Tarantool box info
using System;
using System.Net;
using System.Threading.Tasks;
using MsgPack.Light;
using Tarantool.Client;
using Tarantool.Client.Model;
using Tuple = Tarantool.Client.Model.Tuple;
namespace Tarantool.BoxInfo
{