Skip to content

Instantly share code, notes, and snippets.

View takeshik's full-sized avatar

Takeshi KIRIYA takeshik

View GitHub Profile
// License: MIT
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.Serialization.Formatters.Binary;
internal class Program
@takeshik
takeshik / decompiler-battle.cs
Created July 16, 2011 09:54
.NET Reflector vs. ILSpy vs. dotPeek
// Original
public static Expression DispatchMethod(
Expression instance,
IEnumerable<MethodBase> methods,
IList<Type> typeArguments,
IList<Expression> arguments
)
{
return methods
.Select(m => m is MethodInfo && ((MethodInfo) m).IsExtensionMethod()

openpgp4fpr:260032D45A1BB80D4662D16E7F0B72A0F5468326

@takeshik
takeshik / default-colors.gitconfig
Last active December 11, 2021 12:24
Default config values of color.* slots (on Git 2.24.1)
[color "branch"]
plain = normal
remote = red
local = normal
current = green
upstream = blue
worktree = cyan # not in doc
[color "diff"]
context = normal
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace ConsoleApplication1
{
public class TaskQueue : IDisposable
{
//仕事キュー
@takeshik
takeshik / parseq-new-msg.cs
Last active December 31, 2015 13:29
Parseq new message system
var reply = Chars.Digit()
.Or(Chars.Any().Message("not a digit"))
.Many()
.Select(cs => new string(cs.ToArray()))
("12a3b".AsStream());
reply.Status.Dump(); // Success
reply.Left.Value.Value.Dump(); // "12a3b"
reply.Messages.Dump();
// [ not a digit (1:5,1:5),
// not a digit (1:3,1:3),
// Yacq
private static readonly Grammar _standard = new Grammar();
public static Grammar Standard
{
get
{
return _standard;
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace TinyTweet
@takeshik
takeshik / get-attrs.cs
Created February 18, 2013 09:53
get Attribute[] from lambda
public static Attribute[] GetAttributes(Expression expr)
{
switch (expr.NodeType)
{
case ExpressionType.MemberAccess:
return Attribute.GetCustomAttributes(((MemberExpression) expr).Member);
case ExpressionType.Invoke:
return Attribute.GetCustomAttributes(((MethodCallExpression) expr).Method);
case ExpressionType.Index:
return Attribute.GetCustomAttributes(((IndexExpression) expr).Indexer);
public class TypeName
{
public String Namespace { get; set; }
public String[] HierarchicalNames { get; set; }
public override String ToString()
{
return String.Join("+", this.HierarchicalNames);
}
}