Skip to content

Instantly share code, notes, and snippets.

View samjco's full-sized avatar

Sam C. samjco

View GitHub Profile
@Spencer-Easton
Spencer-Easton / exportSpreadsheet.gs
Last active March 21, 2024 00:43
Example on how to export a Google sheet to various formats, includes most PDF options
function exportSpreadsheet() {
//All requests must include id in the path and a format parameter
//https://docs.google.com/spreadsheets/d/{SpreadsheetId}/export
//FORMATS WITH NO ADDITIONAL OPTIONS
//format=xlsx //excel
//format=ods //Open Document Spreadsheet
//format=zip //html zipped
@stormwarning
stormwarning / __wordpress.php
Last active February 29, 2024 03:03
WordPress PROTIPs
/**
* A selection of handy code snippets, plugins, and best practices for WordPress development.
*
*/
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@michelegiorgi
michelegiorgi / formality_hooks_sample.php
Last active December 20, 2023 00:06
Formality hooks reference
<?php
/**
* Formality hooks reference
*
* @link https://formality.dev
* @since 1.1
* @package Formality
* @author Michele Giorgi <hi@giorgi.io>
*/
@JProffitt71
JProffitt71 / s3cmdclearfiles
Created February 17, 2014 04:29
Uses s3cmd to manually remove files older than specified date (##d|m|y) in a specified bucket
#!/bin/bash
# Usage: ./s3cmdclearfiles "bucketname" "30d"
s3cmd ls s3://$1 | grep " DIR " -v | while read -r line;
do
createDate=`echo $line|awk {'print $1" "$2'}`
createDate=`date -j -f "%Y-%m-%d %H:%M" "$createDate" +%s`
olderThan=`date -j -v-$2 +%s`
if [[ $createDate -lt $olderThan ]]
@ensostyle
ensostyle / ListFieldRowTotal
Created January 11, 2017 12:15
Count the number of rows in a Gravity Forms list field and store the result in another field.
<script>
function ListFieldRowCount( listField, totalField ) {
var totalRows = jQuery( listField ).find('table.gfield_list tbody tr').length;
jQuery( totalField ).val( totalRows ).change();
}
function ListFieldRowTotal( formId, fieldId, totalFieldId ) {
var listField = '#field_' + formId + '_' + fieldId;
var totalField = '#input_' + formId + '_' + totalFieldId;
ListFieldRowCount( listField, totalField );
jQuery( listField ).on( 'click', '.add_list_item', function() {
@thierrypigot
thierrypigot / acf-missing.php
Created June 3, 2016 10:13
WordPress mu plugins to check if "Advanced Custom Fields Pro" is active.
<?php
if( !class_exists('acf') )
{
$tp_acf_notice_msg = __( 'This website needs "Advanced Custom Fields Pro" to run. Please download and activate it', 'tp-notice-acf' );
/*
* Admin notice
*/
add_action( 'admin_notices', 'tp_notice_missing_acf' );
function tp_notice_missing_acf()
@RickeyMessick
RickeyMessick / Gravity Forms get all fields function
Created November 3, 2015 21:11
Gravity Forms get all fields function to use with gform_after_submission to display just filled out fields
function get_all_fields($entry, $form)
{
//only do this for a certain form (id 53 for example)
// if ($form["id"] == 17)
//{
foreach($form["fields"] as &$field)
{
//see if this is a multi-field, like name or address
if (is_array($field["inputs"]))
@eclarrrk
eclarrrk / get-gravity-forms-entries.php
Last active May 29, 2022 22:46
Display Gravity Form entries into WordPress page template
<?php
/*
Official Gravity Forms documentation on get_entries() found here:
https://docs.gravityforms.com/api-functions/#get-entries
*/
/* Gravity Form ID. */
$form_id = '20';
/* Sorting options avalable but left blank for simplicity. */
@KittenCodes
KittenCodes / modal.js
Created February 20, 2020 13:28
jQuery to create Lightbox popup using Oxygen's Modal element
jQuery('.lightbox-trigger').click( function() {
var image = jQuery(this).attr('src');
jQuery('.lightbox-popup').css('background-image', 'url(' + image + ')');
var caption = jQuery(this).next().text();
jQuery('.lightbox-popup-caption').text( caption );