Skip to content

Instantly share code, notes, and snippets.

View lars-erik's full-sized avatar

Lars-Erik Aabech lars-erik

View GitHub Profile
@lars-erik
lars-erik / grid-classses.js
Last active April 3, 2020 13:44
Applying styling to the Umbraco grid while editing
angular.module("umbraco").run(["eventsService", function(eventsService) {
function findModelScope(scope) {
if (!scope) {
return null;
}
if (scope.model) {
return scope;
}
return findModelScope(scope.$parent);
}
@lars-erik
lars-erik / package.json
Last active January 27, 2020 08:14 — forked from rikukissa/POST.md
Unit testing Angular.js app with node.js, mocha, angular-mocks and jsdom #angular.js #testing
{
"name": "angularmochaparcel",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "mocha --watch"
@lars-erik
lars-erik / Umbraco - Delete Older Versions.sql
Last active January 10, 2020 15:21 — forked from enkelmedia/Umbraco - Delete Older Versions.sql
Remove older content versions from the Umbraco database (tested on v7.9.2)
-- set how many versions to keep on line 21 (rn > n)
-- actually delete stuff by modifying line 34 to 'commit tran'
begin tran
go
IF OBJECT_ID('tempdb..#tmp') IS NOT NULL DROP Table #tmp
create table #tmp (versionid uniqueidentifier)
insert #tmp select versionid from (
select
@lars-erik
lars-erik / adventofcode-dec04-v2.idiomatic.rock
Last active December 6, 2019 10:49
OMG, I solved AdventOfCode 2019 Dec. 4 A with RockStar!
validate takes code
let hasDouble be no
let char be 1
let max be 6
while char is weaker than max
let thisvalue be code at char
let thatvalue be code at char without 1
if thisvalue is weaker than thatvalue (can't use array refs here)
give back no
else
@lars-erik
lars-erik / FakeContentModelFactory.cs
Last active October 30, 2019 20:03
Umbracosupport 7.15
using System;
using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web;
namespace Umbraco.UnitTesting.Adapter.Support
{
public class FakeModelFactoryResolver : PublishedContentModelFactoryResolver
@lars-erik
lars-erik / VsoGitFileSystemProvider.cs
Created April 25, 2019 11:22
Azure Devops GIT Umbraco Forms FileSystem
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;
using Umbraco.Core.IO;
namespace Umbraco.Forms.Git
@lars-erik
lars-erik / CompositeCommands.cs
Created February 13, 2019 21:26
Simple but flexible command handling
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace SimpleCommands.Tests
{
[TestFixture]
public class When_Processing_A_Command_With_A_Composite
{
@lars-erik
lars-erik / FancyHomeController.cs
Last active January 18, 2019 08:45
Making strings something readable and valuable automagically
using System;
using System.ComponentModel;
using System.Globalization;
using System.Web.Mvc;
using Microsoft.Ajax.Utilities;
namespace StringTypes.Web.Controllers
{
public class HomeController : Controller
{
@lars-erik
lars-erik / Fake_Json.test.cs
Created September 28, 2018 14:16
Fake JSON API in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Owin.Hosting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@lars-erik
lars-erik / list-parameters.component.ts
Created July 11, 2018 09:39
Failing entry component
@Component({
selector: "list-parameters",
templateUrl: "./list-parameters.html"
})
export class ListParametersComponent {
@Input()
public query: any = {};
@Output()
queryChange = new EventEmitter();