ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
chachasmooth has quit [Ping timeout: 276 seconds]
chachasmooth has joined #crystal-lang
chachasmooth has quit [Ping timeout: 250 seconds]
chachasmooth has joined #crystal-lang
oprypin has quit [Remote host closed the connection]
hendursaga has quit [Ping timeout: 240 seconds]
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
oprypin has joined #crystal-lang
hendursaga has joined #crystal-lang
<FromGitter> <Blacksmoke16> is there an equivalent to https://www.php.net/manual/en/function.str-pad.php ?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/String.html#rjust(len:Int,char:Char='')-instance-method nvm, found it :)
Flipez has quit [Remote host closed the connection]
vasanth has joined #crystal-lang
<FromGitter> <woodgear> hi,i'm a newbie in crystal, and i'm try to pase a json from file,here is my code ```
<FromGitter> <woodgear> hi,i'm a newbie in crystal, and i'm try to pase a json from file,here is my code
<FromGitter> <woodgear> hi,i'm a newbie in crystal, and i'm try to pase a json from file,here is my code `require "json" ⏎ ⏎ class Item ⏎ JSON.mapping( ⏎ ... [https://gitter.im/crystal-lang/crystal?at=60924de94d0065337e540256]
<FromGitter> <woodgear> hi,i'm a newbie in crystal, and i'm try to pase a json from file,here is my code ⏎ ` ⏎ `
<FromGitter> <erdnaxeli:cervoi.se> you should not use JSON.mapping, but instead usee JSON::Serializable :)
<FromGitter> <woodgear> oh,that's something new to me.
<FromGitter> <erdnaxeli:cervoi.se> JSON mapping isn't in the stdlib anymore, but it is still available here https://github.com/crystal-lang/json_mapping.cr if you really need it
hendursaga has quit [Ping timeout: 240 seconds]
hendursaga has joined #crystal-lang
vasanth has quit [Ping timeout: 240 seconds]
_ht has joined #crystal-lang
Xeago has quit [Quit: Xeago]
<FromGitter> <woodgear> hi, everybody. i just write a tiny tool use crystal,which will call xdotool according a json config,if you feel interesting check it out xdotool-ext (https://github.com/woodgear/xdotool-ext)
<FromGitter> <woodgear> cool,thanks again.
<FromGitter> <erdnaxeli:cervoi.se> nice
<FromGitter> <erdnaxeli:cervoi.se> with JSON::Serializable when the field name and the attribute name are the same, the JSON::Field annotation is not necessary
Xeago has joined #crystal-lang
Xeago has quit [Client Quit]
Xeago has joined #crystal-lang
Xeago has quit [Quit: Xeago]
Xeago has joined #crystal-lang
HumanG33k has quit [Quit: Leaving]
<FromGitter> <linkyndy> Hey! 👋 I've tried rebuilding my Docker image and it failed: `Outdated shard.lock (radix requirements changed). Please run shards update instead.` ⏎ ⏎ I did not change anything for some time, so I'm wondering what's the issue. I believe `shard.lock` should dictate what should be installed, however `shards install` outputs `Installing kemal (1.0.0)` whereas my lockfile states `version: 0.26.1` 🤔 What
<FromGitter> ... am I missing? ⏎ ⏎ Running on `crystal:0.32.1-alpine`. [https://gitter.im/crystal-lang/crystal?at=60926c3f963923553ae4f25e]
HumanG33k has joined #crystal-lang
frojnd has quit [Quit: WeeChat 2.3]
frojnd has joined #crystal-lang
<straight-shoota> Crystal 0.32.1 ships with an equally old shards release that might have issues with more recent configs.
<straight-shoota> This is hard to figure out for such old versions. At this point it would be very recommended to update to Crystal 1.0
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
postmodern has quit [Remote host closed the connection]
deavmi has quit [Ping timeout: 240 seconds]
<FromGitter> <linkyndy> I see. But since the configs didn't change at all, wouldn't it make sense for the lockfile dependencies to be satisfied? It feels like they are ignored when running `shard install`
<straight-shoota> Technically, yes
<straight-shoota> But this is shards 0.8.1, which was released 3 years ago. A lot has changed since then. No idea what, but it's not a huge surprise
deavmi has joined #crystal-lang
<FromGitter> <linkyndy> I understand. I will look into upgrading this, then. Thank you
<FromGitter> <roduquen> Hi everyone, I am a bit stuck and dont find a solution to migrate from bintray.. Can anyone help, I use travis and Docker
<FromGitter> <Blacksmoke16> are you using it for anymore more than just running specs?
vasanth has joined #crystal-lang
vasanth has quit [Ping timeout: 260 seconds]
<FromGitter> <roduquen> In travis no, but in my dockers it s for running shards and the crystal install
<FromGitter> <Blacksmoke16> docker images should be up to date to handle it. what exactly is the problem you're having?
<frojnd> I am gonna parse json file to strings and insert the into db. I see sqlite3 actually supports json: https://www.sqlite.org/json1.html
<frojnd> On a long run this will be better to modify specific json objects
<FromGitter> <roduquen> I use the docker from bintray
<FromGitter> <roduquen> Directly bintray dockers
<FromGitter> <Blacksmoke16> was that a thing? i thought all docker images were on dockerhub
vasanth has joined #crystal-lang
<FromGitter> <roduquen> ```code paste, see link``` ⏎ ⏎ I have this using crystal repo [https://gitter.im/crystal-lang/crystal?at=60929be90056b2262c2de8d0]
<FromGitter> <Blacksmoke16> and whats the image of this container?
<FromGitter> <Blacksmoke16> nvm, i see it `docker.io/crystallang/crystal:latest` yea?
<FromGitter> <roduquen> Yep
vasanth has quit [Ping timeout: 268 seconds]
<FromGitter> <Blacksmoke16> @straight-shoota has been doing some infra stuff around this lately. Prob needs a new image published?
<straight-shoota> The crystallang/crystal dockerfile has the package directly embedded, it doesn't use bintray
<FromGitter> <roduquen> the docker is this one : ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60929dbdf7e4221825bb6df0]
<FromGitter> <roduquen> it's a simple one
<FromGitter> <Blacksmoke16> yea, i just pulled it and it does error
<FromGitter> <Blacksmoke16> so it found its way in there somehow
<straight-shoota> WTF?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60929e5931d2306a0e9137e3]
<FromGitter> <Blacksmoke16> and theres no way installing the actual deb adds it because of some metadata or something in the deb itself?
<straight-shoota> nope
<straight-shoota> so it must actually be a docker image built from a different dockerfile
<FromGitter> <roduquen> It's when running apt-get update that it tries to pick bintray
* straight-shoota has to dig out the obosolete bintray stuff again
<straight-shoota> As a workaround you can use crystallang/crystal:nightly
<straight-shoota> that uses the correct dockerfile and has no bintray in it
<FromGitter> <roduquen> nightly for prod..
<straight-shoota> you can pin it to the nightly from 2021-03-22, the release date of 1.0
vasanth has joined #crystal-lang
<FromGitter> <roduquen> ok thank you :/
<FromGitter> <Blacksmoke16> in unrelated news i actually had a use for the `Levenshtein` module today :P
vasanth has quit [Ping timeout: 240 seconds]
<straight-shoota> or well docker hub seems to forget images once they're untagged
<FromGitter> <Blacksmoke16> depending on exact use case might be able to get away with the alpine image
<FromGitter> <Blacksmoke16> that would do it
<FromGitter> <riffraff169> just out of curiosity, say you were trying to create your own linux build, that there were no crystal packages for, how would you go about building crystal for it? you have llvm
<FromGitter> <riffraff169> i know, not likely, but just say
<straight-shoota> you just grab the generic linux tarball
<straight-shoota> it has a statically linked binary that runs on any linux system
<straight-shoota> don't even need llvm to build anything
<FromGitter> <riffraff169> and go from there, ok......
<FromGitter> <riffraff169> what process do you guys go through to build on a new system that doesnt currently have support, but it does have a c compiler....or is that way to complex to describe here
<straight-shoota> cross-compiling
<straight-shoota> so you start from a supported system, build the compiler with `--cross-compile --target=$TARGET_ARCH` and link it on the target system
<FromGitter> <riffraff169> ok
<FromGitter> <riffraff169> just out of curiosity, at what verion did it get self-compiled?
<FromGitter> <erdnaxeli:cervoi.se> hmm, there is a commit "removed all ruby code" from 29/10/2013
<FromGitter> <erdnaxeli:cervoi.se> but I can't find the version
<FromGitter> <erdnaxeli:cervoi.se> I think it was 0.1.0
<FromGitter> <erdnaxeli:cervoi.se> the only version before (on github) is named just "ruby"
<straight-shoota> this is the bootstrap genealogy: https://github.com/crystal-lang/bootstrap-script/blob/master/bootstrap
<straight-shoota> so you could start with the ruby implementation, wait a couple of hours and should get a revent Crystal compiler build
<FromGitter> <riffraff169> cool....im interested in language design...ive created several languages over the past 20 years, but never got to the point of it self-hosting
<FromGitter> <erdnaxeli:cervoi.se> oooh this boostrap script is amazing
vasanth has joined #crystal-lang
vasanth has quit [Ping timeout: 246 seconds]
vasanth has joined #crystal-lang
vasanth has quit [Ping timeout: 240 seconds]
vasanth has joined #crystal-lang
vasanth has quit [Ping timeout: 240 seconds]
hendursaga has quit [Remote host closed the connection]
hendursaga has joined #crystal-lang
<FromGitter> <spaceaardvark> just wanted to drop in a give a big high five to the crystal team. you have combined 1) approachability 2) static typing 3) compilation/speed 4) simplicity better than any other language out there
<straight-shoota> thanks =) Working hard to get even better.
<FromGitter> <spaceaardvark> straight-shoota do you have a roadmap? i couldn't find one. or is the roadmap "everything, quit asking" :)
<straight-shoota> there, is but it's a bit hidden and not super specific on anything
_ht has quit [Remote host closed the connection]
<straight-shoota> @roduquen Even simpler workaround: Delete the bintray repository before running apt update
<straight-shoota> this is now tracked in https://github.com/crystal-lang/crystal/issues/10678 btw.
<FromGitter> <djberg96> @spaceaardvark unfortunately, I'm trapped in Golang!
<FromGitter> <djberg96> i don't suppose you feel like rewriting Kubernetes in Crystal, do you?
<FromGitter> <spaceaardvark> @djberg96 hard pass! haha we're using Go at my gig, too. it's powerful but not very approachable -- at all
<FromGitter> <djberg96> i feel like i'm programming in 1997 again
<FromGitter> <spaceaardvark> ok that hit me in the nostalgia nerve
postmodern has joined #crystal-lang
<postmodern> if you have a Value type object within a Class as an ivar, and you call object.ivar, is it passed by value or reference?
<FromGitter> <RespiteSage> Value, I believe.
<FromGitter> <RespiteSage> Usually, though, `object.ivar` is a getter.
<FromGitter> <RespiteSage> Hm... Yeah, I think when you're moving a Value around at all, it will always be copied.
<FromGitter> <RespiteSage> https://carc.in/#/r/b2o5
<FromGitter> <RespiteSage> I think `Value`s are always meant to be immutable, though.
<FromGitter> <RespiteSage> Yeah: https://crystal-lang.org/api/1.0.0/Value.html
<FromGitter> <RespiteSage> > A Value is passed by value: when you pass it to methods, return it from methods or assign it to variables, a copy of the value is actually passed. This is not important for nil, bools, integers, floats, symbols, pointers and tuples, because they are immutable, but with a mutable Struct or with a StaticArray you have to be careful.
<postmodern> ah ha
<postmodern> can you call `delegate each, to: @...` twice on multiple ivars, such that the method signatures have different block types based on what type the @ivar contains?
<postmodern> `delegate each, to: @chars` followed by `delegate each, to: @bytes`. Or would the second delegate override the first one?
<FromGitter> <RespiteSage> I have no clue about that one.
<FromGitter> <Blacksmoke16> easy enough to just try it
<postmodern> to test.cr we go
<postmodern> actually, how does one specify the type of the yield argument you want in return?
<FromGitter> <Blacksmoke16> `& : String -> Int32`
<FromGitter> <Blacksmoke16> yields a string and returns an int32
<postmodern> what if you had to overloaded methods with different block type definitions, how would the caller request "i want to call the method that yields an Int32 not a Char"?
<postmodern> `do |i : Int32|` doesn't seem to work
<FromGitter> <Blacksmoke16> idt thats a thing?
<straight-shoota> block arguments can't be overloaded
<postmodern> ah thought as much
oddp has joined #crystal-lang
<FromGitter> <Blacksmoke16> would be nice if the exception backtrace had the option of being an array of like `Exception::Frame`
<FromGitter> <Blacksmoke16> E.g. https://github.com/Sija/backtracer.cr, but in the stdlib. Is a cool lib but debating if its worth the extra dependency just for 1 context
<FromGitter> <Blacksmoke16> esp since in the stdlib i imagine it has that data on hand versus needing to parse it from the line