Skip to content

Instantly share code, notes, and snippets.

View matt-bernhardt's full-sized avatar
💭
Learning Rails...

Matthew Bernhardt matt-bernhardt

💭
Learning Rails...
View GitHub Profile
@matt-bernhardt
matt-bernhardt / eds-widget-hours.html
Last active March 2, 2016 02:44
This is a generic template for a widget/placard displayed at the top of the BartonPlus (EBSCO Discovery Service) search results.
<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 August 23, 2013 18:42
This is a sample of a rendered placard within BartonPlus
<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>
@matt-bernhardt
matt-bernhardt / placard_iframe_hours.html
Last active December 22, 2015 20:39
BartonPlus Placards
<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();
#!/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 December 30, 2015 19:29
An R function to extract event interaction data from Google Analytics
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 December 9, 2013 16:10
An R script to pull search activity from Google Analytics
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 January 4, 2016 07:59
A sudoku solver, as I teach myself Python
#
# 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 January 4, 2016 17:39
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.
# update summary data based on requests collection
# Imports
from pymongo import MongoClient
# Globals
log = ''
reqs = ''
sums = ''
@matt-bernhardt
matt-bernhardt / README.md
Last active August 29, 2015 13:56
Interactive Force Directed Graph

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.

@matt-bernhardt
matt-bernhardt / index.html
Last active August 29, 2015 13:56 — forked from MoritzStefaner/.block
asdf
<!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>