<FromGitter>
<Blacksmoke16> you'd have to create a new one with the properties from both
alex```` has quit [Ping timeout: 252 seconds]
<FromGitter>
<Blacksmoke16> easiest solution here would be to use `JSON::Serializable` and inheritance
<FromGitter>
<Blacksmoke16> @samueleaton
alex```` has joined #crystal-lang
<FromGitter>
<samueleaton> @Blacksmoke16 That's a good idea. But I put this in a variable MAPPING so that i can do `JSON.mapping({{MAPPING}})` followed by `DB.mapping({{MAPPING}})` for dry-er code. Doing a JSON specific solution wouldn't be dry enough since i'd have to still do mapping for the DB table.
<FromGitter>
<Blacksmoke16> not easier to just use an ORM?
<FromGitter>
<Blacksmoke16> basically your problem is there is no `#merge` method
<FromGitter>
<Blacksmoke16> prob could just do `JSON.mapping({{MAPPING}}, {{Thing::MAPPING}})`, is good enough
<FromGitter>
<Blacksmoke16> making a JSON API by chance? :p
<FromGitter>
<PlayLights_twitter> @It is dynamic so i ended up refactoring my code
<FromGitter>
<Blacksmoke16> π
hightower2 has quit [Ping timeout: 244 seconds]
<FromGitter>
<samueleaton> @Blacksmoke16 just selling cookies haha https://cravecookie.co/ β Been loving Crystal for this project. A little more trouble getting everything to compile with all the views and stuff but it pays off in run time.
<FromGitter>
<PlayLights_twitter> Hey guys is it is possible to manually free memory used by an object?
<FromGitter>
<Blacksmoke16> ah gotcha, good to hear
<FromGitter>
<Blacksmoke16> you could manually call the GC
<FromGitter>
<Blacksmoke16> however im not super familiar with this kinda stuff
<FromGitter>
<watzon> @samueleaton just using Kemal?
<FromGitter>
<PlayLights_twitter> @Blacksmoke16 i think i have saw code before using the GC but i donβt remember where
<FromGitter>
<watzon> I have too
<FromGitter>
<Blacksmoke16> afaik its just `GC.collect`?
<FromGitter>
<watzon> I think you're correct. `GC.free` might be a thing?
<FromGitter>
<watzon> Yeah it is as well
<FromGitter>
<Blacksmoke16> might be able to do like `GC.free pointerof(my_obj)` then?
<rkeene>
Anyone know of a place that's hiring ? I know Crystal, if that helps :-D
<FromGitter>
<watzon> Unfortunately for most places it doesn't
<FromGitter>
<watzon> I got lucky
<FromGitter>
<watzon> Hopefully once Crystal hits v1 we'll start seeing it in production more
sz0 has joined #crystal-lang
<rkeene>
I also know dozens of other languages, as well as having done UNIX administration, and network administration, and built CI/CD systems, and designed and built a private cloud system (bare metal to cloud, automatically)
<rkeene>
And I've built smartcard middleware, been a ("top 50") cryptocurrency lead developer, written software for everything from Flight Data Recorders (NIOS-II softcore), ESP32 IoT devices, ...
<FromGitter>
<Blacksmoke16> i probably would have opened with that instead
<rkeene>
I was the lead developer of Nano (https://nano.org/; Formerly RaiBlocks)
<rkeene>
The software I wrote for the flight data recorders is closed source
<rkeene>
So... any ideas, anyone ?
<FromGitter>
<watzon> I'll let you know if I hear anything. You've worked with crypto?
<FromGitter>
<Blacksmoke16> could always just check like indeed and stuff
<rkeene>
Yes, both cryptocurrencies (lead developer for Nano and security audits on other cryptocurrencies) and cryptography (in addition to my smartcard middleware, I maintain a PKI stack for Tcl, and have talks on it)
<FromGitter>
<watzon> That's cool. I'm helping out with the SushiChain project.
<FromGitter>
<girng> > This method is useful for dealing with nilable types, to safely perform operations only when the value is not nil.
<FromGitter>
<watzon> The idea is that you can avoid typing `if var1 && var2 && var3`
<jokke>
but imho something like foo&.bar&.baz is a code smell
<FromGitter>
<watzon> I like it better in Crystal
<FromGitter>
<watzon> You have to use `try`
<jokke>
watzon that's not the usecase
<FromGitter>
<girng> i just did &.strip on an array, i
<FromGitter>
<girng> i'm loving this &. lol
<FromGitter>
<girng> should i say, `.map &.strip`
<jokke>
its more like `var1 && var1.foo && var1.foo.bar`
<FromGitter>
<watzon> Well yeah
<jokke>
oh does crystal have `&.` as well?
<FromGitter>
<girng> yah
<jokke>
ooh
<jokke>
ok
<jokke>
but why?
<jokke>
it already has try
<FromGitter>
<watzon> It's not the same thing
<jokke>
`foo.try(&.bar)`
<FromGitter>
<girng> i think, for the optional chaining thing
<FromGitter>
<watzon> You can't chain it like you can with Ruby
<FromGitter>
<girng> lets you pass it inline
<FromGitter>
<watzon> You have to do `article.try &.author.try &.name`
<jokke>
yeah i see
<FromGitter>
<girng> @watzon damn i never gone that far with chains
<jokke>
which is good
<FromGitter>
<girng> lol
<jokke>
i think it's bad practice
<FromGitter>
<watzon> Sometimes it's necessary
<FromGitter>
<watzon> Especially when dealing with lots of nested JSON
<FromGitter>
<girng> wait
<FromGitter>
<girng> 1 sec gonna try something
<jokke>
hmm
<jokke>
i think using guard clauses would be cleaner
<jokke>
author = article.try(&.author)
<jokke>
return if author.nil?
<FromGitter>
<girng> i like that
<FromGitter>
<girng> easy to read
<jokke>
it's more verbose but i think it's easyer to read, yeah
<jokke>
because usually you just have one level where something can be nil. if that isn't nil the lower levels aren't nil either
<jokke>
in that case name of the author
<jokke>
the chaining of `&.` doesn't give you that information
<FromGitter>
<girng> omg LOL
<FromGitter>
<girng> gonna show this playground link 1 sec
<FromGitter>
<watzon> It's very verbose and gets extremely annoying when you get 3 levels in
<FromGitter>
<watzon> But it's all a matter of personal preference
<jokke>
watzon then i think it's time to refactor the method that is doing all that
<jokke>
but sure, personal preference too
<FromGitter>
<watzon> If you have 3 nested JSON objects and you need to get a property on the third object there isn't much refactoring you can do. Your options are pretty much: use the short `prop.try &.other.try &.another`, or use the much more verbose syntax.
<FromGitter>
<girng> in my baseball code golf challenge some of the submissions made my head explode
<FromGitter>
<girng> ..and i thought i knew crystal pretty well
devil_tux has quit [Ping timeout: 252 seconds]
<FromGitter>
<girng> just like in real life, there will always be someone bigger
<FromGitter>
<girng> in programming, there will always be someone smarter
laaron has joined #crystal-lang
SukinoSenze has joined #crystal-lang
<FromGitter>
<r00ster91> I'm getting an `SSL_connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed` error when connecting to a web socket URL, is there any way to just skip the certificate verification?
DTZUZO has joined #crystal-lang
SukinoSenze has quit [Remote host closed the connection]
devil_tux has joined #crystal-lang
alex`` has quit [Ping timeout: 272 seconds]
alex`` has joined #crystal-lang
devil_tux has quit [Ping timeout: 272 seconds]
<FromGitter>
<Blacksmoke16> looks like i got some competition in the logger scene now @watzon :p
<FromGitter>
<dscottboggs_gitlab> it allows for dynamic typing as long as *all types are known at compile time*. Very important difference there.
<FromGitter>
<girng> personally, i don't like that. shouldn't a method in a statically typed language, accept a statically typed input? and only that type?
<FromGitter>
<girng> "known at compile time" but the developer still uses the method as a dynamic one lol
<FromGitter>
<dscottboggs_gitlab> yes, but if the developer were to call the method on a type that won't work at any point in the method, the compiler will alert the developer *at compile time* instead of *at runtime*
<FromGitter>
<girng> developer should create another method if they want a method to accept that type
<FromGitter>
<dscottboggs_gitlab> Go is a decently nice language (well...not in terms of aesthetics lol) that has no support for generics
<FromGitter>
<girng> why have 1 method be dynamic that's silly
<FromGitter>
<girng> and prob leads to confusion
<FromGitter>
<girng> and trouble finding bugs
<FromGitter>
<dscottboggs_gitlab> yes, I use type restrictions almost all the time
<FromGitter>
<girng> since this csv to to_i static parsing strick blacksmoke helped me with. i really like things statically typed
<FromGitter>
<dscottboggs_gitlab> there was a really good example I saw the other day, but I can't find it now, and it was pretty short so I'll just write it here
<FromGitter>
<girng> Why would @lucky_number have `| Nil` to it?
<FromGitter>
<girng> Is it because it's not in the constructor?
<FromGitter>
<girng> initialize section?
<FromGitter>
<dscottboggs_gitlab> ```code paste, see link``` β β crystal does this by internally creating a new version of your function for each type of value that gets passed to it, and statically compiling all of those functions. [https://gitter.im/crystal-lang/crystal?at=5d1225da81d4c416606af513]
<FromGitter>
<girng> wtf
<FromGitter>
<Blacksmoke16> @girng yes, nor has a default value
<FromGitter>
<girng> interesting
<FromGitter>
<girng> > can take any type that has a + method defined on it.
<FromGitter>
<dscottboggs_gitlab> because in the method I am calling `+` on the values
<FromGitter>
<girng> yeah
<FromGitter>
<girng> so.. if you were to do x : Int32
<FromGitter>
<girng> it wouldn't work on the array right
<FromGitter>
<girng> with the array*
<FromGitter>
<dscottboggs_gitlab> yes
<FromGitter>
<girng> ic, okay i can see it's usage then "can take any type that has a +"
<FromGitter>
<girng> but imho, i'd rather create sum_array, or whatever
<FromGitter>
<girng> have diff methods for what kind of types they interact with
<FromGitter>
<girng> i guess it does that for you behind the scenes
<FromGitter>
<Blacksmoke16> depends on the use case
<FromGitter>
<Blacksmoke16> are some cases where you want a method to take any type of arg
<FromGitter>
<girng> but yeah @dscottboggs_gitlab iknow that was just an example. ty for doing it
<FromGitter>
<dscottboggs_gitlab> > i guess it does that for you behind the scenes β β Exactly, it's a shortcut. The more shortcuts, the better IMO :p
<FromGitter>
<girng> ;D
<FromGitter>
<girng> 6 more hours :/ then sleep fml
<FromGitter>
<girng> i want to CODE ALL DAY
<FromGitter>
<dscottboggs_gitlab> oof, sleep is super important
<FromGitter>
<yxhuvud> Looks like something that should be an exception though.
<FromGitter>
<tenebrousedge> @girng search through the crystal-lang source for "forall" for more uses
<FromGitter>
<vladfaust> @yxhuvud I'm working with PG Numeric, and BigRational is the closest thing to it in Crystal
<FromGitter>
<vladfaust> PG Numeric has NaNs though
<FromGitter>
<yxhuvud> @vladfaust Well, an exception is probably more helpful in any case, as it alterts you that there is an issue. -1024 isn't very useful.
<FromGitter>
<vladfaust> Ah, yes
lucasb has joined #crystal-lang
<FromGitter>
<girng> @vladfaust working with some big numbers, eh? :D
<jokke>
then you can just keep everything as it is
<jokke>
the macro i mean
<FromGitter>
<mwlang> but the macro calls #from_json...wouldn't I need to know the JSON starts with "[" and thus an Array of objects and call #new instead of #from_json?
<jokke>
from_json just calls the initializer
<jokke>
so just write the initializer and it should "just work"
<FromGitter>
<mwlang> ok, will do.
<jokke>
basically your initializer just does `@trades = Array(TradeEntry).from_json(pull)`
<jokke>
and that's it
<jokke>
i'm not 100% certain though if your initializer will override the one generated by including JSON::Serializable
<jokke>
but if you don't want to do `to_json` anyway you can just ditch that
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<kinxer> I'm finishing up a GeoJSON library in Crystal. Would it be confusing to name it something "clever" or should it just have a name related to GeoJSON (like "crGeoJSON")?
<FromGitter>
<asterite> Nice! Clever or funny names are good. I guess it depends on whether you want the shard to be more discoverable... but with search engines it's not a real problem anymore
duane has quit [Ping timeout: 245 seconds]
<FromGitter>
<kinxer> Unfortunately, crystals and gems don't seem to be very related to navigation or cartography, so I'm still working on what a clever name could be. I appreciate the input, though. I prefer fun names if possible.
_whitelogger has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter>
<watzon> You sure do @Blacksmoke16 ;)
duane has joined #crystal-lang
<FromGitter>
<Blacksmoke16> should have just made some PRs :P are quite similar
<FromGitter>
<Blacksmoke16> concept wise
<FromGitter>
<jwoertink> If I wanted to gzip my static assets, would the `HTTP::CompressHandler` come after the `HTTP::StaticFileHandler`?
<FromGitter>
<jwoertink> so it seems like it would never hit the gzip handler
<FromGitter>
<jwoertink> but if you put the compression before the static, then it wouldn't actually compress the file, right?
<FromGitter>
<Blacksmoke16> prob not
<FromGitter>
<mwlang> @kinxer how about "sextant" ?
<FromGitter>
<Blacksmoke16> could just reopen the static file handler and add the compressions stuff
<FromGitter>
<kinxer> @mwlang That's pretty good. I was thinking of "geode", which only has a couple of direct matches on GH.
<FromGitter>
<tenebrousedge> I like "geode"
<FromGitter>
<kinxer> Ideally I'd get something about the serialization in the name, but I don't think that's gonna be feasible (at least, not with a reasonably short name).
<FromGitter>
<tenebrousedge> but what about those sunstones the Vikings used
<FromGitter>
<tenebrousedge> "There are only two hard problems in Computer Science: cache invalidation, naming things, and off-by-one errors."
<FromGitter>
<Blacksmoke16> imagine thats what the LibPQ is doing already tho...
<rkeene>
Also, OpenNebula is Ruby based and they considered moving to Crystal
<rkeene>
I couldn't convince them to move to Tcl
<FromGitter>
<vladfaust> > imagine thats what the LibPQ is doing already tho... β β It should not matter. It accepts `Bytes` as argument, so what the hell
<FromGitter>
<vladfaust> BTW, for encoding into bytes, using `StaticArray` is pointless, because we still use slices (which are always in heap)
alex`` has joined #crystal-lang
<FromGitter>
<r00ster91> when spawning multiple fibers in a method and then `return`ing inside of one of the fibers, then all other fibers stop running too, right? Or do they continue running even after the `return`?
<oprypin>
continue
<FromGitter>
<r00ster91> ooh
<FromGitter>
<r00ster91> thats good to know
devil_tux has quit [Ping timeout: 268 seconds]
<FromGitter>
<watzon> I can't wait for multithreading support
<FromGitter>
<watzon> I mean fibers are great and all
<FromGitter>
<watzon> But true parallelism would be nice
<FromGitter>
<Blacksmoke16> esp since yours also allows multiple loggers to have their own stuff
<FromGitter>
<Blacksmoke16> kinda based our stuff off similar frameworks haha
<FromGitter>
<watzon> Yeah I guess so. I noticed you based yours off of a PHP logger, so I didn't really bother looking at the one you based it off in any more depth. I kind of hate PHP just a little.
sagax has quit [Write error: Connection reset by peer]
<FromGitter>
<Blacksmoke16> hehe
<FromGitter>
<watzon> On an unrelated note, I'm testing my web scraper on pornhub right now π
<FromGitter>
<watzon> It's working fantastically
<FromGitter>
<watzon> Oh the flexibility you have when working from home
<FromGitter>
<Blacksmoke16> my pipe dream is some framework with formatters/processors/handlers be defined in the stdlib
<FromGitter>
<Blacksmoke16> which would define the basic ones and the API
<FromGitter>
<watzon> That would be wonderful, but definitely a pipe dream
<FromGitter>
<Blacksmoke16> then shards could define them
<FromGitter>
<Blacksmoke16> other projects could use them, everything would just work
<FromGitter>
<watzon> Well maybe once the stdlib gets split apart into different shards the core devs will be open to that
<FromGitter>
<Blacksmoke16> i got a +1 on my comment on the improve logger issue
<FromGitter>
<Blacksmoke16> ill take that as #progress
<FromGitter>
<Blacksmoke16> however im unsure if thats something they actually want, or just agree with my pipe dream π
<FromGitter>
<watzon> Yeah. I feel like we need some kind of voting system for ideas. Right now everything is up to the core devs, and they tend to disagree a lot with the community and among themselves.
<oprypin>
this is one of those cases where democracy doesnt work
<oprypin>
the voting would be disproportionately affectionate to what already exists in ruby, whether it makes sense or not
<oprypin>
(yes, im a hater, w/e)
<FromGitter>
<watzon> Why do you say that? Obviously core devs need to have the final say, because sometimes people are just stupid, but if the community as a whole thinks that something should exist or not exist then I feel like that should influence their decisions
<oprypin>
tbh i'd just let asterite decide everything, but then again, i think he was feeling overburdened by exactly that
<oprypin>
watzon, i feel that github issues, reactions and even normal replies handle the part of "influencing decisions" fine
<rkeene>
What Tcl does maintain a set of common packages outside of the Tcl core, then at release time they'll be included in the release in such a way they are built with the Tcl core
<oprypin>
python has exactly 1 package like that :D - pip / ensurepip
alex`` has quit [Ping timeout: 252 seconds]
<rkeene>
Tcl has a few: SQLite3, Database stuff, the OO package, the thread package
<FromGitter>
<ezrast_gitlab> @Blacksmoke16 Did you see my PR for that issue you commented on? I think it does a lot of what you're asking for (super simple interfaces for filter/emitter that you can slot your own handlers into) but it's been pending review since October.
asterite has quit [Ping timeout: 245 seconds]
jhass has quit [Ping timeout: 250 seconds]
lucasb has quit [Quit: Connection closed for inactivity]