RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.26.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
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <girng> i was reading this https://github.com/crystal-lang/crystal-db/blob/be139c900c86e28b150b9808c74d2a4dd2bb913b/src/db/mapping.cr#L3, might have to do `from_rs` instead of `, as: DB_User_Items` gonna try this
return0e has joined #crystal-lang
return0xe has quit [Ping timeout: 245 seconds]
<FromGitter> <girng> i created issue https://github.com/crystal-lang/crystal-db/issues/92
f1refly has quit [Ping timeout: 246 seconds]
f1refly has joined #crystal-lang
thews has quit [Excess Flood]
thews has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
Groogy1 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
Raimondii has joined #crystal-lang
ashirase has quit [Ping timeout: 240 seconds]
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
ashirase has joined #crystal-lang
Yxhuvud has quit [Read error: Connection reset by peer]
Groogy1 has quit [Ping timeout: 240 seconds]
Groogy1 has joined #crystal-lang
<FromGitter> <vladfaust> Excuse me, does crystal-mysql support arrays?
<FromGitter> <jrfondren> support arrays, how? where do you want to use arrays?
<FromGitter> <jrfondren> like there's this right in the readme
<FromGitter> <jrfondren> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b963e791e2b442a25eda4d5]
<FromGitter> <vladfaust> Yep, this one. Thanks, @jrfondren
lvmbdv has joined #crystal-lang
Groogy1 has quit [Ping timeout: 240 seconds]
<FromGitter> <drum445> anybody here know how I can convert a string to a binary representation please?
<FromGitter> <drum445> I've loaded an image but need to convert this to binary
<FromGitter> <j8r> https://crystal-lang.org/api/master/Slice.html#hexdump-instance-method , with `"mystring".to_slice.hexdump`?
<FromGitter> <drum445> is that binary?
<FromGitter> <drum445> https://play.crystal-lang.org/#/r/4xi9 ⏎ i'd expect: 01101000 01101001
Groogy1 has joined #crystal-lang
<FromGitter> <jrfondren> 0110100 01101001 it a string of characters, '0' '1' and ' ', that you might derive from two numerical values
<FromGitter> <jrfondren> if that's what you want, then loop over the bytes of "mystring" and print each char as a binary number
<FromGitter> <drum445> 01101000 = h ⏎ 01101001 = i
<FromGitter> <drum445> I don't follow how sorry
<FromGitter> <jrfondren> what part don't you know?
<FromGitter> <drum445> Is how I would do it in Python
<FromGitter> <jrfondren> OK. what part of that don't you know, in Crystal?
<FromGitter> <drum445> format(ord(x), 'b')
<FromGitter> <jrfondren> https://crystal-lang.org/api/0.26.1/Int.html#to_s(base:Int,upcase:Bool=false)-instance-method
<FromGitter> <j8r> `'p "abc".to_slice.map(&.to_s(2)).join'`
<FromGitter> <j8r> the join can be removed to have a Slice
<FromGitter> <drum445> perfect, cheers chaps
<FromGitter> <drum445> is there a way to convert it back sorry
<FromGitter> <drum445> ?
<FromGitter> <drum445> so if I make changes in binary I want to convert that back to the string representation please
<FromGitter> <drum445> ah I see what I'm missing, I need a binread method on a file :(
<FromGitter> <jrfondren> https://crystal-lang.org/api/0.26.1/String.html#to_i(base:Int=10,whitespace=true,underscore=false,prefix=false,strict=true,&block)-instance-method
_whitelogger has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
shalmezad has joined #crystal-lang
<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.
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
_whitelogger has joined #crystal-lang
<FromGitter> <j8r> https://carc.in/#/r/4xjy
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
<FromGitter> <xababafr> I have a problem with fibers ⏎ ⏎ https://play.crystal-lang.org/#/r/4xk4 ⏎ ⏎ Can someone explain to me why the fibers are called in this order? To me, it should be (1/2/3/4) every single iterations... [https://gitter.im/crystal-lang/crystal?at=5b967d64e481f854a6997e37]
<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/" ...
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter> <asterite> It's in the Location http response header
<FromGitter> <drum445> Thanks @asterite, https://carc.in/#/r/4xmb
<FromGitter> <drum445> do you know how I can complete that playground please sir
I0 has joined #crystal-lang
DTZUZO has quit [Ping timeout: 252 seconds]
I0 has left #crystal-lang ["Leaving"]
<FromGitter> <bmulvihill> @drum445 is this what you mean? https://carc.in/#/r/4xn2
<FromGitter> <drum445> it is, thank you sir
<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> <jrfondren> for zip... I dunno. the answer might be in docs relating to https://crystal-lang.org/api/0.26.1/Zip/FileInfo.html
<FromGitter> <drum445> gzip is fine cheers, trying to keep permissions after compress/extract
Yxhuvud has joined #crystal-lang
druonysus has joined #crystal-lang
<FromGitter> <jwaldrip> Is static linking broken in alpine?
<FromGitter> <jwaldrip> or is something wrong with my Dockerfile?
<FromGitter> <jwaldrip> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b96c1234771ae5e6e47e1d1]
<FromGitter> <jwaldrip> I get the following error:
<FromGitter> <jwaldrip> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b96c141ef1aba7463799ab4]
Raimondi has quit [Ping timeout: 240 seconds]
Raimondi has joined #crystal-lang
<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> <jrfondren> over at https://crystal-lang.org/api/0.26.1/
<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> <vladfaust> Hi, can I safely check if constant is defined on the top level? E.g. ⏎ ⏎ ```if is_defined(PG) ⏎ if db.driver.is_a?(PG::Driver) ⏎ # ... ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5b96d7f333ebb72e37faafac]
shalmezad has quit [Quit: Leaving]
<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> I'm sure it's already solved
<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]