ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.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
[gnubie] has joined #crystal-lang
[gnubie] has quit [Ping timeout: 240 seconds]
<FromGitter> <fridgerator> I'm trying to write a c binding to TA-Lib, and I'm not sure how to pass the last parameter `out` to this function : https://github.com/fridgerator/crystal_talib/blob/master/src/libta_lib.cr#L256
<FromGitter> <fridgerator> Here is an example of how its used in c / c++ :https://github.com/oransel/node-talib/blob/master/src/talib.cpp#L1039
<FromGitter> <fridgerator> I can just use an out paramter `out out_value`, but `out_value` is a `Float64` however it needs to be an `Array(Float64)`
<FromGitter> <asterite> it seems you need to pass a pointerof s buffer
<FromGitter> <fridgerator> @asterite bufer ?
DTZUZO has joined #crystal-lang
hypercore has quit [Ping timeout: 260 seconds]
chemist69 has quit [Ping timeout: 245 seconds]
chemist69 has joined #crystal-lang
ht_ has joined #crystal-lang
livcd has quit [Ping timeout: 245 seconds]
wmoxam has quit [Ping timeout: 245 seconds]
wmoxam has joined #crystal-lang
ht_ has quit [Remote host closed the connection]
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
go|dfish has joined #crystal-lang
tdc has quit [Ping timeout: 240 seconds]
alex`` has joined #crystal-lang
tdc has joined #crystal-lang
livcd has joined #crystal-lang
alex`` has quit [Ping timeout: 250 seconds]
alex`` has joined #crystal-lang
tdc has quit [Read error: Connection reset by peer]
tdc has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <asterite> I mean, in the c++ code there's `wo->outReal = new double*[func_info->nbOutput]`
<FromGitter> <asterite> so it seems outReal is an "array" of double
<FromGitter> <asterite> and then: `TA_SetOutputParamRealPtr(func_params, i, &wo->outReal[i][0])`
<FromGitter> <asterite> `&exp` is `pointerof(exp)` in Crystal
erdnaxeli has quit [Read error: Connection reset by peer]
ternarysolo has quit [Read error: Connection reset by peer]
beepdog has quit [Read error: Connection reset by peer]
olbat[m] has quit [Read error: Connection reset by peer]
<FromGitter> <asterite> but you need to do `pointerof` an offset inside that array. I don't know if Crystal can do that
<FromGitter> <asterite> actually `outReal` seems to be an array of arrays
<FromGitter> <asterite> so complex... I'm having trouble understanding that code so I'll have more trouble translating that code to Crystal, sorry
beepdog has joined #crystal-lang
<FromGitter> <fridgerator> I had trouble understanding it too. I have the TALib source, maybe I'll try and write my own wrapper function for it.
DTZUZO has quit [Ping timeout: 245 seconds]
<repo> hey o/
<repo> how do i get the exit status of a process i ran with Process.run {}
<repo> i get a nil assertion error if i try using $?.success? after the block
olbat[m] has joined #crystal-lang
erdnaxeli has joined #crystal-lang
ternarysolo has joined #crystal-lang
pf_ has joined #crystal-lang
pf_ has left #crystal-lang [#crystal-lang]
pf_ has joined #crystal-lang
baweaver has quit [Ping timeout: 245 seconds]
pf_ has quit [Quit: Leaving.]
<repo> hm never mind
<repo> another question: i have an abstract struct Item and several direct inheriting non-abstract structs. I try to read an array of the json-serialized structs like so: Array(Login | Card | Identity | SecureNote).from_json(io)
<repo> this gives me an error though, that i can't instanciate the abstract class Item
<repo> i wonder where it get's Item from
<repo> gets
<repo> yield T.new(pull: Error: instantiating 'AutoBW::Item.class#new(JSON::PullParser)'
pf_ has joined #crystal-lang
go|dfish has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> repo you would just do like `run = Process.run(...)`
<FromGitter> <Blacksmoke16> where run would be a https://crystal-lang.org/api/master/Process/Status.html
<FromGitter> <Blacksmoke16> got some example code?
DTZUZO has joined #crystal-lang
Human_G33k has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
<repo> nah it's fine. some weirdness about $? being unset outside of the method or something
<repo> got it to work
<FromGitter> <Blacksmoke16> πŸ‘ meant for the json thing you were doing
<repo> ah
<repo> got that to work as well
<FromGitter> <Blacksmoke16> :P nice
<repo> used a module instead of an abstract struct
HumanG33k has quit [Ping timeout: 265 seconds]
<repo> about sockets: is it possible to timeout on accept?
<repo> i want to exit my program if there hasn't been a request in over 15 minutes
<alex``> Hi
<repo> hi alex``
<alex``> How can I distribute a static version of a program?
<repo> what do you mean?
<alex``> Ideally build after each commit
<repo> oh
<repo> just set up a ci
<alex``> I want to avoid other to depend on Crystal
<repo> use alpine
<alex``> do you have a guide?
<alex``> where ci put the compiled binary?
<repo> no, sorry. but i have a project which does this i think
<repo> lemme check
<alex``> (is there a way from a script to determine which binary is needed?)
<FromGitter> <sam0x17> anyone know the magical alpine package name for this one? having the hardest time finding it: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d94a90347de0a719d4cbad4]
<repo> what do you mean by that?
<alex``> whether he is on Mac/Linux/Windows and architecture
<alex``> ideally posix commands
<alex``> I’m writing an installer using curl
<alex``> + sh
<alex``> I want to pick the right binary the user needs
<repo> check out the .gitlab-ci.yml and Dockerfile
<alex``> how have you defined the $CI_REGISTRY_IMAGE variables, etc.?
<alex``> s/how/where/
<repo> they're defined by gitlab ci
<repo> everything that starts with CI_
<repo> alex``: you can run uname and see if it returns "Darwin" for checking if you're on mac
<repo> no idea how to detect windows
<repo> also no idea how you can build for windows
<repo> static linking won't work on mac though
<FromGitter> <Blacksmoke16> crystal doesnt support windows
<repo> as far as i know
<FromGitter> <Blacksmoke16> yet
<alex``> repo: ADD <a> <b>, <a> is a file of the system, and <b> a file to copy in the Docker?
<repo> correct
<alex``> what does it do after compiling the Dockerfile?
<alex``> the generated files are in the Docker, how you made them available?
<alex``> oh oki
<alex``> nice
<repo> do it a step at a time. first try to statically link your binary and go from there
<alex``> 'fogtrack' is in GIT_ROOT_DIR/fogtrack after that command?
<repo> correct
<alex``> and what happens after
<alex``> of this file
<repo> might be that you'll need to set the -Dmusl in the shards build command in the docker file. there was some trouble detecting musl libc in the past
<repo> alex``: see artifacts
<repo> i define the file as an artifact so gitlab will upload it to artifacts
<repo> basically you could do whatever you want with it. upload it to a webserver or what not. your choice
<alex``> I don't understand what artifacts does
<FromGitter> <Blacksmoke16> `shards build --release --production` is redundant, production flag does both
<FromGitter> <Blacksmoke16> if its prob binaries you could also do `--no-debug` to make it a bit smaller
<FromGitter> <Blacksmoke16> prod*
<repo> good point
<repo> alex``: did you read the gitlab docs link i sent?
<alex``> repo: what will be the final archive?
<alex``> yes
<alex``> macos and linux have the same 'fogtrack'
<alex``> I understand all files will be zip in an archive
<alex``> but macos and linux have the same artifact path
<FromGitter> <Blacksmoke16> https://linux.die.net/man/1/strip makes it a bit smaller as well
<repo> alex``: that doesn't matter. each job has its own artifacts
<repo> see how you have to define the job name?
<repo> you could also use gitlab pages for a more permanent storage of the binaries. It wouldn't be versioned though
<FromGitter> <sam0x17> anyone on the libcrt0.o issue? I'm building duktape.cr on alpine
go|dfish has joined #crystal-lang
ht_ has joined #crystal-lang
<FromGitter> <j8r> @naqvis I'm trying to use crystar on Crystal 0.31.0, but it does not compile
<FromGitter> <j8r> there is `/` to `//` to change in `SparseArray#max_entries` to compile, but then running specs returns an overflow in the reader specs
<FromGitter> <j8r> I open an issue
alex`` has quit [Ping timeout: 265 seconds]
alex`` has joined #crystal-lang
repo is now known as jokke
jokke is now known as repo
alex`` has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
<FromGitter> <fridgerator> @asterite I got it to work!
pf_ has quit [Quit: Leaving.]
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <fridgerator> I created an array filled with 0.0, then passed it like `out_real[i].to_unsafe` : https://github.com/fridgerator/crystal_talib/blob/master/src/crystal_talib.cr#L201
pf_ has joined #crystal-lang
pf_ has quit [Ping timeout: 240 seconds]
alex`` has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
alex`` has quit [Client Quit]
alex`` has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> @kinxer I got your ping from that April post, sadly, I scrolled back down on accident. Was there a user wondering about Crystal w/ Godot? That's pretty cool, I hope more people are seeing the potential. They intertwine very easily and it's a powerful stack! Something great can definitely be created with it
pf_ has joined #crystal-lang
<FromGitter> <kinxer> @ImAHopelessDev_gitlab I hope to have the free time and motivation soon to try out Godot; it seems like a really cool game development suite. With multithreading currently being integrated into Crystal, it might even be feasible (if perhaps time-consuming) to make GDScript/Godot (not sure which one is accurate) bindings for Crystal.
<FromGitter> <ImAHopelessDev_gitlab> @kinxer πŸ‘
f1refly has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.6]
pf_ has quit [Ping timeout: 245 seconds]
pf_ has joined #crystal-lang
<FromGitter> <sam0x17> any way to make `shards build` output to a particular binary name/path?
<FromGitter> <sam0x17> in an awkward build script for something and I cant `&& mv bin/my-app ./server` after the build command because that would be executed outside of docker
<FromGitter> <sam0x17> tool I'm using expects binary at `./server`
<FromGitter> <sam0x17> was originally using `crystal build` to do this manually, however I now have a dependency that has a postinstall step, which `crystal build` ignores
<FromGitter> <sam0x17> about to pull out my bag of symbolic link tricks but was hoping I wouldn't have to ;)
<FromGitter> <nsuchy> Looks like my code broke due to some changes in Crystal and I'm a bit stuck. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Relies internally on: https://github.com/ulayer/crystalproxmox [https://gitter.im/crystal-lang/crystal?at=5d950dfc6d4b2512c1565db1]
<FromGitter> <nsuchy> if I just pass it the host name I get an error about missing the scheme
ht_ has quit [Quit: ht_]
<FromGitter> <nsuchy> Based on the error `Socket::Addrinfo::Error getaddrinfo: Temporary failure in name resolution` and it showing a different area with just the host name it looks like it's trying to resolve the entire URL as a domain name.
<FromGitter> <nsuchy> In the initializer, `@site = HTTP::Client.new(URI.parse(@pve_cluster))` where `@pve_cluster = url`
<FromGitter> <nsuchy> URI.parse should take the URL we give it and create the client, right?
<FromGitter> <nsuchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d951144deb6da63d7eb6202]
<FromGitter> <nsuchy> Create ticket works like
<FromGitter> <nsuchy> It only seems to have the issue when using as a shard
<FromGitter> <nsuchy> If I add the code to the bottom of CrystalProxmox.cr, it works fine
<FromGitter> <nsuchy> If I print the value of URL from logs: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d95171c6d4b2512c156a4e5]
<FromGitter> <sam0x17> new problem: has anyone ever had `shards build` seemingly take forever (longest I have run the build is 15 minutes) and `GC Warning: Repeated allocation of very large block (appr. size 805310464): ⏎ ⏎ ``` May lead to memory leak and poor performance`?``` [https://gitter.im/crystal-lang/crystal?at=5d951941d97d8e3549f260b0]
<FromGitter> <Blacksmoke16> @nsuchy im pretty sure you can just pass the url to the client
<FromGitter> <Blacksmoke16> er nvm, if it has protocol and stuff on it prob better to use URI
<FromGitter> <nsuchy> @Blacksmoke16 what do you mean?
<FromGitter> <nsuchy> are you talking about my init function?
<FromGitter> <nsuchy> it fails without the URL.parse
<FromGitter> <nsuchy> one thing i've noticed is that it works fine on Mac with the shard but not with the app inside Docker
<FromGitter> <nsuchy> Does Crystal require any special libraries for DNS
<FromGitter> <Blacksmoke16> might be missing some dep in your container
<FromGitter> <nsuchy> I found ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9519c6eb1eff63d666913d]
<FromGitter> <nsuchy> Which looks like it asks LibC to resolve
<FromGitter> <nsuchy> But build-essential is installed
<FromGitter> <Blacksmoke16> could try that
<FromGitter> <nsuchy> I can open bash in the container and use curl fine
<FromGitter> <nsuchy> I rebuilt the image with GCC and LibC directly from apt
<FromGitter> <nsuchy> checking now what happens
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <nsuchy> if anyone else has ideas
<FromGitter> <nsuchy> Elixir Team says if the error message isn't easily readable it's a bug. What does Crystal Team say?
<FromGitter> <nsuchy> Maybe the DNS error should check if LibC is installed and complain
<FromGitter> <nsuchy> still fails
<FromGitter> <nsuchy> that wasn't the issue
<FromGitter> <nsuchy> any other ideas
<FromGitter> <nsuchy> This is even stranger
<FromGitter> <nsuchy> In the same docker container running the app
<FromGitter> <nsuchy> a test program makes a DNS request fine
<sorcus> Hi, little question. How to store 4GB (~140 millions) of strings in memory with fast searching? Radix eats much memory... Custom tree faster, but used ~20GB of memory...
<sorcus> *Radix very slow when build tree.
<FromGitter> <nsuchy> You might just need a lot of memory?
<FromGitter> <fridgerator> Redis?
<sorcus> I have only ~30GB of memory... :-(
<sorcus> @fridgerator, hmmm...
<FromGitter> <nsuchy> any ideas on my dns issue?
<FromGitter> <nsuchy> I've confirmed that with direct scripts requesting the URL Crystal DNS works with http/client
<FromGitter> <fridgerator> @nsuchy have you searched the "Temporary failure in name resolution" error?
<FromGitter> <nsuchy> yes
<FromGitter> <nsuchy> im at a loss to what's causing it
<FromGitter> <nsuchy> I'm able to continiously run a test.cr file
<FromGitter> <nsuchy> to request our proxmox host fine
<FromGitter> <nsuchy> it's only when using the shard I have the issue
<FromGitter> <fridgerator> I see a lot of posts about `/etc/resolv.conf` being the culprit
<FromGitter> <nsuchy> curl works fine
<FromGitter> <nsuchy> inside the container
<FromGitter> <nsuchy> it's not a resolver issue
<sorcus> @nsuchy, maybe clear cache? ~/.cache/crystal and/or reinstall deps?
<FromGitter> <nsuchy> Screen Shot 2019-10-02 at 6.08.24 PM
<FromGitter> <nsuchy> It fails when I directly declare the URL too
<FromGitter> <nsuchy> So it's not caused by passing an incorrect URL
<FromGitter> <nsuchy> I've rebuild the docker container several times
<FromGitter> <nsuchy> which by extension clears cache and installs deps
<FromGitter> <fridgerator> @nsuchy are you running this on aws?
<FromGitter> <fridgerator> It just occurred to me, scrolling back through my comments, that I had this same error message last week.
<FromGitter> <fridgerator> And I know this sounds crazy, and doesn't make any sense, but I went to to work the next day and it was working just fine without me making any changes.
<FromGitter> <fridgerator> I blamed my aws instance and moved on
<FromGitter> <fridgerator> ec2*
<sorcus> Maybe it issue with systemd-resolved if used?
<sorcus> @nsuchy as a temporary solution you can use direct IP in your URL with Host header.
myfreeweb has joined #crystal-lang
baweaver has joined #crystal-lang
<FromGitter> <alexherbo2> Hi
<FromGitter> <Blacksmoke16> Hi
<FromGitter> <alexherbo2> @Blacksmoke16 You’re always around xD
<FromGitter> <Blacksmoke16> I try :p
<FromGitter> <alexherbo2> Do you have an example of web socket server / client ?
<FromGitter> <Blacksmoke16> Uhh I do not
<FromGitter> <plambert> Is anyone aware of a way to call alarm() on Linux/Darwin systems? Or, another way to trigger a timer within a tight loop without the overhead of checking the clock?
<FromGitter> <alexherbo2> I want to execute commands from JavaScript (client) on my machine through web socket messaging
<FromGitter> <alexherbo2> @Blacksmoke16 :(
<FromGitter> <Blacksmoke16> Might be an example in the API docs?
<FromGitter> <alexherbo2> Under which namespace exactly?
<FromGitter> <alexherbo2> Thanks
<myfreeweb> @plambert pthread timers maybe
<FromGitter> <alexherbo2> I don’t see an event when ready
<FromGitter> <alexherbo2> On the client side if I want to do in Crystal
<FromGitter> <alexherbo2> To establish the connection with the ws
<FromGitter> <alexherbo2> And run the server
<FromGitter> <fridgerator> @alexherbo2 What are you using as a web server?