Skip to content

Instantly share code, notes, and snippets.

View jdunne-kaplan's full-sized avatar

Jim Dunne jdunne-kaplan

  • Kaplan
  • Chicago, IL
View GitHub Profile
@jdunne-kaplan
jdunne-kaplan / BatchPPTConverterREADME.md
Created May 30, 2014 15:47
Batch PPT Converter README

Batch PPT Converter

This is a commandline tool used to convert PPT or PPTX files in bulk to HTML5 presentations for import into KAPx.

The tool takes as input the path to a simple CSV file describing the locations of PPT or PPTX files to be converted. The CSV file may be of one or two columns, the first is the relative path to the PPT/PPTX input file, and the second is optionally the output folder to store the HTML5 converted assets to. If the second column is omitted, an output folder is assumed based on the name of the input PPT/PPTX file but replaced with a ".html" extension.

During operation, the tool will write to two output CSV files named after the input CSV file and stored in the same folder, "filename.completed.csv" and "filename.failed.csv". These keep track of which PPT/PPTX conversions have succeeded and failed, respectively. The intent is to be able to recover the batch process in case of random failures. These output files are not read by the converter tool so it is up to t

@jdunne-kaplan
jdunne-kaplan / demo-deploy.sh
Created September 9, 2014 17:24
kapx-courses deploy script
#!/bin/bash
branch=`git rev-parse --abbrev-ref HEAD`
if [[ $branch != "kapx-"* ]]; then
echo "Branch name '$branch' does not start with 'kapx-'."
exit
fi
bin/appcfg --application=kapx-live-demo --version=$branch update kapx_courses
@jdunne-kaplan
jdunne-kaplan / migrate.py
Last active August 29, 2015 14:06
timeline_version migration
import models
import datetime
import time
from google.appengine.ext import ndb
# Upgrade sessions and set timeline_version to 1
#sessions = models.DBSession.all().run()
#for s in sessions:
# if s.timeline_version:
# continue
@jdunne-kaplan
jdunne-kaplan / clear-versions.py
Last active August 29, 2015 14:08
Clear all timeline versions
from google.appengine.api import memcache
from google.appengine.ext import ndb
import models
memcache.flush_all()
opaqueID = "jsd-1"
s = models.DBSession.get_by_key_name(opaqueID)
s.timeline_version = 1
s.edit_timeline_version = None
@jdunne-kaplan
jdunne-kaplan / export_deck.py
Last active August 29, 2015 14:09
Import SlideDeck
import models
import json
from lib.utils import DateTimeJSONEncoder
d = models.SlideDeck.get_by_id("47cabc7c-3b06-48fb-9f85-b7a194a7c6d1")
print json.dumps(d.to_dict(), cls=DateTimeJSONEncoder)
@jdunne-kaplan
jdunne-kaplan / tle_report.py
Created December 2, 2014 16:40
Production debug TLEs
import models
opaqueID = "55a3d0f9-760f-46c7-b0fb-a0162fa383f8"
start_tle = models.TimelineEvent.query(models.TimelineEvent.opaque_id == opaqueID, models.TimelineEvent.event_type == "eventStart").get()
#print start_tle
tles = models.TimelineEvent.query(models.TimelineEvent.opaque_id == opaqueID).order(models.TimelineEvent.sequence_number).fetch()
for tle in tles:
print "{: 10.3f}\t{:<16}\t{:>9}".format((tle.start - start_tle.start).total_seconds(), tle.event_type, len(tle.drawing_args.drawing) if hasattr(tle, "drawing_args") and tle.drawing_args.drawing is not None else "")
@jdunne-kaplan
jdunne-kaplan / talkbacks.py
Created December 4, 2014 02:42
List talkbacks
import models
from lib.talkback import Talkback
tbs = Talkback.query(Talkback.opaque_id == "ec18060e-f4e4-4246-bc29-3f5579611f09").order(-Talkback.created_at).fetch()
for tb in reversed(list(tbs)):
print ""
print tb.submitted_by, tb.created_at
print "Q: " + tb.submission.strip()
if tb.response:
print "A: " + tb.response.strip()
@jdunne-kaplan
jdunne-kaplan / instructor-server-delta.py
Created December 8, 2014 19:08
Instructor to server timeline deltas
import models
tles = models.TimelineEvent.query(models.TimelineEvent.opaque_id == "d9db9bda-0349-4327-8709-e7fe0276abde").order(models.TimelineEvent.sequence_number).fetch()
first_tle = tles[0]
for tle in tles:
seq_delta = (tle.sequence_number - first_tle.sequence_number) / 1000.0
srv_delta = (tle.start - first_tle.start).total_seconds()
print "{: 10.3f}\t{: 10.3f}\t{: 10.3f}".format(seq_delta, srv_delta, seq_delta - srv_delta)
import models
from lib.utils import AsyncBatchUpdateManager
from lib.utils import QueryBatchIterator
session = models.DBSession.get_by_key_name("18ceb0d6-52b7-4c67-b47c-ae72edfe4394")
print session.is_versioned
print ""
tles = models.TimelineEvent.query_unversioned(session)
@jdunne-kaplan
jdunne-kaplan / associate-slidedeck.py
Created February 2, 2015 20:01
Associate slide deck to session
import lib.session
opaque_id = "620-test-1"
a = lib.session.get_asset(opaque_id, "slidedecks")
print a.asset
# lib.session.save_asset(opaque_id, "slidedecks", {"deck_ids":["e7eb7111-30f7-4468-a334-4b87a7ac012a"]})
a = lib.session.get_asset(opaque_id, "slidedecks")