Skip to content

Instantly share code, notes, and snippets.

View schotime's full-sized avatar

Adam Schroder schotime

  • Melbourne, Australia
View GitHub Profile
@benaadams
benaadams / Microservice.cs
Last active May 20, 2020 13:11
Microservice Lib + App
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System;
namespace MicroserviceLib
{
public class Microservice : Controller, IStartup
@GFoley83
GFoley83 / tw-bs.3.1.1.css
Last active September 13, 2017 15:55
Twitter Bootstrap 3.1.1 namespaced to "tw-bs" so as not to conflict with other libraries/pre-existing css rules.
/*
Bootstrap 3.1.1 namepaced to .tw-bs
E.g.
<table>
// my regular table
</table>
<div class="tw-bs">
<table>
@bleroy
bleroy / XmlHelper.cs
Last active September 18, 2022 03:11
A C# helper class to read and write XML from and to objects
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Xml.Linq;
namespace Nwazet.Commerce.Helpers {
public static class XmlHelper {
/// <summary>
/// Like Add, but chainable.
@Ummon
Ummon / NewtworkManagerConnection.cs
Created December 17, 2012 10:18
To control the Network Manager on Ubuntu with DBUS and C#/Mono. D-BUS documentation: * The D-BUS Network Manager: http://projects.gnome.org/NetworkManager/developers/api/09/spec.html#org.freedesktop.NetworkManager.Settings.Connection * The D-BUS C# free library: https://github.com/mono/dbus-sharp and http://www.ndesk.org/DBus_Documentation * D-B…
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using DBus;
namespace IPChangerPrototype
{
public enum Method
[TestFixture]
public class AntiForgeryTests
{
[Test]
[TestCaseSource(typeof(AllMvcActions), "GetActions")]
public void AllPostActionsShouldHaveAntiForgeryValidation(MethodInfo action)
{
if (!action.GetCustomAttributes(typeof (HttpPostAttribute), false).Any())
return;
@skoon
skoon / GenericTryParse.cs
Created May 10, 2011 06:16
First crack at trying a generic TryParse method.
public static T TryParse<T>(this string stringToParse) {
if (typeof(T).HasMethod("TryParse")) {
var m = typeof(T).GetMethod("TryParse", new Type[] { typeof(string), typeof(T).MakeByRefType() });
T outParam = Activator.CreateInstance<T>();
object[] ps = new object[] { stringToParse, outParam };
bool result = (bool)m.Invoke(null, ps);
if (result)
return (T)ps[1];
}
return default(T);
@gsherman
gsherman / IIS7: rewrite cookies to be httponly
Created January 20, 2011 22:40
a rewriting rule that adds "HttpOnly" to any out going "Set-Cookie" headers
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!--
Rewrite any outgoing "Set-Cookie" headers to be "HttpOnly"
Requires the IIS7 URL Rewrite Module, available from: http://www.iis.net/download/urlrewrite
-->
<rewrite>
<outboundRules>
<rule name="Add HttpOnly" preCondition="No HttpOnly">