Skip to content

Instantly share code, notes, and snippets.

View michaelbramwell's full-sized avatar

696d656b michaelbramwell

  • Perth Australia
View GitHub Profile
export const chaosTestStrings = (): void => {
const textNodes = getAllTextNodes(document.body);
for (const node of textNodes) {
const textNodeLength = node.textContent ? node.textContent.length : 0;
if (node.textContent === null) {
return;
}
if (node.parentElement instanceof Element) {
if (node.parentElement.dataset.originalText === undefined) {
@bic742
bic742 / SearchQuery.cs
Last active August 15, 2023 12:04
Extended Sitecore SearchQuery to support sorting and more complex search criteria
using GraphQL.Types;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Linq;
using Sitecore.ContentSearch.Linq.Utilities;
using Sitecore.ContentSearch.Utilities;
using Sitecore.Data;
using Sitecore.Data.Managers;
using Sitecore.Globalization;
using Sitecore.Services.GraphQL.Content.GraphTypes.ContentSearch;
using Sitecore.Services.GraphQL.GraphTypes.Connections;
@czachor
czachor / wp_usermeta.md
Last active June 30, 2021 08:24 — forked from magnific0/wp_usermeta.md
Show and Edit User Meta in Wordpress

Show and Edit User Meta in WordPress (works with UltimateMember)

Description

This simple procedure will allow you to:

  1. Display user meta fields under in the user list as additional columns (Users > All Users).
  2. Display these fields on user profiles.
  3. Edit these fields under user edit.

This method works completely without plugins and involves just some functions and hooks in functions.php. Plugins like "User Meta Display" achieve this to some level, but treat custom meta fiedlds completely different from the regular fields. They are shown and edited in seperate environment and fail to show the meta data is a table list. This method integrates custom user meta along with regular user (meta).

@ayende
ayende / LetsEncryptClient.cs
Created January 11, 2018 22:26
ACME v2 client for Let's Encrypt
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@JamesSkemp
JamesSkemp / New Sitecore Ribbon Button.md
Last active June 22, 2017 08:35
Steps to create a new Sitecore ribbon button

Add a New Command Button to a Sitecore Ribbon

The following covers how to add a new button to the Sitecore ribbon.

The following Sitecore changes must be done in the core database.

Create a new Ribbon Chunk

/sitecore/content/Applications/Content Editor/Ribbons/Chunks/*group name*
@kamsar
kamsar / Performance.Dev.config
Last active August 17, 2021 16:04
SItecore 8.0/8.1/8.2 Performance Config
<!--
A set of performance optimizations for development that vastly increase application startup time.
Should not be used in production, as they largely disable forensic diagnostics that you'd want there over fast startup time after a compile.
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<hooks>
<hook type="Sitecore.Diagnostics.HealthMonitorHook, Sitecore.Kernel">
<patch:delete />
@jogleasonjr
jogleasonjr / SlackClient.cs
Last active October 20, 2023 15:54
A simple C# class to post messages to a Slack channel. You must have the Incoming WebHooks Integration enabled. This class uses the Newtonsoft Json.NET serializer available via NuGet. Scroll down for an example test method and a LinqPad snippet. Enjoy!
using Newtonsoft.Json;
using System;
using System.Collections.Specialized;
using System.Net;
using System.Text;
//A simple C# class to post messages to a Slack channel
//Note: This class uses the Newtonsoft Json.NET serializer available via NuGet
public class SlackClient
{
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@PaulKinlan
PaulKinlan / criticalcss.html
Last active March 15, 2023 02:13
Detect Critical CSS
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<h2>Original CSS</h2>
<style style="display: block; white-space: pre; font-family: monospace">
h2 { margin:0; }
@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];