Skip to content

Instantly share code, notes, and snippets.

View svick's full-sized avatar

Petr Onderka svick

View GitHub Profile
void Main()
{
DumpAnonymousType(new { i = 42, j = 13 });
DumpAnonymousType((i: 42, j: 13));
}
void DumpAnonymousType(object o)
{
var properties = o.GetType().GetProperties();
@svick
svick / Program.cs
Created June 20, 2017 02:08
A simple implementtion of StringBuilder.EnumerateChunks
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
var sb = new StringBuilder
{
m_ChunkChars = "cd".ToCharArray(),
@svick
svick / project.json
Created June 17, 2017 12:54
Get corefx-standup reactions
{
"frameworks": {
"net46":{
"dependencies": {
"Octokit": "0.24.0"
}
}
}
}
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
class Program
{
static void Main()
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Text;
class Program
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
class Program
{
static unsafe void Main()
{
Console.WriteLine($"Sequential: {sizeof(SequentialS)}");
Console.WriteLine($"Auto: {sizeof(AutoS)}");
@svick
svick / commands.sh
Last active March 9, 2017 21:50
idumps commands
idumps c cswikibooks now cswikibooks-20170301-pages-meta-history.xml ph cswikibooks.id
idumps r cswikibooks.id cswikibooks.xml
ls -l
cmp cswikibooks.xml cswikibooks-20170301-pages-meta-history.xml
sed '1445380q;d' cswikibooks-20170301-pages-meta-history.xml
idumps u localwiki 1 php /var/www/html/mediawiki/maintenance/dumpBackup.php /var/www/html/mediawiki/maintenance/fetchText.php ph localwiki1.id
idumps r localwiki1.id localwiki1.xml
vi localwiki1.xml
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Attributes;
namespace Benchmark
{
public static class Program
{
public static void Main()
{
BenchmarkRunner.Run<RefProperty>();
@svick
svick / Program.cs
Created November 7, 2016 15:03
Counting underscores in lambdas on GitHub
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
string path = @"E:\Users\Svick\git\visualfsharpdocs\docs\conceptual";
var files = Directory.EnumerateFiles(path);
Regex regex = new Regex(@"\[([^]]*?)\]\(http.*?\)");
foreach (var file in files)
{
var lines = File.ReadAllLines(file);