Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
xmlns:string="http://symphony-cms.com/functions"
xmlns:func="http://exslt.org/functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
extension-element-prefixes="func">
<xsl:output method="text"/>
<xsl:variable name="accessDict">
@SlyNet
SlyNet / gist:5317631
Created April 5, 2013 08:38
Awaitable async file download with HttpWebRequest
public class ImageDownloader
{
public async Task<byte[]> Download(string url)
{
var request = (HttpWebRequest) HttpWebRequest.Create(url);
var response = await Task<WebResponse>.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null);
using (var mStream = new MemoryStream())
{
response.GetResponseStream().CopyTo(mStream);
return mStream.ToArray();
#region license
// Copyright (c) 2005 - 2007 Ayende Rahien ([email protected])
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
select internalas0_.Id as Id30_,
internalas0_.InternalAssessmentConfigurationId as Internal2_30_,
internalas0_.InternalAssessorId as Internal3_30_,
internalas0_.ZipCode as ZipCode30_
from dbo.InternalAssessmentMap internalas0_
where replace(cast(internalas0_.ZipCode as nvarchar(50)), ' ' /* @p0 */, '' /* @p1 */) = '6123' /* @p2 */
class Surface
{
public virtual void Draw(Shape shape)
{
shape.Draw(this);
}
}
class EtchASketch : Surface
{
@SlyNet
SlyNet / gist:2889138
Created June 7, 2012 14:36
Unit testing friendly datetime
using System;
namespace Core.Utils
{
public static class SystemTime
{
public static Func<DateTime> Engine { private get; set; }
static SystemTime()
{
builder.RegisterType<DenyAnonymousAccessPolicyViolationHandler>().As<IPolicyViolationHandler>();
Container = builder.Build();
var denyAnonymousAccessPolicyViolationHandler = DependencyResolver.Current.GetService<DenyAnonymousAccessPolicyViolationHandler>();
var denyAnonymousAccessPolicyViolationHandleri = DependencyResolver.Current.GetService<IPolicyViolationHandler>();
@SlyNet
SlyNet / gist:2036300
Created March 14, 2012 13:01
Making asp.net validation work with twitter bootstrap
$.validator.setDefaults({
highlight: function (element) {
$(element).closest(".control-group").addClass("error");
},
unhighlight: function (element) {
$(element).closest(".control-group").removeClass("error");
}
});
$(function () {
$('span.field-validation-valid, span.field-validation-error').each(function () {
using System.Web.Mvc;
using Hoya.Administration.Web.UI.Controllers;
using Machine.Specifications;
namespace Hoya.Administration.Web.UI.Specs.SessionControllerSpecs
{
[Subject(typeof(SessionController))]
public class SessionControllerSpec : BaseSpec
{
public class base_spec
{
protected static AutoMoqer mocker;
protected static Mock<IDependencyResolver> resolver;
private Establish context = () =>
{
mocker = new AutoMoqer();
resolver = new Mock<IDependecyResolver>
DependencyResolver.SetResolver(resolver.Object);