Skip to content

Instantly share code, notes, and snippets.

View clnmcgrw's full-sized avatar
🏠
Working from home

Colin McGraw clnmcgrw

🏠
Working from home
View GitHub Profile
@clnmcgrw
clnmcgrw / gist:9086505
Last active November 25, 2021 11:16
Google Maps API Geocode Example - PHP/JSON
<?php
// address to map
$map_address = "";
$url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=".urlencode($map_address);
$lat_long = get_object_vars(json_decode(file_get_contents($url)));
// pick out what we need (lat,lng)
$lat_long = $lat_long['results'][0]->geometry->location->lat . "," . $lat_long['results'][0]->geometry->location->lng;
@clnmcgrw
clnmcgrw / gist:83fd9c95c45506874c14
Last active February 4, 2016 22:59
Mailchimp AJAX Submit w/ JSONP
$('#form-selector').submit( function(event) {
event.preventDefault();
//copy the mailchimp formm action URL, and change "post" parameter to "post-json"
var submitUrl = $(this).data('submit-url');
$.getJSON( submitUrl+"&c=?", $(this).serialize(), function(data) {
});
});
Verifying that "clnmcgrw.id" is my Blockstack ID. https://onename.com/clnmcgrw
@clnmcgrw
clnmcgrw / hubspot-hubl-dreamcode.hubl
Last active April 4, 2017 00:37
Hubspot COS / Hubl - Features We'd Love to See
{# (1) get another page's context #}
{% set other_landing_page = get_landing_page_by_id(123456); %}
{# (2) interpolate hubl variable values in module attribute values (particularly label attr) #}
{% set my_options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] %}
@clnmcgrw
clnmcgrw / bigcommerce-product-data.js
Last active August 5, 2022 16:37
Bigcommerce Conversion Tracking - Get Product Data
(function() {
//Bigcommerce doesn't provide variables for individual product info,
//so this is a hacky way to read it from the GA ecommerce script
var products = [];
var scripts = document.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].innerHTML.match(/pageTracker\._addItem/)) {
var stuff = scripts[i].innerHTML.match(/_addItem\(([^\)]+)/g);
for (var c = 0; c < stuff.length; c++) {
@clnmcgrw
clnmcgrw / snippet.html
Created July 27, 2017 23:11
Cookies Notice - Wonderware International
<script src="https://on.wonderware.com/hs-fs/hub/2199074/hub_generated/template_assets/1501196906904/Custom/system/assets/wonderware-utilities.js"></script>
@clnmcgrw
clnmcgrw / migrate.js
Last active April 26, 2019 17:54
Data Migration Technique
// prop - destination key
// value - source key
const entityProps = {
name: 'title',
body: 'description',
day: 'date',
room: 'location',
};
// transform a destination value