Skip to content

Instantly share code, notes, and snippets.

Avatar
🏴

Jet Holt Jetroid

🏴
View GitHub Profile
View gist:0ab5e676ab279e19fb245680ada0588d
var tooltipTimer;
var tooltipDiv;
var tooltip;
var tooltipIn = function(e){
tooltip = e.target;
tooltipTimer = setTimeout(function(){
var position = e.target.getBoundingClientRect();
tooltip.classList.add("show");
}, 200);
}
@Jetroid
Jetroid / product-lifecycle.php
Last active Dec 20, 2019
A snippet of code for use with WooCommerce and Advanced Custom Fields to make a product discontinued or forthcoming.
View product-lifecycle.php
<?php
function is_released($id) {
$status = get_field('product_status', $id);
// We consider null to be for sale, as this indicates an old product
// where we haven't made a selection yet
if (is_null($status) || $status === "forsale") {
return True;
} else if ($status === "forthcoming") {
View Image Tag srcset, sizes, and lazyloading modification
{%- assign pieces = content | split: '<img src="' -%}
{%- for piece in pieces -%}
{%- if forloop.first == true -%}
{{ piece }}
{%- else -%}
{%- if piece contains '" alt="' -%}
{%- assign url = piece | split: '" alt="' | first -%}
{%- assign alt = piece | split: '" alt="' | shift | join: '" alt="' | split: '"' | first -%}
{%- assign rest = piece | split: '" alt="' | shift | join: '" alt="' | split: '"' | shift | join: '"' -%}
{%- assign url-filename = url | split: '.' | pop | join: '.' -%}
View responsiveimages.py
import yaml
import os
import git
import subprocess
YAML_FILE = "processed.md"
FOLDERS = {
"assets/images/backgrounds/":[1920,1600,1366,1024,768,640],
"assets/images/content/":[1230,1024,874,655,560],
"assets/images/":[] #Do not make any additional sizes
View Sister optimimage.py
import yaml
import os
import git
YAML_FILE = "gallery.md"
FOLDERS = ["_tattoos","_brows","_commission"]
#Link git with python
repo = git.Repo()
#Get the staged files
View jetroid.github.io optimimage.py
import yaml
import os
import git
YAML_FILE = "compressed.md"
FOLDERS = ["assets/images/"]
#Link git with python
repo = git.Repo()
#Get the staged files
@Jetroid
Jetroid / custom_stylesheets.html
Created Jul 29, 2016
A hacky Liquid script to allow page-specific stylesheets using Yaml Front Matter
View custom_stylesheets.html
---
---
{% assign delim = "|" %}
{% assign had_elements = "" %}
<!-- Custom Stylesheets - use custom_css in YAML front matter !-->
{% if page.custom_css %}
{% for stylesheet in page.custom_css %}
{% capture had_elements %}{{ had_elements | join: delim }}{{ delim }}{{ stylesheet }}{% endcapture %}
{% assign had_elements = had_elements | split: delim %}
<link rel="stylesheet" href="/assets/css/{{ stylesheet }}.css" type="text/css">
@Jetroid
Jetroid / union.rb
Created Jul 29, 2016
A plugin to allow union of arrays with Jekyll.
View union.rb
module Jekyll
module UnionFilter
def union(input, array)
unless array.respond_to?(:to_ary)
array = Array.new
end
InputIterator.new(input).concat(array).uniq
end
class InputIterator