Skip to content

Instantly share code, notes, and snippets.

@ryanpcmcquen
ryanpcmcquen / darkify_slack.sh
Last active February 23, 2023 16:08
Darkify your Slack.
#!/bin/sh
# Darkify Slack on Mac OS or Linux.
# curl https://gist.githubusercontent.com/ryanpcmcquen/8a7ddc72460eca0dc1f2dc389674dde1/raw/darkify_slack.sh | sh
if [ "`uname -s`" = "Darwin" ]; then
SLACK_INTEROP_JS="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/dist/ssb-interop.bundle.js"
else
SLACK_INTEROP_JS="/usr/lib/slack/resources/app.asar.unpacked/dist/ssb-interop.bundle.js"
fi
@lots0logs
lots0logs / child-theme-functions-php-snippet.php
Last active July 6, 2017 09:21
WordPress :: Divi Builder :: Fullwidth Portfolio Module :: Custom Links
<?php
/* DON'T copy the first line (above) if your functions.php already has it.
* ---------------------------------------------------------------------- */
function my_et_theme_setup() {
if ( class_exists( 'ET_Builder_Module_Fullwidth_Portfolio' ) && file_exists( 'my-main-modules.php' ) ) {
get_template_part( 'my-main-modules' );
$et_pb_fullwidth_portfolio = new My_ET_Builder_Module_Fullwidth_Portfolio();
remove_shortcode('et_pb_fullwidth_portfolio');
add_shortcode('et_pb_fullwidth_portfolio', array( $et_pb_fullwidth_portfolio, '_shortcode_callback' ) );
@lots0logs
lots0logs / functions.php
Last active May 14, 2019 08:40
WordPress :: Divi Builder :: Filterable Portfolio Module :: Show Lightbox On-Click
<?php
/* DON'T copy the first line (above) if your functions.php already has it.
* ---------------------------------------------------------------------- */
function my_et_theme_setup() {
if ( class_exists( 'ET_Builder_Module_Filterable_Portfolio' ) ) {
get_template_part( 'my-main-modules' );
$et_pb_filterable_portfolio = new My_ET_Builder_Module_Filterable_Portfolio();
remove_shortcode('et_pb_filterable_portfolio');
add_shortcode('et_pb_filterable_portfolio', array( $et_pb_filterable_portfolio, '_shortcode_callback' ) );
@ghalusa
ghalusa / youtube_id_regex.php
Created June 20, 2015 23:14
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@pietromalerba
pietromalerba / woocommerce-my-account.php
Last active July 13, 2022 18:34 — forked from SiR-DanieL/functions.php
Add custom fields to Woocommerce My Account
// Add VAT and SSN fields in billing address display
add_filter( 'woocommerce_order_formatted_billing_address', 'custom_add_vat_ssn_formatted_billing_address', 10, 2 );
function custom_add_vat_ssn_formatted_billing_address( $fields, $order ) {
$fields['vat'] = $order->billing_vat;
$fields['ssn'] = $order->billing_ssn;
return $fields;
}
add_filter( 'woocommerce_my_account_my_address_formatted_address', 'custom_my_account_my_address_formatted_address', 10, 3 );
@c-kick
c-kick / hnl.taphover.js
Last active January 19, 2021 23:00
jQuery - Mouse hover on touch devices
//26-5-2020 update: possibly shorter, and better, since 'click' now fires on a tap, and is not prevented by the previous script.
//Also: more concatenation.
$(document).on('touchstart, click', 'a.taphover', function (e) {
if (!$(this).hasClass('hover')) { e.preventDefault(); }
$('.taphover').not($(this).toggleClass('hover')).removeClass('hover');
});
//the previous version:
//taphover - a solution to the lack of hover on touch devices.
@HoundstoothSTL
HoundstoothSTL / anchor-scroll-with-offset.js
Created May 3, 2013 15:43
Anchor scroll with fixed header offset
(function($) {
$('a[href*=#]:not([href=#])').click(function()
{
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname)
{
var target = $(this.hash),
headerHeight = $(".primary-header").height() + 5; // Get fixed header height
@gregrickaby
gregrickaby / functions.php
Created June 7, 2012 13:48
Allow HTML in WordPress Custom Menu Descriptions
/**
* Create HTML list of nav menu items and allow HTML tags.
* Replacement for the native menu Walker, echoing the description.
* This is the ONLY known way to display the Description field.
*
* @see http://wordpress.stackexchange.com/questions/51609/
*
*/
class Description_Walker extends Walker_Nav_Menu {
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@mikejolley
mikejolley / gist:2044109
Last active April 10, 2024 13:17 — forked from jameskoster/header.php
WooCommerce - Update number of items in cart and total after Ajax
<?php
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php)
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' );
function woocommerce_header_add_to_cart_fragment( $fragments ) {
ob_start();
?>
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
<?php