Skip to content

Instantly share code, notes, and snippets.

@Soben
Soben / docker-compose.yml
Created January 15, 2020 19:10
Wordpress Docker Configuration
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
<?php
function nyo_truncate_content ( $content ) {
require_once( AMP__DIR__ . '/includes/utils/class-amp-dom-utils.php' );
$elementsRemaining = 2;
$contentDOM = \AMP_DOM_Utils::get_dom_from_content(apply_filters('the_content', $content) ); // Returns a DOMDocument
$contentDOMParsed = clone $contentDOM;
// Strip all elements from the body.
@Soben
Soben / columns.php
Created September 20, 2019 17:20
Special Column Layout
<?php
/*
Purpose of this script is that if the last row is not equal
to the total that we want, we need to update the wrapping
element's classes based on a variety of quantities.
Thanks Tailwind.
*/
$totalCount = 11;
{
"sync.quietSync": false,
"sync.removeExtensions": true,
"sync.syncExtensions": true,
"sync.autoDownload": false,
"sync.autoUpload": false,
"sync.forceDownload": false,
"workbench.startupEditor": "newUntitledFile",
"editor.tabSize": 2,
"explorer.confirmDelete": false,
@Soben
Soben / explanation.md
Created October 2, 2018 21:33
WP CLI search and replace on non-standard characters

We had a client that was seeing special characters on their website in Chrome and Internet Explorer on Windows.

It was an instance of the typical "hey we don't have an available character for this, so show the diamond with a question mark in it or a rectangle"

As this was a Wordpress site, we were able to use the WP CLI to resolve, but this should help others in a similar find/replace direction.

In this case the special character was \03 ... the code that shows up at the end of a copied string (https://cl.ly/8d8b44f8db54)

@Soben
Soben / gist:1baa2127147382f32112b53c1235307f
Created August 16, 2018 17:08
Find biggest consumers of Access Requests
cat {path/to/access/log} | awk '{print $1}' | sort | uniq -c | sort -n | tail
@Soben
Soben / beanstalk-backup.sh
Created June 7, 2018 12:19
Quick Git Backup and Zip
function bsbb {
currentDate=`date +"%Y%m%d"`
if [ "$1" ]; then
printf "${COLOR_YELLOW}Getting repository${COLOR_DEFAULT}\n"
git clone "[email protected]:/TEAMNAME/$1.git" || return 1
printf "${COLOR_YELLOW}Zipping up folder${COLOR_DEFAULT}\n"
zip -qr "$1-$currentDate.zip" "$1/"
if [ $? -eq 1 ]; then
rm -rf ./*
UPDATE wp_term_taxonomy SET count = (
SELECT COUNT(*) FROM wp_term_relationships rel
LEFT JOIN wp_posts po ON (po.ID = rel.object_id)
WHERE
rel.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
AND
wp_term_taxonomy.taxonomy NOT IN ('link_category')
AND
po.post_status IN ('publish', 'future')
)
@Soben
Soben / combo-solver.php
Created November 11, 2017 23:36
Finds combinations of real words for a WordLock (requires pspell)
<?php
class WordGenerator {
private $attemptedWords = [];
private $foundWords = [];
private $totalPermutations = 0;
private $comboLock = [];
private $dictionary = null;
private $totalAttempts = 0;
@Soben
Soben / wp.sh
Created October 25, 2017 16:25
WP-CLI Find/Replace URLs
wp search-replace "oldurl" "newurl" --precise --all-tables --skip-themes --skip-plugins