Skip to content

Instantly share code, notes, and snippets.

View dawoe's full-sized avatar

Dave Woestenborghs dawoe

  • DotControl
  • Dilsen-Stokkem, Belgium
  • X @dawoe21
View GitHub Profile
@mattbrailsford
mattbrailsford / Bootstrap.cs
Created August 7, 2014 12:50
Indexing JSON values in Umbraco
public class Bootstrapper : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarted(umbracoApplication, applicationContext);
ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"]
.GatheringNodeData += (sender, e) =>
{
// Extract JSON properties

By using my Skybrud.Umbraco.GridData package (which introduces a strongly typed model for the Grid), indexing the new Grid in Umbraco 7.2 is quite easy.

At Skybrud.dk we typically create a class named ExamineIndexer that takes care of the Examine related events. This class should be initalized during Umbraco startup like this:

using Umbraco.Core;

namespace FanoeTest {

 public class Startup : ApplicationEventHandler {
@cssquirrel
cssquirrel / FileUploadApiController.cs
Last active January 25, 2019 11:49
Using AngularJS API service and Umbraco API controller to permit users to upload files to the server
// Use whatever namespacing works for your project.
namespace YourSite.Web.Controllers.Api
{
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
@mattbrailsford
mattbrailsford / CountryAppender.js
Last active August 29, 2015 14:22
CountryAppender.js
angular.module("umbraco").config(["$provide", function ($provide) {
$provide.decorator("entityResource", function ($delegate, $q) {
var getByIdsFn = $delegate.getByIds;
$delegate.getByIds = function (ids, type) {
var result = getByIdsFn.apply(null, arguments);
var loadRegionInfo = function(data, idx, def) {
@dampee
dampee / umbraco db cleanup.sql
Last active November 9, 2021 12:57
Umbraco Database cleanup. After pulling in an umbraco database from production, you don't need all history or log.
-- Umbraco Clear Old Document Versions To Decrease Database Size And Improve Performance
-- http://borism.net/2008/12/16/fixing-a-large-cmspropertydata-table-in-umbraco/
DECLARE @createdDate Datetime = DATEADD(m, -1, getdate())
-- dump logs
-- TRUNCATE TABLE umbracolog -- faster if log table is very big and you don't need anything
DELETE FROM umbracolog WHERE Datestamp < @createdDate
-- clean up old versions
DELETE FROM cmsPropertyData WHERE
@jamiepollock
jamiepollock / CreateOnlyDictionaryHandler.cs
Last active July 29, 2020 08:24
A uSync custom DictionaryHandler which only imports items if they're missing. It will not overwrite any existing authored translations.
using Jumoo.uSync.BackOffice;
using Jumoo.uSync.BackOffice.Handlers;
using Jumoo.uSync.BackOffice.Helpers;
using Jumoo.uSync.Core;
using Jumoo.uSync.Core.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
// Filter to take a node id and grab it's name instead
// Usage: {{ pickerAlias | ncNodeName }}
// Cache for node names so we don't make a ton of requests
var ncNodeNameCache = {
id: "",
keys: {}
}
angular.module("umbraco.filters").filter("ncNodeName", function (editorState, entityResource) {
@enkelmedia
enkelmedia / gist:5e7c242d08d8af6b7b3149af2e952ab2
Last active September 17, 2019 14:15
ModelsBuilderMock.cs
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text.RegularExpressions;
using Moq;
using Umbraco.Core.Models;
using Umbraco.ModelsBuilder;
namespace Obviuse.Tests
@jraps20
jraps20 / build.yml
Created August 12, 2019 17:57
Cache NuGet Packages with Cache Task in Azure DevOps YAML
- powershell: | # generates a hash of all packages.config and saves each on a single line on 'hash.txt'
Get-FileHash -Algorithm MD5 -Path (Get-ChildItem packages.config -Recurse) >> hash.txt
Write-Host "Hash File saved to $pwd\hash.txt"
workingDirectory: src
displayName: 'Calculate and save packages.config hash'
- task: CacheBeta@0 # speed up builds by caching packages folder
inputs:
key: nuget|1|$(Agent.OS)|$(Build.SourcesDirectory)\src\hash.txt # hash map generated in previous step
path: $(Build.SourcesDirectory)\src\packages
@dawoe
dawoe / CreateOnlyDictionaryHandler.cs
Created October 16, 2019 11:07 — forked from jamiepollock/CreateOnlyDictionaryHandler.cs
A uSync custom DictionaryHandler which only imports items if they're missing. It will not overwrite any existing authored translations.
using Jumoo.uSync.BackOffice;
using Jumoo.uSync.BackOffice.Handlers;
using Jumoo.uSync.BackOffice.Helpers;
using Jumoo.uSync.Core;
using Jumoo.uSync.Core.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;