Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / .htaccess
Last active June 15, 2020 09:22
Rewrite rule for .htaccess for rewritting /page/subpage to ?page=page&subpage=subpage
# redirects for url params
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1&subpage=$2
RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1&subpage=$2
# index file priority
DirectoryIndex index.html index.htm index.php welcome.html
@jvanja
jvanja / Drush Cheats
Last active April 2, 2018 08:57
Useful Drush commands
# download stable Drupal
drush dl drupal
# install Drupal site with admin/admin acc
sudo drush site-install standard --account-name=admin --account-pass=admin --db-url=mysql://drupal7:drupal7@localhost/drupal7
# clear drupal cache
drush cc
# download and enable module
@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]