Skip to content

Instantly share code, notes, and snippets.

View takeshik's full-sized avatar

Takeshi KIRIYA takeshik

View GitHub Profile
public static class DispatchHelper
{
public static Tuple<MethodInfo, Expression[]> DispatchMethod(IEnumerable<MethodInfo> methods, IList<Type> typeArguments, IList<Expression> arguments)
{
return methods
.Select(m => Tuple.Create(m, new Dictionary<Type, Type>(), arguments))
.If(_ => typeArguments != null && typeArguments.Any(), s => s
.Where(_ => _.Item1.IsGenericMethodDefinition && _.Item1.GetGenericArguments().Length == typeArguments.Count)
.Select(_ => _.Item1.MakeGenericMethod(typeArguments.ToArray())
.Let(m => Tuple.Create(m, m.GetGenericParameterMap(), arguments))
Traceback (most recent call last):
File "/usr/local/bin/gentwoo.py", line 96, in <module>
with open(logfile) as plf:
IOError: [Errno 2] No such file or directory: '/var/log/portage/elog/app-emulation:virt-manager-0.8.7-r2:20110608-164506.log'
Traceback (most recent call last): (r:0 s:5 j:0)
File "/usr/local/bin/gentwoo.py", line 110, in <module>
sendQuery(package, end, end-beg, logfile)
File "/usr/local/bin/gentwoo.py", line 45, in sendQuery
"Accept": "application/json"}))
File "/usr/lib64/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib64/python2.7/urllib2.py", line 392, in open
response = self._open(req, data)
File "/usr/lib64/python2.7/urllib2.py", line 410, in _open
EnumerableEx.Generate(
EnumerableEx.Return((Expression) expr),
_ => _.Any(),
_ => _.SelectMany(e =>
EnumerableEx.Generate(e.GetType(), t => t.BaseType != null, t => t.BaseType, t => t)
.SelectMany(t => t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
.Where(t => t.FieldType.IsAssignableFrom(typeof(Expression)))
.Select(f => (Expression) f.GetValue(e))
),
_ => _
Operating System : Microsoft Windows NT 6.1.7601 Service Pack 1
Common Language RunTime Version : 4.0.30319.431
My version : 0.0.7.220
Application Key : 61307-231-0-0
System.ArgumentOutOfRangeException: Index and count must refer to a location within the string.
Parameter name: count
@takeshik
takeshik / Solar.patch
Created May 23, 2011 17:01
Patch for Solar code
Lunar/Status.cs | 20 +
Lunar/StatusID.cs | 10 +-
Lunar/TwitterClient.cs | 66 +-
Lunar/TwitterUriBuilder.cs | 1 +
Lunar/UserID.cs | 10 +-
Solar/Filtering/EnumerableFilterSource.cs | 44 +
Solar/Filtering/QueryCacheFilterSource.cs | 30 +-
Solar/Library/DynamicLibrary.cs | 6020 +++++++++++++++++-----------
Solar/Library/UriBitmapConverter.cs | 39 +-
Solar/Models/Client.cs | 9 +-
@takeshik
takeshik / solar-icon-file-cache.patch
Created May 19, 2011 14:46
[PATCH] Solar: Icon File Cache Mechanism
--- S:/solar/Solar/Library/UriBitmapConverter.cs Thu May 19 23:44:03 2011
+++ S:/solar/Solar/Library/UriBitmapConverter.cs Thu May 19 23:45:04 2011
@@ -1,5 +1,6 @@
using System;
using System.Collections.Concurrent;
+using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Media;
@@ -24,6 +25,11 @@
@takeshik
takeshik / mtw-new-requests.cs
Created May 2, 2011 01:47
MetaTweet (new) Requests code
private static void Main()
{
var fragments = CreateFragments(Regex.Matches(
@"/$a=1$b==44OG44K544OILyEv44OG44K544OI(/!/obj/activities?query=name:ScreenName value:bob/@Single().Account/-or/$c=3$d=4!twitter/users/show?screen_name=bob/)/!/.xml?encoding=utf-8&format=oneline&b64==44OG44K544OILyEv44OG44K544OI",
@"(/(?:\$[^!@\(\)\-]+)?[!@\(\)\-])(.*?(?=/[\$!@\(\)\-]|$))"
).Cast<Match>().Select(m => new [] { m.Groups[1].Value, m.Groups[2].Value, })).Dump();
}
private static IDictionary<String, String> GetVariableTable(String str)
{
@takeshik
takeshik / metatweet-requests-spec.txt
Created May 1, 2011 18:48
MetaTweet (new) Requests Specification
MetaTweet Requests (リクエスト)
目的
MetaTweet サーバに対し要求を与え、結果を得る定型化された唯一の手段として定義される。
サーバに対し要求を与えるとは、例えばローカルストレージからデータを受取り、または Twitter 等の
外部サービスに対し問い合わせを行いその結果を格納しつつ返す、などに繋がる行為となる。
入力および出力の型は自由である。本来 IEnumerable<StorageObject>、即ち MetaTweet のデータ
オブジェクトのシーケンスが長らく前提とされてきたが、もはや全く限定されない。
定義
return input.Do(a => a.Act("Body", ((HttpWebResponse) WebRequest.Create(a.GetValue<String>()).GetResponse())
.If(
r => (Int32) r.StatusCode < 300,
r => new Byte[r.ContentLength].Apply(b => r.GetResponseStream().Dispose(s => s.Read(b, 0, b.Length))),
r => new Byte[0]
))
);