ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.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
alex has joined #crystal-lang
<FromGitter> <jaydorsey> are macros supposed to work for class methods? was trying to do something like this: https://play.crystal-lang.org/#/r/8ch1
<FromGitter> <jaydorsey> (the first non-macro version was just to make sure i had syntax for macro correct
<FromGitter> <dscottboggs_gitlab> you need to convert the macro param from a `SymbolLiteral` to a `MacroID` by calling `.id` on it
<FromGitter> <dscottboggs_gitlab> https://play.crystal-lang.org/#/r/8ch2
<FromGitter> <dscottboggs_gitlab> https://play.crystal-lang.org/#/r/8ch6
<FromGitter> <jaydorsey> thank you so much, i wouldn’t have figured that out on my own
<FromGitter> <dscottboggs_gitlab> no problem at all :D
<FromGitter> <jaydorsey> that was exactly what I needed (aside from getting the method signature wrong as well 😂 )
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 265 seconds]
alex has quit [Ping timeout: 258 seconds]
_whitelogger has joined #crystal-lang
dwdv has quit [Ping timeout: 265 seconds]
alex has joined #crystal-lang
Creatornator has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
uu91 has joined #crystal-lang
alex has quit [Ping timeout: 260 seconds]
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
ht_ has joined #crystal-lang
ht_ has quit [Quit: ht_]
<FromGitter> <girng> i'm getting this error https://paste.ee/p/e8oaa on a fresh installation of debian 8 64-bit
<FromGitter> <girng> i get it after running `crystal muffin.cr` (muffin.cr is puts "Hello!")
<FromGitter> <girng> i found this https://stackoverflow.com/a/47725251
<FromGitter> <girng> I just stumbled upon on this thread https://news.ycombinator.com/item?id=19750507 look at Crystal ;D
vitallium has joined #crystal-lang
<FromGitter> <Nicolab> Hello, I'm looking for a validation lib like this https://github.com/validatorjs/validator.js#validators ⏎ I did not find an equivalent allowing to have multiple pre-built validations ⏎ ⏎ Please, is there such a shard? [https://gitter.im/crystal-lang/crystal?at=5e12fb522af31b403d2857d3]
<repo> in case someone is interested: https://github.com/repomaa/cresult
vitallium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<repo> i would also appreciate it if someone could check out the benchmark and make sure it doesn't optimize away everything
Nicolab has joined #crystal-lang
<Nicolab> @repo Cresult is Nice! Simple and useful. Good choice for the struct ;)
<sorcus> Hi @Nicolab. You can try this https://github.com/Blacksmoke16/assert
<repo> Nicolab: unfortunately there's no way to do something like `type Result(T, E) = Ok(T) | Err(E)`
<repo> this would make it perfect
<repo> since you could type restrict the method return values
<repo> i an easy way
dwdv has joined #crystal-lang
<Nicolab> @repo Indeed, but you have avoided slipping into a too heavy over-pattern (class, hash, etc. in the heap). For such a lib which will be executed exessively I find your choice wise.
<Nicolab> Hi @sorcus Thanks, I have looked, assert is good but I'm looking for something simpler and lighter.
<Nicolab> micro check only
<sorcus> @Nicolab, oh, sorry. I don't know another validaton library :-(
<Nicolab> No soucy, thank you :)
<FromGitter> <j8r> repo: I don't see the use case of `try!`
<FromGitter> <j8r> Remind me something I have done on https://github.com/j8r/crystalxd
<FromGitter> <j8r> But for on this it's just `Success(T) | Error`
alex`` has joined #crystal-lang
<FromGitter> <j8r> same for the `ResultMethods` module, don't see the need
<FromGitter> <j8r> a yielding method would be useful too
<FromGitter> <j8r> except that, nice, starred!
alex`` has quit [Ping timeout: 260 seconds]
alex`` has joined #crystal-lang
dwdv has quit [Quit: quit]
return0__ has joined #crystal-lang
return0e_ has quit [Ping timeout: 268 seconds]
Nicolab has quit [Ping timeout: 246 seconds]
Nicolab has joined #crystal-lang
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
<repo> j8r: try! works like rust's ? operator. So it's basically a guard clause. If the expression passed to the macro evaluates to an Err object it will be propagated (because it's returned immediately), if it's an Ok object it will be unwrapped, so that you can use it further along the way
<repo> yeah the ResultMethods module is a bit overkill
<repo> but it should ensure that both Err and Ok have the same methods
<repo> you could think of it as something like this: foo = method_might_raise
flaviodesousa has joined #crystal-lang
<repo> if method_might_raise raises, the following code won't be executed and because of a missing rescue the exception will be propagated one stack level higher.
<repo> to mimick this type of behavior try! (or in rust the ? operator) exists
<FromGitter> <j8r> ha ok I see
<FromGitter> <j8r> repo I tried this before https://github.com/j8r/error.cr/
<FromGitter> <j8r> please put the benchmark elsewhere than `src/` :)
<FromGitter> <j8r> because it's not really library code
duane has quit [Ping timeout: 265 seconds]
<repo> j8r: i actually had it in bench/benchmark.cr before but it wouldn't correctly rebuild it (with shards build --release) for some reason.
<repo> but i'll move it back
<repo> j8r: ah i remember this error.cr shard. we both had the issue of not being able to unwind the stack with musllibc
<FromGitter> <Blacksmoke16> @Nicolab have you seen the ad hoc validation part of assert?
duane has joined #crystal-lang
alex`` has quit [Ping timeout: 258 seconds]
alex`` has joined #crystal-lang
Creatornator has joined #crystal-lang
duane has quit [Ping timeout: 260 seconds]
Nicolab has quit [Ping timeout: 260 seconds]
duane has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alex`` has quit [Ping timeout: 258 seconds]
<repo> j8r: interesting! i added a trace option and this seems to be the thing that eats up a lot of performance: https://p.jokke.space/CmpNoJ/
<repo> even though i already optimized a lot by using a tuple instead of an array
vitallium has joined #crystal-lang
Nicolab has joined #crystal-lang
<FromGitter> <Nicolab> @Blacksmoke16 Yes, `Assert.not_blank("foo")` etc It's very well for unit tests or other. But here, I only want to make small checks (true or false), do not execute classes and a lot of logic for each check, there can be ten validations per request (and thousands of requests by second).
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 268 seconds]
Creatornator has joined #crystal-lang
<FromGitter> <Blacksmoke16> Then probably best to write something yous
<FromGitter> <Blacksmoke16> Yourself*
<FromGitter> <Blacksmoke16> A module with some class methods would do it
<FromGitter> <Blacksmoke16> Fwiw all the ad hoc things do is new up a class and run the validation of that class, so isn't really that much going on other than newing up the validation class
<FromGitter> <Blacksmoke16> Need to do some benchmarking but going to refactor it a bit to use structs which are probably better suited for this
<repo> how can i get the line from which a macro was called (inside the macro)?
alex`` has joined #crystal-lang
sagax has quit [Ping timeout: 258 seconds]
<FromGitter> <Blacksmoke16> There is like https://crystal-lang.org/api/master/Crystal/Macros/ASTNode.html#line_number:StringLiteral%7CNilLiteral-instance-method
ht_ has joined #crystal-lang
<FromGitter> <j8r> repo look a my shard :)
<repo> yeah i found out
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vitallium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Nicolab has quit [Quit: Leaving.]
Nicolab has joined #crystal-lang
Nicolab has quit [Quit: Leaving.]
alex`` has quit [Ping timeout: 258 seconds]
alex`` has joined #crystal-lang
ur5us has joined #crystal-lang
alex`` has quit [Ping timeout: 268 seconds]
alex`` has joined #crystal-lang
sorcus has quit [Quit: WeeChat 2.7]
alex`` has quit [Ping timeout: 258 seconds]
alex`` has joined #crystal-lang
hpyc9 is now known as Irving
tankf33der has joined #crystal-lang
Irving is now known as hpyc9
Nicolab has joined #crystal-lang
sorcus has joined #crystal-lang
Creatornator has joined #crystal-lang
Creatornator has quit [Client Quit]
Creatornator has joined #crystal-lang
sagax has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ht_ has quit [Quit: ht_]
Creatornator has joined #crystal-lang
<FromGitter> <girng> wow, so when I do `crystal src/MasterServer.cr` on the vps, the ram goes up by 450MB permanently and stays there. If I build my app and then just do `./MasterServer`, ram usages goes up like a couple MB
<FromGitter> <girng> why is that?
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <Daniel-Worrall> Does anyone have any examples of distributing crystal apps? I've just deployed an app with proper linking to the config folders and a systemd startup file, but I did it all by hand and hard-coded `/etc/appname/config.yml`
<FromGitter> <Daniel-Worrall> It's probably holding onto the crystal compiler in ram girng
<FromGitter> <Daniel-Worrall> are you building regular or release too?
<FromGitter> <girng> release, yeah i think your right
<FromGitter> <girng> i was just kinda surprised at first. i was like how the hell is my app using that much memory lol
Yxhuvud has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> the former has to compile the binary then run it, the latter just runs it
<FromGitter> <Blacksmoke16> @Daniel-Worrall i mainly use Docker, swarm (or ideally k8s) is also an option if you have multiple things going
duane has quit [Ping timeout: 268 seconds]
<FromGitter> <Blacksmoke16> easy to scale/move around etc
Creatornator has joined #crystal-lang
<FromGitter> <randiaz95> Guys... I know you guys are backend experts, but do you know any html/css libraries for small carousels like slick js?
<FromGitter> <Blacksmoke16> im sure a quick google search would turn up plenty
<FromGitter> <Blacksmoke16> bootstrap prob has something
<FromGitter> <tenebrousedge> bootstrap, also I think there are jquery plugins
<FromGitter> <randiaz95> oo really jquery?!
<FromGitter> <randiaz95> I like jquery
<FromGitter> <randiaz95> I googled bootstrap carousels and its only for the super large ones.
<FromGitter> <randiaz95> with the buttons below.
<FromGitter> <tenebrousedge> slick is jquery
<FromGitter> <randiaz95> I am going to use waltzer js
<FromGitter> <randiaz95> slick is not safari safe lol
<FromGitter> <tenebrousedge> k
<FromGitter> <randiaz95> well at least not 100 % safe
<FromGitter> <randiaz95> requirements are safari or nothing lol.
<FromGitter> <randiaz95> DANG IPHONE USERS!!!!
<FromGitter> <tenebrousedge> huh
<FromGitter> <Daniel-Worrall> I was distributing with docker and it ended up swallowing up 600MB up with a start-up of 200MB. Systemd reduces that to 2MB
<FromGitter> <Daniel-Worrall> Maybe k8s would help, but this works.
<FromGitter> <randiaz95> there is a built in zipping library to compress your entire ubuntu file system
<FromGitter> <tenebrousedge> docker is about reproducible builds
<FromGitter> <randiaz95> Yep, Docker is when you are big
<FromGitter> <randiaz95> or if you want to be human capital ready, you can learn when your small
<FromGitter> <Blacksmoke16> makes deployments easy too, just pull down new image and restart
<FromGitter> <Blacksmoke16> or if you need to setup another server just install docker and done
<FromGitter> <Daniel-Worrall> With a 250mb host, I needed the ram
<FromGitter> <Blacksmoke16> ah fair
<FromGitter> <randiaz95> You mean ram! not hard disk?
<FromGitter> <randiaz95> 1) o
<FromGitter> <Daniel-Worrall> Ram host yes
<FromGitter> <randiaz95> Jeez
<FromGitter> <Daniel-Worrall> Cheap though
<FromGitter> <randiaz95> lol each of my apps are still on 2-3 gig ram droplets
uu91 has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #crystal-lang
Creatornator has quit [Quit: Textual IRC Client: www.textualapp.com]
duane has joined #crystal-lang