Skip to content

Instantly share code, notes, and snippets.

View uniquelau's full-sized avatar

Laurence Gillian uniquelau

View GitHub Profile
@Hendy
Hendy / DeleteAllVersions.sql
Last active October 28, 2020 10:10
Umbraco - delete version history for all content
-- Create a temporary table for all documents which are published and not in the recycle bin
CREATE TABLE #Nodes (id int)
-- Delete all rows if the table exists before
TRUNCATE TABLE #Nodes
-- Insert all nodeIds from all documents which are published and not in the recycle bin
INSERT INTO #Nodes
SELECT N.id
FROM umbracoNode N
INNER JOIN cmsDocument D ON N.ID = D.NodeId
@nicolashery
nicolashery / elasticsearch.md
Last active December 30, 2023 19:03
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
@greystate
greystate / affiliates.xml
Last active December 15, 2015 04:49
Demo of how to grab all `<affiliate>` nodes with the `@refID` as specified by the `$refID` variable – *or*, if the $refID variable is empty, take all `<affiliate>`s ...
<root>
<affiliate refID="1200">1200</affiliate>
<affiliate refID="1201">1201</affiliate>
<affiliate refID="1202">1202</affiliate>
<affiliate refID="1203">1203</affiliate>
<affiliate refID="1204">1204</affiliate>
<affiliate refID="1205">1205</affiliate>
<affiliate refID="1206">1206</affiliate>
<affiliate refID="1207">1207</affiliate>
<affiliate refID="1208">1208</affiliate>
@kevinblake
kevinblake / gist:4000628
Created November 2, 2012 11:50
Rebuild Examine Indexes on Application Start
using System.Collections.Generic;
using Examine;
using umbraco.businesslogic;
namespace MyApplication
{
public class ExamineIndexRebuild : ApplicationStartupHandler
{
@greystate
greystate / Explanation.md
Created September 5, 2012 22:18
Umbraco CSS Style Switcher (XSLT)

Explaining the set trickery bit

Short version

We select the 1st stylesheet in a temporary nodeset created from the default stylesheet and the stylesheet referenced by the either the QueryString or a Cookie value.

Long version

Here's a commented version of the XPath that creates the $activeCSS variable:

@paulirish
paulirish / data-markdown.user.js
Last active February 6, 2024 10:41
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@leekelleher
leekelleher / RedirectToFirstChild.master
Created August 24, 2011 15:55
Umbraco template to redirect the current page/node to its first child page/node.
<%@ Master Language="C#" MasterPageFile="~/masterpages/BlankTemplate.master" AutoEventWireup="true" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
var current = umbraco.NodeFactory.Node.GetCurrent();
if (current != null)
{
var child = current.ChildrenAsList.FirstOrDefault();
if (child != null)
{
@leekelleher
leekelleher / PaginationExample.xslt
Created August 3, 2011 08:08
Generic XSLT template for pagination with Umbraco
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "&#x00A0;">
]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">