<FromGitter>
<tenebrousedge> ruby isn't compiled; in Crystal the compiled binary is not going to match the executed filename
<FromGitter>
<watzon> I need an example file to be runnable via `crystal run`, but I also need certain parts to only run if the file itself is being called
<FromGitter>
<watzon> Basically I need a block of code to not be compiled unless the file itself is the file being compiled
<FromGitter>
<Blacksmoke16> can you use flags
<FromGitter>
<watzon> Is there a flag that fits that usecase?
<FromGitter>
<Blacksmoke16> i mean you can define your own
<FromGitter>
<Blacksmoke16> prob less than ideal
<FromGitter>
<tenebrousedge> `crystal run` compiles the file, though, right?
<FromGitter>
<watzon> Yes
<FromGitter>
<watzon> What I'm trying to do though is import a class from one example into another example
<FromGitter>
<watzon> But all the examples also execute a code block, which I want to avoid unless the file itself is the one being compiled
<FromGitter>
<tenebrousedge> if you're convinced there's no way to make that work, I will believe you
<FromGitter>
<tenebrousedge> it certainly seems like it would be required to patch the compiler if you didn't want to test whether the constant was already defined in every file
_whitelogger has joined #crystal-lang
chemist69 has quit [Ping timeout: 252 seconds]
duane has quit [Ping timeout: 246 seconds]
chemist69 has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
hightower3 has quit [Ping timeout: 245 seconds]
_whitelogger has joined #crystal-lang
<FromGitter>
<bararchy> @bcardiff I mean `snaps install crystal` etc.. inside a docker won't work, it needs al kind of hacks to work (it needs a daemon running, etc..)
chachasmooth_ has joined #crystal-lang
chachasmooth has quit [Ping timeout: 250 seconds]
ht_ has joined #crystal-lang
alex``` has joined #crystal-lang
blassin has joined #crystal-lang
ht_ has quit [Quit: ht_]
hightower3 has joined #crystal-lang
DTZUZO has quit [Ping timeout: 245 seconds]
alex``` has quit [Ping timeout: 245 seconds]
alex``` has joined #crystal-lang
alex``` has quit [Ping timeout: 244 seconds]
alex``` has joined #crystal-lang
<FromGitter>
<j8r> Snap kinda sucks for this
<FromGitter>
<j8r> appimage as far as I know doesn't need a runtime, it's optional
<FromGitter>
<Blacksmoke16> got ci running ameba, formatter and latest/nightly specs
<FromGitter>
<Blacksmoke16> that runs on all non master branches
<FromGitter>
<Blacksmoke16> then deploys api docs when merged into master
<FromGitter>
<Blacksmoke16> kinda dont like it fails the checks when nightly fails, but is good to know something breaking is coming
<FromGitter>
<Blacksmoke16> didnt make it required so is np if it fails when doing a pr
DTZUZO has joined #crystal-lang
sorcus has quit [Ping timeout: 264 seconds]
alex``` has quit [Ping timeout: 245 seconds]
alex``` has joined #crystal-lang
companion_cube has joined #crystal-lang
<companion_cube>
hello, I'm interested in crystal as a kind of clean, typed scripting language (I hate python more and more). Seems like a lot of interesting ideas.
<FromGitter>
<tenebrousedge> what do you need in a scripting language?
<companion_cube>
mostly, unix stuff: file manip, subprocesses, this kind of stuff. `spawn` looks pretty good for that.
<companion_cube>
(also, good tooling, mypy is … not perfect)
sorcus has joined #crystal-lang
<FromGitter>
<Blacksmoke16> Easiest way would be to just give it a go and try it out
<companion_cube>
yep :)
<FromGitter>
<tenebrousedge> icr is pretty workable as a REPL, but not perfect. `crystal play` is a really nice command
<companion_cube>
I just discovered that indeed
<companion_cube>
does the vim extension automatically install the code analyser? seems like goto-def works
<FromGitter>
<Blacksmoke16> No idea
<companion_cube>
unrelatedly, is there a roadmap to 1.0, or is it in the distant future?
<companion_cube>
ah, no, specific tool for `implementations`.
<FromGitter>
<tenebrousedge> weird how links work differently for issues
<FromGitter>
<vlazar> how do I write from `Slice` to smaller `Slice`? ⏎ ⏎ I'm using `rest.copy_from(chunk.to_unsafe, last_bytes_count)`
<FromGitter>
<vlazar> where `chunk` is like `4096` bytes and `rest` if for last piece of data I need to write to file
<FromGitter>
<vlazar> I don't like to use `chunk.to_unsafe`
<FromGitter>
<dscottboggs_gitlab> it looks like you're trying to copy from a smaller slice to a bigger one, not the other way around... when dealing with slices, you need to ensure `rest` is large enough to hold the copied data before performing the copy
<FromGitter>
<dscottboggs_gitlab> the requirement to call `#to_unsafe` is a reminder that that action *is* unsafe, and you need to check to make sure you can do it before you do it
<FromGitter>
<dscottboggs_gitlab> It'd be nice if there were a standardized way to move rest into the new slice though :/
<FromGitter>
<SewerynKaminski> I have some strange results in my benchmark. I test 3 functions one regular, one optimised and one optimised+. The first two plays nicely times are always the same regular one are slow and optmised are fast. But optimised+ give incredible short times or simply short times when I put 'puts' call before benchmark. Are you interested in this? The code is very short and free :)
<FromGitter>
<kingsleyh> hello - I've written this today - it's still very experimental and needs lots of work - but conceptually - it seems to work quite well: https://github.com/SushiChain/spinach
<FromGitter>
<tenebrousedge> @kingsleyh it's written in html?
<FromGitter>
<kingsleyh> yeah you write the test in html
<FromGitter>
<tenebrousedge> that seems strange to me
<FromGitter>
<kingsleyh> it's BDD - which generally has specs written in html, markdown, or plain text
<FromGitter>
<kingsleyh> but I like html - as it's easier to add images and supporting documentation etc
<FromGitter>
<kingsleyh> the idea is you write a document that explains how your system works - and that document is executable
<FromGitter>
<tenebrousedge> the BDD-style testing frameworks I've seen have used a domain-specific language
<FromGitter>
<kingsleyh> yeah some like Cucumber have a DSL
<FromGitter>
<vlazar> I'm want to read in chunks to use little memory and watch progress to show download indicator
<oprypin>
vlazar, cant u do `chunk.copy_to(rest)` instead
<FromGitter>
<vlazar> That's what I've started from actually when I read in the docs it should truncate
<FromGitter>
<vlazar> but the it turned out it was old docs for Crystal 0.20 :S
<FromGitter>
<dscottboggs_gitlab> @vlazar this is a good way to do it, the only improvement I can suggest (which would also remove the `#to_unsafe` call) is to remove the zero-initialization of the new slice by using the block version of `Slice.new`, I.E. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d73e4f750508949d3f3b80a]
<FromGitter>
<dscottboggs_gitlab> this initializes the slice with values from `chunk` rather than zeroing it so it will be faster
<FromGitter>
<dscottboggs_gitlab> `(chunk + idx).value` is the same as saying `*(ptr + offset)` in `C` if you're familiar
<companion_cube>
wondering if there's a natural encoding of sum types, but seems like the main AST uses inheritance (as in scala, in a way)
<FromGitter>
<Blacksmoke16> that should work
<FromGitter>
<watzon> @companion_cube, I'm sorry for what I did to you in Portal
<FromGitter>
<watzon> GladOS gave me no choice
<companion_cube>
you're forgiven ;)
<companion_cube>
it burns though :o
<FromGitter>
<dscottboggs_gitlab> @SewerynKaminski you were running into some optimizations. The "puts" call made it so that the values you were looking at were not optimized away.
HumanGeek has quit [Read error: Connection reset by peer]
<FromGitter>
<dscottboggs_gitlab> Zero times for benchmarks come from something being precalculated at compile-time
<FromGitter>
<SewerynKaminski> @dscottboggs_gitlab So, in debug mode this shouldn't happen? I have to check it
<FromGitter>
<dscottboggs_gitlab> Not sure if that will prevent it, but you want to run benchmarks in release mode anyway.
<FromGitter>
<dscottboggs_gitlab> best way I can think of to avoid that off of the top of my head (which works well since you're dealing with strings and slices) is to write them to /dev/null
<companion_cube>
it's also weird that IO isn't split into a reader and writer part
<companion_cube>
(sorry for the stream of consciousness)
<FromGitter>
<Blacksmoke16> you mean like https://crystal-lang.org/api/master/IO.html#pipe(read_blocking=false,write_blocking=false):Tuple(IO::FileDescriptor,IO::FileDescriptor)-class-method ?
<companion_cube>
I mean, I read that to include the IO module one must define read and write
<FromGitter>
<Blacksmoke16> right
<companion_cube>
otherwise, the iterator-based design and all look super good for scripting/small programs ^^
<FromGitter>
<Blacksmoke16> 👍
_whitelogger has joined #crystal-lang
<companion_cube>
damn, the crirc library seems to fail when `ssl=true` is passed :(
<FromGitter>
<Blacksmoke16> Hm?
<companion_cube>
well, trying my favorite toy program, an IRC bot, and there's a lib for that but it seems to fail :/
chachasmooth_ has quit [Ping timeout: 264 seconds]
<FromGitter>
<Sija> /shameless plug/ for all of u `puts`/`pp`-style debugging fans, I’ve made https://github.com/Sija/debug.cr to make your life in terminal a bit moar colorful! give it a try :)
<FromGitter>
<watzon> Ahh nice
<FromGitter>
<watzon> I like it
<FromGitter>
<watzon> Seeing as we're shamelessly plugging, I've been working on the wiki for my Tourmaline project. Pretty proud of it so far https://github.com/watzon/tourmaline/wiki
<FromGitter>
<Blacksmoke16> how the annotation stuff go
<FromGitter>
<watzon> Awesome. I'm super happy with it
<FromGitter>
<watzon> Annotations allowed me to simplify a lot of things
<FromGitter>
<watzon> And provide a nicer way to add bot commands
<FromGitter>
<watzon> Yeah that was quite a while ago. It needs some updating to match what I've learned in Crystal over the past couple years, but it works :)
<FromGitter>
<watzon> Makes developing bots a lot easier too
<FromGitter>
<Sija> I bet it does :) especially with webhooks
<FromGitter>
<watzon> Yep, that's my #1 usecase haha
<FromGitter>
<watzon> It's why I made it in the first place
<FromGitter>
<Sija> yeah, we use it extensively (ngrok) for the same purpose too at the place were I work atm
<FromGitter>
<Sija> nothin’ works better with local development combined with 3rd party services using webhooks
<FromGitter>
<Sija> btw, is ngrok.cr battle-tested? would it work if I’d to leave it for weeks/months to come?
<FromGitter>
<watzon> It should, it just uses an installed version of ngrok in the background so it should be as reliable as ngrok itself
<companion_cube>
hmmm MatchData.size is the number of captured elements, actually…
<FromGitter>
<Blacksmoke16> can you add a type restriction for a specific module?