Skip to content

Instantly share code, notes, and snippets.

@benerdin
benerdin / CollateEnumerator.cs
Last active August 29, 2015 13:56
An enumerator that collates an IGrouping data structure.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Brian.Federici
{
/// <summary>
/// An object that can iterate over an IGrouping collection.
/// </summary>
/// <typeparam name="T">Value type.</typeparam>
@benerdin
benerdin / delete-win32-service.bat
Last active August 29, 2015 13:56
Delete Windows Service from command-line
sc delete <name-of-service>
@benerdin
benerdin / manually-kill-a-service.bat
Created February 27, 2014 16:25
Manually kill a process for a Windows Service that won't stop.
sc queryex wuauserv
SERVICE_NAME: wuauserv
DISPLAY_NAME: Windows Update
TYPE : 20 WIN32_SHARE_PROCESS
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_PRESHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
@benerdin
benerdin / RestSharp.cs
Created June 10, 2014 18:14
RestSharp and ServiceStack nUnit tests for POSTing form data
[TestFixture]
class RestSharpIntegration
{
[Test]
public void EnsureFormIsPosted()
{
// Arrange
var request = CreateRequest();
// Act
@benerdin
benerdin / prevent-pasting-into-text-input.js
Created July 17, 2014 14:06
How to prevent pasting into a text field using jQuery.
$(document).ready(function() {
$('#elementId')
.keypress(function(e) {
// Prevent users from being able to type into the field.
e.preventDefault();
})
.keydown(function (e) {
// Prevent users from being able to type into the field.
e.preventDefault();
})
@benerdin
benerdin / TimeZoneConverter.cs
Last active August 29, 2015 14:04
TimeZoneConverter
using System;
using System.Linq;
namespace TimeZones
{
/// <summary>
/// Responsible for converting between different time zones.
/// </summary>
public class TimeZoneConverter
{
@benerdin
benerdin / SomeController.cs
Last active August 29, 2015 14:18
ASP.NET Web API - Download File
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;