Skip to content

Instantly share code, notes, and snippets.

View ankona's full-sized avatar
🏠
Working from home

Chris McBride ankona

🏠
Working from home
View GitHub Profile
@ankona
ankona / js_list_props.js
Created April 11, 2014 13:59
JS to list methods / properties on a javascript object
var obj = document.getElementById('flashObj');
for(var prop in obj){
var fx = obj[prop];
if(obj.hasOwnProperty(prop) && (typeof fx == 'function') && /eval\(instance/.test(fx)){
console.log(prop)
}
}
@ankona
ankona / gist:7b3587ee6bd005cf9604
Created July 1, 2014 22:05
test harness for requesting launch URLs from UCMS
import webapp2
from lib import auth
from lib import keys
import logging
# call the UCMS launch URL endpoint and retrieve the url to open the KAPx session with the supplied UCMS ID.
def get_launch_url(ucms_id, headers):
krc = auth.KapRestClient(keys.AuthKeys.AUTH_PREFIX,
keys.AuthKeys.SECRET_KEY,
@ankona
ankona / global_lc.js
Created July 30, 2014 20:26
create global literally canvas variable
$('.literally.index').literallycanvas({
backgroundColor: 'whiteSmoke',
onInit: function(lc) {
window.lc = lc; }
});
@ankona
ankona / remote_snippet.py
Created July 31, 2014 17:38
open remote env in python
from lib.remoteapi import env_picker
from models import Course
env_picker()
# enter the info that it asks you to enter
for course in Course.query():
print course.session_opaqueID
@ankona
ankona / gist:e485c79dc2a7ce1765f6
Created October 24, 2014 19:19
new dbparticipant json
{
"client_sys_id": "TestInstructor",
"email": "instructor@test.com",
"first_name": "Test",
"last_name": "Instructor",
"role_id": "1",
"username": "Instructor"
}
{
@ankona
ankona / gist:ba350040ad40e3d962eb
Created October 30, 2014 14:54
update DBSession to comply with fields newly configured as required
from google.appengine.ext import db
from datetime import datetime
# local override with start not being required
class DBSession(db.Model):
start = db.DateTimeProperty()
title = db.StringProperty()
for s in DBSession.all():
save_it = False
@ankona
ankona / gist:b90c2a1445696461537e
Last active August 29, 2015 14:15
nose larnin'
from tests import KapxDataSet
from datetime import datetime, timedelta
from models import DBAssetDefault, DBAsset, DBSession
__author__ = 'McBride'
_now_datetime = datetime.now()
class DBSessionData(KapxDataSet):
class Meta:
@ankona
ankona / pil_image_direct_to_response_stream.py
Last active August 29, 2015 14:22
using a PIL.Image to write out to the response stream
from StringIO import StringIO
from google.appengine.api import images
out_stream = StringIO()
# put the data into a StringIO instance so we can manipulate it with PIL.Image
original_image_data = StringIO(source_img_response.read())
editable_image = Image.open(original_image_data)
editable_image.thumbnail((width, height), Image.ANTIALIAS)
editable_image.save(out_stream, "PNG")
@ankona
ankona / fix_sequence_numbers.py
Last active August 29, 2015 14:23
update TimelineEvent sequence_number for values imported incorrectly from Stream57
opaque_id = 'f6d43db7-d33f-409a-a791-f37a8a004b09'
offset = 0
from pprint import pprint
from datetime import datetime
from models import DBSession, SlideAnnotationEventArgs
from google.appengine.ext import ndb
class TimelineEvent(ndb.Expando):
@ankona
ankona / file_list_s3.py
Last active August 29, 2015 14:23
List all the files in an S3 bucket
AWS_ACCESS_KEY_ID = '' # todo: insert aws key.
AWS_ACCESS_KEY_SECRET = '' # todo: insert aws secret.
import os
import boto
import boto.s3
import os.path
import sys, getopt
import logging