Skip to content

Instantly share code, notes, and snippets.

@kressaty
kressaty / google_form_to_segment.js
Created June 30, 2021 22:17
Sends the submitted payload of a Google Form to Segment.
/**
Sends the submitted payload of a Google Form to Segment.
Steps to install:
1. modify the script below to include your base64 encoded write key (with a colon at the end!) per the Segment docs
2. set the event name you want
3. add as a script to your Google Form (More > Script Editor)
4. add "https://www.googleapis.com/auth/script.external_request" & "https://www.googleapis.com/auth/forms" to your oauthScopes key in appscript.json
5. set your script trigger to onFormSubmit
@kressaty
kressaty / basicauthfilter.php
Created March 20, 2015 00:10
Simple basic auth example for Laravel
<?php
// this is a route filter that goes in your filters.php file
// you'll call this on a route by doing something like Route::get('/api/whatever', ['before' => 'auth.api'], function() {whatever});
Route::filter('auth.api', function()
{
// get the basic auth username
$key = Request::getUser();
// get the basic auth password
$secret = Request::getPassword();
@kressaty
kressaty / console_helper.php
Last active December 16, 2015 00:29
Codeigniter helper function utilizing Chrome PHP log feature
<?php
// You must include the PHP file from here for this to work: https://github.com/ccampbell/chromephp
// In Codeigniter, simply save the PHP file in the "Libraries" directory
function consolelog($stuff)
{
if(ENVIRONMENT == 'production')
{
return;
@kressaty
kressaty / gist:4217892
Created December 5, 2012 17:54
Install WordPress from the command line
cd /html
wget http://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
cp -R wordpress/* .
rm latest.tar.gz
rm -rf wordpress/
@kressaty
kressaty / ga-facebook.js
Created October 9, 2012 15:42
Facebook Like Button Google Analytics
// This assumes Facebook buttons are using the Facebook Javascript SDK.
// Thanks to Google for most of this code, see the Social Interaction Analytics guide at
// https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial
// Facebook provides a Javascript event framework that allows you to subscribe to events
// happening within the Facebook Javascript SDK and provides data accordingly.
// To track a like, subscribe to the edge.create event and then use the callback to
// execute the Analytics tracking code:
@kressaty
kressaty / ga-twitter.js
Created October 9, 2012 15:37
Twitter Button Google Analytics
// This assumes that you have included the Tweet button via the standard Twitter JS include
// Thanks to Google for most of this code, see the Social Interaction Analytics guide at
// https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial
// To track a Tweet, subscribe to the tweet event (note the additional function required
// to determine the query parameter being sent to Twitter):
function trackTwitter(intent_event) {
if (intent_event) {
var opt_pagePath;
if (intent_event.target && intent_event.target.nodeName == 'IFRAME') {
@kressaty
kressaty / ga-form-abandonment.js
Created September 24, 2012 21:20
Track Form Abandonment in Google Analytics
// NOTE: this assumes you have loaded jQuery
$(document).ready(function() {
// REPLACE 'UNIQUE_FORM_ID' BELOW WITH THE ID OF YOUR FORM
$('#UNIQUE_FORM_ID input').blur(function () {
if($(this).val().length > 0) {
_gaq.push(['_trackEvent', 'Form: FORM NAME HERE','input_exit_full', $(this).attr('name')]);
}
else {
_gaq.push(['_trackEvent', 'Form: FORM NAME HERE','input_exit_empty', $(this).attr('name')]);
@kressaty
kressaty / ga-youtube.js
Created September 24, 2012 18:26
Track YouTube Events in Google Analytics
//NOTE: you must also include https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api?enablejsapi=1&version=3&showinfo=0";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
@kressaty
kressaty / bpt.php
Created June 25, 2011 21:37
Quick PHP Functions to call Brown Paper Tickets API to get event and dates
function bpt_handler($atts)
{
extract(shortcode_atts(array(
"event_id" => ''
), $atts));
$event_data = $this->getBptEvent($event_id);
return '<pre>'.$event_data.'</pre>';
<?php
$account_id = '#'; //your account id
$path = "accounts/$account_id/limits.xml"; //the method or function you're calling via the api
$subdomain = "subdomain"; //your subdomain
$username = "api_key"; // your api key
$password = "password"; //your password
$method = "GET"; //method for the path you've chosen
//do the request