Skip to content

Instantly share code, notes, and snippets.

View schakko's full-sized avatar

Schakko schakko

View GitHub Profile
@schakko
schakko / glibberish-aes-256-cbc-decrypt.js
Created May 7, 2012 16:11
Using AES-256-CBC with OpenSSL, node.js and PHP
// Doing AES-256-CBC (salted) decryption with node.js.
// This code is based on http://php.net/manual/de/function.openssl-decrypt.php and works with PHP sqAES.
//
// Create your encrypted data with
// echo -n 'Hello world' | openssl aes-256-cbc -a -e
var crypto = require('crypto');
var password = 'password';
var edata = 'U2FsdGVkX18M7K+pELP06c4d5gz7kLM1CcqJBbubW/Q=';
@schakko
schakko / nginx.conf
Last active January 17, 2024 08:06
Adjusted nginx.conf to make Laravel 9 and Laravel 10 apps with PHP 8.0, 8.1 and 8.2 features runnable on Azure App Service
server {
# adjusted nginx.conf to make Laravel 9 and Laravel 10 apps with PHP 8.0, 8.1 and 8.2 features runnable on Azure App Service
# @see https://laravel.com/docs/10.x/deployment
# @see https://laravel.com/docs/9.x/deployment
listen 8080;
listen [::]:8080;
root /home/site/wwwroot/public;
index index.php;
server_name example.com www.example.com;
@schakko
schakko / fix-woocommerce-germanized-invoices.md
Last active November 17, 2023 09:05
Fix WooCommerce Germanized invoices due to changes or inconsistent order data

When using WooCommerce Germanized you might end up with processed orders but the invoices can not be generated. Clicking onto the Create invoice button throws the following error:

An invoice could not be created due to changes to or inconsistent order data. Please review the corresponding order.

For debugging purposes, you can look into wp-content/plugins/woocommerce-germanized-pro/packages/storeabill/src/WooCommerce/Order.php. Somewhere in protected function get_order_items_to_cancel( $args = array() ) WooCommerce Germanized detects a pricing difference. This is most likely to a mismatch between the data provided during the payment and the current point in time.

WooCommerce Germanize does the following:

  • If not present, create a new invoice in the table storeabill_documents
  • Fill up the invoice items in table storeabill_document_items by loading the data from woocommerce_order_items
@schakko
schakko / check_microsoft_windows_software_raid.ps1
Last active January 24, 2023 17:24
A simple PowerShell script for retrieving the RAID status of volumes with help of diskpart. The nicer solution would be using WMI (which does not contain the RAID status in the Status field of Win32_DiskDrive, Win32_LogicalDisk or Win32_Volume for unknown reason) or using the new PowerShell API introduced with Windows 8 (wrong target system as o…
# A simple PowerShell script for retrieving the RAID status of volumes with help of diskpart.
# The nicer solution would be using WMI (which does not contain the RAID status in the Status field of Win32_DiskDrive, Win32_LogicalDisk or Win32_Volume for unknown reason)
# or using the new PowerShell API introduced with Windows 8 (wrong target system as our customer uses a Windows 7 architecture).
#
# diskpart requires administrative privileges so this script must be executed under an administrative account if it is executed standalone.
# check_mk has this privileges and therefore this script must only be copied to your check_mk/plugins directory and you are done.
#
# Christopher Klein <ckl[at]neos-it[dot]de>
# This script is distributed under the GPL v2 license.
@schakko
schakko / pre-receive-hook.enforce-one-change-per-directory.sh
Last active November 9, 2022 08:44
git pre-receive hook for e.g. GitLab or GitHub Enterprise to enforce the one-change-per-directory pattern for GitOps (Argo CD etc) repos.
#!/bin/env bash
#
# git pre-receive hook for e.g. GitLab or GitHub Enterprise to enforce the one-change-per-directory pattern for GitOps (Argo CD etc) repos.
# It checks each of the commits in the received packs for a given path specification ($PATH_SPECIFICATION).
# If a file in another matching path has been modified, the commit is denied.
#
# This script makes heavy use of bash-only features.
#
# Author: Christopher Klein <ckl[dot]dreitier[dot]com>
#
@schakko
schakko / create_azure_container_registry_service_principals.sh
Last active November 9, 2022 08:26
Creates two new service principals for Azure Container Registry for read-write and read-only
#!/bin/env bash
#
# Creates two new service principals for Azure Container Registry:
# a read-only service principal and a read/write service principal.
#
# Author: Christopher Klein <ckl[dot]dreitier[dot]com>
# See: https://dreitier.com/knowledge-base/continuous-delivery-and-deployment/publish-docker-images-to-azure-container-registry-with-github-actions
#
if [ $# -ne 2 ]; then
@schakko
schakko / AuditAllKeyVaultsInTenant.ps1
Created June 23, 2021 09:18
Create an overview with all key vaults in current Azure tenant for auditing reasons
# This has been written to list all permissions to Key Vaults in the current Azure AD tenant.
# It comes in handy if you need to do a scheduled audit e.g. for TISAX compliance reasons.
$vaults = Get-AzKeyVault
foreach ($vault in $vaults) {
$detail = Get-AzKeyVault -VaultName $vault.VaultName;
# Expand all permissions
$FormatEnumerationLimit = 20;
# Get permissions for secrets (certificates etc. not required in our case)
@schakko
schakko / extension_nt_multi_field.php
Last active August 12, 2020 14:45
Fixes various bugs in Techland WordPress theme with WordPress 5.5; meta-box has currently issues and must be disabled
/**
* fix constructor to make it work with custom wp-content path (e.g. when hosting multiple webservers for loadbalancing purposes and using the same NFS share
* goes to wp-content/themes/techland/inc/theme-options/redux-extensions/extensions/nt_multi_field/extension_nt_multi_field.php line ~72
*/
if ( empty( $this->extension_dir ) ) {
$this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) );
$this->extension_url = home_url( '/wp-content/' . str_replace( trailingslashit( str_replace( '\\', '/', WP_CONTENT_DIR ) ), '', $this->extension_dir ) );
}
@schakko
schakko / ad_ldif_to_xml_json.php
Created March 31, 2011 16:02
Converts Active Directory LDIF schema to XML or JSON
<?php
/**
* This hack converts an Active Directory LDIF schema file to XML or JSON.
* Export Active Directory schema with the following command (must be run as Domain Administrator):
* ldifde -f SaveSchema.ldif -d CN=Schema,CN=Configuration,DC=domain,DC=local
* Change var $file to location of generated schema, open your browser, point to this file and append ?xml for XML output or ?json for JSON output
*
* @author Christopher Klein <ckl[at]ecw[dot]de>
* @url http://wap.ecw.de
*/
@schakko
schakko / setup-wordpress-in-wsl.sh
Created March 6, 2019 15:54
WordPress in WSL / Windows Subsystem for Linux
sudo apt-get install apache2 php-fpm php-ldap php-xdebug
sudo a2enmod proxy_fcgi setenvif rewrite
sudo a2enconf php7.3-fpm
sudo service apache2 reload
vim /etc/apache2/apache2.conf
--- snip ---
# AllowOverride all for DocumentRoot
--- snip ---