Skip to content

Instantly share code, notes, and snippets.

View jayniz's full-sized avatar
💭
I like turtles!

Jannis Hermanns jayniz

💭
I like turtles!
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jayniz on github.
  • I am jannis (https://keybase.io/jannis) on keybase.
  • I have a public key whose fingerprint is 8D06 217E 8BAC E560 25CE 72D5 136E 7814 92D7 064F

To claim this, I am signing this object:

Eins, zwei, drei und die für '
Snoop Doggy Dogg und Dr. Dre ist am do '
Bereit zum Eingang machen, um wieder auf bis
[Weil Sie wissen, dass wir 'bout zerreißen shit up]
Gimme das Mikrofon erste, so dass ich Büste einer Blase wie kann
Compton und Long Beach zusammen, jetzt wissen Sie, in Schwierigkeiten
Ain't Nothin 'But a G thang, baaaaabay!
Zwei loc'ed aus nigga's so sind wir craaaaazay!
{196=>50, 1768=>0, 327=>80, 2030=>60, 262=>25, 7074=>65, 6485=>50, 1376=>10, 10153=>60, 394=>0, 329=>40, 591=>45, 6748=>0, 2425=>55, 9172=>75, 5373=>45, 5635=>65, 1443=>0, 2=>50, 4456=>80, 199=>75, 2557=>85, 4129=>85, 68=>70, 6029=>90, 11662=>85, 3344=>50, 1969=>75, 6554=>10, 1183=>80, 332=>70, 201=>0, 19393=>80, 4721=>70, 6293=>70, 4328=>50, 20769=>70, 7407=>90, 202=>80, 3150=>40, 7408=>60, 19395=>80, 531=>60, 4985=>40, 5509=>80, 7=>65, 5313=>70, 5444=>75, 7409=>90, 3545=>70, 1056=>75, 5510=>65, 3021=>25, 139=>0, 8916=>20, 270=>40, 24702=>65, 18152=>0, 2432=>50, 926=>60, 5773=>40, 5904=>0, 861=>80, 1385=>80, 4660=>80, 3219=>70, 337=>25, 18350=>80, 4988=>65, 3678=>0, 272=>85, 2434=>60, 5709=>35, 1779=>20, 4792=>60, 3679=>90, 11=>30, 273=>90, 8068=>50, 19531=>35, 1060=>80, 2632=>65, 2436=>60, 1257=>65, 1781=>70, 4925=>0, 5515=>10, 6629=>85, 865=>90, 2437=>60, 996=>80, 5450=>70, 5581=>70, 1258=>70, 1520=>70, 1913=>85, 3485=>0, 6695=>25, 276=>20, 407=>80, 2110=>45, 997=>25, 9774=>75, 1259=>75, 7154=>80, 211=>85,
@jayniz
jayniz / Nested set indented tree select.sql
Created September 15, 2010 10:48
Nested set indented tree output in SQL
-- Indented output, like a tree
SELECT CONCAT(REPEAT(' ', count(*)-1), node1.name)
FROM genres AS node1,
genres AS node2
WHERE node1.lft BETWEEN node2.lft AND node2.rgt
GROUP BY node1.LFT;
-- Unindented but with level (for corrupt data)
SELECT node1.name, COUNT(*) AS level
FROM genres AS node1,

== Nested Set integrity check ==

Does a quick checksum check on a nested set tree. Adds all left and right values to check they sum up to the correct values and does some other little checks.

mysql> SELECT

              #
              # The sum of all lft and rgt values should add up (does not guarantee
              # correct structure, but is good at catching borked data.

futex(0x40339cf4, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x40339cf0, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
futex(0x7f8430112ba4, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x7f8430112ba0, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
futex(0x7f84300c8470, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x4033a184, FUTEX_WAIT_PRIVATE, 1662871845, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x7f84301128c0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x40339cf4, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x40339cf0, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
futex(0x7f8430068cd0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x4033a184, FUTEX_WAIT_PRIVATE, 1662871847, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x7f84301128c0, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x4033a184, FUTEX_WAIT_PRIVATE, 1662871849, NULL) = -1 EAGAIN (Resource temporarily unavailable)
Date/Time: 2011-05-06 17:49:29 +0200
OS Version: 10.6.7 (Build 10J869)
Architecture: x86_64
Report Version: 7
Command: Tomahawk
Path: /Applications/Tomahawk.app/Contents/MacOS/Tomahawk
Version: 0.0.3 (0.0.3.0)
Parent: launchd [160]
futex(0x2506654, FUTEX_WAIT_PRIVATE, 59255, NULL) = 0
futex(0x2506628, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x1e0c954, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x1e0c950, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
futex(0x1e0c928, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x1e05854, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x1e05850, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
futex(0x2506654, FUTEX_WAIT_PRIVATE, 59257, NULL) = 0
futex(0x2506628, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x1e0c954, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x1e0c950, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
futex(0x1e0c928, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x1e05854, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x1e05850, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
t = Jogger.new(my_pacer_vertex)
t.in(:friends)
t.filter(gender: 'female')
t.out(:likes)
t.filter(type: 'Movie')
t.sort_by{ |v, c| -c }
t.group_count{ |v| v }
t = Jogger.new(my_pacer_vertex)
t.friends(:female)
t.top_list(:movies)