Skip to content

Instantly share code, notes, and snippets.

@tsvx
tsvx / Try-AspNetCoreMvc.linq
Last active July 19, 2018 15:07
PoC of ASP.NET Core MVC App in LinqPAD
<Query Kind="Program">
<NuGetReference>Microsoft.AspNetCore</NuGetReference>
<NuGetReference>Microsoft.AspNetCore.Hosting</NuGetReference>
<NuGetReference>Microsoft.AspNetCore.Mvc</NuGetReference>
<NuGetReference>Microsoft.AspNetCore.Routing</NuGetReference>
<NuGetReference>Microsoft.AspNetCore.StaticFiles</NuGetReference>
<NuGetReference>Swashbuckle.AspNetCore</NuGetReference>
<NuGetReference>Swashbuckle.AspNetCore.SwaggerGen</NuGetReference>
<Namespace>Microsoft.AspNetCore</Namespace>
<Namespace>Microsoft.AspNetCore.Builder</Namespace>
@tsvx
tsvx / Jq Issues.md
Last active January 25, 2018 10:51
An example of jq's buffer issue

Some jq issues on Windows.

When applying b2str to the input in (authors-bytes.json), it should give the JSON array of some name as a value and the name's number as a key. But if applying b2utf8, I've got a mess at author 2246 (byte offset 0x108C6) and for the rest of the input.

I.e., after commands

jq -f b2str.jq  -r authors-bytes.json > b2str.json
jq -f b2utf8.jq -r authors-bytes.json &gt; b2utf8.json
@tsvx
tsvx / branding.css.diff
Last active September 20, 2017 12:57
MSDN2012 EN-US patch to nifty display the code
diff --git a/branding.css b/branding.css
index 1e8c4c6..f3030bc 100644
--- a/branding.css
+++ b/branding.css
@@ -43,7 +43,7 @@ a img
}
pre
{
- font-family:Courier, "Courier New", Consolas, Monospace;
+ font-family:Consolas, "DejaVu Sans Mono", "Courier New", Courier, Monospace;
@tsvx
tsvx / TestEof.g4
Created June 12, 2017 12:07
Prove that ANTLR4's EOF can be matched any number of times
grammar TestEof;
ra: 'a' rb EOF;
rb: 'b' rc EOF;
rc: 'c' EOF;
WS: [ \r\n\t] -> skip;
@tsvx
tsvx / MeasureAccumulators.cs
Last active January 24, 2017 12:32
Measure accumulator implementations on .NET 4
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Concurrent;
using System.Collections.Generic;
public interface IAccum
{
IEnumerable<int> Keys { get; }
void Inc(int key);
@tsvx
tsvx / story.md
Created August 9, 2016 19:52
Fedora 23 prevents link-local sourced packets to go out.

This is the first edition of my answer to the question below
http://superuser.com/questions/1069956/all-outgoing-tcp-packets-have-source-ip-address-0-0-0-0

It's all about Avahi daemon, Link-Local, scope link, etc. It's possible to solve this problem. You have to make scope global on the host's IP address and make right routing table.

Below is my story.

We have such a local subnet (169.254.0.0/16) too. Nobody had known that it's wrong when it was built. So it works, and Windows hosts go through a router (a Linux machine with Fedora 12 and IP 169.254.0.34)

@tsvx
tsvx / main.c
Last active October 16, 2015 16:02
C: Trying integers sizeof and implicit type conversion
#include <stdio.h>
typedef unsigned short ushort;
int main()
{
printf("sizeof(sizeof)=%ld\n", sizeof(sizeof(ushort))); // 8
printf("ushort=%ld\n", sizeof(ushort)); // 2
printf("int = %ld\n", sizeof(int)); // 4
ushort a=1, b=3;