Skip to content

Instantly share code, notes, and snippets.

View johndhancock's full-sized avatar

John Hancock johndhancock

  • The Boston Globe
  • Dallas, Texas
View GitHub Profile
@johndhancock
johndhancock / customJS.js
Last active August 29, 2015 14:20
Map repositioning on scroll
$(document).ready(function() {
//custom scripting goes here
// map setup
L.Browser.webkit3d = false;
var map;
map = L.map('map').setView([32.8935772, -96.8870228],10);
@johndhancock
johndhancock / export
Created June 7, 2015 16:13
Export JSON to S3
///////////////////////////////////////////////////////
// EXPORT JSON to S3 ///////////////////////////
////////////////////////////////////////////
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [
{name: "Publish to DMN data store", functionName: "exportS3"},
];
ss.addMenu("Publish Data", menuEntries);
@johndhancock
johndhancock / responsiveD3.js
Created July 20, 2015 16:40
Starter js for responsive d3 charts. Assumes jquery and a div for your d3 chart with id of "chart". Your d3 charts will redraw to the new #chart with upon window resize
// this is a starter template for a responsive d3 chart
// it assumes you're using jquery, and that the div your chart
// will live in has an id of "chart"
$(document).ready(function() {
var windowWidth = $(window).width();
//variable setup: chartcontainer and it's width
@johndhancock
johndhancock / dropdown.css
Last active September 2, 2015 12:55
Dropdown panels
.dropList .dropHed {
cursor: pointer;
}
.dropList .dropItem {
background-color: rgb(240,240,240);
border-radius: 2px;
margin-bottom: .6rem;
padding: 1rem;
}
.dropList .dropHed span.cardinal {
@johndhancock
johndhancock / jquery ajax request
Created March 2, 2017 14:44
jquery ajax request that doesn't cache data
$.ajax({
dataType: "json",
url: "<url for json here>",
success: <function to run when request is done ex: filterdata>,
cache: false
});
@johndhancock
johndhancock / terminalCommands.md
Last active June 7, 2017 16:25
Handy terminal commands for various things.

In command line of directory desired:

Virtual Env

Creating viruatl environment

virtualenv venv

Specifying python version upon creation

virtualenv venv --python=python3

Stepping into the virtual environment
@johndhancock
johndhancock / django-commands.md
Last active May 25, 2017 21:05
django commands

In project directory command line where website is to be created ...

STARTING PROJECT

django-admin startproject <website_name>


In created project command line ...

RUN SERVER

POSTGRESQL COMMAND LINE COMMANDS

Starting up a postgres database

pg_ctl -D /usr/local/var/postgres start

creating a database. This needs to be done via the command line outside of python

createdb <databasename>

viewing a database

psql <databasename>

Starting a django project from the command line

django-admin startproject <project name>


Starting up the django server

From within the app root directory:

python manage.py runserver 0.0.0.0:8000


@johndhancock
johndhancock / ooyala-overrides.scss
Created September 12, 2017 15:23
Style overrides for ooyala player in interactives
.video-block {
width: 55%;
margin: 4.8rem 0;
font-size: 15px;
img {
max-width: 170px !important;
max-height: 18px !important;
}
}
.video-wrapper {