Skip to content

Instantly share code, notes, and snippets.

View christopherhill's full-sized avatar

Christopher Hill christopherhill

View GitHub Profile
@christopherhill
christopherhill / gist:5928421
Last active December 19, 2015 08:49
Script for injecting Google A/B testing into multiple pages. Could be extended in any number of ways.
<script type="text/javascript">
var abtestValue = "", runTest = false;
var windowLocation = window.location.pathname;
var mapArr = new Array();
mapArr.push({ "url" : "/url.html", "id" : "99999999-99" });
mapArr.push({ "url" : "/url.html", "id" : "99999999-99" });
mapArr.push({ "url" : "/url.html", "id" : "99999999-99" });
mapArr.push({ "url" : "/url.html", "id" : "99999999-99" });
@christopherhill
christopherhill / gist:5928546
Last active December 19, 2015 08:49
Password strength and requirements validation.
var password = {
v: "",
update: function() {
this.v = $("#pass").val();
}
}
var criteria = {
update: function() {
password.update();
},
@christopherhill
christopherhill / gist:5935721
Last active December 19, 2015 09:49
Simple shell script to set-up a new front-end project.
#!/bin/bash
#simple script to setup a new front-end project
echo 'make in:'
echo $1
mkdir $1
mkdir $1/css
touch $1/css/styles.css
mkdir $1/img
@christopherhill
christopherhill / gist:5967901
Last active December 19, 2015 14:18
Drupal block of insertable code to query a content type against a field value and return matching field values. In this case, use the Smart IP module to grab the user country, and find international fields.
<?php
// get country (requires Smart IP installed)
$smart_ip_session = smart_ip_session_get('smart_ip');
$user_country = $smart_ip_session['location']['country'];
// execute a query against the international_data content type using field_location_name
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'node')
@christopherhill
christopherhill / gist:5978941
Created July 11, 2013 20:27
Sample PHP Backup Script. Needs lots of improvements, but a place to start.
<?php
/*
* CRH: 3/24/13
* Backup Script
* - This script will back up all files in public_html to a .tar.gz
* - It will also dump the complete set of mysql databases to a .tar.gz
* - It will send those files to an offsite location via FTP, in addition to locally
* storing them
* - It will send an e-mail with the results
@christopherhill
christopherhill / PHP Web Service
Last active December 19, 2015 15:49
Marketo Web Proxy
<?php
$staging = "http://marketostaging.domain.com/index.php/leadCapture/save";
$production = "http://marketoproduction.domain.com/index.php/leadCapture/save";
$url = '';
if (isset($_GET["s"])) {
$stagingFlag = $_GET["s"];
@christopherhill
christopherhill / gist:5979082
Created July 11, 2013 20:45
Marketo Key Hash, for a site with staging and production values.
<?php
// Marketo Web Service
// define the API key
$apikey = '';
$staging = 'secretkey';
$production = 'secretkey';
if (isset($_GET["s"])) {
@christopherhill
christopherhill / gist:5979154
Created July 11, 2013 20:54
Wistia work in progress. Eventually will take the rel attribute of a link and display a fancybox popup.
/* wistiaJQuery(document).bind("wistia-popover", function(event, iframe) {
iframe.wistiaApi.time(30).play();
iframe.wistiaApi.bind("end", function() {
alert("The video ended!");
});
}); */
$(document).ready(function() {
$("a.fancybox").fancybox();
@christopherhill
christopherhill / Array Sum of All Elements
Last active December 24, 2015 20:09
This was derived from a little game on-line; it uses recursion to sum a nested array of dynamic elements.
function arraySum(i) {
// i will be an array, containing integers, strings and/or arrays like itself.
// Sum all the integers you find, anywhere in the nest of arrays.
var intTotal = 0;
for (var j = 0; j < i.length; j++)
{
if (typeof(i[j]) === 'number') {
@christopherhill
christopherhill / Find Longest String in Array
Created October 6, 2013 16:25
Find the longest string in a given array.
function longestString(i) {
// i will be an array.
// return the longest string in the array
var longestIndex = -1;
for (var j = 0; j < i.length; j++) {
var curStr = i[j];