RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.26.1 | 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> <girng> what does ** do in a parameter?
<FromGitter> <girng> i see ty
<FromGitter> <girng> https://play.crystal-lang.org/#/r/4vhs what's the difference?
<FromGitter> <girng> is it just semantics, or is there a performance difference using either 1?
<FromGitter> <Blacksmoke16> well the diff is in the first one you are passing each named param on its own, while in the 2nd you are passing it a named tuple
<FromGitter> <Blacksmoke16> but also notice in the first how you are passing it `1` as first param
<FromGitter> <Blacksmoke16> the splat accounts for additional params after the first required
<FromGitter> <girng> yeah, but it still becomes a NamedTuple?? https://play.crystal-lang.org/#/r/4vhx for example, look at typeof's result
<FromGitter> <girng> i'm guessing there is a reason then why someone should pass it in as additional parameters, or just pass a namedtupleliteral
<FromGitter> <Blacksmoke16> yea it captures the extra params as a namedTuple
bds has quit [Ping timeout: 272 seconds]
<FromGitter> <Blacksmoke16> depends on the senario i guess
<FromGitter> <girng> ok i think i get it now, was just worried when i first saw the ** i thought it had to do with memory / pointers for a second
<FromGitter> <girng> but i'm fine now ty
<FromGitter> <Blacksmoke16> np
<FromGitter> <girng> one reason why i love crystal so much don't have to deal with all that stuff!
return0xe has quit [Remote host closed the connection]
return0xe has joined #crystal-lang
ashirase has quit [Ping timeout: 245 seconds]
ashirase has joined #crystal-lang
ashirase has quit [Ping timeout: 245 seconds]
ashirase has joined #crystal-lang
baweaver is now known as baweaver_away
<FromGitter> <codenoid> is crystal stable for this ⏎ ⏎ get "/" do ⏎ spawn do ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5b8cb9e61d3a5711b6d75add]
<FromGitter> <codenoid> ```get "/" do ⏎ spawn do ⏎ 1.minutes > process ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5b8cb9ee60f9ee7aa4cc8418]
<FromGitter> <codenoid> 5 minutes, maybe more
zorp_ has joined #crystal-lang
_whitelogger has joined #crystal-lang
DTZUZO has quit [Ping timeout: 244 seconds]
return0xe has quit [Remote host closed the connection]
return0xe has joined #crystal-lang
jokke__ has joined #crystal-lang
<FromGitter> <bararchy> I just had the amazing experiance of building an `npm` package, who the hell said that crystal is slow to compile ...
<FromGitter> <bew> X)
Groogy1 has joined #crystal-lang
<Groogy1> Morning! o/
ua_ has quit [Quit: Leaving]
ua has joined #crystal-lang
Raimondii has joined #crystal-lang
ashirase has quit [Ping timeout: 244 seconds]
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
ashirase has joined #crystal-lang
<FromGitter> <bew> Hey Groogy, how are you doing? ;)
sz0 has joined #crystal-lang
hightower2 has quit [Remote host closed the connection]
<Groogy1> Just fine, vacation over so back to work. Got tons of stuff done with my crystal projects though
<FromGitter> <bew> Cool! What did you do?
<Groogy1> Fixed so my libraries would work better with shards and put together at least an example on boleite on how to get started with the framework
<Groogy1> also continued on my game
DTZUZO has joined #crystal-lang
<FromGitter> <icyleaf> Hey folks, Halite v0.7.0 has been released, here is some mainly changelog: ⏎ ⏎ 1) Features (a.k.a middlewares) support ⏎ 2) Add cache feature (speed up developing) ⏎ 3) And some API changes. ... [https://gitter.im/crystal-lang/crystal?at=5b8d0ff21d3a5711b6d9733b]
hightower2 has joined #crystal-lang
<jokke> hey there o/
<jokke> is there something like a file watcher lib similar to maybe guard which would allow compiling crystal sources on change and maybe running the compiled program?
<jokke> ah got it
<FromGitter> <rishavs> I am trying to do some simple html parsing using the XML/httpClient libs. How do I get a specific tag from the html? ⏎ In my example, I am trying to retrieve a tag `<meta content=\"My cool website\" name=description />` ⏎ my code is; ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5b8d2e0dcff55e56179e8709]
<FromGitter> <bew> This is not XPath syntax
<FromGitter> <bew> Looks like you need to do `//html/head/meta[@name=description]`
<FromGitter> <bew> Oops with `'` around `description`
<FromGitter> <bew> So: `//html/head/meta[@name='description']`
<FromGitter> <bew> (not tested, i applied what wikipedia said^^)
<FromGitter> <rishavs> I actually had tried this earlier . it gives me nil :( `pp document.xpath_node("//html/head/meta[@name='description']")`
<FromGitter> <bew> Then it can't find it
<FromGitter> <bew> ..
<FromGitter> <rishavs> i have also tried `pp document.xpath_node("meta[@name='description']")` and `pp document.xpath_node("//meta[@name='description']")`. They all just give nil as output 😢
<FromGitter> <f1refly_gitlab> Have you tried giving the meta element actual content? I haven't worked with xpaths in crystal yet, but i guess it tries to return the contents instead of the node element
<FromGitter> <bew> Hm no it should return the node here
<FromGitter> <bew> And in this case, the first node (only) matching this xpath
<FromGitter> <f1refly_gitlab> jokke: i use guardian (https://github.com/f/guardian) or more specifically a fork without emojis (https://github.com/f1reflyyyylmao/guardian). It's linked in the library you already found and can be configured with yaml
<jokke> thanks!
<FromGitter> <codenoid> @rishavs i'm never use xpath xD
<FromGitter> <codenoid> https://github.com/kostya/myhtml
<jokke> f1refly_gitlab not sure if i could do what i'm doing in guardian
<jokke> f1refly_gitlab: https://p.jokke.space/f5qbe/crystal
<FromGitter> <rishavs> @codenoid my plan is to try with vanilla crystal. Only if there is no other way, i'll use libraries 😄
<FromGitter> <rishavs> So far i have used 0 libraries in my web project. Its masochistic but fun
<FromGitter> <f1refly_gitlab> jokke: Probably not. I didn't knew you where doing something as complex, as for small and simple projects guardian is probably the easier solution, hence my recommendation
<FromGitter> <codenoid> 👍 @rishavs
<FromGitter> <f1refly_gitlab> @rishavs In your example xml the element "name" has the value "description", but the quotes are missing. Could you try using `<meta content="My cool website" name="description" />` instead in your html?
<FromGitter> <proyb6> I wonder who been doing benchmark on Crystal?
<jokke> sure :)
<jokke> but it's not _that_ complex
<jokke> i'd argue it's a very common usecase
<jokke> it's kinda like shotgun for ruby
<FromGitter> <f1refly_gitlab> It's more complex than "if i change a thing please recompile", which is the only use case of the people i know, since we're not web developers and mostly toying around with the language
<jokke> ah sure
<FromGitter> <f1refly_gitlab> But yeah, it probably is common
<FromGitter> <f1refly_gitlab> I'll give you that
<FromGitter> <f1refly_gitlab> also guardian is hand
<jokke> crystal is reeeeally great for the web ;)
<jokke> and the ecosystem is growing pretty fast
<FromGitter> <f1refly_gitlab> I think crystal is a good general use language that will be great with multi threading
<jokke> well it has green threads already
<FromGitter> <j8r> Fibers you mean
<FromGitter> <f1refly_gitlab> I think it doesn't has true multi threading yet
<jokke> yeah no native threads
<FromGitter> <j8r> There is concurrency, and multi process
<FromGitter> <f1refly_gitlab> fibers != multithreading, but they're working on it
<jokke> but it already takes advantage of io blocking
<FromGitter> <f1refly_gitlab> yeah, its very handy
<jokke> so it has the same type of multithreading as most scripting languages
<jokke> which have the global interpreter lock
<jokke> like ruby or python
<FromGitter> <f1refly_gitlab> Except it's not a scripting language and is not interpreted
<jokke> exactly
<FromGitter> <f1refly_gitlab> Well, it's fast enough for my purposes as is
<jokke> which results in much lower memory footprint which in turn lets you spawn up as many instances as you have cores if you don't need IPC
<jokke> so for the web when you're dealing with stateless apis and such it's already great as is
<FromGitter> <f1refly_gitlab> Hmm
<FromGitter> <f1refly_gitlab> As a not-web-developer, where can i learn about this?
<jokke> but it will become truly awesome with real multi processing
Raimondii has joined #crystal-lang
<jokke> hmm good question
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
<FromGitter> <j8r> Multi thread is only really useful for games
<jokke> well and number crunching
<jokke> or image/video processing
<FromGitter> <f1refly_gitlab> It's also useful for heavy calculations
<FromGitter> <f1refly_gitlab> yeah
<FromGitter> <j8r> But else you may want to scale at number of machines
<FromGitter> <j8r> not only on a big single one
<FromGitter> <f1refly_gitlab> The programs i work with need to perform tons of complex calculations very fast to stay somewhat responsive and we're using c++
<jokke> stuff like travelling salesman and other np complete algorithms can sometimes also profit from multithreading
<FromGitter> <j8r> It's simpler to spawn N processes for N number of cores, with instances communicating to each others, than designing a multihread app to laverage 16 cores
<jokke> travelling salesman is actually only np hard though
<jokke> you could use something like zeromq for ipc
<jokke> i think there are even bindings for crystal
<jokke> yup
<FromGitter> <j8r> for example look at AWS, better to spawn 8 T2 small than 1 big c5 x2large
<jokke> j8r: AWS lambda can run binaries :P
<FromGitter> <f1refly_gitlab> It's all purely hypothetical currently because we deploy for windows anyway (i know, i know...)
<FromGitter> <f1refly_gitlab> We're toying around with it to present it to our boss should it be available in the future
<FromGitter> <rishavs> @f1refly_gitlab unfortunately, i don't have control on the tags. I just chose that as an example. the exact tag is `<meta content=\"Tate, a young boy on the autism spectrum, loves watching tops spin. One day, he realizes that watching them takes him into a different world.\" name=description />`. My end goal is to strip the open graph tags from the html of any website
<FromGitter> <j8r> jokke: I don't for lambda if it's better to spawn more single threadfunctions vs one big that do multi thread
<FromGitter> <f1refly_gitlab> @rishavs Shame. Can you test it anyway so we can see if this is the problem with the previous approach
<jokke> j8r: yeah that's what i meant. spawning a single threaded crystal binary in lambda
<jokke> also docker swarm with replication is great to make use of this
<FromGitter> <j8r> i mean, for example, a go binary?
<jokke> hm?
<FromGitter> <j8r> What's the recommended GOMAXPROCS?
<FromGitter> <j8r> on Lambda
<jokke> i have no idea
<jokke> i've only fiddled with lambda once
<jokke> if i read the docs of lamba correctly it just scales horizaontally
<FromGitter> <j8r> makes totally sense
<FromGitter> <j8r> so goodbye the big java monolith
<jokke> yupp
<jokke> i'd like to try this
<FromGitter> <rishavs> @f1refly_gitlab This is what I tried. My test url is `https://medium.com/welldone-software/an-overview-of-javascript-testing-in-2018-f68950900bc3` and the source contains `meta property="og:image" content="https://cdn-images-1.medium.com/max/1200/1*yt0amuDg5VL3QtomaZHvNA.png">` my code is: ⏎ ```` res_str = HTTP::Client.get(url) document = XML.parse(res_str.to_s) prop = "og:image" xpath =
<FromGitter> ... "meta[@property=#{prop}]" pp document.xpath_node(xpath) ```` and output, yet again is nil ⏎ _
zorp has joined #crystal-lang
zorp_ has quit [Ping timeout: 252 seconds]
<FromGitter> <f1refly_gitlab> try putting "'" around the "og:image" and add a doubleslash, this works for me:
<FromGitter> <f1refly_gitlab> `content = File.read "./site.html"` ⏎ `document = XML.parse(content.to_s)` ⏎ `prop = "og:image"` ⏎ `xpath = "meta[@property='#{prop}']"` ⏎ `pp document.xpath_node(xpath)` [https://gitter.im/crystal-lang/crystal?at=5b8d465ee5b40332ab3b17e1]
<FromGitter> <f1refly_gitlab> I don't know if the output has any worth for you, but at least it's not nil anymore
<FromGitter> <f1refly_gitlab> "'" is a single ' with "" around it by the way, i don't know what it's called in english
<FromGitter> <rishavs> Did gitter die for everyone or just me?
<FromGitter> <rishavs> @f1refly_gitlab can u try with `https://medium.com/welldone-software/an-overview-of-javascript-testing-in-2018-f68950900bc3` as the url?
<FromGitter> <f1refly_gitlab> @rishavs Didn't die for me
<FromGitter> <rishavs> damn. still nil for me.... ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b8d474ce5b40332ab3b1bed]
<FromGitter> <f1refly_gitlab> I can't because i can't be assed to handle the proxy my employer set up for the non-it folks. I downloaded the websites html though, that's what i put in site.html
<FromGitter> <f1refly_gitlab> don't use double quotes, but single quotes
<FromGitter> <f1refly_gitlab> `pp document.xpath_node("meta[@property='og:image']")`
<FromGitter> <bararchy> Why does ⏎ ⏎ ```nilable.x if nilable``` ⏎ ⏎ raises "might be nil" in compile time [https://gitter.im/crystal-lang/crystal?at=5b8d478511b41f69dbb45d43]
<FromGitter> <f1refly_gitlab> That's because the trailing if is actually a macro that the compile expands to a full if later but doesn't like for type checking to my understanding
<FromGitter> <codenoid> @rishavs is that content loaded by ajax ?
<FromGitter> <codenoid> *rendered by javascript
<FromGitter> <rishavs> 3 nils in a row #_# ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Can't even use carc.in for this. gives me a `Program received and didn't handle signal SYS (31)` ... [https://gitter.im/crystal-lang/crystal?at=5b8d487d4be56c5918d6ecd2]
<FromGitter> <f1refly_gitlab> Have you verified that yo uget the source you want with your crystal code?
<FromGitter> <rishavs> @codenoid I don't think so. I disabled JS for medium and I am getting the same page.
<FromGitter> <rishavs> yep
<FromGitter> <f1refly_gitlab> have tried adding the double slash as i suggested?
<FromGitter> <rishavs> btw, any idea why this isn't working in carc.in? https://carc.in/#/r/4vle
<FromGitter> <codenoid> yeah, and it's meta tag too
<FromGitter> <f1refly_gitlab> they probably blocked some networking to prevent abuse
<FromGitter> <f1refly_gitlab> @rishavs please try `pp document.xpath_node("//meta[@property='og:image']")`
<FromGitter> <rishavs> @f1refly_gitlab same. nil 😿 ⏎ @codenoid I don't think so. I really hope noone is putting meta tags using ajax as that would break all sorts of spiders
<FromGitter> <rishavs> i will try another site, which I am certain has no ajax tags
<FromGitter> <codenoid> @rishavs yup
<FromGitter> <rishavs> Just tried `http://ogp.me/`. This site is likely not to have any ajax based meta tags as they are the main site for open graph rules. ⏎ code is ; ⏎ ⏎ ```code paste, see link``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5b8d4a6958a3797aa3f85739]
<FromGitter> <f1refly_gitlab> Works for me
<FromGitter> <rishavs> weird.... can you put it on carc.in?
<FromGitter> <f1refly_gitlab> https://carc.in/#/r/4vln
<FromGitter> <f1refly_gitlab> again with my local file
<FromGitter> <f1refly_gitlab> wait a sec, i'll try something
<FromGitter> <f1refly_gitlab> Ok it doesn't run in carc.in and i can't test it right now, but have you tried replacing the "to_s" with a "body"?
<FromGitter> <f1refly_gitlab> So it would read ⏎ ⏎ ```res_str = HTTP::Client.get("http://ogp.me/") ⏎ document = XML.parse(res_str.body)``` [https://gitter.im/crystal-lang/crystal?at=5b8d4c71cff55e56179f5983]
<FromGitter> <rishavs> that.... fixed it
<FromGitter> <rishavs> -___-
<FromGitter> <rishavs> 😆
<FromGitter> <f1refly_gitlab> Happd to help :)
<FromGitter> <rishavs> i want to go bang my head somewhere. Wasted hours on this 😢
<FromGitter> <rishavs> Thanks for your patience and help @codenoid and @f1refly_gitlab
<FromGitter> <f1refly_gitlab> You should probably spew more debug with puts next time
<FromGitter> <j8r> yeah, `p!`, `p` and `typeof()`
<FromGitter> <f1refly_gitlab> Also look up "gdb -gui" for debugging if you're *really* bored at work
<FromGitter> <j8r> @bcardiff use sometimes `pp!({x, x.class, typeof(x)})`, which is quite good to debug I think
<FromGitter> <f1refly_gitlab> Yes, that's a good solution
<FromGitter> <rishavs> does a protobuff library for crystal exists?
<FromGitter> <vladfaust> I'm an OFFICIAL CONTRIBUTOR now
<FromGitter> <vladfaust> http://i.imgur.com/DpQ9YJl.png
<FromGitter> <vladfaust> A very important and feature-rich commit, yeah
<FromGitter> <vladfaust> Just wanted to share that finally after 1.5 years I put something into the core
<FromGitter> <rishavs> 👯
<FromGitter> <Blacksmoke16> is there a crystal version of PHP elvis operator like `foo = bar ?: baz;` which resolves to like `foo = bar ? bar : baz;`
<FromGitter> <bew> @Blacksmoke16 `foo = bar || baz`
<FromGitter> <bew> @vladfaust yay \o/ welcome to the party ;)
* FromGitter * Blacksmoke16 facepalm, forgot about that one
<FromGitter> <Blacksmoke16> thanks
<FromGitter> <noahlh> Wondering if the following is possible or if I'm taking the wrong approach: Is there a way to assign a splat argument to an instance variable if the arguments themselves are Tuples of unknown size? (I'm implementing a Matrix data structure). For example, I'd like to be able to do: ⏎ ⏎ ```struct Matrix ⏎ def initialize(*input) ⏎ @data = input ⏎ end ⏎ end``` ⏎ ⏎ But without an explicit
<FromGitter> ... type for `@data`, this doesn't work. And I'm not sure how to annotate `@data` to be a `Tuple` of `Tuples` of unknown size... [https://gitter.im/crystal-lang/crystal?at=5b8d848f11227d711d0e0e1a]
<FromGitter> <Sija> @noahlh You’d need to make it `Matrix(T)`
<FromGitter> <Sija> https://carc.in/#/r/4vn9
<FromGitter> <Sija> or with splat operator: https://carc.in/#/r/4vnb
salvor has quit [*.net *.split]
danzilio has quit [*.net *.split]
thi_ has quit [*.net *.split]
OvermindDL1 has quit [*.net *.split]
manveru has quit [*.net *.split]
pippin has quit [*.net *.split]
<FromGitter> <noahlh> ahhhh that's perfect. So simple. Thank you @Sija !
<FromGitter> <Sija> or https://carc.in/#/r/4vnf
<FromGitter> <noahlh> (I'm still getting the hang of generics so this is slightly new ground for me - very helpful)
salvor has joined #crystal-lang
<FromGitter> <noahlh> what's the difference between your latter 2? How is Matrix(*T) handled differently from Matrix(T)?
<FromGitter> <Sija> depends do you want to have the type tuple expanded as a @data type or not
<FromGitter> <Sija> the first one is of type `Matrix(Tuple(Tuple(Int32, Int32, Int32, Int32), Tuple(Int32, Int32, Int32, Int32)))`, 2nd: `Matrix(Tuple(Int32, Int32, Int32, Int32), Tuple(Int32, Int32, Int32, Int32))`
<FromGitter> <noahlh> ahhhh i see
<FromGitter> <noahlh> that makes perfect sense
<FromGitter> <noahlh> this is extremely helpful - thanks again
<FromGitter> <Sija> np, yw :)
DTZUZO has quit [Ping timeout: 240 seconds]
sevensidedmarble has joined #crystal-lang
DTZUZO has joined #crystal-lang
ua has quit [Ping timeout: 244 seconds]
ua has joined #crystal-lang
baweaver_away is now known as lemur
lemur is now known as baweaver
sevensidedmarble has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
<FromGitter> <Blacksmoke16> i found a strange bug, but im not sure what is causing it...https://paste.ee/p/cJe8M
<FromGitter> <Blacksmoke16> cant seem to reproduce it outside of mosquito, maybe @robacarp has an idea?
pabs has joined #crystal-lang
hightower2 has quit [Ping timeout: 244 seconds]
<FromGitter> <Blacksmoke16> huh cant reproduce it at all now
<FromGitter> <Blacksmoke16> oh well
<FromGitter> <Blacksmoke16> ah there it goes
<FromGitter> <robacarp> Weird. Maybe a networking or server glitch?
<FromGitter> <Blacksmoke16> thinking it has something to do with the my HTTP client keep-alive, being idle for too long
<FromGitter> <Blacksmoke16> because only seems to happen when the time between each run is higher
zorp has quit [Ping timeout: 252 seconds]
<FromGitter> <Blacksmoke16> yea must be something with that, ran fine first time, then 2min later ran again and got the error. closed my client connection at end of each run and 2nd time ran fine
<FromGitter> <Blacksmoke16> will let it run longer and see what happens
zorp has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <bew> I can't find the (iirc open) issue about destructuring, anyone has the link? (for things like `a, b, *rest = {1, 2, 3, 4}`)
<FromGitter> <bew> nvm, found it (#132)