Skip to content

Instantly share code, notes, and snippets.

Matthew Bernhardt matt-bernhardt

Block or report user

Report or block matt-bernhardt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@matt-bernhardt
matt-bernhardt / eds-widget-hours.html
Last active Mar 2, 2016
This is a generic template for a widget/placard displayed at the top of the BartonPlus (EBSCO Discovery Service) search results.
View eds-widget-hours.html
<div id="analysis" style="font-family:helvetica, verdana, tahoma;font-size:12px"><center>This widget is evaluating the search term </center></div>
<div id="mysearch" style="display:none">ep.SearchTerm</div>
<script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
var searchterm = document.getElementById('mysearch').innerHTML;
if(searchterm == "hours" || searchterm == "library hours" || searchterm == "Hours" || searchterm == "Library Hours"){
@matt-bernhardt
matt-bernhardt / eds-placard.html
Created Aug 23, 2013
This is a sample of a rendered placard within BartonPlus
View eds-placard.html
<div id="bartonplus_placard">
<h2><a href="http://libraries.mit.edu/locations">Hours and Locations</a></h2>
<ul class="inline">
<li><a href="http://libraries.mit.edu/barker">Barker Library</a></li>
<li><a href="http://libraries.mit.edu/dewey">Dewey Library</a></li>
<li><a href="http://libraries.mit.edu/hayden">Hayden Library</a></li>
<li><a href="http://libraries.mit.edu/archives">Institute Archives &amp; Special Collections</a></li>
<li><a href="http://libraries.mit.edu/music">Lewis Music Library</a></li>
<li><a href="http://libraries.mit.edu/rotch">Rotch Library</a></li>
</ul>
View placard_iframe_hours.html
<div><center>This widget is attempting to put an iframe into a custom placard area</center></div>
<div id="mysearch" style="display:none">ep.SearchTerm</div>
<script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
// functions
function CleanSearchTerm(strTerm) {
strTerm = strTerm.toLowerCase();
View potemkin.py
#!/usr/bin/env python
from __future__ import print_function
import json
import sys
from datetime import timedelta, datetime
from random import randint, choice
countries = ('004','008','010','012','016','020','024','028','031','032','036','040','044','048','050','051','052','056','060','064','068','070','072','074','076','084','086','090','092','096','100','104','108','112','116','120','124','132','136','140','144','148','152','156','158','162','166','170','174','175','178','180','184','188','191','192','196','203','204','208','212','214','218','222','226','231','232','233','234','238','239','242','246','248','250','254','258','260','262','266','268','270','275','276','288','292','296','300','304','308','312','316','320','324','328','332','334','336','340','344','348','352','356','360','364','368','372','376','380','384','388','392','398','400','404','408','410','414','417','418','422','426','428','430','434','438','440','442','446','450','454','458','462','466','470','474','478','480','484','492','496','498
@matt-bernhardt
matt-bernhardt / pullBartonPlusResults()
Last active Dec 30, 2015
An R function to extract event interaction data from Google Analytics
View pullBartonPlusResults()
pullBartonPlusResults <- function(GAprofile,startDate,endDate) {
# taken from http://stackoverflow.com/questions/6434663/r-why-does-looping-over-a-date-object-result-in-a-numeric-iterator
days <- seq(from=as.Date(startDate), to=as.Date(endDate),by='days')
result <- data.frame()
master <- data.frame()
for ( i in seq_along(days) )
{
@matt-bernhardt
matt-bernhardt / pullSearchesGA
Created Dec 9, 2013
An R script to pull search activity from Google Analytics
View pullSearchesGA
pullSearchesGA <- function(GAprofile,startDate,endDate) {
# taken from http://stackoverflow.com/questions/6434663/r-why-does-looping-over-a-date-object-result-in-a-numeric-iterator
days <- seq(from=as.Date(startDate), to=as.Date(endDate),by='days')
result <- data.frame()
master <- data.frame()
for ( i in seq_along(days) )
{
@matt-bernhardt
matt-bernhardt / sudoku.py
Last active Jan 4, 2016
A sudoku solver, as I teach myself Python
View sudoku.py
#
# Translating the sudoku solver from VBScript to Python
#
# Libraries
from xlrd import open_workbook
from tempfile import TemporaryFile
from xlwt import Workbook
import datetime
from array import *
@matt-bernhardt
matt-bernhardt / summarize.py
Last active Jan 4, 2016
This is a quick and crude summarizing script that assembles a summary collection on top of a raw requests collection - a loose part of the OA Stats project.
View summarize.py
# update summary data based on requests collection
# Imports
from pymongo import MongoClient
# Globals
log = ''
reqs = ''
sums = ''
@matt-bernhardt
matt-bernhardt / README.md
Last active Aug 29, 2015
Interactive Force Directed Graph
View README.md

A page with input sliders for the two primary parameters, LinkDistance and Charge. Adjusting either slider will momentarily stop the force animation, adjust the parameter, and then restart the animation with the new values.

View index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta charset="utf-8">
<title>Force based label placement</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.6.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.6.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.6.0"></script>
</head>
<body>
You can’t perform that action at this time.