Skip to content

Instantly share code, notes, and snippets.

@chrono-meter
chrono-meter / Apache reverse proxy via Putty port forward.md
Last active May 3, 2024 22:52
Apache reverse proxy via Putty port forward.

⚠️ Fix weak security before expose.

Add apache setting.

HOST="your-host.example.com"; FORWARD_URL="http://127.0.0.1:10080/"
sudo tee -a /etc/apache2/sites-enabled/$HOST.conf <<EOT
<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass / $FORWARD_URL
 ProxyPassReverse / $FORWARD_URL
@chrono-meter
chrono-meter / install-sevpn-service.sh
Last active February 26, 2024 23:38
Install SoftEther VPN Server as systemd service.
sudo tee /lib/systemd/system/vpnserver.service << END
[Unit]
Description=SoftEther VPN Server
After=network.target
[Service]
Type=forking
Environment="TAP=tap_vpn"
Environment="BR=br0"
ExecStartPre=ip tuntap add \$TAP mode tap
ExecStartPre=ip link set \$TAP up
@chrono-meter
chrono-meter / wp-spoofing-hostport.php
Created October 26, 2023 00:39
Spoofing host and port for WordPress environment
<?php
/**
* Spoofing host and port for WordPress environment.
* To use this, include from your "wp-config.php" file.
* Note that this functions is not intended to be used in production.
*
* @see \is_ssl()
* @link https://ngrok.com/docs/using-ngrok-with/wordpress/
*/
@chrono-meter
chrono-meter / wp-elfinder-googledrive.php
Last active November 27, 2020 19:03
Sample: Call elFinder from WordPress plugin.
<?php
/**
* Class GdriveFolderViewer
*
* @see https://github.com/nao-pon/flysystem-google-drive#usage-to-with-elfinder
* composer require nao-pon/elfinder-flysystem-driver-ext nao-pon/flysystem-google-drive:~1.1
*
*/
class GdriveFolderViewer {
@chrono-meter
chrono-meter / wc-builtin-shortcode-stock-filter.php
Created July 26, 2020 00:48
WooCommerce: Add stock filter function to builtin shortcodes.
<?php
/**
* Description: WooCommerce: Add stock filter function to builtin shortcodes.
* Author: chrono-meter@gmx.net
* Version: v20200727
*
* @link https://docs.woocommerce.com/document/woocommerce-shortcodes/
*
* Example:
* [products stock="instock"]
<?php
/**
* CMB2 delete value instead of saving empty value. So fields with default value cannot hold empty value.
* This example works around this issue by adding new field parameter `initial value'.
*
* Example:
* $cmb->add_field( array(
* 'name' => 'Title for publish',
* 'initial_value' => '%d product(s) published',
@chrono-meter
chrono-meter / cmb2-option-example.php
Last active December 22, 2021 21:02
CMB2 option example
<?php
/**
* Plugin Name: CMB2 option test
* Author: chrono-meter@gmx.net
* Version: 20211223
*
* @link https://github.com/CMB2/CMB2-Snippet-Library/search?q=object_types&unscoped_q=object_types
* @see add_menu_page()
*
* to get variables: cmb2_get_option('myprefix_network_options', 'key', 'default')
@chrono-meter
chrono-meter / wp-meta-thumbnail.php
Created June 16, 2019 18:16
WordPress | Thumbnail images in search results
<?php
/**
* Thumbnail images in search results
*
* @see https://support.google.com/customsearch/answer/1626955
*/
add_action( 'wp_head', function() {
if ( is_single() && '' !== ($thumbnail_id = get_post_thumbnail_id()) && false !== ($image = wp_get_attachment_image_src( $thumbnail_id ))) {
echo "<meta name=\"thumbnail\" content=\"{$image[0]}\">";
@chrono-meter
chrono-meter / wc-fix-pa-creation.php
Created February 5, 2019 09:45
FIX: WooCommerce doesn't support attribute taxonomy creation on non startup.
<?php
/**
* @wordpress-plugin
* Plugin Name: FIX: WooCommerce doesn't support attribute taxonomy creation on non startup.
* Depends: WooCommerce
* Plugin URI:
* Description:
* Version: 1.0.0
* Author: chrono-meter@gmx.net
* Author URI: mailto:chrono-meter@gmx.net
@chrono-meter
chrono-meter / wc-fix-pa-rewrite-slug.php
Last active February 5, 2019 09:36
FIX: WooCommerce generates non appropriate rewrite slug for product attributes with non latin language slug.
<?php
/**
* @wordpress-plugin
* Plugin Name: FIX: WooCommerce generates non appropriate rewrite slug for product attributes with CJK language slug.
* Depends: WooCommerce
* Plugin URI:
* Description:
* Version: 1.0.0
* Author: chrono-meter@gmx.net
* Author URI: mailto:chrono-meter@gmx.net