Skip to content

Instantly share code, notes, and snippets.

View mkdizajn's full-sized avatar
🐢
slow & thorough > faster & mistakable

Kresimir Pendic mkdizajn

🐢
slow & thorough > faster & mistakable
View GitHub Profile
@jacobwise
jacobwise / Advanced Custom Fields and JSON API
Last active November 1, 2017 13:11
How to add Advance Custom Fields to the JSON API in WordPress.
<?php
add_filter('json_api_encode', 'json_api_encode_acf');
function json_api_encode_acf($response)
{
if (isset($response['posts'])) {
foreach ($response['posts'] as $post) {
json_api_add_acf($post); // Add specs to each post
}
@splosch
splosch / md5_device_fingerprint.js
Last active March 6, 2018 20:50
Browser and device fingerprinting - a MD5 checksum generator to identify a device-browser-combination
(function(window, document, JSON){
"use strict";
var SEP = '|', ua, opera, ie;
/*
* Collect Browser & Device Data
*/
var Collector = {
/*
* MD5 Checksum calculation
*/
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
( function( $ ) {
'use strict';
function yourCustomCarousels {
// Make sure scripts are loaded
if ( undefined === $.fn.wpexOwlCarousel || undefined === $.fn.imagesLoaded ) {
return;
}
@trevorfox
trevorfox / drift-events.js
Last active June 5, 2019 19:32
Drift Data Layer Events
// Read more on the blog posts: https://trevorfox.com/2019/01/drift-event-tracking-google-tag-manager/
// Data Layer event values to be pushed according to their driftEventName
var driftEvents = [
{driftEventType: 'sidebar', driftEventName: 'sidebarOpen', driftEventDescription: 'sidebar opened'},
{driftEventType: 'sidebar', driftEventName: 'sidebarClose', driftEventDescription: 'sidebar closed'},
{driftEventType: 'welcome message', driftEventName: 'welcomeMessage:open', driftEventDescription: 'welcome message opened'},
{driftEventType: 'welcome message', driftEventName: 'welcomeMessage:close', driftEventDescription: 'welcome message closed'},
{driftEventType: 'away message', driftEventName: 'awayMessage:open', driftEventDescription: 'away message opened'},
{driftEventType: 'away message', driftEventName: 'awayMessage:close', driftEventDescription: 'away message closed'},
@aeurielesn
aeurielesn / gist:2511005
Created April 27, 2012 17:23
Retrying a jQuery.ajax() call
$.ajax({
url: '/echo/error/',
async: true,
// retryCount and retryLimit will let you retry a determined number of times
retryCount: 0,
retryLimit: 10,
// retryTimeout limits the total time retrying (in milliseconds)
retryTimeout: 10000,
// timeout for each request
timeout: 1000,
@mikejolley
mikejolley / gist:1547491
Created January 1, 2012 14:38
WooCommerce - A filter to add a tracking (or any other field for that matter) to order emails to customers.
/* To use:
1. Add this snippet to your theme's functions.php file
2. Change the meta key names in the snippet
3. Create a custom field in the order post - e.g. key = "Tracking Code" value = abcdefg
4. When next updating the status, or during any other event which emails the user, they will see this field in their email
*/
add_filter('woocommerce_email_order_meta_keys', 'my_custom_order_meta_keys');
function my_custom_order_meta_keys( $keys ) {
$keys[] = 'Tracking Code'; // This will look for a custom field called 'Tracking Code' and add it to emails
@Rich-Harris
Rich-Harris / gh-pages.md
Created August 11, 2013 23:02
Automating gh-pages branch updating with changes to the master branch
@brankoajzele
brankoajzele / gist:2781404
Created May 24, 2012 12:56
Programatically create Magento order with tablerate shipping
<?php
require_once 'app/Mage.php';
Mage::app();
$quote = Mage::getModel('sales/quote')
->setStoreId(Mage::app()->getStore('default')->getId());
$product = Mage::getModel('catalog/product')->load(6); /* 6 => Some product ID */
@hteumeuleu
hteumeuleu / gmail-animation.html
Created April 26, 2018 13:49
The new Gmail loading animation is just HTML and CSS.
<style>
body{margin:0;width:100%;height:100%} body,td,input,textarea,select{font-family:arial,sans-serif} input,textarea,select{font-size:100%} #loading{position:absolute;width:100%;height:100%;z-index:1000;background-color:#fff} .msg{ color: #757575; font: 20px/20px Arial, sans-serif; letter-spacing: .2px; text-align: center } #nlpt{ animation: a-s .5s 2.5s 1 forwards; background-color: #f1f1f1; height: 4px; margin: 56px auto 20px; opacity: 0; overflow: hidden; position: relative; width: 300px } #nlpt::before{ animation: a-lb 20s 3s linear forwards; background-color: #db4437; content: ''; display: block; height: 100%; position: absolute; transform: translateX(-300px); width: 100% } @keyframes a-lb{ 0%{transform:translateX(-300px)}5%{transform:translateX(-240px)}15%{transform:translateX(-30px)}25%{transform:translateX(-30px)}30%{transform:translateX(-20px)}45%{transform:translateX(-20px)}50%{transform:translateX(-15px)}65%{transform:translateX(-15px)}70%{transform:translateX(-10px)}95%{transform:translateX(-1