<FromGitter>
<rishavs> In JS, I would probably create an array of the functions and iterate through them, returning the value the moment any of them suceeded
<FromGitter>
<Timbus> I guess you can just chain the functions using `||`, if its only a few
<FromGitter>
<Timbus> methods*
<FromGitter>
<rishavs> but wouldn't it run through each and every function in the chain?
<Yxhuvud>
No, || shortcuts
<FromGitter>
<f1refly_gitlab> It wouldn't. Besides, your proposed solution isn't too bad in my opinion
<Yxhuvud>
also, you should read up on elsif and case statements.
<FromGitter>
<rishavs> @yxhuvud case wouldn't work here and elsif would force me to use .try anyway. @f1refly_gitlab which solution? the array of functions? or just the if/else forest? โ Also, if I were to do โ โ ```code paste, see link``` โ ... [https://gitter.im/crystal-lang/crystal?at=5b8e2c0158a3797aa3fd88c8]
<FromGitter>
<Timbus> it wouldn't
<FromGitter>
<rishavs> Nice. I will try it out
<FromGitter>
<rishavs> Thanks guys
<FromGitter>
<f1refly_gitlab> The if/else forest you planted
<FromGitter>
<Timbus> id save it for.. like small use cases
<FromGitter>
<f1refly_gitlab> It works, but i feel like it's a horrible solution
<FromGitter>
<bajro17> @aminraeisi do you want we make one with crystal
<FromGitter>
<bararchy> arch linux still don't have 26.1 package :(
<FromGitter>
<bararchy> whos the brave soul to add `.to_h` for XML::Node ? ;)
<FromGitter>
<bew> What would be the key?
<FromGitter>
<bew> Maybe YOU can do a PR @bararchy ;)
<FromGitter>
<bararchy> lol not brave enough
<FromGitter>
<bararchy> XML::Serilizable hahah
<FromGitter>
<bararchy> basicly the idea is having a more generic way to recurse around standard data structures
<FromGitter>
<bararchy> we already treat YAML and JSON as "hash-like" objects, why not XML too ?
<FromGitter>
<codenoid> hi, how i can check free memory in my computer with only crystal
<FromGitter>
<Timbus> You have to ask the OS.. And its platform specific
<FromGitter>
<bew> @bararchy don't forget that hash-like usage of a YAML or JSON doc is definitely not recommended
<FromGitter>
<bew> You want sth like a XML::Any ?
<FromGitter>
<bararchy> yeha
<FromGitter>
<bararchy> `XML::Any`
<FromGitter>
<bew> Have fun, I'm not touching any of that ๐
<FromGitter>
<codenoid> @Timbus Ubuntu 16.04
<FromGitter>
<codenoid> btw, i want to run child process for a long time, โ better to use `fork` or `spawn`
<FromGitter>
<Timbus> In theory, spawn is what you want.
<FromGitter>
<Timbus> `fork` will give you a different process, and there's some tricky filehandle related issues. But sometimes it is quite useful, and you'll have real cooperative concurrency
<FromGitter>
<codenoid> ups
<FromGitter>
<codenoid> but i think `fork` is answer for my case
<FromGitter>
<codenoid> bcoz sometime i will kill that child process
<FromGitter>
<codenoid> ah i'll try
<FromGitter>
<Timbus> For the meminfo, I guess the best way seems to be to read `/proc/meminfo`
<FromGitter>
<Timbus> And in case you need it, `/proc/#{PID}/status` is probably useful for you, too
<FromGitter>
<Timbus> I'll let @codenoid see that ^^
shalmezad has joined #crystal-lang
ua has quit [Read error: Connection reset by peer]
ua has joined #crystal-lang
Groogy1 has quit [Ping timeout: 240 seconds]
zorp_ has joined #crystal-lang
v2px__ has joined #crystal-lang
zorp has quit [Ping timeout: 245 seconds]
zorp_ has quit [Ping timeout: 260 seconds]
zolbatar has joined #crystal-lang
zolbatar has quit [Quit: zolbatar]
Groogy1 has joined #crystal-lang
<FromGitter>
<MyrddinE> Quick noob question... I found the language specification reference, but I'm not seeing the library reference. Where can I find the Object hierarchy, Modules, and standard library documentation?
<robacarp>
@sdogruyol thanks for the mention in crystal-weekly :]
<FromGitter>
<bew> Welcome to Crystal @MyrddinE ;)
<FromGitter>
<rishavs> Heiyyyyoooo!! I just wrote my first library for crystal. Its simple and shitty, but does the work. :D โ https://github.com/rishavs/crog it fetches the open graph tags from any web page.
<FromGitter>
<bew> Cool! Don't forget to populate the "Usage" section of the Readme!
<FromGitter>
<rishavs> lol. i forgot that. updating now
<FromGitter>
<rishavs> no specs though. will add them later
Groogy1 has quit [Ping timeout: 252 seconds]
<FromGitter>
<j8r> I don't know who was the first to use the typical "Add this to your application's shard.yml:" - everyone, including me, use it ๐
<FromGitter>
<j8r> @rishavs You could have `T?` types instead of `T | Nil` ๐
<FromGitter>
<rishavs> Thanks! I am still pretty bad when it comes to handling nils. bad JS habits and all ๐
DTZUZO has joined #crystal-lang
<robacarp>
@j8r I always assumed that came from the Ruby "add this to your gemfile"
<FromGitter>
<j8r> robacard yeah it can be, well observed (I don't come from Ruby). We could simply say `Add this to your shard.yml`... I will use this starting from now
<FromGitter>
<j8r> but this will be more correct to say something like: โ โ > Add the dependency to your `shard.yml`:
<robacarp>
yeah, or "Update your shard.yml: <diff>"
<robacarp>
I have the diff on https://github.com/robacarp/mosquito/ . shard.yml has the distinct complexity that you can't just paste the shard name in wherever, so I wanted to make it a little more obvious what needed to happen
DTZUZO has quit [Ping timeout: 260 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 252 seconds]
DTZUZO has joined #crystal-lang
<RX14>
@robacarp why didn't you contribute to sidekiq.cr
<RX14>
i've had to use it in production recently and I found it lacking too
<RX14>
well, a bit buggy actually
<RX14>
and not suitable to very high concurrency jobs
<RX14>
and it might have been leaking memory, didn't have time to track that down
<FromGitter>
<vladfaust> Hm, RX14, I've seen you as an OSS guy
<FromGitter>
<vladfaust> And now you propose to contribute into PAID SOFTWARE
<RX14>
sidekiq is open source
<RX14>
and sidekiq.cr
<FromGitter>
<vladfaust> Or rly
<FromGitter>
<vladfaust> https://sidekiq.org says that many essentials are paid
<RX14>
well it's half open source
<RX14>
i didn't pay for it
<FromGitter>
<vladfaust> Why not using and promoting Resque then?
<FromGitter>
<vladfaust> I beleive its integration with Crystal would be fairly simple
<RX14>
because it doesnt have a crystal runner and because i didn't know it existed
<FromGitter>
<vladfaust> Wow
DTZUZO has quit [Ping timeout: 244 seconds]
<FromGitter>
<vladfaust> Resque is a very nice thing, I've used it in my Ruby projects
<RX14>
and because the codebase i was porting didn't use it
<RX14>
either way
<RX14>
all of them would have eventually had the same problem for this usecase
<RX14>
which is why i'm rewriting to use none of them
<FromGitter>
<vladfaust> How do you organaize jobs then?
<robacarp>
@RX14 I don't agree with the freemium model of open source
<robacarp>
and it didn't have what I've always wanted from sidekiq ruby which is periodic jobs
<FromGitter>
<vladfaust> @robacarp I do. It's wonderful when an OSS developer gets paid from companies for extra features
<robacarp>
I'm not agaist getting paid to implement features, I'm against forking your project into a free and a paid version
<robacarp>
if a company wants to sponsor a project, great, and that sponsorship should be available to everyone
<robacarp>
er, the product of that sponsorship
<FromGitter>
<vladfaust> That's a point of view
<FromGitter>
<vladfaust> However, a developer would make much more when splitting. It's a hard job to find an ideal balance of what to split, and if it's found, it's great for many
<robacarp>
As you said, that's a point of view.
<FromGitter>
<vladfaust> ะัะท
<RX14>
@vladfaust the whole model of submitting jobs doesn't suit this application
<FromGitter>
<vladfaust> Got it
<RX14>
more like kafka
<RX14>
but i'm thinking on using redis streams
<FromGitter>
<vladfaust> I got no experience in such things, Resque always was enough. Or bare cron
<robacarp>
@rx14 you're looking for something more like event processing?
<RX14>
not really
<RX14>
its just fan-out message delivery
<RX14>
many publishers pushing messages
<RX14>
many subscribers
<RX14>
and this is a federated system so high-letency and broken subscribers are exremely common
<RX14>
job queues don't segregate each consumer
<robacarp>
oh sure, yeah.
<RX14>
and so they're vulnerable to one consumer backing up the whole system when their DNS fails and you're waiting 10 seconds for each job
<RX14>
also, 600+ messages in per second and 130+ subscriptions, so 78000 deliveries per second :)
<RX14>
sidekiq was not suitable
<robacarp>
that doesn't sound like the right application for a worker cluster at all
<RX14>
yeah, the ruby prototype I was copying used sidekiq for this
<RX14>
so I copied the structure before doing the math
<RX14>
and now i'm having to rewrite
<robacarp>
I've used rabbitmq in the past for something that I think is similar, and had nothing bad to say about it. I've never used redis streams though
<RX14>
for now i'm skimping on the consistency and going to do it all in-process
<RX14>
and then i'll add streams once that's working
<RX14>
because if even in-process can't keep up then redis has no hope
<FromGitter>
<sdzyba> Take a look at NATS and NATS Streaming particularly. Mostly the same features as Kafka has but NATS has way simplier API while having about the same performance. It simply doesn't feel that bloated
<FromGitter>
<sdzyba> ...that bloated as most of the Java software does and Kafka is no exception
<RX14>
@sdzyba thanks i'll check it out
rohitpaulk has quit [Ping timeout: 245 seconds]
<RX14>
oof, nats streaming protocol seems pretty hard to implement
<FromGitter>
<sdzyba> that's exactly why I suggested a Ruby client, meaning it might be not that hard to port it to Crystal :)
<RX14>
porting ruby code never really works out well
<RX14>
it's never type-safe
<FromGitter>
<sdzyba> well, still can be used as a reference, I believe. Go client might used as well in that case but, well, it is a too different programming paradigm
<RX14>
yeah i'd use it as a reference but i'd rather not port a whole library
<RX14>
so it's a bit moot because it'd be a lot of effort to use an under-documented solution anyway
<FromGitter>
<girng> interesting, i wish him the best very nice person
<FromGitter>
<girng> he's the reason why i first sttarted to transition to crystal
<FromGitter>
<girng> cause of websocket benchmark article
ua has quit [Ping timeout: 260 seconds]
shalmezad has quit [Quit: Leaving]
<FromGitter>
<j8r> @DanielSokil like @r00ster91 said, you have to assign a variable to check if it's nillable. The compiler doens't *introspect* inside objects to check nillability. Also very often the `!= nil`can be dropped (unless the type is `Bool?`)
<FromGitter>
<j8r> I think this check can only be done at the same variable level, or something like that (don't know the internals enough)
<FromGitter>
<straight-shoota> Actually, `var != nil` doesn't work as a nil restriction either. You need to use `var.nil?` (or just `var` unless it's boolean). โ See https://crystal-lang.org/docs/syntax_and_semantics/if_var.html for details and limitations.
<robacarp>
running in circles here today, aren't we