<Papierkorb>
Build it? As opposed to Go you can even make use of union types to statically type different kind of structures
<watzon>
Yeah I'm seeing if I can throw something together. I'm trying to wrap the docker api right now and it would be really helpful and save me a lot of time.
<Papierkorb>
Fair point, doesn't Docker have something like a swagger spec?
<watzon>
I've never used swagger so I couldn't really say
<Papierkorb>
And I don't even know if there's already a swagger generator for Crystal ;)
jradd has quit [Ping timeout: 256 seconds]
ome has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
greengriminal has joined #crystal-lang
<watzon>
Doesn't look like it
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
<FromGitter>
<jaynagpaul> Is there a simple way to add together a url with query params in it and a Hash(String,String)? This seems to tell me that has_key? is undefined, and seems very unelegant to me. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a87bbcc6fba1a703a604144]
qard has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
<watzon>
@jaynagpaul I've just been doing this: `query = "?" + HTTP::Params.encode({ "key" => "value" })` and then concatenate that onto the URL. Really it would be nice if all of the `HTTP::Client` request methods allowed you to define query params.
<watzon>
Or if URI allowed you to set query params with a Hash or NamedTuple
ome has quit [Quit: Connection closed for inactivity]
<FromGitter>
<straight-shoota> what would you use the generated Crystal code for, if not a Crystal project??
alex`` has quit [Ping timeout: 240 seconds]
maattdd_ has quit [Ping timeout: 255 seconds]
<watzon>
The point is to generate crystal classes with JSON mappings so that they can be copy-pasted into a project. It will help with wrapping large APIs like docker's
<watzon>
Just generates boilerplate code
BlaXpirit has joined #crystal-lang
oprypin has quit [Remote host closed the connection]
<FromGitter>
<sdogruyol> @bararchy it's because of JSON::Any change
<FromGitter>
<straight-shoota> @watzon yes I understand the purpose, I just don't get why the boilerplate generator istself is not a Crystal tool as that would simplify the toolchain
<FromGitter>
<sdogruyol> are you getting that error from kemal @bararchy ?
<FromGitter>
<j8r> yes, because macros are specials - no object orientation, so no dots.
<FromGitter>
<j8r> but the `[0..9]` syntax may be implemented - normal arrays are
<FromGitter>
<r00ster91> oh man there really should be an easier way to generate 10 times puts
<FromGitter>
<j8r> like python, a `for i in range(10)` ?
<FromGitter>
<j8r> BTW this is quite surprising to generate exacly the same thing `n` times with a macro, are you sure the `10.times { puts }` can't fill your needs?
<FromGitter>
<r00ster91> i dont really have a "need". I just want to know how to generate this with macros
maattdd has quit [Ping timeout: 248 seconds]
<FromGitter>
<j8r> very ofter the array is filled with strings(or whatever), this way you have a macro boilerplate that will be used for each string in the array
<FromGitter>
<r00ster91> but this isnt really efficient. its a dumb way. there should be something else
<FromGitter>
<j8r> a macro is used to avoid boilerplate
<FromGitter>
<j8r> To generate classes, defs, variables that's share a same structure. Here, that's exactly the same, so the macro is not really useful
<FromGitter>
<j8r> I don't know how the compiler works, but maybe the `x.times` method is close of macros for performance
<FromGitter>
<j8r> better said: `puts; puts; puts; puts` vs `4.time { puts }` may be close
maattdd has joined #crystal-lang
alex`` has joined #crystal-lang
maattdd_ has joined #crystal-lang
devil_tux has quit [Ping timeout: 248 seconds]
alex`` has quit [Ping timeout: 252 seconds]
jradd has joined #crystal-lang
maattdd_ has quit [Ping timeout: 260 seconds]
alex`` has joined #crystal-lang
<FromGitter>
<jwaldrip> How can I make an abstract method with a block signature?
<Papierkorb>
add a fully typed &block argument
<Papierkorb>
the implementations don't need to have that argument as long they `yield` like normal. They can have it of course.
<watzon>
@straight-shoota I don't know how you mean. I wanted it to be a web based tool which is pretty much the only reason I used JS. Also the json-to-go project was done in JS, and I baed my project off of it so keeping it in JS made things a little simpler
alex`` has quit [Ping timeout: 240 seconds]
maattdd_ has joined #crystal-lang
maattdd_ has quit [Ping timeout: 276 seconds]
<FromGitter>
<jwaldrip> I got an alternative implementation of Handlers/Middleware working without linked lists!
<FromGitter>
<jwaldrip> Do you think it would be valuable to propose a change into Crystal with this implementation?
<FromGitter>
<sdogruyol> @jwaldrip sorry for not following, what's the purpose of this change?
jradd has quit [Quit: WeeChat 2.0.1]
maattdd_ has joined #crystal-lang
maattdd_ has quit [Ping timeout: 256 seconds]
maattdd_ has joined #crystal-lang
maattdd_ has quit [Ping timeout: 240 seconds]
<FromGitter>
<jwaldrip> A handler is used in an http route, and sometimes contains configuration. In some router configurations, handlers may want to be reused with their configuration. Because each Handler today is a linked list. You would have to duplicate every handler to have it exist as part of a different list
<FromGitter>
<jwaldrip> That is not the case in the implementation I just shared.
<FromGitter>
<jwaldrip> There is no modification to each middleware to make it middleware, which means they can now also be structs in this implementation where they could not before.
maattdd_ has joined #crystal-lang
maattdd_ has quit [Ping timeout: 276 seconds]
maattdd_ has joined #crystal-lang
maattdd_ has quit [Ping timeout: 260 seconds]
maattdd_ has joined #crystal-lang
hightower2 has joined #crystal-lang
alex`` has joined #crystal-lang
maattdd_ has quit [Ping timeout: 252 seconds]
maattdd_ has joined #crystal-lang
maattdd_ has quit [Ping timeout: 260 seconds]
greengriminal has quit [Quit: Leaving]
<FromGitter>
<Yive> is it not possible to create a hash which will have other hashes stored in it?
<Papierkorb>
of course it's possible.
<FromGitter>
<Yive> hmm I might not be doing it right then since `table = {} of String => Hash` errors out
maattdd_ has joined #crystal-lang
<Papierkorb>
>> table = {} of String => Hash; p(table)
<DeBot>
Papierkorb: can't use Hash(K, V) as generic type argument yet, use a more specific type - https://carc.in/#/r/3lp6
<Papierkorb>
> use a more specific type
<Papierkorb>
Do as the compiler tells you and you shall succeed.
<Papierkorb>
Static languages aren't like dynamic languages in that you have to proof to the compiler that what you're about to do can be traced at compile.time and will work at run-time. That's the reason there's no "NoMethodError" at run-time.
<FromGitter>
<sdogruyol> styler1972 ideally, it'd be suitable to use Nginx as reverse proxy for your Kemal application
<FromGitter>
<sdogruyol> but you can also use Kemal with custom port and SSL
<styler1972>
i'll end up getting to that eventually
<styler1972>
so you run two instances of the webapp? one on 80 and one of 443?
<FromGitter>
<sdogruyol> well like I said you better use Nginx for that and proxy both 80 and 443 ports to Kemal
<styler1972>
i mean this works for now.. basically im just setting up a placeholder so i can configure gsuite.. i'll take your advice regarding nginx
Guest75431 is now known as baweaver
<Papierkorb>
You should always use NGINX (or apache or so) over directly exposing the application servers. The benefits are too large, and the disvantages of not are too large too
baweaver has quit [Changing host]
baweaver has joined #crystal-lang
<FromGitter>
<sdogruyol> ^
<Papierkorb>
Except for local development, there's no reason to ever not use NGINX (or apache or ...)
<styler1972>
chrome on mac, didnt convert anything
<FromGitter>
<sdogruyol> @watzon interesting
<Papierkorb>
> 480KiB of JS?
<Papierkorb>
Letting go of horizontal cursor/movement keys makes the cursor jump to the beginning of the line, it also generates errors in the log
<Papierkorb>
(using Firefox)
<watzon>
Yeah it's meant to be more of a copy/paste thing. The large JS size is a temporary issue. Right now all of my JS is being bundled together for the whole site.
<Papierkorb>
`{"a": [{ "bar": 1 },"Hi",4]}` tries to generate a class inside the Array(..) definition
<watzon>
styler1972: what did you do? It's meant to convert input pasted with ctrl-v (or cmd-v), I'll add support for regular paste later hopefully
<watzon>
Papierkorb: Crap. I'll check it out
<Papierkorb>
Apart from that it's nice that it's already using union types
<watzon>
Yeah that was one of the goals. It's nice to have unions in Crystal.
<styler1972>
watzon: i just typed actually
<styler1972>
copy/paste works like a charm
maattdd_ has joined #crystal-lang
styler1972 has quit [Quit: Page closed]
<FromGitter>
<j8r> @watzon is it planned to have the equivalent in crystal?
maattdd_ has quit [Ping timeout: 240 seconds]
<watzon>
@jr8 well I've already done most of the hard work which is figuring out how to do it. I don't see why I couldn't pretty easily make a Crystal version
<watzon>
Do you have a use case in mind?
<FromGitter>
<j8r> yeah! that's exactly what I need when handling different configurations from different softwares
<FromGitter>
<j8r> I want to build a REST api to modify e.g. my configuration of Transmission torrent, Ghost blog etc
jnyw has joined #crystal-lang
robacarp has joined #crystal-lang
mooe has joined #crystal-lang
devil_tux has joined #crystal-lang
<devil_tux>
so I just did an apt update of crystal compiler and for some reason it didn't append to bin path, so I symlinked in manually to bindir but now everytime I try to `shards build` some strange `execvp` error terminates the compiler process
<devil_tux>
I'm on v0.24.1 running on RHEL
rohitpaulk has joined #crystal-lang
<devil_tux>
I've switched `crystal` version in shards.yml but to no avail
<robacarp>
does crystal have any libraries for terminal cursor manipulation?
<devil_tux>
robacarp: isn't there an ncurses fork?
<robacarp>
that feels a little heavy for what I'm after, I just want to be able to make a list of items in the terminal, similar to what fish-shell does for tab completion
<robacarp>
curses is for writing to the whole window, right?
<devil_tux>
robacarp: try TerminalTable
<devil_tux>
from top of my head
<devil_tux>
might be of use
<FromGitter>
<robacarp> I looked at that too, and it might be, but I want to have the cursor jump between options printed in the table, so they can be selected and rearranged.
<FromGitter>
<robacarp> maybe I should just use curses
<watzon>
Curses may be a little heavy, but it does just about everything
<watzon>
If you can find a c library that does what you want you can always wrap it
<watzon>
Or just write your own by with stdout. That shouldn't be too difficult
<robacarp>
I was headed in that direction, but searching stack overflow for information I found one post that said "use the stdlib in <language>" and I thought I should do a survey to find out what's out there
<robacarp>
awesome_crystal has a bunch of things, but nothing that overtly does what I want
<devil_tux>
tried initing a new project, still same error .. shall I write issue?
faustinoaq has joined #crystal-lang
faustinoaq has quit [Client Quit]
faustinoaq has joined #crystal-lang
faustinoaq has quit [Client Quit]
faustinoaq has joined #crystal-lang
<FromGitter>
<CaDs> Hello, this might be a silly question, but here goes nothing. Is there any documentation regarding how to build crystal itself? ⏎ I’m looking into this issue https://github.com/crystal-lang/crystal/issues/5672 and I was wondering how to test it in local