Skip to content

Instantly share code, notes, and snippets.

View mattbrailsford's full-sized avatar

Matt Brailsford mattbrailsford

View GitHub Profile
@mattbrailsford
mattbrailsford / Example.cs
Last active April 24, 2019 11:09
MethodStatus.cs
public void Delete(IMyEntity myEntity, out MethodStatus status)
{
var eventArgs = new MyEventArgs<IMyEntity>(myEntity);
if (myEntity.CanDelete()) // Some arbitrary check before deleting
{
status = MethodStatus.Error("Entity can't be deleted");
return;
}
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; }
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)
{
@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";
}
namespace MyNamespace
{
[ComposeAfter(typeof(TeaCommerceComposer))]
public class MyComposer : IUserComposer
{
public void Compose(Composition composition)
{
composition.WithOrderCheckoutPipeline()
.InsertBefore<CalculateShippingTask, MyPipelineTask>()
.Append<MyOtherPipelineTask>();
...
try:
while True:
blynk.run()
except KeyboardInterrupt:
pass
@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);
@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 / .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: