Skip to content

Instantly share code, notes, and snippets.

View bradenmacdonald's full-sized avatar

Braden MacDonald bradenmacdonald

View GitHub Profile
@bradenmacdonald
bradenmacdonald / test.py
Created October 19, 2021 00:04
Test new MySQL-based Split Mongo modulestore Case Sensitivity
from datetime import datetime
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from common.djangoapps.split_modulestore_django.models import SplitModulestoreCourseIndex
from bson.objectid import ObjectId
split_modulestore = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split)
course_index_common = {
"course": "TL101",
@bradenmacdonald
bradenmacdonald / openedx_client.py
Created May 11, 2021 01:36
Open edX API Client Example
"""
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
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';
/**
* 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
<!--
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
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 \
swagger: '2.0'
info:
title: BugReportAPI
version: v1
basePath: /api/v1
consumes:
- application/json
produces:
- application/json
paths:

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 June 13, 2018 18:03
Vagrantfile Optimized for Solutions devstack
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
#include <iostream>
#include <string>
using std::string;
string name = "Alice";
void foo() {
std::cout << "Hello " << name << std::endl;
}