Skip to content

Instantly share code, notes, and snippets.

View dougludlow's full-sized avatar
🏠
Working from home

Douglas Ludlow dougludlow

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am dougludlow on github.
  • I am dougludlow (https://keybase.io/dougludlow) on keybase.
  • I have a public key whose fingerprint is 5DBF 8468 75A2 2C6C F2EC 9F1E 71C6 8D52 0D1E B6F7

To claim this, I am signing this object:

@dougludlow
dougludlow / SaveMedia.cs
Created September 5, 2014 17:30
Resave media nodes to fix cache problem
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using umbraco.cms.businesslogic.media;
using umbraco.presentation.umbracobase;
[RestExtension("Media")]
public class SaveMedia
{
@dougludlow
dougludlow / FindEmbeddedMediaInUmbraco.ps1
Last active August 29, 2015 14:02
Find embedded media (embeds and iframes) in Umbraco that are not using a protocol relative url.
Function Get-EmbeddedCount {
Param([string]$path)
$embedded = @{}
Get-ChildItem $path | ForEach-Object {
[xml]$cache = Get-Content $_.FullName
$regex = "<(?<tag>iframe|embed|param)(?<space>[\S\s-[>]]*?)(?<attr>src|value)=`"(?<protocol>http:)(?<url>//(.)*?)`"(?<therest>[\S\s-[>]]*?)>"
$xpath = "//bodyText"
$nodes = $cache.SelectNodes($xpath) | Where-Object { $_.InnerText -match $regex }
@dougludlow
dougludlow / EmbeddedMedia.config
Created June 16, 2014 22:45
Umbraco EmbeddedMedia YouTube oEmbed SSL
<!-- Youtube Settings -->
<provider name="Youtube" type="Umbraco.Web.Media.EmbedProviders.OEmbedVideo, umbraco">
<urlShemeRegex><![CDATA[youtu(?:\.be|be\.com)/(?:(.*)v(/|=)|(.*/)?)([a-zA-Z0-9-_]+)]]></urlShemeRegex>
<apiEndpoint><![CDATA[http://www.youtube.com/oembed]]></apiEndpoint>
<requestParams type="Umbraco.Web.Media.EmbedProviders.Settings.Dictionary, umbraco">
<param name="iframe">1</param>
<param name="format">xml</param>
<param name="scheme">https</param>
</requestParams>
</provider>
@dougludlow
dougludlow / UpdateEmbeddedContent.ps1
Created June 16, 2014 20:19
Update the EmbeddedContent package on mulitple Umbraco sites
function Update-EmbeddedContent {
Param([string]$site)
# Replace DLL
$source = "Updated\bin\TheFarm.Umbraco.EmbeddedContent.dll"
$assembly = (Join-Path $site "bin\TheFarm.Umbraco.EmbeddedContent.dll")
Remove-Item $assembly
Copy-Item $source -Destination $assembly
@dougludlow
dougludlow / AuditLogTriggers.sql
Last active August 29, 2015 14:01
Audit log triggers on select tables
SET NOCOUNT ON
DECLARE
@table sysname,
@sql varchar(2000)
SELECT * INTO #tables FROM INFORMATION_SCHEMA.Tables WHERE TABLE_NAME IN ('Post', 'PostArea', 'Comment', 'Location', 'Attachment')
SELECT @table = MIN(TABLE_NAME) FROM #tables
WHILE @table IS NOT NULL
@dougludlow
dougludlow / ssis-datestamp
Last active August 29, 2015 14:01
Datestamp for SSIS Expression
REPLACE(REPLACE(REPLACE(SUBSTRING((DT_STR, 30, 1252)GETDATE(), 1, 19 ) , "-", ""), " ", ""), ":", "")
@dougludlow
dougludlow / vs-mit-code-snippet
Created January 6, 2014 18:44
Visual Studio code snippet to include the MIT(X11) License
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>The MIT License (MIT)</Title>
<Shortcut>mit</Shortcut>
<Description>The Open Source MIT License (MIT)</Description>
<Author>Douglas Ludlow</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
@dougludlow
dougludlow / Move.cs
Created August 6, 2013 23:24
Move Umbraco nodes from one parent to another.
var old = new Document(1234);
var newId = 4321;
foreach (var child in old.Children)
{
child.Move(newId);
}
umbraco.library.RefreshContent();
@dougludlow
dougludlow / Sidebar.cs
Created August 6, 2013 20:18
Programmatically add a list of properties to a document type in Umbraco. In this case, add the sidebar tab and properties.
var dt = DocumentType.GetByAlias("Test");
var sidebar = new DataTypeDefinition(1424);
var note = new DataTypeDefinition(1485);
var picker = new DataTypeDefinition(1034);
var trueFalse = new DataTypeDefinition(-49);
var textString = new DataTypeDefinition(-88);
var list = new List<Tuple<DataTypeDefinition, string, string>> {
new Tuple<DataTypeDefinition, string, string>(trueFalse, "sidebarEnabled", "Enable Sidebar"),