Skip to content

Instantly share code, notes, and snippets.

View szepeviktor's full-sized avatar
🍓
Doing byte-level care

Viktor Szépe szepeviktor

🍓
Doing byte-level care
View GitHub Profile
@szepeviktor
szepeviktor / class-wc-order-factory.php
Created March 12, 2024 12:07
WooCommerce order types
<?php
switch ( $item_type ) {
case 'line_item':
case 'product':
$classname = 'WC_Order_Item_Product';
break;
case 'coupon':
$classname = 'WC_Order_Item_Coupon';
break;
@szepeviktor
szepeviktor / index.php
Last active March 7, 2024 18:09
Installing WordPress core in a subdirectory
<?php
/** Tell WordPress to load the WordPress theme and output it. */
define('WP_USE_THEMES', true);
/** Load the WordPress Environment and Template. */
require __DIR__ . '/project/wp-blog-header.php';
@szepeviktor
szepeviktor / jq-dot.sh
Created December 4, 2023 01:48
jq dot notation
jq -r 'paths(scalars) as $p | ($p | join(".")) + " = " + (getpath($p)|tostring)'
@szepeviktor
szepeviktor / indent-detector.php
Last active November 26, 2023 20:39
indent detector
#!/usr/bin/env php
<?php
declare(strict_types=1);
const INDENT_CHAR = ' ';
const INDENT_SIZE = 4;
const END_OF_LINE = "\n";
function exitWith(int $exitStatus, string $message): void
@szepeviktor
szepeviktor / artikulus.php
Last active November 4, 2023 22:58
Határozott névelő hozzáadása egy szóhoz PHP-ban
<?php
namespace Grammar\Hungarian;
class DefiniteArticle
{
const CONSONANTS = [
'0',
'2',
'3',
@szepeviktor
szepeviktor / unicode-sort.sh
Last active October 31, 2023 13:20
Sort characters by their UNICODE codepoint
#!/bin/bash
# File with a string of UTF-8 characters
FILE="$1"
paste <(cat "${FILE}" | iconv -f UTF-8 -t UNICODE | hexdump -s 2 -e '1/2 "U+%04X\n"') <(grep -o '.' "${FILE}") \
| sort
@szepeviktor
szepeviktor / laravel-queue-cli.sh
Last active November 3, 2023 10:59
CLI tool to list Laravel queue jobs and failed jobs
#!/bin/bash
REDIS_DB="0"
QUEUE_REDIS_KEY="app_name_database_queues:default:delayed"
DB_NAME="sql_db_name"
redis()
{
redis-cli -n "${REDIS_DB}" --raw "$@"
}
document.querySelector("#container video.html5-main-video").onwaiting = (event) => {
var to;
var cnt = 0;
var ov = event.target.volume;
if (document.querySelector("#movie_player.ad-created") === null) {
return;
}
to = setTimeout(() => {
@szepeviktor
szepeviktor / standard-deviation.php
Created October 24, 2023 03:03
Calculate standard deviation
<?php
/**
* Calculate standard deviation
*
* Square root of sum of squares divided by N-1
*
* @param list<float> $values
*/
function sd(array $values): float
@szepeviktor
szepeviktor / remove-block-library.php
Created August 5, 2023 10:05
Remove WordPress block-library CSS
<link
rel='stylesheet'
id='wp-block-library-css'
href='https://example.com/wp-includes/css/dist/block-library/style.min.css'
media='all'
>
<?php
// Unconditional inclusion in core
function wp_common_block_scripts_and_styles()