Skip to content

Instantly share code, notes, and snippets.

View lars-erik's full-sized avatar

Lars-Erik Aabech lars-erik

View GitHub Profile
@lars-erik
lars-erik / gist:2365774
Created April 12, 2012 09:16
HttpClient testwrapper
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace AHttpClientTestWrapper
{
public class HttpClientWrapper
@lars-erik
lars-erik / RandomPassword.cs
Created April 30, 2012 11:30
Random Password Generators
using System;
public class RandomPassword
{
private static Random random = new Random();
public static string Create(int length = 8, float charRatio = .8f)
{
string password = "";
@lars-erik
lars-erik / TestStub.cs
Created May 24, 2012 11:07
Umbraco Test Helpers
[TestFixture]
public class TestStub: UmbracoTestBase
{
[SetUp]
public void Setup()
{
SetupFakeEnvironment();
SetupRootContent();
}
@lars-erik
lars-erik / ControlRenderer.cs
Created July 25, 2012 14:16
ASP.NET Control Snapshot Renderer
public class ControlRenderer : IDisposable
{
public static string RenderContents(Control control)
{
using (var renderer = new ControlRenderer(control))
{
return renderer.Render();
}
}
@lars-erik
lars-erik / BusinessTests.cs
Created November 30, 2012 14:49
UOW & Repo template
[TestFixture]
public class BusinessTests
{
private IRepository<Entity> repo;
private ConcreteService service;
[SetUp]
public void SetUp()
{
repo = MockRepository.GenerateStub<IRepository<Entity>>();
@lars-erik
lars-erik / Category.aspx
Created May 29, 2013 10:36
UCommerce Datatypes Category picker with stores
<%@ Control Language="C#" AutoEventWireup="true" Inherits="This.Web.usercontrols.Administrative.UCommerceDataTypesCategory" %>
<asp:UpdateProgress ID="UpdateProgress1"
runat="server"
AssociatedUpdatePanelID="CategoryPanel">
<ProgressTemplate>
<img src="/umbraco/images/throbber.gif" alt="Loading"/>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel runat="server" UpdateMode="Always" ID="CategoryPanel">
<ContentTemplate>
@lars-erik
lars-erik / ellipsisul.js
Last active December 22, 2015 23:39
Adds ... to too long lis.
$.fn.ellipsisUl = function() {
var sum = function(array, selector) {
var sum = 0;
array.each(function(i, e) {
sum += selector($(e));
});
return sum;
},
paddingLeft = function(e) {
return Number(e.css("padding-left").replace("px", ""));
@lars-erik
lars-erik / listassemblies.aspx
Created September 13, 2013 14:02
See all referenced assemblies and their references. (Nice when in the middle of dll hell)
<%@ Page Language="C#" AutoEventWireup="true" %>
<%
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
Response.Write("<b>" + assembly.FullName + "</b><br/>\r\n");
Response.Write("<ul>\r\n");
foreach (var subAssembly in assembly.GetReferencedAssemblies())
{
Response.Write("<li>" + subAssembly.FullName + "</li>\r\n");
@lars-erik
lars-erik / GetUmbracoServices.cs
Created October 14, 2013 16:22
Gist description…
protected static ServiceContext CreateServiceContext(string basePath, string connectionString, string providerName)
{
var serviceContextManagerType = OptimisticType.GetType("Umbraco.Core.Standalone.ServiceContextManager, Umbraco.Core");
if (serviceContextManagerType == null)
throw new Exception("Couldn't get Umbraco.Core.Standalone.ServiceContextManager type");
var serviceContextManager = Activator.CreateInstance(serviceContextManagerType,
connectionString,
providerName,
basePath
);
@lars-erik
lars-erik / FilesXml.sql
Created February 6, 2014 14:28
Umbraco.config transformations for CMSImport
SELECT
image.id,
replace(dataNvarchar, '/media', '/oldmedia') filename
FROM [umbracoNode] as image
inner join cmscontent on
cmscontent.nodeid = image.id
inner join cmscontenttype on
contenttype = cmscontenttype.nodeid
inner join cmsPropertyData on
cmsPropertyData.contentNodeId = image.id