Skip to content

Instantly share code, notes, and snippets.

@JeanCollas
JeanCollas / JavscriptHTMLTemplating.html
Last active November 5, 2018 13:28
HTML javascript templating
<!-- To combine with https://gist.github.com/DanDiplo/30528387da41332ff22b -->
<script>
const renderULLI = (data) => `<ul>${data.map(li => `<li>${li}</li>`).join('')}</ul>`;
document.body.innerHTML=renderULLI(['Hi!','line2','line 3'])
</script>
<!-- might be improved for template updates with https://github.com/Polymer/lit-html -->
@JeanCollas
JeanCollas / QueryStringHelper.cs
Created November 5, 2018 00:59 — forked from DanDiplo/QueryStringHelper.cs
QueryString Helper
// Code examples of using my QueryStringHelper c# class for parsing query string values
// See https://github.com/DanDiplo/QueryString-Helper
QueryStringHelper qs1 = new QueryStringHelper(Request.QueryString); // initialise from Request.QueryString
string query = "?page=5&username=dan&year=2010&enabled=true&email=dan@example.com&option=apple&option=banana&option=melon&date=2015/07/06";
QueryStringHelper qs = new QueryStringHelper(query); // intialise from string
@JeanCollas
JeanCollas / JS-LINQ.js
Created November 5, 2018 00:56 — forked from DanDiplo/JS-LINQ.js
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
{ name: "Judy", age: 42 },
{ name: "Tim", age: 8 }
@JeanCollas
JeanCollas / ViewToStringRendererService.cs
Last active May 25, 2018 19:34
Service to render views as HTML string in ASP.NET Core
// Inspired by several web solutions and https://raw.githubusercontent.com/aspnet/Mvc/133dd964abb1c2a4167cf38faa38fe0319b7b931/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs
public class ViewToStringRendererService: ViewExecutor
{
private ITempDataProvider _tempDataProvider;
private IServiceProvider _serviceProvider;
public ViewToStringRendererService(
IOptions<MvcViewOptions> viewOptions,
IHttpResponseStreamWriterFactory writerFactory,
ICompositeViewEngine viewEngine,