Skip to content

Instantly share code, notes, and snippets.

View bradenmacdonald's full-sized avatar

Braden MacDonald bradenmacdonald

View GitHub Profile
@bradenmacdonald
bradenmacdonald / update_anonymous_user_ids.py
Last active February 9, 2017 19:11
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.
#

Keybase proof

I hereby claim:

  • I am bradenmacdonald on github.
  • I am bradenm (https://keybase.io/bradenm) on keybase.
  • I have a public key whose fingerprint is 0832 4B93 0227 C5FA 85D3 86AD 2BDF 383C 42AB AB95

To claim this, I am signing this object:

@bradenmacdonald
bradenmacdonald / gist:148240764a1aede24ba50fae24119c7b
Created May 10, 2016 04:16
Backup instance_singlevmopenedxinstance
CREATE TABLE instance_singlevmopenedxinstance_backup (
id integer NOT NULL,
created timestamp with time zone NOT NULL,
modified timestamp with time zone NOT NULL,
sub_domain character varying(50) NOT NULL,
email character varying(254) NOT NULL,
name character varying(250) NOT NULL,
base_domain character varying(50) NOT NULL,
protocol character varying(5) NOT NULL,
branch_name character varying(50) NOT NULL,
from contextlib import contextmanager
from datetime import datetime
import time
def test_pass():
print('.')
time.sleep(0.5)
return True

As of: 2015-08-19

This is how to set up a combined devstack/insights virtualbox.

Run these commands on your host computer, in a new "combined-devstack" folder:

mkdir combined-devstack
cd combined-devstack
curl -L https://raw.githubusercontent.com/edx/configuration/master/vagrant/release/analyticstack/Vagrantfile > Vagrantfile
@bradenmacdonald
bradenmacdonald / gist:7796629
Last active December 30, 2015 07:29
Examples of extending CppSqlWrapper
#include "CppSqlWrapper.h"
#define INFO_TABLE "CoreInfo"
#ifndef SQL_BLOCK
#define SQL_BLOCK(a) #a
#endif
class Database : public SqlDatabase {
public:
Database();
virtual ~Database() {}
@bradenmacdonald
bradenmacdonald / temp_defines_debug.h
Created December 5, 2012 01:49
Marmalade Preprocessor definitions
#ifndef I3D_OS_S3E
# define I3D_OS_S3E 1
#endif
#ifndef I3D_PLATFORM_S3E
# define I3D_PLATFORM_S3E 1
#endif
#ifndef IW_APP_NAME
# define IW_APP_NAME "angelscript"
#endif
#ifndef IW_APP_VERSION
@bradenmacdonald
bradenmacdonald / __init__.py
Created May 9, 2012 03:50
Make Marmalade work with C++11 :-)
import Emitter
Emitter.Emitter.add_gcc_ccflags_orig = Emitter.Emitter.add_gcc_ccflags
def my_add_gcc_ccflags(obj, flag):
obj.add_gcc_ccflags_orig(flag)
obj.add_gcc_ccflags = obj.add_gcc_ccflags_orig
obj.add_gcc_ccflags("--cppflag=-std=c++0x")
Emitter.Emitter.add_gcc_ccflags = my_add_gcc_ccflags
@bradenmacdonald
bradenmacdonald / gist:2562364
Created April 30, 2012 20:19
Get infinite-scroll to send X-PJAX header.
$.infinitescroll.prototype.retrieve = function (pageNum) {
var instance = this,
opts = instance.options,
path = opts.path,
box, frag, desturl, method, condition,
pageNum = pageNum || null,
getPage = (!!pageNum) ? pageNum : opts.state.currPage;
beginAjax = function infscr_ajax(opts) {
// increment the URL bit. e.g. /page/3/
opts.state.currPage++;
@bradenmacdonald
bradenmacdonald / gist:1726771
Created February 3, 2012 00:40
Create synthetic data cube for testing astrodendro
#!/usr/bin/env python
import numpy as np
import pyfits
import math
import random
random.seed(5678) # consistent random seed
ri = random.randint
def export_data(data, desc, filename):