Skip to content

Instantly share code, notes, and snippets.

View PiotrKrzyzek's full-sized avatar

Peter Krzyzek PiotrKrzyzek

View GitHub Profile
@PiotrKrzyzek
PiotrKrzyzek / bitly_to_yourls.py
Created June 3, 2016 23:37
Migrate Links From Bit.LY To Your YOURLS Install
#! /usr/bin/python
#Simple script for importing data from bitly to yourls using bitly and yourls API.
import urllib2, json, urllib
#Add the following data
yourls_host = 'your-domain-where-yours-is-installed.com'
bitly_token = 'your-bitly-token'
yourls_signature = 'your-yourls-signature-key'
@PiotrKrzyzek
PiotrKrzyzek / laravel-setSlugAttribute-model-php
Last active February 14, 2018 01:50
Set the Slug Attribute in Laravel & append counter is not unique
/**
* Set the Slug attribute and add counter if not unique.
* This function will check if the current model's slug is unique and update
* if with a counter at the end of the slug (such as -2) if there already exists.
* For example, if we're saving a page called "About us" with the slug
* "about-us", but for some reason you already have a page with the slug
* "about-us" this new page would then be set to have the slug
* "about-us-2" instead.
*
* @param any $value This is the value passed to this setting function.
@PiotrKrzyzek
PiotrKrzyzek / new_email_animation_ckb_next.scpt
Last active May 23, 2018 23:50
Upon new file detected, run animation script for ckb_next pipe animation as a system notification for whatever event.
on adding folder items to this_folder after receiving added_items
try
repeat with nDec from 0 to 255
set nHex to do shell script "perl -e 'printf(\"FFFFFF%x\", " & nDec & ")'"
do shell script "echo " & nHex & " > /tmp/ckbpipe001"
delay 0.005
end repeat
delay 0.1
repeat with nDec from 0 to 255
set nHex to do shell script "perl -e 'printf(\"FFFFFF%x\", " & 255 - nDec & ")'"
@PiotrKrzyzek
PiotrKrzyzek / shopify_checkout_conversion_tracking.liquid
Last active May 31, 2018 02:51
Shopify: Track purchased with FB Pixel & Google Analytics (run one time, detailed data)
{% if first_time_accessed %}
<script>
fbq('track', 'Purchase', {
contents: [
{% for line_item in line_items %}
{
'id': '{{ line_item.sku }}',
'quantity': {{ line_item.quantity }},
'item_price': {{ line_item.line_price | money_without_currency }}
},
@PiotrKrzyzek
PiotrKrzyzek / css.json
Created July 21, 2018 17:12
VSCode css snippet for standard media queries
{
"_media": {
"prefix": "_media",
"body": [
"/* Large Devices, Wide Screens */",
"@media only screen and (max-width : 1200px) {}",
"/* Medium Devices, Desktops */",
"@media only screen and (max-width : 992px) {}",
"/* Small Devices, Tablets */",
"@media only screen and (max-width : 768px) {}",
@PiotrKrzyzek
PiotrKrzyzek / woocommerce_all_filters_reset.php
Created August 1, 2018 02:21
Add Reset All Filters link to filters
<?php $filterreset = $_SERVER['REQUEST_URI'];
if ( strpos($filterreset,'?filter_') !== false | strpos($filterreset,'?min_price') !== false | strpos($filterreset,'?max_price')) {
$filterreset = strtok($filterreset, '?');
echo '<div class="clear-filters-container"><a id="woo-clear-filters" href="'.$filterreset.'">Clear All Filters</a></div>';
}
@PiotrKrzyzek
PiotrKrzyzek / woocommerce_default_payment_gateway.php
Created August 3, 2018 03:19
WooCommerce: Select default payment gateway option on checkout page
/**
* Select Stripe as default payment gateway
*/
add_action( 'woocommerce_before_checkout_form', 'set_default_gateway' );
function set_default_gateway(){
// HERE define the default payment gateway ID
$default_payment_gateway_id = 'stripe';
WC()->session->set('chosen_payment_method', $default_payment_gateway_id);
}
@PiotrKrzyzek
PiotrKrzyzek / woocommerce_stripe_hide_payment_icons.php
Created August 3, 2018 03:36
WooCommerce: Hide Stripe gateway payment icons on checkout page
/*
* Pick and chose which payment icons you'd want to show on the checkout page
* next to he payment gateways. The default in this function is to hide them all.
* Primarily made for stripe
*/
add_filter( 'wc_stripe_payment_icons', 'show_hide_woocommerce_gateway_payment_icons' );
function show_hide_woocommerce_gateway_payment_icons( $icons ) {
$icon_list = [
"visa",
@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;
}
@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)