<trapped>
don't know what you did about the Class < Class+ issue lately but a project of mine magically managed to compile on tip after weeks being broken for no reason
havenwood has quit [Ping timeout: 246 seconds]
BlaXpirit has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
sdogruyol has joined #crystal-lang
sdogruyol has quit [Remote host closed the connection]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass>
dzv: I never saw that anywhere else (and I've seen hundreds 30+ min builds now). Their containers are limited to 3G RAM, I wonder if we sometimes scratch that and that's simply the symptom
<jhass>
trapped: there have been 2-3 fixes around that, yeah
<jhass>
because people provided test cases ;)
<trapped>
great
nkts has joined #crystal-lang
sdogruyo_ has joined #crystal-lang
sdogruyol has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
NeverDie has joined #crystal-lang
n0xff has joined #crystal-lang
NeverDie has quit [Client Quit]
Philpax has quit [Ping timeout: 240 seconds]
gamemanj has joined #crystal-lang
sdogruyo_ has quit [Remote host closed the connection]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Liothen has quit [Ping timeout: 256 seconds]
toydestroyer has quit [Ping timeout: 256 seconds]
Liothen has joined #crystal-lang
Philpax has joined #crystal-lang
n0xff has left #crystal-lang [#crystal-lang]
toydestroyer has joined #crystal-lang
sardaukar has quit [Ping timeout: 256 seconds]
sdogruyol has joined #crystal-lang
gamemanj has quit [Ping timeout: 256 seconds]
NikN9ne has joined #crystal-lang
sdogruyol has quit [Ping timeout: 240 seconds]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gamemanj has joined #crystal-lang
<NikN9ne>
hi guys, I'm new to crystal, is there any tutorial on how to parse a json api?
<jokke>
NikN9ne: afaik no, but look into the json_mapping macro
<gamemanj>
"cc"? Shouldn't it specifically use "clang" (gcc wouldn't like the LLVM bitcode), anyway?
<gamemanj>
Or is this just for the linking step...?
<NikN9ne>
I have no clue, I installed crystal on ubuntu from the official repo and tried to use the official sample with the crystal command and it throws the cc not found error at me, it doesn't matter if I use the official samples, my own code or anything else, I always get the cc error
<jhass>
NikN9ne: install build-essential please
<NikN9ne>
nvm
<NikN9ne>
yeah
<jhass>
gamemanj: just linking, gcc is fine
<NikN9ne>
I noticed that just now, it was a new machine which required build-essential + libssl
<NikN9ne>
:D
<NikN9ne>
sorry
<jhass>
nothing to worry about
<NikN9ne>
but I think it wouldn't be a bad idea to add that to the docs
<jhass>
maybe the compiler should even depend on it, mmh
<jhass>
the package that is
<NikN9ne>
yup
<jhass>
though maybe there are deb based distros that don't have it
unshadow has joined #crystal-lang
sdogruyol has joined #crystal-lang
unshadow_ has quit [Ping timeout: 246 seconds]
Ven has joined #crystal-lang
sdogruyol has quit [Ping timeout: 240 seconds]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nakilon has quit [Ping timeout: 265 seconds]
Ven has joined #crystal-lang
nkts has quit [Quit: xy]
BlaXpirit has quit [Quit: Konversation]
BlaXpirit has joined #crystal-lang
elia has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven has quit [Client Quit]
elia has quit [Quit: Computer has gone to sleep.]
havenwood has joined #crystal-lang
sdogruyol has joined #crystal-lang
sdogruyol has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
nakilon has joined #crystal-lang
leafybasil has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sdogruyol has joined #crystal-lang
<dzv>
jhass: it wasn't a 30m build. it was a 3 min build. i think they just rebooted
<jhass>
dzv: I'm saying if I didn't see a reboot in tons of 30m builds yet, while having seen more than half a dozen reboots in < 6m builds, it's unlikely that they're just rebooting all the time but more likely that we hit some limit that makes them kill the worker
Ven has joined #crystal-lang
ssvb has quit [Ping timeout: 244 seconds]
<jokke>
how would i build xml nodes in crystal?
<jokke>
the initializers in xml/node.cr all need a reference to a node
sdogruyol has quit [Remote host closed the connection]
lex_ has joined #crystal-lang
sdogruyol has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass>
you know the game, if it's not there it's not there yet ;)
<jokke>
:)
<jokke>
yeah
dylanmei has joined #crystal-lang
nakilon has quit [Ping timeout: 256 seconds]
Ven has joined #crystal-lang
<dzv>
jhass: there is a specific message about killed jobs. "no output within 10 minutes" or something like that. the reboot that hit my test was probably just bad luck. there were a few messages. one said "message from root ...", another "system is going down for reboot now"
<jhass>
dzv: still my assumption is having hit a resource limit, that the behavior differs significantly from a timeout is not unexpected to me
rmosolgo has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
<lex_>
hello, sorry but I here with the nil trace again
<lex_>
i added append method to the program jhass sent
<rmosolgo>
I assigned `current_tail = @tail` and used that instead
Philpax has joined #crystal-lang
<rmosolgo>
I read somewhere taht this is because it's possible the object is mutated by another thread (?)
<rmosolgo>
which might cause the instance variable to become nil _after_ checking it
<rmosolgo>
if you use a local variable, you don't have that posibility
<jhass>
lex_: what's the difference between @curr and @tail btw?
<jhass>
rmosolgo: yes that's right
sdogruyol has quit [Remote host closed the connection]
<lex_>
you can move @curr position and look at a different link (node), @tail will always be the last link
<jhass>
so << moves the cursor while append doesn't? kinda confusing
<lex_>
ahh well, consider << as inserting at current position for now
ssvb has joined #crystal-lang
<lex_>
so if I have @curr.next = @curr.next.next ... then if condition will become to verbose ... using @curr.try{|c| c.next.try{|c1| c1 = c1.next}} is my only option
<lex_>
basically, i need to have instance variable as local variable and then a nil check on them
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass>
I pictured insert as inserting after current and since there weren't any ways to move @curr to something different than tail and no insert overload that takes an index or node, I figured its append and << is the idiomatic name for that operation
<jhass>
the iterator for example could in theory also support the drop and insert operations, though it might get messy
dylanmei has quit [Quit: ZZZzzz…]
dylanmei has joined #crystal-lang
greengriminal has joined #crystal-lang
Ven has joined #crystal-lang
<jokke>
jhass: any idea how i would read lines of a potentially very large file starting from the _end_ of the file/
<jokke>
?
<jhass>
I don't think there's any C/Kernel level API to read backwards?
<jokke>
not that i'm aware of
<BlaXpirit>
jokke, well i have an idea
<jokke>
BlaXpirit: shoot
<jhass>
so heuristics, determine average or max line length, seek to end - twice that, find offset of last \n between current pos and last pos (initially end)
<jhass>
repeat with current pos as end
<jhass>
+ edge cases
havenwood has quit [Ping timeout: 250 seconds]
<jokke>
jhass: if i need to determine the line length of each line then i've already lost
<jhass>
yeah
<jhass>
for a general solution you have
nakilon has joined #crystal-lang
<jhass>
then it's cheaper to mmap/read into memory and read all \n positions
<BlaXpirit>
i think it's best to read, let's say, 65536 bytes from the end of the file
<BlaXpirit>
then seek from the end, leave the rest in the buffer, read into it again
<jokke>
jhass: hm mmap would be nice indeed
<jhass>
but you can't guarantee to find a \n in there, so insufficient for a general solution
<BlaXpirit>
would be difficult if there were larger lines
<jokke>
yeah
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<BlaXpirit>
perfect use case for deque
<BlaXpirit>
but a special one, because the one i submitted isn't made for this task
<jhass>
jokke: well, guess why grep -n is so much slower than just grep ;)
<BlaXpirit>
read all \n positions is a pretty good idea, but it just a scaled down version of reading everything into memory
rmosolgo has quit [Remote host closed the connection]
<jokke>
jhass: i could also do sth like: buffer = [] of UInt8; file.seek(-1, IO::Seek::End); while file.read_byte != "\n".ord ...
<jokke>
BlaXpirit: ^
<jhass>
I predict that to be twice as slow than reading twice and memorizing \n positions
<jokke>
jhass: depends how far you need to rea
<jokke>
d
<BlaXpirit>
yeah but what if the file consists of only newlines
<jokke>
i only need a couple of lines
<BlaXpirit>
dang it, there is no bytestring data type
Ven has joined #crystal-lang
<jokke>
yeah
<jokke>
it's [] of UInt8 i guess
rmosolgo has joined #crystal-lang
rmosolgo has quit [Remote host closed the connection]
<jhass>
I'd still argue for Slice(UInt8)
<jokke>
jhass: you can't grow it
<jhass>
you can't grow Crystal's String either
elia has joined #crystal-lang
<BlaXpirit>
jhass, u can concatenate
<jhass>
which is something we could implement for Slice(UInt8) too
<jokke>
jhass: i opened a pr for that
<jokke>
but it wasn't wanted
<jhass>
it's still open
<jokke>
yeeeah..
<jokke>
surprise there :D
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass>
There, I added you a usecase, sort of
<jokke>
:)
<BlaXpirit>
i was almost convinced that crystal's string/bytes model was better that python's
<BlaXpirit>
but... nope nope nope
<jhass>
BlaXpirit: it lacks a throughout design, but I like the general approach of having it IO centric and isolated from String
Ven has joined #crystal-lang
lex_ has quit [Quit: Page closed]
NeverDie has joined #crystal-lang
<RX14>
what's the site which renders crystal docs from github?
<BlaXpirit>
docrystal
<RX14>
thanks <3
<BlaXpirit>
it's been broken for a long time
Philpax_ has joined #crystal-lang
<RX14>
really?
NeverDie has quit [Max SendQ exceeded]
NeverDie has joined #crystal-lang
Philpax has quit [Ping timeout: 264 seconds]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elia has quit [Quit: Computer has gone to sleep.]
<ddfreyne_>
I can’t run a HTTP::Server in a separate thread. Is this a known issue?
<ddfreyne_>
I also found out that the Thread class is not documented.
<ddfreyne_>
And am running into other odd issues when using threads.
<ddfreyne_>
Here’s an example: http://play.crystal-lang.org/#/r/hx8 -- the server never opens a socket on port 8090, because I get Connection Refused in my browser.
<ddfreyne_>
Without the Thread.new stuff, the server listens just fine.
<BlaXpirit>
ddfreyne_, IO don't work in separate threads
<BlaXpirit>
threads are not supported
<BlaXpirit>
they're for internal use only
<ddfreyne_>
Aw :(
<BlaXpirit>
ddfreyne_, are you sure fibers don't satisfy your needs?
<ddfreyne_>
BlaXpirit: How would you convert the code example I gave to use fibers?
<jhass>
ddfreyne_: remove the Thread.new
<BlaXpirit>
ddfreyne_, remove t = Thread.new do
<ddfreyne_>
(That example is quite close to what I actually want to do--run a HTTP server for exporting metrics, while I do other stuff)
<jhass>
spawn { server.listen }
<ddfreyne_>
jhass: BlaXpirit Imagine the “waiting” stuff is replaced by doing other work.
Philpax_ has quit [Ping timeout: 240 seconds]
<BlaXpirit>
replace Thread.new with spawn
<ddfreyne_>
Oh, neat. I think I missed this spawn entirely...
<BlaXpirit>
ddfreyne_, fibers are everywhere in the library code. chances are you'll just be able to concurrency safely without even thinking about it, by using fibers
<BlaXpirit>
to do*
leafybasil has joined #crystal-lang
<ddfreyne_>
Nice.
<ddfreyne_>
Is there a way to yield within fibers?
<ddfreyne_>
It seems like whatever I have in “waiting” is blocking the fiber from resuming.
<jhass>
Scheduler.yield but that should be rarely needed
<ddfreyne_>
Or I am misunderstanding this :/
<ddfreyne_>
jhass: When is it necessary?
<jhass>
in weird situations
<jhass>
if you show some code we might be able to see another way
<ddfreyne_>
OK, Scheduler.yield fixed what I was seeing.
<jhass>
most of the time you would want to use a Channel to signal things
<ddfreyne_>
jhass: I’m running a game with GLFW and it doesn't at any moment do anything blocking, so maybe that’s why.
<ddfreyne_>
I put a Scheduler.yield in my game loop
<jhass>
maybe
<jhass>
well yeah that sounds reasonable
<ddfreyne_>
(Some context: I’m running an external web server so I can serve metrics about this OpenGL game to be consumed by Prometheus - http://prometheus.io/)
<ddfreyne_>
Hm, still no luck. Will investigate later. Thanks for the pointers!
leafybasil has quit [Remote host closed the connection]
nkts has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
<ddfreyne_>
Gah. Turning this into a minimal test case will be a pain. Does someone not mind dealing with GLFW and OpenGL and help me out for a second? :)
<ddfreyne_>
(“second” is impossibly optimistic.)
<jhass>
I'm afraid I wouldn't be able to spot things in GL code
<BlaXpirit>
i don't use GLFW and have minimal understanding of outdated opengl
<ddfreyne_>
jhass: I’m reducing the code to a minimal test case at the moment. I‘ll play around with that for a bit, see whether I can get a minimal test case working.
<ddfreyne_>
BlaXpirit: jhass: The issue is unlikely to be in GL/GLFW code.
rmosolgo has joined #crystal-lang
<ddfreyne_>
Oh--interesting. Scheduler.yield has no effect, but `sleep 0.1` does.
<BlaXpirit>
ddfreyne_, i shouldn't have hesitated to suggest it
rmosolgo has quit [Remote host closed the connection]
* CompanionCube
should actually write some crystal code
rmosolgo has joined #crystal-lang
<BlaXpirit>
ddfreyne_, it's strange, even by looking at source code they should have the same effect because they call reschedule
<jhass>
mmh, sigh right, I shouldn't try to spawn after the listen
<ddfreyne_>
BlaXpirit: Oh, you’re right--interesting. Let me try whether that also does the trick in my game.
<ddfreyne_>
Yup, works. That’s good enough for me for now.
<asterite>
I guess waj will give you a good answer, but you should use a channel. When the game finishes, send a message on that channel. In the main fiber, wait on that channel.
<BlaXpirit>
asterite, that's not the point
<asterite>
That loop loops endlessly and hogs the CPU
<BlaXpirit>
oh maybe it is
<BlaXpirit>
you mean when the game finishes one iteration
<asterite>
But it's strange that requests are not served
<BlaXpirit>
i don't think a channel is supposed to be needed
<ddfreyne_>
asterite: I would need to be able to query whether the channel has anything in it, in a non-blocking fashion, so the game keeps on running.
<BlaXpirit>
asterite, i think you misunderstand something. let's talk in the context of the example in the issue. let's say that fiber does heavy computations and only yields sometimes
<BlaXpirit>
it's not about finishing, it's about letting two fibers (one of which doesnt use crystal I/O) run simultaneously
<BlaXpirit>
point is, yield seems to have no effect, while sleep(0) does give control to the other fiber