Skip to content

Instantly share code, notes, and snippets.

@whyleee
whyleee / ExportMediaJob.cs
Created July 23, 2015 15:01
EPiServer jobs to migrate Commerce assets between servers
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web.Hosting;
using EPiServer;
using EPiServer.BaseLibrary.Scheduling;
using EPiServer.Commerce.Catalog.ContentTypes;
using EPiServer.Core;
@whyleee
whyleee / js-git-node-request.js
Created August 9, 2015 19:14
js-git node.js request implementation
var https = require('https');
var urlParse = require('url').parse;
function request(method, url, headers, body, callback) {
if (typeof body == 'function') {
callback = body;
body = undefined;
}
var parsedUrl = urlParse(url);
@whyleee
whyleee / WriteObject.cs
Last active October 14, 2015 08:39
Function to write RDB C# objects to console
private static void WriteObject(object obj, int indent = 0, string suffix = null)
{
foreach (var prop in obj.GetType().GetProperties())
{
var value = prop.GetValue(obj);
if (prop.PropertyType.FullName.StartsWith("RDB") && !prop.PropertyType.IsEnum && value != null)
{
Console.Write(new string(' ', indent));
Console.WriteLine(prop.Name + ":");
@whyleee
whyleee / IocConfig.cs
Created May 20, 2016 08:00
StructureMap dependency resolver for Episerver with MVC/Web API
[ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
public class IocConfig : IConfigurableModule
{
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.Container.EjectAllInstancesOf<ICatalogContentBuilder>();
context.Container.Configure(ConfigureContainer);
DependencyResolver.SetResolver(new StructureMap.StructureMapDependencyResolver(context.Container));
@whyleee
whyleee / FixedGoogleAnalyticsContextController.cs
Created November 24, 2016 14:46
Fix for Episerver Google Analytics context gadget for multi-hostname websites or dedicated edit server.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using EPiServer.Core;
using EPiServer.GoogleAnalytics.Models;
namespace EPiServer.GoogleAnalytics.Controllers
{
// Fixes Google Analytics context gadget for multi-hostname websites or dedicated edit server.
@whyleee
whyleee / MigrateHeroPanelOverlayJob
Created February 1, 2017 13:46
Example Episerver job for block property migration
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAccess;
using EPiServer.PlugIn;
using EPiServer.Scheduler;
@whyleee
whyleee / WebpackController.cs
Created September 27, 2018 11:34
Inject Webpack output HTML into ASP.NET MVC
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web.Hosting;
using System.Web.Mvc;
[user]
name = Pavel Nezhencev
email = pavel.nezhencev@creuna.com
[core]
autocrlf = true
editor = code --wait
[push]
default = simple
[alias]
ll = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
@whyleee
whyleee / async-data-mixin.js
Created December 3, 2018 11:53
Async data mixin with content area handling (is it really needed on client side? because mixin as applied to all components)
import blockRouter from '@/router/block-router'
// TODO ssr move to lib and reuse with entry-server.js
function loadBlocksAsyncData({ store, route, model }) {
const contentAreas = Object.keys(model)
.filter(key => key.endsWith('ContentArea'))
.map(key => model[key])
const blockPromises = contentAreas
.map(blocks => blockRouter.resolveComponents(blocks))
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using EPiServer;
using EPiServer.Core;
using EPiServer.Framework.Cache;
using EPiServer.Globalization;
using EPiServer.Web;