RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <dscottboggs_gitlab> is there any way to make a struct literal or is a NamedTuple the closest we get?
<FromGitter> <j8r> Isn't, by chance, GB something encoding?
<mps> j8r: well, no. have to find time to thoroughly look why test fail, but don't have much time these days
<FromGitter> <j8r> jirutka has also worked on this before
<mps> yes, but he is not active as before, that's a pity because he is brilliant
<mps> he introduced me to crystal
<FromGitter> <j8r> Agree, he is amazing. It's him who has ported Crystal or aarch64 musl
<FromGitter> <j8r> *to
<mps> I just trying to follow his work, I'm not nearly competent as he is
<mps> rkeene: I don't see any port to pa-risc anywhere
<rkeene> :-(
<mps> agree with you: :-(
<jokke> \o/
<jokke> i set up an automated build
<jokke> gotta love gitlab ci <3
<jokke> this part i don't like: export VERSION=$(docker run $REGISTRY_NAME:$CI_COMMIT_SHA crystal --version | head -n1 | awk '{print $2}')
<jokke> is there a way to get a machine readable output from --version?
<FromGitter> <j8r> You're more than fine mps, IMHO. We are lucky :P
<FromGitter> <j8r> What to do think of NixOS? I don't know of they have Crystal
<jokke> hehe
<jokke> i dabbled with nixos once
<jokke> a few years back
<jokke> i really like the concept
<jokke> but it didn't turn out to be that great in practice
<jokke> (for me)
<jokke> for servers it could be great though
<mps> sorry, I don't know much about docker and all that you just posted
<FromGitter> <j8r> What's sure they have bots spaming issues and PR https://github.com/NixOS/nixpkgs
<FromGitter> <j8r> Thx for the feedback jokke
<mps> ok, late is here, good night to you all
<jokke> mps: ah ok. alpine is very popular as base for docker images since it's very light weight. with muslibc it's even possible to statically link crystal builds which makes it even more interesting for docker since you can just use "scrach" as base image for your final build (a container containing nothing (no pun intended :)) and copy the statically linked binary in there.
<FromGitter> <dscottboggs_gitlab> good night mps!
<jokke> night mps and thanks for the great work!
<mps> you are welcome :)
<FromGitter> <dscottboggs_gitlab> what prevents statically linking glibc stuff?
<rkeene> If you like Nix/NixOS you'll like AppFS ( http://appfs.rkeene.org/ )
<jokke> dscottboggs_gitlab: glibc basically :D
<jokke> it's GPL
<rkeene> discottboggs_gitlab, glibc supports NSS, which are dynamic, and statically linking to it requires that the same versions be used since they haven't defined a stable ABI for NSS modules
<rkeene> jokke, glibc is LGPL, which allows you to statically link as long as you make available the unlinked objects to replace the LGPL parts and relink
<jokke> that's true
<jokke> but it's a bit unpractical
<jokke> oh it's LGPL
<jokke> thought it was GPL
<FromGitter> <dscottboggs_gitlab> rkeene what is NSS?
jemc has quit [Ping timeout: 250 seconds]
<FromGitter> <dscottboggs_gitlab> that is kind of essential, yes
<FromGitter> <dscottboggs_gitlab> I'm gonna be honest I still don't get how that prevents static linking but if you don't want to explain it to me that's ok haah
<rkeene> Because NSS modules are shared objects (i.e., can't be statically linked in) and lack a stable ABI (i.e., the ones on the system may not match the ones compiled against) if you statically link glibc then you can't reliably use NSS
ashirase has quit [Quit: ZNC - http://znc.in]
<FromGitter> <dscottboggs_gitlab> > NSS modules are shared objects (i.e., can't be statically linked in) ⏎ ⏎ I see...why can't they be linked in?
<rkeene> Because they're shared objects :-D
<rkeene> They're defined by the fact that they are linked in at runtime
<rkeene> Since the running system could be configured for arbitrary NSS module usage -- there are MySQL NSS modules, for example
<FromGitter> <dscottboggs_gitlab> Oh I think I get it now
<FromGitter> <dscottboggs_gitlab> Jeeze
<rkeene> It's the identification counterpart to PAM
<FromGitter> <dscottboggs_gitlab> So is there no way we could get around using NSS or would it not be worth it to do so?
<rkeene> You can always not use NSS as part of your program -- don't try to resolve hostnames, or lookup users, etc
<rkeene> Then there's no problem -- same as if you don't try to authenticate users (e.g., PAM)
<FromGitter> <dscottboggs_gitlab> oh, so even though the compiler gives you warnings it'll still run
<rkeene> If you don't use those functions it won't give you the warning
<FromGitter> <dscottboggs_gitlab> oh I see
<rkeene> It'll still run with the warning, it might just crash if the ABI's mismatch
<rkeene> :-D
<FromGitter> <dscottboggs_gitlab> It would be nice if the warnings also told you what you did that caused the warning. Like, does `File.open` implicitly call something in NSS? or `HTTP::Server`? Tjere
<rkeene> musl-libc just doesn't care about supporting arbitrary NSS modules, so only the ones you link in will be used
<FromGitter> <dscottboggs_gitlab> except reading the source of course..
<rkeene> It'll tell you the name of the object file that tried to use the symbol, IIRC
<FromGitter> <dscottboggs_gitlab> hm...
<rkeene> $ cat foo.c
<rkeene> int main(int argc, char **argv) { getaddrinfo(); }
<rkeene> $ cc -o foo -static foo.c
<rkeene> foo.c:(.text+0x15): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
<FromGitter> <dscottboggs_gitlab> yeah it looks like using a TCP Server uses `getaddrinfo` at least so anything to do with HTTP serving will implicitly bring that into scope
<rkeene> You could always modify glibc to not link them dynamically but instead statically, like musl-libc
<rkeene> And then be sad when users have weird systems
<FromGitter> <dscottboggs_gitlab> hahah yeah that's pretty much what I figured :p
<rkeene> (same as musl-libc)
<rkeene> ABIs are hard, man
<FromGitter> <dscottboggs_gitlab> yeah that's true
<FromGitter> <bew> @j8r you're looking into NixOS? me too since 3days :)
<rkeene> AppFS man, I'm telling you
<jokke> j8r: about nixos: it's roughly 2-3 years ago since i tried it, so things might be much smoother now
<FromGitter> <bew> you did appfs right?
<rkeene> Yes
<FromGitter> <bew> how is it different from Nix?
<rkeene> I thought about rewriting it in Crystal but I wasn't sure how FUSE's insetence on creating threads would work with it
<FromGitter> <bew> beside it's fuse and everything that goes with it
<rkeene> AppFS is on-demand lazy caching of packages rather than including an additional "install" step
<FromGitter> <bew> caching only? I'm mainly interested in Nix for the 'create your own environment in code' thing, and the 'track everything you do on the system in config files' and also 'keep track of all the change you do when doing a custom package, reproducible build' etc.. (most of what Nix & NixOS highlights actually)
<rkeene> Yeah, all writes go to your home directory so it's not perscriptive like NixOS
<FromGitter> <bew> it looks interesting for non-root package install though, easier than organize everything yourself like I did up until now^^
<rkeene> Yeah, and you only have to build the package once and then everywhere has the new package/update without having to install/update/distribute, etc
ashirase has joined #crystal-lang
<rkeene> I used to maintain a few thousand Slackware packages (counting revisions as separate packages)
<FromGitter> <bew> oh *** that's a lot
<rkeene> Now I don't install anything other than base Slackware, everything (including crystal, go, etc) I do from AppFS :-D
<FromGitter> <bew> I don't understand how you use AppFS
<FromGitter> <bew> your demo only shows an app/package already installed if i understand correctly
<FromGitter> <bew> who does the packages you can install on appfs?
<rkeene> Anyone who can run an HTTP server with static files
<rkeene> http://appfs.rkeene.org/web/home/Getting%20Started has "Getting Started as a Publisher" at the bottom
<rkeene> https://rkeene.org/terminal/1/ if you want to see a live demo
ashirase has quit [Quit: ZNC - http://znc.in]
<FromGitter> <bew> I don't think you explained how to install things on it (did you?)
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab https://play.crystal-lang.org/#/r/6425 is getting closer
ashirase has joined #crystal-lang
<rkeene> bew, There's only publishing and using
<FromGitter> <Blacksmoke16> `SELECT * FROM contacts e JOIN settings s ON s.id = e.id WHERE (e.age = ? AND e.role = ?); [30, "'foo'"]` is from the example as it requires DB shad now
<FromGitter> <Blacksmoke16> shard
<rkeene> bew, I'll publish something next
ashirase has quit [Client Quit]
<FromGitter> <bew> how do you the live sharing like that??
<rkeene> I need to upgrade my Go-lang package
<rkeene> bew, GoTTY
ashirase has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> @Blacksmoke16 that's nice but I am tired
<rkeene> I don't feel like verifying the SHA256 right now, so I'm going to trust it
<jokke> rkeene: gotty.. nice
<jokke> really nice
<rkeene> bew, Go is building -- I'll be right back, gotta pick up food
<jokke> didn't know this existed
<FromGitter> <bew> it's pretty cool, really
<jokke> yeah
<FromGitter> <bew> I reaally need to setup a server for my stuff...
johndescs has quit [Ping timeout: 268 seconds]
<FromGitter> <Blacksmoke16> well now just gotta write tests
johndescs has joined #crystal-lang
<FromGitter> <Blacksmoke16> just requires that a model has a class method called `table` which returns the table name
<FromGitter> <Blacksmoke16> possibly could provide some extensions/adapters for various ORMs
<FromGitter> <dscottboggs_gitlab> yes, mine required a `#table_name` as well
<FromGitter> <Blacksmoke16> maybe eventually can include some fancier API methods that other ORMs can implement
<FromGitter> <Blacksmoke16> to turn like `Model.where(id: 1)` into spec under the hood
<rkeene> I think I'll package something simpler than Go it's not working out for me
<FromGitter> <bew> gotta go, byee
<FromGitter> <Blacksmoke16> o/
<rkeene> bew, Doh
<rkeene> bew, I was going to jq real quck
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab yea is kinda required, *could* base it off class name but thats not really representative of what the model's name would be
<FromGitter> <Blacksmoke16> table's name*
<FromGitter> <dscottboggs_gitlab> it could be, why not?
<FromGitter> <dscottboggs_gitlab> `@type.class.name.underscore`?
<FromGitter> <Blacksmoke16> what if your class name is called `Moose`
<rkeene> Nevermind, it's got some kind of build issue too :-D
<FromGitter> <Blacksmoke16> er bad example :p
<FromGitter> <Blacksmoke16> like `Person`
<FromGitter> <Blacksmoke16> table name would obs be `people`
<FromGitter> <Blacksmoke16> then you're into whatever that word is
<FromGitter> <Blacksmoke16> then what do you do?
<FromGitter> <dscottboggs_gitlab> you'd have to make the class named the same as the table name, or implement `#table`
<FromGitter> <Blacksmoke16> yea, and at that point easier to just require a `table` method :p
<FromGitter> <dscottboggs_gitlab> true, I was just thinking of Rails's definitions of types based on class names
<FromGitter> <Blacksmoke16> yea but rails has a fancy thing that handles that pluralization and stuff
<FromGitter> <dscottboggs_gitlab> true
<FromGitter> <Blacksmoke16> https://github.com/phoffer/inflector.cr is this but would be a bit overkill imo
<FromGitter> <dscottboggs_gitlab> oh that's nice
<FromGitter> <dscottboggs_gitlab> but I think `#underscore` would be adequate, as long as you could use it only if `#table` isn't defined, but it's your library and if you don't want that then don't do it :p
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c4fb84c78e1ed4103a6cf80]
<FromGitter> <Blacksmoke16> got the `#add` implemented
<FromGitter> <Blacksmoke16> `SELECT * FROM contacts e WHERE ((e.role = ? OR e.foo <> ?))` `query = User.match( HasRole.new "foo")`
<FromGitter> <dscottboggs_gitlab> oh nice!!
<FromGitter> <Blacksmoke16> ye 💯
<FromGitter> <Blacksmoke16> but good call on that whitelisting thing
<FromGitter> <Blacksmoke16> was a good idea
<FromGitter> <Blacksmoke16> what else you got? :P
<FromGitter> <dscottboggs_gitlab> whitelisting?
<FromGitter> <Blacksmoke16> `extend Specify(IsAdmin | HasRole)`
<FromGitter> <dscottboggs_gitlab> oh yeah
DTZUZO_ has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> wanna write some tests for me? :trollface:
<FromGitter> <dscottboggs_gitlab> I'll consider it :p
<FromGitter> <dscottboggs_gitlab> is the repo public?
<FromGitter> <Blacksmoke16> not yet, didnt push anything yet
<FromGitter> <Blacksmoke16> while everything was still influx
<FromGitter> <Blacksmoke16> the one major thing i still need to solve is the param placeholders
<FromGitter> <Blacksmoke16> grr PG
<FromGitter> <Blacksmoke16> might make this modular in like
<FromGitter> <Blacksmoke16> `require "specify"`
<FromGitter> <Blacksmoke16> `require "specify/pg"` for the pg specific stuff etc
<FromGitter> <Blacksmoke16> didnt get that far yet
<FromGitter> <dscottboggs_gitlab> I was considering different backends for storing config data for flix, and I think I'm going to use compile-time flags to generate different sections.
<FromGitter> <Blacksmoke16> Oh?
<FromGitter> <Blacksmoke16> That would be an option
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <dscottboggs_gitlab> like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c4fbc27ca428b06451b2146]
laaron has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> I think that would make it compile differently based on compile_time environment flags but I haven't played with it yet
<FromGitter> <Blacksmoke16> flag?
<FromGitter> <Blacksmoke16> That would look for env variables ATM
<FromGitter> <dscottboggs_gitlab> I mean environment variables
<FromGitter> <dscottboggs_gitlab> yeah
<FromGitter> <Blacksmoke16> Ah gotcha
<FromGitter> <Blacksmoke16> Going to throw an error if none is provided? Or have a default?
<FromGitter> <dscottboggs_gitlab> default will be flat yaml file in `$XDG_CONFIG_HOME`, with PG or redis options
<FromGitter> <Blacksmoke16> Sounds like a plan
Vexatos has quit [Ping timeout: 246 seconds]
RX14 has quit [Ping timeout: 250 seconds]
Vexatos has joined #crystal-lang
<FromGitter> <proyb6> Üt
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
jemc has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <Ronaq13> Hey guys. I love crystal. ⏎ ⏎ I was looking for some meet-up group in my city (Delhi, India), but there is none. So I thought to start one. Is there anything I need to do before? Need to register somewhere or tell someone?
<FromGitter> <proyb6> But have you consider making your repo in Crystal first?
<FromGitter> <proyb6> @Ronaq13
<oprypin> Ronaq13: if nothing commercial is involved then i don't see why it wouldn't be allowed. i mean, people start meetups about all kinds of programming languages
_whitelogger has joined #crystal-lang
<FromGitter> <sam0x17> how can I xor two Slice(UInt8)'s ?
<FromGitter> <sam0x17> compiler is saying operator `^` is undefined for `Slice(UInt8)`
<FromGitter> <sam0x17> that should definitely be a thing looks like it might not be though without converting to some type of Int
cyberarm has quit [Ping timeout: 268 seconds]
cyberarm has joined #crystal-lang
<FromGitter> <j8r> @bew yes I need to try it soon. I'm working on an installer for server apps, that will have an API in the future to modify their configuration, install, remove etc
<FromGitter> <j8r> What worries me is the configuration format pf .nix files – they aren't simply parsable. They may provides bindings, though
<FromGitter> <j8r> Another thing is I don't know if system users share the library packages, and if I can install the same package X time
<FromGitter> <j8r> (Like installing N wordpress). I need to try all of this soon
<FromGitter> <mavu> @j8r Why do you need an installer for server apps? Why not use the systems package manager? Build a debian package for example and use the existing infrastructure.
<FromGitter> <j8r> @mavu because debian packages only works on debian. They can't be installed multiple times. They are system-wide by default
<FromGitter> <j8r> For now my install handle the creation of a dedicated user, the configuration through an unified CLI (`port=3000 name=mygiteaserver`)
<FromGitter> <j8r> Little change is required to support BSD and MacOS too.
<FromGitter> <j8r> The project is https://github.com/DFabric/dppm
<FromGitter> <j8r> The goal is to be a light alternative tohttps://alternativeto.net/software/yunohost/
jemc has quit [Ping timeout: 240 seconds]
<FromGitter> <mavu> Ahh. i see.
<FromGitter> <j8r> for now everything is statically-linked
RX14 has joined #crystal-lang
ashirase has quit [Ping timeout: 272 seconds]
ashirase has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron- has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <j8r> oprypin, what do you think now of the API? https://github.com/j8r/exec.cr#usage-examples
<FromGitter> <j8r> I'm thinking about opening an RFC in crystal issues
ternarysolo has joined #crystal-lang
<mps> j8r: could that be used to 'self exec'? i.e. running app start self again
<mps> I'm working on graceful restart app and trying to find elegant solution
<FromGitter> <j8r> like https://crystal-lang.org/api/master/Process.html#exec%28command%3AString%2Cargs%3Dnil%2Cenv%3AEnv%3Dnil%2Cclear_env%3ABool%3Dfalse%2Cshell%3ABool%3Dfalse%2Cinput%3AExecStdio%3DRedirect%3A%3AInherit%2Coutput%3AExecStdio%3DRedirect%3A%3AInherit%2Cerror%3AExecStdio%3DRedirect%3A%3AInherit%2Cchdir%3AString%3F%3Dnil%29-class-method ?
<FromGitter> <j8r> no, this lib is just a thin elegant wrapper around `Process.new`
<FromGitter> <j8r> I'm finding Process.new, Process.run and Process.run &block confusing.Internally, their logic are more/less duplicated
<mps> eh, looked there but missed self.executable_path
<mps> that is what I need. thanks for hint
<FromGitter> <j8r> They are not easy to use because if we want to put the result in a string, we have to create a `IO::Memory.new` and pass it as stdout argument
<FromGitter> <r00ster91> why not `String::Builder.new`?
<FromGitter> <j8r> The point is we have to pass something
<FromGitter> <j8r> this isn't just `result=$(ls /tmp)`
<FromGitter> <j8r> Personally I also confuse .run and .new :/
<jokke> rkeene: you don't use base16 by any chance?
<jokke> i have a problem with gotty (and also asciinema) messing up the colors in vim
<rkeene> base16 ?
<rkeene> jokke, If your colors are messed up then maybe TERM is being mangled ?
<rkeene> jokke, Make sure you have LANG=en_US.UTF-8 (or equiv.) and TERM=xterm-256color
<rkeene> jokke, Any info on TERM and LANG fixing your gotty issue ?
<jokke> gotta look at it later
ternarysolo has quit [Ping timeout: 268 seconds]
jemc has joined #crystal-lang
jemc has quit [Client Quit]
DTZUZO_ has joined #crystal-lang
<jokke> rkeene: didn't help
<rkeene> Can you show me an example ?
<FromGitter> <vivus-ignis> hi! anyone using openssl with static builds? i'm having this ⏎ `Unhandled exception: SSL_connect: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed (OpenSSL::SSL::Error)` ⏎ when crest tries to get an https endpoint
<FromGitter> <vivus-ignis> i'm building statically on alpine with openssl 1.0.2
<FromGitter> <vivus-ignis> openssl is built from source
<FromGitter> <Prutheus> Hello. I wanna mmap a file in crystal. I tried this: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ but how to print the content of the `map` pointer now? with .value, I just get a nil back ... [https://gitter.im/crystal-lang/crystal?at=5c50849eca428b0645203d8e]
<rkeene> Maybe `mmap()` is failing ? Check errno ? Maybe `file` failed, or isn't a valid file descriptor ?
rohitpaulk has joined #crystal-lang
<FromGitter> <Prutheus> I get back a pointer, but its value is nil
rohitpaulk has quit [Ping timeout: 245 seconds]
g- has quit [Quit: leaving]
eisque has joined #crystal-lang
<eisque> Heyo
<eisque> have a /cmds directory with commands in the module Commands. What will be the best way to load them all into a hash map.
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <r00ster91> it was Discord-related, he already got his answer
<FromGitter> <Blacksmoke16> 👍
eisque has quit [Quit: Page closed]
<FromGitter> <Prutheus> can anybody please still help me?
<FromGitter> <franciscoadasme> hi everyone, could anyone explain to me why the following multiple chained nil check does not restrict the types after the first one:
<FromGitter> <Blacksmoke16> ehh sorry, i know pretty much nothing about pointers and C :/
<FromGitter> <franciscoadasme> hey everyone, could anyone explain why chained nil checks do not restrict the types in a guard clause except for the first check? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Here only `a` is restricted to `Int32` [https://gitter.im/crystal-lang/crystal?at=5c50bff854f21a71a1c80ec2]
<z64> @Prutheus aren't you throwing the pointer away? mmap doesn't return a pointer, if i'm reading this right http://man7.org/linux/man-pages/man2/mmap.2.html, so nil would be expected
<z64> you need to pass it a pointer for it to write into of `length` size. then you could read from that memory later
<z64> or `Pointer.null` i guess, if you want the other behavior
<FromGitter> <asterite> @franciscoadasme probably a compiler bug or enhancement. It works if you move the assignments out of the `if` (which is probably a bit clearer too)
<FromGitter> <franciscoadasme> I'm aware that it works if I use `if ... end`instead, but I've encountered some cases where this leads to deep nested `if`s, in which case I rather use guard clauses like the above
<Yxhuvud> @fransicoadasme: Perhaps you can turn your if statements around and do early returns instead of deep nesting?
<FromGitter> <franciscoadasme> That's my idea... but I'd like to check several variables in one guard clause instead of doing one per each variable (I'd have many consecutive returns), but it doesn't work right now
<FromGitter> <Blacksmoke16> what about `((a = ary[0]?) && (b = ary[1]?) && (c = ary[2]?)) ? a + b +c : nil`
DTZUZO_ has quit [Quit: WeeChat 2.0]
DTZUZO has joined #crystal-lang
moei has quit [Quit: Leaving...]
<FromGitter> <franciscoadasme> Regardless of which is your preferred style to do such thing, the important point is that `return unless (a = foo) && (b = foo)` should restrict `a` and `b` to be not nil and it's currently not working
<FromGitter> <franciscoadasme> thanks for the ideas... I'll see how to apply them to my code
<FromGitter> <Blacksmoke16> Also worth looking if you can do the check further up in the code