Skip to content

Instantly share code, notes, and snippets.

@cfxd
cfxd / httpdfwd.plist
Created Nov 28, 2021
httpdfwd.plist for M1 MacBook Pro LEMP stack
View httpdfwd.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>httpdfwd</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
@cfxd
cfxd / nginx.conf
Created Nov 28, 2021
nginx.conf file for LEMP stack on MacBook Pro M1
View nginx.conf
#replace all instances of <YOUR_USERNAME> with your local username
#place this file in /opt/homebrew/etc/nginx (overwrite the existing default file there)
user <YOUR_USERNAME> staff;
worker_processes 1;
error_log /Users/<YOUR_USERNAME>/Sites/nginx.log;
error_log /Users/<YOUR_USERNAME>/Sites/nginx.log notice;
error_log /Users/<YOUR_USERNAME>/Sites/nginx.log info;
error_log /Users/<YOUR_USERNAME>/Sites/nginx.log warn;
@cfxd
cfxd / hide_toptal_linkedin_jobs_spam.js
Created Nov 21, 2021
How to hide Toptal LinkedIn jobs spam. Open your Chrome Dev Tools console and copy/paste this JS.
View hide_toptal_linkedin_jobs_spam.js
document.querySelectorAll('button[aria-label*="Hide"]').forEach(function(el, index) {
if(el.closest('.job-card-list__entity-lockup').querySelector('.job-card-container__company-name').innerHTML.trim() == 'Toptal') {
el.click();
}
});
View gist:98d899d65079b68d60c0f635ee59b324
find
var t=window.location.protocol+"//"+window.location.host+window.location.pathname+"?variant="+e.id;
replace with
var newUrlRegex=/variant=\d*/g;var newUrlExt='?variant='+e.id;if(window.location.search!=''){if(window.location.search.includes('variant=')){newUrlExt=window.location.search.replace(newUrlRegex,'variant='+e.id);}else{newUrlExt=window.location.search+'&variant='+e.id;}}var t=window.location.protocol+"//"+window.location.host+window.location.pathname+newUrlExt;
@cfxd
cfxd / rakuten_for_woocommerce.php
Last active Aug 11, 2021
Rakuten code for WooCommerce using WordPress actions & hooks
View rakuten_for_woocommerce.php
<?php
namespace Roots\Sage\Rakuten;
function assets() {
wp_register_script('sage/rakuten', '//tag.rmp.rakuten.com/124013.ct.js', [], null, false);
wp_enqueue_script('sage/rakuten');
}
add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\assets', 10);
View apple_news_remove_empty_p_tags.php
function apple_news_remove_empty_p_tags($content, $post_id) {
$new_content = preg_replace('/<span[^>]*>[\s\040\t\r\n\W]*<\/span>/', '', $content);
$new_content = preg_replace('/<span[^>]*>&nbsp;*<\/span>/', '', $new_content);
$new_content = preg_replace('/<span[^>]*> <\/span>/', '', $new_content);
$new_content = preg_replace('/<p[^>]*>[\s\040\t\r\n\W]*<\/p>/', '', $new_content);
$new_content = preg_replace('/<p[^>]*>&nbsp;*<\/p>/', '', $new_content);
$new_content = preg_replace('/<p[^>]*> <\/p>/', '', $new_content);
return $new_content;
View sortby-es6.js
// Save existing sort parameters
Shopify.queryParams = {};
if(location.search.length) {
for(var aKeyValue, i = 0, aCouples = location.search.substr(1).split('&'); i < aCouples.length; i++) {
aKeyValue = aCouples[i].split('=');
if (aKeyValue.length > 1) {
Shopify.queryParams[decodeURIComponent(aKeyValue[0])] = decodeURIComponent(aKeyValue[1]);
}
}
}
@cfxd
cfxd / class-membership.php
Created Feb 15, 2019 — forked from wturnerharris/class-membership.php
Class to make things members-only in WordPress.--This class depends on a custom capability called 'is_approved_member' for user member access and the custom post meta key '_members_only' as a post-level custom field.
View class-membership.php
<?php
/**
* Custom class for WP_Membership routines.
*
*
* @package WP_Membership
* @since WP_Membership 0.1
*/
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
View _quickview.scss.liquid
#quick-view {
display: flex;
height: 100%;
justify-content: flex-end;
flex-wrap: wrap;
position: relative;
-ms-overflow-style: -ms-autohiding-scrollbar;
.qv-product-images {
width: 60%;
height: auto;
View gist:1e8b929851bbd1dbe008073997008ad3
// Update PHP version when using AMP setup from https://alanthing.com/blog/2014/12/22/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew/
$ brew install php72 --with-fpm --without-apache --with-homebrew-curl --with-homebrew-openssl --without-snmp