ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | 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
<FromGitter> <watzon> Making good progress here
<FromGitter> <watzon> Man I thought it would display a preview, guess not
<FromGitter> <watzon> Any good way around this?
<FromGitter> <watzon> Trying to subclass and redeclare a variable as a different type
<FromGitter> <Blacksmoke16> dont declare it in the parent?
<FromGitter> <watzon> It's needed in the parent though
<FromGitter> <watzon> I guess I'd have to make a parent for the parent huh
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <watzon> Fml haha
<FromGitter> <watzon> Just hacked around it for now by making a `@_default` variable in the child class, but I don't like it
<FromGitter> <watzon> I'll figure out something later
<FromGitter> <Blacksmoke16> :this_is_fine:
deavmi has quit [Ping timeout: 264 seconds]
deavmi has joined #crystal-lang
DTZUZU has quit [Quit: WeeChat 2.7]
<FromGitter> <watzon> Does Crystal have trouble resolving requires with a hyphen? Like `require "term-cursor"`.
<FromGitter> <watzon> It was working when it was just cursor, but adding the hyphen seems to have broken things. It's updated in both `shard.yml` files.
<FromGitter> <Blacksmoke16> It shouldn't
<FromGitter> <Blacksmoke16> Try deleting lib and reinstall?
<FromGitter> <watzon> Already tried
<FromGitter> <watzon> Hmm
<FromGitter> <watzon> Does directory structure matter in this case? Changing it back to `cursor` made it work again, so I'm thinking maybe I need a `src/term/cursor` structure?
<FromGitter> <Blacksmoke16> Or q file with the hyphen
<FromGitter> <watzon> Ahhh yeah, that would probably do it
<FromGitter> <watzon> Duh
<FromGitter> <watzon> Yep that's it
<FromGitter> <Blacksmoke16> Mhm
blueberrypie7 has quit [Quit: leaving]
blueberrypie has joined #crystal-lang
DTZUZU has joined #crystal-lang
<FromGitter> <damianham> > *<raz>* john carmack says it's ok, so it's ok ⏎ ⏎ But it isn't though. As software engineers if we review the code we can see instantly that it isn't OK. The problem is not that this code isn't OK. The problem is that this code is being used to drive government policy decisions that affect the lives of millions of people and without decent test coverage they cannot prove the code is OK. The
<FromGitter> ... cancelling of cancer treatment in hospitals will cause some people with cancer to die due to lack of treatment. That has happened because of this prediction model. If we cannot prove that this model performs correctly then how can we trust it to accurately predict pandemic outcomes. Furthermore this team at IC has been spectacular ... [https://gitter.im/crystal-lang/crystal?at=5eb6342e7975db7ebff3a87a]
zorp has joined #crystal-lang
<FromGitter> <watzon> The problem is that very few people have the requisite knowledge about the subject in order to successfully write something better than what's already there. Think about it, whoever wrote that code likely at least knew what they were doing to some degree when it comes to modeling the spread of a virus, and they still managed to fuck it up. As cool as it would be to use Crystal and recreate that software, I don't
<FromGitter> ... think anyone here knows near enough about viruses and how they spread.
<FromGitter> <watzon> The one person I can think of that might have any clue is @ArtLinkov, but he's a busy guy, aren't you Art πŸ˜‰ haha
<raz> damianham: yep, what watzon said. also you are jumping to many questionable conclusions (some of which are provably false). that code does not "drive policy". it's one study of many. afaik UK and partially US are the only countries where it got disproportionate media attn. we don't know if the predictions was/is wrong (the world is in lockdown, so of course the observed reality is better than what the model predicted - that's the whole purpose of the
<raz> lockdowns). etc.
<raz> also afaik it's not the only model that predicted these numbers. many (all?) epidemiologist worldwide look at this every day with all the tools they have. nearly all countries came to the same conclusion (that a lockdown is needed) and they certainly didn't base that decision on a single foreign study.
renich has quit [Quit: renich]
alexherbo2 has joined #crystal-lang
_ht has joined #crystal-lang
livcd has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
<FromGitter> <alex-lairan> Hello! ⏎ ⏎ Small question more architectural than Crystal :slightly_smiling_face: ⏎ ⏎ I'm coding an app that will generate applications and automatically put them into production. ... [https://gitter.im/crystal-lang/crystal?at=5eb674279f0c955d7db40e42]
<raz> on an unrelated note: it would be great if the irc bridge didn't truncate messages :(
<FromGitter> <alex-lairan> Oh :/ From where it truncate ?
<raz> alex-lairan: sounds like you're in the realm of deployment tools like ansible
<raz> but really depends a lot on the details
<raz> alex-lairan: sorry that wasn't directed at you (but at whoever the botmaster is :)). i'm reading with IRC and here we only get half your msg and a link to gitter :/
<FromGitter> <alex-lairan> The details are that the user will send me an AI in a single file (there are multiple formats for this) ⏎ My app will take the file and generate the most appropriate application to read the format and execute AI queries. ⏎ ⏎ In the first time I will just handle python and TensorFlow, but I will handle more standards in a near future. [https://gitter.im/crystal-lang/crystal?at=5eb675b731a6d25d7cbbcc94]
<FromGitter> <alex-lairan> My api is in Crystal. I use `.ecr` to generate the Python file and configuration.
<raz> from the sound of it i'd generally decouple the code generation. people may want to deploy in different envs, there's usually no one size fits all. so maybe just emit a plain python app, then people can deploy it in the same way as they do with other python apps.
<raz> if you want to make it a turnkey "one-click" solution then releasing it as a docker image could also work
<FromGitter> <alex-lairan> Yes, I want a one-click solution. ⏎ Docker may be a good idea
<raz> yup docker can do that. many admins are not fans of running opaque docker images in production, but at least that give a solid "just works" starting point and they can still tweak the image from there.
<raz> ideally you could not only release a static image but a Dockerfile generator. (i.e. emit the python app and a Dockerfile to bundle it up)
iwq has joined #crystal-lang
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has joined #crystal-lang
Human_G33k has joined #crystal-lang
return0e has quit [Remote host closed the connection]
HumanGeek has quit [Ping timeout: 240 seconds]
gangstacat has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
sagax has quit [Quit: Konversation terminated!]
<FromGitter> <didactic-drunk> @damianham *My* conversation with head of microbiology dept at university that lead to shutdowns in large cities/states (he/she personaly met with governors/mayors urging early shutdowns in Feb). ⏎ ⏎ Abbreviated txt conversation: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5eb6daf322f9c45c2a7da381]
<FromGitter> <j8r> It is interesting, but I don't see how it is crystal related.
<FromGitter> <j8r> It is fine to make quick references of non-crystal stuff, IMHO here it is a bit long :/
<FromGitter> <j8r> @alex-lairan I'd use caddy instead of nginx, because it has an API
alexherbo25 has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<FromGitter> <watzon> Idk I think it's a fine response. This is the second time in as many days that this guy has put out a call to action for us to rewrite that C++ code in Crystal because the original code is "broken". I doubt this will end it, but hopefully he sees that it's just not a good, or even feasible, idea.
<FromGitter> <watzon> Same man, same
<FromGitter> <watzon> Caddy is great
alexherbo25 has quit [Ping timeout: 264 seconds]
<FromGitter> <didactic-drunk> Next time I'll put everything past the first paragraph in a subthread.
<raz> j8r: agreed. unfortunately this covid thing not only infects people, but also each and every discussion group that exists anywhere, regardless of what it was originally about :D
<raz> however, i liked that little diversion, it's interesting to hear what the fellow crystalers think about it. although yes, in general, if we want to talk about viruses, we should keep it about computer viruses in here. :p
<FromGitter> <watzon> Overall the forum would've been a better place for discussion, but who knows if Damian knows about the forum
<FromGitter> <didactic-drunk> @j8r this was my short response. There were others I left out, like if you made the software, no one would use it or read the results. The scientists don't use crystal/ruby, so wouldn't validate it. Or want to use it for a variety of reasons. Does anyone have published research paper here? No? Then you won't get published anywhere credible. Know anyone high up in government/research? No? Another
<FromGitter> ... dead end.
return0e has joined #crystal-lang
<FromGitter> <didactic-drunk> Next time I'll create a forum post and link it.
<FromGitter> <watzon> Anyone know how I could use `select` to wait for every channel in an array to send once?
<FromGitter> <didactic-drunk> @watzon Is this for signaling completion?
<FromGitter> <RomainFranceschini> Agreed, there's no point in reproducing this model in Crystal
<FromGitter> <RomainFranceschini> On a side note I believe Crystal is a really nice language to do science, I published papers backed by Crystal code and will continue to do so
renich has joined #crystal-lang
<renich> Good day
<renich> I wonder... how do you parse an array? I tried `[1, 2, 3].each do |n| {}` but it doesn't work... Is there a preferred way to go through all of an array's elements? I want to do something with them, not to them...
Stephanie is now known as Stephie
<oprypin> renich, the `{}` is out of place. start a new line instead
<renich> oprypin: OK. So, the each should work?
<oprypin> yes
alexherbo2 has quit [Ping timeout: 256 seconds]
<renich> oprypin: OK. Thanks. Will check it.
<renich> oprypin: thank you. It works fine. The problem was I used `File.read_lines(file) if File.readable?(file)`. I should've used if File.readable?(file)... `
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/File.html#each_line(filename:Path|String,encoding=nil,invalid=nil,chomp=true,&)-class-method
<FromGitter> <Blacksmoke16> would be better if you just want to iterate over each line
<FromGitter> <Blacksmoke16> assuming you dont need the array of lines for some other than just iterating it
<FromGitter> <watzon> @didactic-drunk yeah. I was thinking about it the wrong way. I just used a buffered channel and did `receive` for each item.
woodruffw has joined #crystal-lang
zorp has quit [Ping timeout: 246 seconds]
renich has quit [Quit: renich]
renich has joined #crystal-lang
sagax has joined #crystal-lang
<FromGitter> <UnsolvedCypher_gitlab> Is there a way to force a type not to be nil? Do I need to cast it to what I want it to be, or use a ternary if to handle the nil case, or is there a cleaner awy?
<FromGitter> <Blacksmoke16> `.not_nil!`
<FromGitter> <Blacksmoke16> but id think about if you can rework things to not need it
<FromGitter> <Blacksmoke16> i.e. what does `nil` represent, what should happen if the value is `nil` etc
<FromGitter> <UnsolvedCypher_gitlab> Oh, I completely missed that, thank you!
<FromGitter> <Blacksmoke16> if you need to use it a lot there prob is a better way to do something
<FromGitter> <UnsolvedCypher_gitlab> Yes I do realize that it's typically poor practice, this is for a quick script I only need to run once and I'm just trying to do .index of an element that I already know exists
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <Blacksmoke16> other option would be like
<FromGitter> <Blacksmoke16> ```if idx = arr.index 1 ⏎ # do something with idx ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5eb712d80b23797ec0725603]
<FromGitter> <Blacksmoke16> or
<FromGitter> <Blacksmoke16> `arr.index(1).try { |idx| pp idx }`
<FromGitter> <UnsolvedCypher_gitlab> Those are both very helpful to know, I'll read up on the Object API a little more. Thank you!
<FromGitter> <Blacksmoke16> `.try` is good if the value can also be false
<FromGitter> <Blacksmoke16> since `idx` couldnt be `false` since it isnt truthy
<FromGitter> <UnsolvedCypher_gitlab> Oh I didn't think of that
<FromGitter> <watzon> Woo
<FromGitter> <watzon> Multiple spinners running at the same time with a top level spinner representing the status
<FromGitter> <j8r> gg
<FromGitter> <j8r> I suppose the 4 lines are redrawn each spin
<FromGitter> <watzon> Yep haha
<FromGitter> <j8r> you have made a library?
<FromGitter> <watzon> Interestingly enough, they can each spin at different rates and with different styles too
<FromGitter> <j8r> great, love this projects
<FromGitter> <watzon> Thanks :) dealing with the terminal is kind of a pain in the ass haha, but I'm making good progress
<FromGitter> <j8r> I could rewrite https://github.com/j8r/cride to use them :P
<FromGitter> <watzon> Oh yeah, you probably could! I'm hoping to take the individual pieces of this and actually build out a terminal UI library in pure Crystal
<FromGitter> <watzon> I don't think I could make an enum work here, unless I were to make an enum on top of the hash. The hash is because I'm mapping the key's control character to a key name.
<FromGitter> <watzon> I guess I could map it to an enum value
<FromGitter> <watzon> But I'd still need the control character map
<FromGitter> <j8r> why names?
<FromGitter> <j8r> you can do with enums
<FromGitter> <watzon> Doesn't have to be names specifically, mapping to an enum value would work
<FromGitter> <Blacksmoke16> you can define methods on enums remember
<FromGitter> <j8r> `Enum#parse(String)`
<FromGitter> <j8r> I made a terminal editor, so definitely possible
<FromGitter> <watzon> Fair, but I'd still need a key map
<FromGitter> <watzon> I'll look into refactoring it to use an enum now
<FromGitter> <Blacksmoke16> something like that `Key::CTRL_A.some_method`?
<FromGitter> <j8r> @watzon where do you need the map?
<FromGitter> <j8r> Can be done with macros anyway
<FromGitter> <j8r> Using an enum helps to match the key code with its meaning
<FromGitter> <watzon> Maybe I'm just not understanding. Right now I'm using the map because I need to match a key control character to the name of the key. I could map to an enum value instead, or use an enum method to parse the control character to a value, but I still need a map that says which control character is which value, no?
<FromGitter> <watzon> Unless I just use a giant case statement, but isn't using a constant hash more efficient?
<FromGitter> <j8r> When reading the character, you got a integer, right?
<FromGitter> <j8r> This integer, then, is matched with an enum member
<FromGitter> <watzon> Actually yes haha, you're right
<FromGitter> <watzon> I forgot that the control character started as an integer
<FromGitter> <j8r> I have done in a way, I see you use an other logic with `cooked` etc. ⏎ I don't know what is the proper way :/
<FromGitter> <j8r> But it does not seem there is a buffer?
<FromGitter> <watzon> A buffer for pressed keys?
<FromGitter> <j8r> yeah
<FromGitter> <j8r> For instance, when I copy paste
<FromGitter> <watzon> I've gotta refamiliarize myself with my work for a bit haha, I made this like a month ago and haven't touched it much since
<FromGitter> <j8r> `Int#unsafe_chr` is useful in this case :)
<FromGitter> <j8r> (I wonder why they omit the `a` in `chr`)
<FromGitter> <watzon> Shorter I guess haha
<FromGitter> <watzon> Idk
woodruffw has quit [Excess Flood]
woodruffw has joined #crystal-lang
hightower2 has joined #crystal-lang
<hightower2> Hey which version of llvm is supported by crystal? 8 or?
<FromGitter> <Blacksmoke16> 6+ i think?
<FromGitter> <Blacksmoke16> can prob just use the latest if you have choice
<hightower2> hm yeah... looks like the default binary pkgs are compiled with 8 though. ( crystal eval 'p ::Crystal::LLVM_VERSION' )
<FromGitter> <Blacksmoke16> so?
<hightower2> nothing, just checking :)
<FromGitter> <j8r> ho too bad, there is no `None` for samesite cookies :(
<FromGitter> <j8r> sending a PR
<FromGitter> <Blacksmoke16> πŸ‘
return0e has quit [Remote host closed the connection]
<FromGitter> <j8r> > Browsers are migrating to have cookies default to SameSite=Lax. If a cookie is needed to be sent cross-origin, opt out of the SameSite restriction using the None directive. The None directive requires the Secure attribute.
<FromGitter> <j8r> No way to enforce that :(
<FromGitter> <Blacksmoke16> `None` wasnt in the RFC so didnt think it was valid when i added that
<FromGitter> <Blacksmoke16> and was before the chrome change and such
<FromGitter> <Blacksmoke16> er oops, its in the RFC, just missed that one i guess 😬
<FromGitter> <Blacksmoke16> `This field's value is one of "None", "Strict", or "Lax".`
<FromGitter> <j8r> Will just add a value to the enum
<FromGitter> <Blacksmoke16> given that requirement isnt in the RFC would be hard to enforce i suppose
<FromGitter> <Blacksmoke16> as its just required for chrome i guess?
<FromGitter> <j8r> No, I just want to be sure a will always be sent
_ht has quit [Quit: _ht]
<FromGitter> <j8r> or maybe, I didn't checked
<FromGitter> <Blacksmoke16> sorry, was referring to `The None directive requires the Secure attribute.`
<FromGitter> <j8r> ha, this
<FromGitter> <Blacksmoke16> for now you could use `extension` property of the cookie
<FromGitter> <Blacksmoke16> set that to `SameSite=None`
<FromGitter> <j8r> right, thanks
* raz groans at everything related to browser "security" and to browsers in general and to the web in general and an extra groan to javascript
<FromGitter> <j8r> not easy yeah
<raz> the damage these trainwrecks of a rotten mess have done to us as a species, and will still do, is immeasurable
<FromGitter> <Blacksmoke16> http_only; secure; SameSite=Lax covers most of the bases
* FromGitter * j8r being cheesed by web security
<raz> all the braincycles wasted on CORS, SRI, CSP and a bazillion other acronyms that shouldn't exist
return0e has joined #crystal-lang
<FromGitter> <j8r> that's because of legacy insecure sites
<FromGitter> <j8r> and also new ones
<raz> and the poor young brains who make their first contact to programming through a language that invented a freakin `===` operator...
<FromGitter> <j8r> Crystal has it too :)
* raz blinks
<FromGitter> <watzon> For instance https://crystal-lang.org/api/0.34.0/Char.html#===(byte:Int)-instance-method
<FromGitter> <j8r> https://carc.in/#/r/91eb
<raz> meh ok. that's like a wart on an otherwise fine language. in js it's more like a wart on a wart of a language.
<FromGitter> <j8r> It may be unexpected: ⏎ ``cr
<FromGitter> <Blacksmoke16> only really used in crystal to customize behavior within `case`
<FromGitter> <j8r> case 'c' ⏎ ⏎ when 99 then puts "True!" ⏎ end [https://gitter.im/crystal-lang/crystal?at=5eb730829f0c955d7db5beb8]
<raz> yea, poor naming imho. but i guess it's obscure enough that few people will get confused by it.
<FromGitter> <j8r> if instead of `'c'`, there is an union type of `Char | Int32`, it becomes a mess
<FromGitter> <j8r> Is it that complicated to use `#ord`...
<raz> definitely not. that's what any sane person would do anyway
<raz> if only as a courtesy to not give JS PTSD to the next person who reads the code
woodruffw has quit [Ping timeout: 258 seconds]
<FromGitter> <j8r> wow, 175 PRs waiting in Crystal :/
<FromGitter> <Blacksmoke16> any reason to not make it last?
<FromGitter> <Blacksmoke16> ```Strict ⏎ Lax ⏎ None``` [https://gitter.im/crystal-lang/crystal?at=5eb7347b97338850a2fab15c]
<FromGitter> <Blacksmoke16> half of them can prob be closed id imagine
<FromGitter> <j8r> because: ⏎ ⏎ 1) It is the order in MDN ⏎ 2) `None` in crystal is usually `0` (example: flag enums) [https://gitter.im/crystal-lang/crystal?at=5eb734bd14b48f0698be5a3c]
<raz> yes, starting with this one https://github.com/crystal-lang/crystal/pull/9102
<raz> i mean, i understand core devs drink booze, too
<FromGitter> <Blacksmoke16> :shrug: fair enough
<FromGitter> <j8r> haha :D
<raz> but pleaaase
<raz> adding random syntax gimmicks is bad, mmkay.
<raz> linters, editors, code highlighters all have to keep up with nonsense
<raz> that*
hightower2 has quit [Ping timeout: 256 seconds]
hightower4 has joined #crystal-lang