RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/vAjdE
<crystal-gh> crystal/master e8916bc Benoit de Chezelles: Restore STDIN|OUT|ERR blocking state on exit (#5802)
DTZUZU has quit [Quit: WeeChat 1.9]
tilpner has quit [Quit: :wq]
tilpner has joined #crystal-lang
tilpner has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<travis-ci> crystal-lang/crystal#e8916bc (master - Restore STDIN|OUT|ERR blocking state on exit (#5802)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/351844174
<DeBot> https://github.com/crystal-lang/crystal/pull/5802 (Restore STDIN|OUT|ERR blocking state on exit)
snsei has quit [Ping timeout: 255 seconds]
tilpner has joined #crystal-lang
alex`` has quit [Ping timeout: 265 seconds]
<FromGitter> <watzon> Whoa, when did Crystal become C++?
<FromGitter> <watzon> Lol
<FromGitter> <bew> Really nice explanation for humans from @RX14 😄 https://github.com/crystal-lang/crystal/issues/2713#issuecomment-372079542
<RX14> np
<RX14> was fun to write
<RX14> plus writing stuff like that helps you to understand it a little better yourself
<FromGitter> <bew> yeah, I didn't know about what this flag really does (returning EAGAIN), ty :)
<FromGitter> <bew> @RX14 do you know macos a little bit?
<RX14> not really
<RX14> but it's 1:30am
<RX14> and I trally should be sleeping
<FromGitter> <bew> ahah go ahead, won't ask more questions!
<crystal-gh> [crystal] bew opened pull request #5804: Use llvm5 for darwin build in CI (master...use-llvm5-circleci-for-darwin-build) https://git.io/vAjNN
<RX14> nice pr
<FromGitter> <bew> yes but it's not working ^^ remove that approval
<RX14> approval means nothing if CI broke
<FromGitter> <bew> hmm it's just weird to approve changes if it shoudl fix CI and CI break
<RX14> it didn't fail when I approved it lol
<FromGitter> <bew> ok, let's try again
<FromGitter> <bew> it's fun because I did those commands an hour ago while trying to test #5413 on a macbook of a friend
<DeBot> https://github.com/crystal-lang/crystal/pull/5413 (Fix exit in at_exit handlers)
<FromGitter> <bew> looks like it worked this time!
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
faustinoaq has joined #crystal-lang
snsei has joined #crystal-lang
_whitelogger has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
<FromGitter> <watzon> Trying to get things working on my CentOS server is a pain in the ass
<FromGitter> <watzon> I'm having trouble getting libgc working
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
notdaniel has joined #crystal-lang
<crystal-gh> [crystal] bew opened pull request #5806: Fix internal doc (typo & old invalid comment) (master...fix-internal-doc) https://git.io/vxefb
notdaniel has quit [Quit: Leaving]
DTZUZO has quit [Ping timeout: 245 seconds]
<crystal-gh> [crystal] MakeNowJust opened pull request #5807: Semantic: fix behavior of union and proc notation with untyped expression (master...fix/crystal/ealry-return-for-untyped-union-and-proc-type) https://git.io/vxefh
<crystal-gh> [crystal] bew opened pull request #5808: Semantic: Allow macro overload on named args (master...allow-macro-overload-on-named-args) https://git.io/vxeJC
alex`` has joined #crystal-lang
snsei has joined #crystal-lang
return0e has quit [Ping timeout: 268 seconds]
snsei has quit [Ping timeout: 276 seconds]
return0e has joined #crystal-lang
<FromGitter> <bararchy> So again me and my C issues ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I'm translating the commented C part, this part is wierd for me: `ioctl(dd, HCIGETCONNINFO, (unsigned long) cr) ` ... [https://gitter.im/crystal-lang/crystal?at=5aa51230f3f6d24c68605c5c]
<FromGitter> <JonnyCodewalker> isnt the third argument of ioctl just a pointer to any memory that doesnt care about the type?
<FromGitter> <bararchy> `Void*` ?
<FromGitter> <bararchy> @JonnyCodewalker ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa513a2a60157d62fd3ba83]
<FromGitter> <JonnyCodewalker> i feel like the casted it to a simple type because ioctl cant work with a struct and made it an unsigned long as to not cut off data at the end? not sure though
<FromGitter> <bararchy> In crystal it wont allow me to cast the struct into random stuff like that XD
<FromGitter> <bararchy> so, should I just.. pass in a pointer?
<FromGitter> <JonnyCodewalker> well in crystal not everything is just a bunch of bystes anyway :P. also as i said i am not sure, i am not that great with C.
<FromGitter> <bararchy> hmmm @bew save me !
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> or RX14
<RX14> @bararchy just struct.unsafe_as(LibC::ULong)
<FromGitter> <bararchy> Oh, damn nice trick !
<RX14> but cr is a pointer
<RX14> not a struct
<RX14> they're just casting a pointer to a ulong
<FromGitter> <JonnyCodewalker> oh damn, you are right.
<FromGitter> <JonnyCodewalker> i should learn reading xD
<FromGitter> <bararchy> isn't `cr` a struct hci_conn_info
<FromGitter> <bararchy> oh, it's just the malloc
<FromGitter> <bararchy> so it's just Pointer(Void) ?
<FromGitter> <bararchy> with the size of the struct
<RX14> yeah i think
<RX14> i'd need to see more context
<RX14> like your C code doesn't even have the type of cr in it
<RX14> struct hci_conn_info_req *cr;
<FromGitter> <bararchy> `struct hci_conn_info_req *cr;`
<FromGitter> <bararchy> yeha
<FromGitter> <bararchy> so it's a pointer of the struct?
<RX14> yes
<FromGitter> <bararchy> So this is indded casting the pointer as uint32 right ? ⏎ ⏎ ```ioctl(dd, HCIGETCONNINFO, (unsigned long) cr)``` [https://gitter.im/crystal-lang/crystal?at=5aa5167453c1dbb743cb7f78]
<RX14> as a LibC::ULong
<FromGitter> <bararchy> hmmm, still seems to misbehave :\
<RX14> i mean it's not that simple
<RX14> it's a HciConInfoReq pointer but you're allocating more memory than that
<FromGitter> <bararchy> what do you mean?
<RX14> plus hci_conn_info_req has a struct hci_conn_info conn_info[0]; at the bottom
<FromGitter> <bararchy> Oh wait
<FromGitter> <bararchy> I', using the wrong struct
<RX14> lol
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> damn
<RX14> crystal doesn't have flexible array members
<RX14> so you have to do it manually
<RX14> and this bluez code seems to use flexible array members a lot
<FromGitter> <bararchy> RX14 I did this: ⏎ ⏎ ```ci = LibHCI::ConnInfoReq.new ⏎ ci.conn_info[0].handle ⏎ ``` [https://gitter.im/crystal-lang/crystal?at=5aa518f6e4ff28713a1bbf1b]
<FromGitter> <bararchy> not sure if it makes sense
<RX14> alsoyou mean to malloc a pointer(void) with the same sizeof as the bluez code uses
<RX14> then cast it to a ConnInfoReq pointer
<RX14> then pass it in
<RX14> you need to*
<RX14> they're not mallocing sizeof(struct hci_conn_info_req)
<RX14> they're doing more than that
<RX14> so you need to do more than that
<FromGitter> <bararchy> I hate C
<RX14> haha
<FromGitter> <JonnyCodewalker> but c is love, c is life
<RX14> so pay me to do it for you :)
<FromGitter> <bararchy> RX14 working on that ;)
<RX14> I need to go have breakfast
<RX14> but i'll check it out after
<FromGitter> <bararchy> cool, thanks
<FromGitter> <bararchy> I'm also hoping @mjago will come along and help, he is a bluetooth expert
<RX14> cr = Pointer.malloc(sizeof(Void*) + sizeof(LibHCI::ConnInfo)).as(LibHCI::ConnInfoReq*)
<RX14> @bararchy
<RX14> then you probably want to do a LibHCI::ConnInfoReq.new, copy the bdaddr, set the type, then do cr.value = <that>
<RX14> then you probably don't need to cast at all
<FromGitter> <bararchy> wow
<FromGitter> <bararchy> nice
<FromGitter> <bararchy> !
<RX14> does it work?
<FromGitter> <bararchy> trying now
<RX14> bet it doesn't haha
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/vxe3X
<crystal-gh> crystal/master 10fb1ff Benoit de Chezelles: Use the same llvm's version as crystal-lang package for CI's darwin build (#5804)...
<FromGitter> <bararchy> RX14 can't malloc pointer without type, use Pointer(Type).malloc(size)
<RX14> Pointer(Void) then
<FromGitter> <bararchy> yeha, trying that now :)
<FromGitter> <bararchy> So i Might made a mess here, but here it is: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Which makes sense as it's not a pointer anymore after being cast into LibHCI::ConnInfoReq [https://gitter.im/crystal-lang/crystal?at=5aa51e966f8b4b994613aeff]
<RX14> .as(LibHCI::ConnInfoReq*)
<RX14> oh ffs
<RX14> gitter strips my stars
<FromGitter> <bararchy> ohhh
<FromGitter> <bararchy> makes sense now
<RX14> `cr = Pointer.malloc(sizeof(Void*) + sizeof(LibHCI::ConnInfo)).as(LibHCI::ConnInfoReq*)`
<RX14> yeah
<RX14> there's 2 stars missing
<FromGitter> <bararchy> compiles and running
<RX14> you changed the Void to Void* right?
<FromGitter> <bararchy> in a sec I'll tell if workin
snsei has joined #crystal-lang
<FromGitter> <bararchy> Yeha I did, still wont connect, I'm checking some stuff to see we are not missing something else
<RX14> any useful error?
<FromGitter> <bararchy> ```code paste, see link``` ⏎ ⏎ we never get to "super handle", which is the issue [https://gitter.im/crystal-lang/crystal?at=5aa51fbde4d1c63604e89d04]
<FromGitter> <bararchy> which means we get non 0 from ioctl
<RX14> you mean 0 or negative?
snsei has quit [Ping timeout: 252 seconds]
<RX14> @bararchy you realise your consdition is different to the C
<RX14> the C fails when < 0
<RX14> you check it's > 0
<RX14> if it returns 0 you get different behaviours
<RX14> also print the errno
<FromGitter> <bararchy> Oh, damn
<FromGitter> <bararchy> the errno is -1
<RX14> well
<RX14> thats not very helpful
<RX14> ugh it's an ioctl but it has no manpages
<RX14> @bararchy does it return -1 or errno -1
<FromGitter> <bararchy> return -1
<RX14> what errno?
<FromGitter> <bararchy> not sure how to translate that to errno
<FromGitter> <bararchy> no `get error` function or something like that
<RX14> uhh
<RX14> p Errno.new ?
<FromGitter> <bararchy> Oo
<FromGitter> <bararchy> oh
<FromGitter> <bararchy> Check: -1 ⏎ Error: -1: Invalid argument
<FromGitter> <bararchy> ```puts "Error: #{Errno.new(check)}"```
<FromGitter> <bararchy> this is what is gives back ^
<RX14> uhh no
<RX14> it's just Errno.new
<RX14> no args
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa5231be4d1c63604e8ab7b]
<RX14> oh
<RX14> Errno.new("")
<FromGitter> <bararchy> ok
<RX14> this is the implementation of the syscall btw: https://elixir.bootlin.com/linux/latest/source/net/bluetooth/hci_conn.c#L1449
<RX14> it essentially copies in a hci_conn_info_req from the pointer location, then copies back a hci_conn_info which is off the end of the pointer
<RX14> see where it calls copy_to_user(ptr, &ci
<RX14> where ptr is arg + sizeof(req)
Papierkorb has joined #crystal-lang
Papierkorb has left #crystal-lang ["Konversation terminated!"]
<RX14> so my code is actually wrong
<RX14> and i'm a dunce
<FromGitter> <bararchy> XD
<FromGitter> <bew> \o/
<FromGitter> <bararchy> it seems we all hate C
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> hahaha
<RX14> it's pointer = Pointer(Void).malloc(sizeof(LibHCI::ConnInfoReq) + sizeof(LibHCI::ConnInfo))
<FromGitter> <bew> Stars*
<FromGitter> <bew> ?
<RX14> you then create your conninforeq and do pointer.as(ConnInfoReq*).value = cir
<RX14> then conn_info = (pointer + sizeof(ConnInfoReq)).as(ConnInfo*).value
<RX14> or just define a packed struct of the two
<RX14> and make it 10x easier on yourself :)
<travis-ci> crystal-lang/crystal#10fb1ff (master - Use the same llvm's version as crystal-lang package for CI's darwin build (#5804)): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/351955596
<DeBot> https://github.com/crystal-lang/crystal/pull/5804 (Use the same llvm's version as crystal-lang package for CI's darwin build)
<RX14> @[Packed]; struct HCIGetConnInfoPair; request : ConnInfoReq; response : ConnInfo; end
<RX14> and then you can do foo = HCIGetConnInfoPair.new on the stack and just pass in pointerof(pair) to the ioctl
<RX14> and that SHOULD get you the same answer as the code I put above
<RX14> but test it
<FromGitter> <bararchy> ```Check: -1 ⏎ Error: : Invalid argument ⏎ ``` [https://gitter.im/crystal-lang/crystal?at=5aa527470a1614b71208b3ce]
<FromGitter> <bararchy> RX14
<RX14> i bet p pair.request shows an invalid request
<RX14> since pair.request.type = will be a noop
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa5284c8f1c77ef3aa9f136]
<RX14> huh
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa52879c3c5f8b90d5b896a]
<FromGitter> <bararchy> that;s the print
<FromGitter> <bararchy> looks pretty good TBH
<RX14> can you show the definition of the three structs
<RX14> I want to check something
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa528bf27c509a7744d5ef1]
<RX14> huh
<RX14> and is @socket correct?
<RX14> as in
<RX14> do you KNOW if it's correct
<FromGitter> <bararchy> it's correct as it manages to scan for remote devices
<FromGitter> <bararchy> it's also the number '8' which makes sense :)
<FromGitter> <bararchy> as in, FD
<RX14> hmm
<RX14> yep thats impossible
<RX14> that ioctl can't return EINVAL
<RX14> I checked the kernel source
<FromGitter> <bararchy> maybe I can just pass in 0 as handle
<RX14> @bararchy please push your code to a branch
<RX14> i'll debug it myself
<FromGitter> <bararchy> oh, cool :)
<FromGitter> <bararchy> thanks
<RX14> nah
<RX14> this is too interesting to pass up
<FromGitter> <bararchy> All code commited, you can fork
<FromGitter> <bararchy> relevant specs are at ⏎ ⏎ ```crystal spec/local_device_spec.cr``` [https://gitter.im/crystal-lang/crystal?at=5aa52bc035dd17022e47bf72]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
<RX14> @bararchy all specs pass?
<RX14> oh
<RX14> thats because I have no remote devices
<RX14> lel
<FromGitter> <bararchy> whaaaaa
<FromGitter> <bararchy> lol
<FromGitter> <bararchy> open phone with bluetooth
<FromGitter> <bararchy> or something
<FromGitter> <bararchy> :)
<RX14> yeah
<FromGitter> <bararchy> or sit in a bus, I one got 97 listed devices
<RX14> lol
<RX14> ok fixed
<RX14> I need to literally be in the bluetooth menu on my phone
<FromGitter> <bararchy> Yap, mine too
<RX14> also "[Moto G (5) (820)]0\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u000
<RX14> 0\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u000
<RX14> 0\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u000
<RX14> 0\u0000\u0000"
<RX14> which is fun
<RX14> that needs a fixing
<FromGitter> <bararchy> the hell is this XD
<RX14> a bunch of null bytes in your strings
<FromGitter> <bararchy> RX14 any luck? :)
<RX14> not yet
<FromGitter> <bararchy> I'm leaving this to you and go back to work on BLE scan support
<RX14> @bararchy you're using the wrong ioctl
<RX14> ioctl(10, HCIGETCONNLIST, 0x7ffcec60f090) = -1 EINVAL (Invalid argument)
<RX14> according to strace at least
<FromGitter> <bararchy> Is there another ioctl ?
<RX14> 0x800448d5 is the correct ioctl number
<RX14> @bararchy yeah you were trying to call HCIGETCONNINFO
<RX14> but you had the wrong ioctl number and were calling HCIGETCONNLIST
<RX14> i mean it's still broken
<RX14> but at least we get the right errno
<FromGitter> <bararchy> What errno we get now ?
snsei has joined #crystal-lang
<RX14> ENOENT
<RX14> very strange thing is that
<RX14> even when I strace hcitool
snsei has quit [Ping timeout: 255 seconds]
<RX14> it gets ENOENT for conninfo
<RX14> @bararchy I don't know why you're using HCIGETCONNINFO at all actually
<RX14> @bararchy hci_create_connection's handle parameter is an out parameter
<crystal-gh> [crystal] straight-shoota opened pull request #5809: CHANGELOG: Add missing links to Github issues (master...patch-2) https://git.io/vxeWq
return0e has quit [Ping timeout: 260 seconds]
return0e has joined #crystal-lang
<FromGitter> <bararchy> Oo
<FromGitter> <bararchy> Are you sure ?
<FromGitter> <bararchy> RX14 then I guess it makes sense why it didn't work XD
<RX14> yeah
<FromGitter> <bararchy> I'm just reverse engineer everything on account of 0 docs
<RX14> i'm super confused on the actual core architecture of bluetooth and how all it fits together
<RX14> and yeah
<RX14> there's no docs
<RX14> this piece looks good
<RX14> and it barely if at all uses any of the libhci stuff
<FromGitter> <bararchy> Yeha, but its only the scan part
<RX14> no its not
<RX14> there's a next button
<FromGitter> <bararchy> Oh...
<FromGitter> <bararchy> Yeha
<RX14> ...
<FromGitter> <bararchy> Hahaha
<FromGitter> <bararchy> Yap my bad
<RX14> I'm just starting to understand bluetooth's actual protocol structure
<RX14> looks like all bluetooth protocols are built on top of L2CAP
<RX14> I mean, what do you want to do with this library
<RX14> presumably you'd want to have quite a lot of low-level control for use with fuzzing
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
<FromGitter> <bararchy> My initial idea was binding the actual sockets , as in RFCOMM sockets and L2CAP socket.
<FromGitter> <bararchy> But it seems I can send arbitrary commands to remote devices even using the HCI socket
<FromGitter> <bararchy> Which seems to wrap around those low level parts
<FromGitter> <bararchy> Also, I need to handle GATT
<FromGitter> <bararchy> Which I guess will need a little bit different handling
<RX14> @bararchy most things don't use rfcomm i think
<RX14> l2cap seems to be the lowest layer you need to go to
<RX14> I mean the lower you go the more you need to reimplement right?
<RX14> reimplementing l2cap sounds like a lot of work
<FromGitter> <bararchy> L2cap is the "udp" form of Bluetooth, while RFCOMM is the "TCP" part , you have relevance for both i think, I still research this
<RX14> yeah that's the impression I got
<RX14> except that rfcomm is built on top of l2cap
<RX14> but tcp isnt built on top of udp
<RX14> I think it's more kinda like l2cap is udp+ip
<RX14> and rfcomm is tcp on top of that
<RX14> except it's emulating serial ports
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
qard has joined #crystal-lang
<wmoxam> OpenBSD port updated for 0.24.2: https://github.com/wmoxam/crystal-openbsd-port
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/vxezu
<crystal-gh> crystal/master ed0aad8 Benoit de Chezelles: Fix internal doc (typo & old invalid comment) (#5806)...
snsei has joined #crystal-lang
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
snsei_ has quit [Ping timeout: 252 seconds]
<travis-ci> crystal-lang/crystal#ed0aad8 (master - Fix internal doc (typo & old invalid comment) (#5806)): The build was fixed. https://travis-ci.org/crystal-lang/crystal/builds/352013522
<DeBot> https://github.com/crystal-lang/crystal/pull/5806 (Fix internal doc (typo & old invalid comment))
olbat has joined #crystal-lang
olbat has quit [Changing host]
olbat has joined #crystal-lang
<FromGitter> <bew> > but tcp inst built on top of udp
<FromGitter> <bew> True in practice, but it's possible to do it
<FromGitter> <bew> (I did at my first internship, was fun ˆˆ)
snsei has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
<FromGitter> <watzon> Is there a way to get `String#gsub` to return `Regex::MatchData`, or is there another method that I can use? The block method for gsub seems to just loop over results and return matches one at a time.
<FromGitter> <watzon> I want to basically be able to do `string.gsub { |m| " #{m[1] " }`
<FromGitter> <straight-shoota> what exactly is not working for you?
<FromGitter> <watzon> I'm basically trying to do a similar thing to this https://github.com/NaturalNode/natural/blob/master/lib/natural/tokenizers/treebank_word_tokenizer.js#L52
<FromGitter> <straight-shoota> you don't even need MatchData for this...
<FromGitter> <straight-shoota> `"foo bar".gsub(/(fo+)/, "(\\1)") # => "(foo) bar"`
<FromGitter> <watzon> Ahh I tried that, but I was using `\\0` instead
<FromGitter> <watzon> Making it `\\1` instead fixed my issue
<FromGitter> <watzon> Thanks
<FromGitter> <straight-shoota> or with evaluating MatchData manually: ⏎ `foo bar".gsub(/(fo+)/) { |string, matcher| "(#{matcher[1]})" }`
<FromGitter> <straight-shoota> np
<FromGitter> <straight-shoota> there are a lot of docs missing...
<FromGitter> <watzon> Oh so `gsub` can return the match data
<FromGitter> <watzon> Yeah that needs to be documented
<FromGitter> <straight-shoota> oc
<FromGitter> <watzon> The back references work great though
<FromGitter> <bew> Oo why does `Dir.mkdir_p` always returns 0 ?
<FromGitter> <straight-shoota> doesn't seem to make sense
<FromGitter> <straight-shoota> I'm not sure it should return anything
<FromGitter> <bew> hm I think the same here
<crystal-gh> [crystal] bew opened pull request #5810: Ensure cleanup tempfile after some specs (master...ensure-cleanup-after-some-specs) https://git.io/vxePT
<FromGitter> <watzon> PCRE doesn't support Unicode values like `\u0041`?
<FromGitter> <watzon> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa5826927c509a7744ef197]
<FromGitter> <bew> checkout #5412
<DeBot> https://github.com/crystal-lang/crystal/issues/5412 (Regex literal won't accept escaped unicode codepoints)
<FromGitter> <watzon> Well that's dumb haha
<FromGitter> <watzon> At least the workaround isn't too much different
<FromGitter> <genericpenguin> Hi all. I'm having a small issue with Fibers. I've got a basic TCP server that handles incoming connections as individual Fibers (where the connection is part of a player object), but I would like to have a channel that can receive messages from the outside after spawning. I keep a reference to the channel in the player object but when I send a message, it comes through only once, even though the spawn
<FromGitter> ... has a loop. In fact, the whole loop only runs twice and then dies. Code is here - https://gist.github.com/genericpenguin/df13cc583bdd5b74cc60a92f7e2155d4
<FromGitter> <genericpenguin> Obviously I'm doing something stupid but I'm not sure what.
<FromGitter> <genericpenguin> This is the player class which is minimal - https://gist.github.com/genericpenguin/aab72b5ae328d2c0585d1178999ac845
<FromGitter> <genericpenguin> Running from my machine, the ouput from the server is: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ And the clients only receive a single ping [https://gitter.im/crystal-lang/crystal?at=5aa58deae4d1c63604ea7aca]
<FromGitter> <bew> (note: you can put multiple files in one gist)
<FromGitter> <genericpenguin> @bew Thanks, I didn't know that.
shalmezad has joined #crystal-lang
<FromGitter> <straight-shoota> @genericpenguin you only call Channel#receive once so it obviously will only receive one message
<FromGitter> <straight-shoota> I guess you need to put that logic in a loop
<FromGitter> <mikeyhew> `crystal docs` generates docs for your shard. Is there a way to generate docs for a dependency?
<FromGitter> <bew> you could go in the dependency directory and run `crystal docs`
<FromGitter> <mikeyhew> hmm... seems I hit a bug in the compiler
<FromGitter> <bew> What is the error?
<FromGitter> <mikeyhew> @bew I posted an issue: https://github.com/crystal-lang/crystal/issues/5812
<FromGitter> <bew> @mikeyhew I think you meant `crystal init ...` not `crystal new ...`
<FromGitter> <bew> and the command is `crystal init app lucky-docs-test`
Ven`` has joined #crystal-lang
livcd has quit [Remote host closed the connection]
<FromGitter> <mikeyhew> @bew good point 😄
<FromGitter> <mikeyhew> for the record, I *did* run `crystal init app lucky-docs-test`
<FromGitter> <mikeyhew> after a few false starts
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alex`` has quit [Ping timeout: 245 seconds]
<FromGitter> <genericpenguin> @straight-shoota thank you! I think I'm going to write a spawn_loop macro cause I keep on making the same mistake. Thanks again!