Skip to content

Instantly share code, notes, and snippets.

I'm in the middle of some calibrations

Braden MacDonald bradenmacdonald

I'm in the middle of some calibrations
View GitHub Profile
bradenmacdonald /
Created May 11, 2021
Open edX API Client Example
API Client used to make requests from Open edX
Originally created by OpenCraft for LabXchange,
You may use this under the terms of the Apache 2 license,
import logging
View Block.tsx
import { bind } from 'bind-decorator';
import * as React from 'react';
import { XBlocksApi } from 'global/api';
import styles from 'global/styles';
import uiMessages from 'ui/components/displayMessages';
import { WrappedMessage } from 'utils';
import messages from '../../displayMessages';
import { wrapBlockHtmlForIFrame } from './wrap';
View wrap.ts
* Code to wrap an XBlock so that we can embed it in an IFrame
declare const LMS_BASE_URL: string;
import * as xblockCssPath from './xblock-styles.scss';
* Given an XBlock's fragment data (HTML plus CSS and JS URLs), return the
* inner HTML that should go into an IFrame in order to display that XBlock
View xblock-bootstrap.html
This file is meant to be hosted on a completely separate domain name
from the LMS / frontend that is hosting the Open edX content (XBlocks).
Doing so allows us to enable features like cookies in the sandboxed
IFrame while keeping the XBlock content on a distinct origin, so that
the XBlock cannot access user data from the host application (like
cookies nor call APIs as the user).
This particular sandboxing code uses the secure message passing API
if [ ! -f $OPENAPI_JAR ]; then
java -jar $OPENAPI_JAR generate \
View api-spec.yaml
swagger: '2.0'
title: BugReportAPI
version: v1
basePath: /api/v1
- application/json
- application/json
View React Content Theming Proposal for Open

React guidelines to support content theming in Open edX (Braden's proposal)

  1. Build the UI out of small, modular React components as much as possible.
  2. Build two types of components: "customizable" ones that only compose others using JSX and contain little-or-no HTML nor logic, as well as "internal" components that contain logic and detailed HTML and CSS, etc.
  3. In customizable components, include placeholders like {this.extraContent} in the render() method so that subclasses don't have to override render().

Bad example:

bradenmacdonald / Vagrantfile
Last active Jun 13, 2018
Vagrantfile Optimized for Solutions devstack
View Vagrantfile
Vagrant.require_version ">= 1.8.7"
unless Vagrant.has_plugin?("vagrant-vbguest")
raise "Please install the vagrant-vbguest plugin by running `vagrant plugin install vagrant-vbguest`"
MEMORY = 4096
View hello.cpp
#include <iostream>
#include <string>
using std::string;
string name = "Alice";
void foo() {
std::cout << "Hello " << name << std::endl;
bradenmacdonald /
Last active Feb 9, 2017
Open edX Platform PR #14102: A management command to update the anonymous IDs in the database
# When changing the `SECRET_KEY` of an instance, all anonymous user ids change as well.
# Since #13717 the new anonymous ids are stored in the database in addition to the old
# ones, so both the old and the new anonymous ids can be inverted.
# This has the negative side effect that e.g. ORA submissions and grades for the same
# student are now stored under two different ids, so they don't show up correctly
# anymore in the web interface. For Open edX installations that are not too big, the
# problem can be solved by running the management command in this PR, which translates
# all IDs in the database to the new values.