Skip to content

Instantly share code, notes, and snippets.

@jvanja
jvanja / filters.php
Created June 22, 2023 09:24 — forked from dkjensen/filters.php
WordPress Gutenberg Query Loop View More AJAX
<?php
/**
* Add data attributes to the query block to describe the block query.
*
* @param string $block_content Default query content.
* @param array $block Parsed block.
* @return string
*/
function query_render_block( $block_content, $block ) {
if ( 'core/query' === $block['blockName'] ) {
@jvanja
jvanja / mp4_to_webm.sh
Created February 18, 2018 11:55
Convert all MP4s in current directory to WEBM using FFMPEG
#!/bin/bash
find "$PWD" -name '*.mp4' -exec sh -c 'ffmpeg -i "$0" -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis "${0%%.mp4}.webm"' {} \;
exit;
0x944A6120ce6D69F351149020c230F466C45eE427
@jvanja
jvanja / functions.php
Created March 13, 2017 08:54 — forked from martynchamberlin/functions.php
How to get_the_content() with formatting
<?php
/**
* Instead of calling get_the_content(), call this function instead, and it'll all be good
*/
function get_the_content_with_formatting()
{
ob_start();
the_content();
$the_content = ob_get_contents();
@jvanja
jvanja / largest_20.sh
Created December 14, 2016 09:50
List the 20 largest files or folders under the current directory
du -ma | sort -nr | head -n 20
@jvanja
jvanja / list_process_using__port.sh
Created June 23, 2016 09:40
List processes using the port
lsof -n -i4TCP:[PORT_NUMBER]
@jvanja
jvanja / pngquant_on_all.sh
Created June 23, 2016 08:52
Execute pngquant on all PNGs in subfolders and overwrite original files.
pngquant -f --ext .png **/*.png
@jvanja
jvanja / find_all_pngs_in_images_folders_and_exec-pngquant.sh
Last active September 17, 2021 14:41
Finds all pngs in "*/images" folders and executes pngquant on them overwriting the original files.
find ./ -path '*/images/*.png' -type f -exec pngquant -f --ext .png {} \;
@jvanja
jvanja / awk_examples.sh
Created January 12, 2016 09:28
Useful awk examples
#searches for 'search_term' and prints all columns
awk '/search_term/' file.txt
#searches for 'search_term' and prints columns 1 and 4 separated with tab (the first column is index 1)
awk '/search_term/ {print $1 "\t" $4}' file.txt
#searches for 'search_term' and prints the number of occurances
awk '/search_term/{++cnt} END {print "Count = ", cnt}' file.txt
#print lines having more than 18 characters
@jvanja
jvanja / Rename All.sh
Created November 2, 2015 16:16
Find all files of type of HTML and change their names to index.html
find . -name "*.html" -exec bash -c 'cp "{}" "$(dirname "{}")"/index.html' \;