Skip to content

Instantly share code, notes, and snippets.

View hanleybrand's full-sized avatar

Peter Hanley hanleybrand

View GitHub Profile
@hanleybrand
hanleybrand / mdid_admin_tricks_pres_perms.py
Created February 28, 2014 22:06
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
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 August 29, 2015 14:01
Environment debugging for MDID3 - paste this to the bottom of your settings_local.py and run the server with `python manage.py run server`
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 August 29, 2015 14:01
mdid django 1.6 test.sh errors
## 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
@hanleybrand
hanleybrand / mdid_init.sh
Last active August 29, 2015 14:01
mdid_init_d
#!/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 16:12
updated_dj16_test_results
$ ./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 13:45
Django [copy database] - management command
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 August 29, 2015 14:02 — 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
(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 July 2, 2014 16:51
traceback for stackoverflow question
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 August 29, 2015 14:06
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
@hanleybrand
hanleybrand / min max dates on bb learn activity accumulator tables.sql
Created December 15, 2014 15:05
Blackboard Learn Activity Accumulator - min/max dates (bb60 schema)
-- 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;