Skip to content

Instantly share code, notes, and snippets.

David Reaver jdreaver

Block or report user

Report or block jdreaver

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jdreaver / Master database
Last active Sep 19, 2017
Slow INNER JOIN planning time
View Master database
localhost [classroom_prod] # EXPLAIN ANALYZE SELECT * FROM knowledge_snapshots ks INNER JOIN answers a ON a.knowledge_snapshot_id = WHERE ks.student_id = 7538860;
Nested Loop (cost=0.87..2899.01 rows=235 width=105) (actual time=0.095..5.197 rows=72 loops=1)
-> Index Scan using knowledge_snapshots_parent_student_id_created_at_idx on knowledge_snapshots ks (cost=0.43..95.05 rows=26 width=53) (actual time=0.047..0.086 rows=6 loops=1)
Index Cond: (student_id = 7538860)
-> Index Scan using answers_parent_knowledge_snapshot_id_idx on answers a (cost=0.44..106.56 rows=128 width=52) (actual time=0.838..0.845 rows=12 loops=6)
Index Cond:
View Long planning time
db-standby-1-prod [classroom_prod] # EXPLAIN ANALYZE SELECT "math_adaptive_assignment_sessions"."student_id", "math_adaptive_assignments"."domain_id", count (*) FROM "math_adaptive_assignments" INNER JOIN "math_adaptive_assignment_sessions" ON "math_adaptive_assignments"."id" = "math_adaptive_assignment_sessions"."assignment_id" INNER JOIN "knowledge_snapshots" ON "math_adaptive_assignment_sessions"."knowledge_snapshot_id" = "knowledge_snapshots"."id" INNER JOIN "answers" ON "knowledge_snapshots"."id" = "answers"."knowledge_snapshot_id" WHERE ("math_adaptive_assignment_sessions"."student_id" IN (7538860)) AND (("math_adaptive_assignment_sessions"."completed_at" >= '2017-09-08 08:00:00Z') AND (("math_adaptive_assignment_sessions"."completed_at" <= '2017-09-08 18:02:08.431692Z') AND ("answers"."correctness" >= 100.0))) GROUP BY "math_adaptive_assignment_sessions"."student_id", "math_adaptive_assignments"."domain_id";
jdreaver /
Created Oct 31, 2014
DoubleSlider for PyQt/PySide
from PySide import QtGui
class DoubleSlider(QtGui.QSlider):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Set integer max and min. These stay constant.
self._max_int = 10000
jdreaver /
Last active Apr 24, 2017
A Scientific Notation Double Spin Box for PyQt/PySide
# Regular expression to find floats. Match groups are the whole string, the
# whole coefficient, the decimal part of the coefficient, and the exponent
# part.
_float_re = re.compile(r'(([+-]?\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?)')
def valid_float_string(string):
match =
return match.groups()[0] == string if match else False
You can’t perform that action at this time.