Skip to content

Instantly share code, notes, and snippets.

@skttl
skttl / console.js
Created July 11, 2019 09:45
IKEA huskeliste til js object
console.table([...products].map(p => {
var o = {};
o.name = p.querySelector(".product__name").innerText;
o.description = [...p.querySelectorAll(".product__description-list > :not(:last-child)")].map(d => d.innerText).join(" ");
o.articlenumber = p.querySelector(".product_description-article-number").innerText;
o.price = (p.querySelector(".product__price-regular") || p.querySelector(".product__total")).innerText;
o.quantity = p.querySelector(".product-controls__quantity select").value;
o.total = p.querySelector(".product__total").innerText;
return o;
}));
@skttl
skttl / migrate.sql
Created July 11, 2019 09:18
Migrate from Simple301 to SkybrudUmbracoRedirects
INSERT INTO [dbo].[SkybrudRedirects] (RedirectUniqueId, RootNodeId, Url, LinkMode, LinkId, LinkUrl, Created, Updated, IsPermanent, IsRegex, ForwardQueryString)
SELECT NEWID(), 0, OldUrl, 'url', 0, NewUrl, 1562836223, 1562836223, 1, IsRegex, 1 FROM [dbo].[Redirects];
SELECT TOP (1000) [RedirectId]
,[RedirectUniqueId]
,[RootNodeId]
,[Url]
,[QueryString]
,[LinkMode]
,[LinkId]
,[LinkUrl]
@skttl
skttl / DocTypeGridEditor.cshtml
Created February 6, 2019 10:10
Partial view for rendering Doc Type Grid Editor content using Skybrud.Umbraco.GridData
@using Our.Umbraco.DocTypeGridEditor.Helpers
@using Our.Umbraco.DocTypeGridEditor.Web.Extensions
@inherits UmbracoViewPage<GridControl>
@*
This view converts the dynamic Doc Type Grid Editor model to the parts needed for firing up the view
for DTGE based editors. It then uses DTGEs own methods for rendering the needed partial views.
We could do a strongly typed edition of this, but since this is a one-off and we probably never have
to edit this particular view, we didn't.
*@
@skttl
skttl / controller.cs
Created January 22, 2019 19:19
Attribute routing for Umbraco API Controller
// https://our.umbraco.com/forum/extending-umbraco-and-using-the-api/86507-can-i-use-rout-attributes-in-umbraco-controllers#
[RoutePrefix("api/v1/products")]
public class ProductsController : UmbracoApiController
{
[Route("")]
public List<Product> GetAllProducts()
{
return null;
}
@using Umbraco.Core.Models;
@using Umbraco.Web;
@using System.Collections.Generic;
namespace skttl.UmbracoExtensions
{
public static class UmbracoHelperExtensions
{
public static IEnumerable<IPublishedContent> TypedContentAtRelativeXPath(this UmbracoHelper helper, IPublishedContent current, string xpath)
@skttl
skttl / Stylefile.yml
Created August 2, 2018 20:46
Customizations for www.youtube.com via StyleURL.
---
version: 1.0
domains:
- www.youtube.com
url_patterns:
- www.youtube.com/*
timestamp: '2018-08-02T20:46:51Z'
id: pqTX
redirect_url: https://www.youtube.com/watch?v=s0vg_H9hBuU
shared_via: StyleURL - (https://styleurl.app) import and export CSS changes from Chrome
@skttl
skttl / nestedcontent.cs
Last active June 19, 2018 09:34
Models for Nested Content Items to be used with Umbraco ContentService
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Umbraco.Core.Models
{
public class NestedContent : List<NestedContentItem>
{
@skttl
skttl / membergrid.cshtml
Created January 31, 2018 20:36
Member access for grid content
@inherits UmbracoViewPage<dynamic>
@using Umbraco.Web.Templates
@using Newtonsoft.Json.Linq
@* this is my custom grid rendering
Note the function IsAreaVisible at line 69, which takes the UmbracoHelper (for getting the current member) and the area (for reading the visibility-setting)
In the rendering, IsAreaVisible is used at line 50
*@
@skttl
skttl / _outline.scss
Created December 7, 2017 11:31
SCSS mixin for outlining text
@mixin outline-text($width:1px, $color:#fff) {
$text-shadow-result: "0 0 0 #{$color}";
@for $y from -$width through $width {
@for $x from -$width through $width {
$text-shadow-result: #{append($text-shadow-result, ", #{$y} #{$x} 0 #{$color}")};
}
}
text-shadow:$text-shadow-result;
}
@skttl
skttl / metalliganot.js
Created September 27, 2017 08:06
Notifikationer fra metalligaen.dk
if (localStorage.getItem("metalliganot_following") == null)
{
localStorage.setItem("metalliganot_following", "[]");
}
function addFollowButtons()
{
const games = document.querySelectorAll(".live .game");