<FromGitter>
<jrfondren> pack/unpack are a swiss army knife. You either have it or you don't. Crystal doesn't, so you'd have to implement every specific conversion wanted.
<FromGitter>
<straight-shoota> @xababafr I don't think libevent guarantees to resume in a certain order
<FromGitter>
<straight-shoota> Although the order of main fiber in relation to the other fibers seems to be always correspond to invocation
<FromGitter>
<xababafr> @straight-shoota but then, is there a way for me to force the the order in any way? I looked at the Scheduler for a bit, but that seems like overkill and not quite clever
<FromGitter>
<xababafr> because i'm porting a simulator from ruby, but there, I can pause and resume fibers, so I can guarantee the order
<robacarp>
if you want to guarantee the order, I don't think you want fibers
sevensidedmarble has joined #crystal-lang
<FromGitter>
<xababafr> Im looking at the Mutex class (just saw it), couldn't this solve my problem?
<robacarp>
sure, it could, but I'm not sure that's the right solution for your problem
<FromGitter>
<xababafr> so, here are a bit more details. I have a simulator class, that has a @fibers : Array(Fiber). The run method then is just supposed to execute each fiber in the correct order (the order of the array). It's implemented quite like the example I gave before : https://play.crystal-lang.org/#/r/4xkv ⏎ ⏎ So yeah, as long as I get the correct order, I'm absolutely fine
rohitpaulk has joined #crystal-lang
DTZUZO has quit [Ping timeout: 244 seconds]
rohitpaulk has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
lvmbdv has quit [Quit: WeeChat 2.2]
<robacarp>
@xababafr what I'm saying is, if you want to execute the code in a specific order, just make it a method that you call instead of a fiber
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter>
<xababafr> But I also need a wait() system that suspends the execution and jumps to the next fiber/method ^^' Maybe i can just use channels instead, in fact, that seems like the good way to do it
DTZUZO has joined #crystal-lang
<FromGitter>
<madranet> Hi all. ⏎ ⏎ I'm just dipping a toe in the water with Crystal at the moment and, as an exercise, trying to port one of my Python scripts across. ⏎ ⏎ The script in question downloads the 'latest' PDF from a URL which takes the form: "http://somesite.com/download/latest/". When visited that URL automatically redirects to the page for the latest download eg. "http://somesite.com/download/4563/" ...
<FromGitter>
<drum445> I have another question ;). When using gzip or zip does anyone know how to keep the file mode intact when extracting
<FromGitter>
<drum445> i.e. execute
<FromGitter>
<jrfondren> execute isn't present in the gzip data, but the command preserves the original permissions of files passed to it. You could do that by statting the file and then applying those permissions to the file you create.
<FromGitter>
<drum445> you can get permissions from a file?
<FromGitter>
<jrfondren> you can get permissions from a path on a file system - a filename
<FromGitter>
<drum445> File.stat("foo").perm
<FromGitter>
<drum445> lovely, cheers
<FromGitter>
<jrfondren> that's how gzip knows whether to make the result executable, if you invoke it like 'gzip -d somefile.gz'
<FromGitter>
<straight-shoota> @xababafr You could probably enforce a specific order by enqueueing the fibers directly with `Scheduler.enqueue(fiber); Scheduler.reschedule`. This won't go through libevent but the internal runnable queue of the Scheduler. But these methods are not part of the official API, undocumented and abusing them might have some unexpected side-effects. When you constantly enqueue fibers in this queue, the main
<FromGitter>
... fiber has no time to run the even loop wich will potentially stall IO operations etc.
<FromGitter>
<straight-shoota> So, I wouldn't recommend it. If you need some specific sequential concurrency, you should probably communicate through channels.
<FromGitter>
<j8r> @jwaldrip why do you install `libc-dev` on Alpine?! Use `musl-dev` instead
<FromGitter>
<jwaldrip> Changed. Now what about the static linking?
<FromGitter>
<resigned> Hey, anyone know how I can do file compression for a simple file store?
<FromGitter>
<jrfondren> there's Zlib and Gzip and Zip
<FromGitter>
<zbaylin> I'm using kemal-session with my kemal application and for some reason am only running into this issue on my production server (which is annoying). ⏎ Since I have two types of users (Manager and Student), some of my JSON-serializable User objects do not have a `User.student_id` property. On my computer, this is fine -- kemal-session deserializes it without a hitch. On my server, however, it throws an error
<FromGitter>
... about `Missing JSON attribute: student_id`. Does anyone else have this issue?
<FromGitter>
<j8r> @jwaldrip you still have the same issue? What about on Alpine:latest?
<FromGitter>
<jwaldrip> same issue. Alpine latest only has access to crystal 0.25.0
<FromGitter>
<j8r> What do you mean @vladfaust ? A constant is always defined, we are in a compiled language. Better to check is value like .empty? or if it's nil
<FromGitter>
<vladfaust> We have `respond_to?` for a method
<FromGitter>
<j8r> That's a macro no?
<FromGitter>
<vladfaust> Yep
<FromGitter>
<vladfaust> `has_constant?` is for `TypeNode`. And what about top level namespace?
<FromGitter>
<j8r> Good point, you could do the same with a const
<FromGitter>
<vladfaust> How can one call `has_constant?` on top level namespace?
<FromGitter>
<j8r> @jwaldrip don't now so. There may be already issues lying, or else you could open one
<FromGitter>
<vladfaust> Something like `TopLevelNamespace.has_constant?("PG")`
<FromGitter>
<jrfondren> rather there should be some answer to "how does crystal do C Preprocessor-like #ifdef stuff" ⏎ maybe the answer is "your build should do that instead"
<FromGitter>
<jrfondren> *build system
<FromGitter>
<jrfondren> but, with stuff like this in the docs: {% if flag?(:x86_64) %}
<FromGitter>
<jrfondren> it might just be an oversight
<FromGitter>
<straight-shoota> @vladfaust `@type` on top level scope
<FromGitter>
<vladfaust> @straight-shoota yeah, it works. Thanks!
<FromGitter>
<jrfondren> huh? how does it work?
_whitelogger has joined #crystal-lang
return0e has quit [Ping timeout: 245 seconds]
<robacarp>
man, the macro verbatim block cleaned up a lot of \{{ cruft for me today
sz0 has quit [Quit: Connection closed for inactivity]