Skip to content

Instantly share code, notes, and snippets.

View Trott's full-sized avatar

Rich Trott Trott

View GitHub Profile
@Trott
Trott / gist:7271573
Created November 1, 2013 20:37
Using nc to proxy SSH through an intermediary server (here called intermediary.example.com). Put this in ~/.ssh/config and `ssh target` will do the trick.
Host target
ProxyCommand ssh -q intermediary.example.com nc target.example.com 22
{
"camelcase" : true,
"indent": 2,
"undef": true,
"quotmark": "single",
"maxlen": 80,
"trailing": true,
"curly": true
}
@Trott
Trott / gist:7681630
Last active December 29, 2015 14:09
Some operations for CSV in PHP
<?php
// Here's our multiline test CSV string:
$csv = <<<EOD
2012,Camel,1
2012,Marlboro,15
2013,Camel,15
2013,Marlboro,47
total,,78
EOD;
@Trott
Trott / gist:7778147
Last active March 20, 2024 19:16
Generated query from TUTD
DROP PROCEDURE IF EXISTS sp_create_and_display_exposures_table;
DELIMITER //
CREATE PROCEDURE sp_create_and_display_exposures_table() BEGIN
DROP TABLE IF EXISTS actlzd_vw_total_exposures_all_years;
CREATE TABLE actlzd_vw_total_exposures_all_years AS
@Trott
Trott / gist:7920434
Created December 11, 2013 23:27
Quick and dirty prototype for cross-off functionality in Moodle quizzes. Plenty of limitations to this and lots of suboptimal coding practices. But good enough for a quick demo and "something like this?" questions.
var answers = document.querySelectorAll('.multichoice .answer div');
for (var i=0, l=answers.length; i<l; i++) {
answers[i].appendChild(document.createTextNode('\u2717'));
answers[i].addEventListener('click', function( e ) {
if (e.target===this) {
if (this.getAttribute('style') === 'text-decoration: line-through') {
this.setAttribute('style', '');
} else {
this.setAttribute('style','text-decoration: line-through');
@Trott
Trott / gist:9559375
Last active August 29, 2015 13:57
Get all the eduPersonTargetedIDs that accessed UpToDate via EZProxy
grep -i uptodate spu* | grep proxy | cut -f3 | sort | uniq > uptodate.csv
@Trott
Trott / countdown.js
Created March 18, 2014 18:36
Timezone-independent countdown. Well, not a countdown, but you know, find out how long it is between now and the specified time.
// Get date object for the current time.
var now = new Date();
// Now let's get a timestamp for midnight UTC time.
// Well, one millisecond before midnight so we don't have to deal with incrementing.
var midnight = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), 23, 59, 59, 999);
// And the number of minutes until that time.
var diffInMinutes = Math.round((midnight - now.getTime()) / (1000 * 60));
@Trott
Trott / gist:76d6b584b2369cebd0b1
Created January 2, 2015 03:43
Stuff I've Been Doing Or Thinking About Lately
  • Someone asked me what I was working on. My answer was tedious even for me to listen to, so I set out to do something in my spare time that was at least energizing to me. Music Routes Playlist Generator Not sure there's anything groundbreaking here, but it's fun (for me, anyway) and I get to play with technologies that interest me (Web Components, Browserify, etc.)

  • Physical Web: Excited to try some stuff out at work but that's as far as I've gotten. I literally know nothing more than what I've seen in a talk or two and what I've read on a few websites.

  • Ageism in tech communities. I'll just stop there.

  • Making music, but I do that with instruments and not via high tech.

  • At work, I created a federated search tool and I gave a talk about it

@Trott
Trott / gist:9bd16aa06545356540a8
Created April 8, 2015 14:39
How Access To Library-Licensed Resources Should Work

Naively Proposed Solution

  1. All access goes through a proxy server. Publishers only need to allow the proxy server and nothing else. This simplifies management. You don't have to worry about expanding networks, remote networks for affiliated organizations, whether or not you should allow your VPN, and any other number of issues.
  2. The proxy server should use a single sign-on (SSO) service like Shibboleth.
  3. If you are on campus, and you authenticate onto your Wi-Fi network or your Active Directory domain or whatever, you are automatically authenticated via SSO as well. This way, you will immediately get access to licensed resources seamlessly.

Remaining Problems

  1. What about the situation where a colleague emails you a link or you otherwise have something that is not going through a proxy server?
  2. What about public workstations in the library and elsewhere that theoretically should have access based on their geographic location?
@Trott
Trott / gist:0e1230dee081c3c4bc7a
Last active August 29, 2015 14:18
Migrating from solr-security-proxy to solr-proxy for IDDL

Install solr-proxy

sudo env "PATH=$PATH" npm install -g solr-proxy

Edit /etc/init.d/solr-proxy

There's a bug in the current init script that prevents the proxy from stopping. Add tobacco to the end of the line that stops the proxy. In other words, change this:

runuser -c "$DAEMON stop $SERVER"