Skip to content

Instantly share code, notes, and snippets.

View anderly's full-sized avatar

Adam Anderly anderly

View GitHub Profile
@anderly
anderly / FrmProEntriesController.php
Created April 9, 2012 21:53
Changed set_cookie() function to use new cookie_expiration option.
/* AJAX */
function set_cookie($entry_id, $form_id){
global $frm_form;
$form = $frm_form->getOne($form_id);
$form->options = stripslashes_deep(maybe_unserialize($form->options));
$expires = time() + 30000000;
if ( $form->options['cookie_expiration'] == 'midnight' ) {
$expires = mktime( 23, 59, 59, date( 'm' ), date( 'd' ), date( 'y' ) );
} elseif ( $form->options['cookie_expiration'] == 'one-day-from-now' ) {
$expires = time() + 60 * 60 * 24 * 1;
@anderly
anderly / DFP Wallpaper Ad
Last active May 28, 2019 05:16
DFP Wallpaper Ad Code
<script>
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
http://assets.dmagazine.com so that it is served via CloudFlare CDN (this makes pages and images load faster) */
@anderly
anderly / DFP Interstitial Ad
Last active March 13, 2017 16:34
DFP Interstitial Ad Code
<script>
var DmagInterstitialAd = DmagInterstitialAd || {};
DmagInterstitialAd.showInterstitial = true;
DmagInterstitialAd.adWidth = 720;
DmagInterstitialAd.adHeight = 480;
DmagInterstitialAd.destinationURL = "http://ad.doubleclick.net/ddm/trackclk/N5716.759086CENTRO.NET/B8239828.110882020;dc_trk_aid=283955045;dc_trk_cid=59150503";
DmagInterstitialAd.embedCode = '<img src="http://ad.doubleclick.net/ddm/trackimp/N5716.759086CENTRO.NET/B8239828.110882020;dc_trk_aid=283955045;dc_trk_cid=59150503;ord=[timestamp]?" border="0" height="1" width="1" alt="Advertisement">';
/*-------------------------------------------------------------------------------------------------------*/
/* DO NOT MODIFY CODE BELOW */
@anderly
anderly / woocommerce-add-custom-product-data-tab.php
Last active June 8, 2023 20:30
WooCommerce - Add Custom Product Data Tab
// 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
anderly / showdown.md
Last active September 17, 2016 19:10
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
anderly / Index.vue
Created March 13, 2019 05:26
Make Index.vue support initializing viaResource, viaResourceId and viaRelationship from query string.
<template>
<loading-view :loading="initialLoading" :dusk="resourceName + '-index-component'">
<custom-index-header v-if="!viaResource" class="mb-3" :resource-name="resourceName" />
<div v-if="shouldShowCards">
<cards
v-if="smallCards.length > 0"
:cards="smallCards"
class="mb-3"
:resource-name="resourceName"
@anderly
anderly / FilterMenu.vue
Last active August 16, 2019 16:17
Make Laravel Nova Per Page options configurable both globally and at resource level.
<template>
<dropdown
v-if="filters.length > 0 || softDeletes || !viaResource"
dusk="filter-selector"
class-whitelist="flatpickr-calendar"
>
<dropdown-trigger
slot-scope="{ toggle }"
:handle-click="toggle"
class="bg-30 px-3 border-2 border-30 rounded"
@anderly
anderly / CacheService.cs
Last active January 27, 2024 20:54
MediatR Caching Pipeline Behavior
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
anderly / Details.cs
Last active December 12, 2019 19:48
MediatR Retry Pipeline Behavior
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
anderly / Details.cs
Last active December 12, 2019 19:52
MediatR Fallback Pipeline Behavior
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;