dingenskirchen has quit [Ping timeout: 272 seconds]
<FromGitter>
<watzon> Anyone have a good idea for how to go about connecting to a IPC socket like https://mpv.io/manual/stable/#json-ipc and pass messages back and forth?
<FromGitter>
<watzon> I know @Papierkorb has a json-rpc library, but it doesn't say how to connect to a socket specifically and it hasn't been updated for a while so I'm not sure if it will work anyway.
<FromGitter>
<watzon> Just got Tidal and I want a working terminal client for it, so...
<FromGitter>
<galvertez> i have a question about array behavior - i was surprised to learn that i can include `module M` in `class C` and then add an instance of `C` to a `[] of M` with no problem. that is, the memory footprint of `class C` could be different from `class G` even if they both include `M`
<FromGitter>
<galvertez> and i thought the reason for the type restriction for generic arrays was mainly about predictable memory formats since array uses pointers
<FromGitter>
<galvertez> but given that i was able to do it, it kind of seems like it is more about predictable behavior of the array's entries (i.e. we know that all members will respond to the methods defined in `M`)
<FromGitter>
<galvertez> i guess this is more a question about pointers in crystal rather than arrays :)
<FromGitter>
<galvertez> oh @watzon actually i've been working on a json rpc lib as well... it's not quite working yet but should be soon - i am specifically designing it to be transport agnostic so you that anyone can use whatever socket they like
<FromGitter>
<galvertez> idk if that would help but it might mean less hacking around somebody else's library
<FromGitter>
<galvertez> i've been distracted writing up a shard that implements a layer 6 (maybe layer 7... OSI gets kinda murky above layer 4) protocol for this https://raft.github.io/ because i wanted to learn more about `IO`
<FromGitter>
<galvertez> but if it would be helpful for you to have a working jsonrpc lib i could change gears and get back to that
<FromGitter>
<watzon> Turns out I don't really need jsonrpc, just normal text based rpc
ht_ has joined #crystal-lang
go|dfish has quit [Ping timeout: 248 seconds]
ht_ has quit [Quit: ht_]
<FromGitter>
<kingsleyh> @galvertez I wonder if Raft might be incorporated into my Blockchain platform - https://SushiChain.io
<FromGitter>
<watzon> That would be pretty cool
moei has joined #crystal-lang
<FromGitter>
<rishavs> Wonder what the community thinks about Artichoke. https://github.com/artichoke/artichoke β Its essentially a Ruby compiler written in Rust.
<FromGitter>
<watzon> I just saw that earlier actually
<FromGitter>
<watzon> Looks pretty cool
<FromGitter>
<bew> @watzon tidal looks good! Fwiw I'm fond of mpv, did some ipc with it in shell (note: writing json in shell is ugly), I'd love to see what you come up with using crystal ;)
<FromGitter>
<watzon> So far writing a wrapper for mpv is proving to be a pain in the ass, but I'm still working at it lol
<FromGitter>
<watzon> Anything event based in Crystal kinda sucks
<FromGitter>
<bew> Is it? Do you want a full wrapper and make your own player on top? Or just feed it a url and let it do its thing? (using mpv's cli interface)
<FromGitter>
<watzon> I'm trying to wrap a portion of it. I eventually want to have a curses front end, so I need the ability to play/pause/stop, change tracks, keep track of the play position, etc.
<FromGitter>
<watzon> Right now I'm doing this inside of the tidal.cr project, but I think I'll put it in its own shard and just attempt a full wrapper.
laaron has joined #crystal-lang
<FromGitter>
<watzon> The problem is just listening for events. It's so easy in node because of EventEmitter.
<FromGitter>
<bew> True, but EventEmitter is pretty simple to recreate iirc
<FromGitter>
<bew> Good luck with the wrapper, please tell me what you have a poc of it if you want another pair of eyes on it ;)
<FromGitter>
<absolutejam_gitlab> `created_at: { type: Time, converter: Time::Format }`
<FromGitter>
<absolutejam_gitlab> In my `JSON.mapping`
<FromGitter>
<absolutejam_gitlab> Should that work?
<FromGitter>
<watzon> @bew the hard part about EventEmitter is allowing any type to be emitted. I've contributed a lot to @hugoabonizio's EventEmitter library, but it's still hard to get to the same level that Node is π€·πΌββοΈ
<FromGitter>
<watzon> @absolutejam_gitlab Time::Format isn't a converter so no
<FromGitter>
<watzon> You either would have to use one of the built in Time converters or roll your own
<FromGitter>
<absolutejam_gitlab> Defines `to_json` and `from_json` - Isn't that enough?
<FromGitter>
<absolutejam_gitlab> It's an example too
<FromGitter>
<absolutejam_gitlab> > converter: specify an alternate type for parsing and generation. The converter must define from_json(JSON::PullParser) and to_json(value, JSON::Builder) as class methods. Examples of converters are Time::Format and Time::EpochConverter for Time.
<FromGitter>
<watzon> I mean you can try it, but I don't think it will work
<chachasmooth>
I get the following new error since i upgraded kemal from 0.25.2 to 0.26.0: Error in ...: instantiating 'Kemal::ParamParser#url()' id = env.params.url["id"]
<chachasmooth>
how to fix that?
<FromGitter>
<watzon> @chachasmooth I'd try the Kemal gitter channel
<FromGitter>
<tenebrousedge> @naqvis I don't know what else you would expect `split` to do; JS and Ruby work the same way
<FromGitter>
<absolutejam_gitlab> Yeah, that's right
<FromGitter>
<absolutejam_gitlab> It does exactly what it says on the string
<FromGitter>
<absolutejam_gitlab> The ARGV one threw me off because that should be a shell feature
<FromGitter>
<tenebrousedge> the rule with shell scripting is, "always quote variables"
<FromGitter>
<tenebrousedge> the other rule with shell scripting is, "try not to write shell scripts"
<FromGitter>
<absolutejam_gitlab> Aint nothing wrong with shell scripts
<FromGitter>
<tenebrousedge> except that Bash lacks basic features present in all other scripting languages
<FromGitter>
<tenebrousedge> named arguments, classes, types
<FromGitter>
<tenebrousedge> even `test` is an external command
<FromGitter>
<tenebrousedge> `[[` is a program with a required last argument of `]]`
<FromGitter>
<tenebrousedge> if bash didn't exist, and you came up with a language with those characteristics and tried to market it, people would call you nuts
<FromGitter>
<naqvis> > that looks correct β β I was expecting `#split` to preserve the quotes, as does Go
<FromGitter>
<tenebrousedge> it does
<FromGitter>
<tenebrousedge> `"\"Baz"`
<FromGitter>
<naqvis> i mean, `#split` should have ended up with size of 3 instead of 4
<FromGitter>
<naqvis> `βBaz Barβ` should have been treated single entity
<FromGitter>
<tenebrousedge> why? there's a space in there
<FromGitter>
<naqvis> shouldnβt be spliting on the `delimiter` inside quotes
<FromGitter>
<tenebrousedge> yes it should. It's splitting, not parsing
<FromGitter>
<naqvis> its similar behavior to how `CSV` parser does
<FromGitter>
<naqvis> commands inside quotes arenβt treated as separator
<FromGitter>
<tenebrousedge> CSV is parsed, `split` is not a parser
<FromGitter>
<naqvis> iβm talking about the behavior
<FromGitter>
<naqvis> not about the implementation details
<FromGitter>
<tenebrousedge> right, `split` is not and should not be content-aware
<FromGitter>
<tenebrousedge> if Go works differently, it's probably alone in doing that
<FromGitter>
<tenebrousedge> π you are quite welcome
return0e has joined #crystal-lang
<FromGitter>
<rogerwelin_gitlab> Hi all, crystal newbie here, I have a question about json parsing. The problem is that when the json keys have leading capital letter the json mapping wont work: β β ```code paste, see link``` β β Any ideas how to fix this? =) [https://gitter.im/crystal-lang/crystal?at=5d4828aa4b8ca519c9ebe898]
<FromGitter>
<naqvis> Variables name need to start with lowercase. If you have different keys then variables then use `type` instead
<FromGitter>
<naqvis> @absolutejam_gitlab any example along with problem will help here
<FromGitter>
<Blacksmoke16> i could go either way, one hand it makes sense since the restriction is just allowing any array with a type of any of those unioned types, while the return type is actually enforcing what it should be
<FromGitter>
<ArtLinkov> I have no clue what key i t refers too
<FromGitter>
<Blacksmoke16> doesnt actually mean the input type is *GOING* to always be of type `Array(Token)`
laaron has joined #crystal-lang
<FromGitter>
<Blacksmoke16> its an issue with mysql8 @ArtLinkov
<FromGitter>
<Blacksmoke16> i think
<FromGitter>
<ArtLinkov> @Blacksmoke16 what do you mean?
<FromGitter>
<Blacksmoke16> are you using mysql8? or?
<FromGitter>
<tenebrousedge> what were you trying to do?
<rkeene>
tenebrousedge, There are a couple of things -- one is replication is handled differently in MySQL (Postgres replicates by telling the slaves how to update their files, by file position); Another is indexing, MySQL (and SQLite) both support better indexing options
<rkeene>
Nothing too complicated, I was surprised Postgres didn't support it
<FromGitter>
<Blacksmoke16> maybe it does now?
<rkeene>
No, it was like a year ago
<rkeene>
It didn't support querying the index to count the rows or something like that
<rkeene>
Uber also moved their stuff from Postgres to MySQL due to replication issues and they wrote a good post about why replication is bad with Postgres
<rkeene>
COMDB2, however, avoids all those problems ;-)
<rkeene>
(It also has good Tcl bindings !)
duane has quit [Quit: Lost terminal]
duane has joined #crystal-lang
ht_ has joined #crystal-lang
ua has quit [Ping timeout: 272 seconds]
<FromGitter>
<absolutejam_gitlab> wait, does `ARGV` stringify everything?
ua has joined #crystal-lang
<FromGitter>
<ArtLinkov> got it thanks @Blacksmoke16 @tenebrousedge, I'll check it out :)
<FromGitter>
<tenebrousedge> @absolutejam_gitlab I mean, you will only get strings, but it's not Crystal's fault
<FromGitter>
<absolutejam_gitlab> Fuck. Then I don't need this stupid Union
<FromGitter>
<Blacksmoke16> :p
<FromGitter>
<absolutejam_gitlab> and I can just parse to `Int`/`Bool` last
<FromGitter>
<tenebrousedge> :plus1:
<FromGitter>
<ArtLinkov> @Blacksmoke16 whats the driver schema for pg?
<FromGitter>
<Blacksmoke16> hm?
<FromGitter>
<ArtLinkov> ```mysql://etc..."``` β What do I set instead of 'mysql'?
<FromGitter>
<Blacksmoke16> postgres
<FromGitter>
<ArtLinkov> Ah... I wrote 'postgre' lol β Thank!
<FromGitter>
<watzon> I just think I've been spoiled by NodeJS haha. The EventManager API is just intuitive.
<FromGitter>
<watzon> Also cute hasn't been updated in 2+ years, so it would almost definitely need some patching
laaron has quit [Remote host closed the connection]
<FromGitter>
<kniknoo> Agreed, 2 years without an update usually makes me scroll by a library. Even just a Readme update every release that says "works with #{cr_version}" would be nice.
laaron has joined #crystal-lang
ht_ has quit [Quit: ht_]
<FromGitter>
<AregevDev> Hello, I am developing `lib` bindings for a C library. How can I check if a C define is defined?
<FromGitter>
<watzon> @AregevDev what do you mean "check if a C define is defined"?
<FromGitter>
<tenebrousedge> I would assume that whatever `#define` test was happening would have to be replicated in Crystal, but I have very little knowledge of these things
<FromGitter>
<watzon> Oh yeah, you can't use C macros in Crystal
<FromGitter>
<watzon> You will have to re-define them
<FromGitter>
<AregevDev> I am looking for the equivalent of #ifndef
<FromGitter>
<AregevDev> Oh
<FromGitter>
<greenbigfrog> hm. am I remembering something wrong or not. β Can I have an enum as type in a DB.mapping?
<FromGitter>
<AregevDev> Any alternative in that case?
<FromGitter>
<Blacksmoke16> @greenbigfrog would prob have to specify a converter
<FromGitter>
<watzon> @AregevDev you might have to write a wrapper in C and then bind that
<FromGitter>
<greenbigfrog> how do I do such again?
<FromGitter>
<greenbigfrog> (or where can I find the docs)
<FromGitter>
<greenbigfrog> I find the DB docs rly weird to navigate/find what I'm looking for
<wmoxam>
How much RAM does it take to build the Crystal compiler these days? I'm trying to build on OpenBSD and am getting "LLVM_ERROR: out of memory"
<wmoxam>
It's on a vm with 12GB RAM allocated, and am using LLVM 8
<mps_>
wmoxam: I build it on Alpine linux with 6GB RAM and 8GB swap
<mps_>
didn't worked with 4GB swap, had to extend it
<mps_>
also, llvm8
<wmoxam>
mps_: ok, thanks
<wmoxam>
I've only got 1.5GB swap
<mps_>
I created swapfile, not swap partition
lucasb has joined #crystal-lang
<mps_>
maybe I could go with less swap if I stopped firefox and some lxc containers, but just increased swapfile, it was easier and didn't wanted to stop active sessions
moei has quit [Quit: Leaving...]
<mps_>
still have no luck at aarc64
<FromGitter>
<j8r> Have you zswap mps_?
<FromGitter>
<j8r> Not sure it's a RAM issue at the end.
<mps_>
j8r: no, I have big lxc container with 128GB RAM
<FromGitter>
<j8r> Woa :o
<mps_>
no, it is not RAM size related
<mps_>
I thought to check it tomorrow again, today I had a lot of work on some unrelated things
<mps_>
as a distro dev I have some privileges, 64 CPU's and 128GB RAM, although I mostly use 8 to 16 of them and not more than 20GB RAM