<watzon>
Ok, so if I wanted to test scry I'd just pipe some crystal into it right?
<watzon>
Like `cat main.cr | scry`
renovo_ has quit []
<crystal-gh>
[crystal] javanut13 opened pull request #5294: Add reduce macromethod to TupleLiteral and ArrayLiteral (master...arrayliteral-reduce-macro-method) https://git.io/vFPWe
azah has quit [Quit: ""]
andrewzah has joined #crystal-lang
andrewzah has quit [Client Quit]
andrewzah has joined #crystal-lang
andrewzah has quit [Client Quit]
<FromGitter>
<megatux> Hi everyone! I've some problems trying to compile the sample apps in *crystal-gobject* shard. Crystal v 0.23. I know Ruby but no Crystal. There is an "undefined macro variable 'main' " error. I think it is defined in an already required file as a *fun*
andrewzah has joined #crystal-lang
andrewzah has quit [Client Quit]
andrewzah has joined #crystal-lang
andrewzah has quit [Client Quit]
andrewzah has joined #crystal-lang
<faustinoaq>
@watzon no, scry doesn't work in that way. Scry is a Language Server Protocol implementation, you must use it with a client like VIM, Eclipse, Sublime, Atom, VSCode, etc
<faustinoaq>
@watzon also please try scry master branch instead of latest version, we have fixed some issues :)
vikaton has quit [Quit: Connection closed for inactivity]
<watzon>
faustinoaq: yeah I figured that out. I'm actually on the master branch now, I was just confused as to why the VS Code plugin didn't seem to be working
<FromGitter>
<vonKingsley> @cyclecraze_twitter its because location has the possibility to be nil (nilable: true). The compiler checks to see if there is a method called lat for nil. Since it doesn't fine one, the compiler throws that error. if you know for a fact that its not going to be nil you can do `house.location.not_nil!.lat` or if the json could actually not include a location node you could do this
<Groogy>
my library is probably too big for whatever you want to do so you should create your own specifically for this :) Though you can use mine as guide on how freeimage works
<Papierkorb_>
Roses are red, violets are blue, Groogy wrote lib bindings, and so can you
<Groogy>
That's a quite nice poem ^^
<Papierkorb_>
haven't seen you around in recent weeks Groogy, were you on vacation?
<Groogy>
Nah just been working on release candidate and day 1 patch
<Papierkorb_>
ah crunchy time
<Groogy>
some bad planning happened TM and the tech lead is on vacation
<Groogy>
Didn't like being tech lead, so stopped and now pulled back in D:
danielpclark has joined #crystal-lang
<FromGitter>
<zyriuse75> do you know an equivalant of CSSH ?
<FromGitter>
<bew> @zyriuse75 what is it?
<crystal-gh>
[crystal] icyleaf opened pull request #5296: Remove mistake example in query property comment (master...correct-query-property-doc) https://git.io/vFPSW
<FromGitter>
<Rinkana> Is there some article on functions to avoid for better performance. Like the `+=` operator. It took me some time to debug some performance issues with that operator: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a0c19c9f257ad9109993a3d]
<FromGitter>
<Rinkana> You would expect that they would perform somewhat the same
<Groogy>
eh what, what's slow with +=?
<Groogy>
doesn't += just expand into foo = foo + 5?
<FromGitter>
<Rinkana> Adding to the array, as seen in the `Slow` example
<FromGitter>
<bew> well, `ary += ["bla"]` will be transformed to `ary = ary + ["bla"]` I think, so it'll create a temporary array and re-assign to ary
<Groogy>
ooooh yeah
<FromGitter>
<bew> and `<<` will directly add the item to `ary` to there's no temporary object
<Groogy>
so if you think about that += is always a shortcut for literally foo = f00 + something
<Groogy>
it becomes more obvious
<FromGitter>
<Rinkana> Yeah that's correct.
<FromGitter>
<bew> and @Rinkana, `["foo", "bar", "baz"].each` is slower than `{"foo", "bar", "baz"}` and probably even slower than assigning the tuple to a variable, and iterate it in the `.times`'s block
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<Rinkana> @bew the example is a simplified version of what i have.
<FromGitter>
<bew> I imagine that ;)
<FromGitter>
<Rinkana> But would there be a reason to keep using `ary = ary + [...]` for arrays instead of looping trough it and adding it to itself?
<FromGitter>
<Rinkana> > but we can't remove `+=` for arrays, as it is a syntax sugar on `ary = ary + {something}`, Array only has to define `+` ⏎ ⏎ No but what about changing the `+=` operator for arrays to my other implementation?
<Papierkorb_>
+= isn't a real operator, it's rewritten.
<Groogy>
how do you mean bew?
<Papierkorb_>
And as += is `x = x + y`, it's *not* equivalent to using #<<
<FromGitter>
<bew> Groogy instead of writing the methods yourself, you can use `class_property?`!
<Yxhuvud>
because being able to concatenate two arrays without modifying them is necessary to have. In this case you will just have to learn the performance cost of creating new arrays.
<Groogy>
oh
<Groogy>
didn't know it existed
<FromGitter>
<bew> that's why I tell you ;)
<Groogy>
does property? do the same?
<FromGitter>
<Rinkana> Papierkorb_ what's the difference then?
<Groogy>
it creates a ? method instead of a getter?
<Groogy>
what if I only want a getter do I then do getter?
<Papierkorb_>
Rinkana, please think about "passing by reference."
<Papierkorb_>
(/or read up on it)
<Papierkorb_>
And what it implies in the general case.
<Groogy>
Rinkana #<< acts on left hand object, while #+ will create a new array
<Papierkorb_>
> Because CouchDB databases are meant to be exposed directly to the internet, this enabled privilege escalation, and ultimately remote code execution, on a large number of installations.
<Papierkorb_>
Let me reiterate:
<Papierkorb_>
> Because CouchDB databases are meant to be exposed directly to the internet,
<Papierkorb_>
... Just why man
<Groogy>
why the hell would you...
<Papierkorb_>
That is so obviously stupid that not even the OWASP is warning against it
<Papierkorb_>
Reminds me of the perl sucks talk which exploited a really similar behaviour in popular powered-by-Perl web applications
Papierkorb_ has quit [Remote host closed the connection]
Papierkorb_ has joined #crystal-lang
qard has joined #crystal-lang
<FromGitter>
<bararchy> We should ofc encourage this kind of thinking ;)
danielpclark has quit [Ping timeout: 240 seconds]
<Papierkorb_>
?
danielpclark has joined #crystal-lang
<FromGitter>
<bararchy> The more RCE the better ?
<FromGitter>
<bararchy> Hahahah
<FromGitter>
<bararchy> I was working with an organization, not a small one, who didn't want to use VPN as its "not secured" , they ended opening up multiple RDP servers to the internet
<FromGitter>
<bararchy> A much better solution hahahha
<Papierkorb_>
Yeah RDP never had vulns or anything
<FromGitter>
<bararchy> Never ever , also , super secured support of SSL3
unshadow has joined #crystal-lang
danielpclark has quit [Remote host closed the connection]
<Groogy>
Hey kinda curious... the code for like parsing crystal code and get AST nodes from that...
<Groogy>
I can do like require "something" to access that right?
<Papierkorb_>
For UI imho a declarative approach is amazing
<Papierkorb_>
but YAML surely isn't nice once you want to put some kind of script into it :P
<Groogy>
yeah but also YAML kind of... grows
<Groogy>
let's say I try to define a window in it and its components under it
<Papierkorb_>
But maybe, like `onclick: some.random(js_code);` would still be the most sane way, if all functionality is kinda specialized - and you're working on your own anyway
<Papierkorb_>
The UI designer can't mess up the logic if there's no UI designer to begin with :^)
Excureo has quit [Remote host closed the connection]
<hightower4>
I'm looking to load files/plugins in runtime. Plugins would be in Crystal. Is there a convenient way/recipe to do so, or I should by all means load stuff during compile time and that's it?
<literal>
how could Foo.new ever be called when filename is Nil? I
<Papierkorb>
you're using filename in a caught block (L13). as the block is stored, the compiler can't guarantee that it's actually called
<Papierkorb>
hence it must assume that the type is String or Nil
<literal>
but how can I ever make sure of it myself if even an "if filename" won't do?
<Papierkorb>
but as the block still exists on line 17 onwards, the compiler can't know if from line 17 to 20 `filename` isn't written to, it could be changed from a String to a nil
<Papierkorb>
either `if var=`, or use a different option parser lib
<literal>
I thought that only applied to instance variables
<FromGitter>
<victor95pc> It's not running because the compiler thinks I want a string like this: ```def initialize({{ fields.map { |f| "@#{f[:name]} : #{f[:type]}" }.join(", ") }})```
<FromGitter>
<victor95pc> but I want this: ```def initialize(@:name : String, @:age : Int32)```
<FromGitter>
<victor95pc> so you guys know a way to do it?
<FromGitter>
<bew> you should look at how `record` is defined
<FromGitter>
<victor95pc> record?
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<faustinoaq>
@victor95pc I think you should add `.id` at end of `join(", ").id`
<FromGitter>
<bew> you still use .map for the initialize, but yes, you get the idea!
<FromGitter>
<victor95pc> yup, thx
<oprypin>
victor95pc, check out the nice `{{*` feature that `record` uses though
<FromGitter>
<victor95pc> now I'm anxious about 1.0
<oprypin>
well it is basically equivalent to `.join(", ").id` but hey
<oprypin>
victor95pc, don't worry about it any time soon :p
<hightower4>
mm, help me a little bit here. I do x= @@X; next unless x; x.something() and I get undefined method something for Nil (compile-time type is (Logger | Nil))
<hightower4>
How do I restrict type to Logger?
<oprypin>
hightower4, i dunno, maybe `next` just doesnt get the type inference
<FromGitter>
<marksiemers> Still working on our solution for amber right now @sdogruyol - hopefully by the end of day we'll have something and perhaps you can adapt it for kemal, if you like.
<hightower4>
I have text = [ "txt", "cfg"]. Then I want to run 'case extension' and have a 'when text'. How exactly do I do that? (i.e. have case/when match a value from array)
<hightower4>
Actually, that can be a tuple, in which case *text would work. So I just need an equivalent of %w() which creates a tuple rather than an array
<hightower4>
Hm looks like *text doesn't work even with a tuple