Skip to content

Instantly share code, notes, and snippets.

View oneblackcrayon's full-sized avatar

Frederick Polk oneblackcrayon

View GitHub Profile
@oneblackcrayon
oneblackcrayon / Use JQuery to show and hide elements based on data attributes.md
Last active November 22, 2023 03:40
Use JQuery to show and hide elements based on data attributes.

Use Jquery to show and hide elements with data-attributes

I needed to show and hide a list of posts on a page when clicking on links.

<main role="main">
  <nav role="navigation">
    <a href="javascript.void(0);" data-slug="slug-1">Link 1</a>
    <a href="javascript.void(0);" data-slug="slug-2">Link 2</a>
 <a href="javascript.void(0);" data-slug="slug-3">Link 3</a>
@oneblackcrayon
oneblackcrayon / mu-woo.php
Last active July 5, 2023 01:28
Must Use Plugin for Woocommerce not working
<?php
/*
Plugin Name: MU Woo Snippets
Plugin URI: https://gist.github.com/oneblackcrayon
Description:
Version: 1.0.0
Author: OneBlackCrayon
Author URI: https://gist.github.com/oneblackcrayon
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@oneblackcrayon
oneblackcrayon / rss-email.txt
Created March 26, 2023 04:06 — forked from robincornett/rss-email.txt
MailChimp RSS email template
*|RSSITEMS:|*
<h2 class="mc-toc-title"><a href="*|RSSITEM:URL|*" target="_blank">*|RSSITEM:TITLE|*</a></h2>
*|RSSITEM:CONTENT_FULL|*<br />
<a href="*|RSSITEM:URL|*" target="_blank">Read in browser &raquo;</a><br />
*|RSSITEM:TWITTER|* *|RSSITEM:LIKE|*<br />
<br />
*|END:RSSITEMS|*
@oneblackcrayon
oneblackcrayon / mail.php
Created March 26, 2023 04:06 — forked from Archie22is/mail.php
Filters images for RSS feed (Erik Teichmann)
/**
* Filters images for RSS feed--makes thumbs go through large; large images resize down to MailChimp friendly width.
* Add this to your functions.php file WITHOUT the opening php
*
* Author: Erik Teichmann, minor tweaks by Robin Cornett
* Author URI: http://www.eriktdesign.com/
*/
// Add filters for RSS
add_filter('the_excerpt_rss', 'et_change_thumbs', 20); // changes the excerpt for rss
@oneblackcrayon
oneblackcrayon / coundown.html
Last active February 27, 2023 20:06
Countdown timer with a weekly reset
<!-- @link: https://stackoverflow.com/questions/35587387/javascript-countdown-clock-every-saturday-at-11am#answer-35588057 -->
<div class="has-time">
<div id="clockdiv" class="is-time simply-countdown">
<div class="simply-section">
<span class="days simply-amount"></span>
<div class="smalltext simply-word">Days</div>
</div>
<div class="simply-section">
<span class="hours simply-amount"></span>
<div class="smalltext simply-word">Hours</div>
@oneblackcrayon
oneblackcrayon / 0-Using two loops on a home.php with pagination on the second loop.md
Last active October 19, 2022 02:42
Using two loops on a home.php with pagination on the second loop.

Wordpress - Using two loops on a home.php with pagination on the second loop notes & examples

Problem

I have a layout where I need to show the most recent post in a different layout/design component and remaining posts, needed to have a separate layout/design. I also wanted to use pagination to show other posts instead of infinite scrolling because I do not prefer infinite scrolling. Using the count modulus was not going to be a viable option due to how the design needed to be implemented but I think it could work for someone with experience in PHP. When using the offset in the loop, it was changing on pagination so each page after the first page had different recent post.

This was troublesome but I think I have a solid working solution for having multiple loops it works for my needs.

@oneblackcrayon
oneblackcrayon / functions.php
Created October 17, 2022 22:07 — forked from r4nd1/functions.php
Test #1
<?php
/*
Author: Zhen Huang
URL: http://themefortress.com/
This place is much cleaner. Put your theme specific codes here,
anything else you may want to use plugins to keep things tidy.
*/
@oneblackcrayon
oneblackcrayon / gsutil_cron_example.sh
Created October 13, 2022 21:20 — forked from nazroll/gsutil_cron_example.sh
A shell script example to run "gsutil" as a cronjob
#! /bin/bash
# Replace "/path/to/gsutil/" with the path of your gsutil installation.
PATH="$PATH":/path/to/gsutil/
# Replace "/home/username/" with the path of your home directory in Linux/Mac.
# The ".boto" file contains the settings that helps you connect to Google Cloud Storage.
export BOTO_CONFIG="/home/username/.boto"
# A simple gsutil command that returns a list of files/folders in your bucket.
@oneblackcrayon
oneblackcrayon / index.php
Created June 5, 2022 03:10 — forked from lepittenger/index.php
Check if the_content is empty
<?php
if ( $post->post_content=="" ) {
// do something for posts without content
} else {
// do something for posts with content
};
// OR
@oneblackcrayon
oneblackcrayon / opencl-amd_aur_ubuntu.bash
Created April 23, 2022 20:50 — forked from nottux/opencl-amd_aur_ubuntu.bash
bash implementation of opencl-amd AUR package, Install opencl amdgpu amdgpu-pro opencl only. Supports ubuntu and others with standard prefix
#!/bin/bash
# DO NOT run the line 167 standalone. It will remove the necessary files besides the junk!
if echo $@|grep -q "\-\-help\|\-help\|\-h\|help\|\-\-h\|\-\-no\-deb\|\-\-no\-install\|\-\-no\-cleaning\|\-\-assume\-debian"
then :
else echo wrong entry\(ies\) !
help=yes
fi
if echo $@|grep -q "\-\-help\|\-help\|\-h\|help\|\-\-h" || [ "$help" = yes ]