ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.23.1 | Fund Crystal's development: | GH: | Docs: | API: | Gitter:
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <faustinoaq> Just curiosity, Somebody knows if would merely be possible a JVM backend for Crystal, I mean Crystal interop/compiling to JVM like JRuby does. I found this for Android.
_tsound has quit [Ping timeout: 260 seconds]
hightower2 has quit [Ping timeout: 260 seconds]
bcardiff has quit [Quit: bcardiff]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter> <watzon> @faustinoaq I’m sure it would be possible. Someone would just need to figure out how to compile the Crystal ast to Java bytecode
<FromGitter> <faustinoaq> πŸ‘
<FromGitter> <watzon> @faustinoaq if you want to start looking into it I'd definitely be interested in contributing
rohitpaulk has joined #crystal-lang
Renich has quit [Quit: Renich]
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
<FromGitter> <watzon> Is it possible to create a thread that continues after the program ends?
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
<oprypin> no by definition. why?
<oprypin> in fact this might be the single biggest difference between threads and processes in Linux
<oprypin> also depends on what you mean by program
chamar has quit [Read error: Connection reset by peer]
<oprypin> a process can keep running with threads after the main thread ends
<FromGitter> <watzon> Should've thought of that. Ok, how would I run, say Kemal, as it's own process?
_whitelogger has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
tdc has joined #crystal-lang
<oprypin> i feel like there's something really obvious but how do i know with an incomplete description
<oprypin> running a process is like one of the simplest things to do
<oprypin> please describe the result you actually want to get
sz0 has joined #crystal-lang
zaiste has joined #crystal-lang
zaiste has quit [Ping timeout: 240 seconds]
tzekid has joined #crystal-lang
mark_66 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest15800
Guest15800 has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
alex``` has joined #crystal-lang
<FromGitter> <watzon> Really all I'm looking to do is start kemal as a daemon in the background from a cli app
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <bararchy> @watzon You can just tell init or systemd to do that, or, you coult `Process.setsid` after a fork and it will live after the "father" process has died
mark_66 has quit [Ping timeout: 260 seconds]
alex``` has quit [Quit: WeeChat 1.9]
leandrobighetti has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest81141
<FromGitter> <drosehn> It would be good to do more than that. Has anyone written the crystal equivalent of the `daemons` gem? with `daemons/daemonize`?
<FromGitter> <drosehn> (or does kemal already handle most of the steps for `daemonize`?)
Guest81141 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…]
mark_66 has joined #crystal-lang
hightower2 has joined #crystal-lang
hightower2 has quit [Read error: Connection reset by peer]
bmcginty has quit [Ping timeout: 240 seconds]
bmcginty has joined #crystal-lang
unshadow has joined #crystal-lang
unshadow has quit [Client Quit]
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<oprypin> watzon, you just do Process.whatever or if you insist on having it baked into the same binary then maybe fork would work
<oprypin> just use systemd tho :p
<RX14> please don't daemonise your own binaries
<RX14> there's plenty of tools out there that do it for arbitrary binaries and get it right:
<RX14> systemd is one
<RX14> there was another standalone one i forgot about
<FromGitter> <bararchy> Newest passtime activety: stalk
leandrobighetti has quit []
leandrobighetti has joined #crystal-lang
<FromGitter> <akzhan> @RX14 any chances to get #4653 merged?
<FromGitter> <akzhan> And, of course #4675
<RX14> #4675 is pending an opinion from an expert
<RX14> plus it's a pain to review because it's quite a large diff
<FromGitter> <akzhan> @funny-falcon is one of two men who did Ruby 2.4 Hash :)
<RX14> well, there's a reason why we need approval by 2 core team people before a merge
<RX14> to get a second opinion
<RX14> and thats what we need
<FromGitter> <akzhan> Ok. Anyway I think that it should be merged. Hashing algorithm can be changed within minutes later. This is becvause #4675 is about Hashing infrastructure and number normalization.
<FromGitter> <akzhan> It’s better than anything I have seen before. Rust, Python etc.
<RX14> maybe it can be changed within minutes but thats no reason not to get it right first time
<FromGitter> <akzhan> Yes, it is. But there is some misambiquation. Hasing is not high science at all. And we need no cryptographically secure hashing. We need just unpredicable solid one. Proposed hashing is fast and simple.
<RX14> but how do we know it's not predictable
<RX14> we're not experts in hashing algorithms, we don't know whether this new algorithm is any less predictable than 31 * hash + value
<FromGitter> <akzhan> Siphash13 is another option (Rust authors firstly introduce Siphash24 - very slow, but just changed it to Siphash13 due to its speed).
<RX14> and I don't know where to start on proving that
<FromGitter> <akzhan> Ok, i’ll reach funny-falcon to provide numbers :)
<RX14> All I need is one other person with verifiable credentials to OK this and it's good to review
<RX14> it's not about not trusting funny-falcon, it's about getting 2 opinions
<FromGitter> <akzhan> Ok, got it. ⏎ ⏎ But I should note that it is just prerequisite for another work - rebuilding of Hash class itself :)
<RX14> yes
<FromGitter> <akzhan> Do you know anybody else who is hashing expert
<FromGitter> <akzhan> I’m just not expert. It’s ok from my side. But I’m enthusiast :)
<RX14> no, but i'm sure funny-falcon does being an expert himself
<FromGitter> <akzhan> Russian experts usually prefer that someone else say about them. Some variant of modesty :)
<FromGitter> <akzhan> But just asked @funny-falcon. It’s work was looked by Jean-Phillipe Aumasson so I’ll try to reach him.
<FromGitter> <konovod> I think i would be best to change PR to SipHash13 (that is proven and used by rust), then try to merge replacing it with faster hash. So no conflict and discussion on the better hash will not affect infrastructure. Well unless @funny-falcon won't be too offended by using a slow hash.
<RX14> that's an option
<RX14> i think both is fine
rohitpaulk has quit [Ping timeout: 255 seconds]
<FromGitter> <akzhan> Solution is to replace hashing algorithm with slow siphash13. Will do
<FromGitter> <akzhan> Funny falcon hash algorithm will be proposed by another pull request. It will do faster
<RX14> @akzhan if he thinks it's easier to get an expert to OK it rather than implement SipHash13 then he should go for the former
<RX14> but if not, and he's rather just get Hash refactor rolling then he should go for the latter
<RX14> i don't want him to feel that we want siphash13, I don't mind either way, we just need a second opinion
<FromGitter> <funny-falcon> I don't think it is easy to convince expert to analyze non-cryptographic algorithm. ⏎ I may try to explain how it works, but I have no competence to prove anything. ⏎ I don't want to change my PR to siphash13. But I wont be against if some copy code from my PR and reuse it for other PR with siphash inside.
w-p has quit [Ping timeout: 248 seconds]
<FromGitter> <oprypin> b
<jokke> hey
<jokke> hey, how would i go about deploying an amber project to something else than a cloud hoster?
<jokke> i'd want to have it build docker containers and deploy them to via docker stack
<jokke> -to
<FromGitter> <akzhan> just build project got executable and copy it to container (in docker file)
<FromGitter> <akzhan> nothing special.
<FromGitter> <akzhan> you may need to do this with β€”cross-compile option.
<FromGitter> <akzhan> to set llvm target triple to conianer os.
<crystal-gh> [crystal] MakeNowJust opened pull request #4805: Context: show more helpful message for never called method (master...fix/crystal-context/detailed-message-for-nerver-called-method)
<FromGitter> <akzhan> Somebody uses crystallang/crystal image to compile executable within container but it just an option.
<RX14> simple way is just to FROM crystallang/crystal:0.23.1 and then ADD the source, and RUN shards build then set CMD to the executable
<RX14> that's how I would do it
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
<RX14> @funny-falcon I don't even need an expert to look through your hash function, i just need someone to say that the hash function is fine to use.
<FromGitter> <faustinoaq> @watzon A proof concept for Crystal on JVM or NetCore would be interesting, also I'm thinking on a JS backend for Crystal
<FromGitter> <bararchy> Crystal on .Net .... please no
<FromGitter> <akzhan> @RX14 It already approved by me :)
<FromGitter> <faustinoaq> I use dotNet on Linux, is very impressive, also Xamarin.
<FromGitter> <sdogruyol> @akzhan πŸ‘ πŸ˜„
alibby has quit [Ping timeout: 260 seconds]
alibby has joined #crystal-lang
w-p has joined #crystal-lang
<FromGitter> <funny-falcon> @RX14 who is "someone"? @akzhan is "someone" or not? ⏎ I spent a lot of time to convince Rust to switch from siphash24 to siphash13. I knew I could not sell my function to them. ⏎ I had to call Jean-Phillipe Aumasson to join conversation (he joined, cause it were his function). ⏎ And you know what? I had to several times to remind that he is SipHash's author. ⏎ Who is the "someone" who just have
<FromGitter> <faustinoaq> @bararchy Crystal is a front-end for LLVM, I think would be interesting see crystal code running anywhere πŸ˜„ JVM, Native, netCore, WebAssembler, JavaScript. I mean just imagine the possibilities. Ruby already have something like that with IronRuby, JRuby, mRuby, Opal, Rubinius, etc.
<RX14> well if siphash's author came up and said your hash was fine i'd merge it right away @funny-falcon
<RX14> because the person has written a hash which has been accepted and tested and known to be good
<RX14> anyone with verifiable experience in the field is enough
<FromGitter> <funny-falcon> @RX14 :-) see, so you need an expert, despite your previous word. ⏎ ⏎ > anyone with verifiable experience in the field is enough ⏎ I thought, it is "expert" definition. []
<RX14> yes that was implied that "someone" was an expert
<FromGitter> <sdogruyol> lol
<FromGitter> <faustinoaq> I would use Ruby all time but I love Crystal types too much 😜 (just a joke) I love all languages by equal πŸ˜† , I'm just having a fun with Crystal.
<FromGitter> <faustinoaq> Crystal is my choice because types, concurrency and binary distribution πŸ˜„
<FromGitter> <sdogruyol> @faustinoaq true
<FromGitter> <funny-falcon> I'm not fellow of Jean-Phillipe to ask him to analyze my function in public. ⏎ I had the audacity to ask for it in private mail, and his answer was: ⏎ "I had looked at your code and found no obvious flaw... However I've not run statistical tests nor differential cryptanalysis or diffusion tests, so don't take my word as a quality stamp :-)" ⏎ I doubt he will give more exhaustive answer. ⏎ ...
Philpax_ has quit [Ping timeout: 240 seconds]
<FromGitter> <watzon> @faustinoaq a crystal->js transpiler sounds like a grand idea to me
<FromGitter> <akzhan> @funny-falcon it looks like somebody can write statistical tests for hashing algorithms in crystal. is ok for source of it?
<FromGitter> <funny-falcon> I've tested with SMHasher. I could test with hashtest as well.
nikkkk has joined #crystal-lang
nikkkk has quit [Client Quit]
<FromGitter> <akzhan> You have written it in C? afaik, allows C/C++ implementation only
<FromGitter> <akzhan> these results should be attached to pull request
<FromGitter> <akzhan> and C++ implementation should be published too.
<FromGitter> <codenoid> whoaa, active again
<FromGitter> <faustinoaq> IRB compiled to Web Assembly πŸ‘‰
<FromGitter> <faustinoaq> very impressive
<RX14> @funny-falcon that email helps, thanks
<RX14> @akzhan you can call crystal from C++ so it should be fine.
<jokke> RX14: akzhan: hm i wish there was a builtin way to ship the whole cluster (with db container)
<RX14> you mean with docker?
<RX14> isnt that docker compose?
mark_66 has quit [Remote host closed the connection]
<FromGitter> <akzhan> @jokke nobody embeds database into app container. it should be another one. and database files should be outside of database container.
<jokke> RX14: i was thinking about docker stack
<jokke> akzhan: i'm aware ;)
<RX14> jokke, doesn't docker stack just deploy a compose file on swarm?
<jokke> exactly
<RX14> so write a compose file?
<jokke> there's even one included..
<RX14> ok
<jokke> i could just use that
<jokke> i'd still need to build the app container manually.
<jokke> but i guess that's doable :)
<FromGitter> <zatherz> if anybody here has the time, could you try to run this benchmark and give me the output?
<FromGitter> <zatherz> run with `crystal run --release`
<FromGitter> <zatherz> it's to test which method of getting "dependencies" from a json payload (fields that are needed to deserialize other fields) is faster, I want to make sure the results are consistent
<FromGitter> <zatherz> crap, it segfaults for me lol
<FromGitter> <konovod> nice try)
<FromGitter> <funny-falcon> @akzhan ⏎ ⏎ > You have written it in C? ⏎ ⏎ Yes. Current code in PR is mostly funny_hash, and I've tested funny_hash with SMHasher. ... []
rohitpaulk has joined #crystal-lang
Renich has joined #crystal-lang
<FromGitter> <funny-falcon> And I should correct myself: SipHash13 is slower for short strings (cause its finalizer is heavy weight), and it is slower on 32bit platform (cause it uses 64bit arithmetic). funny32_hash is faster on short strings on any platform, and on 32bit platform for any string. ⏎ There is funny64_hash that uses 64bit integers that is always faster than SipHash13, but it is slower on 32bit platform than
<FromGitter> ... funny32_hash. I didn't include it into PR to simplify code.
<FromGitter> <fridgerator> @codenoid those tweets are from april
Renich has quit [Remote host closed the connection]
Renich has joined #crystal-lang
leandrobighetti has quit []
tzekid has quit [Quit: Leaving]
greenbigfrog has quit [Remote host closed the connection]
<FromGitter> <delef> Hi! I have union type, how I can add a method to it? As example: .to_hash (.as_hash)
<FromGitter> <funny-falcon> @delef I think, you have to add method to all of it parts separately.
cyberarm has quit [Ping timeout: 260 seconds]
<FromGitter> <faustinoaq> Interesting way to run code between Crystal and Ruby πŸ‘‰
Ven has joined #crystal-lang
Ven is now known as Guest63750
<oprypin> fridgerator, point is the account was deleted before
<oprypin> so really good news anyway if you ask me
<oprypin> faustinoaq, what in particular? i'm afraid that it's just a tiny subset that will work
<txdv> 88this works for ruby and crystal?
<txdv> :D
<txdv> that is a really difficult subset you are targeting there
<FromGitter> <zatherz> fixed the JSON dependency benchmark
<FromGitter> <zatherz> would appreciate if someone could run it and give me the results so that I can compare
Guest63750 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <faustinoaq> Is just a experiment, I use default values to ensure the same code running on Ruby (
<FromGitter> ...]
<FromGitter> ... JK@Cgj/AWOR@hIWi9jjgHDxCXoEBoN39l7jfvHPXD@PKyn5Ij37Gej3KxRd5Wxhj6uJe0W7LFe9q3de47QsSs51O1apgiNJSzpQeAcTpwe3kqZngC5Nit6@ziHB3zwarb3bhQU1bZzaDFdsjjNbtZ/I8KGnWeC09PuwcP2WWN3hw88ZcM3ppXBlTAjX1P/93BFUdwu56CJ3BqsqJ@@fgdGEx1a@gK7@PH5koz3QzGEs3MYiMGjtXm3fQlUUR7jiCrbUG9xelKDl67ceUU2/gtRROvVrTTrlVQxbp3wE5BOe2ZAwsieotjoaQ0hZoXZffSCMZMFhlQdS0Iy6z@5VN7J2yIvvBolNs/r2HLY8YGG6 ... [https://gi
Ven_ has joined #crystal-lang
greenbigfrog has joined #crystal-lang
<FromGitter> <bararchy> @zatherz Running
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO has quit [Quit: WeeChat 1.9]
DTZUZO has joined #crystal-lang
<FromGitter> <bararchy> ```code paste, see link``` []
<FromGitter> <bararchy> CPU: Intel Xeon CPU E3-1505M v6 @ 4GHz
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest88849
Guest88849 is now known as Ven``
Ven`` has quit [Ping timeout: 240 seconds]
tdc has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
Ven_ has quit [Ping timeout: 248 seconds]
office_boy has joined #crystal-lang
<FromGitter> <code-andres> Hi, fast question how can compile for 32 bits?
<oprypin> yes
<FromGitter> <code-andres> Ok, how? I'm 64bits but i need the exec for 32bits
<oprypin> mh that's not quite it
<FromGitter> <straight-shoota> that should point you in the right direction
<FromGitter> <straight-shoota> you need to add `--cross-compile` and ` --target` with a LLVM target triple
<FromGitter> <code-andres> yeah i forget see the docs...
<FromGitter> <code-andres> Ok... so much thanks
<FromGitter> <watzon> @zatherz force-ordered is definitely the fastest ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <watzon> CPU: Intel i7-4700MQ (8) @ 2.401GHz
A124 has quit [Read error: No route to host]
rohitpaulk has quit [Ping timeout: 240 seconds]
A124 has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest20233
alex`` has joined #crystal-lang
<office_boy> Hey, I'm very new to Crystal. I'm trying to use the Crystagiri shard, but I'm getting issues with require. These are what my files look like:
<office_boy> Error in while requiring "crystagiri": can't find file 'crystagiri' relative to '/Users/office_boy/Downloads/Crystal/crawl/src' require "
<office_boy> I know its a problem with paths, but I even tried require "./crawl/**"
cyberarm has joined #crystal-lang
Guest20233 has quit [Ping timeout: 260 seconds]
<FromGitter> <bew> You need to install the dependencies with `shards install`
<FromGitter> <davidblurton> Can someone tell me how to make a string that contains a hexidecimal escape sequence? I have an array of bytes and want to format them like "\x95"
<FromGitter> <davidblurton> I can't concat "\x" and "95" because I get invalid hex escape
<office_boy> @bew I did `shards install` in '/Users/office_boy/Downloads/Crystal/crawl', but it still doesn't work
<FromGitter> <straight-shoota> @office_boy what does `ls lib/crystagiri` show?
Renich has quit [Remote host closed the connection]
<FromGitter> <straight-shoota> @davidblurton `"\x"` is not a valid string because it has an invalid hex escape
Renich has joined #crystal-lang
<FromGitter> <davidblurton> @straight-shoota I know that crystal understand "\x95" but how can I produce the string "\x95" from the number 95
<office_boy> @straight_shoota All the correct files it seems, this is what lib/crystagiri looks like:
<FromGitter> <straight-shoota> @davidblurton maybe `(Char::ZERO + 0x95).to_s`
<FromGitter> <straight-shoota> ?
<FromGitter> <straight-shoota> @office_boy just to make sure: `echo $SHARDS_INSTALL_PATH`
<FromGitter> <straight-shoota> usually this shouldn't be set
<office_boy> Yep, nothing is set there
<FromGitter> <straight-shoota> what if you require `../lib/crystagiri/src/`?
Renich has quit [Remote host closed the connection]
Renich has joined #crystal-lang
<FromGitter> <straight-shoota> hey, it works =)
<FromGitter> <straight-shoota> now it seems you're just missing libssl... but the program itself gets compiled
<office_boy> Cool, cool!
<office_boy> Thanks :)
<FromGitter> <straight-shoota> yeah but it should work with `crystagiri` as well. this is just a workaround
<FromGitter> <straight-shoota> you should probably create an issue here:
<FromGitter> <straight-shoota> maybe it's just something utterly stupid, but I can't think of a reason why this would fail
<oprypin> davidblurton, if you have an array of bytes, you work with it as an array of bytes. creating malformed strings is not the way to go. are you actually trying to, for whatever reason, turn it into backslash x hexadecimal?
<oprypin> but oh my god there have been like 4 people in the last month trying to do this?
Renich has quit [Quit: Renich]
<FromGitter> <watzon> I can't remember, can we do desctructuring of tuples? Something like `{a, b} = {{status: :ok, message: "Hello, World}, nil}`
<FromGitter> <watzon> Never mind, I figured it out
office_boy has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
DTZUZU has quit [Ping timeout: 255 seconds]
DTZUZO has quit [Ping timeout: 260 seconds]
DTZUZU has joined #crystal-lang
<FromGitter> <drosehn> @watzon @RX14 - wrt `daemonize`, at least some of the BSD's have the unix command named `daemon`, but I don't know if they all do. macOS works with `launchd` (certainly not `systemd`!). And if you're working with macports, macports has a command `daemondo` which I'm not familiar with. It seems to be a front-end to `launchd`. I'm not sure if there is anything special for people on macOS using homebrew
<FromGitter> ... instead of macports.
<FromGitter> <drosehn> @watzon - but you certainly don't want your program trying to guess which system routines would be good to call if the program needs to become a daemon.
leandrobighetti has joined #crystal-lang
<FromGitter> <davidblurton> @oprypin I see now that I should probably leave the data in a slice. I'm implementing a bittorrent client and the tracker responses have mixed utf8 and binary responses. The info hash is URL encoded hex escaped string. I've worked around the problem by going straight to the URL encoded version.
<oprypin> davidblurton, does that string actually go like \x12 ?
<oprypin> even if so, you can't rely on syntactic similarities of the language to pull you through.
<FromGitter> <davidblurton> I'm not sure what you mean by that
<oprypin> same.
DTZUZO has joined #crystal-lang
<FromGitter> <davidblurton> The \x12 would be URI escaped to give "%12" as the string you send to the tracker
<FromGitter> <davidblurton> so if I call URI.unescape I get back "\x12", but I can't make this string any other way...
<oprypin> what use do you have from this string? none at all
<FromGitter> <davidblurton> Right, which is why I said I should leave this data in a slice
<FromGitter> <davidblurton> But the response is mixed utf8 and binary, so it's a bit more tricky
<oprypin> seems like you need this
<oprypin> no idea what the block is for, lol
<oprypin> it's for some special case handling if you need but there's a version without a block
<oprypin> so if you know it's gonna be valid utf-8 you make ` those bytes )`
<FromGitter> <davidblurton> I guess I can do the same with the HTTP::Client response.body
<FromGitter> <davidblurton> use the version with a block to read into a slice and carefully convert to a string
<FromGitter> <watzon> Why does `Array` not have a `filter` method? Is there something similar that's just named differently?
<oprypin> yeah, definitely don't keep arbitrary bytes in a string, it just happens to work but you cant rely on it because all string methods assume utf-8
<oprypin> but yeah `` is the way to blindly stuff things into a string
<FromGitter> <davidblurton> But the data will round trip fine if I were to convert it back to binary?
<oprypin> watzon, select
<oprypin> davidblurton, if you put data into a string, don't modify it, and then obtain raw data from it, yes, it will probably be fine. why would you do that though?
<oprypin> by the way if you read a string from a http endpoint producing arbitrary bytes, that will NOT be fine
<oprypin> probably, i dunno. really unreliable in any case
<FromGitter> <davidblurton> Right, doesn't make any sense.
<FromGitter> <davidblurton> I'll stick to slices
<FromGitter> <davidblurton> Can just read a byte at a time and see if it's utf8
<oprypin> davidblurton, ...uh no?
<oprypin> it has to be known in advance, defined by a protocol, guessing never works
<FromGitter> <davidblurton> I won't be guessing. But I do need to parse the data. Some of it will be strings, some of it bytes.
<oprypin> davidblurton so you have an IO and call this when you expect utf-8 encoded text and other methods otherwise
<oprypin> likely or more advanced variants
leandrobighetti has quit []
<FromGitter> <davidblurton> ```code paste, see link``` ⏎ ⏎ @oprypin How can I improve this? []
hightower2 has joined #crystal-lang
<oprypin> i'm at a loss, can't see an improvement
<FromGitter> <davidblurton> Just leave the data in the an Array? I feel like slices are nicer though
<hightower2> Hey, isn't behavior of Dir.entries( "/directory") a bit weird given that it returns "." and ".." among the results, in unclear sort order? I called it and it returned ["three", "four", "one", ".", "two", ".."]
<oprypin> but maybe you don't actually want to turn it into a slice and leave it in the IO
<FromGitter> <davidblurton> That's true, I could pass the IO directly to my body parser
<oprypin> hightower2, the sort order is not weird, but the .. stuff is indeed silly; unusable
<oprypin> so with the IO you can read a few bytes to a slice, then read a few bytes as a string
<oprypin> which seems to be what you want
<oprypin> but it's always weird how inconvenient it is to go from IO to slice. i guess they don't want people to be wasteful with allocations
<oprypin> like, instead of making a loop creating a new slice every time this encourages reuse
<FromGitter> <davidblurton> I guess I was expecting the client response to have a raw_body property or something
<oprypin> davidblurton, but it allows streaming, it does not contain the whole response
<oprypin> abstracting streaming is the whole reason for IO to exist in addition to Slice
<FromGitter> <davidblurton> right, I'm looking for a simple way to read the whole body though
<FromGitter> <davidblurton> I can see that IO is a nice abstraction for reading and writing, but I don't really care about streams here
<oprypin> davidblurton, but it's also a nice abstraction for protocol parsing
Ven has joined #crystal-lang
Ven is now known as Guest44413
Guest44413 is now known as Ven``
<FromGitter> <davidblurton> I agree, I was using Char::Reader before, until I realised some of the response was binary
<FromGitter> <davidblurton> so should be easy to swap that for an IO
edwinonuonga has joined #crystal-lang
edwinonuonga has quit [Remote host closed the connection]
office_boy has joined #crystal-lang
w-p has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
Renich has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
Renich has quit [Remote host closed the connection]
Renich has joined #crystal-lang
Renich has quit [Ping timeout: 268 seconds]
<FromGitter> <johnjansen> anyone got a nice way to timeout an http get
<FromGitter> <johnjansen> ive done it before, now i cant find the code, or remember what i did
<FromGitter> <johnjansen> forget i asked … stupid me ;-/
office_boy has quit []
<RX14> @johnjansen you need to use then set the timeout on that client instance
<RX14> HTTP::Client needs some love to be honest
<FromGitter> <johnjansen> yep … didnt think to look first, did i ;-)
Ven`` has quit [Ping timeout: 260 seconds]
Philpax_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<hightower2> Hey, if I need to write a 16bit unsigned int in little endian order into some buffer, then 1) What buffer do I use? StringBuilder? and 2) How do I write something like that?
<FromGitter> <johnjansen> @RX14 might have an answer to that, he was here a little while ago
<RX14> hightower2, you should look at the write_bytes method on IO
<RX14> yields you an IO instance
<RX14> so you can use that
<RX14> however writing a raw integer to a string is unlikely to be what you want
<RX14> strings shouldn't contain binary data
<RX14> if you're working with binary data, IO::Memory and Bytes should be what you use
<hightower2> RX14, right, was just about to say that, thanks
DTZUZU has quit [Ping timeout: 268 seconds]
DTZUZO has quit [Ping timeout: 260 seconds]
<FromGitter> <watzon> Anyone know where `stddef.h` would come from? I seem to be missing it. Reinstalled clang and gcc already
DTZUZU has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <watzon> Never mind, I found it in `/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/include`, but clang seems to not be picking it up for some reason. I'm trying to use `crystal_lib` and it keeps telling me `/usr/include/sys/types.h:145:10: fatal error: 'stddef.h' file not found`
<hightower2> I am trying to write data to a socket, and invoke some method/callback when the data is actually written out. Is there a built-in way for this?
greenbigfrog has quit [Quit: The server of my BNC just shutdown or got killed!!!]
<FromGitter> <DougEverly> @drosehn see if works for you