Skip to content

Instantly share code, notes, and snippets.

View yetanotherchris's full-sized avatar
🔏
;ÿÿÿÿrules

Chris S. yetanotherchris

🔏
;ÿÿÿÿrules
View GitHub Profile
@yetanotherchris
yetanotherchris / TplExample.cs
Created May 20, 2015 22:34
This console application allows you to start, stop, list and query running tasks. The DoStuff() method does the work itself - 50 iterations of sleeping for 10 seconds.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace TplTest
{
@yetanotherchris
yetanotherchris / ApplicationHostParser.cs
Last active August 29, 2015 14:21
A small class for getting site information out of an ApplicationHost.config (the idea being you don't have to copy this applicationhost over the existing one)
public class ApplicationHostParser
{
public void GetSites()
{
string xml = File.ReadAllText("applicationHost.config");
XDocument doc = XDocument.Load(new StringReader(xml));
IEnumerable<XElement> siteNode = doc.Document.Descendants().FirstOrDefault(x => x.Name.LocalName == "system.applicationHost").Descendants().Where(x => x.Name.LocalName == "sites");
IEnumerable<XElement> sites = siteNode.Elements().Where(x => x.Name.LocalName == "site");
Console.WriteLine("Found {0} sites", sites.Count());
nuget pack .\src\IisConfiguration\IisConfiguration.csproj -build -Properties Configuration=Release
/// <summary>
/// Writes the args to the default logging output using the format provided.
/// </summary>
public static void WriteLine(LoggingLevel level,string format, params object[] args)
{
var name = new StackFrame(2,false).GetMethod().Name;
string prefix = string.Format("[{0} - {1}] ",level,name);
string message = string.Format(prefix + format, args);
@yetanotherchris
yetanotherchris / Options.cs
Created September 18, 2015 09:45
Novell Command Line Options class
//
// Options.cs
//
// Authors:
// Jonathan Pryor <jpryor@novell.com>
//
// Copyright (C) 2008 Novell (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
/// <summary>
/// Returns the original summary for a member inherited from a specified type.
/// </summary>
/// <param name="memberID">The member ID to lookup.</param>
/// <param name="declaringType">The type that declares that member.</param>
/// <returns>The summary xml. If not found, returns an zero length string.</returns>
public string GetSummary(string memberID, Type declaringType) {
//extract member type (T:, P:, etc.)
string memberType = memberID.Substring(0, 2);
/* Open
C:\Users\username\AppData\Local\Google\Chrome\User Data\Default\User StyleSheets\Custom.css
and pasted this into it
*/
.even {
padding: 10px !important;
font-family: Segoe UI !important;
border-bottom: 1px solid #EEE !important;
}
///
/// Formats the provided XML so it's indented and humanly-readable.
///
/// <param name="inputXml" />The input XML to format.
///
public static string FormatXml(string inputXml)
{
XmlDocument document = new XmlDocument();
document.Load(new StringReader(inputXml));
class Program
{
static void Main(string[] args)
{
var list = MimeType.Load();
MimeType mimetype = list.FirstOrDefault(m =&gt; m.Extension == "jpg");
}
}
public class MimeType
{
public string Extension { get; set; }
public string Value { get; set; }
public MimeType()
{
Extension = "";
Value = "";
}