Skip to content

Instantly share code, notes, and snippets.

@shanselman
shanselman / gist:5422230
Last active May 23, 2022
Evil Blog Comment Spammer just exposed his template through some error and the whole thing showed up in my comments.
View gist:5422230
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|
@simonech
simonech / CsvActionResult.cs
Created Nov 18, 2012
ActionResult for ASP.NET MVC that returns a CSV file from any list of objects
View CsvActionResult.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace webnetconf.website.Helpers
@ardalis
ardalis / Program.cs
Last active Sep 20, 2021
A StructureMap Example using a Console Application
View Program.cs
using System;
using System.Linq;
using StructureMap;
namespace ConsoleApplication1
{
/// <summary>
/// See http://stackoverflow.com/questions/6777671/setting-up-structure-map-in-a-c-sharp-console-application
/// Updated for SM 4: http://ardalis.com/using-structuremap-4-in-a-console-app
/// </summary>
@codahale
codahale / pom.xml
Last active May 15, 2022
Take this and save it as pom.xml in your project directory.
View pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- none yet -->
@rdingwall
rdingwall / DropAllRavenDatabases.bat
Created Feb 29, 2012
Fast Raven DB sandbox database helpers
View DropAllRavenDatabases.bat
@echo off
rem Warning: this batch file deletes ALL Raven DB data and databases, leaving you with a totally empty (but ready to use) Raven DB instance.
net stop RavenDB
rd /S /Q C:\RavenDB\Server\Data
rd /S /Q C:\RavenDB\Server\Tenants
net start RavenDB
@bgrins
bgrins / gist:1789787
Created Feb 10, 2012
C# Multipart File Upload
View gist:1789787
// Implements multipart/form-data POST in C# http://www.ietf.org/rfc/rfc2388.txt
// http://www.briangrinstead.com/blog/multipart-form-post-in-c
public static class FormUpload
{
private static readonly Encoding encoding = Encoding.UTF8;
public static HttpWebResponse MultipartFormDataPost(string postUrl, string userAgent, Dictionary<string, object> postParameters)
{
string formDataBoundary = String.Format("----------{0:N}", Guid.NewGuid());
string contentType = "multipart/form-data; boundary=" + formDataBoundary;
View FindConflictingReferences.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace MyProject
{
public class UtilityTest
{
@brianlow
brianlow / FindConflictingReferences.cs
Created Jan 3, 2012
Find conflicting assembly references
View FindConflictingReferences.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
namespace MyProject
{
[TestFixture]
@mattwarren
mattwarren / gist:990623
Created May 25, 2011
Array patching with RavenDB
View gist:990623
using (var store = NewDocumentStore())
{
using (var s = store.OpenSession())
{
s.Store(new Post
{
//Create an empty list that we can add items to later
Comments = new List<Comment>()
});
s.SaveChanges();
View AutoMapperExtensions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
namespace DovetailCRM.Core.Web.Mapping
{
public static class AutoMapperExtensions
{
public static void CreateMapsForSourceTypes(this IConfiguration configuration, Func<Type, bool> filter, Func<Type, Type> destinationType, Action<IMappingExpression, Type, Type> mappingConfiguration)