Skip to content

Instantly share code, notes, and snippets.

Avatar

David Collien dcollien

View GitHub Profile
@dcollien
dcollien / index.html
Last active May 5, 2020
xAPI iFrame Example
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>xAPI Form Example</title>
<!-- xAPI base functionality, from: https://github.com/RusticiSoftware/TinCanJS/blob/master/build/tincan-min.js -->
<script src="tincan-min.js"></script>
<!-- Setting up the xAPI connection from launch data -->
<script src="xapi-interface.js"></script>
@dcollien
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: https://github.com/dcollien/mp4filechecker/blob/master/src/index.ts
View xapi_test.html
<html>
<head>
<title>Simple xAPI Example</title>
<script src="tincan-min.js"></script>
</head>
<body>
<p>This is an xAPI Example</p>
<button type="button" id="complete-button">Send Completion Statement</button>
<span id="status"></span>
<script>
View generate_sas_token.py
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"
SAS_VALUE = "EXAMPLE-TOKEN"
View coursecode.py
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
dcollien / config.py
Last active Sep 12, 2018
ESP8266 Traffic Lights
View config.py
import socket
import network
import time
CONTENT = b"""\
HTTP/1.0 200 OK
<!doctype html>
<html>
@dcollien
dcollien / classify_text.py
Last active Aug 22, 2018
Simple Text Classification using NLTK Naive Bayes and TextRank
View classify_text.py
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
dcollien / config.py
Last active Aug 16, 2018
OAuth2.0 Sign-On for various providers, and retrieving user details: id, name, email, photo
View config.py
class Config(object):
def __init__(self, **entries):
self.__dict__.update(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.