Skip to content

Instantly share code, notes, and snippets.

View mattbrailsford's full-sized avatar

Matt Brailsford mattbrailsford

View GitHub Profile
@mattbrailsford
mattbrailsford / propeditor.js
Created February 23, 2018 08:28
Example Umbraco property editor code for writing to the model.value and listening for changes without using an angular watcher
//here we declare a special method which will be called
// whenever the value has changed from the server
$scope.model.onValueChanged = function (newVal, oldVal) {
// Model value changed so update UI
updateUi()
};
var unsubscribe = $scope.$on("formSubmitting", function () {
// Write data back to the model.value
$scope.model.value = ...
@mattbrailsford
mattbrailsford / .travis.yml
Last active September 12, 2021 13:49
Configuration for deploying a NUXT static site to github pages
language: node_js
node_js:
- "8"
cache:
directories:
- "node_modules"
branches:
only:
@mattbrailsford
mattbrailsford / line-us-plotclock.json
Last active September 9, 2018 16:13
Node-RED Flow for a plotclock implementation using a Line-us machine
[
{
"id": "1207feb6.6cb2e1",
"type": "tab",
"label": "Line-us",
"disabled": true,
"info": ""
},
{
"id": "688cc590.31b39c",
@mattbrailsford
mattbrailsford / aspect-ratio.js
Last active January 18, 2019 18:55
Tailwind CSS Aspect Ratio plugin
const _ = require('lodash');
module.exports = function({ ratios, options, variants }) {
return function({ addUtilities, e }) {
const opts = Object.assign({}, {
orientedRatios: false,
invertedRatios: false
}, options);
...
try:
while True:
blynk.run()
except KeyboardInterrupt:
pass
namespace MyNamespace
{
[ComposeAfter(typeof(TeaCommerceComposer))]
public class MyComposer : IUserComposer
{
public void Compose(Composition composition)
{
composition.WithOrderCheckoutPipeline()
.InsertBefore<CalculateShippingTask, MyPipelineTask>()
.Append<MyOtherPipelineTask>();
@mattbrailsford
mattbrailsford / TeaCommerce.Umbraco.Courier.cs
Last active February 20, 2019 15:06
Courier property resolver for Tea Commerce Variants property editor
namespace TeaCommerce.Umbraco.Courier
{
public class TeaCommerceVariantPropertyDataResolver : PropertyDataResolverProvider
{
public override string EditorAlias
{
get
{
return "TeaCommerce.VariantEditor";
}
public class Bootstrap : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"].GatheringNodeData += (sender, e) =>
{
// Extract JSON properties
var fieldKeys = e.Fields.Keys.ToArray();
foreach (var key in fieldKeys)
{
public IPublishedContent GetGlobalContentNode()
{
return (IPublishedContent)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem("Application.BusinessLogic.Services.GetGlobalContentNode", () => {
var settingsNode = GetNonPageContentNode();
//Get the child folder node - Configuration Folder
var configFolder = settingsNode.Children.SingleOrDefault(x => x.DocumentTypeAlias == Constants.DocTypes.SiteConfigurationFolder);
if (configFolder == null) { return null; }
public IPublishedContent GetGlobalContentNode()
{
return (IPublishedContent)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem("Application.BusinessLogic.Services.GetGlobalContentNode", () => {
var settingsNode = GetNonPageContentNode();
//Get the child folder node - Configuration Folder
var configFolder = settingsNode.Children.SingleOrDefault(x => x.DocumentTypeAlias == Constants.DocTypes.SiteConfigurationFolder);
if (configFolder == null) { return null; }