Skip to content

Instantly share code, notes, and snippets.

@ghhv
ghhv / wc-optional-redirect-to-checkout.php
Created June 30, 2024 08:19 — forked from helgatheviking/wc-optional-redirect-to-checkout.php
Woo Redirect Certain Products to Checkout- How to skip cart page on woocomerce for certain products only?
<?php
/**
* Plugin Name: WC Redirect to checkout
* Plugin URI: http://stackoverflow.com/q/32962653/383847
* Description: Redirect to checkout for certain products
* Version: 1.0.1
* Author: Kathy Darling
* Author URI: http://kathyisawesome.com
* Requires at least: 3.8
* Tested up to: 3.9
@ghhv
ghhv / jp_add_ics_to_woocommerce_emails.php
Created June 13, 2024 04:18 — forked from jessepearson/jp_add_ics_to_woocommerce_emails.php
This function/filter will add ics files from bookings created with WooCommerce Bookings to the Processing and Completed emails sent from WooCommerce itself.
<?php // do not copy this line
/**
* This function/filter will add ics files from bookings created with WooCommerce Bookings to
* the Processing and Completed emails sent from WooCommerce itself.
* @param arr $attachments Current array of attachments being filtered.
* @param str $email_id The id of the email being sent.
* @param obj $order The order for which the email is being sent.
* @return arr The filtered list of attachments.
*/
@ghhv
ghhv / addressFinder-GravityForms-script.js
Last active June 14, 2022 05:04
Sample Script to use AddressFinder to fill Gravity Forms Advanced Address field individual address fields - address 1, city, state, postcode
// see original doco here - https://github.com/AddressFinder/addressfinder-gravity-forms
// change field ids to suit your form fields..
// this not processing the country field...
<script>
(function() {
var widget, initAddressFinder = function() {
widget = new AddressFinder.Widget(
document.getElementById('input_1_3_1'),
'YOUR_KEY',
@ghhv
ghhv / 1.ExceptionExtensions.cs
Created April 27, 2022 11:22 — forked from Zodt/1.ExceptionExtensions.cs
MediatR exceptions handling
public static class ExceptionExtensions
{
public static List<Exception> FlattenInnerExceptions(this Exception exception)
{
return exception
.DepthFirstSearchInnerExceptions()
.Distinct()
.Reverse()
.ToList();
}
@ghhv
ghhv / Oqtane.Server\Migrations\Tenant\03000201_UpdateSettingIsPublic.cs
Created March 3, 2022 02:24
Fix 2 for Oqtane V3.0.3 bug with non MS SQL databases
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Oqtane.Databases.Interfaces;
using Oqtane.Migrations.EntityBuilders;
using Oqtane.Repository;
using Oqtane.Shared;
namespace Oqtane.Migrations.Tenant
{
[DbContext(typeof(TenantDBContext))]
@ghhv
ghhv / Oqtane.Server\Migrations\Tenant\03000202_UpdateSettingIsPrivate.cs
Created March 3, 2022 02:22
Fix 1 for Oqtane V3.0.3 bug with non MS SQL databases
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Oqtane.Databases.Interfaces;
using Oqtane.Migrations.EntityBuilders;
using Oqtane.Repository;
using Oqtane.Shared;
namespace Oqtane.Migrations.Tenant
{
[DbContext(typeof(TenantDBContext))]
@ghhv
ghhv / AuthyToOtherAuthenticator.md
Created February 15, 2022 02:41 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy

Generating Authy passwords on other authenticators


There is an increasing count of applications which use Authy for two-factor authentication. However many users who aren't using Authy, have their own authenticator setup up already and do not wish to use two applications for generating passwords.

Since I use 1Password for all of my password storing/generating needs, I was looking for a solution to use Authy passwords on that. I couldn't find any completely working solutions, however I stumbled upon a gist by Brian Hartvigsen. His post had a neat code with it to generate QR codes for you to use on your favorite authenticator.

His method is to extract the secret keys using Authy's Google Chrome app via Developer Tools. If this was not possible, I guess people would be reverse engineering the Android app or something like that. But when I tried that code, nothing appeared on the screen. My guess is that Brian used the

/* keep a reference to original toISOString to use it into new method */
const oldToISOString = Date.prototype.toISOString
/* Define new method */
const toISOString = function toISOString(date) {
if(!date) return date;
/* extract GTM timezone from date.toString() */
const regex = /(?:GMT)([-+]\d*)/gm;
let gtm = regex.exec(date.toString())[1];
gtm = [...gtm];
/* insert ':' in time -0500 -> -05:00*/
@ghhv
ghhv / traefik_portainer.md
Created March 21, 2020 09:14 — forked from ruanbekker/traefik_portainer.md
Traefik with SSL + Portainer on Docker Swarm Repro

Traefik and Portainer on Docker Swarm with Letsencrypt

Reproducing a Traefik with SSL and Portainer setup on a 2 Node Docker Swarm

Install Docker:

Install Docker on both nodes with a Bootstrap Script:

$ curl https://gitlab.com/rbekker87/scripts/raw/master/setup-docker-ubuntu.sh | bash