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
<FromGitter> <Blacksmoke16> so could only really handle this within the `IOHandler`
<FromGitter> <Blacksmoke16> vs the formatter, which would make more sense
<FromGitter> <Blacksmoke16> i.e. if you make a handler to save a string to a db or sentry, would have to handle it there also
<FromGitter> <tenebrousedge> but should you be stripping ANSI escape sequences anyway?
<FromGitter> <tenebrousedge> the regex (https://stackoverflow.com/questions/25245716/remove-all-ansi-colors-styles-from-strings) for it is pretty arcane
<FromGitter> <Blacksmoke16> i guess it all boils down to
<FromGitter> <Blacksmoke16> if you log a colorized `STRING` would you expect to see `STRING` or `STRING` in a log file
<FromGitter> <tenebrousedge> can you set a value at initialization for whether the output supports color?
<FromGitter> <Blacksmoke16> and should there be a way to customize it
<FromGitter> <tenebrousedge> I would expect the logger to behave like other unix programs, and use colors when directed at an interactive terminal, and to strip them for text output
<FromGitter> <Blacksmoke16> i think that would be ideal
<FromGitter> <Blacksmoke16> but gotta think on how to implement that
<FromGitter> <tenebrousedge> the handler should probably know whether the output supports color
<FromGitter> <Blacksmoke16> heres another question, would it be ok that it would have to be handled in every handler?
<FromGitter> <Blacksmoke16> or suppose it could be a comon on the parent formatter type, of which each handler could do something like
dwdv_ has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da7b0bf870fa33a4d0647ed]
<FromGitter> <Blacksmoke16> with it defaulted to false?
<FromGitter> <Blacksmoke16> then its decoupled from the handler, albeit a bit more verbose
<FromGitter> <tenebrousedge> I would expect the handler to have something like a `supports_color?` property, or perhaps an `ansi?` one, and that this would default to `false`
<FromGitter> <tenebrousedge> presumably this would be passed or detected at initialization
<FromGitter> <tenebrousedge> I don't know how it can be detected, I just know that it can be done
<FromGitter> <Blacksmoke16> then if it doesnt support color, strip them out
<FromGitter> <Blacksmoke16> just seems more like something a formatter should do
<FromGitter> <Blacksmoke16> oo heres an idea
<FromGitter> <Blacksmoke16> make it part of the abstract formatter type, but enabled on the handler level
<FromGitter> <Blacksmoke16> `Crylog::Handlers::IOHandler.new(File.open("out.log", "a"), colorize: false)`
<FromGitter> <Blacksmoke16> which internally sets it on that handler's formatter instance
<FromGitter> <Blacksmoke16> bit better UX you think?
hypercore has quit [Ping timeout: 260 seconds]
hypercore has joined #crystal-lang
alex``` has quit [Ping timeout: 250 seconds]
<FromGitter> <tenebrousedge> that looks good to me
<FromGitter> <sam0x17> ugg still getting this error in lambda (crystal app compiled via static alpine image) only and not locally whenever I hit an https link with `HTTP:Client`: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da7bf4adbf676673471f912]
<FromGitter> <sam0x17> I'm assuming I need to give crystal access to ca certificates somehow
<FromGitter> <tenebrousedge> probs
<FromGitter> <sam0x17> somehow :(
<FromGitter> <sam0x17> hopefully crystal has an option somewhere where I can specify a cacerts bundle file like curl has
<FromGitter> <sam0x17> googling is just finding a bunch of crystal reports crap of course
<FromGitter> <sam0x17> aha https://crystal-lang.org/api/0.31.1/OpenSSL/SSL/Context.html#ca_certificates_path%3D(dir_path%3AString)-instance-method
<FromGitter> <tenebrousedge> @sam0x17 how do you pass that when you instantiate a client?
<FromGitter> <sam0x17> hah nice it works, ok here's how:
<FromGitter> <sam0x17> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da7c6862d59854e7f17bd70]
<FromGitter> <sam0x17> the rest is just the original code for the initialize method for `OpenSSL::SSL::Context::Client`
<FromGitter> <tenebrousedge> wait, you have to monkey patch it?
<FromGitter> <sam0x17> there is no class method for globally setting it so yeah
<FromGitter> <sam0x17> otherwise I have to manually do it on whatever instance of that gets instantiated
<FromGitter> <sam0x17> I just want all https requests to work
<FromGitter> <tenebrousedge> hmmmmmmm
<FromGitter> <sam0x17> if that `ca_certificates` method was a class method I'd be good
<FromGitter> <sam0x17> but sadly instance, with no class method equivalent
<FromGitter> <sam0x17> still surprised this worked on the first try xD
<FromGitter> <sam0x17> just used certificate bundle from mozilla
<FromGitter> <tenebrousedge> is there a default path that it checks?
<FromGitter> <sam0x17> there might be
<FromGitter> <sam0x17> I'm on a deadline so not gonna dig deeper but def let me know if you find anything fruitful
<FromGitter> <tenebrousedge> yes, there is a default path
<FromGitter> <sam0x17> what is it?
<FromGitter> <sam0x17> thing is, in a lambda, I only have write access to /tmp
<FromGitter> <sam0x17> so unless there is some environment variable I can set I have to override it
<FromGitter> <tenebrousedge> probably /opt/local/etc/openssl
<FromGitter> <sam0x17> yeah, strange that it's not there already, as nodejs's ssl works fine
<FromGitter> <sam0x17> amazon must be manually setting a weird path
<FromGitter> <tenebrousedge> or /usr/lib/ssl
<FromGitter> <tenebrousedge> whatever `openssl version -d` says
<FromGitter> <sam0x17> I'll find out
<FromGitter> <sam0x17> running in lambda has been quite an adventure
<FromGitter> <tenebrousedge> I would probably override this (https://github.com/crystal-lang/crystal/blob/fd0780c3a4ef972a6090e09abc9b09a0e39345ff/src/openssl/ssl/context.cr#L238) and not `initialize`
<FromGitter> <sam0x17> looks like that one is for `Server`
<FromGitter> <tenebrousedge> it's for `Context`
<FromGitter> <tenebrousedge> so it should be used by both?
<FromGitter> <tenebrousedge> it's hard to tell
<FromGitter> <ImAHopelessDev_gitlab> @marynowac you ever get that db connection to work? if not, submit an issue
f1reflyylmao has joined #crystal-lang
<FromGitter> <wontruefree> this looks stuck https://app.circleci.com/jobs/github/crystal-lang/crystal/31067
<FromGitter> <wontruefree> can someone rerun it ?
f1refly has quit [Ping timeout: 246 seconds]
<FromGitter> <ImAHopelessDev_gitlab> can someone please explain to me consts in a way so i can understand.
<FromGitter> <tenebrousedge> constants are used for values that shouldn't change over the execution of the program. They're usually a good substitute for a global reference to something
<FromGitter> <tenebrousedge> classes are technically constants, I think
<FromGitter> <tenebrousedge> constants must exist at compile time
<FromGitter> <tenebrousedge> I'm told that constants that are values (`A = 5`) are in-lined at compile time
<FromGitter> <tenebrousedge> now if you're talking about JS consts
<FromGitter> <tenebrousedge> that's a different story
<FromGitter> <sam0x17> the reason they aren't always inlined is things like `MY_COOL_CONSTANT = Set.new{1, 2, 3}`
<FromGitter> <ImAHopelessDev_gitlab> i just don't understand when i see them used in parameters, not so much in crystal, but for example, in godot `int get_available_bytes() const`, which i don't get cause the byte amount is so different depending on what's on the socket, so does it become a "constant" that doesn't change
<FromGitter> <sam0x17> oh that's different
<FromGitter> <sam0x17> what language is that?
chemist69 has quit [Ping timeout: 250 seconds]
<FromGitter> <tenebrousedge> c++ I think
<FromGitter> <ImAHopelessDev_gitlab> gdscript, however, i see it in c++ as well. i think i can understand constants in crystal, because of what @tenebrousedge said really resonated with how i thought about them. but then @tenebrousedge mentioned "JS consts, that's a diff story". which I assume..
<FromGitter> <ImAHopelessDev_gitlab> const has diff meanings in diff languages??
<FromGitter> <tenebrousedge> yes
chemist69 has joined #crystal-lang
<FromGitter> <sam0x17> because in javascript they aren't really constants
<FromGitter> <sam0x17> you can do stuff to override it and still change the value
<FromGitter> <tenebrousedge> and most of what I said about the compiler doesn't apply
<FromGitter> <sam0x17> constants in interpreted (rather than compiled) languages are usually "fake" because there aren't compiler optimizations in place to take advantage of the fact that they are constants -- they are usually just variables with some special syntax
<FromGitter> <tenebrousedge> except in TypeScript, and we're not talking about TypeScript
<FromGitter> <sam0x17> if I do `const MY_NUM = 7;` in javacript, it creates a variable named `MY_NUM` and loads the value `7` into it when you run that line of the script. If I do the same in crystal, `MY_NUM = 7`, that will get built into the program itself so the memory address for the variable `MY_NUM` will be pre-programmed to contain `7` when the program loads
<FromGitter> <ImAHopelessDev_gitlab> @tenebrousedge thanks for the link. function in question would here (https://github.com/godotengine/godot/blob/master/core/io/stream_peer_tcp.cpp#L313) i guess
<FromGitter> <ImAHopelessDev_gitlab> > A "const function", denoted with the keyword const after a function declaration, makes it a compiler error for this class function to change a member variable of the class.
<FromGitter> <sam0x17> its a weird C++ism essentially
<FromGitter> <ImAHopelessDev_gitlab> So.. this const is NOT the same as a Crystal const
<FromGitter> <sam0x17> exactly
<FromGitter> <ImAHopelessDev_gitlab> My gosh that really threw me off
<FromGitter> <tenebrousedge> but c++ does have constants
<FromGitter> <sam0x17> yes
<FromGitter> <sam0x17> this thing is closer to in rust how things can be mutable or not mutable
<FromGitter> <sam0x17> on a method level
<FromGitter> <ImAHopelessDev_gitlab> > you are promising that the original variable (inside the function frame) will not be modified. And again, because you’re returning it by value, it’s copied so the original value could never be modified via the return value.
<FromGitter> <ImAHopelessDev_gitlab> Basically, in the get_available_bytes function, that const is making sure that bytes is NEVER modified
<FromGitter> <tenebrousedge> yes
<FromGitter> <ImAHopelessDev_gitlab> Awww O_o
<FromGitter> <ImAHopelessDev_gitlab> COOL
<FromGitter> <tenebrousedge> or any other variable part of that class
<FromGitter> <ImAHopelessDev_gitlab> That makes sense, cause those bytes read are the data, it shouldn't be touched
<FromGitter> <tenebrousedge> :plus1:
Raimondi has quit [Quit: WeeChat 2.5: ¡Chau!]
Raimondi has joined #crystal-lang
ht_ has joined #crystal-lang
<FromGitter> <sdogruyol> For anyone interested how to get Crystal accepted into your company..I wrote my story https://www.reddit.com/r/crystal_programming/comments/di7c1t/looking_to_get_a_green_light_to_use_crystal_at/f40ai9n/
<FromGitter> <bajro17> @sdogruyol thank you so much. It mean a lot for me
<FromGitter> <sdogruyol> @bajro17 anytime!
<FromGitter> <sdogruyol> Thanks for reading
ht_ has quit [Quit: ht_]
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 246 seconds]
hypercore has quit [Ping timeout: 260 seconds]
hypercore has joined #crystal-lang
hypercore has quit [Quit: hypercore]
<fifr> kinxer: I submitted an issue
gangstacat has joined #crystal-lang
absolutejam has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> @sdogruyol Nice write-up, I love your story
lvmbdv has quit [Quit: oh no they got me]
<livcd> well it's hard
<livcd> not everyone has the luxury of interacting with so few things that they can pick the bare minimum language
<FromGitter> <bajro17> I guess he just explain how he start and also way how you can show company who use ruby how easy is switch to crystal
dwdv_ has joined #crystal-lang
<FromGitter> <sdogruyol> @livcd yeah, it's hard
<FromGitter> <sdogruyol> thank you, great to hear that @ImAHopelessDev_gitlab 👍
absolutejam has quit [Ping timeout: 268 seconds]
<FromGitter> <sdogruyol> For anyone using Twitter also https://twitter.com/sdogruyol/status/1184711184580263939
<FromGitter> <sdogruyol> More interaction = more people into Crystal
blassin has quit [Ping timeout: 240 seconds]
blassin has joined #crystal-lang
absolutejam has joined #crystal-lang
context has joined #crystal-lang
<FromGitter> <zacheryph> question, why do all the web frameworks appear to treat crystal like its a scripting language
<FromGitter> <zacheryph> ie, why do all of them have deployment instructions of `install crystal, put code on server, pull deps, run tasks/compile`
<FromGitter> <zacheryph> vs using one of crystals selling points of `compile, copy binary to server, execute with config file/env vars`
<FromGitter> <absolutejam_gitlab> I think it's just the most understandable/portable workflow
<FromGitter> <absolutejam_gitlab> A bit daunting to say create a docker image, push to a private registry, template values from consul, create a Kubernetes deployment...
<FromGitter> <absolutejam_gitlab> That was a bit of an exaggerated example...
<FromGitter> <zacheryph> thats a bit overboard ;)
<FromGitter> <absolutejam_gitlab> But I agree, there should be more emphasis on statically compiling and 'here is your binary'
<FromGitter> <absolutejam_gitlab> This aint PHP
<FromGitter> <absolutejam_gitlab> we aint ftping
return0e has quit [Ping timeout: 265 seconds]
return0e has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <sdogruyol> @zacheryph @absolutejam_gitlab we're getting there :)
<FromGitter> <sdogruyol> Currently statically compiling is not so hassle-free as in Go or Rust
<FromGitter> <sdogruyol> That's why we're not emphasizing it too much
absolutejam has quit [Read error: Connection reset by peer]
absolutejam has joined #crystal-lang
<FromGitter> <zacheryph> ahh gotcha
<FromGitter> <absolutejam_gitlab> Go's is so hassle-free because the stdlin is all written in Go, right?
<FromGitter> <absolutejam_gitlab> I dunno why I always write stdlin
asterite has quit [Quit: Bye]
asterite has joined #crystal-lang
<FromGitter> <zacheryph> @sdogruyol can i ask whats *not* hassle free or is it documented somewhere
<FromGitter> <ImAHopelessDev_gitlab> GOOD LORD JSON::Serializable is amazing
<FromGitter> <ImAHopelessDev_gitlab> just mapped my entire LEVEL DATA structure baby let's get it
<FromGitter> <mavu> @zacheryph I have been wondering about the same thing. Docker here, static compile there. Its all coping mechanisms for dealing with the fragmentation of platforms. Theoretically I would prefer to have a OS'native' package for things. for example make a debian packge of your Crystal software and deploy that. ⏎ But that leaves arch users, build a package for them , then comes fedora, macos, gentooo, etc. ⏎
<FromGitter> ... Appimage is an option with a bit more easy portability.
<FromGitter> <absolutejam_gitlab> I'd always opt for Docker
<FromGitter> <mavu> maybe snap. I think Docker is way overused for jobs that would be better served with a different mechanism
<FromGitter> <absolutejam_gitlab> Why the fuck is there no :shrug: emoji in Gitter
<FromGitter> <absolutejam_gitlab> Docker alpine is fine for static compilation though
<FromGitter> <mavu> But in the end, it doesn't matter. I build debian packages because thats my target and my system.
<FromGitter> <absolutejam_gitlab> yeah, fair enough
<FromGitter> <mavu> others find docker easier (the nutters. :P)
<FromGitter> <absolutejam_gitlab> I mean, I see merit in the likes of Snap, AppImage, flatpak, etc.
<FromGitter> <absolutejam_gitlab> But they're just as fragmented at times
<FromGitter> <absolutejam_gitlab> Docker/OCI format is what I live and breath though, so I'm comfortable with it
sagax has quit [Ping timeout: 245 seconds]
<FromGitter> <mavu> I tried docker for a while, but I came to the conclusion that Docker and me just don't speak the same language. ⏎ Docker commands kept not doing what I was expecting, and things in Docker-land were not called what I would have called them etc. ⏎ That in the end was just too tedious. ⏎ But thats a matter of taste as much as anything. [https://gitter.im/crystal-lang/crystal?at=5da83c7e4afd703a4ef5d1e0]
blassin6 has joined #crystal-lang
blassin has quit [Ping timeout: 250 seconds]
absolutejam has quit [Ping timeout: 265 seconds]
absolutejam has joined #crystal-lang
sagax has joined #crystal-lang
alex``` has joined #crystal-lang
_whitelogger has joined #crystal-lang
EvilKhaosKat has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
EvilKhaosKat has quit []
EvilKhaosKat has joined #crystal-lang
<FromGitter> <sdogruyol> @zacheryph about static compilation..guess there's not :P
absolutejam has quit [Ping timeout: 240 seconds]
fifr[m] has joined #crystal-lang
fifr[m] has left #crystal-lang ["User left"]
absolutejam has joined #crystal-lang
fifr[m] has joined #crystal-lang
dwdv_ has quit [Quit: quit]
<FromGitter> <zacheryph> no issue or no document? ;)
<FromGitter> <zacheryph> @mavu yeah but there should be no reason you cannot compile and build each package, you shouldn't need to compile for each target
<FromGitter> <zacheryph> i mean... barring major glibc version discrepencies
<FromGitter> <straight-shoota> @zacheryph Regarding the original question about deployment lifecycle: I guess that at least part of this workflow is encouraged by continuous integration paradigm. When you constantly rebuild the software it's simply easier to merge build and deploy stages together. It's a matter of economics: How often do you deploy vs. how often do you build. If you don't deploy the same builds often enough, the
<FromGitter> ... complexity of separation is not worth it.
EvilKhaosKat has quit [Remote host closed the connection]
<FromGitter> <zacheryph> yeah but you are still avoiding simplicity. `clone this big repo, download crystal, download dependencies, build` vs ... `download this binary`
<FromGitter> <straight-shoota> Static building is nice, but I don't think it's the most important thing in the world. You can as easily build a dynamically-linked binary with gnu, and use the package manger to install the necessary binaries. Done. It can save a lot of effort, because besides glibc, there are also other libraries that have problems with static linking. If you control the build and deploy environments, there is no
<FromGitter> ... strong reason to use static linking at all. Dynamic works just the same. ⏎ Static linking shines when you distribute a binary without control of it's execution environment. Then users don't need to hassle with installing libraries.
<FromGitter> <zacheryph> so i really dont care a huge deal if its static/dynamic, my question was contexted in the frame of the web frameworks available today. none of them really are designed to produce usable/distributable binary artifacts in the end
<FromGitter> <Blacksmoke16> kemal/athena dont have any external deps
<FromGitter> <Blacksmoke16> i'm sure there are others as well
<FromGitter> <straight-shoota> Yeah, I figured as much and wanted to clarify, because static linking came up in the discussion.
<FromGitter> <zacheryph> ill have to download and play a little but at least what ive seen the example/docs/deployment always shows the basic clone/build
<FromGitter> <straight-shoota> `download this binary`: where do you download it from? This requires to setup and maintain an extra build stage and distribution channel.
<FromGitter> <zacheryph> depending on your project... your laptop, any of the free CI out there, internally your.. intenral CI
<FromGitter> <zacheryph> distribution channel, the `releases` tab of your github project
<FromGitter> <zacheryph> i was just wondering why it seems like the ability to distribute via single binary is avoided in the web frameworks
<FromGitter> <Blacksmoke16> im assuming you mean like, i install crystal, dev a webapp/api, then want to deploy that webapp/api as a single binary?
<FromGitter> <Blacksmoke16> w/o installing crystal on the server
<FromGitter> <straight-shoota> For frameworks it doesn't make any sense to distribute a binary, because they're just frameworks. They're only distributed as source code to build you webapp upon it. Then you build that app and deploy it.
<FromGitter> <Blacksmoke16> ^
<FromGitter> <absolutejam_gitlab> yeah, they don't work like something like hugo
<FromGitter> <zacheryph> ... i mean the project you are writing WITH the framework
<FromGitter> <absolutejam_gitlab> which you run and it spits out your artifacts
<FromGitter> <zacheryph> ie; i write an app in amber, or amethyst (defunct?) or lucky
<FromGitter> <zacheryph> and distribute my app in a binary
<FromGitter> <absolutejam_gitlab> But you mean the instructions should tell you how to an app and create a binary to be distributed
<FromGitter> <Blacksmoke16> cant speak for those 2, but its deff possible
<FromGitter> <absolutejam_gitlab> I think clarification of the build and deploy steps perhaps
<FromGitter> <absolutejam_gitlab> I definitely think there's merit to what you're saying @zacheryph
<FromGitter> <zacheryph> possible yeah, none of them seem to show that or judging from the docs, doesnt seem like it would be easy
<FromGitter> <absolutejam_gitlab> Like Phoenix provides how to do it in their docs
<FromGitter> <absolutejam_gitlab> there's docs for developing which uses all the auto-reloading magic
<FromGitter> <absolutejam_gitlab> or how to create an erlang release package for production deployment
<FromGitter> <Blacksmoke16> i know its possible for kemal, athena, and other can
<FromGitter> <absolutejam_gitlab> perhaps it's an opportunity to help with those project's docs
<FromGitter> <Blacksmoke16> depends how the framework sets things up i guess :shrug:
<FromGitter> <zacheryph> @Blacksmoke16 thnx ill check them out
<FromGitter> <straight-shoota> I guess currently there aren't many Crystal webapps available that have reached a point of maturity where you'd distribute binaries :D
<FromGitter> <Blacksmoke16> either that or most come from a more rails way of doing things?
absolutejam has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> also i think amber/lucky have dependencies on like node?
Raimondi has joined #crystal-lang
absolutejam has joined #crystal-lang
<FromGitter> <wontruefree> I cannot reproduce these errors is there a way for someone to rerun this CI test https://circleci.com/gh/crystal-lang/crystal/31067?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link
<FromGitter> <straight-shoota> @wontruefree done
alex``` has quit [Quit: The Lounge - https://thelounge.chat]
flaviodesousa has joined #crystal-lang
<FromGitter> <wontruefree> thanks :)
<FromGitter> <wontruefree> if you get a chance I would could you take a look at the PR https://github.com/crystal-lang/crystal/pull/8313
<FromGitter> <sam0x17> @wontruefree this is the alpine image I use to do static builds of pretty much anything: https://github.com/sam0x17/crystal-alpine/blob/master/Dockerfile
<FromGitter> <wontruefree> I think https://github.com/crystal-lang/crystal/pull/8313 has the potential of cleaning up some things in my branch
<FromGitter> <wontruefree> but it might be a ways out
<FromGitter> <sam0x17> sorry meant to link @zacheryph
<FromGitter> <wontruefree> thanks @sam0x17 but CI keeps failing on darwin
<FromGitter> <wontruefree> ah :)
<FromGitter> <sam0x17> similar avatar
<FromGitter> <zacheryph> @sam0x17 thanks
absolutejam has quit [Ping timeout: 268 seconds]
alexherbo2 has joined #crystal-lang
alexherbo24 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 276 seconds]
<FromGitter> <wontruefree> weird this seems to not run and it seems to fail with errors I cannot reproduce
ht__ has joined #crystal-lang
HumanGeek has quit [Ping timeout: 276 seconds]
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
<FromGitter> <abnersajr> Hello everybody. I made a question on forum: https://forum.crystal-lang.org/t/how-to-add-a-field-with-custom-method-using-json-serializable/1257 ⏎ Still waiting answers then I found the Gitter.
HumanG33k has joined #crystal-lang
<FromGitter> <abnersajr> One question about `JSON::Serializable`. How is the correct way to serialize an object value from a key? ⏎ Is it a `NamedTuple` or Creating new classes like in the question that I've made?
<FromGitter> <Blacksmoke16> was just replying to that thread
<FromGitter> <Blacksmoke16> you can do `def on_to_json(json : JSON::Builder)`
<FromGitter> <Blacksmoke16> which gets called after the obj is done being serialized, i.e. you could do `builder.field "count", @entires.uniq.size`
<FromGitter> <Blacksmoke16> which would add that on
<FromGitter> <Blacksmoke16> > How is the correct way to serialize an object value from a key? ⏎ ⏎ Do you mean based on the value of a key serialize the correct class?
<FromGitter> <Blacksmoke16> like `{"type": "dog"}` etc?
<FromGitter> <abnersajr> Looking here you see that I have another keys pointing to other "Class" that include serializable
<FromGitter> <abnersajr> Example `Entries`
<FromGitter> <abnersajr> It's working. But It's correct to do that?
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> if the types are immutable you could also use records
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7tr4 example of that `on_to_json` as well
<FromGitter> <abnersajr> Ok.
<FromGitter> <abnersajr> I did: `API::Search` `API::Serializer::Search`. Then on the initialize of `API::Search` I pass the Serializer on the `initialize`
<FromGitter> <Blacksmoke16> how do you have it setup exactly? like `load data from db => use those to new up serializer classes => render the json in the api response`?
<FromGitter> <abnersajr> Yes.
<FromGitter> <Blacksmoke16> where is the data coming from?
<FromGitter> <straight-shoota> @wontruefree restarted workflow
<FromGitter> <Blacksmoke16> oh ok so from an external API?
<FromGitter> <abnersajr> For now it's stored in a `class` variable. I'm not persisting this in a Database for now. I'm newbie on 'back-end' stuffs.
<FromGitter> <abnersajr> Yes @Blacksmoke16, I have one endpoint that retrieves the data and stores in the `@@search` variable
<FromGitter> <Blacksmoke16> gotcha, so if the data is coming from another API whats the point of wrapping that api with a new api?
<FromGitter> <Blacksmoke16> building a UI for the data or something?
<FromGitter> <abnersajr> Yes. They came limited in 200 per request. I'm wrapping up to answer all in one single shot.
<FromGitter> <Blacksmoke16> with a goal of persisting the data to a db later?
Nekka has quit [Ping timeout: 276 seconds]
<FromGitter> <abnersajr> Yes. I probably will do that.
<FromGitter> <Blacksmoke16> im personally not a fan of having separate classes for just serializing a class
<FromGitter> <Blacksmoke16> but until then, loading data from the api into the classes is fine
Nekka has joined #crystal-lang
<FromGitter> <Blacksmoke16> maybe look into converting the serializer classes into ORM models
<FromGitter> <abnersajr> So, I'm new on Crystal and know a little bit of Rails that is used i n our company. But In rails you can have something Like that: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da8a5252d59854e7f1e0d66]
rohitpaulk has joined #crystal-lang
<FromGitter> <abnersajr> @Blacksmoke16 but this `on_to_json` probably will help me.
<FromGitter> <abnersajr> Thanks for your patient.
<FromGitter> <abnersajr> 👍
<FromGitter> <Blacksmoke16> i cant speak for how other ORMs work, but https://github.com/amberframework/granite/ uses properties for its columns
<FromGitter> <Blacksmoke16> which would work with `JSON::Serializable`
<FromGitter> <abnersajr> I didn't find `#on_to_json` on the API doc :(
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da8a5c3809de9699f553af3]
<FromGitter> <Blacksmoke16> as an example
<FromGitter> <Blacksmoke16> yea its not documented atm :/
<FromGitter> <abnersajr> And inthis scenario how I can add a column based in a method?
<FromGitter> <Blacksmoke16> could still use `on_to_json`
<FromGitter> <abnersajr> Oh cool.
<FromGitter> <Blacksmoke16> iv'e also been working on a serialization shard that might be helpful, however its still a WIP
<FromGitter> <Blacksmoke16> (things changed a bit and didnt update the docs yet) here (https://github.com/Blacksmoke16/CrSerializer/blob/refactor/spec/models/virtual_property.cr) and here (https://github.com/Blacksmoke16/CrSerializer/blob/refactor/spec/models/name.cr) would be more up to date
Raimondi has joined #crystal-lang
<FromGitter> <abnersajr> How I would define one default value for this array of entries.
<FromGitter> <abnersajr> The empty value ok. But if I would like to define one default Array with 2 entries for example
<FromGitter> <Blacksmoke16> `property entries : Array(Entries) = [Entries.new, Entries.new]`?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7tsa
<FromGitter> <Blacksmoke16> obs the objects are going to be empty since they have no values but you get the idea
<FromGitter> <wontruefree> @straight-shoota I dont know if you have time but I dont understand why that is failing. And I cannot reproduce it. Do you know what is going on?
<FromGitter> <abnersajr> @Blacksmoke16 this is supposed to work API::Entries.from_json(%({"name": "Abner", "date": 0}))
<FromGitter> <bew> @abnersajr this should work already isn't it?
<FromGitter> <abnersajr> @bew https://play.crystal-lang.org/#/r/7ttb
<FromGitter> <Blacksmoke16> whoa, uh
<FromGitter> <Blacksmoke16> thats prob a bug
<FromGitter> <bew> nice compiler bug ^^ playground is pretty broken with that one :P
<FromGitter> <bew> (visually)
<FromGitter> <abnersajr> I have something equal
<FromGitter> <kinxer> @abnersajr Why are you trying to deserialize json instead of just having default instances?
<FromGitter> <abnersajr> the only difference is that I don't have the new method
<FromGitter> <Blacksmoke16> just define one?
<FromGitter> <Blacksmoke16> since both properties on `DelveDepth` have defaults you just have to add `def initialize; end` then can do `DelveDepth.new`
<FromGitter> <abnersajr> But this one in my project is working
<FromGitter> <marynowac> I'm back again. I haven't solved my issue with connection to postgres. ⏎ Just to remind you: ⏎ ⏎ A standard piece of code: ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5da8af6c809de9699f5587d8]
<FromGitter> <Blacksmoke16> its not within an array
<FromGitter> <Blacksmoke16> thats prob the problem
<FromGitter> <abnersajr> I tried either. Without array too.
<FromGitter> <Blacksmoke16> for now you could also do ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da8afa91e314c0467278dce]
<FromGitter> <Blacksmoke16> @marynowac looks like the pg lib doesnt support clear text
<FromGitter> <bew> @marynowac which shard are you using to connect to pg ?
<FromGitter> <Blacksmoke16> but im pretty sure thats how granite works, prob is something else going on
<FromGitter> <Blacksmoke16> for how it does specs at least
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
dostoyevsky has quit [Remote host closed the connection]
<FromGitter> <kinxer> The best I could do in terms of a minimal case: https://play.crystal-lang.org/#/r/7tus
dostoyevsky has joined #crystal-lang
<FromGitter> <abnersajr> @kinxer this don't work on the playground at least with 0.31.1
<FromGitter> <bew> @bcardiff the new install pages are pretty!! Just a note, on the archlinux install page (I only looked at that one) https://crystal-lang.org/install/on_arch_linux/ it looks like the Snapcraft install section is mandatory to have crystal.. I think it would be better to say `Install using pacman` for normal install, and `Install using snapcraft` for the snapcraft install, wdyt?
<FromGitter> <Blacksmoke16> snap should have its own section
<FromGitter> <Blacksmoke16> it can be used to install crystal on most of those OS
<FromGitter> <bew> Looking at the debian install page, it's not clear as well that snapcraft/linuxbrew is not mandatory (https://crystal-lang.org/install/on_debian/)
<FromGitter> <bew> yes that's a good idea too @Blacksmoke16
<FromGitter> <bew> and maybe something elso for linuxbrew which works on many distro similarly to snapcraft
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/oq/issues/38 kind related
<FromGitter> <kinxer> Works on 0.27.0: https://play.crystal-lang.org/#/r/7tv1 ⏎ Doesn't work on 0.27.1: https://play.crystal-lang.org/#/r/7tv2
absolutejam has joined #crystal-lang
<FromGitter> <straight-shoota> @wontruefree Sorry no idea. Seems to be totally unrelated
<FromGitter> <straight-shoota> I can give you ssh access if that would help to figure this out on the CI machine
<FromGitter> <marynowac> @bew will/crystal-pg
<FromGitter> <bcardiff> @Blacksmoke16 @bew thanks for the feedback. The intention is for the user to pick the distro that is been used and list there the available options. Some distros users might not know the existante of snapcraft for example and that might be the only option currently. ⏎ ⏎ Changes the phrase and sections for better clarification is definitely double. ⏎ ⏎ We can iterate in the forum & crystal-website
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <absolutejam_gitlab> Is there any kind of issue open for providing a standardised docblock format?
<FromGitter> <absolutejam_gitlab> I'm searching through 'em now but can't see something that covers my point
<FromGitter> <Blacksmoke16> @kinxer ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da8b55765dd8569a0f4a2e5]
<FromGitter> <Blacksmoke16> is first bit of the trace if you wanted to include that
<FromGitter> <Blacksmoke16> like how to structure your comments on methods and stuff?
<FromGitter> <absolutejam_gitlab> Yeah
<FromGitter> <Blacksmoke16> not that i know of, is up to each shard
<FromGitter> <absolutejam_gitlab> The likes of Python and PHP have standardised comments
<FromGitter> <absolutejam_gitlab> documenting parameter types etc.
<FromGitter> <Blacksmoke16> crystal handles that for you tho
<FromGitter> <absolutejam_gitlab> while types aren't necessary for Crystal, it'd be nice to have a standard format for supplying context
<FromGitter> <absolutejam_gitlab> Or return types, or what exceptions are raised
<FromGitter> <Blacksmoke16> also handles that
<FromGitter> <absolutejam_gitlab> types was the worst example I could have started with
<FromGitter> <Blacksmoke16> the former at least
<FromGitter> <Blacksmoke16> :P
<FromGitter> <Blacksmoke16> was thinking of a like `RAISES: ArgumentError When *other* is less than 0`
<FromGitter> <Blacksmoke16> could be handy
<FromGitter> <Blacksmoke16> `Foo.Bar.baz/2` whats this do?
<FromGitter> <Blacksmoke16> what is `2`?
<FromGitter> <absolutejam_gitlab> In Elixir, you refer to the function definition by its arity
<FromGitter> <absolutejam_gitlab> `Foo.Bar.baz/0` and `Foo.Bar.baz/1` are distinct
<FromGitter> <Blacksmoke16> ah so to link to a specific overload?
<FromGitter> <absolutejam_gitlab> Yeah
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <Blacksmoke16> id clarify that in your comment
<FromGitter> <absolutejam_gitlab> and you can actually have multiple variants of `/1` because of guard clauses
<FromGitter> <absolutejam_gitlab> eg `def foo(items) when is_list(items) do`
<FromGitter> <naqvis> how can we pass `Pointer(Pointer(UInt8))` to C code from crystal? I'm working on crystal binding and in C there is `[in,out]` param and i'm passing `Slice#to_unsafe`, but i'm getting error `must pass Pointer(Pointer(UInt8)), not Pointer(UInt8)`, i found that doing `pointerof` on `unsafe` is not working.
<FromGitter> <kinxer> I've never opened an issue before... Well, here goes.
<FromGitter> <bew> @absolutejam_gitlab how do you refer to each variant then?
<FromGitter> <absolutejam_gitlab> You can't in that case
<FromGitter> <absolutejam_gitlab> That's the only shortcoming
<FromGitter> <bew> i see
<FromGitter> <Blacksmoke16> `Pointer(UInt8)*`?
<FromGitter> <naqvis> thanks @Blacksmoke16 , let me check that
<FromGitter> <Blacksmoke16> er no
<FromGitter> <Blacksmoke16> that would be the type, but not how to do it
<FromGitter> <bew> can you link to a documentation @naqvis ?
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <naqvis> in C it is `next_out : Uint8T**`
<FromGitter> <bew> and your crystal type is what?
<FromGitter> <naqvis> crystal type is `Slice`
<FromGitter> <bew> ah i see
<FromGitter> <bew> make a var of the to_unsafe, then do a pointerof on it
alexherbo24 has quit [Ping timeout: 276 seconds]
alexherbo245 has joined #crystal-lang
<FromGitter> <bew> like: ⏎ ⏎ ```var = my_slice.to_unsafe ⏎ C.my_func(pointerof(var))``` [https://gitter.im/crystal-lang/crystal?at=5da8b79739e2ef28adfd0759]
<FromGitter> <naqvis> you made my day, thank you @bew
<FromGitter> <naqvis> 👏
<FromGitter> <bew> is *should* work since `Slice#to_unsafe` returns the memory of slice directly without make new intermediate objects
<FromGitter> <bew> :)
<FromGitter> <naqvis> thank you again
<FromGitter> <bew> you're welcome
<FromGitter> <bew> what lib is it?
<FromGitter> <naqvis> Brotli
<FromGitter> <naqvis> https://github.com/google/brotli
<FromGitter> <bew> 👏 that's interesting
<FromGitter> <naqvis> yeah, thought of doing Crystal binding, as I couldn't find one
alexherbo245 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <bew> do you have a need for this compression format?
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
<FromGitter> <naqvis> yeah, for some toy project
<FromGitter> <naqvis> as this is supported by majority of browsers, so thought of playing around instead of gzip
<FromGitter> <kinxer> @Blacksmoke16 @abnersajr https://github.com/crystal-lang/crystal/issues/8343
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <marynowac> @bew @Blacksmoke16 ⏎ i use standard shard from will/crystal-pg
EvilKhaosKat has joined #crystal-lang
<FromGitter> <bew> @marynowac I don't know enough of pg nor crystal-pg to give proper help here, I'd suggest to wait some time for someone who can help you better, then if no one comes, post an issue on crystal-pg repo
EvilKhaosKat has quit [Quit: Leaving]
lvmbdv has joined #crystal-lang
EvilKhaosKat has joined #crystal-lang
<FromGitter> <kinxer> @Blacksmoke16 It was already reported... Ah, well. Maybe one day I'll make a useful contribution to Crystal.
EvilKhaosKat has quit [Quit: This computer has gone to sleep]
<FromGitter> <Blacksmoke16> :p
<FromGitter> <straight-shoota> @marynowac what's your issue?
<FromGitter> <Blacksmoke16> ☝️ October 17, 2019 2:14 PM (https://gitter.im/crystal-lang/crystal?at=5da8af6c809de9699f5587d8)
<FromGitter> <marynowac> @straight-shoota i cannot connect to pg database. got an exception "(DB::ConnectionRefused), caused by: *Cleartext auth* is not supported"
<FromGitter> <ImAHopelessDev_gitlab> @marynowac is basically trying to connect to his postgres db using ⏎ ⏎ ```DB.open "postgres://myuser:mypasswd@remoteserver/mydb" do |db| ⏎ # code ⏎ end``` ⏎ ⏎ He receives an exception: ... [https://gitter.im/crystal-lang/crystal?at=5da8c50fdbf6766734793983]
<FromGitter> <marynowac> that's not my postgres. i have no power to change config there :-[
<FromGitter> <Blacksmoke16> did you try the other form of auth?
<FromGitter> <Blacksmoke16> it might support that but not cleartext
<FromGitter> <marynowac> how to force other form of auth using crystal?
<FromGitter> <straight-shoota> It's just as it says. `crystal-pg` doesn't support cleartext password authentication.
<FromGitter> <absolutejam_gitlab> can you re-open a class and add it yourself?
<FromGitter> <straight-shoota> There is no config for this. It's not implemented and that seems to be on purpose.
<FromGitter> <marynowac> so what can i do to get access to that database? change to php/python?
<FromGitter> <absolutejam_gitlab> Do you really wanna send cleartext credentials?
<FromGitter> <Blacksmoke16> try using MD5 vs cleartext
<FromGitter> <Blacksmoke16> i dont have example of how to do that but that might work
<FromGitter> <marynowac> how to do that?
<FromGitter> <straight-shoota> @Blacksmoke16 The server asks for cleartext password and the Crystal client can't produce that.
<FromGitter> <straight-shoota> @absolutejam_gitlab If the connection is encrypted, sending cleartext password should be save actually.
<FromGitter> <Blacksmoke16> but im pretty sure thats how granite does its specs, wouldnt that also fail?
<FromGitter> <absolutejam_twitter> Oh makes sense, I didn't think about that 😁
<FromGitter> <absolutejam_twitter> Man I really wanna play with Amber
alexherbo2 has joined #crystal-lang
<FromGitter> <straight-shoota> @Blacksmoke16 It really just depends on the server, which authentication method it asks for. It's typically MD5.
<FromGitter> <Blacksmoke16> ohh i think i see the issue, MD5 and cleartext use the same connection string, but the issue is how those creds are validated on the server
<FromGitter> <Blacksmoke16> not how you provide them
<FromGitter> <Blacksmoke16> @marynowac see if the server can be updated to support MD5?
<FromGitter> <marynowac> i don't have any power to change server cofiguration
<FromGitter> <straight-shoota> @Blacksmoke16 Exactly.
<FromGitter> <Blacksmoke16> see if the owner can change it?
<FromGitter> <ImAHopelessDev_gitlab> @marynowac who is your provider
<FromGitter> <Blacksmoke16> otherwise would have to what, monkeypactch that back in i guess?
<FromGitter> <straight-shoota> @marynowac You might be able to monkeypatch cleartext authentication into crystal-pg
<FromGitter> <marynowac> how to do that?
<FromGitter> <absolutejam_gitlab> Can we at least give it a better name in Crystal?
<FromGitter> <straight-shoota> I'd guess it's probably really simple. Like ⏎ ⏎ ```class PG::Connection ⏎ private def handle_auth(auth_frame) ⏎ case auth_frame.frame``` [https://gitter.im/crystal-lang/crystal?at=5da8c98c57c2517c6a27876e]
<FromGitter> <absolutejam_gitlab> monkey-patching is what makes people shudder when they think about Ruby
<FromGitter> <straight-shoota> I'd guess it's probably really simple. Like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da8c9cb8e2e9a7c6b16dd54]
<FromGitter> <kinxer> @absolutejam_gitlab It's the same thing, though, isn't it? It should make people shudder, because it's a last-resort solution.
<FromGitter> <straight-shoota> @absolutejam_gitlab ⏎ ⏎ > Can we at least give it a better name in Crystal? ⏎ Better name for what? [https://gitter.im/crystal-lang/crystal?at=5da8ca02c87a1d28acc9f722]
Yxhuvud has quit [Remote host closed the connection]
<FromGitter> <marynowac> @straight-shoota i try it tomorrow. don't have access to that server now. thanks a lot.
<FromGitter> <straight-shoota> after sending to the socket, there needs to be a receive. Probably just `expect_frame Frame::Authentication`
<FromGitter> <absolutejam_gitlab> yeah I guess haha
<FromGitter> <straight-shoota> You could also look through the version history of crystal-pg, it was implemented once
<FromGitter> <absolutejam_gitlab> But give it a good name and we get away with it
<FromGitter> <absolutejam_gitlab> woah, Crystal doesn't have monkey-patching, it has crystalline extension
<FromGitter> <tenebrousedge> hot-patching
<FromGitter> <tenebrousedge> or just "open-class extension"
<FromGitter> <absolutejam_gitlab> I was being facetious, but I like that
<FromGitter> <straight-shoota> I guess it's just an easier-to-maintain alternative to adding custom patches to upstream libraries.
<FromGitter> <kinxer> @absolutejam_gitlab Any chance to use the word "crystalline" is great, but I'd still prefer to have a term with a negative connotation. :P
<FromGitter> <kinxer> @absolutejam_gitlab Also, does Crystal give you a lot of opportunities to be *facet*ious?
<FromGitter> <marynowac> thx @straight-shoota , @ImAHopelessDev_gitlab
Yxhuvud has joined #crystal-lang
teardown has quit [Read error: Connection reset by peer]
teardown has joined #crystal-lang
teardown has quit [Read error: Connection reset by peer]
teardown has joined #crystal-lang
ht__ has quit [Quit: ht__]
teardown has quit [Read error: Connection reset by peer]
teardown has joined #crystal-lang
teardown has quit [Read error: Connection reset by peer]
teardown has joined #crystal-lang
<FromGitter> <bew> Would be interesting to make this benchmark https://medium.com/sean3z/rest-api-node-vs-rust-c75aa8c96343 using latest crystal (mt)
<FromGitter> <ImAHopelessDev_gitlab> `&'` wtf kind of syntax is this
<FromGitter> <bew> where did you see that?
<FromGitter> <ImAHopelessDev_gitlab> looks like the brainf*ck language lol
<FromGitter> <kinxer> Yeah, it's not the prettiest, but I like Rust from what I've seen of it so far.
<FromGitter> <bew> ah yes in rust, `&'a` represents the lifetime of the variable `s` iirc
<FromGitter> <bew> hmm more like `'a` only
<FromGitter> <kinxer> I think `&` marks it as an immutable reference.
<FromGitter> <kinxer> Or at least a reference.
<FromGitter> <bew> yes, and references are immutable by default so yes
<FromGitter> <ImAHopelessDev_gitlab> looking at this code, i think the concrete truck just arrived. it just delivered 10 gallons of wet concrete and poured it around my feet, solidifying my use for crystal even more
<FromGitter> <bew> ahah rust is awesome though, it's my next lang to learn when-i-have-time
<FromGitter> <kinxer> @ImAHopelessDev_gitlab Crystal is much easier to write, but there some definite benefits to using Rust, depending on your application.
<FromGitter> <kinxer> Yeah, I'm still (slowly) making my way through their intro book, but they won me over with `enums` that can have struct-like values and methods.
<FromGitter> <bew> yeah they are pretty nices! it's possible to do in crystal but not as easily as in rust
<FromGitter> <kinxer> It seems like a great language to replace processing-intensive C and C++ with.
<FromGitter> <kinxer> (Or really *any* C or C++...)
<FromGitter> <ImAHopelessDev_gitlab> i dabbled in nim-lang. participated on their forums, received good help. they have a good/nice community like crystal.
<FromGitter> <ImAHopelessDev_gitlab> have not tried rust, but maybe later down the road
<oprypin> `let mut` 👿
<FromGitter> <kinxer> @oprypin Lol.
<FromGitter> <ImAHopelessDev_gitlab> however, i can think of game ideas / implementations of features, and my mind will subconsciously process those ideas out into crystal code. i can't do this with other languages at the moment, so i'm sticking with crystal. going to be using crystal for a long time. there is no turning back
<FromGitter> <kinxer> @ImAHopelessDev_gitlab As I mentioned, it *is* harder to write than Crystal. I've seen people complaining about wrestling with Crystal's type system, which I don't really experience myself, but I had some serious difficulty trying to wrap my mind around Rust's ownership system when writing up a simple toy genetic algorithm problem.
<FromGitter> <kinxer> And I'm still trying to understand Traits, which are *kind of* like Crystal's modules. There's no inheritance at all in Rust, though, so you have to do everything with traits, generics, and composition.
<FromGitter> <ImAHopelessDev_gitlab> Yeah, if you are having difficult, imagine me trying to understand 😆
<FromGitter> <kinxer> It's just your background. You don't have a formal computer science education (which is, of course, perfectly fine) and you started in PHP, so your ideas about programming have been formed from your programming experiences, which are almost all (I think) in PHP, Crystal, and GDScript.
<FromGitter> <ImAHopelessDev_gitlab> Yep, and JS! LOL
<FromGitter> <ImAHopelessDev_gitlab> I've transcended to Crystal, I think I hit peak :)
<FromGitter> <kinxer> It's definitely much nicer to work with than anything I've worked with previously.
<FromGitter> <ilanpillemer> Can only classes inherit?
<FromGitter> <ilanpillemer> There is no peak
<FromGitter> <ilanpillemer> Beware of the Blub Paradox
<FromGitter> <ilanpillemer> Go uses structural typing, which is also unusual
<FromGitter> <ilanpillemer> I tried to use inheritance with structs and its just complaining
<FromGitter> <kinxer> @ilanpillemer The Blub Paradox (https://en.wikipedia.org/wiki/Paul_Graham_(programmer)#The_Blub_paradox) is interesting (and a good word of caution about thinking we know more than we do). Thanks for sharing.
<FromGitter> <ilanpillemer> Yes. Its one of the easiest traps to fall into.
<FromGitter> <ilanpillemer> when out hunting heffalumps, beware the Blub Paradox.
<FromGitter> <kinxer> It's right up there with trying to use Markdown custom links with a URL that has closing parentheses in it.
<FromGitter> <kinxer> My constant bane on Gitter.
<FromGitter> <ImAHopelessDev_gitlab> @kinxer I actually raged kinda hard when the breaking-changes happened with division operator and stuff. That's when I looked into nim, cause my goodness their syntax is amazing (imo). However, I quickly realized it would take AGES to convert my entire master and game server files over. Plus, I feel like I would betray all the people who played a role in helping me to get to where I'm at with
<FromGitter> ... Crystal. And most importantly, game features and ideas can flow into Crystal code when I want it to, I can't do that with other languages (not as versed). ⏎ ⏎ So I accepted straight-shoota's advice and tucked my tail in and adapted. All I had to do was change `/` to `//` about 50 times across several files, but that's a t ... [https://gitter.im/crystal-lang/crystal?at=5da8e5f2809de9699f570382]
<FromGitter> <ilanpillemer> 🐰
<FromGitter> <kinxer> > The entire programming world *doesn't revolve around my codebase and practices*, so I should learn to adapt. That's my take on it anyway.
<FromGitter> <ilanpillemer> @ImAHopelessDev_gitlab its a online change with sed
<FromGitter> <ilanpillemer> learn sed and grep
<FromGitter> <kinxer> ^
<FromGitter> <kinxer> If you're feeling adventurous, learn `awk`, too. But only if you're feeling adventurous.
<FromGitter> <ilanpillemer> awk is very useful
<FromGitter> <ilanpillemer> I use it most days
<FromGitter> <ilanpillemer> I learnt about pgrep today
<FromGitter> <ilanpillemer> so useful
<FromGitter> <kinxer> I don't use `awk` very often, but I learned it a few weeks ago for a filtering thing I needed at work.
<FromGitter> <bew> there's pkill too :) @ilanpillemer
<FromGitter> <kinxer> Oh, that does look useful.
<FromGitter> <tenebrousedge> `ag` > `grep`
<FromGitter> <bew> @ImAHopelessDev_gitlab are you really girng? this is really someone else I'm reading, I'm glad you climbed that step :D
<FromGitter> <kinxer> @ImAHopelessDev_gitlab If you look into any of these things, you'd be using them on WSL (since I think you work on Windows primarily?).
<FromGitter> <bew> `rg` > `ag` :D
<FromGitter> <ilanpillemer> is `pkill acme-lip` the same as `kill `pgrep acme-lsp`?
<FromGitter> <bew> yes
<FromGitter> <ilanpillemer> nice
<FromGitter> <ilanpillemer> what does it do if the process does not exist?
<FromGitter> <bew> nothing, exit with error code 1
<FromGitter> <tenebrousedge> @bew I don't know if I want my grepper to use `.gitignore`
<FromGitter> <bew> ag doesn't ?
<FromGitter> <ilanpillemer> so I could simplify the top two lines?
<FromGitter> <tenebrousedge> ...it does o___o
<FromGitter> <bew> @tenebrousedge x)
<FromGitter> <tenebrousedge> welp, looks like I need to switch to `rg`
<FromGitter> <tenebrousedge> what else does that get me?
<FromGitter> <ilanpillemer> what is rg?
<FromGitter> <bew> ripgrep
<FromGitter> <tenebrousedge> https://github.com/BurntSushi/ripgrep
<FromGitter> <ilanpillemer> I thought I had evolved when I started using egrep
<FromGitter> <ilanpillemer> I guess structs dont inherit?
<FromGitter> <bew> you can only inherit fgrom abstract struct
<FromGitter> <ilanpillemer> Why?
absolutejam has quit [Ping timeout: 240 seconds]
<FromGitter> <ilanpillemer> ooh.. playing with the pattern matching in the case statements.
<FromGitter> <ilanpillemer> nice
<FromGitter> <ilanpillemer> So its to do with how array are implemented
<FromGitter> <bew> more info
<FromGitter> <bew> @ilanpillemer for pgrep and pkill, note that if you have 2 running processes `ab1` and `ab2`, `pgrep ab` will match both and `pkill ab` will kill both
<FromGitter> <bew> this happened to me a lot of time with hanging ssh sessions, and I do `pkill ssh` and it also kills my `ssh-agent` ><
<FromGitter> <ilanpillemer> lol
<FromGitter> <bew> you can use `-x` / `--exact` for an exact match though
<FromGitter> <bew> _I'm going to make an alias immediatelyç
<FromGitter> <absolutejam_twitter> Rg is amazingly fast
<FromGitter> <ilanpillemer> like `wget -c`
<FromGitter> <absolutejam_twitter> And I spent a day learning awk and it's my go to tool for a lot of things now
<FromGitter> <ilanpillemer> and `emacs -nw`
<FromGitter> <absolutejam_twitter> Don't start a holy war
<FromGitter> <ilanpillemer> emacs and vim are the same thing really.
alexherbo2 has quit [Ping timeout: 240 seconds]
<FromGitter> <absolutejam_twitter> You going to get hate from both sides now
<FromGitter> <ilanpillemer> I tried to learn vim, but my emacs muscle memory made it impossible. I use acme mainly now
<FromGitter> <absolutejam_twitter> Id love to try emacs again but I've become supper accustomed to kakounes modal style that I feel like I'd have to unlearn loads
<FromGitter> <absolutejam_twitter> And I can't deal with emacs key combos
<FromGitter> <ilanpillemer> acme is amazing
<FromGitter> <ilanpillemer> both vim and emacs have need them. And you end up littering your code with stange things and accidently doing incorrect things.
<FromGitter> <bew> I watched the intro to acme, but it looks like the mouse is used for way too many things
<FromGitter> <ilanpillemer> you need a 3 button mouse
<FromGitter> <absolutejam_twitter> I'm happy with Kakoune
<FromGitter> <ilanpillemer> I use the contour mouse
<FromGitter> <bew> yeah, touchpad on laptops are no good
<FromGitter> <absolutejam_twitter> It's hipster but it works really well for what I need
<FromGitter> <ilanpillemer> yeah then emacs or vim probably is best
<FromGitter> <ilanpillemer> I guess touchpad works well with menu driven IDEs too
<FromGitter> <absolutejam_twitter> I'm the opposite, I try and use my mouse as little as possible
<FromGitter> <ilanpillemer> I have had a strange journey withj acme
<FromGitter> <absolutejam_twitter> Tmux, kakoune and when I was on Linux, bspsm as my window manager
<FromGitter> <bew> well now that I'm married to my nvim config, I can't stand having to aim a button with a mouse ^^
<FromGitter> <ilanpillemer> yeah. I was the same for many years
<FromGitter> <ilanpillemer> but acme mouse use is different
<FromGitter> <ilanpillemer> as a game I forced myself to use acme for a month
<FromGitter> <absolutejam_twitter> I'm genuinely interested in this conversation but just realised I have to be up in 3 hours to do a rabbitmq reboot
<FromGitter> <bew> arf, script it!
<FromGitter> <ilanpillemer> then I stopped and went to emacs, then intelliji, then emacs, then visual code, then intellij, then emacs and now acme.
<FromGitter> <absolutejam_twitter> Not being ignorant
<FromGitter> <Blacksmoke16> you can sleep when you're dead :S
<FromGitter> <ilanpillemer> and I tried vim for a week
<FromGitter> <absolutejam_twitter> Bit more than just a reboot
<FromGitter> <absolutejam_twitter> I've got 2 kids, if I don't sleep, I will be dead
<FromGitter> <Blacksmoke16> xD
<FromGitter> <absolutejam_twitter> Laters
<FromGitter> <bew> see ya
<FromGitter> <ilanpillemer> and now emacs only in the terminal as it hangs to much
<FromGitter> <ilanpillemer> but now that I have learnt how to extend acme. I am sold.
<FromGitter> <ilanpillemer> why is that pink?
<FromGitter> <bew> Oo?
<FromGitter> <ilanpillemer> hmm.. seems it meant that message didnt send.
<FromGitter> <ilanpillemer> I reloaded and it disappeared.. maybe gitter has an editor war detector and prevents certain messages displaying.
<FromGitter> <bew> ahahah
<FromGitter> <bew> let's try it
<FromGitter> <bew> vim > emacs
<FromGitter> <bew> nop!
<FromGitter> <tenebrousedge> spacevim ❤️
<FromGitter> <ilanpillemer> Emacs > vim
<FromGitter> <ilanpillemer> seemed to work
<FromGitter> <bew> neovim > emacs then
<FromGitter> <ilanpillemer> Is there a better way of writing this
<FromGitter> <ilanpillemer> ```grid = Array.new(8, Array.new(8, 0))```
<FromGitter> <bew> first of all, I think it's wrong
<FromGitter> <ilanpillemer> it compiles
<FromGitter> <bew> since you're assingning the same array
<FromGitter> <bew> try to use it and display the content, you'll see
<FromGitter> <bew> Do like that: `grid = Array.new(8) { Array.new(8, 0) }`
<FromGitter> <ilanpillemer> yes, its very wrong
<FromGitter> <ilanpillemer> I just tried to use it
<FromGitter> <tenebrousedge> ??
<FromGitter> <bew> do you understand why?
<FromGitter> <tenebrousedge> I feel like I've done that in the past without issues
<FromGitter> <ilanpillemer> no I dont understand why
<FromGitter> <bew> it's like: ⏎ ⏎ ```default = Array.new(8, 0) ⏎ grid = Array.new(8, default)``` [https://gitter.im/crystal-lang/crystal?at=5da8f326870fa33a4d0f3af1]
<FromGitter> <ilanpillemer> yeah I have 8 arrays of 8 arrays
<FromGitter> <bew> meaning that each element of grid will be *the same* `default`
<FromGitter> <ilanpillemer> well I didnt see that
<FromGitter> <ilanpillemer> let me change one value and see if explodes
<FromGitter> <tenebrousedge> it does asplode
<FromGitter> <tenebrousedge> I wonder if I have a copy of that code...
<FromGitter> <bew> it's demonstrated in the docs https://crystal-lang.org/api/0.31.1/Array.html#new(size:Int,value:T)-class-method
<FromGitter> <bew> and the version with a block is https://crystal-lang.org/api/0.31.1/Array.html#new(size:Int,&block:Int32->T)-class-method
<FromGitter> <ilanpillemer> omw
<FromGitter> <ilanpillemer> its a virus
<FromGitter> <ImAHopelessDev_gitlab> #AllAMatrixArraysMatter
<FromGitter> <ilanpillemer> I wonder if you could something like this
<FromGitter> <ImAHopelessDev_gitlab> O_o
<FromGitter> <ilanpillemer> but that is weird behaviour
<FromGitter> <ImAHopelessDev_gitlab> "yaml-bomb" LOL
<FromGitter> <ImAHopelessDev_gitlab> You naughty dev
<FromGitter> <ilanpillemer> why is the second Array an alias of the first?
<FromGitter> <ilanpillemer> its all over the news
<FromGitter> <bew> why is that?
<FromGitter> <ilanpillemer> its a current defect in kubernetes being patched today
<FromGitter> <ImAHopelessDev_gitlab> Oh
<FromGitter> <ilanpillemer> if you try an set that config map it goes into a death spiral
<FromGitter> <ImAHopelessDev_gitlab> https://en.wikipedia.org/wiki/Billion_laughs_attack I've never heard of this before, lol. I've heard of "fork bombs" but not "billion laughs attack"
<FromGitter> <ilanpillemer> but why is the second array and reference of the first
<FromGitter> <bew> what do you mean 'why' ?
<FromGitter> <ilanpillemer> `Creates a new Array of the given size filled with the same value in each position.`
<FromGitter> <ilanpillemer> and so if that value is a pointer
<FromGitter> <ilanpillemer> and an array is a pointer
<FromGitter> <ilanpillemer> you get the same reference 8 times?
<FromGitter> <bew> for crystal yes, for other not necessarily
<FromGitter> <bew> i guess
<FromGitter> <ilanpillemer> yes. in other languages I think you normally do things like `[][]int`
<FromGitter> <ilanpillemer> [8][8]int
<FromGitter> <ilanpillemer> @tenebrousedge better go check your code for bugs
<FromGitter> <ilanpillemer> 😂
<FromGitter> <ImAHopelessDev_gitlab> ```default = Array.new(8, 0) ⏎ grid = Array.new(8, default)``` ⏎ ⏎ Wait, so this isn't doing what I think it's doing? [https://gitter.im/crystal-lang/crystal?at=5da8f5bf8e2e9a7c6b181431]
<FromGitter> <Blacksmoke16> @nsuchy @didactic-drunk and others, https://github.com/Blacksmoke16/crylog/tree/v0.1.4/docs#cryloglogger released a new `Crylog` version that allows it to be used within the stdlib's `::Logger` class
<FromGitter> <ilanpillemer> ```grid = Array.new(8, Array.new(8, 0))```
<FromGitter> <ilanpillemer> its obvious with the top one
<FromGitter> <ilanpillemer> but when you do it this way, its not so obvious
<FromGitter> <ilanpillemer> ok. I understand now.
<FromGitter> <bew> (:
<FromGitter> <ilanpillemer> maybe docs should call it out more explicitly
<FromGitter> <ilanpillemer> C does it differently to Go that does it differently to Java that does it differently to Crystal 🙈
<FromGitter> <ilanpillemer> array are tricky
<FromGitter> <bew> let's all kill your browsers! https://carc.in/#/r/7txd 😇
<FromGitter> <ilanpillemer> `grid = Array.new(8) { Array.new(8, 0) }`
<FromGitter> <ilanpillemer> this seems to explode too
<FromGitter> <bew> shouldn't
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da8f80e80e62056e4227f4e]
<FromGitter> <ilanpillemer> ok
<FromGitter> <ilanpillemer> I am just tired
<FromGitter> <ilanpillemer> ino
<FromGitter> <ilanpillemer> no
<FromGitter> <ilanpillemer> it is wrong I think
<FromGitter> <ilanpillemer> am I tired and brain dead or is it wrong?
<FromGitter> <bew> full program?
<FromGitter> <ilanpillemer> that is the full program
<FromGitter> <bew> where d you print the `[` `]` `,` ` `
<FromGitter> <ilanpillemer> I think I am doing something silly now
<FromGitter> <ilanpillemer> I dont
<FromGitter> <ilanpillemer> the x and the y I guess are arrays?
<FromGitter> <bew> ah
<FromGitter> <bew> yes
<FromGitter> <ilanpillemer> I am not doing something right
<FromGitter> <bew> y is array
<FromGitter> <bew> yes
<FromGitter> <bew> it's definitely wrong :P
<FromGitter> <ilanpillemer> Yes.. so I am not getting an 8 by 8 array. I am getting lots of arrays.. and somehow setting the value to 1 is doing weird things too
<FromGitter> <bew> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da8f9c539d0c70757caafc3]
<FromGitter> <ilanpillemer> seems like 16 arrays by 8 arrays
<FromGitter> <bew> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da8f9ea65dd8569a0f68a4a]
<FromGitter> <bew> you'll read it tomorrow and you'll see your mistake :p
<FromGitter> <ilanpillemer> aha
<FromGitter> <ilanpillemer> the doube gris
<FromGitter> <ilanpillemer> 🤪
<FromGitter> <bew> I'm tired too, I saw your code, knew somethign was off but couldn't point it immediately 💤
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5da8fa5ef88b526fb95926d3]
<FromGitter> <ilanpillemer> that works
<FromGitter> <bew> yay
<FromGitter> <bew> time for bed for me!
<FromGitter> <ilanpillemer> is there a more idiomatic way to print a grid?
<FromGitter> <bew> do'nt think so
<FromGitter> <ilanpillemer> yeah.. I guess tomorrow night I can actually try solve https://adventofcode.com/2016/day/8
<FromGitter> <ilanpillemer> at least I now can emulate a easter bunny key authentication door mini screen
<FromGitter> <ilanpillemer> I think I am actually going to a little visualisation of this one too
<FromGitter> <ilanpillemer> and play with IO console library
<FromGitter> <bew> this aoc looks cool! I should try one of these one day
<FromGitter> <ilanpillemer> yes. they are fun.
<FromGitter> <ilanpillemer> a great way to learn languages too
<FromGitter> <bew> 👍
<FromGitter> <ilanpillemer> but with one. I intend to literally emulate the screen
<FromGitter> <ilanpillemer> as it processes the magnetic strip.. not just work out the answer
<FromGitter> <tenebrousedge> @ilanpillemer it's on another machine, and probably wasn't written in Crystal anyway D:
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 240 seconds]