Skip to content

Instantly share code, notes, and snippets.

@prabirshrestha
prabirshrestha / DiffMatchPatchProgram.cs
Created November 5, 2010 05:45
DiffMatchPatch command line
/* to build:
* download DiffMatchPatch from http://code.google.com/p/google-diff-match-patch/
* then in command line run
* "%WINDIR%\Microsoft.NET\Framework\v3.5\csc.exe" /out:DiffMatchPatch.exe DiffMatchPatch.cs DiffMatchPatchProgram.cs
*
* to create patch:
* DiffMatchPatch.exe file1 file2 destination
* to apply patch
* DiffMatchPatch.exe patch file_to_patch
*/
@prabirshrestha
prabirshrestha / SubSpec.resharper.livetemplates.xml
Created November 6, 2010 06:29
SubSpec Resharper LiveTemplates
<TemplatesExport family="Live Templates">
<Template uid="b01f5164-ebc7-4796-92a7-dfebea08afb3" shortcut="sa" description="SubSpec Assert" text="&quot;$Assert$&quot;&#xD;&#xA; .Assert(&#xD;&#xA; () =&gt; { $END$ });" reformat="True" shortenQualifiedReferences="True">
<Context>
<CSharpContext context="Statement" minimumLanguageVersion="2.0" />
</Context>
<Categories>
<Category name="SubSpec" />
</Categories>
<Variables>
<Variable name="Assert" expression="" initialRange="0" />
@prabirshrestha
prabirshrestha / GetPathRelativeToExecutable
Created November 9, 2010 07:20
GetPathRelativeToExecutable
public static string GetPathRelativeToExecutable(string fileName)
{
string executable = new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath;
return System.IO.Path.GetFullPath(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(executable), fileName));
}
@prabirshrestha
prabirshrestha / LogoutFacebook.aspx
Created November 23, 2010 06:12
Logout of Facebook website using FacebookJsSdk
<%@ Page Language="C#" %>
<%@ Import Namespace="FacebookSharp.Web.JavascriptSdk" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Logging you out of facebook...</title>
</head>
<body>
<form id="form1" runat="server">
@prabirshrestha
prabirshrestha / FacebookSignedRequest.cs
Created February 7, 2011 19:12
FacebookSignedRequest
namespace Facebook.Web
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
@prabirshrestha
prabirshrestha / CombinationStream.cs
Created February 21, 2011 21:21
EeekSoft.Asynchronous
namespace HttpWebHelperSample
{
// http://stackoverflow.com/questions/3963483/stitching-together-multiple-streams-in-one-stream-class
// todo: implement BeginRead and EndRead.
internal class CombinationStream : System.IO.Stream
{
private readonly System.Collections.Generic.IList<System.IO.Stream> streams;
private int currentStreamIndex;
private System.IO.Stream currentStream;
private long length = -1;
var result = fb.Batch(
new FacebookBatchParameter { HttpMethod = HttpMethod.Get, Path = "/4" },
new FacebookBatchParameter(HttpMethod.Get, "/me/friends", new Dictionary<string, object> { { "limit", 10 } }) { Data = new { name = "friends", omit_response_on_success = false } },
new FacebookBatchParameter("/me", new { fields = new[] { "id", "name" } }),
new FacebookBatchParameter("/me/feed", new { limit = 10 }),
new FacebookBatchParameter(HttpMethod.Post, "/me/feed", new { message = "test status update" }));
private static void Get()
{
var ms = new MemoryStream();
var request = new FluentHttpRequest()
.BaseUrl("https://graph.facebook.com")
.ResourcePath("/prabirshrestha")
.Method("GET")
.QueryStrings(qs =>
qs
// original code from http://tomasp.net/blog/csharp-async.aspx
// converted to C# 2.0 compatible code and modified to support exceptions.
namespace AsyncEnumerator
{
using System;
using System.Collections.Generic;
#if ASYNC_ENUMERATOR_INTERNAL
internal
@prabirshrestha
prabirshrestha / iso8601Datetime.cs
Created April 5, 2011 16:43
ISO8601 Date Time helpers
public static class DateTimeHelpers
{
private static readonly string[] Iso8601Format = new[]
{
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'",
@"yyyy-MM-dd\THH:mm:ssK"
};
//SortableDateTimePattern (ISO 8601)
public static string ToIso8601(DateTime value)