Skip to content

Instantly share code, notes, and snippets.

View chgeuer's full-sized avatar
🏠
Working from Düsseldorf

Dr. Christian Geuer-Pollmann chgeuer

🏠
Working from Düsseldorf
View GitHub Profile
@chgeuer
chgeuer / DefaultProxySettings.cs
Created February 28, 2012 07:36
Set default proxy recipe
HttpWebRequest.DefaultWebProxy = new WebProxy("127.0.0.1", 8080)
{
BypassProxyOnLocal = true,
Credentials = new NetworkCredential("user", "pass")
};
@chgeuer
chgeuer / SelfHostedAspNetWebApi.cs
Created February 28, 2012 18:28
Sample for self-hosting ASP.NET Web API
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.SelfHost;
using System.Threading;
@chgeuer
chgeuer / NameGenerator.cs
Created February 29, 2012 16:43
Name generator
class Program
{
static void Main(string[] args)
{
var random = new Random();
var firstnames = female;
for (int i = 0; i < 100; i++)
{
if (random.Next()%2 == 0) firstnames = male;
@chgeuer
chgeuer / ExposeAMefContainer.cs
Created March 7, 2012 08:09
Demonstrates how a MEF CompositionContainer itself ensures that it can be [Import]ed as well.
namespace ExposeAMefContainer
{
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
class Program
{
static void Main(string[] args)
@chgeuer
chgeuer / clean.ps1
Created April 18, 2012 20:01
Cleaning up some processes and deleting artefacts
Get-Process | Where-Object { $_.Name -eq "w3wp" } | Stop-Process -Force
Remove-Item -Recurse -Force D:\LogFiles\*
@chgeuer
chgeuer / DataContractSerializeUtil.cs
Created April 18, 2012 20:05
Serialize using a DataContractSerializer
public static string DataContractSerialize(object serializableObject)
{
if (serializableObject == null)
{
return null;
}
using (MemoryStream memoryStream = new MemoryStream())
{
DataContractSerializer serializer = new DataContractSerializer(serializableObject.GetType());
serializer.WriteObject(memoryStream, serializableObject);
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
set BASE=C:\T
set TOMCAT_VERSION=7.0.27
set WAR_NAME=HelloWorld.war
set JRE_LOCALZIP=jdk.zip
set JAVA_HOME=%BASE%\jre
set PATH=%PATH%;%JAVA_HOME%\bin
set TOMCAT_LOCALZIP=apache-tomcat-%TOMCAT_VERSION%-windows-x64.zip
set CATALINA_HOME=%BASE%\apache-tomcat-%TOMCAT_VERSION%
@chgeuer
chgeuer / ^sampl
Created May 7, 2012 12:12
sample1
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<ServiceDefinition xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" name="WindowsAzureProject">
<WorkerRole name="WorkerRole1" vmsize="Medium">
<Startup>
<!-- Sample startup task calling startup.cmd from the role's approot folder -->
<Task commandLine="util/.start.cmd startup.cmd" executionContext="elevated" taskType="simple">
<Environment>
<Variable name="BASE">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/LocalResources/LocalResource[@name='TC']/@path"/>
</Variable>
@chgeuer
chgeuer / RestartingProcessHost.cs
Created May 10, 2012 21:17
Hosting a process, and ensuring that it's restarted even if it terminates unexpectedly
namespace chgeuer.WebRoleUtils
{
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
public class RestartingProcessHost
{
internal class ValueTypeWrapper<T>