Skip to content

Instantly share code, notes, and snippets.

View agehrke's full-sized avatar

Andreas Gehrke agehrke

View GitHub Profile
@agehrke
agehrke / index.html
Created December 18, 2016 11:07
Retina-ready countdown timer
<div id="canvastimer"
class="count-down"
data-timeend="Fri Dec 31 2016 23:59:59 GMT+0100 (CET)
">
</div>
<div id="canvastimer1"
class="count-down"
data-timeend="Fri Dec 30 2016 23:59:59 GMT+0100 (CET)
">
@agehrke
agehrke / error-message.json
Last active April 27, 2016 09:58
Web API error in Sitecore 8.1 Update-2 on CD-servers
{
"Message":"An error has occurred.",
"ExceptionMessage":"experienceAnalytics/api/logger",
"ExceptionType":"System.InvalidOperationException",
"StackTrace":"at Sitecore.ExperienceAnalytics.Api.ApiContainer.CreateObject[T](String xpath)
at Sitecore.ExperienceAnalytics.Api.Http.Filters.NotFoundExceptionFilterAttribute..ctor()
at System.RuntimeTypeHandle.CreateCaInstance(RuntimeType type, IRuntimeMethodInfo ctor)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)
@agehrke
agehrke / ApiController.cs
Last active January 5, 2016 17:59
Disable globally defined Sitecore Web API filters.
/// <summary>
/// Available at url: /sitecore/api/ssc/example1/andreas/{id}/{action}
/// </summary>
[Sitecore.Services.Core.ServicesController("example1.andreas")]
[ClearSitecoreWebApiConfig]
public class MyController : System.Web.Http.ApiController
{
[HttpGet]
public IHttpActionResult MyAction()
{
@agehrke
agehrke / ApiController.cs
Last active August 29, 2015 14:26
Web API controller in Sitecore 8 - including async/await
/// <summary>
/// Note that name of controller does not matter when using ServicesControllerAttribute like below.
/// You can reach the Test() action on url: /sitecore/api/ssc/example1/andreas/1/test
/// </summary>
[Sitecore.Services.Core.ServicesController("example1.andreas")]
public class ApiController : Sitecore.Services.Infrastructure.Web.Http.ServicesApiController
{
[HttpGet]
public async Task<IHttpActionResult> Test(string id)
{
@agehrke
agehrke / ResizeImageStream.cs
Last active August 29, 2015 14:15
Resize media image stream in Sitecore
var mediaItem = GetMediaItemFromSomewhere();
var mediaOptions = new global::Sitecore.Resources.Media.MediaOptions() { MaxWidth = 300 };
var pipelineArgs = new global::Sitecore.Resources.Media.GetMediaStreamPipelineArgs(new global::Sitecore.Resources.Media.MediaData(mediaItem), mediaOptions);
// Run resizing pipeline
var resizeProcessor = new global::Sitecore.Resources.Media.ResizeProcessor();
resizeProcessor.Process(pipelineArgs);
// Copy resized OutputStream to MemoryStream, or use OutputStream.Stream directly
var memoryStream = new System.IO.MemoryStream();
@agehrke
agehrke / SqlServerDataProvider.cs
Last active August 29, 2015 14:09
Custom Sitecore SqlDataProvider and QueryToSqlTranslator which fixes field querying in Sitecore Fast queries.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sitecore.Data.DataProviders.Sql.FastQuery;
using Sitecore.Data.Query;
namespace Kraftvaerk
{
public class KvSqlServerDataProvider : Sitecore.Data.SqlServer.SqlServerDataProvider
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Concorde.AzurePack.Domain.Websites.Preallocation.Settings;
using Concorde.Contracts.Processes;
using Concorde.Infrastructure.Messaging;
using Microsoft.ServiceBus.Messaging;
namespace Allocation
@agehrke
agehrke / dr.dk-nyheder.css
Created June 29, 2012 13:59
Responsive CSS for dr.dk/nyheder
@media all and (max-width: 920px) {
.site-wrapper {
width: auto;
}
/* Footer */
#globalfooter > div, #globalfooter .disclaimer-section div {
width: auto;
}
/* Header */
#globalnavigation > div, #globalnavigation ul li.active ul {