Skip to content

Instantly share code, notes, and snippets.

View jpolvora's full-sized avatar

Jone jpolvora

View GitHub Profile
<!-- Custom caching policy for on HTTP POST for Azure API Management:
1. Policy looks in the Request body - 'cacheKey' property which then used as cache key.
Expected values are: <null>, ALL or NOEXPIRED
Defaults to ALL in case <null>
2. Cache expiration set to 60 seconds/1 minute
!-->
<policies>
<inbound>
<base />
#include <stdio.h>
#define MAX 20000
int main (){
int i;
int x[MAX];
for(i=0;i<MAX;i++){
x[i] = i+1;}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
namespace AsyncKonsole
{
class Program
{
@jpolvora
jpolvora / ActionResult.cs
Last active December 10, 2015 08:38
By using ActionResult, you can yield an inline IResult by constructing it with a delegate (Action) via Lambda Expression. You will receive an action as parameter, which you must invoke in order to do the completion of the IResult.
//Usage:
public IEnumerable<IResult> Logout()
{
yield return new ActionResult(completed =>
{
var operation = WebContext.Current.Authentication.Logout(false);
operation.Completed += (sender, args) => completed();
});
}
@jpolvora
jpolvora / BusyResultWrapper.cs
Created November 16, 2012 18:29
BusyResultWrapper
//Original Idea: http://blog.smoothfriction.nl/archive/2012/05/07/silverlight-busyindicator-in-caliburn-micro-pt-2-again.aspx
//A simpler solution:
public interface IBusy
{
bool IsBusy { get; set; }
}
public static class CaliburnExtensions
{
public static IEnumerable<IResult> BeginExecute(this IEnumerable<Func<IResult>> routines)
{
return routines.Select(routine => routine());
}
public static void AsCoroutine(this IEnumerable<IResult> routine,
EventHandler<ResultCompletionEventArgs> callBack = null,
ActionExecutionContext ctx = null)
@jpolvora
jpolvora / DynamicDecorator.cs
Created May 17, 2012 03:28
My custom implementation of DynamicDecorator from Gary H Guo
// Created by por Jone Polvora
// Twitter: @jpolvora
// WebSite: http://silverlightrush.blogspot.com
// Based on Dynamic Decorator / CBO Extender Project (http://www.codeproject.com/Articles/275292/Component-Based-Object-Extender)
// Depends on Impromptu-Interface (https://code.google.com/p/impromptu-interface/_
// Last Update: 21/05/2012 10:40AM GMT -04:00
// Brazil
/* USAGE EXAMPLE