Skip to content

Instantly share code, notes, and snippets.

@cfxd
cfxd / httpdfwd.plist
Created November 28, 2021 02:57
httpdfwd.plist for M1 MacBook Pro LEMP stack
<?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 November 28, 2021 01:35
nginx.conf file for LEMP stack on MacBook Pro M1
#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 November 21, 2021 17:11
How to hide Toptal LinkedIn jobs spam. Open your Chrome Dev Tools console and copy/paste this 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();
}
});
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 August 11, 2021 19:54
Rakuten code for WooCommerce using WordPress actions & hooks
<?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);
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;
@cfxd
cfxd / sortby-es6.js
Last active October 18, 2020 13:57
Add a sort by dropdown in Shopify (the right way). See https://cfxdesign.com/add-a-sort-by-dropdown-in-shopify-the-right-way
// 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 February 15, 2019 12:46 — 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.
<?php
/**
* Custom class for WP_Membership routines.
*
*
* @package WP_Membership
* @since WP_Membership 0.1
*/
if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
@cfxd
cfxd / _quickview.scss.liquid
Created August 12, 2018 14:55 — forked from kellyvaughn/_quickview.scss.liquid
Shopify Quick View
#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;
// 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