Skip to content

Instantly share code, notes, and snippets.

View clintonb's full-sized avatar

Clinton Blackburn clintonb

View GitHub Profile
@clintonb
clintonb / setup
Last active November 28, 2016 15:51
Create a new edx-platform superuser
sudo -u www-data /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/manage.py lms --settings aws create_user -s -p edx -e [email protected]
sudo -u www-data /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/manage.py lms --settings aws shell
from django.contrib.auth.models import User
me = User.objects.get(username="edxapp")
me.is_superuser = True
me.is_staff = True
me.save()
@clintonb
clintonb / reset_mongo.sh
Created June 29, 2015 20:51
edX devstack scripts
rm /edx/var/mongo/mongodb/mongod.lock
mongod -repair --config /etc/mongodb.conf
chown -R mongodb:mongodb /edx/var/mongo/.
/etc/init.d/mongod start
@clintonb
clintonb / ecom-private.py
Last active April 5, 2018 10:34
E-Commerce + LMS Settings
# NOTE: I (CCB) use a hosts file to create ecommerce.local and lms.local. If you choose not to do this,
# replace ecommerce.local with localhost and lms.local with 127.0.0.1.
from django.conf import settings
from ecommerce.settings import get_lms_url
from ecommerce.settings.base import JWT_AUTH
ECOMMERCE_URL_ROOT = 'http://ecommerce.local:8002'
settings.LMS_URL_ROOT = 'http://lms.local:8000'
@clintonb
clintonb / cs_credit.py
Created April 11, 2015 12:39
Issue credit via CyberSource SOAP API
"""
This is a basic script to issue a credit via the CyberSource API.
Requirements:
suds (https://fedorahosted.org/suds/) [Install via pip]
References
* http://www.cybersource.com/developers/integration_methods/simple_order_and_soap_toolkit_api/soap_api/SOAP_toolkits.pdf
* http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SO_API/Credit_Cards_SO_API.pdf
* http://pydoc.net/Python/merchant-gateways/0.0.1/merchant_gateways.billing.gateways.cybersource/
@clintonb
clintonb / print_course_ids.py
Created February 26, 2015 15:41
Script to print all course IDs and the instance type of the course ID
# Get the courses from modulestore
from xmodule.modulestore.django import modulestore
courses = modulestore().get_courses()
# Loop through the ids and print the IDs and types
for course in courses:
print "{}, {}".format(course.id, type(course.id))
@clintonb
clintonb / gist:0f022e148c718c44d87d
Last active August 29, 2015 14:05
Proposed Design for Permissions
"""
Workflow:
1. User authenticates and OIDC provider returns permissions as comma-delimited list of globs.
2. When user access a course page, call has_access() to verify permissions.
If no permissions, view should raise a 403 error. This can be accomplished with a mixin added to our existing views.
"""
# models.py
class UserCoursePermissons(models.Model):
user = models.ForeignKey(User, primary_key=True) # Unsure if foreign key can also be primary key
@clintonb
clintonb / backends.py
Last active May 2, 2022 16:26
python-social-auth OpenID Connect Backend
"""
This file contains Django authentication backends. For more information visit
https://docs.djangoproject.com/en/dev/topics/auth/customizing/.
"""
from calendar import timegm
from datetime import datetime
from django.conf import settings
import jwt
from social.backends.oauth import BaseOAuth2
@clintonb
clintonb / courses.json
Created June 19, 2014 18:17
API HAL Response
// GET /api/edx.core/courses/edX+Open_DemoX+edx_demo_course
{
"course_id": "edX+Open_DemoX+edx_demo_course",
"name": "edX Demonstration Course",
"_links": {
"self": { "href": "/api/edx.core/courses/edX+Open_DemoX+edx_demo_course" },
"curies": [
{ "name": "edx.analytics", "href": "https://analytics-api.edx.org/docs/rels/{rel}", "templated": true },
{ "name": "edx.content", "href": "https://api.edx.org/api/edx.content/docs/rels/{rel}", "templated": true },
{ "name": "edx.videos", "href": "https://api.edx.org/api/edx.video/docs/rels/{rel}", "templated": true }
@clintonb
clintonb / 0_reuse_code.js
Created February 2, 2014 04:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@clintonb
clintonb / etc-salt-cloud
Created November 5, 2013 05:16
Example salt-cloud config
# Set Salt master
minion:
master: eng-salt-master.example.com
providers:
ec2:
provider: ec2
ssh_username: ec2-user
ssh_interface: private_ips