Skip to content

Instantly share code, notes, and snippets.

View warrenbuckley's full-sized avatar

Warren Buckley warrenbuckley

View GitHub Profile
@warrenbuckley
warrenbuckley / winget.ps1
Last active July 20, 2021 10:58
WinGet install Powershell script
winget install --id=Spotify.Spotify -e ;
winget install --id=Microsoft.WindowsTerminal -e ;
winget install --id=Microsoft.VisualStudioCode -e ;
winget install --id=7zip.7zip -e ;
winget install --id=Microsoft.AzureStorageExplorer -e ;
winget install --id=ScooterSoftware.BeyondCompare4 -e ;
winget install --id=Google.Chrome -e ;
winget install --id=Dropbox.Dropbox -e ;
winget install --id=Git.Git -e ;
winget install --id=Insomnia.Insomnia -e ;
@heyMP
heyMP / utils.js
Last active April 18, 2024 07:58
Recursively find elements through multiple layers of shadow dom.
/**
* Example usage:
* const hotspots = findAllDeep(element, `[slot*="hotspot"]`, 10);
*/
const findAllDeep = (parent, selectors, depth = null) => {
let nodes = new Set();
let currentDepth = 1;
const recordResult = (nodesArray) => {
for (const node of nodesArray) {
nodes.add(node)
@TimGeyssens
TimGeyssens / Umbraco Forms validation example
Created June 8, 2015 08:32
Umbraco Forms validation example
public class FormsValidation : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
Umbraco.Forms.Web.Controllers.UmbracoFormsController.FormValidate += UmbracoFormsController_FormValidate;
}
void UmbracoFormsController_FormValidate(object sender, Umbraco.Forms.Mvc.FormValidationEventArgs e)
{
@andrewmurray
andrewmurray / gist:b63b7592386cb67124d1
Last active February 14, 2024 12:17
Convert an Epplus ExcelPackage to a CSV file, returning the byte[] array of this new CSV file. Taking the code provided by "Brad" at http://codejournal.blogspot.co.uk/2012/03/using-epplus-library-to-convert-xlsx-to.html and creating an extension method from it which can be called on Epplus' ExcelPackage. Just call excelPackageObject.ConvertToCsv();
using OfficeOpenXml;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace WebUI.Infrastructure
{
public static class StringUtils
{
private static string DuplicateTicksForSql(this string s)
@leekelleher
leekelleher / MyApplication.cs
Last active December 19, 2015 13:59
Example of Umbraco 6.1's IContentFinder
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web.Mvc;
using Umbraco.Web.Routing;
namespace Our.Umbraco
{
public class MyApplication : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
@trssaunders
trssaunders / GetMNTPValuesRecursively
Created May 22, 2013 12:05
Get MNTP values recursively, as you can't use the built in Umbraco method as it incorrectly detects values. i.e. string[] nodeIds = Model.GetPropertyValue(Parameter.advertSlot, true).Split(','); does not go all the way up the tree if a MNTP has previously had a value that has been subsequently deleted
string[] nodeIds = Model.AncestorOrSelf((Func<dynamic, bool>)(n => n.HasValue("fieldAliasHere"))).GetPropertyValue("fieldAliasHere").Split(',');
using System;
using Umbraco.Core;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace Umbraco.Examples
{
/// <summary>
/// Class that shows the use of creating a new table and inserting a new ArticlePoco.
/// This class is only intended for demo'ing and should not be used as it.
@uniquelau
uniquelau / createWebsite.ps1
Last active December 17, 2015 10:09
Powershell file that makes creating new websites in IIS a breeze! :) $InetFolder & $Domain should be tweaked for your purposes. Original code from http://www.zerrouki.com/create-website/ + added in multiple hostnames, fixed Runtime bug. Now supports creation of a single Virtual Directory, e.g. for Media in a load balanced environment.
<#
.SYNOPSIS CreateWebsite - Automatic website creation.
.DESCRIPTION Allow to create a website and its ApplicationPool. Some tuning is included
.PARAMETER SiteName Defines the display name (in IIS Manager) of the website
Mandatory parameter.
.PARAMETER Port Defines the listening port for the website
Default is "80".
.PARAMETER Environment Defines the website environment.
This will be added as suffix in the website display name
Possible values are "LIVE", "STAGING", "UAT", "QUAL" or "DEV"
@nul800sebastiaan
nul800sebastiaan / gist:5256117
Created March 27, 2013 17:09
Implement Umbraco Macro Error event handler.
using System;
using umbraco.interfaces;
namespace MyNameSpace
{
public class StartupEventHandlers : IApplicationStartupHandler
{
public StartupEventHandlers()
{
umbraco.macro.Error += macro_Error;