Skip to content

Instantly share code, notes, and snippets.

@eliasdabbas
eliasdabbas / serp_heatmap.py
Last active February 2, 2024 22:58
Create a heatmap of SERPs, using a table with columns: "keyword", "rank", and "domain"
import plotly.graph_objects as go
import pandas as pd
def serp_heatmap(df, num_domains=10, select_domain=None):
df = df.rename(columns={'domain': 'displayLink',
'searchTerms': 'keyword'})
top_domains = df['displayLink'].value_counts()[:num_domains].index.tolist()
top_domains = df['displayLink'].value_counts()[:num_domains].index.tolist()
top_df = df[df['displayLink'].isin(top_domains) & df['displayLink'].ne('')]
@doole
doole / wine32_macos.org
Last active April 4, 2024 21:16
Use win32 binaries on macOS 10.15/11.0

macOS wine 32/64-bit Setup

Run 32-bit apps on macOS Catalina (10.15) and Big Sur (11.0).

Installation

Dependencies

First install homebrew brew.sh

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@olooney
olooney / pnorm.sql
Created June 13, 2018 23:28
PostgreSQL pnorm() function calculated the c.d.f. of the normal Gaussian distribution. This function match's R's build in pnorm() function to within +/- 2e-7 over the entire real line. However, it's a constant 1/0 above/below z=+7/-7.
CREATE OR REPLACE FUNCTION pnorm(z double precision) RETURNS double precision AS $$
SELECT CASE
WHEN $1 >= 0 THEN 1 - POWER(((((((0.000005383*$1+0.0000488906)*$1+0.0000380036)*$1+0.0032776263)*$1+0.0211410061)*$1+0.049867347)*$1+1),-16)/2
ELSE 1 - pnorm(-$1)
END;
$$ LANGUAGE SQL IMMUTABLE STRICT;
@woogist
woogist / theme-functions.php
Created July 1, 2014 08:28
change the blog section message to the same as the home page blog area message
<?php
/*-----------------------------------------------------------------------------------
TABLE OF CONTENTS
- Exclude categories from displaying on the "Blog" page template.
- Exclude categories from displaying on the homepage.
- Register WP Menus
- Breadcrumb display
@kloon
kloon / functions.php
Last active October 16, 2022 16:46
WooCommerce 2.1 variation price, revert to 2.0 format
/**
* Use WC 2.0 variable price format, now include sale price strikeout
*
* @param string $price
* @param object $product
* @return string
*/
function wc_wc20_variation_price_format( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
@deltafactory
deltafactory / lazy-load-WC_Countries.diff
Last active December 28, 2015 22:29
Lazy load WooCommerce WC_Countries patch - proof of concept.
Index: classes/class-wc-countries.php
===================================================================
--- classes/class-wc-countries.php (revision 799848)
+++ classes/class-wc-countries.php (working copy)
@@ -1,4 +1,30 @@
<?php
+
+class WC_Countries_Loader {
+
+ private $instance;
@wpscholar
wpscholar / redactor-image-upload.php
Last active December 27, 2015 10:09
This script handles WordPress image uploads when uploading files using Redactor.js. It uses the 'SHORTINIT' parameter to prevent loading plugins and unnecessary files. NOTE: Images uploaded using this script are NOT imported into the WordPress media library.
<?php
// Make sure required $_FILES values are set before trying to load WordPress
if ( isset( $_FILES['file'] ) ) {
// We don't need all of WordPress, just the basics
define( 'SHORTINIT', true );
// Load WordPress
require( strstr( dirname( __FILE__ ), 'wp-content', true ) . 'wp-load.php' );
@robneu
robneu / wordpress-seo-keywords-bs.php
Created September 16, 2013 13:40
WordPress SEO without a plugin is complete crap. Let's break it down one function at a time.
<?php
function basic_wp_seo() {
global $page, $paged, $post;
$default_keywords = 'wordpress, plugins, themes, design, dev, development, security, htaccess, apache, php, sql, html, css, jquery, javascript, tutorials'; // customize
$output = '';
// description
$seo_desc = get_post_meta($post->ID, 'mm_seo_desc', true);
$description = get_bloginfo('description', 'display');
$pagedata = get_post($post->ID);
@kloon
kloon / functions.php
Last active September 15, 2022 11:04
WooCommerce Dropdown Product Quantity, fully compatible with Min/Max quantities extension
<?php
// Place the following code in your theme's functions.php file
// override the quantity input with a dropdown
function woocommerce_quantity_input() {
global $product;
$defaults = array(
'input_name' => 'quantity',
'input_value' => '1',
'max_value' => apply_filters( 'woocommerce_quantity_input_max', '', $product ),
@markjaquith
markjaquith / wp-smart-cache.php
Created February 6, 2013 22:59
WordPress Object Cache wrapper I'm working on that has support for group purging.
<?php
if ( !class_exists( 'WP_Smart_Cache_v1' ) ) :
Class WP_Smart_Cache_v1 {
static $instances = array();
public function __construct() {
if ( function_exists( 'wp_cache_add_global_groups' ) )
wp_cache_add_global_groups( array( 'wp_smart_cache_global' ) );
}