Skip to content

Instantly share code, notes, and snippets.

@jmwhittaker
jmwhittaker / app.js
Last active November 26, 2021 16:15
Standard compliant stylesheet switcher for HTML5. Works on iOS5 and all modern browsers.
$(document).ready(function()
{
/* Check to see if we have saved a style already, a bit verbose but you get the drift! */
var theme = localStorage.getItem('style');
if (!theme) {
localStorage.setItem('style', 'light');
};
updateTheme();
@tvwerkhoven
tvwerkhoven / rsync_backup.sh
Last active July 5, 2023 05:30 — forked from necolas/rsync_backup
Improved script: - Check if run as root - Clarify rsync(1) flags - Add --inplace for performance, extra preservation flags - Check bless(8) target before setting Improved exclusion file: - Included files listed by Carbon Copy Cloner
#!/bin/bash
#
# This script backups an OS X system to an external volume, effectively
# cloning it. It is based on [0], [1] and [2] for OS X and [3] and [4] for
# Linux. One could also use commercial tools like SuperDuper! or Carbon Copy
# Cloner. The latter website has an interesting list[5] on what files to
# exclude when cloning.
#
# Exclusions (from CCC[5]), see rsync_excludes_osx.txt
#
@pamelafox
pamelafox / gist:4674841
Last active September 24, 2020 13:43
truncate based off offscreen
function truncateText(string, nMaxChars) {
if (string.length <= nMaxChars)
return string;
var xMaxFit = nMaxChars - 3;
var xTruncateAt = string.lastIndexOf(' ', xMaxFit);
if (xTruncateAt == -1 || xTruncateAt < nMaxChars / 2)
xTruncateAt = xMaxFit;
return string.substr(0, xTruncateAt) + "&hellip;";
@spivurno
spivurno / gist:4974784
Created February 18, 2013 02:29
Gravity Wiz: Geo IP
<?php
/**
* Gravity Wiz Geo IP
*
* Allows the use of the {geoip} merge tag in the dynamic population parameter of any single input field.
* Additionally, provides ability to populate specific properties from the geo data as follows:
*
* :city Virginia Beach
* :region_code VA
* :region_name Virginia
@claudiosanches
claudiosanches / add-to-cart.php
Last active October 18, 2023 14:02
WooCommerce - Template add-to-cart.php with quantity and Ajax!
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@spivurno
spivurno / gw-gravity-forms-advanced-merge-tags.php
Last active May 5, 2022 18:54
Gravity Wiz // Gravity Forms // Advanced Merge Tags
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-advanced-merge-tags.php
*/
/**
* Gravity Wiz // Gravity Forms // Advanced Merge Tags
*
* Adds support for several advanced merge tags:
@webaware
webaware / gist:6260468
Last active June 6, 2023 18:00
WooCommerce purchase page add-to-cart with quantity and AJAX, without customising any templates. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* start the customisation
*/
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
}
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
@hisnipes
hisnipes / Wordpress GravityForms Google Spreadsheet Hook
Last active December 10, 2021 14:03
Wordpress GravityForms Google Spreadsheet Hook - dynamically populate radio button choices using data from a Google Spreadsheet (should allow for easier collaboration with non-tech colleagues). Matches with today's date to pull relevant information from the table. Thanks to Pamela Fox (parsing JSON output with PHP: https://gist.github.com/pamela…
<?
// Gravity Form Hook to SQL Database for Today's Dishes //
// the ### in gform_pre_render_### locates the id of your form //
add_filter('gform_pre_render_5', 'todays_dishes');
function todays_dishes($form){
foreach($form['fields'] as &$field){
@spivurno
spivurno / gw-gravity-forms-post-content-merge-tags-usage.php
Last active November 4, 2019 14:00
Gravity Wiz // Add Support for Gravity Form Merge Tags in your Post Content (when an entry ID is passed)
<?php
# Basic
gw_post_content_merge_tags();
# With Parameters
gw_post_content_merge_tags( array(
'auto_append_eid' => false,
'encrypt_eid' => true
) );
@spivurno
spivurno / gw-gravity-forms-map-fields-to-field.php
Last active May 22, 2023 17:27
Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
<?php
/**
* Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
*
* Usage
*
* 1 - Enable "Allow field to be populated dynamically" option on field which should be populated.
* 2 - In the "Parameter Name" input, enter the merge tag (or merge tags) of the field whose value whould be populated into this field.
*
* Basic Fields