Skip to content

Instantly share code, notes, and snippets.

View christopherhill's full-sized avatar

Christopher Hill christopherhill

View GitHub Profile
.container {
/* removed width here */
border: 1px solid black;
height:80px;
overflow-x:auto;
overflow-y:hidden; /* turns off y-scrollbar */
display:block;
}
.image-container {
background: blue;
class Automata():
'Represents a cellular automata with configurable params:'
' - number of columns, defaults to 64'
' - number of iterations, defaults to 32'
' - true symbol, defaults to *'
' - false symbol, defaults to -'
entries = []
rows = 0
cur_row = 0
<!DOCTYPE html>
<html>
<head>
<title>MJ Test</title>
<style>
.passed { color: green; }
.failed { color: red; }
@christopherhill
christopherhill / gist:da7e45c198cbad2d76e6
Last active August 29, 2015 14:06
Exercise (get second degree connections from graph data)
var graph = {
nodes:
[{
userId: 'chill',
city: 'Sonoma' },
{
userId: 'sjobs',
city: 'Mountain View' },
{
userId: 'bgates',
'use strict';
function justify(str, lineLength) {
if (str.length >= lineLength) {
throw 'Line length is equal to or exceeds justification length';
}
function genArrayOfSpaces(len) {
var arr = [];
@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: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"])) {