Skip to content

Instantly share code, notes, and snippets.

View PiotrKrzyzek's full-sized avatar

Peter Krzyzek PiotrKrzyzek

View GitHub Profile
@PiotrKrzyzek
PiotrKrzyzek / tuya_4gang_zha_blueprint.yaml
Last active April 28, 2024 19:22
Home Assistant Blueprint For Tuya 4-gang Zigbee Integration via ZHA
blueprint:
name: ZHA - Tuya 4-Button Scene Switch
description: Automate your Tuya 4-Button Scene Switch via ZHA.
domain: automation
input:
switch:
name: Tuya Zigbee Switch
description: Tuya 4-Button Scene Switch to use
selector:
device:
@PiotrKrzyzek
PiotrKrzyzek / .env
Created April 22, 2023 18:38
ERPNext v13 No Treafik Docker compose.yml
ERPNEXT_VERSION=v13
FRAPPE_VERSION=v13
MARIADB_HOST=mariadb
MYSQL_ROOT_PASSWORD=a_mysql_Passw0rd_CHANGEME
SITE_NAME=my.mywebsite.com
SITES=`my.mywebsite.com`
DB_ROOT_USER=root
ADMIN_PASSWORD=myfancyadminPasswordCHANGEME
INSTALL_APPS=erpnext
SKIP_NGINX_TEMPLATE_GENERATION=0
@PiotrKrzyzek
PiotrKrzyzek / ghost_clean_out_empty_tags.py
Created June 1, 2022 19:29
Ghost CRM: Delete all empty tags (via admin api) Python script
import requests # pip install requests
import jwt # pip install pyjwt
from datetime import datetime as date
# Admin API key goes here
key = 'Full Ghost Admin Key Here'
domain = 'https://your-ghost-domain-here.com/'
# Split the key into ID and SECRET
id, secret = key.split(':')
@PiotrKrzyzek
PiotrKrzyzek / notion2blog.js
Created July 14, 2021 19:01 — forked from mayneyao/notion2blog.js
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@PiotrKrzyzek
PiotrKrzyzek / fluentforms_googleanalytics4_event_track.js
Created July 14, 2021 18:27
Track FluentForm View & Submission Event in Google Analytics 4 with custom data
// Wait for jQuery, using the full name for compatability reasons
jQuery('document').ready(function(){
// This is our main function that will loop
function doFFGa(){
// If google tag manager or analytics is NOT detected
// Then loop this function with a two second delay
// return afterwards just in case
if(typeof gtag != 'function') {
@PiotrKrzyzek
PiotrKrzyzek / cartflows_checkout_select_product_url.js
Created May 7, 2020 20:01
Cartflows tweak: select a product (or variation) on a cartflows checkout page by passing in a URL parameter (GET)
// Setting up and splitting up the parameters passed to this url
var QueryString = (function (paramsArr) {
let params = {};
for (let i = 0; i < paramsArr.length; i++) {
let param = paramsArr[i].split("=", 2);
if (param.length !== 2) continue;
params[param[0]] = decodeURIComponent(param[1].replace(/\+/g, " "));
}
return params;
})(window.location.search.substr(1).split("&"));
// for inputData set:
// keys = the array's list of key values (Such as when WooCommerce sends of two arrays for one array of data. Such as "metakeys"
// values = is the array's value list
// of course, you can modify this easy to simply accept one array ... or as many as you'd like.
// Currently, this code does NOT do any error checking (other than exists()) nor sanitization
output = {
'the_output_field_label_here': '',
}
@PiotrKrzyzek
PiotrKrzyzek / wordpress_list_categories_and_children_shortcode.php
Created January 27, 2020 14:32
WordPress shortcode for getting a list of categories (and the children, non-zero) for the given main category and print it out in a button list (for elementor)
<?php
function list_categories_and_children($atributes)
{
$atts = shortcode_atts(array(
'main' => null
), $atributes);
$cat_id = $atts['main'];
if (isset($atts['main'])) {
@PiotrKrzyzek
PiotrKrzyzek / wp-custom-meta.php
Created December 28, 2019 17:52
Add custom meta properties to the WP headers
function add_meta_tags() {
echo '<meta name="meta_name" content="meta_value" />';
}
add_action('wp_head', 'add_meta_tags');
@PiotrKrzyzek
PiotrKrzyzek / no-special-characters.js
Last active November 11, 2019 16:24
Restrict special characters with javascript / jQuery
<script>
$(document).ready(function() {
$('textarea').bind('keypress', function (event) {
// Allow for regular characters and include these special few:
// comma, period, explanation point, new line
var regex = new RegExp("^[a-zA-Z0-9\r\n\.\,\!\ ]+$");
var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
if (!regex.test(key)) {
event.preventDefault();
return false;