Skip to content

Instantly share code, notes, and snippets.

View jackbillstrom's full-sized avatar
🇺🇦
slava ukraini 🔱

Jack Billström jackbillstrom

🇺🇦
slava ukraini 🔱
View GitHub Profile
@jackbillstrom
jackbillstrom / ms_backup_docker.sh
Last active October 20, 2023 00:13
Backup databases inside a MS SQL Server docker container. This bashscript is made for interactivity and ease of use while exporting or importing databases running inside a microsoft-mssql-server container
#!/bin/bash
# Author: Jack Billström (jackbillstrom)
# Description: Backup and restore MS SQL databases running in docker containers with a "GUI" using gum.sh
# Dependencies: gum.sh, docker, dialog
# Usage: ./ms_backup_docker.sh
# Version: 1.1.0
# Intro
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "🐋 $(gum style --foreground 212 'ms sql') manager"
@jackbillstrom
jackbillstrom / CustomComposer.cs
Created August 11, 2023 09:20
Custom OrderID for Vendr Orders
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Vendr.Core.Generators;
namespace My.Ecommerce.Web.Compositions;
public class CustomComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
@jackbillstrom
jackbillstrom / backup_ms_sql_database_inside_a_docker_container.sh
Last active May 25, 2023 20:36
Backup multiple MS SQL Databases from a Docker Container on Ubuntu
#!/bin/bash
DATE=$(printf '%(%Y-%m-%d)T\n')
CONTAINER_NAME="mssql"
SA_PASSWORD="PASSWORD"
DB_NAMES=("DB1" "DB1")
HOME_DIR="/home/ubuntu"
backup_database() {
for DB_NAME in "${DB_NAMES[@]}"; do
@jackbillstrom
jackbillstrom / driftstorningslage-fp.markdown
Created March 26, 2021 10:47
Driftstörningsläge - FP
@jackbillstrom
jackbillstrom / 1. wpFormsToDatalyer.js
Created March 1, 2021 09:21 — forked from kmclaugh/1. wpFormsToDatalyer.js
Notifies the datalyer when a wpForm is submitted so Google Tag Manager can detect it
// This code notifies Google Tag Manager when a wpForm is submitted
document.addEventListener("DOMContentLoaded", function() {
var elementsArray = document.querySelectorAll('[id^="wpforms-form-"]');
elementsArray.forEach(function(elem) {
elem.addEventListener("submit", function(e) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "wpFormSubmit",
wpFormElement: event.target
});
@jackbillstrom
jackbillstrom / wc_ajax_add_to_cart.php
Created November 18, 2020 23:08
Woocommerce Ajax Add To Cart Button
<?php
//AJAX ADD TO CART BUTTON
$product_id = 143;
if( !my_custom_cart_contains( $product_id ) ) {
?>
<button class="my-custom-add-to-cart-button" data-product-id="<?php echo $product_id; ?>">add to cart</button>
<?php
} else {
?>
@jackbillstrom
jackbillstrom / single.php
Created October 30, 2020 12:17
WC v4.4.0
<?php
/**
* Simple product add to cart
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
<?php
function my_customize_rest_cors() {
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
add_filter( 'rest_pre_serve_request', function( $value ) {
header( 'Access-Control-Allow-Origin: *' );
header( 'Access-Control-Allow-Methods: GET' );
header( 'Access-Control-Allow-Credentials: true' );
header( 'Access-Control-Expose-Headers: Link', false );
@jackbillstrom
jackbillstrom / command.sh
Last active July 21, 2020 00:21
How to renew a expired Let's Encrypt certificate via certbot
# This command will be generating a TXT-string you'll need to enter into your "_acme-challenge.example.se"
# When the new DNS post is live, you'll want to press ENTER in your shell to complete setup.
# My setup is a Debian machine with Apache as Web Server with virtualhosts.
sudo certbot-auto --server https://acme-v02.api.letsencrypt.org/directory -d "*.example.se" --preferred-challenges dns-01 certonly
<?
// /product-options-for-woocommerce/Model/Option.php
public function saveOptions($productId, $options) {
$productId = (int)$productId;
// Här kommer alla värden samlas upp efter loopen
// tänk på att loopen svarar RAD FÖR RAD
$lens_options = array();