Skip to content

Instantly share code, notes, and snippets.

View kmclaugh's full-sized avatar

Kevin McLaughlin kmclaugh

View GitHub Profile
@kmclaugh
kmclaugh / Keras_Linear_Model.py
Last active February 4, 2021 15:13
Keras Model for a Simple Linear Function (ie Keras modeling a linear regression)
import pandas as pd
import numpy as np
import seaborn as sns
from keras.layers import Dense
from keras.models import Model, Sequential
from keras import initializers
## ---------- Create our linear dataset ---------------
## Set the mean, standard deviation, and size of the dataset, respectively
@kmclaugh
kmclaugh / evernote_converter.py
Last active November 27, 2017 17:18
Python script to convert clippings.io outputted Kindle Highlights into HTML files ready for evernote. Replace book_code, book_max_location with your book info and update all paths
#!/usr/bin/env python
import csv
from unidecode import unidecode
import os
import math
book_code = 'B06XKFP455'
kindle_highlights_url = 'https://kindle.amazon.com/your_highlights_and_notes/'+book_code
kindle_book_url = 'kindle://book?action=open&asin='+book_code + '&location=' ##40
book_max_location = 18456
@kmclaugh
kmclaugh / background.js
Last active May 11, 2021 21:25
Replacement for Chrome Extension's Inline-Install
var appDomainURL = "*://app.owlandscroll.com/*";
var appDomainURLCononical = "https://app.owlandscroll.com";
const makeAppActive = () => {
chrome.tabs.query({ url: config.appDomainURL }, tabs => {
if (tabs.length) {
var tab = tabs[0];
chrome.tabs.sendMessage(tab.id, { sendingUserToApp: true }, function(
response
) {
@kmclaugh
kmclaugh / nationbuilder_people.py
Created January 27, 2019 17:56
Use nationbuilder API and rauth to create, update, and delete a person
from rauth import OAuth2Service
nation_slug = "aura"
REDIRECT_URI = "aura_redirect"
## Authenticate using OAuth
access_token_url = "http://" + nation_slug + ".nationbuilder.com/oauth/token"
authorize_url = nation_slug + ".nationbuilder.com/oauth/authorize"
@kmclaugh
kmclaugh / survey_and_contacts.py
Created January 27, 2019 18:29
Use nationbuilder API and rauth to create, a survey, add a survey response, and add a contact when someone completes the survey
from rauth import OAuth2Service
nation_slug = "aura"
REDIRECT_URI = "aura_redirect"
## Authenticate using OAuth
access_token_url = "http://" + nation_slug + ".nationbuilder.com/oauth/token"
authorize_url = nation_slug + ".nationbuilder.com/oauth/authorize"
@kmclaugh
kmclaugh / 1. wpFormsToDatalyer.js
Last active March 6, 2024 06:21
Notifies the datalyer when a wpForm is submitted so Google Tag Manager can detect it
// This code notifies Google Tag Manager when a wpForm is submitted
document.addEventListener("DOMContentLoaded", function() {
var elementsArray = document.querySelectorAll('[id^="wpforms-form-"]');
elementsArray.forEach(function(elem) {
elem.addEventListener("submit", function(e) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "wpFormSubmit",
wpFormElement: event.target
});
@kmclaugh
kmclaugh / taxonomyTrackerTemplate.tpl
Last active August 22, 2019 11:42
Track taxonomies like categories and tags in Google Analytics with this Google Tag Manager custom template
___INFO___
{
"displayName": "Taxonomy Tracker",
"description": "Fires a datalayer event for each element in the given taxonomy array",
"securityGroups": [],
"id": "cvt_temp_public_id",
"type": "TAG",
"version": 1,
"brand": {
@kmclaugh
kmclaugh / page-title-internal.json
Created July 15, 2019 17:50
GTM container that adds "-INTERNAL" to the page title
{
"exportFormatVersion": 2,
"exportTime": "2019-07-15 17:47:27",
"containerVersion": {
"path": "accounts/4701996609/containers/11992448/versions/0",
"accountId": "4701996609",
"containerId": "11992448",
"containerVersionId": "0",
"container": {
"path": "accounts/4701996609/containers/11992448",
@kmclaugh
kmclaugh / Page Title DEBUG Mode
Created July 15, 2019 18:05
When in DEBUG mode, add the given string to the page title. When not in DEBUG mode, return the regular title. Useful for filtering out internal traffic when in DEBUG mode
___INFO___
{
"displayName": "Page Title DEBUG Mode",
"description": "When in DEBUG mode, add the given string to the page title. When not in DEBUG mode, return the regular title. Useful for filtering out internal traffic when in DEBUG mode",
"securityGroups": [],
"id": "cvt_temp_public_id",
"type": "MACRO",
"version": 1,
"containerContexts": [
@kmclaugh
kmclaugh / thank-you-page-conversion-recipe.json
Last active February 28, 2024 00:03
Google Tag Manager recipe for tracking pageview conversions
{
"exportFormatVersion": 2,
"exportTime": "2019-08-22 20:35:42",
"containerVersion": {
"path": "accounts/4701996609/containers/12749914/versions/0",
"accountId": "4701996609",
"containerId": "12749914",
"containerVersionId": "0",
"container": {
"path": "accounts/4701996609/containers/12749914",