Skip to content

Instantly share code, notes, and snippets.

View uhlhosting's full-sized avatar
🏠
Working from home

Viorel-Cosmin Miron uhlhosting

🏠
Working from home
View GitHub Profile
/**
* Get shipping info by using chosen method from cart
*
* @param string $type
* @return string
*/
function ml_get_shipping_data($type = '') {
$current_shipping_method = WC()->session->get( 'chosen_shipping_methods' );
if( ! is_array($current_shipping_method) ) {
return '';
@luiskabes-arch
luiskabes-arch / encode-email.js
Last active July 27, 2023 12:36
Encode an email on mailto: link
jQuery(document).ready(function ($) {
// Find all anchor tags with href starting with "mailto:"
$('a[href^="mailto:"]').each(function () {
var email = $(this).attr('href').substring(7); // Extract the email address
// Encode the email address for obfuscation
var encodedEmail = '';
for (var i = 0; i < email.length; i++) {
encodedEmail += '&#' + email.charCodeAt(i) + ';';
}
@Mikaayenson
Mikaayenson / sample_chatgpt_security_use_case.py
Last active September 2, 2023 17:29
Sample use case to demonstrate applying the new chatGPT model to security summaries.
import openai
import requests
import textwrap
import uuid
# pip3 install openai requests
# setup the API credentials
es_username = "<your username>"
es_password = "<your password>"
es_url = "https://localhost:9200"
add_action('woocommerce_thankyou_bacs', 'wpd_qr_code', 10, 1 );
function wpd_qr_code( $order_id ) {
$order = wc_get_order( $order_id );
$bacs_info = get_option( 'woocommerce_bacs_accounts');
echo "<div style='display: grid; grid-template-columns: auto auto auto;'>";
foreach ($bacs_info as $info ) {
@mtx-z
mtx-z / .htaccess
Last active February 15, 2023 11:17
Wordpress .htaccess with Header Caching + CSP Content Security Policy + Gzip compression + PHP execution protection + Spam protection (WIP)
#WP block - see https://fr.wordpress.org/support/article/htaccess/
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# ajouter un slash après /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
@yankiara
yankiara / oxygen-pro-menu-mobile-accessibility.js
Last active February 16, 2022 01:54
Oxygen ProMenu mobile accessibility
jQuery(document).ready(function($) {
// Initialize roles and aria attributes
$('.oxy-pro-menu-list .menu-item-has-children > a').attr('aria-haspopup','true').attr('aria-expanded','false');
$('.oxy-pro-menu-list .sub-menu').each(function(){
$(this).attr('aria-label', $(this).prev('a').text());
});
if ( $('.oxy-pro-menu-mobile-open-icon').css('display') == 'none' ) {
@juliocbc
juliocbc / opnsense-ar.sh
Created July 12, 2021 12:45
OPNsense active response script
#!/bin/sh
#Active response script for OPNSense platform (should work with pfSense too)
# should be in <OSSEC_PATH>/active-response/bin/opnsense.sh
#TrustUX Network 20160803 by JCC
#Block the offensor IP in the virusprot table - default in pfSense's/OPNSense's
#ref.: https://doc.pfsense.org/index.php/Virusprot
#Tested on OPNSense 16.7 and pfSense 2.2.x
#VARs
PFCTL_CMD="/sbin/pfctl"
@cyrenity
cyrenity / k8s-using-talos-in-vms.md
Last active April 21, 2024 06:54
Setup kubernetes cluster using Talos (Lab)

Setup Kubernetes cluster in minutes using Talos

1. Get talosctl

Download and install talosctl binary

wget https://github.com/talos-systems/talos/releases/download/v0.8.1/talosctl-linux-amd64
@lucanastasio
lucanastasio / hookscript.pl
Last active August 11, 2023 22:17
Proxmox passthrough saver hook script
#!/usr/bin/perl
# Copyright (c) 2021 Luca Anastasio
# anastasio<dot>lu<at>gmail<dot>com
# Hookscript to avoid taking PCI passed through devices from running VMs
# also attaches them to their placeholders after guests are stopped
# You can set this via qm with
# qm set 100 --hookscript local:snippets/hookscript.pl
use strict;
@morgyface
morgyface / add_the_categories.php
Created November 25, 2020 17:21
WordPress | Add categories programmatically on theme activation
<?php
// Sets the default categories
function add_the_categories() {
$categories = array(
'Case Study',
'Blog',
'Article'
);
foreach( $categories as $category ) {
$exists = term_exists( $category, 'category' );