RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.0 | 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> <hmans> @paulcsmith Is that assuming you're terminating SSL yourself (in Crystal/Lucky)?
<FromGitter> <paulcsmith> I'm not quite sure yet (still exploring), but I want it to check if the protocol is https and if it is not, do a permanent redirect to the request host/resource
<FromGitter> <paulcsmith> I'm thinking for now I just check for an `X-Forwarded-Proto` header manually since there doesn't seem to be an `ssl?` or `protocol` method
<FromGitter> <Blacksmoke16> can i have some help with JSON::PullParser?
<FromGitter> <Blacksmoke16> the converter should parse the object and set the scope property to `"esi-wallet.read_character_wallet.v1"`
<FromGitter> <Blacksmoke16> but idk what im doing :(
<FromGitter> <Blacksmoke16> oh wait would help if my JSON is valid
<literal> does Crystal have anything like File.which() from the Ruby ptools gem?
rocx has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/4cu0 i figured it out \o/
<FromGitter> <Blacksmoke16> what did that do?
zachk has quit [Quit: Leaving]
<FromGitter> <fgimian> literal: `Process.find_executable` perhaps? 😄
<literal> oh, indeed
<FromGitter> <Qwerp-Derp> Is it possible to call `crystal format` within Crystal without using a shell command?
rocx has quit [Remote host closed the connection]
rocx has joined #crystal-lang
<FromGitter> <bew> @Qwerp-Derp yes, checkout the class Process
<FromGitter> <faustinoaq> Wow, JavaScript Frameworks/Libs are so popular 😅
<FromGitter> <faustinoaq> The world is being written in JS 😅
wontruefree has joined #crystal-lang
<FromGitter> <Qwerp-Derp> @bew I don't want to use process though, I want to do this natively
<FromGitter> <bew> Why?
<FromGitter> <bew> Process makes your life a lot easier to create and manage system processes
<FromGitter> <bew> What do you mean by "natively"?
<FromGitter> <codenoid> what are wrong with crystal-mysql ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5b2db63e59799e701739e70a]
<FromGitter> <codenoid> @bcardiff
<FromGitter> <bew> Nobody can help at this point
<FromGitter> <bew> You'd have to provide more data, compile with debug info, tell us what you were doing, etc..
<FromGitter> <Qwerp-Derp> @bew I looked at Crystal::Formatter, I was wondering if I could just use that class and parse a file like that
<FromGitter> <bew> Maybe, it all depends on what you're trying to do
<FromGitter> <codenoid> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2db6e2d2abe4668881a51b]
<FromGitter> <Qwerp-Derp> I'm basically doing something like React, where I'm replacing a block of code that's not Crystal with Crystal, and then I want to format that
<FromGitter> <Qwerp-Derp> Since the output from my parser isn't indented and stuff
<FromGitter> <bew> You can simply import the Crystal parser, call parse on the code, then to_s on the result, et voilà
That_Guy_Anon1 has joined #crystal-lang
<FromGitter> <Qwerp-Derp> How do I import the Crystal parser?
<FromGitter> <Qwerp-Derp> Do I literally have to go to where Crystal is installed and require a huge path from there?
<FromGitter> <bew> `require "compiler/crystal/syntax"`
<FromGitter> <Qwerp-Derp> Oh, neat
<FromGitter> <Qwerp-Derp> Wait but the parser doesn't format the file does it?
That_Guy_Anon has quit [Ping timeout: 276 seconds]
<FromGitter> <S-YOU> require "compiler/crystal/formatter"
<FromGitter> <bew> I don't think he needs the full formatter, a `to_s` is enough
<FromGitter> <Qwerp-Derp> Is the native parser much faster than `Formatter`?
<FromGitter> <bew> actually I don't know, maybe not
<FromGitter> <Qwerp-Derp> Because if not, I might just use Formatter since when I look back on the code I'll know what it does
<FromGitter> <Qwerp-Derp> How can I make do something like this?
<FromGitter> <Qwerp-Derp> ```crx do ⏎ # Insert another language's code here ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5b2dbc417d3bca737a02ac3b]
<FromGitter> <Qwerp-Derp> I want to process everything within the `crx do` block as another language entirely, parse it, and turn it into native crystal code
<FromGitter> <bew> that's pretty hard to do, which language?
<FromGitter> <Qwerp-Derp> It's a custom markup language that I made
<FromGitter> <Qwerp-Derp> Should I just use heredocs or something
<FromGitter> <bew> that would be much easier
<FromGitter> <codenoid> i move to mongo
<FromGitter> <codenoid> i love mongo
<FromGitter> <codenoid> btw, i have "212.442", what a regexp to find first "212." in string
<FromGitter> <bew> @codenoid you should learn about how regex works, and how to make one, this one is quite easy to start
<FromGitter> <codenoid> yeah @bew , actually 212. and 442 is dynamic value, i think i can use only /212./
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/GESI published new version of my script that uses crystal :)
<FromGitter> <Blacksmoke16> 👍
snsei has joined #crystal-lang
<FromGitter> <S-YOU> Interesting
snsei has quit [Ping timeout: 276 seconds]
<FromGitter> <Blacksmoke16> @codenoid https://regexr.com/3rfil
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> is a helpful website to help learn as well
<FromGitter> <bew> `/(\d+)\./` (note: @Blacksmoke16 without `\`, `.` means any char, so `123a` is valid with your regex)
<FromGitter> <Blacksmoke16> yea i updated it
<FromGitter> <bew> 👍
greengriminal has joined #crystal-lang
<FromGitter> <bew> a regex always look odd ^^
<FromGitter> <Blacksmoke16> its amazing how powerful it can be, yet so simple if you think about it
DTZUZO has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
pwned has joined #crystal-lang
<FromGitter> <vusaalab> Hi guys do you have any idea why this happened ⏎ in src/ffmpeg/movie.cr:41: undefined method 'select' for JSON::Any ⏎ ⏎ ``` @metadata["streams"].select { |stream| stream["codec_type"] === "audio" }``` [https://gitter.im/crystal-lang/crystal?at=5b2dda266ceffe4eba2a4528]
<FromGitter> <vusaalab> Hi guys do you have any idea why this happens ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2ddaec0168e70c08e5b378]
<FromGitter> <Qwerp-Derp> What is `@metadata["streams"]` meant to be
<FromGitter> <vusaalab> it is json array ( JSON::Any )
<FromGitter> <Qwerp-Derp> You have to put `.to_a` after `@metadata["streams"]`
<FromGitter> <Qwerp-Derp> to cast the value into an array
<FromGitter> <vusaalab> I did it ⏎ undefined method 'to_a' for JSON::Any (did you mean 'to_s'?)
<FromGitter> <Qwerp-Derp> `.as_a` sorry
<FromGitter> <vusaalab> Thank you it is working
<FromGitter> <fgimian> yep, you'll need to cast it specifically
<FromGitter> <hmans> @paulcsmith Sorry, I had to catch some sleep... it was around 2am here when we talked
<FromGitter> <hmans> @paulcsmith If you have an external web server process (eg. nginx) terminate your SSL for you, it'll usually set a header like that for you to look for, yes.
<FromGitter> <hmans> @paulcsmith If you intend to terminate the SSL yourself (and I have no idea if this is a good idea to begin with, but I'm not an expert on these matters), I would *guess* you could set up two separate HTTP::Server instances, one for plain HTTP, one for HTTPS, and have the latter provide some piece of information through its env/context.
<FromGitter> <hmans> @paulcsmith If there is a more straight-forward way of doing it, I'm not seeing it
<FromGitter> <rishavs> How do I add elements to a hash? the normal js/json way is throwing exception; ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2de3a5479ca26689778d4a]
<FromGitter> <hmans> @rishavs Try `err_content["details"] = ...`
<FromGitter> <rishavs> already tried that; ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2de44359799e70173a2918]
<FromGitter> <hmans> `to_json` will return a String.
<FromGitter> <hmans> You can't add things to a String like you would add them to a hash.
<FromGitter> <hmans> Add `err_content["details"]` first, before calling `to_json` on it.
<FromGitter> <rishavs> shucks. that was a stupid error. I guess i need to rest soon. Thanks!
<crystal-gh> [crystal] fgimian opened pull request #6248: Corrected missing return value in the FileInfo flags method (master...bug/missing-return-for-flags) https://git.io/f4yNw
That_Guy_Anon has joined #crystal-lang
<FromGitter> <Qwerp-Derp> Is it possible to somehow leverage the Crystal compiler to make custom `do` blocks with new syntax? I want to basically do something like react.js, and inject HDML (my markup language)'s code into that custom `do` block
<FromGitter> <Qwerp-Derp> Nevermind I'll just do something like duktape
<FromGitter> <hmans> Do you have an example of what you're aiming at?
<FromGitter> <Qwerp-Derp> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e023a7d3bca737a031e81]
<FromGitter> <Qwerp-Derp> Pretty much everything within `crx do` and `end` is the custom markup language
<FromGitter> <Qwerp-Derp> And this is in a custom file extension `.crx`, which gets parsed into `.cr`
<FromGitter> <Qwerp-Derp> Pretty much what `react.js` does except for Crystal
<FromGitter> <hmans> When you're referring to `react.js`, I'm assuming you mean JSX?
<FromGitter> <Qwerp-Derp> Yeah
<FromGitter> <hmans> Well, considering your crx syntax is not related to valid Crystal syntax, you could just plug it into a HEREDOC and pass that to your parser (which could be a macro so it happens at compile time.)
rohitpaulk has joined #crystal-lang
<FromGitter> <S-YOU> ```button, #button, { ⏎ text: "Hello, World!" ⏎ }``` ⏎ ⏎ could be valid crystal, imo. [https://gitter.im/crystal-lang/crystal?at=5b2e047aaeb8fa0c073acaf7]
<FromGitter> <S-YOU> or with do ... end instead of NamedTuple
<FromGitter> <hmans> If you're willing to make it valid Crystal syntax, consider that there's a category of packages in the React world like hyperscript (and its many friends) that basically provide a JS DSL for generating HTML (in place of JSX)
<FromGitter> <hmans> I remember seeing a package like that for Crystal, so at least one other person is going in this direction at the moment.
<FromGitter> <hmans> Consider that HTML (or XML) tags are really just things with 0-n attributes and optional content, so it should map nicely to just plain Crystal methods.
<FromGitter> <hmans> Nah, it was a shard that only implemented a HTML generation DSL... I don't remember its name sadly
<lvmbdv> wait that's not it
<lvmbdv> same author tho
<lvmbdv> this one https://github.com/f/temel
<lvmbdv> sorry, i'm still drowsy
<FromGitter> <hmans> Found it: https://github.com/Willamin/morganite/blob/master/spec/morganite_spec.cr -- but it looks abandoned,
<FromGitter> <hmans> Since I could use such a thing in my project, I'm sort of tempted to whip something up... hm
<FromGitter> <fgimian> Hey guys, can you assist me with this implementation please?
<FromGitter> <fgimian> Using this algorithm to walk a large directory results in a `Too many open files (Errno)` error
<FromGitter> <fgimian> Python's `os.walk` or the `find` command has no issue
<FromGitter> <fgimian> perhaps i'm doing something incorrectly
<lvmbdv> maybe you or stdlib use `open()` for each visited file instead of `stat()`
<lvmbdv> linux has a (changable) limit for the amount of open file descriptors per process
<FromGitter> <fgimian> yeah, though I shouldn't have to change the limit as other tools work
<FromGitter> <fgimian> perhaps stdlib is doing a `stat` as you said though
<FromGitter> <fgimian> as per the stack trace, there's some opening going on
<FromGitter> <fgimian> there's a method called Dir.close
<FromGitter> <fgimian> ok that did it
<FromGitter> <fgimian> not really documented in the docs though 😕
Raimondii has joined #crystal-lang
Raimondii is now known as Raimondi
<FromGitter> <rishavs> Is there any way to query the error/exception object on demand (not via the begin rescue pattern) ?
<FromGitter> <gdotdesign> @hmans if you are looking for a DSL for building HTML there is https://github.com/anykeyh/tree_template
That_Guy_Anon has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
_whitelogger has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
Jenz has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
moei has quit [Quit: Leaving...]
mikhail has joined #crystal-lang
mikhail has quit [Client Quit]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
_whitelogger has joined #crystal-lang
pwned has quit [Quit: Lost terminal]
<FromGitter> <hmans> @gdotdesign Nice, thanks. Is it being used by any framework/app?
<FromGitter> <gdotdesign> I'm using it in Mint, not aware of any other
Jenz has quit [Ping timeout: 260 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
dxt has joined #crystal-lang
<dxt> https://play.crystal-lang.org/#/r/4d2w why does it print such a strange error message?
<FromGitter> <hmans> Because it's not valid syntax.
<FromGitter> <hmans> I think you missed a `def` in line 8.
<dxt> okay lol im giving up for today
<dxt> thanks. i think im in need for sleep or coffee
<FromGitter> <hmans> \o/
That_Guy_Anon has joined #crystal-lang
<FromGitter> <j8r> @n00ax I've found https://github.com/multiarch/crossbuild , and personally using https://github.com/multiarch/qemu-user-static
dxt has quit [Ping timeout: 245 seconds]
That_Guy_Anon1 has joined #crystal-lang
That_Guy_Anon has quit [Ping timeout: 276 seconds]
That_Guy_Anon1 has quit [Client Quit]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
<FromGitter> <fgimian> Hey guys, can you think of a shorter or cleaner way to get the MD5 checksum of a file than this? https://play.crystal-lang.org/#/r/4d36
<FromGitter> <S-YOU> Kind of joke, :D ⏎ ⏎ ```icr(0.24.2) > `md5 -q mandelbrot` ⏎ => "923a11704ec4b4acd0d277fd06eeec92\n"``` [https://gitter.im/crystal-lang/crystal?at=5b2e5032960fcd4eb91d0543]
<FromGitter> <fgimian> 😆
<FromGitter> <fgimian> 🏃
<FromGitter> <fgimian> I will admit that Crystal doing this particular task is much slower than the `md5sum` command
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e50f0ce3b0f268d3ce5ba]
<FromGitter> <fgimian> 😢
<FromGitter> <S-YOU> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e511dd2abe4668883feec]
<FromGitter> <fgimian> i'll try that one out, thanks
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e515a0168e70c08e8491d]
<FromGitter> <fgimian> Python beat Crystal in this one
<FromGitter> <fgimian> hmm using OpenSSL::MD5 is not great because I can't buffer the data to it I think
<FromGitter> <fgimian> if I have a big file, this could be a big problem
<FromGitter> <S-YOU> I see, but you can aways call C function directly
<FromGitter> <S-YOU> ```buffer = uninitialized UInt8[16] ⏎ LibCrypto.md5(data, bytesize, buffer)``` [https://gitter.im/crystal-lang/crystal?at=5b2e522c6ceffe4eba2cc978]
<FromGitter> <fgimian> true, I've not really understood what `update` is doing yet, but if I can incorporate the buffering then this may be the best approach
<FromGitter> <fgimian> the `.update` method is the one taking all the time in the md5 lib
<FromGitter> <S-YOU> Yeah, you can append multiple payload with update
<FromGitter> <fgimian> oh cool
<FromGitter> <fgimian> true
<FromGitter> <fgimian> I'm just sad that Python beat it
<FromGitter> <S-YOU> C beat it, not python
<FromGitter> <fgimian> true, I'm certain Python is using a C implementation under the hood
<FromGitter> <fgimian> oh, it seems they use OpenSSL under the hood
<FromGitter> <fgimian> thanks, i'll try that
<FromGitter> <S-YOU> I double that StaticArray has little overhead, if you pass it around.
<FromGitter> <fgimian> yeah
<FromGitter> <fgimian> do you think it's worth raising a case on the poor performance of the native implementation?
<FromGitter> <S-YOU> Well, it will basically be low priority, in my opinion.
<FromGitter> <S-YOU> There is room to improve C binding I think.
<FromGitter> <fgimian> yeah that's what I think too
<FromGitter> <S-YOU> I mean, the way you call or init, update stuff.
<FromGitter> <fgimian> exactly yeah
<FromGitter> <fgimian> it would be nice to see a similar interface to Digest for OpenSSL
<FromGitter> <S-YOU> I guess, performance issue on processing file, not checksum but I will try to measure.
<FromGitter> <S-YOU> how about file size? 50M?
<FromGitter> <fgimian> yep 43 MB in my case
<FromGitter> <fgimian> i found this in the unit tests
<FromGitter> <S-YOU> May be I will make LibMd5sum, lol
<FromGitter> <fgimian> So perhaps there is a nice way do build it up
<FromGitter> <S-YOU> Not using openssl, it means it can do extreme optimization for only purpose.
<FromGitter> <fgimian> aah I see
<FromGitter> <S-YOU> as I thought, It does not load whole file, it read chunk by chunks and processing md5 during that. It mean there can be only one small allocation, and reuse it.
<FromGitter> <fgimian> yeah
<FromGitter> <fgimian> I found a few useful things in the unit tests for OpenSSl
<FromGitter> <fgimian> I think this will work! 😄
<FromGitter> <S-YOU> Cool
<FromGitter> <fgimian> I'll let you know how I go soon
<FromGitter> <fgimian> 🍺
<FromGitter> <S-YOU> You're welcome 🍻
<FromGitter> <fgimian> sadly the same result my friend
dxt has joined #crystal-lang
<FromGitter> <fgimian> this took `0.462s`
<FromGitter> <fgimian> if i remove the `io.read` line I think all the time will be reduced
<FromGitter> <fgimian> np buddy
<FromGitter> <S-YOU> sorry again, try File.read only
<FromGitter> <S-YOU> I doubt that it is file read it is slow.
<FromGitter> <fgimian> yeah it's not File.read, but I'll double check
<FromGitter> <fgimian> just for the reading of the file in 1024 byte blocks, I get `0.024s`
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e579eaeb8fa0c073bdfe9]
<FromGitter> <S-YOU> buffer too smal
<FromGitter> <fgimian> i'll try a bigger one
<FromGitter> <S-YOU> One block is normally larger than 4k in disk (depends on filesystem)
<FromGitter> <fgimian> true
<FromGitter> <fgimian> 16384 bytes => `019s`
<FromGitter> <S-YOU> you can read like 256k (optimal is depends on OS, File System or Disk type)
<FromGitter> <fgimian> ok let me try
<FromGitter> <fgimian> i'll try going higher
<FromGitter> <fgimian> probably about 0.17s is the best I can do
<FromGitter> <fgimian> is that bad for a 43 MB file?
<FromGitter> <fgimian> i need to try in Python too
<FromGitter> <S-YOU> I see. let me try without overhead here
<FromGitter> <fgimian> yeah Python is slower for the reading
<FromGitter> <fgimian> ``````
<FromGitter> <fgimian> so I think my problem REALLY is the MD5 algorithm
<FromGitter> <S-YOU> okay
<FromGitter> <S-YOU> well, right
<FromGitter> <fgimian> 😢
<FromGitter> <S-YOU> fileread only without overhead on my machine ⏎ time ./md5sum ~/Downloads/pianoteq_trial_v621.dmg ⏎ 44693913 ⏎ ./md5sum ~/Downloads/pianoteq_trial_v621.dmg 0.00s user 0.04s system 89% cpu 0.043 total [https://gitter.im/crystal-lang/crystal?at=5b2e5902ad21887018d80f56]
<FromGitter> <fgimian> oh yea
<FromGitter> <S-YOU> yeah, i will try md5 very soon now
<FromGitter> <codenoid> yeah, something you need to find your-self algorithm for your self-problem
<FromGitter> <fgimian> around 0.4s on my MBP
<FromGitter> <fgimian> i wonder if Python C libraries and md5sum are using multiple cores or something like that
<FromGitter> <fgimian> i'll check
<FromGitter> <fgimian> i have some huge Linux ISOs I can md5sum
<FromGitter> <fgimian> nah, same CPU usage and spread across the cores I can see
<FromGitter> <codenoid> you need to do hardwork, to meet your girlfriend
<FromGitter> <codenoid> btw, there is no crystal-lang-girl
<FromGitter> <codenoid> cr.girl
<FromGitter> <fgimian> 😆
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e5ae57da8cd7c8c677900]
<FromGitter> <fgimian> here's a big ISO
<FromGitter> <S-YOU> Seems like libcrypto is just slow
<FromGitter> <fgimian> you could well be right mate
<FromGitter> <fgimian> I'm surprised OpenSSL is the same speed
<FromGitter> <S-YOU> they are general purpose libraries.
<FromGitter> <fgimian> true yeah
<FromGitter> <fgimian> maybe I need to see how I can bind directly to md5sum
<FromGitter> <S-YOU> your application is crystal only?
<FromGitter> <fgimian> I'm trying to make it Crystal only yeah; I'm rewriting my Mac automation library
<FromGitter> <S-YOU> I see, checksum is not one time thing? you need high performance on that?
<FromGitter> <S-YOU> Ah
<FromGitter> <fgimian> it's not a dealbreaker because I don't use it so so much, but it would be good
<FromGitter> <S-YOU> yeah
<FromGitter> <fgimian> I think I just discovered something
<FromGitter> <S-YOU> I discovered md5 in assembly too xD - https://www.nayuki.io/res/fast-md5-hash-implementation-in-x86-assembly/md5-fast-x8664.S
<FromGitter> <fgimian> lmao
<FromGitter> <fgimian> i don't think it's MD5 sum!!!
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e5cab59799e70173b92e7]
<FromGitter> <fgimian> oh wait
<FromGitter> <fgimian> this takes 0.285s but I forgot
<FromGitter> <fgimian> I was going to say that this takes more than half the time
<FromGitter> <fgimian> confirmed, with the 43 MB file this takes exactly 0.019s
<FromGitter> <fgimian> so yes it is the MD5 checksum algo i think
<FromGitter> <fgimian> sorry about that, I got excited
<FromGitter> <S-YOU> Thats true, I read LLVM-IR, it was md5_update, no other extra code inside. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e5d5b7d3bca737a03ceac]
<FromGitter> <fgimian> oh nice
<FromGitter> <fgimian> so I guess there's not much I can do except run the `md5sum` command for now?
<FromGitter> <S-YOU> on mac, it is md5
<FromGitter> <fgimian> yeah, you can also install `md5sum` with brew
<FromGitter> <S-YOU> ah
<FromGitter> <fgimian> thanks again for your help
<FromGitter> <fgimian> if I find any better solution, i'll let you know
<FromGitter> <S-YOU> looking for md5sum has external api
<FromGitter> <S-YOU> how do you install md5sum with brew? brew install md5sum got no formula
<FromGitter> <fgimian> ``````
<FromGitter> <fgimian> 😄
<FromGitter> <S-YOU> it is using openssl
<FromGitter> <fgimian> oh is it??
<FromGitter> <fgimian> so it must be something in the detail of Crystal
<FromGitter> <fgimian> i'm just going through the Crystal implementation to see if I can pinpoint the problem
<FromGitter> <S-YOU> it shouldn't. my llvm-ir has no extra crystal, but it is slow like 0.39s
<FromGitter> <S-YOU> but libcrypto
<FromGitter> <fgimian> weird yeah
<FromGitter> <fgimian> while looking through the source, I found a very quick way to get the MD5 checksum of a file
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e5fbcad21887018d81c49]
<FromGitter> <fgimian> the time is still slow though
<FromGitter> <fgimian> around 6 times slower than md5sum
<FromGitter> <S-YOU> hmm, i see. so md5_update is not the correct one.
<FromGitter> <fgimian> @S-YOU I suppose both options are ok, they both give the same results
<FromGitter> <fgimian> I better get to sleep guys, thanks again for your help @S-YOU
<FromGitter> <S-YOU> @vlazar, h2o set date header by default
<FromGitter> <S-YOU> you can't disable date and server header in h2o
<FromGitter> <S-YOU> Also TFB has the test, which check those when you submit PR btw.
<FromGitter> <S-YOU> Good night @fgimian
<FromGitter> <vlazar> oh, great then 👍 trying to update TFB to latest Crystal
<FromGitter> <S-YOU> You should try locally first, it will most likely be break somewhere.
<FromGitter> <S-YOU> But seems like you managed to know which framework do what, awesome!
<FromGitter> <S-YOU> h2o was ok, but it looks like Amber and Kemal has some issue with 0.25.0 - https://travis-ci.org/TechEmpower/FrameworkBenchmarks/jobs/395841205#L2409
<FromGitter> <vlazar> yeah, TFB setup didn't worked for me out of the box, so I cheated a bit, but not everything was checked
<FromGitter> <vlazar> I also think I should wait for 0.25.1
<FromGitter> <S-YOU> I am wondering reuse_port on bind_tcp is not working anymore, or just hiccup?
<FromGitter> <vlazar> I'll look into it, the API changed a lot :)
<FromGitter> <S-YOU> Gone?
alex`` has joined #crystal-lang
Jenz has joined #crystal-lang
<FromGitter> <S-YOU> It should work, bind_tcp has same api
Jenz has quit [Client Quit]
<FromGitter> <S-YOU> hmm, may be not, .listen may be overriding the default parameter with false?
<FromGitter> <S-YOU> Why I wondering is I saw this message on CI ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e691fbe98b1422402aad2]
<FromGitter> <S-YOU> listen also do bind_tcp inside ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e697d72b31d3691ed67b8]
<FromGitter> <codenoid> Hi i still find a way
<FromGitter> <vlazar> yes, not sure what to do with this, probably Kemal needs update
<FromGitter> <S-YOU> you should ask on stackoverflow or serverfault. that is general OS question.
moei has joined #crystal-lang
dxt has quit [Ping timeout: 240 seconds]
dxt has joined #crystal-lang
<FromGitter> <crash2burn_twitter> anyone know of a way to get the class name of an object without the module prefixed (besides doing obj.class.to_s and doing a string operation to remove the prefix)?
That_Guy_Anon has joined #crystal-lang
<FromGitter> <vladfaust> Please see https://play.crystal-lang.org/#/r/4d6f
<FromGitter> <vladfaust> I'd like `do` syntax to work as well
wontruefree has joined #crystal-lang
<FromGitter> <predatorian3> Extremely noob question, but when using HTTP::Server#bind, I keep getting a `no overload matches 'HTTP::Server#bind' with type Int32` even though I copied it directly from the documentation thinking I typed it wrong.
<FromGitter> <predatorian3> What am i being told then to do? using `server.bind 5000` didn't work, `server.bind "0.0.0.0", 5000` didn't either
wontruefree has quit [Max SendQ exceeded]
wontruefree has joined #crystal-lang
<FromGitter> <predatorian3> docs used: https://crystal-lang.org/api/0.25.0/HTTP/Server.html
<FromGitter> <S-YOU> server.bind_tcp "0.0.0.0", 5000?
faustinoaq has quit [Ping timeout: 245 seconds]
<FromGitter> <bew> @vladfaust the problem is that the do..end is on field, not on call
alex`` has quit [Ping timeout: 265 seconds]
<FromGitter> <bew> @predatorian3 see #6179
<DeBot> https://github.com/crystal-lang/crystal/pull/6179 (Fix docs for new HTTP::Server API)
<FromGitter> <codenoid> can IDA decompile crystal(llvm) compiled binary ?
<FromGitter> <codenoid> i mean, with a clear method/function
<FromGitter> <vladfaust> @bew, ⏎ ⏎ ```unterminated parenthesized expression ⏎ ⏎ field x : Int32 = (call do``` [https://gitter.im/crystal-lang/crystal?at=5b2e81d37d3bca737a040b2b]
snsei has joined #crystal-lang
<FromGitter> <vladfaust> But OK, `{}` is enough in my case. It's just a little weird...
snsei has quit [Ping timeout: 260 seconds]
<FromGitter> <S-YOU> @fgimian, one good news, just linking to openssl from brew make it faster ⏎ ⏎ system crypto ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2e84cb467bd7268c2e4065]
<FromGitter> <bew> I think the error for unterminated
<FromGitter> <bew> About unterminated parenthesized expression is a bug, you might want to open an issue
<FromGitter> <bew> As a workaround you could capture the block of field, and use it
Jenz has joined #crystal-lang
<Jenz> How would I parse `{ "list":[1,2,3] }` into a crystal object
<Jenz> ?
<Jenz> `NameTuple(list: Array(Int32))`?
<RX14> that would work
<RX14> you could also just use JSON.mapping
<Jenz> Really? Ok thanks
<RX14> yeah
<RX14> create an object with a single list property
<RX14> thats an Array(Int32)
<RX14> doing that vs using a named tuple would depend on the situation
wontruefree has quit [Quit: bye]
<FromGitter> <n00ax> @j8r Yeah, I saw the former, my only problem with qemu-user-static is that it runs with traditional emulation during the compile phase, which in my experience can be quite slow (albeit provides a more reliable environment, but perhaps I am wrong?)....
dxt has quit [Ping timeout: 260 seconds]
<Jenz> RX14: But why does this fail?: https://play.crystal-lang.org/#/r/4d6k/edit
<FromGitter> <j8r> Yes you are right
<RX14> Jenz, require json
<FromGitter> <j8r> And cross compilation doesn't always works well for all applications
<Jenz> Oh right, lmao
<Jenz> Yeah, thank you very much
<FromGitter> <vlazar> new to docker, used multistage builds to compile static binary in alpine
<FromGitter> <vlazar> works well but there are intermediate docker images left
<FromGitter> <vlazar> is there a better way?
<FromGitter> <vlazar> maybe using separate docker container with alpine + crystal to build binary and then just copy it to clean alpine?
<RX14> nah just clean up the intermediates
<RX14> the intermediates are only there for the build cache next time
<RX14> as in, they're there because they're useful
<RX14> you can delete them with an argument to docker build
<RX14> if you're not going to use the cache anyway
<RX14> docker build --force-rm I think
<FromGitter> <vlazar> use case: constantly changing source and building docker images to run app and test, wouldn't this flow kill my SSD? :)
<FromGitter> <vlazar> intermediate images are always changing too and they are quite large compared to final alpine image with single binary which is like 20Mb
<RX14> yeah
<FromGitter> <vlazar> intermediate are > 400Mb
<crystal-gh> [crystal] jcs opened pull request #6250: Thread.allocate_stack: Pass MAP_STACK to mmap() on OpenBSD (master...master) https://git.io/f4SGf
<FromGitter> <vlazar> I guess I'l just use hard drive than :)
<RX14> @vlazar there are some solutions here: https://github.com/moby/moby/issues/34151
<RX14> you just have to manually delete the intermediates
<FromGitter> <vlazar> thank you! yes, that's what I'm doing now, but this is expensive so I was wondering if there is a cleaner way
zachk has joined #crystal-lang
zachk has quit [Changing host]
zachk has joined #crystal-lang
rocx has quit [Quit: laptop's latch clicking, barstool screeching as he leaves, he hates these mornings. -- a haiku]
Jenz has quit [Quit: leaving]
snsei has joined #crystal-lang
faustinoaq has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
<crystal-gh> [crystal] asterite opened pull request #6251: Add JSON::Any#dup and YAML::Any#dup (master...feature/6220-json-any-dup) https://git.io/f4SnL
<FromGitter> <asterite> Did someone every write a tool to check that code snippets in doc comments compile and run well? I remember someone did it but can't find it... I think it's a nice thing to have, probably fun to implement, so I might give it a try and have it built-in in the language
<FromGitter> <hmans> sup @asterite! I remember having a discussion about doctests here a few weeks ago and not everybody was agreeing they were a good idea.
<FromGitter> <hmans> (I like them.)
<FromGitter> <asterite> Well, given that there are some issues in the docs not being updated to API changes, I think it's a good idea to automate them to prevent them getting out of sync
<FromGitter> <asterite> At least check that they compile...
<FromGitter> <hmans> It'd be great. I'm too useless to help out. Could this work through annotations (ie. the parser converting code blocks within code comments into annotations to be sourced from a doctest statement in a spec?)
That_Guy_Anon has quit [Quit: Leaving]
<FromGitter> <asterite> Maybe. But it's simpler to just scan the code like the doc generator does. So something separate of spec
<FromGitter> <asterite> I
<FromGitter> <asterite> But I found an issue about it and it seems compiling all samples was too slow, so maybe it won't be possible after all
rocx has joined #crystal-lang
<FromGitter> <hmans> Can Macros emit comments to be picked up by the doc generator? (I'm guessing no?)
<FromGitter> <bew> Yes they can
<FromGitter> <j8r> If we look more closely, code snippets and specs overlap quite a bit. If we can generate code snippets from the specs - it may be possible - this will solve the issue, and add a lot more example in the generated API doc (they can be collapsed in the UI)
<FromGitter> <asterite> They way Go does it is good. You can specify some files as examples
<FromGitter> <j8r> This may include specs for us?
<FromGitter> <asterite> What do you mean?
<FromGitter> <hmans> @bew If Macros can emit code comments (that will be picked up by the doc generator), code examples that should be tested could be defined through such macros?
<oprypin> asterite, there was such a tool and i cant find it either
<FromGitter> <j8r> What I mean is the actual code snippets as comments are example. The specs can also be used as examples. So why not use specs?
<oprypin> for some reason i think it was made by a japanese person
<FromGitter> <j8r> haha :)
<oprypin> YES
<oprypin> seems like it parses code with regex tho ¯\_(ツ)_/¯
<FromGitter> <asterite> Strange, the compiler has a very simple way to extract that code, regex is not needed at all for that
<oprypin> j8r, these concepts cover different avenues and merging them gives you something that doesn't quite fulfill either of the purposes
<oprypin> obviously you dont want assertions in examples and you don't want to limit specs so they also happen to be a nice example
<FromGitter> <asterite> Specs are not examples
<FromGitter> <j8r> I don't really get why we can't use them as example... Sure the comments explaining what the method do should be kept, but on the pure code side, most use case should be covered by the related specs of the method?
<FromGitter> <j8r> Sorry I may be wrong, I will see better If you give me an example to prove me wrong 😄
<FromGitter> <hmans> I'm off to bed. Good night everyone.
<FromGitter> <codenoid> spec is like example
<FromGitter> <j8r> Yes! To sum up, today we have comments that explains what objects, methods etc are. This is nice, and for sure won't be touched. ⏎ On another side, there are have also code snippets to add examples to them. ⏎ They tell us how to use, and what they return with e.g `[1, 2] + [2, 3] # => [1,2,2,3]` ⏎ This is exactly what specs do with e.g `([1, 2] + [2, 3]).should eq [1,2,2,3]` ⏎ Furthermore, by their nature,
<FromGitter> ... they cover a lot more of use cases. [https://gitter.im/crystal-lang/crystal?at=5b2ec4375862c35f47c29761]
<FromGitter> <codenoid> yeah
<FromGitter> <Daniel-Worrall> They can be used as examples for users to understand how the classes are supposed to work, but they shouldn't be seen as the same as documentation examples for the API. They are a separate entity and since there have been instances of them not being updated in PRs, a tool to check that the examples compile is at least something we can do to combat that problem
<FromGitter> <Daniel-Worrall> In my opinion, it can be prevented user side if we had a Find Usages tool (like in an ide) so we could make sure the examples in those calls aren't affected by these changes
<FromGitter> <Daniel-Worrall> Another thought is to have all examples have a 1:1 spec and have them described as such in the spec itself so that if it fails in the spec, it can be looked at in the examples.
<FromGitter> <fgimian> @S-YOU THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!! 😄 😄 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2eda6baeb8fa0c073cc036]
<FromGitter> <fgimian> wow, that's a HUGE difference!
<FromGitter> <fgimian> it's actually about as fast as the md5sum command
<FromGitter> <fgimian> using any of my implementations actually gives the identical performance to md5sum
<FromGitter> <fgimian> ```digest = OpenSSL::Digest.new("MD5") ⏎ puts digest.file(path).hexdigest ⏎ ``` [https://gitter.im/crystal-lang/crystal?at=5b2edb2a960fcd4eb91dff9b]
<FromGitter> <j8r> Testing the examples must be done in one way or another, and for now all solutions are heavy. Personally if we ditch all the examples and instead a have nice browsable HTML UI for specs, I will be happy. Of course I'm probably alone to think that 😃