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
return0e has quit [Ping timeout: 252 seconds]
early` has quit [Quit: Leaving]
early has joined #crystal-lang
_whitelogger has joined #crystal-lang
Groogy1 has quit [Ping timeout: 245 seconds]
baweaver is now known as baweaver_away
<FromGitter> <codenoid> hi i have a question,
<FromGitter> <codenoid> there is a text : ⏎ ⏎ ```1.6289630266935 ⏎ 2.6289625946534 ⏎ informationa da szchma : ⏎ 3.6289614763504``` [https://gitter.im/crystal-lang/crystal?at=5b9df16dd655361f7607f7bd]
<FromGitter> <codenoid> what the regex for making value like : ⏎ ⏎ ```6289630266935 ⏎ 6289625946534 ⏎ 6289614763504``` [https://gitter.im/crystal-lang/crystal?at=5b9df19ed655361f7607f912]
DTZUZO has quit [Ping timeout: 252 seconds]
ua_ has quit [Ping timeout: 246 seconds]
ua has joined #crystal-lang
<FromGitter> <bajro17> is maybe this work?
<FromGitter> <bajro17> \d+[^$.]
<FromGitter> <bajro17> @codenoid also you can test here http://www.crystular.org/
<FromGitter> <codenoid> hmm, it will detect 1. 2. etc too
<FromGitter> <bajro17> for me it dont detect
<FromGitter> <bajro17> are you already test?
<FromGitter> <codenoid> yes, but with Sublime-text :
<FromGitter> <codenoid> @bajro17 https://postimg.cc/image/71i9vjohp/024ddb96/
<FromGitter> <bajro17> do you need new line also
<FromGitter> <bajro17> you can match just numbers where is more then 2 or 3 for example
<FromGitter> <bajro17> [\d]{3,}
<FromGitter> <bajro17> or like this
<FromGitter> <bajro17> [0-9]{3,}
moei has quit [Read error: Connection reset by peer]
moei has joined #crystal-lang
<FromGitter> <codenoid> yeah, it's work ✨
<FromGitter> <bajro17> yaaaay :)
ashirase has quit [Ping timeout: 252 seconds]
DTZUZO has joined #crystal-lang
ashirase has joined #crystal-lang
<FromGitter> <codenoid> `GC Warning: Repeated allocation of very large block (appr. size 528384):`
<FromGitter> <j8r> haha yeah like it
jsn- has joined #crystal-lang
return0e has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
<Yxhuvud> codenoid: the challenge seems very .. specialized to make something work the way julia works, rather than actually trying to solve actual problems within a set of constraints.
<FromGitter> <codenoid> umm right 😕 , let he do his own challenge
_whitelogger has joined #crystal-lang
<FromGitter> <bajro17> Can someone review my code I make so simple blockchain program for tutorial purposes its about 50 lines of code
<FromGitter> <bajro17> https://carc.in/#/r/50mo
lagbox has quit [Quit: this isn't woodshop class]
DTZUZO has quit [Ping timeout: 252 seconds]
<FromGitter> <drum445> type in Pravious ;)
sagax has quit [Ping timeout: 252 seconds]
<FromGitter> <drum445> can't see anything wrong with it though mate
sagax has joined #crystal-lang
Raimondi has quit [Quit: WeeChat 2.2: ¡Chau!]
Groogy has joined #crystal-lang
Groogy has quit [Client Quit]
<FromGitter> <j8r> Seems ok to me
<FromGitter> <codenoid> i'm never know, what is blockchain
<FromGitter> <j8r> I think `index` should be a `getter` instead of using `previous_block.@index + 1`
<FromGitter> <j8r> It's better documentation-wise, but nlt sure for the perfs ironically
<FromGitter> <nulty> I'm trying to create a Tuple from and Array. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b9e94c2a56b215c9748d3ec]
<FromGitter> <nulty> Have I misunderstood the docs?
<FromGitter> <nulty> Same for this format ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ crystal play v0.26.1 [https://gitter.im/crystal-lang/crystal?at=5b9e956eb9531f2dfa76df6e]
<FromGitter> <nulty> For some reason this is ok? ⏎ ⏎ ```tuple = Tuple(Int32).from([1,2,3])``` [https://gitter.im/crystal-lang/crystal?at=5b9e97638909f71f75e23b32]
<FromGitter> <nulty> Oh ok the above example doesn't work. I changed it before posting. ⏎ ⏎ The type arguments to Tuple must match exactly the types of the values in the array supplied. ⏎ ⏎ ```tuple = Tuple(Int32,Int32,Int32).from([1,2,3])``` [https://gitter.im/crystal-lang/crystal?at=5b9e9909b9531f2dfa76f2ac]
<lvmbdv> tuples are not just immutable arrays like in python
<lvmbdv> tuples are... well... tuples
<FromGitter> <nulty> I better understand them now. Is there not facility for Tuple to infer the types of the array elements?
<FromGitter> <bajro17> @j8r @codenoid @drum445 Thank you all I will publish this on Medium I make few changes. The hardest part now is to make good text with code to people be interested to read it :)
<FromGitter> <j8r> @bajro17 looking forward the post :)
rohitpaulk has joined #crystal-lang
<FromGitter> <straight-shoota> @Blacksmoke16 #6314 adds number formatting
JesseH has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter> <t-richards> Anyone else having trouble reading the response body of their HTTPS requests? Wondering if this is a "I broke it" problem or a more widespread issue.
<FromGitter> <t-richards> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b9eaf7f1ee2ca650226e27e]
<FromGitter> <t-richards> This gives me a `Invalid memory access (signal 11) at address 0x8`
<FromGitter> <t-richards> https://carc.in/#/r/50pp
lacour has joined #crystal-lang
<FromGitter> <t-richards> Looks like this could be a GNU/Linux-specific issue for 0.26.1
<FromGitter> <mwean> I have a hopefully very basic question about a C binding ⏎ I'm trying to call this function: `int proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize)` ⏎ I have this declaration: `fun proc_pidinfo(pid : Int8, flavor : Int8, arg : UInt64, buffer : LibC::Char*, size : Int32) : Int8` ⏎ and I'm calling it like this: ⏎ ... [https://gitter.im/c
<FromGitter> ... rystal-lang/crystal?at=5b9eb9c9a56b215c9749a261]
<FromGitter> <mwean> but it doesn't seem to be working
<FromGitter> <mwean> since nothing is returned
DTZUZO has joined #crystal-lang
<FromGitter> <mwean> I have no C experience, so I have no idea what I'm doing...
<FromGitter> <mwean> Is there anything obviously wrong?
DTZUZO has quit [Ping timeout: 252 seconds]
<FromGitter> <mwean> Hmm, I changed the `Int8`s to `Int32` and switched to a string: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b9ebc5ea56b215c9749af7a]
<FromGitter> <mwean> Another question is how can I access a C constant?
<FromGitter> <cfsamson> @mwean I think you need to provide some more info for answering this about what your C library is expecting as input.
DTZUZO has joined #crystal-lang
<FromGitter> <mwean> Other than the signature, the only thing I know is this SO example: https://stackoverflow.com/questions/8327139/working-directory-of-running-process-on-mac-os ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b9ec6c77dca3065030eab6f]
<FromGitter> <mwean> oh, is it maybe that struct instead of just a string? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b9ec711b4990c30eec58fa4]
<FromGitter> <Timbus> that doesnt return a string.. yeah
<FromGitter> <Timbus> you should make the struct(s) required to access the data. then pass it in, using `out`
<FromGitter> <cfsamson> @mwean yeah, &vpi is a struct, so you need to look at that and do as @Timbus suggests...
<FromGitter> <mwean> do I have to copy all the struct definitions into my `Lib` block too?
<oprypin> yes
<FromGitter> <cfsamson> I think so
<FromGitter> <mwean> ok, I'll try that
<FromGitter> <cfsamson> GL
<FromGitter> <mwean> do I have to do the same with the constant?
<oprypin> mwean, what constant
<FromGitter> <cfsamson> I don't think you need too, but you might have to use one of the C types. Look at: https://crystal-lang.org/docs/syntax_and_semantics/c_bindings/constants.html
<oprypin> i doubt that it's this type of constant so i requested clarification before suggesting a possibly misleading path
<oprypin> well actually it probably is this type of constant
<FromGitter> <cfsamson> You can also look at this for how to alias to different c types (just an example): https://github.com/crystal-lang/crystal/blob/master/src/big/lib_gmp.cr
<FromGitter> <mwean> if I just use the constant directly, I get `undefined constant PROC_PIDVNODEPATHINFO`
<oprypin> the thing is, it's useful to understand that C libraries don't usually deal with conventional constants, it's usually macros which cause literal expansion into a literal before compilation
<FromGitter> <mwean> if I do `$const = PROC_PIDVNODEPATHINFO : Int8` and `LibProc.const`, I get ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b9eca40f4bd1056ac71b5cc]
<FromGitter> <mwean> it's defined as `#define PROC_PIDVNODEPATHINFO9`
<oprypin> thank you, finally what i need to see
<oprypin> cuz i was looking really hard and never found where it's defined https://www.google.com/search?q=%22PROC_PIDVNODEPATHINFO%22
<oprypin> mwean, so it is what i was talking about, and you have no way to reference such a value because it's not part of any compiled library
<FromGitter> <mwean> ah, ok
<oprypin> for the case of macros you just have to hardcode it into your lib
<oprypin> PROC_PIDVNODEPATHINFO = 9
<FromGitter> <cfsamson> ty, I learned something new myself!
return0e has quit [Remote host closed the connection]
<oprypin> mwean, and you probably shouldnt default to marking things as `Int8`, it's a one-byte type. and `int` is usually 4 bytes (`Int32`). best practice is to use `LibC::Int` even though technically it's always equal to `Int32` at the moment
<FromGitter> <mwean> oh, ok thanks!
return0e has joined #crystal-lang
<FromGitter> <oprypin> @mwean something to get you started ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b9ecdf40cfe7f30f1a40d5f]
ashirase has quit [Ping timeout: 244 seconds]
<FromGitter> <mwean> awesome, thanks!
<FromGitter> <mwean> that struct is so deeply-nested!
DTZUZU has joined #crystal-lang
<FromGitter> <mwean> ok, I think I'm really close
<FromGitter> <mwean> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b9ed4bef08bc22dfb688adc]
<FromGitter> <mwean> I'm getting ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b9ed4e6f7e1580625dedef3]
<FromGitter> <mwean> I had to make some modifications to the C struct definitions, I'm not sure if those are the problem
<FromGitter> <mwean> I don't care about most of the fields, so it would be great if I could just ignore them somehow
<FromGitter> <mwean> sorry for all the questions. I really appreciate all the help!
<FromGitter> <mwean> `puts vpi.pvi_cdir` is `Pointer(LibProc::VnodeInfoPath).null`
sagax has quit [Quit: Konversation terminated!]
<FromGitter> <cfsamson> There is two things that might help. 1. It seems that bpi.pvi_cdir is a pointer
<FromGitter> <mwean> I tried `out` and got `Error in test.cr:68: can't use out with Void* (argument 'buffer' of LibProc.proc_pidinfo is Void*)`
<FromGitter> <cfsamson> To get the value of a pointer use `vpi.pvi_cdir.value`.....
<FromGitter> <cfsamson> Sorry, i didn't read the last message
<FromGitter> <mwean> ok, I tried making that struct field not a pointer
<FromGitter> <mwean> and now I get `StaticArray[0_u8, 0_u8......`
<FromGitter> <mwean> so I assume it's just not writing there?
<FromGitter> <cfsamson> hmmm, I would personally think that `buffer : Void*` should be `out ProcVnodepathinfo` but I might be mistaken
<FromGitter> <cfsamson> I mean in the LibProc declaration
<FromGitter> <Timbus> its a void pointer because the function can take and fill multiple struct shapes, it seems. but if you're only using it for this one thing, yeah declare it as a ProcVnodepathinfo*
<FromGitter> <mwean> getting closer...
<FromGitter> <mwean> looks like it's now filling in some values
<FromGitter> <Timbus> are pvi_cdir and rdir supposed to be pointers
<FromGitter> <cfsamson> I don't have the code here, but it seems like the C code takes a reference to a `struct proc_vnodepathinfo` and "fills" that with data, so you can access it through vpi.pvi_cdir.vip_path or vpi.pvi_cdir.value.vip_path in Crystal. So without declaring that it's a ProcVnodepathinfo its "filling" it you will have a hard time using the data it points to I think. You could maybe cast it as a ProcVnodepathinfo as
<FromGitter> ... well...
<FromGitter> <mwean> I'm getting `StaticArray[1_u8, 0_u8`
<FromGitter> <mwean> doing `map(&.chr)` is returning a lot of weird stuff
<FromGitter> <mwean> I'm now doing `fun proc_pidinfo(pid : LibC::Int, flavor : LibC::Int, arg : UInt64, buffer : ProcVnodepathinfo*, buffersize : LibC::Int) : LibC::Int` ⏎ and calling `LibProc.proc_pidinfo(20169, LibProc::PROC_PIDVNODEPATHINFO, 0, out vpi, sizeof(LibProc::ProcVnodepathinfo));`
<FromGitter> <Timbus> id need to look at the c header, but what you pasted before makes it look like it should be two structs, not two struct pointers
<FromGitter> <mwean> yeah, I changed to ⏎ ⏎ ``` struct ProcVnodepathinfo ⏎ pvi_cdir, pvi_rdir : VnodeInfoPath ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5b9edf57fcba1254fac6f79e]
<FromGitter> <Timbus> ah ok
<FromGitter> <mwean> it seems like it's misalligned because I'm getting `StaticArray['\u{88}', 'D', 'R', '\u{10}', '\u{1}', '\u{0}', '\u{0}', '\u{0}', 'G', '\u{0}', 'd', 'Ð', 'n', 'x', '\u{1a}', 'b'.....`
<FromGitter> <Timbus> probably just need to go over your definitions again, likely
<FromGitter> <Timbus> -that you set one to the wrong size/type
<FromGitter> <Timbus> you can always cheat, and make a padded out struct with fields you want to ignore. but that might just get you into more trouble at this point :P
<FromGitter> <mwean> is `vip_path : LibC::Char[MAXPATHLEN]` correct for `charvip_path[MAXPATHLEN]`?
<FromGitter> <Timbus> should be..
<FromGitter> <mwean> I wasn't sure about `uid_t, gid_t, off_t` so I used `UInt32`
<FromGitter> <mwean> ah!
<FromGitter> <mwean> success!!
<FromGitter> <Timbus> cool
<FromGitter> <cfsamson> GJ
<FromGitter> <mwean> I was missing `[2]` on a couple types
<FromGitter> <cfsamson> How did it solve the problem?
<FromGitter> <mwean> `vst_qspare : Int64[2]`
<FromGitter> <mwean> it looks like that just fixed the alignment
<FromGitter> <Timbus> you should point us at the header next time, otherwise we need to guess
<FromGitter> <cfsamson> Nice
<FromGitter> <mwean> so now the only weird thing is the value is doubled
<FromGitter> <mwean> separated by a ton of `'\u{0}'`
<FromGitter> <cfsamson> There is something with the mapping then, but atleast the problem is scoped down quite a bit
<FromGitter> <mwean> for ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b9ee3450cfe7f30f1a4787a]
<FromGitter> <mwean> oh well, close enough
<FromGitter> <mwean> thanks again for all your help!
<FromGitter> <cfsamson> :)
lacour has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
oprypin has quit [Ping timeout: 244 seconds]
BlaXpirit is now known as oprypin