Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hardye
hardye / Global.asax.cs
Created March 21, 2018 16:17
Sitefinity Language Redirect
protected void Session_Start(object sender, EventArgs e)
{
// Honor the accept-language-header sent by the user's browser and redirect them to the
// desired language version of the site (if it is available).
ResourcesConfig config = Config.Get<ResourcesConfig>();
if (!config.Multilingual)
{
return;
@hardye
hardye / mpfshell-windows.md
Last active June 27, 2018 13:12
Installing and using mpfshell on Windows 10

Installation and usage of the mpfshell utility on Windows

mpfshell is a command line tool for managing files on ESP8266-based microcontrollers. The project's [README][mpfshell-readme] file contains installation and usage instructions but these don't necessarily work on Windows.

The following steps show you how to make mpfshell work on Windows 10:

  1. Determine the COM port of your device in Windows Device Manager
@hardye
hardye / LanguageRequestFilterAttribute
Created April 29, 2015 14:50
Sitefinity ServiceStack Language Request Filter Attribute
/// <summary>
/// Configures the current UI culture based on the client's 'Accept-Language' header.
/// </summary>
public class LanguageRequestFilterAttribute : RequestFilterAttribute
{
private const string AcceptLanguageRegex = @"([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?";
/// <summary>
/// Initializes a new instance of the <see cref="LanguageRequestFilterAttribute" /> class.
/// </summary>
@hardye
hardye / 01-Setup
Last active August 29, 2015 14:16
Sitefinity IDataEvent sample
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Data.Events;
using Telerik.Sitefinity.Events.Model;
using Telerik.Sitefinity.Scheduling;
using Telerik.Sitefinity.Services;
namespace MyApp.MyNamespace
{
public class Setup
protected void Application_Error(object sender, EventArgs e)
{
// get the last error
HttpException err = Server.GetLastError() as HttpException;
Server.ClearError();
// try to skip using any other custom error settings
Response.TrySkipIisCustomErrors = true;
@hardye
hardye / StringExtensions.cs
Created February 4, 2014 09:58
Some useful extension methods for strings.
/// <summary>
/// Extension methods for strings.
/// </summary>
public static class StringExtensions
{
/// <summary>
/// Truncates a string using the specified options.
/// </summary>
/// <param name="val">The value to truncate.</param>
/// <param name="maxLength">Maximum length of the output string.</param>
@hardye
hardye / Global.asax.cs
Last active August 26, 2016 07:33
A simple "hello world" sample illustrating the integration of ServiceStack with Sitefinity as of version 6.2
using System;
using System.Linq;
using Telerik.Sitefinity.Services;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{