<FromGitter>
<Blacksmoke16> anyone know if its possible to add custom decoders to the mysql/sqlite db adapter shards? Similar to how you can do for the pg shard?
<FromGitter>
<markrjr> Probably a stupid question, but how exactly do I test/run this?
<FromGitter>
<markrjr> Do I compile a version of the compiler for windows and then write a small program that calls that function from the standard library?
<FromGitter>
<markrjr> Is there a quicker way?
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter>
<aboeglin> jokke ? You use ssl as well ?
DTZUZO_ has quit [Ping timeout: 250 seconds]
<FromGitter>
<aboeglin> the proposed solution didn't seem to work for me ..
<jokke>
aboeglin: yeah... For me neither :(
return0e has joined #crystal-lang
<jokke>
I use ssl but it's terminated by the reverse proxy
<FromGitter>
<dejonjulius_gitlab> hello world
<FromGitter>
<proyb6> @bew Iβm curious how does stringview look like?
<jokke>
aboeglin: i'm now trying to access the db via `tasks.db` instead of `db` which apparently uses DNSRR instead of VIP and for some people fixes the problem...
<jokke>
let's see in about an hour
<jokke>
super annoying to debug
<FromGitter>
<proyb6> @bew Cool idea, itβs something very useful
<jokke>
aboeglin: so far it's working
<jokke>
time will tell
ashirase has quit [Ping timeout: 245 seconds]
ashirase has joined #crystal-lang
helaan has joined #crystal-lang
<helaan>
Update on my issue from a few days ago: I got a crosscompiler working, didn't manage to crosscompile the compiler, tried my small Kemal app first.
<helaan>
App works fine, until it needs to send a POST requests, then it crashes with "Invalid memory access (signal 7) at address 0x74a220dc". Stacktrace is not very informative, which flags can I use to get more info?
<helaan>
Currently I have two test programs: One that just calls HTTP::Client.post which works on arm and ad644, the second one wraps it in a Kemal route which works on amd64 but crashes on arm.
<FromGitter>
<aboeglin> @jokke Do you have a link to a document speaking about that ?
<FromGitter>
<aboeglin> And could you tell me what you changed exactly ?
<FromGitter>
<aboeglin> i couldn't find any info about `tasks.db`
<FromGitter>
<j8r> Does incremental compilation requires a Nim/Python approach: files == modules? If yes, this might be done for specs - most people already do `moduletotest_spec.cr`
<FromGitter>
<j8r> I was thinking about this when I saw the results in the CircleCI console for Crystal
<FromGitter>
<straight-shoota> @j8r This approach doesn't work when you can reopen types
<FromGitter>
<straight-shoota> @markrjr You can cross compile for windows from any supported compiler platform. The compiler will build all the object files and spit out a linker command that you need to run on windows directly. But you don't need to run the compiler itself on windows (currently it doesn't even compile anyway).
<FromGitter>
<fusillicode_twitter> guys I have a strange problem
<FromGitter>
<fusillicode_twitter> the problem is that I get the `can't cast Hash(Symbol, NoReturn) to Hash(Symbol, Hash(Symbol, String))` on this line ` rest_results.map { |rest_result| rest_result_to_h(rest_result).as(Hash(Symbol, Hash(Symbol, String))) }`
<FromGitter>
<straight-shoota> You shouldn't use symbol hashes. In Ruby, they're used pretty extensively, but they're no good in Crystal. With dynamic data, you should use string keys instead.
<FromGitter>
<fusillicode_twitter> ok no problem I can switch :)
<FromGitter>
<straight-shoota> Your example looks very much like static data structures. Then you should really use `struct` instead of hashes.
<FromGitter>
<fusillicode_twitter> mmm
<FromGitter>
<straight-shoota> It's much simpler, easier to understand the purpose and way more efficient.
<FromGitter>
<fusillicode_twitter> well the problem is that I need to `.to_json`
<FromGitter>
<straight-shoota> And?
<FromGitter>
<fusillicode_twitter> and `struct` doesn't have it
<FromGitter>
<straight-shoota> it's as simple as `include JSON::Serializable`
<FromGitter>
<fusillicode_twitter> mmm
<FromGitter>
<fusillicode_twitter> sincerely I would like to keep the concern about the serialization separate π€
<FromGitter>
<straight-shoota> It's nothing more separate with your current approach.
<FromGitter>
<fusillicode_twitter> well in my approach I build a representation that should be serializable by default
<FromGitter>
<fusillicode_twitter> an Hash :)
<FromGitter>
<straight-shoota> But that's really not how it's supposed to be used π
<FromGitter>
<fusillicode_twitter> :(
<FromGitter>
<straight-shoota> If you only need these data structures to serialize to JSON, you should even consider to implement the serialization directly on `Rest::Result` etc.
<FromGitter>
<straight-shoota> You can have full control over what gets serialized through implementing `#to_json(builder : JSON::Builder)` manually.
<FromGitter>
<fusillicode_twitter> right now I can't really switch back
<FromGitter>
<fusillicode_twitter> it would be awesome if I could get a clue about the reason behind the compiler error XD
<FromGitter>
<straight-shoota> I'm not sure how the `NoReturn` happens to appear
<FromGitter>
<fusillicode_twitter> π
<FromGitter>
<straight-shoota> But looking at the code there are a few `.to_h` values when the return type should be `Hash(Symbol, String)`. You can't put that in there.
<FromGitter>
<straight-shoota> You shouldn't need these `.as(Hash(Symbol, String))` anyway. They don't do anything.
<FromGitter>
<straight-shoota> Try to remove them, maybe that influences the error.
<FromGitter>
<fusillicode_twitter> I actually added `.as(Hash(Symbol, String))` trying to help the compiler
<FromGitter>
<fusillicode_twitter> let me leave them and go back to my initial error XD
<FromGitter>
<j8r> @straight-shoota the only way will be to have a mode to forbid class reopening of `MyClass` in specs outside the `myclass_spec.cr`, to do incremental compilation :/
<FromGitter>
<straight-shoota> Nah, that's not the only issue
<FromGitter>
<straight-shoota> Method argument and return types also depend on the types available in the entire program, which can obviously change between compilations.
<FromGitter>
<j8r> the main blocking points are type inference and class reopening?
rohitpaulk has joined #crystal-lang
<FromGitter>
<fusillicode_twitter> well I think that I'm totally stuck...
<FromGitter>
<straight-shoota> @j8r Class reopening probably isn't much of a problem for incremental compilation because it doesn't change frequently and is easy to detect. I just mentioned it in response to your file == module statement.
<FromGitter>
<fusillicode_twitter> but it seems that it is not possible to have it outside the class that I want to serialize, or at least it seems to me from your last suggestion :(
marmotini_ has joined #crystal-lang
marmotini has joined #crystal-lang
<FromGitter>
<fusillicode_twitter> I think that the only option that remains is to use `JSON.build`
<helaan>
Anyone who has tips on crosscompiling the Crystal compiler?
<helaan>
When I try running it, it throws "Error parsing inline asm"
<FromGitter>
<straight-shoota> @fusillicode_twitter No, you should really be able to define that function anywhere. As long as it can access the properties of the type it needs to serialize.
<FromGitter>
<fusillicode_twitter> ok but I still need to pass a JSON::Buidlder instance and sincerely I don't know how to instantiate it
<FromGitter>
<fusillicode_twitter> in particular I don't know what `IO` to pass it :(
<FromGitter>
<straight-shoota> helaan what target are you trying to cross compile to?
<FromGitter>
<straight-shoota> @fusillicode_twitter It takes any IO. Depends on what you want to do. Do you want to write to a file? A socket? Just pass it in. β If you need the JSON as String, use a String::Builder.
<FromGitter>
<fusillicode_twitter> exactly this String::Builder!!!
<FromGitter>
<fusillicode_twitter> let me try :D
<helaan>
straight-shoota: either armv7a or aarch64, either would make me happy
rohitpaulk has quit [Ping timeout: 250 seconds]
<FromGitter>
<fusillicode_twitter> @straight-shoota mmm...ok now...a String::Builder is instantiated with?
<helaan>
Currently mostly trying to compile for the armv7a-unknown-linux-gnueabihf triple though
<FromGitter>
<fusillicode_twitter> btw I have the doc at eye
<FromGitter>
<straight-shoota> helaan, hm the docs list only `armv7-linux-gnueabihf`... Is there a compatibilty difference between armv7 and armv7a?
<FromGitter>
<straight-shoota> I'm not very familiar with this subject...
<helaan>
straight-shoota: Not as far as I'm aware, it is just that this is the normal gcc triple for the target system
<FromGitter>
<straight-shoota> @fusillicode_twitter `string = String.build do |io| do_somthing_with(io) end`
<helaan>
Running it with armv7-linux-gnueabihf also crashes, same message
<FromGitter>
<straight-shoota> okay
<helaan>
I checked out the crystal repo and ran `make FLAGS="--cross-compile --target armv7-linux-gnueabihf" progress=1`
<FromGitter>
<fusillicode_twitter> ok then I think that even that will not work
<FromGitter>
<straight-shoota> yeah that should work... you might try something smaller than the compiler
<FromGitter>
<straight-shoota> like cross compile a hello world
<FromGitter>
<straight-shoota> So "Error parsing inline asm" is an LLVM error, so either the compiler is passing it the wrong target ASM or the ASM is buggy.
<helaan>
Ok, will do. With respect to my post issue, it crashes only if it is contained in a Kemal block, should that make it a Kemal issue or a compiler issue?
<helaan>
Invalid memory access (signal 7) at address 0x749a23e4
<helaan>
[0x12d124] ???
<helaan>
[0x6b0e4] __crystal_sigfault_handler +72
<FromGitter>
<straight-shoota> okay, that should be a crystal issue
<FromGitter>
<straight-shoota> kemal shouldn't care about which arch it's compiled to
<helaan>
I thought it was something to do with threads/fibers, but it is 100% reproducible
<FromGitter>
<straight-shoota> unfortunately we have no CI infrastructure for arm so it's easy that there might be some undiscovered issues
<helaan>
Yeah, arm hardware just isn't as popular as x86 and the embedded crystal isn't a thing either
<jokke>
hey there fellow webdevs o/ Check out https://github.com/jreinert/guardian It can monitor your files, build your target when they change, and restart the running target. It also starts a webserver at a user definable port (using the `-w` cli flag) which allows connecting via websocket and sends a message to the websocket when the target has restarted. You can also configure a string to watch for from
<jokke>
the program stdout to know when it's up and running.
<jokke>
in a nutshell: shotgun for crystal with live reload support
<helaan>
Also, I noticed that if you rebuild LLVM with extra targets support, you need to rebuild crystal afterwards to make Crystal pick up these targets
<helaan>
But I think that is a Gentoo bug
<FromGitter>
<jgaskins> hey everyone, I'm having some trouble with `reuse_port` on `HTTP::Server`. I've got `reuse_port` enabled on my `HTTP::Server` instances so I could split the workload across multiple processes (as discussed here (https://github.com/spider-gazelle/action-controller/blob/master/clustering.md)), but every request is being handled by the first process to bind to the port.
<FromGitter>
<jgaskins> I'm on macOS Mojave if that helps. Latest Crystal version.
<FromGitter>
<proyb6> @jgaskins what is the error you were facing?
<FromGitter>
<jgaskins> There's no error, the other processes just aren't getting the request.
<FromGitter>
<proyb6> How about let us seeing your code?
<FromGitter>
<straight-shoota> have you tried reuse_port with any other software on your system?
<FromGitter>
<jgaskins> The `PrintPid` handler was just to see if the app was distributing the requests *at all*, because only one process was getting lit up when I ran `wrk` against it.
<FromGitter>
<straight-shoota> could you run this without fork? Just execute the same binary multiple times?
<FromGitter>
<jgaskins> @straight-shoota No, I haven't used `reuse_port` before. Last time I built anything that worked this closely with sockets, `SO_REUSEPORT` didn't exist yet. :-)
<FromGitter>
<jgaskins> @straight-shoota I did try removing forking and just run it in multiple terminal windows. Same exact thing happened.
<FromGitter>
<aboeglin> @jokke is it still running ?
<FromGitter>
<j8r> @bew thanks, indeed very interesting!
marmotini_ has joined #crystal-lang
baweaver has quit [*.net *.split]
bmcginty has quit [*.net *.split]
<helaan>
I managed to get a crosscompiler built for arm, turned out the tuple was arm-unknown-linux-gnueabihf, but am unable to link it, as it can't find AArch64 and X86 support in the LLVM compiler on the target (which is correct)
marmotini_ has quit [Ping timeout: 252 seconds]
marmotini_ has joined #crystal-lang
sagax has quit [Quit: Konversation terminated!]
<helaan>
Would it be useful to specify the targets Crystal will build itself for? Currently it looks at llvm-config to see what LLVM has been built with and enables everything it can. This causes issues when crosscompiling because the target may have LLVM built with a subset of targets
<jokke>
aboeglin
<jokke>
no
<jokke>
i didn't change anything about the structure of the docker-compose.yml
<f1refly>
I don't think anybody was bothered by this in the first place tbh :)
<jokke>
but it's confusing
<jokke>
f1refly: what do you use guardian for?
<f1refly>
Pretty much everything that needs build on changes
<jokke>
mhm
<f1refly>
Currently im trying to transpose "still alive" by lisa miskovsky with abc notation and use guardian to auto-compile it to pdf
<jokke>
hah cool
<f1refly>
One of the reasons i submitted my makefile patch to it today
<jokke>
yeah guardian is more universal. paladin is exclusively for crystal projects.
<f1refly>
yeah
<f1refly>
the crystal project integration of guardian works pretty good tho
<jokke>
does it kill running processes?
<f1refly>
So
<f1refly>
No
<jokke>
yeah. that's a must for webdevelopment imho
<f1refly>
Theres an issue for that, but nobody bothered
<jokke>
which is why i wrote my shard
<jokke>
it even has autoreload
<f1refly>
I get that, but it's hard to tell what to kill when all you have is a target and a line to execute
<f1refly>
That's pretty cool
<jokke>
exactly
<jokke>
well
<jokke>
you can just kill whatever you started
<f1refly>
The guardian.yml would need to have an extra option to tell it what to kill i reckon
<jokke>
probably
<f1refly>
But i'm not into webdevelopment so i don't really care ;)
<jokke>
you would have to watch the binary or something
<f1refly>
Yeah
<jokke>
i noticed a funny coincidence: everyone who's on arch-linux is connected via irc ;)
<jokke>
maybe it's not coincidence but preference
<f1refly>
I guess so, yeah
<jokke>
i hate that there's no tab completion for gitter users tho
<f1refly>
I see arch linux more as a hobby that i got so proficient with that it's fine for daily use
<f1refly>
I don't really mind
<jokke>
:)
<f1refly>
What do you think, should i submit the package despite the warning?
<jokke>
asterite: so is there any way to suppress adding the source file name to the compiled binary?
<jokke>
f1refly: yeah
helaan has quit [Ping timeout: 272 seconds]
<f1refly>
Are aur and archlinux bbs accounts seperate?
<FromGitter>
<aboeglin> @jokke oh, so it's actually for the host you connect to
<f1refly>
It's on the aur :D
<FromGitter>
<aboeglin> @jokke I just tried it, it's live right now, we'll see !
Jenz has joined #crystal-lang
<jokke>
aboeglin: π
<jokke>
f1refly: π
<jokke>
aboeglin: mine still works
<jokke>
i really hope this was it
bmcginty has joined #crystal-lang
Jenz has quit [Ping timeout: 252 seconds]
robacarp has joined #crystal-lang
wontruefree has joined #crystal-lang
Jenz has joined #crystal-lang
<FromGitter>
<aboeglin> Still up :o
<FromGitter>
<j8r> I'm on Lubuntu, Manjaro and has been on Debian and openSUSE - everything that has LXQt :) At the end, there isn't much differences. I would like to go to Alpine but for now packages are missing
rohitpaulk has joined #crystal-lang
non-aristotelian has joined #crystal-lang
<Jenz>
Why alpine at all?
Jenz has quit [Ping timeout: 252 seconds]
baweaver has joined #crystal-lang
Jenz has joined #crystal-lang
wontruef_ has joined #crystal-lang
wontruefree has quit [Ping timeout: 245 seconds]
helaan has joined #crystal-lang
<helaan>
Hmm, not sure exactly what the crash it, but my crosscompiler exhibits it as well
return0xe has joined #crystal-lang
return0e has quit [Ping timeout: 245 seconds]
<FromGitter>
<j8r> Alpine because light β busybox, openrc, simple packaging
<Jenz>
Huh, ok sounds like it's worth looking into, thanks @j8r!
<helaan>
Ooh, I got the amd64 version of the compiler to crash, segfault
<Jenz>
I've done that a couple of times of x86_64 as well :D
<Jenz>
Why am I so happy about that
<helaan>
Let it crash, let it burn, can't hold it back anymore
<helaan>
Probably not that bad of a crash, compiled crystal with both --release and --debug for arm
Heaven31415 has joined #crystal-lang
<Heaven31415>
Hi
rohitpaulk has quit [Ping timeout: 252 seconds]
<Jenz>
Hello Heaven31415
marmotini_ has quit [Ping timeout: 245 seconds]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Ping timeout: 252 seconds]
<FromGitter>
<valamorgon> how can I pop last char from IO
<FromGitter>
<valamorgon> I need the last char to be removed from my IO
<FromGitter>
<valamorgon> but not after to_s
marmotini_ has joined #crystal-lang
<jhass>
do you know how much data comes before/the total length?
<FromGitter>
<valamorgon> unfortunately no
<FromGitter>
<valamorgon> maybe my logic is wrong I am using something like this
<FromGitter>
<valamorgon> to put comma between each value
<jhass>
oh you mean when writing
<jhass>
google "post fence problem"
marmotini_ has quit [Ping timeout: 246 seconds]
<jhass>
you either have to do the first or the last item outside the loop and start the loop with either the second item or stop it before the last
<FromGitter>
<valamorgon> thanks man, I simply checked if first or not now, but I normally remove last char after loop in other languages, don't know if it is considered bad habit though
<jhass>
well why do work and then undo it if you can just not do it ;)
<FromGitter>
<valamorgon> well it doesnt force me to use extra if statement but messy anyway :)
<FromGitter>
<straight-shoota> If it wasn't for the condition in the loop, you could just use `#join`
return0xe has quit [Quit: Leaving]
<FromGitter>
<valamorgon> if it was javascript I would .filter().join() because hail satan
Jenz has quit [Quit: leaving]
<jhass>
well, actually what's children? maybe you can just get an iterator from it and do exactly that
<FromGitter>
<valamorgon> it is xml nodeset
return0xe has joined #crystal-lang
<jhass>
yeah nvm, join doesn't give access to the io anyway
<helaan>
Not that much of a Crystal expert, didn't test it, but maybe something like this: `children.select{ |child| child.name == "value" }.join(",", io)` ?
<jhass>
misses the parse(...) call
<helaan>
You could throw a map in the middle of it, but then you need to alloc nodes
<jhass>
the select most likely already allocs another array
<helaan>
My suggestion then would to use the original code and output a comma before outputting every item after the first
<jhass>
but yeah the map would add another one + child results
wontruef_ has quit [Quit: bye]
<FromGitter>
<fridgerator> Does crystal have issues resolving an address through a docker container link?
<jokke>
aboeglin: good to hear. Hope it's fixed for you too :)
<FromGitter>
<jwoertink> Anyone else run in to closed stream errors using postgres?
<FromGitter>
<michelson> Hi!!
<FromGitter>
<michelson> i'm receiving an object with this type: `(Hash(String, String) | Int32)`
<FromGitter>
<michelson> what that means ?
<FromGitter>
<michelson> I'm trying to parse the hash, but it throw errors telling that [] is undefined method for Int32
<FromGitter>
<michelson> surprise! :(
<helaan>
@michelson: You have an union type: either it is a hash with Strings as keys and values OR it is an integer.
<helaan>
If you want to do something, you need to have an operation that is valid on both types or make sure that your object is either an integer or an hash