Skip to content

Instantly share code, notes, and snippets.

@chrono-meter
chrono-meter / webpack.config.js
Created November 22, 2024 13:51
How to use `@wordpress/react-i18n`.
/**
* Even though some module is not included in WordPress core, `wp-scripts` treats it as an external module.
*
* The following code will cause an error like: `Uncaught TypeError: Cannot read properties of undefined (reading 'I18nProvider')`.
* ```js
* import { I18nProvider } from '@wordpress/react-i18n';
* ```
*/
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');
@chrono-meter
chrono-meter / wp-customize-classiceditor.php
Created August 3, 2024 02:30
WordPress Classic Editor (wp-admin/edit-form-advanced.php) customization.
<?php
const POST_TYPE_NAME = 'YOUR_TYPE';
/**
* Use Classic Editor for this post type.
*/
add_filter( 'use_block_editor_for_post_type', fn( $result, $post_type_name ) => POST_TYPE_NAME === $post_type_name ? false : $result, 10, 2 );
@chrono-meter
chrono-meter / README.md
Created June 24, 2024 12:47
WordPress React components for plugin pages without node `id`.

Remove html id and pass arguments to React components.

See original version for more information.

@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 / common_prefix.py
Created January 26, 2017 07:01
Python: Common prefix of pathlib.Path
import collections
import pathlib
def common_prefix(*paths):
"""Common prefix of given paths"""
counter = collections.Counter()
for path in paths:
assert isinstance(path, pathlib.Path)
counter.update([path])
@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 / openssl-enc-compat.py
Created November 26, 2016 03:00
OpenSSL enc compatible script by Python.
#!python3
"""OpenSSL enc compatible script by Python.
"""
import sys
import os
import io
import hashlib
import binascii
import argparse
import logging
@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')
#!/usr/bin/env python3
from xml.etree import ElementTree
from pathlib import Path
import io
import datetime
import email.utils
__author__ = 'chrono-meter@gmx.net'
__version__ = '1.0.0'
__license__ = 'Python Software Foundation License'