ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.29.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> <meltheadorable> PHP’s global functions have historically been a mess, it seems like they’ve been trying to clean it up and make it less necessary to rely on them over the years, i don’t really care for the language but I’m also not really interested in spending a lot of time disparaging it, I’m glad I don’t have to write it in my day job most of the time
<FromGitter> <watzon> It's up there in my top 5 least favorite languages
<FromGitter> <meltheadorable> JS continues to be a mess and I’m disappointed that the scope of webassembly was reduced to remove aspirations of letting it interact with the DOM directly, because it means javascript still has to be the target for any language hoping to drive a browser
<FromGitter> <meltheadorable> used to be excited about the possibility webassembly would free us from that
<FromGitter> <meltheadorable> but it’ll only be useful within a canvas now
<rkeene> Many of the W3C examples use Tcl as the language of the web :-D
<FromGitter> <dscottboggs_gitlab> how does one create a variable in macro-land? Like `{% some_var = [:a, :b, :c] %} {% for x in some_var %}"do something with {{x}}"{% end %}`
<FromGitter> <Blacksmoke16> y es
<FromGitter> <dscottboggs_gitlab> yes, as in I did it right?
<FromGitter> <dscottboggs_gitlab> Oh I know what I did
<FromGitter> <Blacksmoke16> looks fine yea
<FromGitter> <dscottboggs_gitlab> needed to wrap it in `{% begin %}` and `{% end %}`
<FromGitter> <Blacksmoke16> that would do it
<FromGitter> <Blacksmoke16> prob not helpful for you, but will be some new methods on annotations coming up
<FromGitter> <Blacksmoke16> `.args` returns a tuple of positional args on the annotation
<FromGitter> <Blacksmoke16> and `named_args` returns a namedTuple of named args on the annotation
<FromGitter> <dscottboggs_gitlab> that's pretty nice
<FromGitter> <Blacksmoke16> oh yea, super nice
<FromGitter> <dscottboggs_gitlab> can we do `@[Annotate arg: "value"]` yet?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <Blacksmoke16> without the paren?
laaron has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> yeah
<FromGitter> <Blacksmoke16> dont think so
* FromGitter * dscottboggs_gitlab grumbles
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <Blacksmoke16> this makes positional args much more useful tho
<FromGitter> <Blacksmoke16> before you only could access them directly, i.e. `ann[idx]`
<FromGitter> <dscottboggs_gitlab> was there at least a size so you could use a `for..in` macro loop?
<FromGitter> <Blacksmoke16> nope
<FromGitter> <dscottboggs_gitlab> jeeze
<FromGitter> <dscottboggs_gitlab> TBF though, crystal has an amazing macro system. I tried to write my first macro in rust today and was shocked at how terrible it was
<FromGitter> <dscottboggs_gitlab> Just gave up on it after looking into it for a while
<FromGitter> <Blacksmoke16> `(0...initializer.args.size)` is the hack i was using before this new feature
<FromGitter> <meltheadorable> why do annotations have an `end` if they don’t have a body
<FromGitter> <dscottboggs_gitlab> because they could have a body in the future maybe? Idk, that's a pretty good point
<FromGitter> <Blacksmoke16> i remember there being talk of future features of them
<FromGitter> <Blacksmoke16> like being able to define the fields and such
<FromGitter> <meltheadorable> that would be useful i think
<FromGitter> <Blacksmoke16> oo another idea i just thought of
<FromGitter> <Blacksmoke16> can iterate over key/value pairs now as well. should be able to cleanup CrSerializer a bit now
<FromGitter> <Blacksmoke16> before you had to manually specify the fields to read off of
<FromGitter> <dscottboggs_gitlab> that should be nice
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <meltheadorable> ✨
<FromGitter> <Blacksmoke16> I lied, no it won't help much
<FromGitter> <Blacksmoke16> Still need to have a list of annotations to read off the Ivar
<FromGitter> <watzon> Has anyone figured out a good way to cast a Hash of one type to another type?
<FromGitter> <watzon> Using `.as` doesn't work
<FromGitter> <watzon> I basically have this ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ which doesn't work because the hash `{"key" => "value}` doesn't match the alias `Action` exactly [https://gitter.im/crystal-lang/crystal?at=5d423b45e2802b6790a7097e]
<FromGitter> <meltheadorable> recursive aliases are going away, yeah?
<FromGitter> <watzon> Not as far as I know. It's been talked about, but I don't think it's happening
<FromGitter> <meltheadorable> it had looked to be trending that way when i read the issue
<FromGitter> <watzon> Either way, the recursive nature isn't the issue. I've tried it without a recursive alias too.
<FromGitter> <Blacksmoke16> Action{}
<FromGitter> <watzon> I've tried that as well
<FromGitter> <Blacksmoke16> Sure you didn't mean action not alias?
<FromGitter> <Blacksmoke16> In the dequeue
<FromGitter> <watzon> Yeah just realized that
<FromGitter> <meltheadorable> oh i noticed that but assumed it was a typo for us and not in the real code
<FromGitter> <watzon> It was haha
<FromGitter> <Blacksmoke16> Because that should work
<FromGitter> <watzon> https://carc.in/#/r/7c12
<FromGitter> <watzon> I feel like it should work too, but it doesn't
<FromGitter> <asterite> I think that should work. Could you report it as a bug? Thanks!
<FromGitter> <watzon> Sure thing @asterite
<FromGitter> <asterite> Oh, no
<FromGitter> <asterite> It's a recursive alias
<FromGitter> <asterite> It won't work, sorry
<FromGitter> <watzon> Yeah I just found that issue
<FromGitter> <asterite> Just cast each value to the expected type
<FromGitter> <Blacksmoke16> https://carc.in/#/r/7c14
<FromGitter> <Blacksmoke16> can just do that
<FromGitter> <asterite> cast the key to string or int or action
<FromGitter> <Blacksmoke16> I had to do a similar thing for crylog
<FromGitter> <watzon> Well shit ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d423dd745775115b377bc27]
<FromGitter> <Blacksmoke16> Rip
<FromGitter> <watzon> This makes me sad
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <meltheadorable> :(
<FromGitter> <meltheadorable> 😢
<FromGitter> <meltheadorable> inquiry — does crystal have a solid generic library for defining finite state machines (yet?)
<FromGitter> <watzon> Not as far as I know
<FromGitter> <meltheadorable> will add to my to-do list, i think i’m gonna need one for managing my SMTP junk
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <ryanstout> hey everyone. Is there a binary for the compiler on arm-linux?
<FromGitter> <tenebrousedge> you can cross-compile, pretty sure
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <kniknoo> I actually have this sitting open to try one day soon. http://hugopl.github.io/2019/04/28/Crystal-on-raspberry-pi.html
<FromGitter> <watzon> Pretty good article from @hugopl
<FromGitter> <absolutejam_gitlab> Elixir
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 245 seconds]
ht_ has joined #crystal-lang
<FromGitter> <watzon> What would I need to do to write a simple proxy server that just acts as a silent passthrough?
<FromGitter> <watzon> Anything special?
sorcus has joined #crystal-lang
<FromGitter> <watzon> I guess this will work https://github.com/mamantoha/http_proxy
laaron- has joined #crystal-lang
laaron has quit [Ping timeout: 260 seconds]
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
alex`` has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
dingenskirchen has joined #crystal-lang
sz0 has joined #crystal-lang
allan has left #crystal-lang [#crystal-lang]
DTZUZU has quit [Ping timeout: 268 seconds]
DTZUZU has joined #crystal-lang
return0e_ has quit [Ping timeout: 268 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> is it possible to use `HTTP::Client` with unix sockets?
<FromGitter> <absolutejam_gitlab> Ugh, I can't find a way to interact with a JSON rest API over a socket..
<FromGitter> <dscottboggs_gitlab> @absolutejam_gitlab yeah that should work, why wouldn't it?
<FromGitter> <absolutejam_gitlab> There's no socket support for `HTTP::Client`
<FromGitter> <absolutejam_gitlab> There's an issue for adding it
<FromGitter> <absolutejam_gitlab> just seen it
<FromGitter> <absolutejam_gitlab> there's the in-built `socket` lib
<FromGitter> <dscottboggs_gitlab> Jeeze, come on.
<FromGitter> <absolutejam_gitlab> but once I bind to the socket, I dunno how to send to a path
<FromGitter> <dscottboggs_gitlab> hang on
return0e has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> it's actually not too hard to write out HTTP requests by hand. You just have to remember to use MS line endings in it
<FromGitter> <absolutejam_gitlab> Are macros limited to only the select few functions? Or do I have to use `run` and make another crystal executable to get full crytsal support?
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <bew> @absolutejam_gitlab yes and yes
<FromGitter> <absolutejam_gitlab> hm, poop
<FromGitter> <absolutejam_gitlab> I'm trying to build in an Alpine container but it's failing to find my relative shard
<FromGitter> <absolutejam_gitlab> ``` dependencies: ⏎ climax: ⏎ path: ../climax``` [https://gitter.im/crystal-lang/crystal?at=5d42ce24475c0a0febdd4319]
<FromGitter> <absolutejam_gitlab> ```/app/shards.yml ⏎ /climax/...``` [https://gitter.im/crystal-lang/crystal?at=5d42ce39ee80d76164cb3e68]
<FromGitter> <absolutejam_gitlab> trying to build within `/app/`
<FromGitter> <absolutejam_gitlab> switched it to git, still saying that it can't find it
<FromGitter> <absolutejam_gitlab> after a `shards install` etc.
<FromGitter> <absolutejam_gitlab> oh, I don't think `shards install` is doing anything...
<FromGitter> <absolutejam_gitlab> `bake_file "foo", {{ system("cat ./assets.tar.gz").stringify }}` works fine locally but gets `Syntax error in expanded macro: macro_140320976575216:1: invalid hex escape` in alpine
<FromGitter> <Blacksmoke16> you could prob just use the `read_file` macro method
<FromGitter> <Blacksmoke16> vs system at
<FromGitter> <absolutejam_gitlab> Did not see that one...
<FromGitter> <absolutejam_gitlab> haha
<FromGitter> <absolutejam_gitlab> jesus
<FromGitter> <Blacksmoke16> :p
<FromGitter> <absolutejam_gitlab> ugh, I am having no joy getting my binary to work across machines
<FromGitter> <absolutejam_gitlab> I really thought it'd be simpler
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
duane has quit [Ping timeout: 248 seconds]
<FromGitter> <bew> how are they different?
<FromGitter> <absolutejam_gitlab> I'm running arch
<FromGitter> <absolutejam_gitlab> the target machine is ubuntu
<FromGitter> <absolutejam_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d42e63275c7976e030b476f]
<FromGitter> <tenebrousedge> @watzon silent passthrough proxy? nginx will do that
<FromGitter> <absolutejam_gitlab> the lasto ne is `libpcre.so.1`
<FromGitter> <absolutejam_gitlab> am I right in thinking a statically compiled binary (From Alpine) will not work on non-alpine boxes?
<FromGitter> <Blacksmoke16> it *should* work on all linux based OS of the same arch afaik
<FromGitter> <Blacksmoke16> but i could be wrong...
<FromGitter> <absolutejam_gitlab> if i compile it in alpine container with `--static` on my arch machine and run it on my machine, it works
<FromGitter> <absolutejam_gitlab> but if I scp to an ubuntu host, it segfaults
<livcd> glibc vs musl ?
<FromGitter> <absolutejam_gitlab> Tried symlinking libpcre.so.3 to .1 and then I get `/lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found `
<FromGitter> <absolutejam_gitlab> 😢
<FromGitter> <absolutejam_gitlab> and this is building on Ubuntu, which I didn't wanna have to do
<FromGitter> <tenebrousedge> symlinking? Isn't that what `LD_PRELOAD` is for?
<FromGitter> <absolutejam_gitlab> Honestly, I have no idea about compilation
<FromGitter> <tenebrousedge> LD_PRELOAD (https://news.ycombinator.com/item?id=19187417)
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
duane has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> oh, I think my llvm target was wrong
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <bew> if you compiled statically, running `ldd ./your_binary` should not list any shared libraries
<FromGitter> <absolutejam_gitlab> that was a non-static version because the static on segfaulted on non-alpine
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
lucasb has joined #crystal-lang
laaron has quit [Remote host closed the connection]
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
laaron has joined #crystal-lang
<FromGitter> <kingsleyh> hi - anyone know what this error means?
<FromGitter> <kingsleyh> ``````
<FromGitter> <kingsleyh> `[ 2019-08-01 15:43:02 -- Erro ] /usr/local/Cellar/crystal/0.29.0/src/gc/boehm.cr:76:5 `
rohitpaulk has joined #crystal-lang
<FromGitter> <kingsleyh> I get that and then my websocket dies
<FromGitter> <kingsleyh> some kind of memory issue with the GC?
<FromGitter> <straight-shoota> @absolutejam_gitlab
<FromGitter> <straight-shoota> > if i compile it in alpine container with `--static` on my arch machine and run it on my machine, it works ⏎ but if I scp to an ubuntu host, it segfaults
<FromGitter> <straight-shoota> This should usually work without issues, as long as it is fully statically compiled and doesn't use any libraries that don't work well when compiled statically (like openssl)
<FromGitter> <straight-shoota> The boehm error seems to indicate an issue with libgc
<FromGitter> <straight-shoota> Is that literally the only thing printed?
<FromGitter> <absolutejam_gitlab> It doesn't do an awful lot outside of stdlib
<FromGitter> <absolutejam_gitlab> just regexes
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> ohhhh
<FromGitter> <absolutejam_gitlab> I think I got it working
<FromGitter> <absolutejam_gitlab> #!/bin/sh ⏎ ⏎ echo "Building for release..." ⏎ compile_cmd=$( ⏎ crystal build \ ... [https://gitter.im/crystal-lang/crystal?at=5d43018545da450fec88eccc]
<FromGitter> <absolutejam_gitlab> I didn't have the `--cross-compile` flag on originally
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <straight-shoota> You shouldn't need `--cross-compile` when building a static linux binary
<FromGitter> <j8r> no need to use eval @absolutejam_gitlab
<FromGitter> <absolutejam_gitlab> Oh, really?
<FromGitter> <absolutejam_gitlab> ohhh
<FromGitter> <absolutejam_gitlab> Maybe my segfault wasn't related to compilation
<FromGitter> <absolutejam_gitlab> I had added some stuff at startup
<FromGitter> <absolutejam_gitlab> But obviously I won't get stack traces in `--release` mode
<FromGitter> <absolutejam_gitlab> So I thought the compilation wasn't working but it was just me being an idiot
<FromGitter> <absolutejam_gitlab> Jesus
<FromGitter> <absolutejam_gitlab> going home.
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter> <straight-shoota> In fact, when you cross-compile to linux-gnu, you would need to link statically against glibc which causes problems
laaron has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
duane has quit [Ping timeout: 248 seconds]
ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.30.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
<Stephie> i wish glibc static linking wasn't cursed
<Stephie> it's just NSS stuff, which uses dlopen
<Stephie> and NSS is a terrible idea
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <r00ster91> is there anything wrong with this websocket creation `HTTP::WebSocket.new("localhost", "", port: 8080, tls: true)`? This websocket creation ends in an infinite loop. I think I've found a bug
duane has joined #crystal-lang
<Stephie> are you sure the infinite loop is during the constructor?
<FromGitter> <r00ster91> this loop is never being exited
<FromGitter> <r00ster91> maybe it's WSL-related
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <r00ster91> can anyone on wsl reproduce this
<FromGitter> <dburnsii> Hey all, I'm really new to Docker but just pulled the latest docker image, anyone know the command I have to run to get it to start compiling?
<FromGitter> <tenebrousedge> to start compiling what?
<FromGitter> <kniknoo> A docker image itself is basically a vm, are you meaning to open fresh image and compile the compiler into it?
<FromGitter> <dburnsii> Well I grabbed this: https://hub.docker.com/r/crystallang/crystal , that should have the source on it already shouldn't it? There's a Dockerfile listed that looks like it has the make command along with a few other operations
<FromGitter> <Blacksmoke16> you would want to make a volume to get your project directory into the container, then could execute it within there
<FromGitter> <Blacksmoke16> something like
<FromGitter> <Blacksmoke16> `docker run crystal -v ./:/app crystal /app/src/my_app.cr`
<FromGitter> <Blacksmoke16> but it would prob be easier to develop locally?
<FromGitter> <kniknoo> Oh, is it not possible to just work from a shell in a docker image?
<FromGitter> <tenebrousedge> you can, it's not ideal
<FromGitter> <tenebrousedge> better to mount the local folder in the docker image
<FromGitter> <kniknoo> (I could see why WSL users might want to try this)
<FromGitter> <dburnsii> Hm, I see what you're saying. The only reason I opted for the Docker image was because of clashing LLVM versions on my arch machine.
<FromGitter> <kniknoo> I'm always once to isolate thoughts via VM images. If you're just starting out on Crystal and you're worried about the clash, it might be a way to roughly do what you're trying to do with docker.
<FromGitter> <tenebrousedge> @kniknoo if you're working inside the docker image then you are probably only going to have `nano` or `vim` available for editing, at most
<FromGitter> <kniknoo> Understood... I admittedly have done most writing in my life on nano... :D
<FromGitter> <Blacksmoke16> oh you could do like
<FromGitter> <kniknoo> These here gui editors are new and neat to me. :D
<FromGitter> <Blacksmoke16> ```docker exec -it <crystal_image_name> bash```
<FromGitter> <Blacksmoke16> which would put you into the container
<FromGitter> <tenebrousedge> nano has syntax highlighting, and what else does one need? :P
<FromGitter> <Blacksmoke16> from there you could develop via like `crystal my_app.cr`
<FromGitter> <Blacksmoke16> could also still setup the volume so changes you make in your editor get synced to the container
<FromGitter> <kniknoo> I don't even have highlighting on. Highlighting is one of those "wow" features for me.
<FromGitter> <tenebrousedge> ...oh
<FromGitter> <kniknoo> I AM in geany now, I'm safe from the siren song of nano. :D
<FromGitter> <absolutejam_gitlab> Anyone know of a http client thay does Unix sockets?
<FromGitter> <tenebrousedge> Crystal's http client can't be made to listen on a socket?
<FromGitter> <kniknoo> I haven't tried it yet, but I do see UDP, TCP, and Unix listed https://crystal-lang.org/api/0.29.0/UNIXSocket.html
<FromGitter> <absolutejam_gitlab> Not implemented yet by looks
<FromGitter> <absolutejam_gitlab> There's an issue
<FromGitter> <dburnsii> So @Blacksmoke16 , what do I specify for the `crystal_image_name`? `crystal` and `crystallang/crystal` don't seem to be working
<FromGitter> <kniknoo> This is something I look forward to learning about. I am correct in my assumption that I could use sockets to talk between languages? Or is there a smarter way to approach that?
<FromGitter> <absolutejam_gitlab> I don't know if there's an official one, is there?
<FromGitter> <absolutejam_gitlab> You could throw together an alpine image like I have
<FromGitter> <absolutejam_gitlab> Between processes so
<FromGitter> <absolutejam_gitlab> Yeah if both of them have a common interface, eg json, protobuf
<FromGitter> <tenebrousedge> `docker exec` presupposes that you have a running docker container
<FromGitter> <tenebrousedge> so if `docker ps` does not list anything...
<FromGitter> <tenebrousedge> @kniknoo you should check out Atom or VSCode. Do you know vim?
<FromGitter> <absolutejam_gitlab> @Blacksmoke16 it's a http rest interface over a socket tho
<FromGitter> <absolutejam_gitlab> I can make it over http but not the default
<FromGitter> <absolutejam_gitlab> And id rather not add http layer...
<FromGitter> <absolutejam_gitlab> Kakoune is best editor
<FromGitter> <absolutejam_gitlab> Im a shill
<FromGitter> <kniknoo> That's what I was thinking for a VM. I'm going to play around with my alpine install a bit. Two things I'd like to accomplish are a simple minimalist iso for people on WSL and and rolling-releases and a working portable ARM image I can provide.
<FromGitter> <kniknoo> I am aware of vim. It would be easier to pull me into emacs world I think. I have been meaning to try out atom to see what it's all about.
<FromGitter> <Blacksmoke16> @dburnsii do a `docker images`
<FromGitter> <dburnsii> Is it the `image_id` I want?
<FromGitter> <tenebrousedge> kakoune looks very interesting, but you can get vim keybindings in a lot of places
<FromGitter> <Blacksmoke16> that would prob work yea
<FromGitter> <tenebrousedge> atom is fine, lots of good plugins, but slow and memory-heavy
<FromGitter> <tenebrousedge> emacs lost the editor wars
<FromGitter> <absolutejam_gitlab> It's like Inversed vim
<FromGitter> <absolutejam_gitlab> And I love it
<FromGitter> <absolutejam_gitlab> dw in vim to delete word
<FromGitter> <absolutejam_gitlab> wd in Kakoune and it you the selection
<FromGitter> <absolutejam_gitlab> Anyway, less pushing form. Me
<FromGitter> <absolutejam_gitlab> Can't type on mobile
<FromGitter> <dburnsii> So a `docker ps -a` shows that it starts up, but it looks like it exits right away
<FromGitter> <Blacksmoke16> @dburnsii one sec, let me try it. was going off memory
<FromGitter> <kniknoo> One of my considerations is that I could never imagine myself using the key-bindings. I see what people do with shortcuts and I can't even imagine getting to a point where I'd think like that.
<FromGitter> <tenebrousedge> modal editors are kinda the opposite of shortcuts
<FromGitter> <kniknoo> I do have a vim book that's been waiting around to be read, perhaps that would help me think in that way.
<FromGitter> <tenebrousedge> I'd try spacevim
<FromGitter> <tenebrousedge> @absolutejam_gitlab does Kakoune have an equivalent to the vim-tutorial?
<FromGitter> <Blacksmoke16> @dburnsii `docker run -v `pwd`:/app -w /app -i -t crystallang/crystal bash`
<FromGitter> <Blacksmoke16> will put you into a shell within the container, with your current directory mapped to `/app` in the container
<FromGitter> <Blacksmoke16> thus you any files you add/remove from that dir will be synced between container and host
<FromGitter> <Blacksmoke16> and in container can just do `crystal my_app.cr`
<FromGitter> <Blacksmoke16> backticks around pwd
<FromGitter> <dburnsii> There it is, awesome, thank you so much
<FromGitter> <Blacksmoke16> np
<FromGitter> <absolutejam_gitlab> So therr is an official image?
<FromGitter> <absolutejam_gitlab> I didn't even look
<FromGitter> <absolutejam_gitlab> P
<FromGitter> <Blacksmoke16> yes
<FromGitter> <jwoertink> Is there a way to do `Spec.before_each` but only within a specific group of specs? So not on every single spec, but for just a small group of them?
<FromGitter> <jwoertink> Also, has anyone come up with a way to focus specs? Like with RSpec how you can add `describe "whatever", :focus`
<FromGitter> <jwoertink> so when you run your spec suite, it only runs those specific blocks
<FromGitter> <kniknoo> Without referencing the phrase "billion dollar mistake" could someone point me to a resource about the dangers of nil and how to anticipate and account for it in crystal code. I keep eventually getting myself out of the weeds but it's without a strategy right now.
<FromGitter> <Blacksmoke16> @jwoertink no
<FromGitter> <Blacksmoke16> @kniknoo the compiler does it for you
<FromGitter> <Blacksmoke16> it prevents doing stuff like
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7c5o
<FromGitter> <Blacksmoke16> whereas in ruby this would be
<FromGitter> <jwoertink> Cool. thanks
<FromGitter> <Blacksmoke16> https://carc.in/#/r/7c5r where it would be a runtime error
<FromGitter> <tenebrousedge> @kniknoo use `try` when you need to
<FromGitter> <tenebrousedge> @kniknoo beyond that, it's hard to give suggestions without seeing how you're approaching things. Do you have any example code?
<FromGitter> <kniknoo> Gotcha on that Kai... Hmmm. So it's actually going to be REALLY common for me to be basing things on probabilities when I get to art projects. That example is exactly why I asked.
<FromGitter> <kniknoo> Oh, ok. The if var strategy looks perfect for what I'm asking.
<FromGitter> <Blacksmoke16> `try` is also helpful, but really it all depends on the context of what you're doing
<FromGitter> <Blacksmoke16> are multiple ways to handle it
<FromGitter> <tenebrousedge> I don't like `if`s <_<
<FromGitter> <kniknoo> Okie doke. This is partly for my understanding and party so I can boil down the strategies for their essence. I feel like, for better or worse, Ruby taught me to love the nil for its truthiness.
<FromGitter> <tenebrousedge> o__o?
<FromGitter> <kniknoo> or, falseyness
<FromGitter> <kniknoo> Oh... ok. So that's why it keeps working out when I whittle things down to ternary? Is that running on the same concept as the if var?
<FromGitter> <Blacksmoke16> `(str = my_string) ? str.upcase : raise "String is null"`
<FromGitter> <Blacksmoke16> would be the same as
<FromGitter> <Blacksmoke16> ```if str = my_string ⏎ str.upcase ⏎ else ⏎ raise "String is null" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d432a06757b7b19c8392ca2]
<FromGitter> <kniknoo> Ok, I `play`ed around with that and it makes sense now. You can tell I got into programming from a weird trajectory. So many basics I don't know and obscure things I do. :D
<FromGitter> <kniknoo> Ok, so like, .not_nil! on a gets is so that it will raise an exception to handle if there's no input? That bit kind of confuses me.
<FromGitter> <Blacksmoke16> `not_nil!` raises an exception if its called on something that is nil
<FromGitter> <kniknoo> Ok, so in the case of gets, it's just like an assurance that something will come of it? I think of gets as assuring a string will come in, but I may totally misunderstand that part.
<FromGitter> <Blacksmoke16> youd have to test it
<FromGitter> <kniknoo> Ok. I need to fiddle a bit it sounds like. Thank you!
<FromGitter> <kniknoo> Wait, maybe this answers it... a blank input is a Nil prior to being converted to "" by gets and that's where the issue lies?
rohitpaulk has joined #crystal-lang
<FromGitter> <tenebrousedge> @kniknoo code example?
DTZUZU has quit [Quit: WeeChat 2.2]
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter> <kniknoo> FFS, I don't even know what I was reading now. Something early on that made me think that gets always had to be followed by .not_nil.
<FromGitter> <kniknoo> Thank you for humoring my derpy questions. :)
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 248 seconds]
<FromGitter> <watzon> `not_nil!` is rarely necessary I've found. `try` and `to_s` make pretty good replacements depending on the scenario.
<FromGitter> <watzon> `try` especially. That thing is a life saver.
<FromGitter> <kniknoo> Ok cool. That makes sense.
alex`` has quit [Ping timeout: 246 seconds]
alex`` has joined #crystal-lang
<oprypin> @kniknoo: it is true though. `gets` can return nil
<oprypin> that's where not_nil comes in
<oprypin> nil is not for an empty input in the normal sense. empty string serves that fine
<oprypin> it's for EOF, which happens for piped input or if u just press Ctrl+D
<oprypin> or just use read_line which has an exception instead of nil
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <kniknoo> *click* THANK YOU!!!
<FromGitter> <kniknoo> Those cases make it make more sense now.
<FromGitter> <watzon> Looks like 0.30.0 (https://github.com/crystal-lang/crystal/releases/tag/0.30.0) just dropped
<FromGitter> <tenebrousedge> D:
<FromGitter> <bararchy> and now enumerable is broken XD
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d434ababea6966fb04d2039]
<FromGitter> <bararchy> or something
<FromGitter> <bararchy> hahah
<FromGitter> <absolutejam_gitlab> Is there a community spec for idiomatic Crystal?
<FromGitter> <tenebrousedge> rubocop
<FromGitter> <bararchy> @absolutejam_gitlab ameba
<FromGitter> <tenebrousedge> oh right, that
<FromGitter> <tenebrousedge> I thought that was more static analysis than idioms
<FromGitter> <Blacksmoke16> does a bit of both
<FromGitter> <tenebrousedge> "also catches code smells" k
<FromGitter> <kniknoo> Yeah, I'm really wanting to boil down style.
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/conventions/coding_style.html if you havent read it already
<FromGitter> <tenebrousedge> use `&.` whenever possible
<FromGitter> <kniknoo> That I have, but I mean more like, best practices actually I guess. Making sure it's approached in the most Crystal way.
<FromGitter> <kniknoo> Right, that's a habit I don't have at all yet.
<FromGitter> <tenebrousedge> use `Enum` when you can
<FromGitter> <absolutejam_gitlab> I've been using ameba but I mana mean more of guidelines
<FromGitter> <absolutejam_gitlab> I've never used &.
<FromGitter> <bararchy> same here ^ XD never used &.
<FromGitter> <tenebrousedge> I'm shocked
<FromGitter> <kniknoo> I think we're the pioneers of a lot of that, James. :)
<FromGitter> <bararchy> also, I hate `try`
<FromGitter> <bararchy> the crystal way is ⏎ ⏎ ```if (local = something) ⏎ # do something with local ⏎ else ⏎ # handle ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d434c152f64b21887da445f]
<FromGitter> <bararchy> ;)
<FromGitter> <tenebrousedge> `else` should be avoidable
<FromGitter> <absolutejam_gitlab> I like that way the most
<FromGitter> <watzon> Lol
<FromGitter> <kniknoo> Well, that seems like a good reason to use ternary heavily, IMO
<FromGitter> <bararchy> @kniknoo yeha... it and `spawn` don't play nicely
<FromGitter> <watzon> Does anyone know if it's possible to add a handler to a HTTP::Server instance after it's been initialized?
<FromGitter> <kniknoo> I haven''t really understood spawn yet.
<FromGitter> <absolutejam_gitlab> I do miss pattern matching a little
<FromGitter> <absolutejam_gitlab> But the way my functions are composed is generslly not like how I'd do it in elixir so I don't think I'd lrscfisallg use it as much a si
<FromGitter> <absolutejam_gitlab> As I think
<FromGitter> <absolutejam_gitlab> Jesus where is autocorrect today
<FromGitter> <absolutejam_gitlab> These fat thumbs need supervision
<FromGitter> <kniknoo> Oh I thought you were breaking into a Welsh idiom...
<FromGitter> <absolutejam_gitlab> I just try and hit 60% accuracy and rely on autocorrect
<FromGitter> <Blacksmoke16> @watzon moment
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/HTTP/Server.html#build_middleware(handlers,last_handler:Context-%3E?=nil)-class-method prob that?
<FromGitter> <watzon> That would overwrite other handlers, but I suppose that may be what I have to do
<FromGitter> <Blacksmoke16> would prob have to keep a reference of the old ones
<FromGitter> <kniknoo> *Avoids making silly Cthulhu joke*
<FromGitter> <j8r> I bet there will have lots of user feedbacks due do shards 0.9.0 perf issue. More than 8 deps without setting the version will eat all the memory and crash.
<FromGitter> <tenebrousedge> o__o
<FromGitter> <watzon> Uh oh
sorcus has quit [Ping timeout: 250 seconds]
<FromGitter> <watzon> Well this sucks ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Just started happening randomly and I have no idea why [https://gitter.im/crystal-lang/crystal?at=5d43503eff59f961b4f9c121]
<FromGitter> <watzon> Can you break a port? Lol
<FromGitter> <watzon> Because I think I did that
<FromGitter> <tenebrousedge> what does `lsof` say about that?
<FromGitter> <watzon> Nada
<FromGitter> <watzon> But when I try to run my proxy on that port I get the above error now. Switching the port fixes it.
<FromGitter> <tenebrousedge> `netstat` same thing?
<FromGitter> <tenebrousedge> does rebooting fix it?
<FromGitter> <watzon> It probably would. I'm just wondering how it happened in the first place
<FromGitter> <tenebrousedge> zombie process?
<FromGitter> <watzon> I don't think so, but it's possible
<FromGitter> <tenebrousedge> does `ps` find any of those ?
<FromGitter> <tenebrousedge> `ps aux | grep 'Z'`
<FromGitter> <watzon> The only result was the grep command iteslf
<FromGitter> <tenebrousedge> try `sudo fuser -k $PORT/tcp` ?
<FromGitter> <watzon> Already did
<FromGitter> <watzon> no dice
<FromGitter> <tenebrousedge> or `tcpkill` ?
<FromGitter> <alex-lairan> Hi, I've tried to upgrade my shards to 0.30.0 ⏎ ⏎ It use a lot of generics and I have this error : ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5d43551345da450fec8b9d72]
<FromGitter> <absolutejam_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d4357217a151629e1083863]
<FromGitter> <absolutejam_gitlab> `"HTTP/1.1 200 OK"`
<FromGitter> <absolutejam_gitlab> Any ideas?
<FromGitter> <tenebrousedge> seems like it got the first line of the response correctly
<FromGitter> <tenebrousedge> maybe `gets` isn't the method you want
<FromGitter> <watzon> @absolutejam_gitlab what are you expecting the output to be?
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Json sorry
DTZUZU has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> ah
<FromGitter> <absolutejam_gitlab> `.gets` is the first line
<FromGitter> <watzon> Yeah, `.gets` with no args gets everything up until a `\n`. You can also include a delimiter.
<FromGitter> <watzon> `.gets(':')` for example
<FromGitter> <absolutejam_gitlab> If I do a ⏎ ⏎ ```while resp = sock.gets ⏎ pp resp ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d435f5a4635976e0412c919]
<FromGitter> <absolutejam_gitlab> I get the full message
<FromGitter> <absolutejam_gitlab> But it doesn't stop blocking
<FromGitter> <absolutejam_gitlab> same with `gets_to_end`
<FromGitter> <watzon> Yeah I've run into that same issue before
<FromGitter> <absolutejam_gitlab> this is why I don't want to deal with low level HTTP calls
<FromGitter> <dscottboggs_gitlab> Oh wow you're still working on that? It might be easier to just patch HTTP::Client
<FromGitter> <dscottboggs_gitlab> or subclass it?
ht_ has quit [Remote host closed the connection]
<FromGitter> <dscottboggs_gitlab> You can reopen HTTP::Client, override `@socket` to be a UnixSocket and create a new constructor, something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d4362c2757b7b19c83acfd4]
teardown has quit [Ping timeout: 272 seconds]
<FromGitter> <dscottboggs_gitlab> shit, where have I seen that before.... 💭
<FromGitter> <dscottboggs_gitlab> There ya go, add that to your source, require it, and you've got a socket compatible http client
<FromGitter> <dscottboggs_gitlab> @absolutejam_gitlab
teardown has joined #crystal-lang
<FromGitter> <tenebrousedge> @watzon did you get anywhere with that one?
<FromGitter> <watzon> I restarted and it fixed it. No idea what happened.
<FromGitter> <watzon> Somehow the port just broke
<FromGitter> <tenebrousedge> you were probably holding it wrong
<FromGitter> <watzon> Lol
OvermindDL1_ has joined #crystal-lang
OvermindDL1 has quit [*.net *.split]
OvermindDL1_ is now known as OvermindDL1
DTZUZU has quit [Quit: WeeChat 2.2]
<FromGitter> <watzon> I need to see if I can make a HTTP::Server just act as a transparent proxy so I can capture the request and response
<FromGitter> <watzon> This doesn't work though,
<FromGitter> <watzon> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d436bc94635976e04131bfa]
<FromGitter> <watzon> Probably because I'm not sending anything
<FromGitter> <Blacksmoke16> whats the goal?
<FromGitter> <dscottboggs_gitlab> In what way does it not work?
alex`` has quit [Ping timeout: 248 seconds]
<FromGitter> <watzon> Right now marionette doesn't have the ability to capture headers and modify them. In order to do that you have to proxy requests and responses and modify them in the proxy.
<FromGitter> <watzon> Right now it doesn't seem to be proxying
<FromGitter> <watzon> It seems to be capturing, but not forwarding
<FromGitter> <Blacksmoke16> would the block cleanup after the block executes
<FromGitter> <Blacksmoke16> which would reset the objs since they prob passed by reference
<FromGitter> <bajro17> @watzon where is that lib for facebook pictures I cant find it
<FromGitter> <watzon> @bajro17 https://github.com/watzon/fbmdob
<FromGitter> <bajro17> It write Vue instead of Crystal this is why I cant find it
<FromGitter> <watzon> Yeah there's more Vue than Crystal so Github labeled as Vue
<FromGitter> <bajro17> I share just tool with my boss :)
<FromGitter> <watzon> Haha awesome :)
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab you around?
<FromGitter> <dscottboggs_gitlab> yessir, what's up?
<FromGitter> <Blacksmoke16> what would be the crystal equivalent of something like ⏎ ⏎ ``` struct TagDirective ⏎ handle : UInt8* ⏎ prefix : UInt8* ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d437243a96def47519f4528]
<FromGitter> <Blacksmoke16> what would be the crystal equivalent of something like ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ mainly the tag start/end stuff? [https://gitter.im/crystal-lang/crystal?at=5d43725a757b7b19c83b4c9a]
<FromGitter> <Blacksmoke16> imagine a pointer to an array or something?
<FromGitter> <dscottboggs_gitlab> > would the block cleanup after the block executes ⏎ ⏎ Probably not, from what I've seen of discussions about it, the GC doesn't kick in for a while after memory isn't needed anymore
<FromGitter> <watzon> It looks like a pointer to the `TagDirective` struct
<FromGitter> <absolutejam_gitlab> Thanks @dscottboggs_gitlab
<FromGitter> <dscottboggs_gitlab> np @absolutejam_gitlab
<FromGitter> <absolutejam_gitlab> Saved me a lot of hard work 👍
<FromGitter> <Blacksmoke16> wouldnt that imply it can only have one?
<FromGitter> <watzon> I don't think so
<FromGitter> <dscottboggs_gitlab> nope
<FromGitter> <Blacksmoke16> :thinking:
<FromGitter> <watzon> I should say a pointer to a TagDirective instance
<FromGitter> <dscottboggs_gitlab> `tag_start` is one memory address, `tag_end` is another.
<FromGitter> <Blacksmoke16> so a slice of tag directive instances?
<FromGitter> <watzon> That looks familiar
<FromGitter> <watzon> libyaml?
<FromGitter> <dscottboggs_gitlab> yes
<FromGitter> <Blacksmoke16> @watzon yea ^
<FromGitter> <dscottboggs_gitlab> you should translate the range of memory from `tag_start` to `tag_end` as a `Slice` of `TagDirective*`
<FromGitter> <Blacksmoke16> hmm, not sure i follow
<FromGitter> <Blacksmoke16> how would you pass the begin/end to each arg?
<FromGitter> <Blacksmoke16> or just do like `slice.first.to_unsafe, slice.last.to_unsafe`?
<FromGitter> <dscottboggs_gitlab> no
<FromGitter> <dscottboggs_gitlab> oh, yesy
<FromGitter> <dscottboggs_gitlab> `Sllice(TagDirective*).new tag_start, size: tag_start - tag_end`
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <watzon> So here's my proxy class (https://github.com/watzon/marionette/blob/proxy-stuff/src/marionette/proxy.cr) right now. It doesn't work as is though. All I want it to do right now is transparently proxy the connection.
<FromGitter> <watzon> Tried running it and setting Firefox to use it
<FromGitter> <Blacksmoke16> can you just new up C structs like normal?
<FromGitter> <Blacksmoke16> or are they just more representing types in C land?
DTZUZU has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> There should be a way to initialize structs, but I can't rememeber what it is. Does `.new` with named arguments work?
<FromGitter> <dscottboggs_gitlab> hang on I'll check
<FromGitter> <dscottboggs_gitlab> OH I rememember, I'll provide an example
<FromGitter> <dscottboggs_gitlab> One sec
<FromGitter> <dscottboggs_gitlab> https://carc.in/#/r/7c6w
<FromGitter> <dscottboggs_gitlab> A crystal `fun` at the top level acts like a C function in every way
<FromGitter> <dscottboggs_gitlab> Structs can *only* be initialized with defaulted parameters, it appears.
<FromGitter> <Blacksmoke16> hmm interesting
<FromGitter> <Blacksmoke16> good to know
<FromGitter> <Blacksmoke16> trying to allow for custom tags
<FromGitter> <Blacksmoke16> i.e. could like register a handler that executes on the given tag
<FromGitter> <dscottboggs_gitlab> @watzon doesn't a proxy require both a client and a server?
<FromGitter> <watzon> Yeah I just realized that
<FromGitter> <watzon> For some reason I thought I could just pass the browsers request through
<FromGitter> <watzon> I've got it semi-working now, but it's erroring on https pages
<FromGitter> <Blacksmoke16> check this out
<FromGitter> <Blacksmoke16> base.yaml ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d437b74ee80d76164d0d3a0]
<FromGitter> <dscottboggs_gitlab> oh cool!
<FromGitter> <Blacksmoke16> dont think it should be in the std lib, but doing something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d437cb545da450fec8cc4f2]
<FromGitter> <Blacksmoke16> would be nice to have
<FromGitter> <watzon> That's pretty nice