from django.contrib.auth.models import AnonymousUser
from rooibos.storage.models import Storage
from rooibos.access.functions import filter_by_access
u = User.objects.get(pk=1)
au = AnonymousUser()
q = Storage
qo = Storage.objects.all()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Expensive queries ordered by CPU */ | |
| SELECT TOP 20 | |
| st.text, | |
| --qp.query_plan, | |
| qs.execution_count, | |
| qs.total_worker_time AS Total_CPU, | |
| total_CPU_inSeconds = --Converted from microseconds | |
| qs.total_worker_time/1000000, | |
| average_CPU_inSeconds = --Converted from microseconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Blocking Report */ | |
| SELECT t1.resource_type AS [lock type], db_name(resource_databASe_id) AS[database], | |
| t1.resource_ASsociated_entity_id AS [blk object], | |
| t1.request_mode AS [lock req], --lock requested | |
| t1.request_session_id AS [waiter sid], --spid of waiter | |
| t2.wait_duration_ms AS [wait time(ms)], | |
| (SELECT text FROM sys.dm_exec_requests AS r --get sql for waiter | |
| CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) | |
| WHERE r.session_id = t1.request_session_id) AS waiter_batch, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- I get | |
| -- IDENTITY_INSERT is already ON for table 'bb_bb60.dbo.group_attempt_files_prv'. Cannot perform SET operation for table 'attempt_prv' | |
| -- if I set it ON and | |
| -- Cannot insert explicit value for identity column in table 'attempt_prv' when IDENTITY_INSERT is set to OFF. | |
| SET IDENTITY_INSERT attempt_prv ON; | |
| INSERT INTO attempt_prv | |
| ([GRADEBOOK_GRADE_PK1], [PK1], [QTI_RESULT_DATA_PK1], [LINKREFID], [SCORE], | |
| [GRADE], [STUDENT_COMMENTS], [INSTRUCTOR_COMMENTS], [INSTRUCTOR_NOTES], [STATUS], | |
| [ATTEMPT_DATE], [DATE_ADDED], [DATE_MODIFIED], [LATEST_IND], [comment_public_ind], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ldap | |
| from django.conf import settings | |
| ldap_auth = settings.LDAP_AUTH[0] | |
| ldap_uri = ldap_auth['uri'] | |
| l_user = ldap_auth['bind_user'] | |
| l_pass = ldap_auth['bind_password'] | |
| searchScope = ldap_auth['scope'] | |
| base = ldap_auth['base'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use bb_bb60; | |
| declare @COURSEID varchar(200) | |
| declare @COURSEPK int | |
| set @COURSEID = '111111111111' | |
| set @COURSEPK = (select pk1 from course_main where course_id = '111111111111') | |
| print @coursePK | |
| SELECT * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| **Fix broken Group Assignments (T-SQL / bb_bb60) | |
| assumes step_0 is complete and that tables | |
| group_attempt_files_prv, attempt_prv and group_attempt_prv | |
| exist. see https://gist.github.com/hanleybrand/8ef04daac0e960b4da14 | |
| */ | |
| use bb_bb60; | |
| declare @COURSEID varchar | |
| set @COURSEID = '111111111111111' # replace with valid course id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Step 0 create preservation tables as a backup in case */ | |
| -- psql | |
| --CREATE TABLE group_attempt_files_prv | |
| -- AS (SELECT * FROM group_attempt_files WHERE 1=0); | |
| -- tsql | |
| SELECT gaf.* into group_attempt_files_prv | |
| FROM group_attempt_files gaf WHERE 1=0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def re_search(): | |
| and_dest = 'roy' | |
| return True | |
| # or even | |
| def re_search(): | |
| return 'and_destroy' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fake_distinct_for_model_field_values(dj_model, field_name): | |
| """ | |
| Perform a fake distinct query on the value_list of a model's objects | |
| example: from myapp.models import ActivityLog | |
| import fake_distinct_for_model_field_values as fake_dist | |
| fake_dist(ActivityLog, 'event_types') | |
| >>> [u'login', u'media-download', u'media-thumbnail', u'media-download-image'] | |
| """ | |
| output = set() | |
| for x in dj_model.objects.values_list(field_name): |