Skip to content

Instantly share code, notes, and snippets.


David Collien dcollien

View GitHub Profile
dcollien / index.html
Last active May 5, 2020
xAPI iFrame Example
View index.html
<!DOCTYPE html>
<meta charset="UTF-8">
<title>xAPI Form Example</title>
<!-- xAPI base functionality, from: -->
<script src="tincan-min.js"></script>
<!-- Setting up the xAPI connection from launch data -->
<script src="xapi-interface.js"></script>
dcollien / AnimatedCanvas.tsx
Last active Feb 12, 2020
Animated Canvas Component
View AnimatedCanvas.tsx
import React, { useRef, useEffect, useCallback, useState } from "react";
type UpdateHandler = (dt: number) => void;
type ContextRenderer = (ctx: CanvasRenderingContext2D) => void;
export interface IAnimatedCanvasProps {
width: number;
height: number;
onFrame: UpdateHandler;
render: ContextRenderer;
View shouldtranscode.ts
Moved to:
View xapi_test.html
<title>Simple xAPI Example</title>
<script src="tincan-min.js"></script>
<p>This is an xAPI Example</p>
<button type="button" id="complete-button">Send Completion Statement</button>
<span id="status"></span>
import time
import urllib.parse
import hmac
import hashlib
import base64
SB_NAME = "ol-events"
EH_NAME = "ol-user-metrics"
SAS_NAME = "collect-user-metric"
from datetime import datetime
import re
import string
def to_course_code(course_path, creation_date):
Turns a course path into a short course code.
Max 14 characters (but likely under 10).
Not guaranteed to be unique
but has month/year of creation date, and single character hash
View curry_uncurry.js
const uncurry = (fn) => (...args) => args.reduce((fn, arg) => fn(arg), fn);
const curry = (fn) => {
const collect = (args, arg) => {
const collected = args.concat([arg]);
return (
collected.length >= fn.length
? fn.apply(null, collected)
: collect.bind(null, collected)
dcollien /
Last active Sep 12, 2018
ESP8266 Traffic Lights
import socket
import network
import time
CONTENT = b"""\
HTTP/1.0 200 OK
<!doctype html>
dcollien /
Last active Aug 22, 2018
Simple Text Classification using NLTK Naive Bayes and TextRank
import nltk
from summa.keywords import keywords
def get_features(text):
# get the top 80% of the phrases from the text, scored by relevance
return dict(keywords(text, ratio=0.8, split=True, scores=True))
def train_texts(classified_texts):
# process the training set
features = []
dcollien /
Last active Aug 16, 2018
OAuth2.0 Sign-On for various providers, and retrieving user details: id, name, email, photo
class Config(object):
def __init__(self, **entries):
self._entries = entries
def __repr__(self):
return "Config(%s)" % str(self._entries)
def __getattr__(self, value):
return None
You can’t perform that action at this time.