Skip to content

Instantly share code, notes, and snippets.

View jfoshee's full-sized avatar
🗺️
Exploring

Jacob Foshee jfoshee

🗺️
Exploring
View GitHub Profile
@SLaks
SLaks / RoutingExtensions.cs
Created September 18, 2011 22:48
Default Controllers in ASP.Net MVC
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace SLaks.Web.Mvc {
//http://blog.slaks.net/2011/09/using-default-controller-in-aspnet-mvc.html
@mythz
mythz / HelloImage.cs
Created April 6, 2012 18:04
Different ways of returning an ImageStream
// 3 different ways to return an image.
// More info about other responses http://stackoverflow.com/questions/6245616/does-servicestack-support-binary-responses
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using ServiceStack.Common.Web;
using ServiceStack.Service;
@ChuckSavage
ChuckSavage / ViewExtensions.cs
Created June 6, 2012 19:58
MonoTouch Swipe Event
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
using MonoTouch.UIKit;
namespace iOSLib
{
public static class ViewExtensions
{
static Dictionary<UIView, Dictionary<UISwipeGestureRecognizerDirection, SwipeClass>>
@mynameismiek
mynameismiek / ViewExtensions.cs
Last active December 14, 2015 00:08 — forked from ChuckSavage/ViewExtensions.cs
Added tap gestures and a way to remove the views from this class when they are disposed. This class registers itself with the default notification center. Simply add NSNotificationCenter.DefaultCenter.PostNotificationName(ViewExtensions.ViewDisposed, View) to your disposal method.
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
using MonoTouch.UIKit;
namespace iOSLib
{
public static class ViewExtensions
{
public static String ViewDisposed = "ViewExtension_ViewDisposed";
@jfoshee
jfoshee / UIViewAnimations.cs
Last active December 14, 2015 01:39
An RAII style class for setting UIView.AnimationsEnabled MonoTouch / Xamarin.iOS
using System;
using MonoTouch.UIKit;
public sealed class UIViewAnimations : IDisposable
{
public UIViewAnimations(bool enabled)
{
_wasEnabled = UIView.AnimationsEnabled;
UIView.AnimationsEnabled = enabled;
}
@martinjw
martinjw / SqlExceptionMocker.cs
Last active October 16, 2022 21:02 — forked from timabell/SqlExceptionMocker.cs
Create a SqlException for testing
using System.Data.SqlClient;
using System.Reflection;
namespace HorribleThingsInHere
{
/// <summary>
/// Workaround completely test-unfriendly sql error classes.
/// Copy-paste from http://stackoverflow.com/a/1387030/10245
/// Adjusted with updates in comments
/// Adjusted to not use ctor indexes
@bjcull
bjcull / CustomRequireHttpsFilter.cs
Created May 15, 2015 06:50
An improved HTTPS redirection filter for ASP.NET MVC.
public class CustomRequireHttpsFilter : RequireHttpsAttribute
{
protected override void HandleNonHttpsRequest(AuthorizationContext filterContext)
{
// The base only redirects GET, but we added HEAD as well. This avoids exceptions for bots crawling using HEAD.
// The other requests will throw an exception to ensure the correct verbs are used.
// We fall back to the base method as the mvc exceptions are marked as internal.
if (!String.Equals(filterContext.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase)
&& !String.Equals(filterContext.HttpContext.Request.HttpMethod, "HEAD", StringComparison.OrdinalIgnoreCase))
@ramonsmits
ramonsmits / RateGate.cs
Last active December 8, 2021 06:55
RateGate originally from Jack Leitch, now async and using Stopwatch.GetTimestamp() instead of Environment.TickCount
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// Used to control the rate of some occurrence per unit of time.
/// </summary>
/// <remarks>
@davidfowl
davidfowl / Global.asax.cs
Last active May 11, 2024 02:04
ASP.NET MVC and ServiceCollection sample
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Microsoft.Extensions.DependencyInjection;
using WebApplication16;
using WebApplication16.Controllers;
@bpesquet
bpesquet / .gitattributes-lfs-unity
Last active December 7, 2022 22:37
.gitattributes file for LFS with Unity
* text=auto
# Unity files
*.meta -text -merge=unityamlmerge
*.unity -text -merge=unityamlmerge
*.asset -text -merge=unityamlmerge
*.prefab -text -merge=unityamlmerge
# Image formats
*.psd filter=lfs diff=lfs merge=lfs -text