This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is Form | |
var textBoxes = this.Controls | |
.OfType<TextBox>() | |
.Where(t => t.Name.StartsWith("textBox")) | |
.OrderBy(t => Int32.Parse(t.Name.Substring("textBox".Length))) | |
.ToList(); | |
foreach (var _ in textBoxes.Select((t, i) => new { t, i, })) | |
{ | |
_.t.Text = "This is TextBox #" + _.i + "!"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From Achiral.Make.Dictionary (modified) | |
/// <see>http://blogs.wankuma.com/mayuki/archive/2007/12/06/111901.aspx</see> | |
public static Dictionary<String, Object> Dictionary(params Expression<Func<Object, Object>>[] exprs) | |
{ | |
return exprs.ToDictionary(expr => expr.Parameters[0].Name, expr => expr.Compile().Invoke(null)); | |
} | |
var o = (IDictionary<String,Object>) new ExpandoObject(); | |
Dictionary(a => 123, b => "foo").ForEach(_ => o.Add(_.Key, _.Value)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
Account acc = Account.Create("test", "foo"); | |
CreateCreationData(acc.Id, "Foo", 123, | |
a => a.Advertise(DateTime.Now, AdvertisementFlags.Created), | |
a => a.Act("Child1", "abc", | |
a2 => a2.Act("Grandchild1", "hoge", DateTime.UtcNow), | |
a2 => a2.Act("Grandchild2", "fugo", DateTime.UtcNow.AddHours(123), | |
a3 => a3.Act("Grand2child", "zzz") | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<TResult> Pairwise<T, TResult>(this IEnumerable<T> source, Func<T, T, TResult> selector) | |
{ | |
using (var enumerator = source.GetEnumerator()) | |
{ | |
if (!enumerator.MoveNext()) | |
{ | |
yield break; | |
} | |
var prev = enumerator.Current; | |
while (enumerator.MoveNext()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected virtual Tuple<Activity, Boolean> CreateObject(Account account, IEnumerable<ActivityId> ancestorIds, String name, Object value) | |
{ | |
ActivityId id = ActivityId.Create(account.Id, ancestorIds, name, value); | |
StorageObject obj; | |
Boolean created = false; | |
if ((obj = this.Load(id)) == null && !this.AddingObjects.TryGetValue(id, out obj)) | |
{ | |
obj = Activity.Create(account.Id, ancestorIds, name, value); | |
this.AddingObjects.Add(obj.ObjectId, obj); | |
obj.Context = this; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main() | |
{ | |
Object obj = Observable.Range(0, 100); | |
IObservable<Object> source = obj.GetType().GetInterface("System.IObservable`1") != null | |
? (IObservable<Object>) typeof(UserQuery) | |
.GetMethod("AsObject", BindingFlags.NonPublic | BindingFlags.Static) | |
.MakeGenericMethod(obj.GetType().GetInterface("System.IObservable`1").GetGenericArguments()) | |
.Invoke(null, new Object[] { obj, }) | |
: Observable.Return(obj); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ProcessingResult Process(RequestContext context) | |
{ | |
Console.WriteLine(context.Request.Uri.PathAndQuery); | |
if (context.Request.Uri.PathAndQuery != "/") | |
{ | |
return ProcessingResult.Continue; | |
} | |
ResponseWriter generator = new ResponseWriter(); | |
context.Response.ContentType.Value = "application/json"; | |
context.Response.Status = HttpStatusCode.OK; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
length q eq ge and print chr ord uc q eval le and print chr ord uc q sin s and print chr oct ord q qx eq and print chr oct hex length q q redo index seekdir next chop ne getnetbyaddr abs setpwent getprotobyname continue getpwuid pack join or shmctl m syswrite seekdir do study while getsockopt q and print chr hex ord uc q eq le and print chr oct hex ord q tie lt and print chr oct hex length q q reset msgget splice socket dbmopen rmdir endhostent send syscall wantarray index getpwuid splice exists waitpid getpgrp shmwrite each localtime join caller q and print chr hex ord uc q eq le and print chr length q q gethostbyname setgrent split setnetent utime getc sethostent endnetent reset telldir getprotobyname msgctl shmctl flock foreach chmod wait undef vec local open sort exec s q and print chr oct hex length q q reset msgget splice socket dbmopen rmdir endhostent send syscall wantarray index getpwuid splice exists waitpid getpgrp shmwrite each localtime join caller q and print chr hex ord uc q |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim inReplyToPosts = From tab In _statuses.Tabs.Values | |
Order By tab IsNot curTabClass | |
From post In DirectCast(IIf(tab.IsInnerStorageTabType, tab.Posts, _statuses.Posts), Dictionary(Of Long, PostClass)).Values | |
Where post.StatusId = inReplyToId | |
Let index = tab.IndexOf(post.StatusId) | |
Where index <> -1 | |
Select New With {.Tab = tab, .Index = index} |