Skip to content

Instantly share code, notes, and snippets.

View liddiard's full-sized avatar
🙃

Harrison Liddiard liddiard

🙃
View GitHub Profile
@liddiard
liddiard / init.coffee
Created February 10, 2015 23:28
GitHub Atom editor config scripts
# use two-space tabs for JavaScript
path = require 'path'
atom.workspaceView.eachEditorView (editorView) ->
editor = editorView.getEditor()
filepath = editor.getPath()
# set Tab Length for JS sources
if path.extname(filepath) is '.js'
@liddiard
liddiard / hw02.cpp
Last active August 29, 2015 14:13
PIC 10A Homework 2
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main(){
const int FIRST_COL_WIDTH = 20;
const int SECOND_COL_WIDTH = 10;
// Takes a year, month, and day number and outputs a string in the format "Dec 05, 2012".
// 'month' input parameter starts with zero.
function convertDateToEnglishString(day, month, year) {
var monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
try {
var monthName = monthNames[month];
} catch (e) {
alert('Invalid date');
return;
@liddiard
liddiard / twidder_models.py
Last active August 29, 2015 14:12
Mock database design for Twidder, a social networking app that has nothing at all to do with a social networking app of a similar name.
from django.db import models
class User(models.Model):
# Django's auth framework provides its own very
# capable user model, but we'll make our own
# assuming English/Western-style names –
# first name/last name distinction doesn't apply in all cultures
first_name = models.CharField(max_length=64)
@liddiard
liddiard / googleSheetsPrettify.js
Last active July 24, 2020 13:45
Make a JSON feed from Google Sheets more pretty to work with – removes "gsx$" key prefixes, un-nests unnecessarily nested objects. Make a GET request to a URL in this format: https://spreadsheets.google.com/feeds/list/126o06NkYz3rLRrIbzKAeLtrK-4a_Eosccmoser11hnk/od6/public/values?alt=json, and pass the resulting JSON to this function.
function prettifyGoogleSheetsJSON(data) {
for (var i = 0; i < data.feed.entry.length; i++) {
for (var key in data.feed.entry[i]) {
if (data.feed.entry[i].hasOwnProperty(key) && key.substr(0,4) === 'gsx$') {
// copy the value in the key up a level and delete the original key
data.feed.entry[i][key.substr(4)] = data.feed.entry[i][key].$t;
delete data.feed.entry[i][key];
}
}
}
{
"content_item": {
"id": 81424633,
"create_time": "2014-09-19T23:36:06Z",
"last_modified_time": "2014-09-20T22:58:13Z",
"expire_time": null,
"slug": "la-me-pc-gov-brown-disposes-of-bills-20140919",
"title": "Governor disposes of mandating diaper changing stations in men's rooms",
"display_time": "2014-09-20T00:02:00Z",
"ad_keywords": null,
@liddiard
liddiard / blank_template.html
Last active July 7, 2017 01:10
Blank starter validated HTML5 template. Features: UTF-8 encoding, meta description, Open Graph tags, favicon, Google Fonts, jQuery (pinned to a specific version), links to an external user-generated CSS and JavaScript file.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="favicon.ico" rel="icon" type="image/x-icon" />
<title>Page title</title>
<meta name="description" content="Page description, shows up in search results. Should be no longer than 150-160 characters." />
hliddiard@ubuntu:~$ npm update -g yo
npm http GET https://registry.npmjs.org/yo
npm http 304 https://registry.npmjs.org/yo
hliddiard@ubuntu:~$ yo --version
1.1.2
hliddiard@ubuntu:~$
@liddiard
liddiard / base.html
Created September 14, 2014 06:20
Boilerplate base HTML for Django
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="{% block meta_description %}Default meta description here.{% endblock %}">
<title>{% block title %}Default title here{% endblock %}</title>
<link rel="icon" type="image/x-icon" href="{{ STATIC_URL }}img/favicon.ico">
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/main.css">
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
(function($) {
/*!
A very simplified version of:
Name: Reading Time
Dependencies: jQuery
Author: Michael Lynch
Author URL: http://michaelynch.com
Date Created: August 14, 2013
Date Updated: January 24, 2014