Skip to content

Instantly share code, notes, and snippets.

View lucamilan's full-sized avatar
🏠
Working from home

Luca Milan lucamilan

🏠
Working from home
View GitHub Profile
using System;
namespace StronglyTypedPipelines
{
public abstract class BasePipelineStep<INPUT, OUTPUT> : IPipelineStep<INPUT, OUTPUT>
{
public event Action<INPUT> OnInput;
public event Action<OUTPUT> OnOutput;
// note need for descendant types to implement this, not Process()
@lucamilan
lucamilan / BasePipelineTypes.cs
Created April 18, 2021 08:03 — forked from jermdavis/BasePipelineTypes.cs
An example of strongly typed data pipelines, with some trivial examples
using System;
namespace StronglyTypedPipelines
{
/// <summary>
/// Base type for individual pipeline steps.
/// Descendants of this type map an input value to an output value.
/// The input and output types can differ.
/// </summary>
@lucamilan
lucamilan / TSQL-to-POCO
Created March 15, 2020 09:41 — forked from joey-qc/TSQL-to-POCO
A simple TSQL script to quickly generate c# POCO classes from SQL Server tables and views. You may tweak the output as needed. Not all datatypes are represented but this should save a bunch of boilerplate coding. USAGE: Run this query against the database of your choice. The script will loop through tables, views and their respective columns. Re…
declare @tableName varchar(200)
declare @columnName varchar(200)
declare @nullable varchar(50)
declare @datatype varchar(50)
declare @maxlen int
declare @sType varchar(50)
declare @sProperty varchar(200)
DECLARE table_cursor CURSOR FOR
@lucamilan
lucamilan / index.html
Created December 11, 2017 19:55 — forked from bergonzzi/index.html
DataTables + yadcf + maplace.js - load the table and the map from the same data source and update the map automatically when filtering
<html>
<head>
<title>DataTables + yadcf + Google Maps</title>
<script type="text/javascript" charset="utf8" src="http://maps.google.com/maps/api/js?libraries=geometry&v=3.22&key={YOUR_API_KEY}"></script>
<script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script type="text/javascript" charset="utf8" src="http://cdn.datatables.net/1.10.11/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.11/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" charset="utf8" src="maplace.min.js"></script>
<script type="text/javascript" charset="utf8" src="jquery.dataTables.yadcf.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Export.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
GrdView.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(GrdView);
frm.RenderControl(hw);
@lucamilan
lucamilan / QueueService.cs
Created April 30, 2016 08:32 — forked from javicrespo/QueueService.cs
Producer/Consumer implementation with .NET 4 BlockingCollection
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
namespace ProducerConsumer
{
/// <summary>
/// Queue Service
/// </summary>
@lucamilan
lucamilan / sips_resample.sh
Last active February 18, 2016 19:42 — forked from NapoleonWils0n/sips_resample.sh
macosx: sips resample height width
#!/bin/sh
# sips resample images
sips --resampleHeightWidth 100 80 *.png
sips --resampleWidth 80 *.png
sips --resampleHeight 80 *.png
@lucamilan
lucamilan / IHttpActionResultExtensions.cs
Created January 19, 2016 15:12 — forked from sixeyed/IHttpActionResultExtensions.cs
Wrapping WebApi IHttpActionResult to expose the response message to controllers
using SampleApi.Results;
using System;
using System.Net.Http;
using System.Web.Http;
namespace SampleApi
{
public static class IHttpActionResultExtensions
{
public static IHttpActionResult With(this IHttpActionResult inner, string responsePhrase = null, Action<HttpResponseMessage> responseAction = null)
@lucamilan
lucamilan / MyController.cs
Created January 19, 2016 15:02 — forked from Boggin/MyController.cs
A WebAPI Controller for an Azure WebRole that can manage a request that will take a long time to fulfill.
namespace WebRole.Controllers
{
public class MyController : ApiController
{
private readonly ICache cache;
private readonly IMyRequestQueue myRequestQueue;
public MyController(
ICache cache,
@lucamilan
lucamilan / ExecuteWithRetryExample.cs
Created January 18, 2016 10:18 — forked from AzimUddin/ExecuteWithRetryExample.cs
Azure DocumentDB .Net SDK example of executing an Async method with retry to handle RequestRateTooLargeException or HTTP 429 errors
/// <summary>
/// Execute the function with retries on throttle
/// </summary>
/// <typeparam name="V"></typeparam>
/// <param name="client"></param>
/// <param name="function"></param>
/// <returns></returns>
private static async Task<V> ExecuteWithRetries<V>(DocumentClient client, Func<Task<V>> function)
{
TimeSpan sleepTime = TimeSpan.Zero;