Skip to content

Instantly share code, notes, and snippets.

@pibby
pibby / critcss.snippet.js
Last active August 23, 2020 16:22 — forked from james-Ballyhoo/critcss.snippet.js
Critical CSS Finder w/media query support for those of us who write mobile-first CSS; will output to console; configurable viewport height on line 12.
/* Critical CSS Finder w/media query support and output to console
by Katie Harron - https://github.com/pibby - https://pibby.com
forked from james-Ballyhoo (https://gist.github.com/james-Ballyhoo/04761ed2a5778c505527) who forked from PaulKinlan (https://gist.github.com/PaulKinlan/6284142)
I don't know why this isn't keeping my 2 space indents :(
*/
(function() {
function findCriticalCSS(w, d) {
// Pseudo classes formatting
var formatPseudo = /([^\s,\:\(])\:\:?(?!not)[a-zA-Z\-]{1,}(?:\(.*?\))?/g;
@iksi
iksi / fluid-typography.css
Created January 14, 2016 11:45
Fluid typography between a min & max font-size and molten leading
/**
* Fluid typography between a min & max font-size and molten leading
* calc(minSize + (maxSize - minSize) * ((100vw - minPort) / (maxPort - minPort)));
*/
:root {
font-size: 100%;
}
body {
font-size: 1em;

Transients

A Transient is a simple way of storing cached data in the database temporarily, by giving it a custom name and a timeframe after which it will expire and be deleted.

Transients are useful when pinging another API (i.e. Wordpress, Instagram, twitter), and saving data for a set period of time.

Once the module is installed, you will find a tab under Utilities. This batch list is only used for debugging. You can view transients here, and delete them.

Please Note

@bheyde
bheyde / gist:26d12958c5c013dd99165a6bc182a79a
Last active May 16, 2016 20:05
Dynamic Resize Images Based on URL
//create a new page in Miva called REQUEST_IMAGE with the following code:
<mvt:assign name="l.constraints[1]:height" value="encodeentities(g.image_height)" />
<mvt:assign name="l.constraints[1]:width" value="encodeentities(g.image_width)" />
<mvt:assign name="l.imagetype_codes[1]" value="encodeentities(g.image_type)" />
<mvt:do name="l.success" file="g.Module_Library_DB" value="Product_Load_Code( encodeentities(g.Product_Code), l.settings:product )" />
@tessguefen
tessguefen / header-example.php
Last active March 17, 2017 23:01
Transient for WordPress & Miva Blog
if ( false === ( $mivaHeader = get_transient( 'miva_header' ) ) ) {
$mivaHeader = file_get_contents("http://" . $hostname . "/mm5/merchant.mvc?Screen=WP-HEADER");
set_transient( 'miva_header', $mivaHeader, 24 * HOUR_IN_SECONDS );
}
echo $mivaHeader;
@bheyde
bheyde / mvt_call_headers.html
Created July 14, 2016 15:49
mvt:call - passing custom headers example
<mvt:assign name="g.api_endpoint" value="'https://DJDHGSDJD-dsn.algolia.net'" />
<mvt:assign name="g.index_name" value="'docs.miva'" />
<mvt:assign name="g.path" value="'/1/indexes/' $ g.index_name $ '/390342730'" />
<mvt:assign name="g.api_request" value="g.api_endpoint $ g.path" />
<mvt:assign name="g.headers" value="'X-Algolia-API-Key: 17181817181912' $ asciichar( 13 ) $ asciichar( 10 )" />
<mvt:assign name="g.headers" value=" g.headers $ 'X-Algolia-Application-Id: HSGDJDJDGD' $ asciichar( 13 ) $ asciichar( 10 )" />
<mvt:call action="g.api_request" method="'PUT'" headers="'g.headers'">
@bheyde
bheyde / scheduled_task.mv
Last active July 15, 2016 15:35
Example Scheduled Task Module
<MvFUNCTION NAME = "Module_Description" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
<MvASSIGN NAME = "l.module:code" VALUE = "call_url_stsk">
<MvASSIGN NAME = "l.module:name" VALUE = "HTTP Request to URL">
<MvASSIGN NAME = "l.module:provider" VALUE = "Miva Merchant">
<MvASSIGN NAME = "l.module:version" VALUE = "9.0003">
<MvASSIGN NAME = "l.module:api_ver" VALUE = "9.05">
<MvASSIGN NAME = "l.module:description" VALUE = "This Scheduled Task allows you to setup a URL which will get called via an http request when the task is run.">
<MvASSIGN NAME = "l.module:features" VALUE = "util, vis_util, scheduledtask">
</MvFUNCTION>
@wojteklu
wojteklu / clean_code.md
Last active September 9, 2025 09:04
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@bheyde
bheyde / variant_price_range.html
Created November 15, 2016 23:12
Load High / Low Price Range for a Product with Attributes (pricing at attribute level)
<mvt:comment>
Load all possible variants using toolkit
</mvt:comment>
<mvt:item name="toolkit" param="variantarray|vcount|g.product_code" />
<mvt:comment>
Loop though variants, load product information for each variant, insert into new array
</mvt:comment>
@tessguefen
tessguefen / example.xml
Last active December 7, 2016 16:14
Group Products Codes together into new array
<mvt:foreach iterator="group" array="basket:groups">
<mvt:comment> <!-- Build Dynamic Array --> </mvt:comment>
<mvt:if expr="miva_array_search( l.settings:new_array, 0, l.item, 'l.item:code EQ l.settings:group:code' )">
<mvt:assign name="l.item:quantity" value="l.item:quantity + l.settings:group:quantity" />
<mvt:else>
<mvt:assign name="l.success" value="miva_array_insert( l.settings:new_array, l.settings:group, -1 )" />
</mvt:if>
<mvt:comment> <!-- Build Dynamic Array --> </mvt:comment>
</mvt:foreach>