Skip to content

Instantly share code, notes, and snippets.

@zavan
zavan / yt.js
Last active September 9, 2024 14:48
Listening to the YouTube Embed Iframe time change events without polling player.getCurrentTime()
// Load the IFrame Player API code asynchronously.
var tag = document.createElement("script");
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Instantiate the Player.
function onYouTubeIframeAPIReady() {
var player = new YT.Player("player", {
@alee
alee / views.py
Last active October 18, 2024 14:20
example Django view function that can be used for Discourse SSO, i.e., Discourse delegates User authentication to Django
import base64
import hmac
import hashlib
from urllib import parse
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseBadRequest, HttpResponseRedirect
from django.conf import settings
@login_required
# couple things I'd throw in there:
# moar whitespace
res = [
[
[
kriger.predict(x,y,z)
for x in grid[0]
]
for y in grid[1]
]