Skip to content

Instantly share code, notes, and snippets.

@prabirshrestha
prabirshrestha / web.config
Created May 19, 2011 20:31
nuget server web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
@prabirshrestha
prabirshrestha / gist:1010812
Created June 6, 2011 18:46
batch request multiple file upload
dynamic result = fb.Batch(
new FacebookBatchParameter(HttpMethod.Post, "/me/photos", new Dictionary<string, object> { { "message", "picture 1 msg" }, { "pic1", new FacebookMediaObject { ContentType = "image/jpeg", FileName = "Tulips.jpg" }.SetValue(File.ReadAllBytes(@"C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg")) } }),
new FacebookBatchParameter(HttpMethod.Post, "/me/photos", new Dictionary<string, object> { { "message", "picture 2 msg" }, { "pic2", new FacebookMediaObject { ContentType = "image/jpeg", FileName = "Penguins.jpg" }.SetValue(File.ReadAllBytes(@"C:\Users\Public\Pictures\Sample Pictures\Penguins.jpg")) } }));
@prabirshrestha
prabirshrestha / start_website.bat
Created June 8, 2011 08:33
run website using iis express
@ECHO off
PUSHD "%~dp0"
SET WebsitePath="%~dp0src\WebApplication"
SET WebsitePort=5000
SET ProgRoot=%ProgramFiles%
IF NOT "%ProgramFiles(x86)%" == "" SET ProgRoot=%ProgramFiles(x86)%
SET IISExpress=%ProgRoot%\IIS Express\iisexpress.exe
using System;
using System.Diagnostics;
public class StopWatchHelper : IDisposable
{
private readonly bool _displayTime;
private readonly Stopwatch _stopwatch;
public StopWatchHelper()
: this(true)
@prabirshrestha
prabirshrestha / AppStart_Unity.cs
Created June 16, 2011 12:05
Unity MVC 3 Dependency Resolver
using System.Configuration;
using System.Web.Mvc;
using Microsoft.Practices.Unity;
[assembly: WebActivator.PreApplicationStartMethod(typeof(WebApplication.App_Start.AppStart_Unity), "Start")]
namespace WebApplication.App_Start
{
public class AppStart_Unity
{
using System.Web;
namespace NetflixDemo
{
public class AppHarborHttpContextWrapper : HttpContextWrapper
{
private readonly HttpContext httpContext;
public AppHarborHttpContextWrapper(HttpContext httpContext) : base(httpContext)
{
// Fluent HTTP CORE
//#define FLUENTHTTP_CORE_TPL
//#define FLUENTHTTP_CORE_STREAM
//#define FLUENTHTTP_URLENCODING
//#define FLUENTHTTP_HTMLENCODING
using System;
using System.Collections;
using System.Collections.Generic;
@prabirshrestha
prabirshrestha / AccountController.cs
Created July 5, 2011 18:11
Facebook Connect with ASP.NET MVC
public class AccountController : Controller
{
public ActionResult Login(string returnUrl, string scope)
{
if (!Url.IsLocalUrl(returnUrl))
{
returnUrl = "/";
}
ViewData["returnUrl"] = returnUrl;
@prabirshrestha
prabirshrestha / AccountController.cs
Created July 5, 2011 18:12 — forked from prabirshrestha/AccountController.cs
Facebook Connect with ASP.NET MVC
public class AccountController : Controller
{
public ActionResult Login(string returnUrl, string scope)
{
if (!Url.IsLocalUrl(returnUrl))
{
returnUrl = "/";
}
ViewData["returnUrl"] = returnUrl;
@prabirshrestha
prabirshrestha / HttpBasicAuthorizeAttribute.cs
Created July 17, 2011 11:17
HttpBasic Auth for GitDotAspx
// License: Apache License Version 2.0
// Author: Prabir Shrestha (http://www.prabir.me) https://github.com/prabirshrestha
// Description: HttpBasic Authentication support for https://github.com/jeremyskinner/git-dot-aspx
// Usage:
// 1. Add this file in the git-dot-aspx project
// 2. Add the following line in Application_Start
// GlobalFilters.Filters.Add(new HttpBasicAuthorizeAttribute());
// 3. In web.config in <appSettings>
// add users and passwords (users seperated by semicolon, username and password sepearted by colon)