ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.22.0 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
bjz has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
sz0 has joined #crystal-lang
<FromGitter> <johnjansen> anyone know how to force docs for private methods
<FromGitter> <paulcsmith> Is there a way to ignore the version and make shards always get the latest commit from master?
<FromGitter> <fridgerator> you can specify `branch: master` in the shard.yml
<FromGitter> <fridgerator> which I *think* is default if you only specify github: link
<FromGitter> <paulcsmith> Ok I'll give that a try. ThanksQ
<FromGitter> <paulcsmith> *!
<FromGitter> <fridgerator> :thumbsup:
chimkan has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
chimkan has quit [Quit: chimkan]
chimkan has joined #crystal-lang
<FromGitter> <codenoid> hi, how to compress / minifying html output in kemal ?
chimkan has quit [Quit: chimkan]
<FromGitter> <codenoid> @sdogruyol @fridgerator
<FromGitter> <johnjansen> ok people, another question, anyone know how to specify the type of a `yield`
<FromGitter> <elorest> proxy through nginx?
<FromGitter> <johnjansen> @elorest i presume you were directing that at @codenoid
<FromGitter> <johnjansen> hows it going BTW?
<FromGitter> <elorest> @johnjansen You guessed right. I’m doign pretty good. How are things going for you?
<FromGitter> <elorest> I’ve mostly just been working on amber and related projects for the last couple months outside of work.
<FromGitter> <johnjansen> great man, very busy … back writing some crystal which is very satisfying
<FromGitter> <elorest> Yeah I really like crystal
<FromGitter> <johnjansen> amber is looking good
<FromGitter> <elorest> Had to go back to go for a couple days last week. Not nearly as much fun.
<FromGitter> <johnjansen> im in the throws of building a custom database with crystal, im pretty happy that i can even attempt that ;-)
<FromGitter> <elorest> Interesting. Just as a challenge or are you actually trying to solve a problem?
<FromGitter> <johnjansen> index all domain names and make them fuzzy searchable … for my day job
<FromGitter> <codenoid> @sdogruyol add to kemal PR please
<FromGitter> <elorest> @codenoid did that help?
<FromGitter> <johnjansen> i was about to say “what PR” and then the comment disappeared
<FromGitter> <johnjansen> ;-)
<FromGitter> <elorest> @johnjansen So basically sphinx in crystal?
<FromGitter> <johnjansen> pretty much … but alot lighter
<FromGitter> <elorest> I wonder how hard it would be to wrap sphinx. I mean it’s written in c++ instead of c.
<FromGitter> <elorest> In ruby I usually just send commands to it’s daemon.
<FromGitter> <codenoid> ` OR compress your response with a handler using Gzip. ` , idk how sir :/ , or catch kemal output, andn modify it, and output is modified
<FromGitter> <johnjansen> yeah i wonder … anyway, this is a thought experiment as much as anything … if i cant make it fast and memory efficient, then ill keep going until i can ;-)
<FromGitter> <elorest> @johnjansen Yeah that sounds pretty fun.
<FromGitter> <codenoid> and sir, how to make a "Read More ..." feature in crystal without use manual looping, like substr in php
<FromGitter> <johnjansen> @elorest you can answer that one
<FromGitter> <elorest> Check `gsub` on `String`
<FromGitter> <codenoid> i think gsub for replacing string sir
<FromGitter> <johnjansen> @codenoid can you please ask your question in a more concrete way
<FromGitter> <elorest> @codenoid Yeah your right. I just saw `substr` and gsub seemed right.
<FromGitter> <codenoid> so i have a string "how to truss a turkey", and i just want to show "how to truss"
<FromGitter> <elorest> Truncate is part of rails instead of ruby. In crystal I can’t seem to find a default method.
<FromGitter> <elorest> This will work though.
<FromGitter> <codenoid> @elorest ok, thanks :+1:
<FromGitter> <codenoid> :smile:
<FromGitter> <codenoid> cool crystal
<FromGitter> <elorest> play.crystal-lang.org is so useful.
<FromGitter> <codenoid> / cool ruby syntax
<FromGitter> <codenoid> @elorest :+1: :sparkles:
<FromGitter> <elorest> @codenoid Did that handler help answer your compression question?
<FromGitter> <codenoid> wait, i'll try
<FromGitter> <codenoid> not work sir, i got same output, un compressed output
<FromGitter> <johnjansen> so you want to minify and compress
<FromGitter> <codenoid> @johnjansen yassss
<FromGitter> <johnjansen> you could look at wrapping something like this https://github.com/deanhume/html-minifier although there may be a common solution im unaware of ...
<FromGitter> <elorest> `context.response.output = Gzip::Writer.new(context.response.output.gsub(/\s/, “”), sync_close: true)`
<FromGitter> <elorest> @codenoid
<FromGitter> <johnjansen> wow now thats agressive ;-)
<FromGitter> <johnjansen> or you could try to port this kind of thing yourself https://github.com/stereobooster/html_press
<FromGitter> <elorest> Hmmmm. Probably a little too far. Probably don’t want to remove all whitespace lol
<FromGitter> <johnjansen> haha … but i loved it
<FromGitter> <johnjansen> its sure minified, although i prefer the following ⏎ ⏎ ```html.gsub(/./, “”)``` [https://gitter.im/crystal-lang/crystal?at=5951e6aa4bcd78af564c7e2b]
<FromGitter> <johnjansen> where’s the fun in that
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <elorest> Do you see any issues with my last one though?
<FromGitter> <johnjansen> i dont think so on the surface, although there *may* be some small formatting issues depending on the actual html being minified
<FromGitter> <johnjansen> it looks pretty good and is certainly what id start with
bjz has joined #crystal-lang
thews_ has joined #crystal-lang
dom96_ has joined #crystal-lang
FromGitter has quit [Ping timeout: 260 seconds]
thews has quit [Ping timeout: 260 seconds]
dom96 has quit [Ping timeout: 260 seconds]
dom96_ is now known as dom96
tatey has quit [Ping timeout: 260 seconds]
FromGitter has joined #crystal-lang
RX14 has quit [Ping timeout: 260 seconds]
olbat has quit [Ping timeout: 260 seconds]
dannyAAM has quit [Ping timeout: 260 seconds]
tatey has joined #crystal-lang
RX14 has joined #crystal-lang
dannyAAM has joined #crystal-lang
olbat has joined #crystal-lang
<FromGitter> <akzhan> It seems that the Changelog is far behind the changes in the Crystal code itself :-)
_whitelogger has joined #crystal-lang
saadq has quit [Ping timeout: 255 seconds]
saadq has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 255 seconds]
cyberarm has quit [Ping timeout: 276 seconds]
cyberarm has joined #crystal-lang
flaviodesousa has joined #crystal-lang
shelvacu has quit [Ping timeout: 276 seconds]
shelvacu has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #4627: Format: fix 4620, fix to format /= after else in case (master...fix/crystal-format/4620-divop-after-case-else) https://git.io/vQZnD
nikkkk has joined #crystal-lang
nikkkk has quit [Client Quit]
<FromGitter> <crisward> I'm getting a crash with `Invalid memory access (signal 11) at address 0x0` Any ideas how I track down what is causing this?
<FromGitter> <crisward> The issues I've found on github don't seem to match what I'm seeing.
<FromGitter> <bew> @crisward can you share more details about the error? Can you share some code? Are you dealing with lib bindings?
Raimondii has joined #crystal-lang
<FromGitter> <straight-shoota> My crystal ball is currently in maintenance, so I'm sorry that I can't tell the cause from the distance ;)
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <crisward> @bew - just kemal. It only seems to be happening on my local vm. Think is may be linked to files be written to a NFS share, as I'm using file sessions.
<FromGitter> <crisward> The full error is - https://gist.github.com/crisward/910ee33a47cdc67af90dadf7476e21f4
<FromGitter> <straight-shoota> NFS seems unlikely
<FromGitter> <crisward> Thats the main difference between local and live, so was my first thought.
<FromGitter> <straight-shoota> The stacktrace points to OpenSSL
<FromGitter> <straight-shoota> What version of openssl do you have on your vm? `$ openssl version`
<FromGitter> <crisward> The code is running inside the Crystal Buildpack. One second I'll enter the container and check. I also know the build uses an older version of llvm. But again these should be identical local and live.
<FromGitter> <crisward> OpenSSL 1.0.1f 6 Jan 2014
<FromGitter> <bew> And local?
<FromGitter> <bew> Does it crashes on startup, after a specific action? Does it crashes with a kemal hello world?
<FromGitter> ... filesystem on the live server may be too quick to replicate this issue.
<FromGitter> <crisward> I have a logout process, which is quickly followed my calling for the user data. The logout returns ok, but then crashes just after. The call for user data returns a 500. I've tried running both of these routes independently and they seem fine. I'm wondering if the session being read, while being written is possibly the cause. I'm probably going to have to script something to recreate this consistently. The
<FromGitter> <straight-shoota> as a side note: if this "live" is a production environment, you should really update openssl. For 3-year-old 1.0.1f there are a number of known vulnerabilities, including heart bleed.
<FromGitter> <straight-shoota> Well, it seems to happen when HTTP::Client creates a POST request over an OpenSSL socket
<FromGitter> <crisward> Not using ssl inside container, my ssl is being proxied outside the container and is up to date. The container is the crystal buildpack which is out of date in many ways, including using llvm 3.5.
<FromGitter> <straight-shoota> Raven is obviously calling an HTTPS request which then utilizes OpenSSL
<FromGitter> <crisward> Ah, just realised, using Raven / Sentry. Pretty sure that's is using SSL.
<FromGitter> <crisward> Pretty ironic if my error tracking is causing the error.
<FromGitter> <crisward> I'll try disabling the error tracking and see what happens.
<FromGitter> <straight-shoota> You're probably gonna see your original exception :D
<FromGitter> <crisward> @straight-shoota thanks for the help. Will let you know what I find...
badeball has joined #crystal-lang
A124 has quit [Disconnected by services]
A124 has joined #crystal-lang
<FromGitter> <crisward> Thinks thats it... it won't crash now. Raven was sending 401's to sentry, so it may have just been that. Not sure why openssl crashes sometimes and not others. Will look to update it in the buildpack and see if the error goes away.
<FromGitter> <straight-shoota> Your welcome =
<FromGitter> <straight-shoota> An HTTP error should not cause an invalid memory access^^
<FromGitter> <straight-shoota> If it still fails with updated buildpack, you should probably open an issue
tatey_ has joined #crystal-lang
dannyAAM has quit [*.net *.split]
tatey has quit [*.net *.split]
hako has quit [*.net *.split]
badeball_ has quit [*.net *.split]
mrus has quit [*.net *.split]
binBASH has quit [*.net *.split]
tatey_ is now known as tatey
dannyAAM has joined #crystal-lang
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
mrus has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
binBASH has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <crisward> Looks like updating openssl in the buildpack is far from simple. Actually using dokku, which doesn't seem to have a updated base buildpack. Trying to do `apt-get install openssl` but getting the same version
<FromGitter> <bew> try to update package database with `apt-get update` ?
<FromGitter> <straight-shoota> or update the distro release
Philpax has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <faustinoaq> Hello crystal community!, I want to share something : https://github.com/kofno/scry/issues/3#issuecomment-311256969
<FromGitter> <faustinoaq> Sometimes crystal generated binaries could be big, but with some tricks and tools it could be *smaller* :smile:
<FromGitter> <bew> what is strip?
<FromGitter> <faustinoaq> strip - Discard symbols from object files.
<FromGitter> <bew> yeah I'm just reading that, but isn't it an issue to remove symbols?
<FromGitter> <akzhan> somebody shows me compiling with custom prelude. It allows to create even smaller binaries.
<FromGitter> <faustinoaq> strip doesn't remove all, it keep just necessary symbols
<FromGitter> <bew> @akzhan weird, I heard that unused code isn't compiled in the binary, so why removing some requires in prelude will make smaller binaries (as it shouldn't be in the binary as not used)
<FromGitter> <faustinoaq> yeah, see https://github.com/kubo39/tinycr
<FromGitter> <bew> wow it's not really crystal anymore x)
<FromGitter> <faustinoaq> But, I really like to code assembler inside crystal, it is a hidden feature :smile:
<FromGitter> <faustinoaq> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59524cc6c101bc4e3a271f60]
<FromGitter> <bew> oO weird syntax for theh arguments of `asm`
<FromGitter> <bew> is there a documentation somewhere about asm in crystal?
<FromGitter> <faustinoaq> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59524dc1ad9c781843a5ad1a]
<FromGitter> <faustinoaq> @bew no documentation yet
<FromGitter> <faustinoaq> but small binaries + fast compile times and good syntax make crystal useful for embed devices
<FromGitter> <faustinoaq> A good documentation for assembler and a shard for this kind of projects would allow to compile crystal with a custom prelude specifying just necessary.
<FromGitter> <faustinoaq> Is a great idea :satisfied:
<FromGitter> <bew> yeah sure, but crystal for embedded devices (like arduino) will need another stdlib!
<FromGitter> <faustinoaq> maybe it would be a *smaller* stdlib
<FromGitter> <bew> maybe!
<FromGitter> <faustinoaq> would be like `mruby` to `ruby`,
<FromGitter> <bew> but thoses embedded devices don't have much spaces for malloc'd data structures, so some core design may need a rework
<FromGitter> <bew> and as some things about the necessary, and initial classes is/are hardcoded in the compiler, either we fork, either (And I much prefere this solution) we allow compiler modules, to modify things like that
<FromGitter> <faustinoaq> not at all: https://github.com/kubo39/tinycr/issues/1
<FromGitter> <faustinoaq> > I was able to get it down to 8602 bytes. I will give you a hint: if you run crystal build a number of options will be shown. One of those options will allow you to not depend on GC, PCRE, etc.
<FromGitter> <faustinoaq> Is like starting from scratch, but without too much work
<FromGitter> <bew> not exactly from scratch, as `Crystal::Program` has some defined classes already, especially there relation to "I'm a reference" and "I'm a Value", but really close to scratch
chimkan has joined #crystal-lang
<FromGitter> <faustinoaq> *defined classes already*, those classes are a reason to choice crystal, simplify all the work when using IR assembler (LLVM)
<FromGitter> <bew> sorry, didn't understood your last message
<FromGitter> <faustinoaq> as you can see :point_up: https://gitter.im/crystal-lang/crystal?at=59524c5cceb5bef82eb6b80d
<FromGitter> <faustinoaq> sorry, my english is not good enough, sometimes I write english thinking in spanish and viceversa :laughing:
<FromGitter> <bew> your english is quite good! my spanish in non existant so it's better than nothing :)
<FromGitter> <bew> your work on vscode is awesome! how did you do the completion part?
<FromGitter> <bew> I'd love to see that kind of stuff for vim/neovim
<FromGitter> <bew> oh didn't though about that x)
<FromGitter> <faustinoaq> Using the source code, regular expressions and time :satisfied:
benner has joined #crystal-lang
<FromGitter> <faustinoaq> but still is a lot of work to do, including submodules, subclases and their methods plus documentation
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter> <bew> I see that you get the type of the word before to get correct completion suggestion, but how do you get the file to compile bad code (`obj.`) to get the type of `obj` ?
<FromGitter> <faustinoaq> yeah, i need to improve the completion algorithm, or implement this using something like https://github.com/TechMagister/cracker
<FromGitter> <faustinoaq> Crystal methods are completes using the type given by `crystal tool context`
<FromGitter> <bew> but do you remove the dot before using the context tool?
<FromGitter> <faustinoaq> Yes, i do, but is it a basic algoritm, doesn't support chain methods no generics
<FromGitter> <bew> nice trick though
rohitpaulk has joined #crystal-lang
<FromGitter> <fridgerator> @faustinoaq nice work on the VS Code plugin, I normally use sublime text but I might have to check this out
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter> <faustinoaq> Yeah, I used to code with sublime text. ⏎ You can install sublime keymap https://marketplace.visualstudio.com/items?itemName=ms-vscode.sublime-keybindings
bjz has joined #crystal-lang
<FromGitter> <kazzkiq> How exactly am I suppose to iterate through a JSON::Any type? I'm fetching a JSON from an endpoint and handle each object in a loop, but got no success on what I've tried so far.
<FromGitter> <kazzkiq> The code: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5952656e57a6e9f72e04cde0]
<FromGitter> <bew> do you know the structure of what you're reading?
<FromGitter> <kazzkiq> Yes
<FromGitter> <bew> You can use JSON.mapping (see: https://crystal-lang.org/api/0.22.0/JSON.html#mapping(properties,strict=false)-macro) example: https://carc.in/#/r/29e2
<FromGitter> <kazzkiq> In the case structure isn't predictable, is there any "generic" way to handle it?
<FromGitter> <bew> From what I see from the link at coinmarketcap, it seems to be quite structured
<FromGitter> <kazzkiq> Got it. Thanks.
Philpax has quit [Ping timeout: 240 seconds]
<FromGitter> <bew> here is a small example how to properly deal with all thoses strings: https://carc.in/#/r/29ed
<FromGitter> <bew> @kazzkiq
<FromGitter> <kazzkiq> Awesome, thanks!
<FromGitter> <kazzkiq> I tried mapping a JSON key that starts with number (`24h_volume_usd`), but it seems to give error. How could I handle those starting with numbers?
<FromGitter> <bew> use a different name for crystal, and specify `your_crystal_key: {type: SomeType, key: "24h_volume_usd"}`
<FromGitter> <bew> also, for the `last_updated`, you'll see that there are some Time converter already available
<FromGitter> <kazzkiq> Perfect. tks
<FromGitter> <schoening> @faustinoaq omg awesome code completion!!!
<FromGitter> <faustinoaq> Thanks! :satisfied:
<FromGitter> <schoening> Man.. crystal code is already short and now completion 😂
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <faustinoaq> Yeah, but help a lot to remind method. VSCode (https://marketplace.visualstudio.com/items?itemName=faustinoaq.crystal-lang) extension still requires a lot of work to support chain methods and generics, also it doesn't have all the stdlib yet. Cracker (https://github.com/TechMagister/cracker) is a lot more advanced for now. I want to include cracker in the extension, but is a bit complicated to work without
<FromGitter> ... using Language Server Protocol See: Scry (https://github.com/kofno/scry)
<FromGitter> <faustinoaq> In the future a full support for LSP (http://langserver.org/) like Scry is doing would be great for the crystal community
<FromGitter> <johnjansen> anyone got any insight into this https://carc.in/#/r/29fb esp. @RX14
<RX14> that crystal 0.22.0
<FromGitter> <johnjansen> YEP
<RX14> need latest crystal
<FromGitter> <johnjansen> im not yelling
<RX14> because it was only merged in the latest release
<FromGitter> <johnjansen> ohhhhh
<FromGitter> <johnjansen> haha
<RX14> haha i disabled my capslock
<RX14> turned it into an extra modifier
<RX14> much better use of such a big key
<FromGitter> <bew> which modifier?
<RX14> mod3 i think
<RX14> nope
<RX14> mod4
<RX14> which is what winkey is bound to in X11
flaviodesousa has quit [Remote host closed the connection]
<RX14> my old keyboard was a monterey K108 which was too old to have a winkey
<Yxhuvud> faustinoaq: do you have any idea of how much work supporting LSP would involve?
<RX14> Yxhuvud, there's a crystal LSP server a while ago being worked on
<RX14> along with a crystal-vscode-ide extension which worked with it
<FromGitter> <johnjansen> has homebrew been updated for the latest version
<RX14> not sure, probably not
<RX14> it hasn't even been released yet
<RX14> just tagged
<FromGitter> <johnjansen> oh well thats probably the problem then
<RX14> the release process goes changelog -> tag
<RX14> which sets the release commit
<RX14> and then it takes a few days to generate the release binaries
<FromGitter> <johnjansen> ok then ;-)
<RX14> and then the mailinglist is informed and the tag turns into a github release etc
<FromGitter> <johnjansen> so im ahead of the game again
<RX14> might be longer this time, not sure if @asterite did the previous release or bnot but i'm willing to bet he's not doing this one
<FromGitter> <johnjansen> fair enough
<RX14> @johnjansen you can build the release now if you want to
<RX14> it's probably trivial to edit the homebrew formula
<RX14> not sure how homebrew handles edits however
<FromGitter> <molovo> @RX14 Should just need to update download URL, version number and sha256 hash - homebrew handles the rest itself
<FromGitter> <johnjansen> another rabbit hole i dont want to fall into right now ;-) as it is im several branches off the one i fell into to begin with
<RX14> yes it's trivial to update the file but idk how trivial to get homebrew to use the updated formula
<RX14> i've never used homebrew - never had a mac
<RX14> @johnjansen side projects? I know the feel
<FromGitter> <johnjansen> ill PM you
<FromGitter> <dipnlik> hello. I wanted to try crystal via a docker image. ran `docker run -it -p 8080:8080 -it crystallang/crystal crystal play` and tried browsing to `http://localhost:8080` but Chrome says `ERR_EMPTY_RESPONSE`. Tried `nc -v localhost 8080`, it looks like the server is running fine. How can I fix this? (I'm new to both docker and crystal, willing to learn about both)
<FromGitter> <fridgerator> do you get an ip address from `docker-machine ls` ?
<FromGitter> <fridgerator> if so, try that instead of `localhost`
<RX14> @dipnlik you'll need to tell the playground to bind on 0.0.0.0
<FromGitter> <dipnlik> @fridgerator i'm not using docker-machine at the moment, so`docker-machine ls` doesn't show anything. tried http://172.17.0.2:8080 too, since that's the IP that I got via `docker inspect <containerId>`, that also didn't work
<RX14> for example, `docker run -it -p 8080:8080 -it crystallang/crystal crystal play -b 0.0.0.0`
<RX14> that works for me whereas the original command does not
<FromGitter> <dipnlik> @RX14 worked like a charm, thank you!
<RX14> i recommend not binding 8080:8080 on docker though because that exposes the playground to anyone on your lan
<RX14> just tested `docker run -it -p 127.0.0.1:8080:8080 -it crystallang/crystal crystal play -b 0.0.0.0`
<RX14> and that works
<RX14> not accessible on LAN
<RX14> crystal play is essentially a giant RCE on purpose
<FromGitter> <dipnlik> @RX14 that's good to know
<FromGitter> <faustinoaq> *<YXhuvud>*: I added LSP support to my extension too, just like crystal-ide, see: https://github.com/faustinoaq/vscode-crystal-lang/tree/support-scry
<FromGitter> <faustinoaq> You can clone the repo in your `.vscode/extensions` folder and compile it.
<FromGitter> <faustinoaq> But only linux binary is avaliable, because I don't have a Mac :sweat_smile:
<FromGitter> <elorest> This is probably really easy or not possible lol. How would I gzip a string without saving it to a file? It seems that gzip writer only takes IO objects or Filenames. Is there a StringIO object like in Ruby?
<Papierkorb> elorest, see IO::Memory
<Yxhuvud> faustinoaq: well, I'm not a vscode user, so your code is not all that useful.
<FromGitter> <elorest> <Papierkorb> Is there an example somewhere of using that with a string. I’ve seen it being used for encrypted data before.
<Yxhuvud> (to me. could be pretty swell for other people)
<Papierkorb> elorest, a String is not a good container for either ends. If you want to compress data from a String, String#to_slice may be your friends
<RX14> Papierkorb, if you're using Gzip::Writer you might as well use << on it
<RX14> which avoids the verbosify of write(string.to_slice)
<RX14> the destination should absolutely be a slice though
<FromGitter> <faustinoaq> **<Yxhuvud> ** Scry doesn't support Formatting yet, but is less resource intensive than Node.js spawning processes. This (https://github.com/faustinoaq/vscode-crystal-lang/tree/support-scry) branch has support for symbols, live linter, basic completion and snippets. Others features like *peek implementations*, *instance method completion* and *types on hover* are WIP by @kofno in his free time :smile:
<FromGitter> <faustinoaq> > I'm not a vscode user ⏎ ⏎ *<Yxhuvud>*, I didn't read your comment :sweat_smile: ⏎ ⏎ But doesn't matter, LSP (http://langserver.org/) is *cross-editor*, I hope to see Scry support in others editors too :+1: [https://gitter.im/crystal-lang/crystal?at=59529f4cad9c781843a769ba]
<FromGitter> <luislavena> @elorest you will open a Gzip::Writer around a IO::Memory and then write the "string".to_slice into it: https://play.crystal-lang.org/#/r/29g9
<FromGitter> <elorest> @luislavena https://play.crystal-lang.org/#/r/29gb
<FromGitter> <luislavena> you will need to build a string using the slice of bytes you just read from the Gzip
<FromGitter> <elorest> It seems like it already returns the slice as a string, rather than a slice.
<FromGitter> <elorest> `rstr.class => String`
<FromGitter> <elorest> In your example don’t we need to close io?
<FromGitter> <luislavena> @elorest you only need to close the `gzip` instance if you're not using the block version. The IO can remain open and you can rewind it to re-read it again.
<FromGitter> <elorest> Ok.
<FromGitter> <elorest> Thanks.
<FromGitter> <luislavena> https://play.crystal-lang.org/#/r/29gm
<FromGitter> <luislavena> back and forth
<FromGitter> <luislavena> Hope that helps
<FromGitter> <elorest> I think I got it. Thanks.
<FromGitter> <mjago> L
Ven has joined #crystal-lang
Ven is now known as Guest73188
Guest73188 has quit [Ping timeout: 240 seconds]
chimkan has quit [Quit: chimkan]
Renich has joined #crystal-lang
<FromGitter> <sdogruyol> @faustinoaq keep up the good job :+1:
Renich has quit [Quit: Renich]
bjz has joined #crystal-lang
<FromGitter> <elorest> @luislavena Helped a lot. Thanks.
Aytan72 has joined #crystal-lang
chimkan has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondi has joined #crystal-lang
chimkan has quit [Quit: chimkan]
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <raydf> @faustinoaq i should replace the plugin created by Ryan with yours?
<FromGitter> <raydf> should i?*
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
hightower3 has joined #crystal-lang
Kug3lis has joined #crystal-lang
hightower4 has quit [Ping timeout: 268 seconds]
<FromGitter> <faustinoaq> @kofno did a great wotk with `crystal-ide`. My extension is based on his work and you can use it if you want more features like a formatter, and ECR support (snippets), and symbols, and completion and other things to help you when you code :satisfied:
sauer2 has joined #crystal-lang
<FromGitter> <faustinoaq> Also Symbol tree like an IDE ((https://i.imgur.com/guRDY0T.png))
<sauer2> @faustinoaq: Whatever that is, it sure looks fancy. Is it a new VS Code plugin?
<FromGitter> <faustinoaq> Yes, It is
<sauer2> Nice!
<sauer2> Unrelated to that, there's a problem I hope one of you can help with.
<sauer2> I have a class BlockStmt with the constructor signature def initialize(statements : Array(Stmt | Nil))
<sauer2> And now there is a case where I can't create an object, because the compiler complains...
<sauer2> >instance variable '@statements' of Lox::BlockStmt must be Array(Lox::Stmt | Nil), not Array(Lox::ExprStmt)
<sauer2> However, ExprStmt is a subclass of Stmt, so that shouldn't be a problem. But it gets weirder...
<sauer2> With the extensive use of .as(Stmt) I only get it to say
<sauer2> instance variable '@statements' of Lox::BlockStmt must be Array(Lox::Stmt | Nil), not Array(Nil)
<sauer2> and filling the constructor call with an Array of nils changes that to
<FromGitter> <bew> `Array(Lox::Stmt | Nil)`, `Array(Lox::Stmt)` and `Array(Nil)` are 3 different types
<sauer2> So I basically have to cast to (Stmt | Nil) for each array element?
<FromGitter> <bew> are you sure it's `Array(Lox::Stmt | Nil)` and not ``Array(Lox::Stmt) | Nil` ?
<sauer2> @bew: yes
<sauer2> Hm, BlockStmt.new([ExprStmt.new(increment).as(Stmt | Nil)]) doesn't do the trick.
<FromGitter> <bew> can you show some code on what you're trying to do, and how you use it? In most cases you don't have to cast or specify types
<sauer2> alright, let me just get that gist going...
<FromGitter> <bew> (I'm wondering why would you want to have a nil in an array of statement now)
<sauer2> the last line is part of another, larger method
<sauer2> >(I'm wondering why would you want to have a nil in an array of statement now)
<sauer2> Chances are I did that instead of another cast or check somewhere else.
<FromGitter> <bew> Using `Array(Stmt | Nil)` will makes you have a check *every* time you want to read/manipulate the array, I'm not sure it's a big win
<sauer2> It probably isn't. I'm just not sure there 100% isn't a case with Nil...
pabs_ is now known as pabs