Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Hanley hanleybrand

View GitHub Profile
@hanleybrand
hanleybrand / mdid_admin_tricks_pres_perms.py
Created Feb 28, 2014
add 'authenticated users' (i.e. anyone logged in) read privileges to presentations (in django shell_plus) - can be edited and run, or copy/pasted into the shell
View mdid_admin_tricks_pres_perms.py
from rooibos.presentation.models import Presentation
from rooibos.access.models import ExtendedGroup, AUTHENTICATED_GROUP, AccessControl
from django.contrib.contenttypes.models import ContentType
from rooibos.contrib.tagging.models import Tag, TaggedItem
# lets get the stuff we need
# user (owner) - edit that, of course
usr = User.objects.get(username='someuser')
# content-type, in this case presentation
@hanleybrand
hanleybrand / add_to_settings_local.py
Last active Aug 29, 2015
Environment debugging for MDID3 - paste this to the bottom of your settings_local.py and run the server with `python manage.py run server`
View add_to_settings_local.py
import os
CL_DEBUG = True
PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
ROOIBOS_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__)))
# This will print a fair amount of information helpful for debugging an installation
# if CL_DEBUG = True at the beginning of this file
@hanleybrand
hanleybrand / out
Last active Aug 29, 2015
mdid django 1.6 test.sh errors
View out
## for this log I replaced my virtualenv path to ////////python/
## and the path to mdid is changed to ~~~~~~~~~~~~~~~~~~~>mdid_root/
## for visual purposes
$ ./test.sh
======CL_DEBUG=True=================================
__name__ = config.settings_local
__file__ = ~~~~~~~~~~~~~~~~~~~>mdid_root/config/settings_local.pyc
os.getpid() = 9262
View mdid_init.sh
#!/bin/bash
### this is a script for a user (with sudo privs if launching mysql) to run.
### it's a script I use for developing on a mac, so it will need tweaking to run
### on linux systems (i.e. it will need all of the init.d, service stuff addded)
###
### it requires an argument - start|stop|restart|procs|pids
### start|stop|restart are as expected,
### procs invokes pgrep -fl for solr, rabbitmq, mysql and "python manage.py runworkers"
### pids invokes pgrep -f for solr, rabbitmq, mysql and "python manage.py runworkers"
@hanleybrand
hanleybrand / test.sh_out
Created May 28, 2014
updated_dj16_test_results
View test.sh_out
$ ./test.sh
Scratch directory for this test session is /var/folders/b2/qyttf5ps2ysdcd7jwhj5s1fr0000gn/T/tmpqtkPbT
TESTING =========== 1 =================== 2 ================== 3
Creating test database for alias 'default' ('test_test_test_mdid')...
Syncing...
Creating tables ...
Creating table django_content_type
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
@hanleybrand
hanleybrand / copy_db.py
Created May 31, 2014
Django [copy database] - management command
View copy_db.py
from optparse import make_option
from django.core import serializers
from django.db.models import get_app, get_models
__author__ = 'mikhailturilin'
from django.core.management.base import BaseCommand
@hanleybrand
hanleybrand / webapp_vpat
Last active Aug 29, 2015 — forked from anonymous/webapp_vpat
Section 1194.22 Web-based Internet information and applications – Detail VPAT™ Voluntary Product Accessibility Template® source: http://www.itic.org/public-policy/accessibility
View webapp_vpat
(a) A text equivalent for every non-text element shall be provided (e.g., via "alt", "longdesc", or in element content).
(b) Equivalent alternatives for any multimedia presentation shall be synchronized with the presentation.
(c) Web pages shall be designed so that all information conveyed with color is also available without color, for example from context or markup.
(d) Documents shall be organized so they are readable without requiring an associated style sheet.
(e) Redundant text links shall be provided for each active region of a server-side image map.
(f) Client-side image maps shall be provided instead of server-side image maps except where the regions cannot be defined with an available geometric shape.
(g) Row and column headers shall be identified for data tables.
(h) Markup shall be used to associate data cells and header cells for data tables that have two or more logical levels of row or column headers.
(i) Frames shall be titled with text that facilitates frame identification and navigation
(j)
@hanleybrand
hanleybrand / gist:ee260b53dfb404f5055a
Created Jul 2, 2014
traceback for stackoverflow question
View gist:ee260b53dfb404f5055a
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/accounts/signup/
Django Version: 1.6.5
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
@hanleybrand
hanleybrand / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@hanleybrand
hanleybrand / min max dates on bb learn activity accumulator tables.sql
Created Dec 15, 2014
Blackboard Learn Activity Accumulator - min/max dates (bb60 schema)
View min max dates on bb learn activity accumulator tables.sql
-- checks the min/max dates on your activity accumulator tables
SELECT
MIN(prod.TIMESTAMP)as 'AA min date bb60'
, MAX(prod.TIMESTAMP) as 'AA max date bb60'
,(SELECT MIN(TIMESTAMP) FROM bb_bb60_stats.dbo.ACTIVITY_ACCUMULATOR) as 'AA min date bb60_stats'
,(SELECT MAX(TIMESTAMP) FROM bb_bb60_stats.dbo.ACTIVITY_ACCUMULATOR) as 'AA min date bb60_stats'
FROM bb_bb60.dbo.ACTIVITY_ACCUMULATOR prod;