Skip to content

Instantly share code, notes, and snippets.

@ahall
ahall / gist:659011
Created November 1, 2010 22:43
TransformXslt.cs
public static void Transform(Stream xmlDoc, string sXslPath, Stream outStream)
{
//load the Xml doc
XPathDocument myXPathDoc = new XPathDocument(xmlDoc);
XslTransform myXslTrans = new XslTransform();
//load the Xsl
myXslTrans.Load(sXslPath) ;
# dmesg | grep -i edac
EDAC MC: Ver: 2.1.0 Mar 1 2011
EDAC amd64_edac: Ver: 3.3.0 Mar 1 2011
EDAC amd64: ECC is enabled by BIOS.
EDAC amd64: This node reports that Memory ECC is currently disabled, set F3x44[22] (0000:00:19.3).
EDAC amd64: ECC disabled in the BIOS or no ECC capability, module will not load.
amd64_edac: probe of 0000:00:19.2 failed with error -22
EDAC MC: F10h CPU detected
EDAC MC: DCT0 chip selects:
EDAC MC: 0: 4096MB 1: 0MB
[Route("/SendFile")]
public void SendFile(IManosContext ctx)
{
const string path = "/etc/services";
ctx.Response.Headers.SetNormalizedHeader("Content-Type", ManosMimeTypes.GetMimeType(path));
ctx.Response.SendFile(path);
ctx.Response.End();
}
@ahall
ahall / gist:1021457
Created June 12, 2011 11:23
Pagination
public class PaginatedList<T> : List<T>
{
private int totalItems;
private int totalPages;
public int PageIndex { get; private set; }
public PaginatedList(IQueryable<T> items, int pageIndex, int perPage)
{
PageIndex = pageIndex < 0 ? 0 : pageIndex;
Errors:
/Users/ahall/Projects/Nancy/src/Nancy.sln (default targets) ->
(Build target) ->
/Users/ahall/Projects/Nancy/src/Nancy/Nancy.csproj (default targets) ->
/Library/Frameworks/Mono.framework/Versions/2.10.1/lib/mono/4.0/Microsoft.CSharp.targets (CoreCompile target) ->
Cryptography/DefaultEncryptionProvider.cs(21,20): error CS1674: `System.Security.Cryptography.Rfc2898DeriveBytes': type used in a using statement must be implicitly convertible to `System.IDisposable'
Cryptography/DefaultEncryptionProvider.cs(43,24): error CS1674: `System.Security.Cryptography.Rfc2898DeriveBytes': type used in a using statement must be implicitly convertible to `System.IDisposable'
This is the p/invoke
public static void CallBackAuth(IntPtr server,
IntPtr share,
IntPtr workgroup,
int wgmaxlen,
IntPtr username,
int unmaxlen,
IntPtr password,
int pwmaxlen)
public class SessionPostAttribute : RequestFilterAttribute
{
public SessionPostAttribute()
{
this.Priority = -200;
this.ApplyTo = ApplyTo.Post;
}
public override void Execute(IHttpRequest req, IHttpResponse res, object requestDto)
{
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
@ahall
ahall / gist:2710678
Created May 16, 2012 14:16
Async vs Sync for servicestack
// Code first
using System;
using ServiceStack.WebHost.Endpoints;
using System.Threading;
using ServiceStack.ServiceInterface;
using System.Threading.Tasks;
namespace ServiceStackBench
Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at System.Array.Copy (System.Array sourceArray, Int32 sourceIndex, System.Array destinationArray, Int32 destinationIndex, Int32 length) [0x00000] in <filename unknown>:0
at System.Collections.ArrayList.CopyTo (Int32 index, System.Array array, Int32 arrayIndex, Int32 count) [0x00000] in <filename unknown>:0
at System.Collections.ArrayList.CopyTo (System.Array array, Int32 arrayIndex) [0x00000] in <filename unknown>:0
at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
at System.MonoType.GetCustomAttributes (System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
at ServiceStack.Common.ReflectionExtensions.FirstAttribute[AliasAttribute] (System.Type type, Boolean inherit) [0x00000] in <filename unknown>:0
at ServiceStack.Common.ReflectionExtensions.FirstAttribute[AliasAttrib