Skip to content

Instantly share code, notes, and snippets.

Avatar

Matias Woloski woloski

View GitHub Profile
@woloski
woloski / CloudQueueCacheDependency.cs
Created Jun 27, 2010
Invalidate ASP.NET Cache using a Windows Azure queue
View CloudQueueCacheDependency.cs
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 Nov 1, 2010
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
View gmail-backup.ps1
## 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
View AccountController.cs
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 Jan 27, 2012
WCF Web API dynamic JsonNet
View WCfWebApiDynamicProgran.cs
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 Apr 12, 2012
ADFS Audit Event Collector
View Console Output
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 Apr 25, 2012
Fire and forget with TPL and retry on ASP.NET
View BasicIdea.cs
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 Jun 21, 2012
WIF disabling encryption and signature on cookies
View Global.asax.cs
protected void Application_Start()
{
FederatedAuthentication.ServiceConfigurationCreated += OnServiceConfigurationCreated;
}
void OnServiceConfigurationCreated(object sender,
ServiceConfigurationCreatedEventArgs e)
{
List<CookieTransform> sessionTransforms =
@woloski
woloski / Usage.md
Created Jul 7, 2012
Create a self signed certificate on Windows
View Usage.md
View gist:3068606
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
View 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)