Skip to content

Instantly share code, notes, and snippets.

View cfbolz's full-sized avatar

CF Bolz-Tereick cfbolz

View GitHub Profile
@cfbolz
cfbolz / crashgdb.py
Created March 24, 2024 20:45
gdb commands for debugging pypy GC problems
import gdb
import sys
import re
import sys
import os.path
# the following is a hacked copy of pypy/tool/gdb_pypy.py
@cfbolz
cfbolz / nqueens.sql
Last active September 20, 2018 13:43
Faster CTE solution to eight queens puzzle in sqlite
-- follows this blog post:
-- http://www.andreas-dewes.de/en/2015/queens-of-the-data-age-abusing-common-table-expressions-to-solve-the-eight-queens-problem-in-sql/
-- but takes under a second, instead of many minutes
--
-- main idea: represent board as permutation of string '12345678',
-- where character at position i is a queen at position (i, s[i])
-- then only check diagonal attacks
-- (this approach is the one traditionally taken in eg Prolog)
with recursive
@cfbolz
cfbolz / gist:7799bba1031ef2e3f13d
Created July 7, 2014 15:07
diff type profiling cells pycket
diff --git a/pycket/values.py b/pycket/values.py
index ef11567..a2ca9de 100755
--- a/pycket/values.py
+++ b/pycket/values.py
@@ -42,12 +42,24 @@ class W_Object(object):
def eqv(self, other):
return self is other # default implementation
+from collections import defaultdict
+celltypes = defaultdict(int)
@cfbolz
cfbolz / gist:3d354b82245ad5b020f5
Created July 5, 2014 20:48
earley.rkt trace 0a0daff7b862f57d6460dadf6bab504090c41473
[f464b432d7e] {jit-log-opt-loop
# Loop 0 ((let ([AppRand1_fresh_221 (+ conf 1)]) (vector-ref state AppRand1_fresh_221))) : loop with 100 ops
[p0, p1]
+83: label(p0, p1, descr=TargetToken(140248750869264))
+83: guard_not_invalidated(descr=<Guard0x11bce20>) [p0, p1]
debug_merge_point(0, 0, '(+ conf 1)')
+83: guard_class(p0, 9625672, descr=<Guard0x11bd830>) [p0, p1]
+102: p3 = getfield_gc_pure(p0, descr=<FieldP pycket.small_list.ConsEnvSize2.inst__vals_1 32>)
+106: guard_class(p3, ConstClass(W_Fixnum), descr=<Guard0x11bd7c0>) [p0, p3, p1]
+118: i5 = getfield_gc_pure(p3, descr=<FieldS pycket.values.W_Fixnum.inst_value 8>)