ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.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
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
alex`` has quit [Ping timeout: 240 seconds]
sp3ncer has joined #crystal-lang
sp3ncer has quit [Client Quit]
_whitelogger has joined #crystal-lang
return0e has quit [Remote host closed the connection]
_whitelogger has joined #crystal-lang
return0e has joined #crystal-lang
ur5us has joined #crystal-lang
_ht has joined #crystal-lang
_whitelogger has joined #crystal-lang
MasterdonX has quit [Quit: ZNC 1.7.4 - https://znc.in]
MasterdonX has joined #crystal-lang
<FromGitter> <kingsleyh> hello - for the db api - query("select * from table where id in (#{list}})") works where list is "v1,v2,v3" etc - but passing query("select * from table where id in (?)", [v1,v2]) says list is unsupported here - and if I use the string I was using in the first version - the statement returns everything
<FromGitter> <kingsleyh> I guess passing an array to query is not supported
<FromGitter> <kingsleyh> but I guess for this type of query you have to use string interpolation instead of the ? approach
alex`` has joined #crystal-lang
ur5us has quit [Ping timeout: 268 seconds]
<sorcus> Hi all.
<sorcus> Little question... https://gist.github.com/MrSorcus/bf0cd260f0a3a4f3133675c378d156f4 - is there another way to receive some data by `identifier` from channel?
Groogy has joined #crystal-lang
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e2c2a31183449313bd6003b]
<FromGitter> <grkek> has anyone ran into this kind of a thing before ?
<FromGitter> <grkek> I am trying to do a JSON mapping with an object
<FromGitter> <grkek> when I encode it to jwt it works
<FromGitter> <grkek> but it doesn't work the other way
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e2c2aa4e177666195c79575]
<FromGitter> <grkek> Might be probably because of that
<FromGitter> <grkek> Nice I got it working
<FromGitter> <grkek> -_-
<FromGitter> <grkek> No one said that the JWT library automagically converts your things into json
_whitelogger has joined #crystal-lang
alexherbo2 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Quit: Ping timeout (120 seconds)]
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> @grkek i approved that PR, still need someone else to approve it tho
rohitpaulk has quit [Ping timeout: 265 seconds]
alexherbo21 has joined #crystal-lang
alex`` has quit [Ping timeout: 268 seconds]
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo21 is now known as alexherbo2
alex`` has joined #crystal-lang
<FromGitter> <Blacksmoke16> actually, you have CI setup but no specs. Would be nice to add some specs/sample project to make sure its working as intended
<FromGitter> <grkek> I test it by hand
<FromGitter> <grkek> I dont believe in automation
<FromGitter> <grkek> sorry
<FromGitter> <Blacksmoke16> 😬
<FromGitter> <grkek> I am not super hackerman like
<FromGitter> <grkek> I believe everythin is pretty siccko mode
<FromGitter> <Blacksmoke16> idk how you manage manually testing everything
<FromGitter> <Blacksmoke16> isnt that a pain?
rohitpaulk has joined #crystal-lang
<FromGitter> <grkek> Not really
<FromGitter> <grkek> When you have autism it is not pain at all
<FromGitter> <grkek> it is fun
<FromGitter> <grkek> instead of pain
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> i suppose
<FromGitter> <grkek> Corona virus is comming my dudes
<FromGitter> <grkek> NOTHING MATTERs
<FromGitter> <tenebrousedge> ever play Plague, Inc. ? It's a pretty good time waster
<FromGitter> <tenebrousedge> it models the world (to some degree); your goal is to design a pathogen to kill off the entire world
<FromGitter> <Blacksmoke16> *Madagascar has closed their port*
<FromGitter> <tenebrousedge> yeah, that is obnoxious. And screw Greenland
<FromGitter> <grkek> Yeah I play it a lot
<FromGitter> <grkek> Killed the planet many times
<FromGitter> <grkek> Not obnoxious but clever
<FromGitter> <grkek> For example if I die with corona virus
<FromGitter> <grkek> Ill have grip
<FromGitter> <grkek> alive to stay
<FromGitter> <grkek> I guess
alexherbo27 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo27 is now known as alexherbo2
alex`` has quit [Ping timeout: 268 seconds]
alex`` has joined #crystal-lang
ua_ has quit [Ping timeout: 240 seconds]
alexherbo27 has joined #crystal-lang
ua_ has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo27 is now known as alexherbo2
alex`` has quit [Ping timeout: 260 seconds]
alex`` has joined #crystal-lang
<FromGitter> <j8r> We can name the pathogen "Crystal": *Crystal is taking over the world* :)
<FromGitter> <j8r> I hope this one will spread
<sorcus> :-D
<sorcus> Again... https://gist.github.com/MrSorcus/bf0cd260f0a3a4f3133675c378d156f4 - is there another way to receive some data by `identifier` from channel?
<FromGitter> <j8r> sorcus: other than json?
<sorcus> j8r: I mean if i send some objects to channel, i want to receive one or more back.
<FromGitter> <j8r> how do we know how much?
<FromGitter> <j8r> if 4 objects are sent, do we expect 4 to be received back?
<sorcus> j8r: Did you see the code? I'm sorry I'm not explaining it well. :-( :-( :-(
<sorcus> j8r: Yes, i think all objects must be received.
<FromGitter> <j8r> yes I have seen the code sorcus
<FromGitter> <j8r> I think a counter can be used then
<FromGitter> <j8r> incremented for each new object sent
alexherbo28 has joined #crystal-lang
<FromGitter> <j8r> then receiving `i.times do { chan.receive }`
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo28 is now known as alexherbo2
alex`` has quit [Ping timeout: 265 seconds]
alex`` has joined #crystal-lang
<sorcus> j8r: Hm... I'm not sure it can be useful for me. Because objects getting from websocket....
<FromGitter> <j8r> perhaps `while obj = chan.receive?`
<FromGitter> <j8r> every time an object is received, it will loop again and wait
<sorcus> j8r: Yes, this is what i done currently. See line#7. But i'm worried that is not a good code.
<FromGitter> <j8r> not really
<FromGitter> <j8r> it is done more in a more complicated way
<FromGitter> <j8r> I'm thinking
<sorcus> j8r: In a short way i want to send some object to web socket and get response for them. But server can return any object in any time. Not only for my request.
<FromGitter> <j8r> ok
<FromGitter> <j8r> don't know :/
<sorcus> j8r: Code on gist works as expected (i think). But not sure. :-D
<sorcus> j8r: Maybe i should to find JSON-RPC implementation on crystal as example.
<sorcus> j8r: https://github.com/Papierkorb/json_rpc - haha, there is no websocket implementation... X-)
<sorcus> j8r: Anyway thank you so much for discussion.
<FromGitter> <j8r> np sorcus - I haven't done anything ^^'
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
ur5us has joined #crystal-lang
fauno has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
<FromGitter> <Daniel-Worrall> @grkek the benchmarking suite you integrated into is automated testing though
<FromGitter> <oren> is it possible to write nice CLI app with crystal? similar to https://github.com/workshopper/workshopper ?
<FromGitter> <tenebrousedge> possible? Sure
<FromGitter> <tenebrousedge> there may be some useful things here https://github.com/veelenga/awesome-crystal#cli-builders
<FromGitter> <oren> Thank you!
<FromGitter> <oren> @tenebrousedge do you know what is that nice blue interface?
<FromGitter> <tenebrousedge> I have no real knowledge of such things, but I would assume that it's whitespace with a background color (https://misc.flogisoft.com/bash/tip_colors_and_formatting) set
<FromGitter> <oren> Thank you
alexherbo29 has joined #crystal-lang
HumanGeek has joined #crystal-lang
alex`` has quit [Ping timeout: 260 seconds]
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo29 is now known as alexherbo2
alex`` has joined #crystal-lang
ur5us has quit [Ping timeout: 268 seconds]
Human_G33k has quit [Ping timeout: 260 seconds]
<FromGitter> <oren> I want to build a CLI. Is there a guide/tutorial that teach me the basics of modules, classes, and code organization?
<FromGitter> <tenebrousedge> probably not. What do you want the CLI to do?
<FromGitter> <oren> I am looking at this codebase for inspiration: https://git.sceptique.eu/Sceptique/todo
<FromGitter> <oren> I want to build a personal coach. Let me show you an example of usage.
<FromGitter> <tenebrousedge> the comment here (https://git.sceptique.eu/Sceptique/todo/src/branch/master/src/todo.cr#L4) explains that it is using bad practices
<FromGitter> <tenebrousedge> which is correct
<FromGitter> <oren> interesting!
<FromGitter> <tenebrousedge> you should probably read a file at either runtime or compile-time, depending on what you want the behavior to be
<FromGitter> <oren> so i want to be able to ask my coach for a few tips around getting stronger, learning to dance cuban salsa, and learn to surf
<FromGitter> <oren> at first i am ok with a very basic coach. everything in one file. later on i would like to have a file per domain. surfing tips on it's own file. salsa dance on it's own etc.
<FromGitter> <oren> the filst thing i believe i should do is `crystal init app coach`
<FromGitter> <tenebrousedge> this (https://git.sceptique.eu/Sceptique/todo/src/branch/master/src/todo.cr#L30-L32) should probably be handled by a method that accepts ARGV as an input
<FromGitter> <oren> since it looks like it create a structure for me
<FromGitter> <oren> but i don't know where to continue after the init command. I do have ruby experience.
<FromGitter> <oren> but i need a refresher on proper folder structure and modules.
<FromGitter> <tenebrousedge> the rest of that library looks fine from a structural standpoint
<FromGitter> <oren> i noticed that the init command created a module Coach inside coach.cr
<FromGitter> <oren> but the todo app doesn't have module in the todo.cr file
<FromGitter> <oren> so i am curious, do i need a module?
<FromGitter> <oren> basically how do i start building a proper CLI?
<FromGitter> <oren> i don't want to copy random code that might not be great, like you pointed earlier with the 'dirty' line
<FromGitter> <tenebrousedge> you should do all of your "work" inside a module. The entry point can do things like load configuration files. It's okay for it to set a version number as well: ⏎ ⏎ ```module Todo ⏎ VERSION = "0.1.0" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e2cc55401914e3e044afeb3]
<FromGitter> <Blacksmoke16> It's a good practice to namespace your code, so I'd keep the module
<FromGitter> <tenebrousedge> or you can do ⏎ ⏎ ```require "./version"``` [https://gitter.im/crystal-lang/crystal?at=5e2cc572183449313bda1942]
<FromGitter> <tenebrousedge> the entrypoint should do the minimum necessary to hand off execution to the rest of the code
<FromGitter> <oren> i have an empty git repo i want to dedicate for this project. `crystal init app coach` created another folder with git project inside. so now i have coach/coach folder structure (:
<FromGitter> <oren> sounds a bit convoluted.
<FromGitter> <oren> what am i doing wrong?
<FromGitter> <oren> also why does the init command create a git repo?
<FromGitter> <oren> i already have one so it's redundant and confusing
<FromGitter> <tenebrousedge> `crystal init app coach .`
<FromGitter> <oren> yes!!
<FromGitter> <oren> i have a bot that spits "I am your coach!"
<FromGitter> <j8r> What's the point of `VERSION = "1.2.3"`?
<FromGitter> <Blacksmoke16> Main thing I can think of is it allows you to support multiple versions of your application
<FromGitter> <j8r> how?
<FromGitter> <Blacksmoke16> I.e macros to check on what version is installed and conditional logic
<FromGitter> <Blacksmoke16> Since constants can be accessed at compile time
<FromGitter> <j8r> of a library you mean?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Crystal/Macros.html#compare_versions(v1:StringLiteral,v2:StringLiteral):NumberLiteral-instance-method
<FromGitter> <j8r> ok, but what's the point for an aplication, not a library?
<FromGitter> <Blacksmoke16> Could be used in logging etc
<FromGitter> <Blacksmoke16> Just as an easy way to represent the current version of the app without having to update it in multiple places
<FromGitter> <j8r> but if git tags are used, better using the `git` command inside a macro
<FromGitter> <j8r> I have seen a lot of `VERSION` not updated in libraries
<FromGitter> <j8r> I suspect being a gemfile convention?
<FromGitter> <Blacksmoke16> Keeps it agnostic of version control
<FromGitter> <Blacksmoke16> Dunno
<FromGitter> <Blacksmoke16> I've also seen it in a file
<FromGitter> <tenebrousedge> I love git. I don't generally think my code should care that I'm using it
<FromGitter> <j8r> having it in multiple locations is error prone BTW
<FromGitter> <Blacksmoke16> Right, which is why it's a constant
<FromGitter> <j8r> it's good to have also the build commit in applications
<FromGitter> <j8r> this way we know exactly what version is used
<FromGitter> <j8r> or flavor we could say
<FromGitter> <j8r> @Blacksmoke16 I mean, this constant may be missed to be updated after a release
<FromGitter> <Blacksmoke16> Probably
<FromGitter> <j8r> generally, applications I have compiled used `git` to add more info if available, but were able to compile without
<FromGitter> <Blacksmoke16> Is up to the owner to do it correctly
<FromGitter> <j8r> (like the crystal compiler)
<FromGitter> <j8r> yep
<FromGitter> <oren> does anyone play with this library? https://github.com/agatan/ncurses.cr I see no output when i run any of the examples
<raz> hm, how do i do a greater_than test with crystal spec?
<raz> should i just do (a > b).should be_true
<FromGitter> <tenebrousedge> that seems like a thing
<raz> one day someone needs to explain to me what the advantage of this DSL nonsense in testing is supposed to be :(
<raz> i never understood it in rails already. for me it just constantly gets in the way
<FromGitter> <tenebrousedge> Spectator has other matchers https://gitlab.com/arctic-fox/spectator
<raz> yea but frankly, if i'm to switch away from stock spec, i'd prefer to switch to something simpler, rather than something even more magical
<FromGitter> <Blacksmoke16> You can do like
<FromGitter> <Blacksmoke16> 1) should be > 5
<raz> i like the describe/before/after scoping. but for the tests itself, i wish i could just do plain older "assert <expression>"
<FromGitter> <tenebrousedge> well, you can
<raz> oh, it works!
<raz> ah, crystal has assert?
<FromGitter> <Blacksmoke16> No
<raz> well, i don't really want to divert from the beaten path too far either. then my tests will look different from everyone elses and i get mocked :<
<raz> i'm just tired of never remembering if it's should be_nil, should be nil, should_be(nil) or whatnot
<FromGitter> <tenebrousedge> `assert` is a one-liner, and I really doubt you would get mocked
<raz> right, i may look into that
<FromGitter> <Blacksmoke16> There's an issue for it
<raz> i assume you mean just make a helper method for it?
<FromGitter> <tenebrousedge> sure
<FromGitter> <tenebrousedge> ```def assert(a, b) ⏎ a == b or raise # or fail, or whatever ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e2cd1d3183449313bda6270]
<raz> yeh, maybe i'll try that when i get annoyed enough
<raz> it could be worse. at least it's not cucumber :p
<FromGitter> <tenebrousedge> D: I like cucumber
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8gfq
<raz> @tene you monster! ;P
<FromGitter> <tenebrousedge> 👹👹👹
* raz still has nightmares from that one rails app...
<FromGitter> <tenebrousedge> the last project I used cucumber with, I taught my non-technical PM how to write useful specs in cucumber
<raz> "yay, testing isn't difficult enough. let's add a whole new layer of bugs and complexity!"
<raz> well ok, i guess that's one way to keep a PM busy so they don't get in the way
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8gg2
<raz> that looks tempting blacksmoke
<raz> oprypin: that looks even more tempting! <3
<raz> Arithmetic overflow (OverflowError)
<raz> that thing when crystal is so fast that in normal spec it works fine. but with --release the instrumentation overflows
* raz not even mad
_ht has quit [Ping timeout: 272 seconds]
_ht has joined #crystal-lang