greengriminal has quit [Quit: This computer has gone to sleep]
cremes has joined #crystal-lang
cremes has quit [Client Quit]
<FromGitter>
<Dillybob1992> Here is a code example of my question https://play.crystal-lang.org/#/r/3evp so the values inside the property of `muffin` will be free'd too, right?
greengriminal has joined #crystal-lang
alex`` has quit [Ping timeout: 276 seconds]
<FromGitter>
<l3kn> Yes, if there is no way to reach an object its memory will be freed. I'm sure that's not 100% accurate, but should be close enough to answer your question
<crystal-gh>
crystal/master a288123 Johannes Müller: Fix HTTP::StaticFileHandler to properly parse HTTP date (#5607)
<FromGitter>
<bew> Yes @Dillybob1992 they'll not be free'd immediately, but after some time the GC might trigger a garbage collection, meaning the space previously used will be marked for re-use for other objects (I think I got it correctly)
<FromGitter>
<Dillybob1992> @bew @bew sweet. i find it better if i make up a code example instead bcz im terrible at explaining things :)
qard_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
faustinoaq has quit [Quit: IRC client terminated!]
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
illyohs has quit [Ping timeout: 255 seconds]
snsei has quit [Remote host closed the connection]
LastWhisper____ has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
ashirase has joined #crystal-lang
tweaks has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
ashirase has quit [Ping timeout: 256 seconds]
relyks has quit [Quit: relyks]
relyks has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
greengriminal has joined #crystal-lang
relyks has quit [Quit: relyks]
relyks has joined #crystal-lang
<FromGitter>
<Dillybob1992> im baffled by this and not sure what is going on https://play.crystal-lang.org/#/r/3ewu/edit the string `LOGIN` is being sent to both, but if it's parsed by json it doesn't work, get missing Hash Key "LOGIN"?
<FromGitter>
<bew> I think it's because `cmd` is not a String, it's a JSON::Any
greengriminal has quit [Quit: This computer has gone to sleep]
tec has joined #crystal-lang
tec has quit [Remote host closed the connection]
tec has joined #crystal-lang
<FromGitter>
<Dillybob1992> @bew thanks, gonna use that =]
tec has quit [Ping timeout: 260 seconds]
tec has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter>
<Dillybob1992> I have another question about fibers: https://play.crystal-lang.org/#/r/3exb/edit ⏎ If a method is spawned using a fiber, do the methods that are spawned from the fiber, also work within that fiber, or are they separate?
<FromGitter>
<Dillybob1992> I'm not sure if I am explaining it correctly, but in my code I posted, would `join_lobby` and `message_handler` take advantage of the fiber its in?
qard has joined #crystal-lang
tec has left #crystal-lang ["Leaving"]
qard has quit [Ping timeout: 255 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
mark_66 has joined #crystal-lang
flaviodesousa has joined #crystal-lang
_whitelogger_ has joined #crystal-lang
_whitelogger has quit [Ping timeout: 276 seconds]
dannyAAM has joined #crystal-lang
Liothen has joined #crystal-lang
snsei has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter>
<watzon> What would be the easiest way to write to the same line every time in the console?
<FromGitter>
<watzon> Like the type of thing you'd do for a progress bar
<FromGitter>
<watzon> STDOUT.write and STDOUT.flush?
<FromGitter>
<watzon> Nvm
jnyw has quit [Quit: WeeChat 2.0.1]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
Liothen has quit [Changing host]
Liothen has joined #crystal-lang
hightower2 has joined #crystal-lang
hightower3 has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
DTZUZO has quit [Quit: WeeChat 2.0]
oprypin has quit [Ping timeout: 248 seconds]
g3funk has quit [Ping timeout: 248 seconds]
bmcginty has quit [Ping timeout: 248 seconds]
oprypin has joined #crystal-lang
bmcginty has joined #crystal-lang
Ven`` has joined #crystal-lang
baweaver has quit [Ping timeout: 260 seconds]
g3funk has joined #crystal-lang
baweaver has joined #crystal-lang
baweaver is now known as Guest81361
Groogy has joined #crystal-lang
<Groogy>
Ah working from home today is nice ^^
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
<vegai>
yeah, that's the best
<vegai>
well, can be
snsei has quit [Ping timeout: 265 seconds]
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
flaviodesousa has quit [Ping timeout: 265 seconds]
mark_66 has quit [Remote host closed the connection]
<Papierkorb>
Groogy: Is the weather as bad up north as it is here?
snsei has quit [Ping timeout: 265 seconds]
<Groogy>
Yeah
<Groogy>
just doing game design today though so don't need the tools at work at least ^^
<greenbigfrog>
somehow I thought that exec
<greenbigfrog>
's etc under DB:Database would use pooled connections by default... apparently I have to use #using_connection
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
<FromGitter>
<asterite> weather here is super hot :-P
<Groogy>
I have about 40cm of snow ;)
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
relyks has quit [Quit: relyks]
<RX14>
greenbigfrog, it is using pooled connections by default...
<greenbigfrog>
it is?
<RX14>
yes
<greenbigfrog>
weird...
<RX14>
why?
<greenbigfrog>
I think I might just have fergotten to specify a max connection limit. let me test that really quick
<greenbigfrog>
hm. even after setting `max_pool_size` to 100 I keep getting lines like: 2018-01-19 16:47:03.445 UTC [19733] frog@dogecoin FATAL: sorry, too many clients already
<greenbigfrog>
so both line 4 and 6 will use a connection from the pool?
greengriminal has quit [Quit: This computer has gone to sleep]
moei has joined #crystal-lang
greengriminal has joined #crystal-lang
qard has joined #crystal-lang
<greenbigfrog>
RX14: sorry to ping, but I'd like to get an answer
<RX14>
using_connection just checks out one specific connection from the pool
<RX14>
you're talking to me as if I know what your problem is
<RX14>
you haven't explained anything to me
<FromGitter>
<asterite> greenbigfrog: I didn't use crystal-db much, but I see the code ends up being super clear (I mean, `db.exec`, `db.query_one`, `&.read(Float64)`, etc.), I'm glad the API ended up like that :-)
<greenbigfrog>
my problem was that postgres/my whole system was having a socket overflow because I didn't limit max_connection_pool (or whatever it 's called). At first I thought it was fault to not reusing connections.
<FromGitter>
<asterite> there's a difference: using connection checks out a connection. exec will also check out a connection, but multiple `exec` might check out different connection from the pool. With `using_connection` you can take hold of a single connection and so multiple things on it
<greenbigfrog>
ok
<greenbigfrog>
I think that answers my question. Thanks!
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter>
<asterite> oh, there's no way... you can change the std and add `request.to_io(STDOUT)` to see that. We probably need the client to have some logger to see that
<FromGitter>
<bcardiff> I think ysbaddaden used to use IO::Hexdump for that. But it requires changing the stdlib to hook them. The IO::Hexdump show sample with socket, but I am not sure if that wrapped would work with http client since the @socket is typed as TCPSocket, there might be some methods that are not in IO that are needed...
<FromGitter>
<bararchy> Found a way :)
<FromGitter>
<bcardiff> But an http client logger would be a nice feature
<FromGitter>
<bararchy> so mrequest is the final HTTP::Request :)
<FromGitter>
<asterite> Actually, there's a way: `client.before_request &.to_io(STDOUT)`
<FromGitter>
<bararchy> but then it wont give you the "resource" part
<FromGitter>
<bararchy> the way I did it, you get the "final product"
<FromGitter>
<asterite> though it happens before some other stuff, like the user agent and accept-encoding
<FromGitter>
<asterite> what's the "resource" part?
<FromGitter>
<asterite> Hm, I just see the above answers. I don't know why they didn't show up before
<FromGitter>
<bararchy> :)
<FromGitter>
<asterite> Anyway, I'll send a PR to change this to execute `before_request` right before the request is written to the socket
<FromGitter>
<asterite> that solves the problem, I think. I always wanted this, I didn't think it was so easy to achieve :-P
<FromGitter>
<bararchy> @asterite good idea, could you also add that the `@scheme` will also be part of the `HTTP::Request` ?
<FromGitter>
<bararchy> else there is almost no way to know if the request was sent using http or https
<FromGitter>
<bararchy> also, stuff like `@port` is missing
<FromGitter>
<asterite> but that's not part of the request per se, that's socket info
<FromGitter>
<asterite> so I don't think I'll change that for now (the change I have is very simple, I don't want to make it too complex just now)
<FromGitter>
<bararchy> ok, makes sense :)
<FromGitter>
<bararchy> thanks for doing it
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
jxv has joined #crystal-lang
<FromGitter>
<Dillybob1992> hi :D
jxv has quit [Quit: zzz…]
jxv has joined #crystal-lang
<Groogy>
Hi
<FromGitter>
<imonmyown> yo
greengriminal has quit [Quit: This computer has gone to sleep]
jxv has quit [Client Quit]
<FromGitter>
<Dillybob1992> when doing doing a fiber like: `spawn handle_connection(socket)` and then handle_connection calls another method, does that method take advantage of being in a fiber too? or do I need to use spawn recursively?
greengriminal has joined #crystal-lang
<FromGitter>
<asterite> Spawn creates a new fiber, the method is run in it, and everything that happens inside that method runs in this new fiber.
<FromGitter>
<Dillybob1992> @asterite thanks, even if handle_connection calls another method outside of it?
<FromGitter>
<asterite> RX14 search immutable variable in the issue tracker
<FromGitter>
<asterite> Dilly what do you mean outside of it?
<RX14>
@asterite no, the type should be String | Nil
<RX14>
but typeof returns the wrong thing
<RX14>
as evidenced by trying to use foo
<FromGitter>
<Dillybob1992> for example, a `db.exec`, or `message_handler`, that parses incoming messages
<RX14>
"compile-time type is (String | Nil)" but right next to it typeof(foo) prints just String
<FromGitter>
<asterite> Probably typeof doesn't make the variable closured because it's not really used/accessed, just it's type
greengriminal has quit [Quit: This computer has gone to sleep]
<RX14>
oh, hmm
<RX14>
still feels like a bug
<FromGitter>
<asterite> I bet it changes if you mention foo in spawn
<FromGitter>
<asterite> Probably
<FromGitter>
<asterite> Dilly hard to know without a code snippet
<FromGitter>
<Dillybob1992> @asterite https://play.crystal-lang.org/#/r/3exd/edit , for example, the `join_lobby` or `message_handler` methods. they are methods outside of `handle_connection` but are used
<FromGitter>
<Dillybob1992> do they inherently take advantage of the fiber
<FromGitter>
<Dillybob1992> or do i need, for example, need to use `spawn message_handler` or, if performing a big query, `spawn db.query`
<FromGitter>
<asterite> Dilly a method is just code, you can think that of you call a method you copy that code into the caller
greengriminal has joined #crystal-lang
greengriminal has quit [Client Quit]
<FromGitter>
<asterite> If you call a method of inside of another method that was spawned, it will happen inside the new fiber
<FromGitter>
<asterite> I think you get confused because of the syntax
vivus_ has quit [Client Quit]
<FromGitter>
<asterite> `spawn foo`§
<FromGitter>
<asterite> is just a syntax sugar for spawn do foo end
<FromGitter>
<Dillybob1992> okay, got it so everything being "done" in the spawned fiber will take advantage of being in a fiber
<RX14>
yup
<FromGitter>
<Dillybob1992> some reason kept thinking if i called another method in that method it's not in fiber anymore. thanks for explanation!! feel much better now
<Groogy>
what's the benefit of fibers right now? just being able to delegate a task out to be done at some point? It's concurrent right but not parallel?
<FromGitter>
<j8r> The goal is to have non blocking operations, like async awaits
<RX14>
Groogy, to take advantage of non-blocking IO and to make concurrent programming easier
<RX14>
for purely non-IO tasks it's far easier to communicate through channels than writing your own messy scheduler
<Groogy>
though goal is when threads work as wanted that fiber will utilize that by itself?
<RX14>
and for IO, it's far faster because work can be done while IO is blocked
<RX14>
Groogy, the goal is with threading to be able to run n fibres at the same time, yes
<FromGitter>
<j8r> creating a new thread is quite heavy
<Groogy>
I'm kind of looking at how to structure my game state for paralellism later when that gets added.
<Groogy>
huh RX14 thought when we talked before it sounded like fibres would be running on threads but it would be handled in the background?
<RX14>
yes?
<RX14>
thats what I meant
<Groogy>
ah ok
<RX14>
treat fibers like threads unless they do actual blocking calls to C libraries
<RX14>
or do blocking things themselves
<RX14>
because they're not preemptible
<Groogy>
Idea right now is to have that each agent have a method that will be run in parallel that checks for "Hey do I need to do a serial update?" and put it into a list. Right now Crystal has no parallel_for kind of function that distributes slices of an array to several threads to loop over?
<Papierkorb>
Fibers being pre-emptive (and staying that!) also means, that even with the advent of Threaded Scheduling, blocking calls (C libs, ...) still block the whole thread. If you have 4 worker threads, and do 4 parallel blocking calls, the application would simply "halt" like it does now. Hence, threading is not a solution to get around intergrating C libs with libevent
<RX14>
you mean fibers not being preemptive
<Papierkorb>
Err, yeah, fibers are cooperative.
<RX14>
yup
<Papierkorb>
Just like applications were in Win3.11 lul
<RX14>
Go seems to make every C call "check out the thread" or something weird
<RX14>
so it never blocks
<RX14>
Go's scheduler is weird
<RX14>
it has this resource called a "proc" which is checked out by each OS thread only when it's running go code
<Papierkorb>
That'd require libs to at least be re-entrant, or it goes kaboom.
<RX14>
why?
<Papierkorb>
E.g. Thread local storage, globals
<RX14>
yeah threadlocals would break anyway
<RX14>
since with any good scheduler there cannot be a guarantee your blocking call would awaken in the same OS thread as you blocked in
<Papierkorb>
No matter the detail why a C lib fails, point is, even with a fancy system like Go, the "issue of blocking" still isn't actually fixed.
<RX14>
Groogy, yeah that's ok
<Papierkorb>
Just made slower because of the added necesary synchronization
<Groogy>
yeah but we don't have a #parallel_each right?
<RX14>
no
<Groogy>
I'm gonna have to implement that myself
<RX14>
it would still make sense to have it in the stdlib
<RX14>
for blocking IO calls son an array
<Papierkorb>
Wasn't there a macro like that in toplevel?
<RX14>
i'd kinda prefer an array.parallel which returned a ParallelArray
<RX14>
or
<RX14>
idk
<RX14>
no thats terrible
<Groogy>
how do I convert a UInt32 to a Char?
<Groogy>
its a codepoint from the keyboard and should be in utf-8 format
Guest69273 is now known as lemur
lemur has quit [Changing host]
lemur has joined #crystal-lang
<Groogy>
ah no it's UTF-32 encoding but yeah
<Papierkorb>
UTF-32, really? .. Either decode it yourself, or use Iconv
<Papierkorb>
Never needed UTF-32, but decoding may actually be easy. There's no variable word length at least.
<Groogy>
Yeah, GLFW gives you a unsigned int 32
<Papierkorb>
Isn't that some kind of scancode?
<Groogy>
but I found a #unsafe_char which says it does it without safety checking
<Groogy>
nah scancode is on the key events
<Groogy>
this is the event for text entered which als respects mods
<RX14>
"Each 32-bit value in UTF-32 represents one Unicode code point and is exactly equal to that code point's numerical value."
<RX14>
so it's a not-encoding
<RX14>
UTF-32 means just use int.chr
<RX14>
lol
<Groogy>
ah lol
<Papierkorb>
I wasn't wrong then :P
<Groogy>
there we go now I can type shit in the input field ^^
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Groogy>
huh for some reason... the input field can lose input focus from the keyboard.... but I haven't written that code yet...
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #crystal-lang
hightower4 has joined #crystal-lang
<hightower4>
Hey I always forget, is it var : Type = default, or var = default : Type ?
<Groogy>
first one
<hightower4>
thanks
lemur is now known as baweaver
<FromGitter>
<Dillybob1992> the mysql db for crystal is such a pleasure to work with...
<FromGitter>
<Dillybob1992> no more promise style waterfall chains from.. code looks so much cleaner
<Papierkorb>
And next PostgreSQL, so that not only the API gets good, but you also get a good database
illyohs has joined #crystal-lang
<FromGitter>
<bew> Nice work Groogy for the input box!
<FromGitter>
<bew> I was wondering how is managed keyboard layout, is it always qwerty (and the dev needs to implement custom stuff to handler multiple keyboard layouts)? Or is it (or will it) work OOTB?
<Groogy>
Eh think most OOSes gives you functions to let you convert to whatever layout is set
<Groogy>
technically what you get is a scancode which is where is button on keyboard
<FromGitter>
<j8r> Gregory, I guess @bew was more talking about for an hypothetical WASD, that can change across keyboards
<Groogy>
yeah, that function handles that for you
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Groogy>
I think also
<Groogy>
ops
<Groogy>
GLFW documentation says: The callback function receives the keyboard key, platform-specific scancode,
<Groogy>
and according to it, they will be consistent as long as it is the same platform
<FromGitter>
<j8r> Yes but if i press 'W' on a US keyboard, the player goes forward, but on a FR one it need to be 'Z'. It will be the same code?
<Groogy>
yes
<Groogy>
according to the documentation it will be
<Groogy>
unless it means keyboards are its own platform which would be weird
<FromGitter>
<j8r> Oh good
qard has joined #crystal-lang
<FromGitter>
<j8r> that's pratical
<Groogy>
though if you actually care what's "on" a button, you should probably be using the text callback which gives you the actual properly converted utf32 character
<Groogy>
no matter if you have a chinese keyboard layout
<Papierkorb>
Groogy: iirc, the keyboard sends a keycode to the system, which it then maps over to a system-local scancode. Based on this scan code the mapping to a character is done. Or in short, if the scancode would change, everything else would break too :)
<Groogy>
yeah
<Papierkorb>
Mh .. not sure though if key code and scan code were separate, or if it was the same thing.
<Groogy>
they are probably most often the exact same
<Groogy>
the OS for simplicity sake probably just guarrantees its set of codes
DTZUZU has quit [Ping timeout: 248 seconds]
<Groogy>
hmm think I have a bug in the compiler... not sure exactly what code that makes it happen is though :/
<Groogy>
if I uncomment one part of the code, the executable crashes in a completly different place for memory access :/
<Papierkorb>
mh #execute_all_interested would've been better
<Groogy>
that works
<Groogy>
wtf
<Papierkorb>
Then it's a compiler bug
<Groogy>
also my event.claimed? when I tried to write things manually did not work at all as expected
<Groogy>
within the #each that is
<Groogy>
have no idea how to reprdocue it with minimal :/
<Papierkorb>
As both glue's are of the same type, my guess it has to do with variable allocation of block arguments going haywire, as it assumes it's already allocated. Basically, a left-over "cache".
<Papierkorb>
Your minimal sample may not trigger it visually, because it doesn't touch any used address, while in your fat sample, it does
<Groogy>
yeah :/
<Papierkorb>
Can you run it through valgrind? Does it complain?
<RX14>
lol
<RX14>
valgrind complains about working crystal code
<RX14>
it's useless
<Papierkorb>
Then it needs some ignore rules, that's normal
<RX14>
gives you a bit more data about any faults
<Groogy>
RX14 you got any ideas then? :/ I can't write an issue with "Yeah use my framework"
<RX14>
you really can't just take a file, and start deleting random stuff
<RX14>
?
<Groogy>
also for some reason pacman is having an argument with me about valgrind
<Groogy>
No
<Groogy>
This is the input system interacting with the GUI
<Groogy>
I tried just pulling out the specific part that crashes
<Groogy>
and interact with it exactly the same
<Papierkorb>
Meanwhile, the plot thickens on the mailing list regarding GUI.
<Groogy>
hm?
<RX14>
"install shards" "no"
<Papierkorb>
TL;DR
<RX14>
my response would be "ok"
<Papierkorb>
^
<RX14>
have fun
<Papierkorb>
Was happy that someone stepped up and replied, pointing to the instructions.
<Papierkorb>
Groogy: Can you check if this only happens in 0.24, and not 0.23?
<Papierkorb>
(Make sure to clear your ~/.cache/crystal)
<Groogy>
no, there's bunch of stuff that breaks between 0.24 and 0.23 for my code base
<Papierkorb>
Mh in your simple sample, does it happen at some point? if you call the code in a loop a few million times?
<Groogy>
It happens when you hover over the UI, so when the Parent window starts delegating down input to the children inside it
<Groogy>
so hmm
<Papierkorb>
Or maybe with some recursion involved, with a deeper stack?
<Papierkorb>
delegating down through Cute, or is it through virtual methods?
<Groogy>
it could have to do with that in the callstack you are already inside of the #each?
<Groogy>
because the passthrough method is also an action that works through this exact same code
<Papierkorb>
Is your code doing an unbound recursion?
<Groogy>
eh no not really
<Groogy>
it's only 2 deep
<crystal-gh>
[crystal] chris-huxtable opened pull request #5615: Adds System Users and Groups (master...users-groups) https://git.io/vNzBr