Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I'm in the middle of some calibrations

Braden MacDonald bradenmacdonald

💭
I'm in the middle of some calibrations
View GitHub Profile
@bradenmacdonald
bradenmacdonald / openedx_client.py
Created May 11, 2021
Open edX API Client Example
View openedx_client.py
"""
API Client used to make requests from Open edX
Originally created by OpenCraft for LabXchange, www.labxchange.org
You may use this under the terms of the Apache 2 license,
https://www.apache.org/licenses/LICENSE-2.0
"""
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
View update-api-client.sh
OPENAPI_CODEGEN_VERSION=4.0.0-beta2
OPENAPI_JAR=../.openapi-generator-cli-${OPENAPI_CODEGEN_VERSION}.jar
OPENAPI_DOWNLOAD_BASE_URL="http://central.maven.org/maven2/org/openapitools/openapi-generator-cli"
if [ ! -f $OPENAPI_JAR ]; then
curl ${OPENAPI_DOWNLOAD_BASE_URL}/${OPENAPI_CODEGEN_VERSION}/openapi-generator-cli-${OPENAPI_CODEGEN_VERSION}.jar \
> $OPENAPI_JAR
fi
java -jar $OPENAPI_JAR generate \
View api-spec.yaml
swagger: '2.0'
info:
title: BugReportAPI
version: v1
basePath: /api/v1
consumes:
- application/json
produces:
- application/json
paths:
View React Content Theming Proposal for Open edX.md

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
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`"
end
VAGRANTFILE_API_VERSION = "2"
MEMORY = 4096
CPU_COUNT = 2
View hello.cpp
#include <iostream>
#include <string>
using std::string;
string name = "Alice";
void foo() {
std::cout << "Hello " << name << std::endl;
}
@bradenmacdonald
bradenmacdonald / update_anonymous_user_ids.py
Last active Feb 9, 2017
Open edX Platform PR #14102: A management command to update the anonymous IDs in the database
View update_anonymous_user_ids.py
# 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.
#