Skip to content

Instantly share code, notes, and snippets.


Adam Anderly anderly

View GitHub Profile
anderly / Startup.cs
Last active Jun 14, 2022
MediatR Pipeline Behavior Registration.
View Startup.cs
// Register MediatR Pipeline Behaviors
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(CachingBehavior<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(FallbackBehavior<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(RetryBehavior<,>));
// ICachePolicy discovery and registration
services.Scan(scan => scan
anderly / Details.cs
Last active Dec 12, 2019
MediatR Fallback Pipeline Behavior
View Details.cs
public class Handler : IRequestHandler<Query, Customer>, IFallbackHandler<Query, Customer>
private readonly ICustomerRepository _db;
private readonly ICustomerRepository<SourceSystem.Secondary> _db2;
private readonly IConfigurationProvider _configuration;
public Handler(ICustomerRepository db, ICustomerRepository<SourceSystem.Secondary> db2, IConfigurationProvider configuration)
_db = db;
_db2 = db2;
anderly / Details.cs
Last active Dec 12, 2019
MediatR Retry Pipeline Behavior
View Details.cs
public class Handler : IRequestHandler<Query, Customer>, IRetryableRequest<Query, Customer>
private readonly CustomerContext _db;
private readonly IConfigurationProvider _configuration;
// By implementing IRetryableRequest<TRequest, TResponse> I get the following
// properties to control how my "Handle" method will get retried.
public int RetryAttempts => 2;
public int RetryDelay => 500;
public bool RetryWithExponentialBackoff => true;
anderly / CacheService.cs
Last active Jun 15, 2022
MediatR Caching Pipeline Behavior
View CacheService.cs
public class CacheService : ICache
private readonly string _keyPrefix;
private readonly IDistributedCache _cache;
private readonly IConfiguration _config;
public CacheService(IDistributedCache cache, IConfiguration config)
_cache = cache;
_config = config;
anderly / FilterMenu.vue
Last active Aug 16, 2019
Make Laravel Nova Per Page options configurable both globally and at resource level.
View FilterMenu.vue
v-if="filters.length > 0 || softDeletes || !viaResource"
slot-scope="{ toggle }"
class="bg-30 px-3 border-2 border-30 rounded"
anderly / Index.vue
Created Mar 13, 2019
Make Index.vue support initializing viaResource, viaResourceId and viaRelationship from query string.
View Index.vue
<loading-view :loading="initialLoading" :dusk="resourceName + '-index-component'">
<custom-index-header v-if="!viaResource" class="mb-3" :resource-name="resourceName" />
<div v-if="shouldShowCards">
v-if="smallCards.length > 0"
anderly /
Last active Sep 17, 2016
Ideas for making ShowDown extensible

Ideas for making ShowDown extensible:

I recently had to customize your plugin a bit for a client but wanted to suggest a few hooks and filters that could be added to the plugin to create some extensibility points for your customers.

Here are the hooks I added which would be great if you could add them into the main plugin so I could still get updates without having to do diffs when the plugin gets updated.

1st set of changes: Adding hooks to Anti-Cheat settings

File: wpshowdown.php
anderly / woocommerce-add-custom-product-data-tab.php
Last active Mar 7, 2022
WooCommerce - Add Custom Product Data Tab
View woocommerce-add-custom-product-data-tab.php
// First Register the Tab by hooking into the 'woocommerce_product_data_tabs' filter
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' );
function add_my_custom_product_data_tab( $product_data_tabs ) {
$product_data_tabs['my-custom-tab'] = array(
'label' => __( 'My Custom Tab', 'my_text_domain' ),
'target' => 'my_custom_product_data',
return $product_data_tabs;
anderly / DFP Interstitial Ad
Last active Mar 13, 2017
DFP Interstitial Ad Code
View DFP Interstitial Ad
var DmagInterstitialAd = DmagInterstitialAd || {};
DmagInterstitialAd.showInterstitial = true;
DmagInterstitialAd.adWidth = 720;
DmagInterstitialAd.adHeight = 480;
DmagInterstitialAd.destinationURL = ";dc_trk_aid=283955045;dc_trk_cid=59150503";
DmagInterstitialAd.embedCode = '<img src=";dc_trk_aid=283955045;dc_trk_cid=59150503;ord=[timestamp]?" border="0" height="1" width="1" alt="Advertisement">';
anderly / DFP Wallpaper Ad
Last active May 28, 2019
DFP Wallpaper Ad Code
View DFP Wallpaper Ad
var WallpaperAd = WallpaperAd || {};
/* Two values are needed for Wallpaper Ads: */
/* 1.) destinationURL (where you want visitors to go when they click the wallpaper) */
/* - NOTE: Click-throughs to this URL will automatically be tracked in DFP */
/* 2.) backgroundURL (URL of wallpaper background image) */
/* - NOTE: Make sure to change the URL to start with so that it is served via CloudFlare CDN (this makes pages and images load faster) */