Skip to content

Instantly share code, notes, and snippets.

View jhauge's full-sized avatar

Jesper Hauge jhauge

View GitHub Profile
using System.Web;
using System.Web.Caching;
namespace DriftinfoSystem
{
public class Global : HttpApplication
{
private const string DummyCacheItem = "SimpleWindowsService";
private static CacheItemRemovedCallback _onCacheRemove;
@jhauge
jhauge / MediaApi.cs
Last active December 23, 2015 22:31
private readonly IMediaService _mediaSvc = ApplicationContext.Current.Services.MediaService;
// Updating profile pic
internal void UpdateProfilePic(int profileId, string picPath)
{
if (profileId == 0) throw new ArgumentException("Error updating profile, no profile id in request");
var contentItem = _contentSvc.GetById(profileId);
// Set mediaitem
var mediaFilename = contentItem.Name + Path.GetExtension(picPath);
@jhauge
jhauge / Backup-umbraco.io-db.ps1
Created May 7, 2014 11:14
Backup umbraco.io db
# Backup your umbraco.io db to local machine with this powershell script
# based on a connection string looking like this
# server=xxxxxx.database.windows.net,1433;database=xxxxxx;user id=xxxxxx;password=xxxxxx
#
$dbserver = 'xxxxxx.database.windows.net,1433'
$dbname = 'xxxxxx'
$username = 'xxxxxx'
$password = 'xxxxxx!'
$timestamp = Get-Date -Format 'yyyyMMddTHHmmss'
& sqlpackage /a:export /ssn:"$dbserver" /sdn:"$dbname" /su:"$username" /sp:"$password" /tf:"xxxprojectnamexxx-$timestamp.bacpac"
@jhauge
jhauge / web.config
Created April 5, 2013 10:59
Setup a web application for smtp pickup directory
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory" from="noreply@yourdomain.com">
<specifiedPickupDirectory pickupDirectoryLocation="C:\temp\mailpickup"/>
</smtp>
</mailSettings>
</system.net>
@jhauge
jhauge / AppStart.cs
Created February 23, 2013 21:17
Setup for using web api controllers in an Umbraco website. Code depends on two nuget packages: Microsoft.AspNet.WebApi and [WebActivator](https://github.com/davidebbo/WebActivator)
// Put this file in /App_Start
using Twins.UmbWebApi.App_Start;
using System.Web.Http;
using System.Web.Routing;
[assembly: WebActivator.PreApplicationStartMethod(typeof (AppStart), "RegisterRoutes")]
namespace YourProject.UmbWebApi.App_Start
{
public class AppStart
{
@jhauge
jhauge / backend.cs
Last active December 12, 2015 06:39
var urlItem = node.GetProperty<string>("urlItemAlias");
var urlPickerState = uComponents.Core.DataTypes.UrlPicker.Dto.UrlPickerState.Deserialize(urlItem);
var url = urlPickerState.Url;
var title = urlPickerState.Title;
@jhauge
jhauge / Macroscript.cshtml
Created January 23, 2013 14:08
Usage of macroscripts without using a macro registered in Umbraco backend
@inherits umbraco.MacroEngines.DynamicNodeContext
@if (Parameter.MyCustomParameter == "showThisNotThat")
{
<div>@Model.MyProperty</div>
}
@jhauge
jhauge / Master.master.aspx
Created December 12, 2012 12:06
Making current page properties available for javascript on all pages
<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true"
CodeBehind="Master.master.cs" Inherits="Web.masterpages.Master" %>
<!--
This is the "root" master page that all other masterpages
in the website is based upon.
-->
<asp:Content runat="server" ContentPlaceHolderID="ContentPlaceHolderDefault"><!doctype html>
<html class="no-js" lang="en">
<head>
</head>
@jhauge
jhauge / Master.master.aspx
Created December 12, 2012 11:33
Making current Umbraco/ASP.NET locale/language available in javascript
<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true"
CodeBehind="Master.master.cs" Inherits="Web.masterpages.Master" %>
<asp:Content runat="server" ContentPlaceHolderID="ContentPlaceHolderDefault"><!doctype html>
<html class="no-js" lang="en">
<head>
</head>
<body>
</body>
<!--
@jhauge
jhauge / NodeItem.cs
Created September 6, 2012 12:26
Razor / uQuery example
using umbraco.NodeFactory;
using umbraco.interfaces;
namespace NyborgBy.Repositories.Entities
{
public abstract class NodeItem
{
protected NodeItem()
{
}