Skip to content

Instantly share code, notes, and snippets.

View woloski's full-sized avatar

Matias Woloski woloski

View GitHub Profile
@woloski
woloski / CloudQueueCacheDependency.cs
Created June 27, 2010 00:16
Invalidate ASP.NET Cache using a Windows Azure queue
namespace Southworks.WindowsAzure
{
using System;
using System.Web.Caching;
/// <summary>
/// Represents a cache dependency that uses Windows Azure queues to detect if an item in cache has changed
/// </summary>
/// <remarks>Sending a message a certain queue (specified using the <see cref="CloudQueueCacheDependencyMonitor" />) will invalidate the cache item </remarks>
/// <example>
@woloski
woloski / gmail-backup.ps1
Created November 1, 2010 03:03
Powershell script that uses the gmail-backup.com cmd line tool to download emails from gmail in chunks of X days and store them in separate folders
## usage
## Download gmail-backup from www.gmail-backup.com and put it under "tools" folder relative to the script
## The idea is to download emails in small batches to avoid network issues and make a re-start easier. It also helps to avoid huge folders
## INPUT: the storage folder, amount of days to make the cut, start date, end date, credentials
## EXAMPLE:
## new-backup "d:\mail" 30 (get-date -year 2004 -month 01 -day 01) (get-date -y 2006 -month 01 -day 01) "youremail" "yourpwd"
function log($msg) {
$msg = (get-date).ToString("yyyyMMdd hh:mm:ss") + " $msg"
add-content log.txt $msg
namespace YourWebApp.Controllers
{
using System;
using System.Text;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using Microsoft.IdentityModel.Protocols.WSFederation;
using Microsoft.IdentityModel.Web;
using System.Net;
@woloski
woloski / WCfWebApiDynamicProgran.cs
Created January 27, 2012 18:01
WCF Web API dynamic JsonNet
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ApplicationServer.Http;
using System.ServiceModel;
using System.Net.Http;
using System.ServiceModel.Web;
using System.Net.Http.Headers;
using WebApiContrib.Formatters.JsonNet;
@woloski
woloski / Console Output
Created April 12, 2012 20:57
ADFS Audit Event Collector
This would be the console output
Claims for: https://myadfs/ (Correlation: 84b46102-3ed2-4ff2-88ac-eace0709667c)
http://schemas.microsoft.com/ws/2008/06/identity/claims/organization : myadfs
http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationinstant : 2012-04-12T21:15:32.410Z
http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod : http://schemas.microsoft.com/ws/20
enticationmethod/windows
http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid : S-1-5-21-1409732942-2814574796-20323036
http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid : S-1-5-21-1409732942-2814574796-203230364-513
http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid : S-1-1-0
@woloski
woloski / BasicIdea.cs
Created April 25, 2012 15:51
Fire and forget with TPL and retry on ASP.NET
Task.Factory.StartNew((state) =>
{
try
{
// use http://nuget.org/packages/TransientFaultHandling.Core
// the defaultfixed strategy retries 10 times every 1 second
RetryPolicy.DefaultFixed.ExecuteAction(() =>
{
// do something that might throw an exception like calling an http endpoint
});
@woloski
woloski / Global.asax.cs
Created June 21, 2012 19:28
WIF disabling encryption and signature on cookies
protected void Application_Start()
{
FederatedAuthentication.ServiceConfigurationCreated += OnServiceConfigurationCreated;
}
void OnServiceConfigurationCreated(object sender,
ServiceConfigurationCreatedEventArgs e)
{
List<CookieTransform> sessionTransforms =
@woloski
woloski / Usage.md
Created July 7, 2012 15:18
Create a self signed certificate on Windows
@woloski
woloski / gist:3068606
Created July 7, 2012 23:46
error resgen
remote: D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1
835,9): error MSB3091: Task failed because "resgen.exe" was not found, or the co
rrect Microsoft Windows SDK is not installed. The task is looking for "resgen.ex
e" in the "bin" subdirectory beneath the location specified in the InstallationF
older value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft
SDKs\Windows\v7.0A. You may be able to solve the problem by doing one of the fol
lowing: 1) Install the Microsoft Windows SDK. 2) Install Visual Studio 2010.
3) Manually set the above registry key to the correct location. 4) Pass the cor
rect location into the "ToolPath" parameter of the task. [C:\DWASFiles\Sites\aut
hbridge\VirtualDirectory0\site\repository\src\ClaimsPolicyEngine\ClaimsPolicyEng
@woloski
woloski / ws-fed
Created July 11, 2012 03:20
ws-fed
https://{identityprovider-url}?
wa=wsignin1.0 -- signin verb. This is fixed.
wtrealm={your-application-identifier} -- logical identifier of your application.
wctx={context-information} -- [optional] contextual information that you want to keep around (e.g.: wctx=ru=/home/some-deep-link this would the original url the user was navigating to)
whr={identity-provider-identifier} -- [optional] hint the idp to use a specific identity provider (e.g.: whr=urn:Google)