Skip to content

Instantly share code, notes, and snippets.

View PiotrKrzyzek's full-sized avatar

Peter Krzyzek PiotrKrzyzek

View GitHub Profile
@PiotrKrzyzek
PiotrKrzyzek / airtable_flatten_json_response.php
Last active October 10, 2019 19:25
Flatten Airtables's JSON API response into one level per item (such as for use in single level inputs / csv file like inputs)
<?php
/* Setup some variables for us to use */
parse_str($_SERVER['QUERY_STRING'], $urls);
$returnJson = []; // This is the main returned object
// Save the app and board params for use
$app = $urls['app'];
$board = $urls['board'];
$api = "YOUR API KEY HERE";
@PiotrKrzyzek
PiotrKrzyzek / collection-sorting.liquid
Last active May 3, 2019 19:26
Modified Shopify collection sort snippet, this one will not interfere with other URL parameters
<!-- /snippets/collection-sorting.liquid -->
<div class="collection-sorting-row">
<div id="sort-by-container"></div>
<script>
var currentURL = new URL(window.location);
var currentParams = currentURL.searchParams.get('sort_by');
var urlSearchParams = new URLSearchParams(
window.location.search.indexOf("sort_by") > -1
? window.location.search.replace(/sort_by/gi,"")
: window.location.search
@PiotrKrzyzek
PiotrKrzyzek / wordpress_the_years.php
Created March 12, 2019 19:33
WordPress shortcode to show the copyright year as well as years in business from given starting date.
/**
* Shortcode for the yearly display items
*
* @param [array] $atts The attributes passed to the shortcode
*
* @return void
*/
function showTheYear( $atts ){
$yearStarted = if(isset($atts['yearStarted'])) intval($atts['yearStarted']) : 1999;
$yearsInBusiness = if(isset($atts['years']))? true : false;
@PiotrKrzyzek
PiotrKrzyzek / wp_add_latest_posts_to_menu_dropdown_v1.php
Created February 27, 2019 20:30
WordPress - Add Latest Posts (By Category) To Specific Dropdown Menu Item
<?php
function add_latest_post_to_menu_dropdown($items, $menu) {
if( !is_admin() ) {
if ($menu->slug == 'the-menu-slug') {
$post_args = [
'post_type' => 'post',
'post_status' => 'publish',
'numberposts' => 6,
'category' => 580
@PiotrKrzyzek
PiotrKrzyzek / pihole_run.sh
Created December 17, 2018 03:24
Config and run pihole in Docker on MacOS
#!/bin/bash
# I've set this up to use my static IP, instead of dynamically getting one.
# Why? Because if my IP keeps changing, then how is the router supposed to constantly find it?!
# I set a static IP for this computer, and that is that.
IP="YOUR local static IP here"
# Default of directory you run this from, update to where ever.
DOCKER_CONFIGS="~/.pihole"
@PiotrKrzyzek
PiotrKrzyzek / fixwppermissions.sh
Created December 7, 2018 04:14
Fix WordPress Persmission
alias fixWPPermissions='find ./ -type d -exec chmod 755 {} \; find ./ -type f -exec chmod 644 {} \; find ./wp-content -type d -exec chmod 775 {} \; find ./wp-content -type f -exec chmod 664 {} \;'

Keybase proof

I hereby claim:

  • I am piotrkrzyzek on github.
  • I am piotrkrzyzek (https://keybase.io/piotrkrzyzek) on keybase.
  • I have a public key ASB7zLBnTFOy_LIzoa_nvvV0EbfLqpsUzujyxgW-65JKKQo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am piotrkrzyzek on github.
  • I am piotrkrzyzek (https://keybase.io/piotrkrzyzek) on keybase.
  • I have a public key ASB7zLBnTFOy_LIzoa_nvvV0EbfLqpsUzujyxgW-65JKKQo

To claim this, I am signing this object:

@PiotrKrzyzek
PiotrKrzyzek / woocommerce_password_strength.php
Created November 3, 2018 00:43
Reduce WooCommerce Password Strength Requirement
add_filter( 'woocommerce_min_password_strength', 'example_woocommerce_min_password_strength' );
/**
* Callback for WooCommerce 'woocommerce_min_password_strength' filter.
*
* Reduce the strength requirement on the woocommerce password.
*
* 0 = Anything (not a good idea)
* 1 = Weak
* 2 = Medium
* 3 = Strong (default)
@PiotrKrzyzek
PiotrKrzyzek / style.scss
Created September 13, 2018 02:26
SCSS (SASS) Input Placeholder Template
@mixin optional-at-root($sel) {
@at-root #{if(not &, $sel, selector-append(&, $sel))} {
@content;
}
}
@mixin placeholder {
@include optional-at-root('::-webkit-input-placeholder') {
@content;
}