RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.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> <proyb6> If PHP development is more haste, less speed. Need to look else where
Renich has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter> <girng> @proyb6 what you mean?
<FromGitter> <proyb6> @girng that speedy, correct performance takes time to develop and coding style must be consistent across programmers with different level of experience in PHP.
<FromGitter> <dscottboggs_gitlab> in other words it's hard to write PHP that performs well? I could've guessed haha
<FromGitter> <girng> i wish i wasn't born so soon, i'd be using crystal for webserver and the gameserver..
<FromGitter> <dscottboggs_gitlab> I'm so confused... in this (https://github.com/dscottboggs/flix.cr/blob/9af828945b1c9c0a0b4f89f87318de5e2e47fbc6/src/auth/all_users.cr#L25) code, if I replace the `delegate` statements with a `forward_missing_to`, I get this error: ` can't use instance variables at the top level`
<FromGitter> <dscottboggs_gitlab> stripping it down to the bare class and module doesn't replicate the issue https://carc.in/#/r/5tuc
<FromGitter> <dscottboggs_gitlab> so I've probably messed something up, but then why do the specs pass with `delegate`?
Renich has quit [Quit: Renich]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
Raimondi has joined #crystal-lang
<FromGitter> <anamba> @nagash so, i finally got a chance to try your take on the html escaping issue (https://play.crystal-lang.org/#/r/5td6) it seems to be working! with one caveat: literal strings with identical content all have the same object_id, so by marking one safe, you mark them all safe. that confused me and made my specs fail until i remembered that, but in 99.99% of real-world cases, it should not be an issue. this
<FromGitter> ... approach could be viable! there is one thing i am having trouble with... overriding `String#+(other : self)`. should be able to figure that out though
<FromGitter> <anamba> ok, when adding to a real project, i found that there is one major issue with this approach. not every String in the app needs to be html safe, it turns out this adds significant overhead in a real project. again, being able to create a class that inherits from `String` would resolve this issue.
<FromGitter> <anamba> have to go now (won't be able to start AoC on time today 😢 ) but i pushed an experimental branch with the reference tracking code https://github.com/anamba/safe_ecr/tree/exp-reference-list
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter> <j8r> I've found a composition trick
<FromGitter> <j8r> This allow to perform an action only when the method is first called, and reuse this value after vs performing the action in `initialize`
<jhass> why's that better than https://play.crystal-lang.org/#/r/5twc ?
<FromGitter> <j8r> @jhass shorter, an ivar avoided
<jhass> how do you avoid an ivar? I would get that if you didn't modify @path, but...
<jhass> also shorter is not always easier to follow ;)
<FromGitter> <j8r> I agree its ugly, the parentheses with `puts` is to show it's parsed only once
<jhass> written like https://play.crystal-lang.org/#/r/5twd it's a pretty standard ruby idiom
<FromGitter> <j8r> In reality it would be https://play.crystal-lang.org/#/r/5twf
<FromGitter> <j8r> Simple as that 😀
<FromGitter> <dscottboggs_gitlab> ☝️ December 20, 2018 3:29 AM (https://gitter.im/crystal-lang/crystal?at=5c1b52ed41637902415a2861) nice
ashirase has quit [Ping timeout: 268 seconds]
ashirase has joined #crystal-lang
<FromGitter> <codenoid> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c1b72c941637902415af123]
<FromGitter> <codenoid> how to allow more deep recursion
<FromGitter> <codenoid> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c1b73129c82bd0240424be3]
<oprypin> codenoid, come back when you have over 1000 terrabytes of RAM
<FromGitter> <codenoid> sure
<oprypin> that's what this level of recursion would require
<FromGitter> <codenoid> school gimme that test, there must be other way to acquire that
<oprypin> sure, you just gotta ask the right question
<FromGitter> <kingsleyh> oprypin - I managed to resolve my openssl issues
<oprypin> ok cool
<FromGitter> <kingsleyh> oprypin - the problem was I was doing `require "openssl"` as well as requiring my binding - and seems the openssl one wins - so instead I upgraded my envs to use openssl 1.1.1a - so now both openssl and my binding use the system one which has all the functions I need
<FromGitter> <kingsleyh> I find it strange that the default openssl on all my envs is 1.0 and there are 3 different versions of openssl 1.1.1 being the recommended one on the openssl website
<FromGitter> <bararchy> @kingsleyh did you manage to find and operate the right relevant functions you needed for encryption?
<FromGitter> <kingsleyh> @bararchy yeah I did
<FromGitter> <kingsleyh> @bararchy I can generate key pairs and sign and verify right now - and I think I know which funcs I need for ECDH encrypt / decrypt
<FromGitter> <kingsleyh> @bararchy but right now I'm investigating ECDHE as that seems better for Perfect Secrecy
<FromGitter> <kingsleyh> @bararchy the main issue I have with using openssl is that the default installed on all my envs was 1.0 which doesn't have all the funcs for getting the r,s from the signature, so I've had to u/g all my envs to use 1.1.1 (which is the recommended version anyway)
<FromGitter> <kingsleyh> the upside though is that it's most compatible with other libraries - the ECDSA we hand crafted was not compatible with other libs - this was also the case with all the other crystal ECDSA implementations I've looked at so far
<FromGitter> <cserb> I can't seem to find an example for how WebSockets work. If I do something like this ` socket = HTTP::WebSocket.new(URI.parse("ws://localhost:2345/stats"))` I get `Unhandled exception: Error connecting to 'localhost:2345': Connection refused (Errno)` ⏎ ⏎ I want to open up a listener so that I can connect to it via browser.
<FromGitter> <greenbigfrog> That's a websocket client (unless I'm mistaken)
<FromGitter> <kingsleyh> yeah you need to start a server
<FromGitter> <cserb> That's what I want... how do I do that?
<FromGitter> <cserb> http server?
<FromGitter> <kingsleyh> Kemal has Websocket server support
<FromGitter> <kingsleyh> I've used the one in Kemal and it works great
<FromGitter> <cserb> I don't want to use Kemal
<FromGitter> <kingsleyh> there's also this one - that I haven't used before: https://github.com/alternatelabs/bifrost
<FromGitter> <kingsleyh> any reason to not using Kemal?
<FromGitter> <cserb> I want bare bone DIY :)
<FromGitter> <greenbigfrog> look at how kemal implements it then ⏎ kemal is nice though
<FromGitter> <cserb> mainly because I want to learn, but also because it hijacks ARGV on start and prints an error if it's not supported
<FromGitter> <kingsleyh> I guess you want to use the TCPSockets stuff then
<FromGitter> <cserb> Also not, because I really want it to run in the browser
<FromGitter> <kingsleyh> er you want to build a browser client side websocket server? you would need javascript for that
<FromGitter> <kingsleyh> usually a websocket is just a way of getting realtime communication from a web app to a backend server
<FromGitter> <kingsleyh> instead of polling
<FromGitter> <cserb> yes
<FromGitter> <cserb> exactly
<FromGitter> <cserb> I want a crystal backend server
<FromGitter> <kingsleyh> so you will need to use TCPSockets
<FromGitter> <kingsleyh> on SushiChain we use https://github.com/tbrand/router.cr - which you could easily extend to add a websocket handler
<FromGitter> <kingsleyh> otherwise you will have to create your own TCPSocket server and write code that handles the websockets requests - they start as regular HTTP usually then get upgraded with an upgrade call
<FromGitter> <kingsleyh> also make sure to check out Sec-WebSocket-Key and Sec-WebSocket-Accept stuff
<FromGitter> <cserb> 👍 this was helpful
<FromGitter> <kingsleyh> @cserb I found this - this is exactly what you want to do - it should be very easy to follow this and convert it for Crystal
<FromGitter> <cserb> @kingsleyh thank you! I didn't thought to look for a ruby example :)
<FromGitter> <cserb> btw I can't find any of this logic in Kemal. I'm still unclear how they are doing it
tankf33der has joined #crystal-lang
<tankf33der> o/
<jhass> hi
akaiiro has quit [Quit: Ping timeout (120 seconds)]
akaiiro has joined #crystal-lang
<FromGitter> <girng> @jhass hi o/
<FromGitter> <kingsleyh> @cserb I believe Kemal uses the built in websocket handling for the upgrade via the built in HTTP Context - which houses a handler for the websocket request: see here: https://github.com/crystal-lang/crystal/blob/18e76172444c7bd07f58bf360bc21981b667668d/src/http/server/handlers/websocket_handler.cr#L10
<FromGitter> <kingsleyh> so in Kemal you just have to pass the websocket handler
<FromGitter> <greenbigfrog> Hm. Smh I get a `no such file` error even when using the full path
<FromGitter> <greenbigfrog> kind of lost here ⏎ so in `FileA.cr` `File.file?("/home/frog/cromd/layout.html")` is true ⏎ but in `sth/FileB.cr` `File.file?("/home/frog/cromd/layout.html")` is false
akaiiro has quit [Ping timeout: 240 seconds]
akaiiro has joined #crystal-lang
ska has joined #crystal-lang
<ska> I'm having problem installing `apt-get install clang-6.0 lldb-6.0 lld-6.0` I can't find the libjsoncpp0 dependency. I run Debian 9.5
<ska> I used the repo data from https://apt.llvm.org/ .. Anyone know the process for Debian 9.5?
Raimondi has joined #crystal-lang
<ska> Sorry: I had wrong repo.. It works fine.
<FromGitter> <girng> :D
<FromGitter> <greenbigfrog> still haven't been able to resolve that file not found error
ua has quit [Quit: Leaving]
Raimondi has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<oprypin> greenbigfrog, maybe share more details
<oprypin> what do you see for the command `ls -la "/home/frog/cromd/layout.html"` ?
ua has joined #crystal-lang
<FromGitter> <greenbigfrog> `-rw-r--r-- 1 frog frog 79 Dec 20 16:49 /home/frog/cromd/layout.html`
<FromGitter> <greenbigfrog> I'll write a quick gist
<FromGitter> <greenbigfrog> hm. in my test I can't replicate...
<oprypin> i'd be more worried if you could :p
<FromGitter> <greenbigfrog> stupid me didn't trim trailing `\n`. Is there a more simple method instead of `#strip("\n")`?
<oprypin> greenbigfrog, the best method would not leave you with that trailing `\n` in the first place
<oprypin> an im actually worried what is it that you're doing because FYI file names can contain `\n` normally
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <greenbigfrog> true.
<oprypin> so do you wanna talk about it?
<FromGitter> <greenbigfrog> writing sth to replace jekyll (not gonna go further than a PoC most likely)
<oprypin> it's good that you're giving a high level view but that's a bit too high level. i mean how are you getting those file names
<FromGitter> <greenbigfrog> oh. regex out of a front matter
<oprypin> oh. that's not so bad then
<oprypin> so let's find a way to not have the `\n` in there, just share that code snippet
<FromGitter> <greenbigfrog> I already did 😄 had the `\n` at the wrong spot in the regex ⏎ (sorry that we both tried moving this conversation in separate directions) ⏎ Thanks
<oprypin> ok, sorry for fearmongering. good job
<oprypin> greenbigfrog, oh yeah, maybe there actually is a useful tip to gather from this. i'm just guessing here, perhaps you were trying to debug it with `puts filename` and didnt see the stray newline. with `p` you would have seen it.
<FromGitter> <greenbigfrog> Yep. Aware of that. Just sometimes I like to miss this stuff 😏
non-aristotelian has joined #crystal-lang
<FromGitter> <j8r> Dumb question: what's the diff between struct/class with only self methods vs a module with only self methods?
<oprypin> j8r, well you can instantiate a class and you can include a module
<oprypin> when considered alone, no difference
Raimondi has joined #crystal-lang
<FromGitter> <Willyboar> Hello everyone.
<FromGitter> <Willyboar> i recently start check crystal and i wonder why crystal don't have an official shard hosting service
<FromGitter> <Willyboar> or am i missing something?
Raimondi has quit [Ping timeout: 240 seconds]
<woodruffw> possibly -- shards don't have builds/packages in the way that pip/npm/rubygems do; they're just metadata about a repository that tells a dependent how to retrieve and use some crystal code
<woodruffw> (to the best of my understanding)
<woodruffw> so there's nothing to really host -- it's all within the git repo that already contains the shard's source
<FromGitter> <Willyboar> yes but i think a central shard host will be better, because you didnt have to manage git branches, no release tagging etc
<oprypin> Willyboar, first time i hear that writing `git tag` (which is good to do even on its own merit) is somehow more difficult than learning some custom service
edcragg has joined #crystal-lang
<FromGitter> <kingsleyh> There are many benefits to the current shard system - one of them being it's distributed - so there is no central server that can go down and cause everyone to complain about not being to fetch shards. (of course github, bitbucket etc can go down but they deal with getting things back up pretty quickly)
<FromGitter> <kingsleyh> I also like having control over my own releases and tagging etc
<oprypin> haha no central server
<FromGitter> <kingsleyh> However - I guess there is nothing stopping anyone from building their own shards equivalent of rubygems - when in a locked down corporate environment it can be useful to run your own internal cache which the powers above can sign off on etc
<FromGitter> <Willyboar> Sorry i wasn't clear (my english is quite bad). I just want to say that i think is syntax better to have : ⏎ ⏎ ```and depending on creators methods``` [https://gitter.im/crystal-lang/crystal?at=5c1c0e75b8760c21bbfd4039]
<oprypin> u just save the commit hash and u don't necessarily need to store the files locally
<oprypin> Willyboar, maybe it is but it's not a big deal
<FromGitter> <Willyboar> Yeah maybe not
<FromGitter> <Willyboar> but still i think is better for new users
<FromGitter> <kingsleyh> potentially the repo will not be a github and perhaps at bitbucket
<FromGitter> <Willyboar> or gitlab
<FromGitter> <kingsleyh> so being able to specify where it is sounds like a useful thing
<oprypin> nobody's suggesting to force github
<oprypin> @Willyboar was suggesting to have crystal's own namespace
<oprypin> (and one way to achieve that which is a special site for publishing shards)
<FromGitter> <kingsleyh> yeah I just mean if you remove the repo location - `github: shardrepo/myshard` you loose the ability to specify it
<FromGitter> <kingsleyh> in his snippet above he removed it - but you might want `bitbucket: shardrepo/myshard` - if you don't keep that - it won't know where to look up the repo (unless you just scan through all know repo services)
<FromGitter> <Willyboar> i just gave an example
maxpowa has quit [Ping timeout: 268 seconds]
<FromGitter> <kingsleyh> oh well I don't really understand the conversation - but I like how it is now if anyone cares lol :)
maxpowa has joined #crystal-lang
<FromGitter> <Willyboar> of course is nice to have the option of github, bitbucket, gitlab or any git hosting service. But imo it would be better for a new programmer the first snippet.
<FromGitter> <Willyboar> Of course we care. But after all is just a conversation
<FromGitter> <j8r> I dream of a cross sync mirror solution between gitlab, github and bitbucket :)
go|dfish has quit [Ping timeout: 250 seconds]
<FromGitter> <j8r> With issues/PR mirroring. But what's sure we'll need 3 bots
tankf33der has left #crystal-lang [#crystal-lang]
<FromGitter> <Willyboar> Well maybe the shard hosting is not actually a hosting but a middleware of this three.
Raimondi has joined #crystal-lang
<FromGitter> <Willyboar> @j8r i like the way you are thinking
<FromGitter> <j8r> @Willyboar haha thx. I got your point, shard is basic. I guess the ideal would be to have a `source` key to be a string or list of one or more mirrors. Then the shard.lock can lock the mirror source. Actually the key is a value – `github`, `gitlab`, however pretty sure only one of those key has to be used a a time :/
<FromGitter> <j8r> *one at a time
<FromGitter> <j8r> Hopefully we'll got our Yarn, to replace our belovel NPM shards :)
<FromGitter> <j8r> A day... That's why I'm militating to move out all shards specific stuff out of the Crystal compiler
<FromGitter> <j8r> *advocating is the term
go|dfish has joined #crystal-lang
<FromGitter> <Willyboar> Well, crystal looks promising. I will give it a try in the next couple of weeks. I have some OS projects in my mind.🎉😉
<FromGitter> <bew> @Willyboar 👍