Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:04
    pbrumm synchronize #12822
  • 16:04
    Blacksmoke16 labeled #12823
  • 16:04
    Blacksmoke16 labeled #12822
  • 16:04
    Blacksmoke16 labeled #12822
  • 16:04
    pbrumm opened #12823
  • 16:04
    pbrumm labeled #12823
  • 15:59
    pbrumm opened #12822
  • 14:52
    HertzDevil edited #12390
  • Dec 04 22:42
    straight-shoota closed #12800
  • Dec 04 22:41
    straight-shoota edited #12800
  • Dec 04 22:41
    straight-shoota closed #12770
  • Dec 04 22:41
    straight-shoota closed #12773
  • Dec 04 20:38
    straight-shoota closed #12819
  • Dec 04 17:58
    HertzDevil synchronize #12784
  • Dec 04 15:51
    Blacksmoke16 review_requested #10648
  • Dec 04 15:50
    Blacksmoke16 synchronize #10648
  • Dec 04 15:48
    Blacksmoke16 synchronize #10648
  • Dec 04 15:00
    Blacksmoke16 closed #12820
  • Dec 04 11:38
    straight-shoota closed #12807
  • Dec 04 11:38
    straight-shoota closed #12808
David Blurton
@davidblurton
Just leave the data in the an Array? I feel like slices are nicer though
From IRC (bridge bot)
@FromIRC
<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
David Blurton
@davidblurton
That's true, I could pass the IO directly to my body parser
From IRC (bridge bot)
@FromIRC
<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
David Blurton
@davidblurton
I guess I was expecting the client response to have a raw_body property or something
From IRC (bridge bot)
@FromIRC
<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
David Blurton
@davidblurton
right, I'm looking for a simple way to read the whole body though
I can see that IO is a nice abstraction for reading and writing, but I don't really care about streams here
From IRC (bridge bot)
@FromIRC
<oprypin> @davidblurton, but it's also a nice abstraction for protocol parsing
David Blurton
@davidblurton
I agree, I was using Char::Reader before, until I realised some of the response was binary
so should be easy to swap that for an IO
John Jansen
@johnjansen
anyone got a nice way to timeout an http get
ive done it before, now i cant find the code, or remember what i did
forget i asked … stupid me ;-/
From IRC (bridge bot)
@FromIRC
<RX14> @johnjansen you need to use HTTP::Client.new then set the timeout on that client instance
<RX14> HTTP::Client needs some love to be honest
John Jansen
@johnjansen
yep … didnt think to look first, did i ;-)
From IRC (bridge bot)
@FromIRC
<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?
John Jansen
@johnjansen
@RX14 might have an answer to that, he was here a little while ago
From IRC (bridge bot)
@FromIRC
<RX14> hightower2, you should look at the write_bytes method on IO
<RX14> String.build 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
Chris Watson
@watzon
Anyone know where stddef.h would come from? I seem to be missing it. Reinstalled clang and gcc already
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
From IRC (bridge bot)
@FromIRC
<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?
Doug
@DougEverly
@drosehn see if https://github.com/DougEverly/daemonize.cr works for you
Chris Watson
@watzon
What would the Crystal equivilent of unsigned long be?
Would I do $var_name : Float64?
Zatherz
@zatherz
unsigned long is an integer type
long is, at least on most platforms that crystal targets, Int64
crystal doesn't have things like unsigned, it's separate types, so UInt64
@bararchy @watzon Thanks, I'm gonna use these results for https://gitlab.com/zatherz/magicjson
I'm gonna have an always_ordered option that makes it use force ordered, otherwise I'm gonna use naive w/ reset
Chris Watson
@watzon
Ooh awesome
Good going using GitLab
sevk
@sevk
make crystal as a human language , similar to short english .
Zatherz
@zatherz
what
Chris Watson
@watzon
:confused:
sevk
@sevk
easy++
Chris Watson
@watzon
Anyone know what these would be in a Crystal Lib file?
void numa_init (void);
void numa_uninit (void);