Skip to content

Instantly share code, notes, and snippets.

@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active May 3, 2024 12:55
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@lonchbox
lonchbox / gist:fb152c46f4ed5c1a410f
Created March 10, 2016 16:25
Display Custom Taxonomy image field with Pods.io
<?php
$terms = get_terms( 'TAXONOMY' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
echo '<div class="item">';
$icon = pods_field( 'TAXONOMY', $term->term_id, 'FIELD', true );
$icon_url = $icon['guid'];
$icon_thumb = pods_image_url ( $icon_url, 'thumbnail', 0, false ) ;
$term_link = get_term_link($term);
echo '<a href="'.$term_link.'">';
@StevenMaude
StevenMaude / convert_gpx.sh
Last active January 29, 2023 17:29
Use gpsbabel to convert Garmin .FIT to .gpx — requires a fairly recent version of gpsbabel (minimum 1.4.3); see https://www.stevenmaude.co.uk/posts/using-garmin-forerunner-watches-with-linux for more details on using Garmin watches with Linux
#!/bin/sh
# Usage: convert_gpx.sh <FIT filename>
# Should works whether you include the .FIT extension or not.
filename=$(basename "$1" .FIT)
gpsbabel -i garmin_fit -f "$filename".FIT -o gpx -F "$filename".gpx
@aFarkas
aFarkas / focus-within.js
Last active August 20, 2020 10:49
simple focus-within polyfill
(function(window, document){
'use strict';
var slice = [].slice;
var removeClass = function(elem){
elem.classList.remove('focus-within');
};
var update = (function(){
var running, last;
var action = function(){
var element = document.activeElement;
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@markatom
markatom / createvh
Created March 3, 2015 13:23
Create virtual host
#!/bin/bash
if [ -z $1 ]; then
echo Usage: $0 project-name >&2
exit 1
fi
CONFIG=$(cat << 'END'
<VirtualHost *:80>
ServerName %name%.dev
#!/usr/bin/env ruby -w
# My first Ruby program
require "json"
if ARGV.empty?
puts "Usage gpx2json.rb filename"
exit
end
@raelgc
raelgc / Email Server (Linux, Unix, Mac).md
Last active April 28, 2024 15:33
Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

1 - Point localhost.com to your machine

Most of programs will not accept an email using just @localhost as domain. So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:

127.0.0.1 localhost.com

2 - Install Postfix

@LeeRJohnson
LeeRJohnson / foundation-grid-sized-flex-video.html
Last active December 12, 2015 08:09
Methods for controlling the scaling of video in a theme using Foundation.
<div class="row"><!-- not really need - row should exist higher in the doc -->
<div class="six columns centered"><!-- six is the width (half) but could be one through tweleve - centered centers it -->
<div class="flex-video widescreen"><!-- widescreen is for the 560 315 ratio -->
<iframe width="560" height="315" src="http://www.youtube.com/embed/N966cATFWjI" frameborder="0" allowfullscreen=""></iframe>
</div>
</div>
</div>
@dsheiko
dsheiko / strtr.js
Last active July 9, 2023 18:18
Java-script strtr — translate characters or replace substrings
/**
* strtr() for JavaScript
* Translate characters or replace substrings
*
* @author Dmitry Sheiko
* @version strtr.js, v 1.0.2
* @license MIT
* @copyright (c) Dmitry Sheiko http://dsheiko.com
**/