Skip to content

Instantly share code, notes, and snippets.

@Soben
Soben / flyingpig-menu-refresh.js
Last active December 27, 2015 14:39
If the server is still accessible, refresh the page, otherwise, check again in another N seconds. -- Flying Pig Taphouse script for their menu. We didn't want to lose their menu on the screen if the internet went down.
var time_to_wait = 600000; // 10 minutes
/**
* refresh_page ()
*
* Runs an AJAX call to check up on the server before refreshing the page.
*/
function refresh_page () {
// Let's make the AJAX call to check to see if the server is still available.
$.ajax({
@Soben
Soben / .gitignore
Last active February 16, 2016 15:46
Ignore list for Git repos involving Wordpress. Ignores the entire Wordpress Core and any non-custom plugins (must add non-custom plugins to the list as part of ongoing development)Ignores the Uploads folder as well.
.DS_Store
.sass-cache
node_modules
wp-content/plugins/*
!wp-content/plugins/index.php
wp-content/themes/*
!wp-content/themes/index.php
class MiniCartHandler
constructor : (@jQuery, @popupElement, @navElement) ->
@cartCount = @popupElement.data('itemcount')
@cartLimit = @popupElement.data('itemlimit')
@cartLimit ?= 5
@cartDisplay = @popupElement.find('.cart-items')
@navElement.on 'click', @popupOnClick
@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
@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;
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 / 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 ./*
@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 / 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)

{
"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,