# User talk:Danf

(→Sets: new section) |
|||

(3 intermediate revisions by 3 users not shown) | |||

Line 50: | Line 50: | ||

I've never seen anything like it. | I've never seen anything like it. | ||

+ | |||

+ | == hey dan == | ||

+ | |||

+ | Chris here. Good talking last night. Here's the deep learning site I mentioned. deeplearning4j.org. Curious to hear what you think. | ||

+ | |||

+ | == Bluetooth Dongle == | ||

+ | |||

+ | I think we have a BS009 from BlueSoleil | ||

+ | |||

+ | http://www.bluesoleil.com/products/H0001201304230001.html | ||

+ | |||

+ | == HTML5 Canvas Element == | ||

+ | |||

+ | Thought you might like to play around with this.. I just stumbeled on this shape hacking a grid together. | ||

+ | |||

+ | <html> | ||

+ | <head> | ||

+ | <title>@title</title> | ||

+ | <script type="text/javascript"> | ||

+ | function rect(ctx, grid, step, cur){ | ||

+ | ctx.lineTo(cur, 0) | ||

+ | ctx.lineTo(cur, grid) | ||

+ | ctx.lineTo(0, cur) | ||

+ | ctx.lineTo(grid, cur) | ||

+ | ctx.stroke() | ||

+ | if (cur < grid){ | ||

+ | rect(ctx, grid, step, cur+step) | ||

+ | } | ||

+ | } | ||

+ | function draw(grid){ | ||

+ | var canvas = document.getElementById('bg'); | ||

+ | if (canvas.getContext){ | ||

+ | var ctx = canvas.getContsext('2d'); | ||

+ | ctx.strokeStyle = '#808080'; | ||

+ | rect(ctx, grid, 20, 20) | ||

+ | } | ||

+ | } | ||

+ | </script> | ||

+ | <style type="text/css"> | ||

+ | canvas { border: 1px solid black; } | ||

+ | </style> | ||

+ | </head> | ||

+ | <body onload="draw(800);"> | ||

+ | <canvas id="bg" width="800" height="800"></canvas> | ||

+ | </body> | ||

+ | </html> | ||

+ | |||

+ | == Sets == | ||

+ | |||

+ | <pre> | ||

+ | from random import shuffle | ||

+ | # from itertools import combinations | ||

+ | |||

+ | def combinations(iterable, r): | ||

+ | pool = tuple(iterable) | ||

+ | n = len(pool) | ||

+ | if r > n: | ||

+ | return | ||

+ | indices = list(range(r)) | ||

+ | yield tuple(pool[i] for i in indices) | ||

+ | while True: | ||

+ | for i in list(range(r))[::-1]: | ||

+ | if indices[i] != i + n - r: | ||

+ | break | ||

+ | else: | ||

+ | return | ||

+ | indices[i] += 1 | ||

+ | for j in range(i+1, r): | ||

+ | indices[j] = indices[j-1] + 1 | ||

+ | yield tuple(pool[i] for i in indices) | ||

+ | |||

+ | def deck(): | ||

+ | r = list(range(3)) | ||

+ | d = [(a,b,c,d) for a in r for b in r for c in r for d in r] | ||

+ | shuffle(d) | ||

+ | return d | ||

+ | |||

+ | def deal(d, n): | ||

+ | if len(d) < n: | ||

+ | return [] | ||

+ | return [d.pop() for i in range(n)] | ||

+ | |||

+ | def is_set(trio): | ||

+ | att = lambda x: set(y[x] for y in trio) | ||

+ | atts = (att(x) for x in range(4)) | ||

+ | return all(len(x) != 2 for x in atts) | ||

+ | |||

+ | def sets(h): | ||

+ | return [trio for trio in combinations(h, 3) if is_set(trio)] | ||

+ | |||

+ | def pare(h, cards): | ||

+ | for c in cards: | ||

+ | h.remove(c) | ||

+ | |||

+ | def replace(h, d): | ||

+ | n = 12 - len(h) | ||

+ | if n == 0: | ||

+ | n = 3 | ||

+ | h.extend(deal(d, n)) | ||

+ | |||

+ | def round(d, h): | ||

+ | found_sets = sets(h) | ||

+ | while found_sets: | ||

+ | first_set = found_sets[0] | ||

+ | yield first_set | ||

+ | pare(h, first_set) | ||

+ | found_sets = sets(h) | ||

+ | replace(h, d) | ||

+ | |||

+ | def play(): | ||

+ | d = deck() | ||

+ | h = deal(d, 12) | ||

+ | found_sets = [] | ||

+ | num_rounds = 0 | ||

+ | while len(d) > 2: | ||

+ | num_rounds += 1 | ||

+ | print("round %d" % num_rounds) | ||

+ | for x in round(d, h): | ||

+ | print(x) | ||

+ | found_sets.append(x) | ||

+ | print("%d sets found in %d rounds" % (len(found_sets), num_rounds)) | ||

+ | |||

+ | play() | ||

+ | </pre> |

## Latest revision as of 20:33, 8 December 2015

https://www.noisebridge.net/index.php?namespace=2&invert=1&title=Special%3ARecentChanges

## Contents |

## [edit] Hi, Danf

Danf, it was a pleasure to meet you and Kevin last night. I just added a user page to this wiki. —Ben Kovitz (talk) 03:47, 27 May 2013 (UTC)

## [edit] New device for now

Hi Dan, my roommate lilly has borrowed me her MindWave Mobie. It has the same ThinGear chip, but talks over bluetooth, not RF. I have a bluetooth receiver on my laptop, but I reckon the dream machine does not. Either way we can use it to debug the plexer code you're writing. Also see https://github.com/robintibor/python-mindwave-mobile for an object oriented approach to reading data off sent by the ThinkGear. robintibor is more maticulous about data rows than akloister. See you at the pwn meeting tomorrow. User:bfb

## [edit] whatsup hacka?

howzit?

Nothing going tonight. Up late, needing sleep. See you tomorrow. PS found a light read on mind/brain sleep research in the 20th century, linked under current readings. -kevin

## [edit] ditto

Thanks Immonad (talk) 18:40, 31 July 2013 (UTC)

## [edit] this is an example of a note to say hello via wiki because email is a broken protocol, considered harmful, and depracatable

**say what ???** --Danf (**talk**) 01:18, 22 August 2013 (UTC)

## [edit] Good stuff

By golly have a listen

http://www.fourier-series.com/f-transform/index.html

## [edit] Connectivity Restored...

to switch 31, aka the collaboration station.

https://en.wikipedia.org/wiki/Foobar

## [edit] ???

def egcd(a, b): if a == 0: return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a) * y, y)

https://en.wikibooks.org/wiki/Algorithm_Implementation/Mathematics/Extended_Euclidean_algorithm

I've never seen anything like it.

## [edit] hey dan

Chris here. Good talking last night. Here's the deep learning site I mentioned. deeplearning4j.org. Curious to hear what you think.

## [edit] Bluetooth Dongle

I think we have a BS009 from BlueSoleil

http://www.bluesoleil.com/products/H0001201304230001.html

## [edit] HTML5 Canvas Element

Thought you might like to play around with this.. I just stumbeled on this shape hacking a grid together.

<html> <head> <title>@title</title> <script type="text/javascript"> function rect(ctx, grid, step, cur){ ctx.lineTo(cur, 0) ctx.lineTo(cur, grid) ctx.lineTo(0, cur) ctx.lineTo(grid, cur) ctx.stroke() if (cur < grid){ rect(ctx, grid, step, cur+step) } } function draw(grid){ var canvas = document.getElementById('bg'); if (canvas.getContext){ var ctx = canvas.getContsext('2d'); ctx.strokeStyle = '#808080'; rect(ctx, grid, 20, 20) } } </script> <style type="text/css"> canvas { border: 1px solid black; } </style> </head> <body onload="draw(800);"> <canvas id="bg" width="800" height="800"></canvas> </body> </html>

## [edit] Sets

from random import shuffle # from itertools import combinations def combinations(iterable, r): pool = tuple(iterable) n = len(pool) if r > n: return indices = list(range(r)) yield tuple(pool[i] for i in indices) while True: for i in list(range(r))[::-1]: if indices[i] != i + n - r: break else: return indices[i] += 1 for j in range(i+1, r): indices[j] = indices[j-1] + 1 yield tuple(pool[i] for i in indices) def deck(): r = list(range(3)) d = [(a,b,c,d) for a in r for b in r for c in r for d in r] shuffle(d) return d def deal(d, n): if len(d) < n: return [] return [d.pop() for i in range(n)] def is_set(trio): att = lambda x: set(y[x] for y in trio) atts = (att(x) for x in range(4)) return all(len(x) != 2 for x in atts) def sets(h): return [trio for trio in combinations(h, 3) if is_set(trio)] def pare(h, cards): for c in cards: h.remove(c) def replace(h, d): n = 12 - len(h) if n == 0: n = 3 h.extend(deal(d, n)) def round(d, h): found_sets = sets(h) while found_sets: first_set = found_sets[0] yield first_set pare(h, first_set) found_sets = sets(h) replace(h, d) def play(): d = deck() h = deal(d, 12) found_sets = [] num_rounds = 0 while len(d) > 2: num_rounds += 1 print("round %d" % num_rounds) for x in round(d, h): print(x) found_sets.append(x) print("%d sets found in %d rounds" % (len(found_sets), num_rounds)) play()