<raz>
hrmpf. i want to keep liking lucky. really do. but the verbosity is getting on my nerves.
<raz>
ops, actions, queries, all in separate files. it's kinda good. but also nauseating.
<FromGitter>
<Blacksmoke16> 😬
<FromGitter>
<lbarasti> @tenebrousedge Relief! Defining the record outside the class - at the cost of having to make the record itself parametrised - does the trick. E.g. the following works ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e34c6bf15941335584b9cb8]
<FromGitter>
<tenebrousedge> @lbarasti neat
<FromGitter>
<lbarasti> even defining the record *inside* the class and with the type parameters works. OK, I'm going to bed. Night!
<FromGitter>
<rurounijones_gitlab> Is there a nice easy way I am missing to merge two hashes together where one has symbol keys and one has string keys
<FromGitter>
<tenebrousedge> hash#merge can take a block argument
<FromGitter>
<tenebrousedge> hmm, but that might not get you where you want
<FromGitter>
<tenebrousedge> you might have to do `transform_keys(&.to_s)`
<FromGitter>
<rurounijones_gitlab> Ah right, yeah that looks close'ish
_ht has quit [Ping timeout: 248 seconds]
DTZUZU has quit [Quit: WeeChat 2.7]
_ht has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
DTZUZU has joined #crystal-lang
Dreamer3 has joined #crystal-lang
fauno has quit [Ping timeout: 272 seconds]
<FromGitter>
<rurounijones_gitlab> Probably basic question but I cannot figure this out ⏎ ⏎ How do I declare the first result so that I can reference it in the block and in the return ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e35863ad9895b17c3c5952c]
<FromGitter>
<Blacksmoke16> result = nil
<FromGitter>
<rurounijones_gitlab> won't that cause issues with having a union of tuple and the actual type
<FromGitter>
<Blacksmoke16> Or could just not use the block, doing what the block does is easy enough
<FromGitter>
<rurounijones_gitlab> tuple and Nil rather
<FromGitter>
<Blacksmoke16> Compiler might be smart enough to know it gets overridden
<FromGitter>
<rurounijones_gitlab> Yea, compiler is now complaining about casting Nil
<FromGitter>
<Blacksmoke16> I'd just not use the block then
<FromGitter>
<straight-shoota> The compiler doesn't know if the block is actually invoked.
<FromGitter>
<straight-shoota> Because `yield` might be guarded by some condition
<FromGitter>
<straight-shoota> If you know the block is certainly going to be invoked (as is the case with `Time.measure`), you could assign `result = nil` and later `return result.not_nil!`.
<FromGitter>
<straight-shoota> That doesn't look very nice, though. So it's probably just easier to not use the yielding `Time.measure` and implement it's behaviour directly. It's really trivial. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e3589b7ea9ba00b84a626f4]
<FromGitter>
<rurounijones_gitlab> Righto
OvermindDL1 has quit []
OvermindDL1 has joined #crystal-lang
<FromGitter>
<rurounijones_gitlab> I saw a blog post about profiling crystal on mac OSX. Anyone done it on Linux?
<FromGitter>
<tenebrousedge> it's about the same, usually
<FromGitter>
<tenebrousedge> but writing good benchmarks is somewhat tricky
early has quit [Quit: Leaving]
early has joined #crystal-lang
sagax has quit [Remote host closed the connection]
duane has joined #crystal-lang
sagax has joined #crystal-lang
<FromGitter>
<andrewc910> Is there a way to connect icr with a database? Something similar to rails console?
<FromGitter>
<andrewc910> Or load up granite for orm queries?
<FromGitter>
<Blacksmoke16> i doubt it
<FromGitter>
<Blacksmoke16> could always just run a file thats like `pp User.find ...`
<FromGitter>
<lbarasti> @rurounijones_gitlab I was looking into it last week, I couldn't find anything specific to crystal. Seems like the best shot is to use an LLVM profiling tool. Will let you know if I try one with success
<FromGitter>
<tenebrousedge> @Blacksmoke16 icr allows you to require files, though. Couldn't you just require your user model, or some other bootstrap file, and go from there?
<FromGitter>
<Blacksmoke16> i suppose? im just under the assumption icr isnt really good
<FromGitter>
<Blacksmoke16> since it would have to recompile everything on every change
<FromGitter>
<tenebrousedge> I think it has some sort of caching, but it does mean that time-based queries behave strangely
<FromGitter>
<andrewc910> @Blacksmoke16 ill play around. Thanks
<FromGitter>
<andrewc910> @tenebrousedge Thats what i am hoping. Just require my models folder and queries should work. ICR is building rn.
<FromGitter>
<Blacksmoke16> probably related to some issue with virtual types since `Response` is not abstract
<FromGitter>
<andrewc910> IT WORKS! Requiring models isn't the way to go. Requiring 'config/applicaion' loaded up amber, granite, and all the amber files. Works fine albeit a bit slow because each command requires all the files again
<FromGitter>
<Blacksmoke16> prob some fancy terminal stuff
<FromGitter>
<Blacksmoke16> write background color and handle key press then rerender the view updating the selected item?
<FromGitter>
<oren> @Blacksmoke16 are you talking to me? do you have any examples or something similar that can help me getting started? i am a crystal newb
<FromGitter>
<Blacksmoke16> i do not sorry :/
<FromGitter>
<oren> is it simple puts statements?
<FromGitter>
<Blacksmoke16> tbh i have no idea, i dont know much about it
<FromGitter>
<Blacksmoke16> that was just my guess :p
<FromGitter>
<oren> maybe something like this? puts "#{"Javascripting".colorize(:white).on(:blue)}"
<FromGitter>
<Blacksmoke16> maybe? would have to try it
<FromGitter>
<oren> the question is how do i use the arrows to move between the options and how to listen to the enter key and pick on option
<FromGitter>
<Blacksmoke16> the underlying code is probably listening for key presses and keeping track which option is currently "selected" and just changing the style of that item
<FromGitter>
<Blacksmoke16> i.e. given an array of choices the first would be selected, pressing down arrow would make the 2nd item selected
<FromGitter>
<Blacksmoke16> increment an index
<FromGitter>
<oren> ok. so listen to up, down, and enter
<FromGitter>
<oren> i also need to maintain state somewhere. each line represent a task and if you completed it, it shows 'complted'
<FromGitter>
<andrewc910> So how can an actual repl work for compiled languages? Icr recompiles after each command so it's pretty slow. How does C-repl solve this problem? I imagine compiling the one line and injecting the new asm into the previously compiled binary?
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<j8r> or reimplement the language as interpreted
<FromGitter>
<andrewc910> Oh man that one sounds difficult
<FromGitter>
<j8r> it seems Dart does it (not sure)
<jhass>
Dart has a VM
<FromGitter>
<j8r> there is a compiled mode, right?
<jhass>
well I guess the binaries still ship a runtime that effectively runs a VM
<jhass>
it's pretty impossible to implement the dynamic typing it has otherwise I think
<jhass>
but there's surprisngly sparse documentation on all of that, yeah
<FromGitter>
<j8r> There is "Ahead-of-time compiled" and "Native", but it may both reference to compiling to bytecodes and not to a binary
<FromGitter>
<straight-shoota> @Blacksmoke16 Yeah, probably. But I won't bother about it right now. IIRC there's going to be a new release for bdwgc in not-so far future which will just solve this issue when it's applied in apk.
_ht has quit [Quit: _ht]
<FromGitter>
<Blacksmoke16> Okey dokey
<FromGitter>
<Blacksmoke16> would the `0.32.1` image be rebuilt after that then?
<FromGitter>
<Blacksmoke16> otherwise it's just always going to be broken for MT
<FromGitter>
<Blacksmoke16> or any other image built before it was released upstream
<FromGitter>
<oren> how to detect that the enter key was pressed? i copy pasted from an example that had up and down but not enter. for example, 'up' was "\e[A", "w"
<FromGitter>
<straight-shoota> > would the `0.32.1` image be rebuilt after that then? ⏎ ⏎ No. 0.32.1-alpine is based on alpine 3.11 and that should not change. Updated bdwgc would probably be in 3.12 but before that we're likely having a couple Crystal releases as well.
<FromGitter>
<Blacksmoke16> :/
<FromGitter>
<Blacksmoke16> fair enough
<FromGitter>
<straight-shoota> As soon as the new bdwgc lands in edge, we might consider adding that, though
<FromGitter>
<straight-shoota> You can install apk packages from different release branches
<FromGitter>
<straight-shoota> Probably not in the official Dockerfile, but it would be a oneliner to add it in a custom one
<FromGitter>
<Blacksmoke16> would be nice to apply the patch until that happens tho no, esp if its going to be a "few crystal version" away
<FromGitter>
<straight-shoota> Using the package from edge is much easier than building it manually.
<FromGitter>
<Blacksmoke16> fair enough
<FromGitter>
<straight-shoota> And I suppose it's going to be in edge "soon"
<FromGitter>
<straight-shoota> If I'm not mistaken, the word was bdwgc release might happen in the next weeks
<FromGitter>
<oren> does anyone know how to detect enter key?
<FromGitter>
<Blacksmoke16> try googling it?
<FromGitter>
<tenebrousedge> > 13 (carriage return, CR, \r, ^M), moves the printing position to the start of the line, allowing overprinting. Used as the end of line marker in Classic Mac OS, OS-9, FLEX (and variants). A CR+LF pair is used by CP/M-80 and its derivatives including DOS and Windows, and by Application Layer protocols such as FTP, SMTP, and HTTP.
<FromGitter>
<tenebrousedge> so enter should have the value 13
<FromGitter>
<oren> my question is where does it say that you need to capture `\r`?
<FromGitter>
<tenebrousedge> > Keyboards also typically have a few single keys which produce control character codes. For example, the key labelled "Backspace" typically produces code 8, "Tab" code 9, "Enter" or "Return" code 13 (though some keyboards might produce code 10 for "Enter").