Skip to content

Instantly share code, notes, and snippets.

View xoofx's full-sized avatar
🏠
Working from home

Alexandre Mutel xoofx

🏠
Working from home
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.ServiceModel.Dispatcher;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.Graphics.Display;
using Windows.Storage;
using Windows.Storage.Pickers;
@xoofx
xoofx / github_webhook_received.js
Created October 7, 2014 13:43
github webhook received sample (POST)
{
"action": "reopened",
"number": 3,
"pull_request": {
"url": "https://api.github.com/repos/xoofx/SharpCLABot/pulls/3",
"id": 22243469,
"html_url": "https://github.com/xoofx/SharpCLABot/pull/3",
"diff_url": "https://github.com/xoofx/SharpCLABot/pull/3.diff",
"patch_url": "https://github.com/xoofx/SharpCLABot/pull/3.patch",
"issue_url": "https://api.github.com/repos/xoofx/SharpCLABot/issues/3",
using System;
public struct ValueBase
{
public int A;
public int B;
public int Calculate()
{
@xoofx
xoofx / JSDL1.yaml
Last active December 24, 2015 02:19
This is a translation of the JSDL sample from the JSON Description Language http://area.autodesk.com/blogs/chris/json-scene-description-language. You can copy paste the following YAML grammar on an online YAML parser (like http://yaml-online-parser.appspot.com/ )
# YAML Version of the JSDL Autodesk example http://area.autodesk.com/blogs/chris/json-scene-description-language
# This version is using flow nodes [ ] { } like JSON but is less verbose by removing all double quotes
{
id: my_scene,
roots: [
{
assets: [Square],
children: [
{
transform:
@xoofx
xoofx / Microsoft.Common.CurrentVersion.js
Created May 12, 2016 15:26
Microsoft.Common.CurrentVersion.targets with a DSL
/***********************************************************************************************
Microsoft.Common.CurrentVersion.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
This file defines the steps in the standard build process for .NET projects. It
contains all the steps that are common among the different .NET languages, such as
Visual Basic, and Visual C#.
Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************/
@xoofx
xoofx / PatchBenchmarkDotNet.txt
Last active May 25, 2016 21:47
Hardcoded patch for BenchmarkDotNet to have fixed GC results in SingleRun mode (only working for Markdig benchmarks env)
var config = ManualConfig.Create(DefaultConfig.Instance);
var gcDiagnoser = new MemoryDiagnoser();
config.Add(new Job { Mode = Mode.SingleRun, LaunchCount = 2, WarmupCount = 2, TargetCount = 10 });
config.Add(gcDiagnoser);
_________________________________ Patch for BenchMarkDotNet to have precise GC:
diff --git a/BenchmarkDotNet/Running/MethodInvoker.cs b/BenchmarkDotNet/Running/MethodInvoker.cs
index e8d8de5..6a46aa2 100644
@xoofx
xoofx / IPIntegerToString.cs
Created June 5, 2016 23:29
Convert an integer to a string IP address
// Follow up of the discussion https://twitter.com/stebets/status/739563007202758656
public static unsafe string IntegerToIPAddress(uint input)
{
var text = stackalloc char[15];
var ptext = text + 15;
for (int i = 0; i < 4; i++)
{
if (i > 0)
{
@xoofx
xoofx / IPIntegerToString2.cs
Created June 6, 2016 04:39
Convert IP integer address to a string
// Follow up of https://twitter.com/stebets/status/739563007202758656
private static readonly string[] ByteToString = Enumerable.Range(0, 256).Select(x => x.ToString()).ToArray();
public unsafe static string FastIntegerToIPAddress2(uint input)
{
// t3.t2.t1.t0
var t0 = ByteToString[input & 0xFF];
input = input >> 8;
var t1 = ByteToString[input & 0xFF];
input = input >> 8;
@xoofx
xoofx / TestBenchNewArrayVsListVsDictionary.cs
Created June 13, 2016 05:29
Test perf allocation/fillup between an Array, a List and a Dictionary
// Check the performance of using an Array (preallocated) vs a List<T>, vs a Dictionary<string, T>
// both in terms of CPU and memory
// * Summary *
//
// BenchmarkDotNet=v0.9.7.0
// OS=Microsoft Windows NT 6.2.9200.0
// Processor=Intel(R) Core(TM) i7-4770 CPU 3.40GHz, ProcessorCount=8
// Frequency=3319351 ticks, Resolution=301.2637 ns, Timer=TSC
// HostCLR=MS.NET 4.0.30319.42000, Arch=32-bit RELEASE
// JitModules=clrjit-v4.6.1080.0
@xoofx
xoofx / ProgramInlineAsm.cs
Created May 25, 2016 03:08
Shows how to use the prototype inline IL ASM with Roslyn
using System;
using System.IO;
using System.Runtime.CompilerServices;
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Method)]
internal class CompilerIntrinsicAttribute : Attribute { }
}