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> <fridgerator> @girng make those elements draggable without jquery
Raimondi has quit [Read error: Connection reset by peer]
Raimondi has joined #crystal-lang
fanta7531 has joined #crystal-lang
Dreamer3 has joined #crystal-lang
fanta7531 has quit [Quit: ...]
bazaar_ has joined #crystal-lang
bazaar has quit [*.net *.split]
fanta7531 has joined #crystal-lang
Dreamer3 has quit [Quit: Leaving...]
DTZUZO has quit [Ping timeout: 268 seconds]
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> `can't execute OpAssign in a macro` rip
DTZUZO has joined #crystal-lang
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c4001ce1cb70a372aef7548]
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab
<FromGitter> <Blacksmoke16> `localhost:8888/test/ # => {"code": 400, "message": "Required query param 'bar' was not supplied."}`
<FromGitter> <Blacksmoke16> if it doesnt match its nil or the default value
<FromGitter> <Blacksmoke16> if the pattern is nil, there is no pattern
<FromGitter> <dscottboggs_gitlab> oh shit that's perfect, nice!
<FromGitter> <Blacksmoke16> functionaly it works yea, but still messing with the implementation details
<FromGitter> <Blacksmoke16> might refactor how im building out the params
<FromGitter> <Blacksmoke16> is getting a bit too complex now to keep everything in order
<FromGitter> <dscottboggs_gitlab> yeah working in macro land on something that complex can get super messy
<FromGitter> <Blacksmoke16> well that portion isnt really in macro land
<FromGitter> <Blacksmoke16> way things work atm the string params are added to an array
<FromGitter> <Blacksmoke16> but those params have to get added in right order to match the method params
<FromGitter> <Blacksmoke16> and the method params have to be in right order to match route params, request body, then query params
<FromGitter> <Blacksmoke16> its a catch 22
<FromGitter> <Blacksmoke16> i cant auto build out routes based on method arg names/types since i dont know where they go
<FromGitter> <Blacksmoke16> and i cant build out method params/names since i dont know the types
<FromGitter> <Blacksmoke16> would be nice if order of method params didnt matter, will have to see if i can think of something
<FromGitter> <dscottboggs_gitlab> wow that sounds tough
<FromGitter> <Blacksmoke16> :shrug: I have some ideas
<FromGitter> <Blacksmoke16> See how it goes :p
<FromGitter> <Blacksmoke16> Anyway, off to bed o/
<FromGitter> <dscottboggs_gitlab> sleep well
<FromGitter> <Blacksmoke16> Well going to write this in case I forget before I go to bed :p
<FromGitter> <dscottboggs_gitlab> yeah, famous last words
<FromGitter> <dscottboggs_gitlab> 3 hours later
<FromGitter> <dscottboggs_gitlab> 😆
<FromGitter> <Blacksmoke16> Think I can just use parameter name in route to match with method param names, would require route and action names to match, which is IMO a good thing
<FromGitter> <Blacksmoke16> And just always call the request body, body
<FromGitter> <Blacksmoke16> So then order you define parameters in doesn't matter
<FromGitter> <Blacksmoke16> Ok, night :p
<FromGitter> <dscottboggs_gitlab> good night, good luck!
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
DTZUZO has quit [Ping timeout: 246 seconds]
DTZUZO has joined #crystal-lang
jemc has quit [Ping timeout: 268 seconds]
marmotini_ has joined #crystal-lang
marmotini has joined #crystal-lang
marmotini_ has quit [Client Quit]
fanta7531 has quit [Quit: ...]
zolbatar has joined #crystal-lang
zolbatar has quit [Client Quit]
ashirase has quit [Ping timeout: 258 seconds]
ashirase has joined #crystal-lang
[spoiler] has quit [Ping timeout: 264 seconds]
[spoiler] has joined #crystal-lang
fanta7531 has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter> <girng> good morning! ready for some crystal coding today am hyped
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <diegogub_gitlab> Hello all..I'm keep reading from @asterite to stop using NamedTuples. I wanted to do some functional programming in Crystal, and I cannot see better fit than NamedTuples to pass data around.
<FromGitter> <diegogub_gitlab> Should I use them everywhere?
<FromGitter> <girng> did you stumble upon that SO question lol
<FromGitter> <girng> i did, too. was surprised he said that
<FromGitter> <girng> but he's prob right...
<FromGitter> <drum445> @diegogub_gitlab generally anonymous objects aren't ideal, but if you are using them for small or no processing it's fine
<FromGitter> <drum445> Everything has a use case
<FromGitter> <drum445> But nothing suits all of them
<FromGitter> <diegogub_gitlab> @drum445 I'm mostly using aliases to NamedTuples..and pass them around functions. Merging them and so on..would that give me any memory leak?
<FromGitter> <drum445> I wouldn't think it would cause a memleak, if you're passing them around a lot I would probably suggest using a class. If you're dealing with JSON you can use Class.from_json. ⏎ Classes are also safer as you won't run into key errors
<FromGitter> <diegogub_gitlab> @drum445 I guess so, class without public properties would be safer. Thanks!
<FromGitter> <girng> @diegogub_gitlab i use namedtuples with `to_json` in a tick rate on my gameserver. ran it for a couple hours, etc no memory leak. for example, in my client Class: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c407bbd95e17b452566d0c9]
<FromGitter> <drum445> Yeah exactly, I'd recommend a look into the SOLID principles
<FromGitter> <diegogub_gitlab> @girng I will do some testing..
laaron has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab it was actually surprisingly easy...took like 2min lol
<FromGitter> <girng> gn
<jokke> hey
<jokke> is it possible to build html instead of xml using the XML.build method? (or any other method)
marmotini has quit [Ping timeout: 250 seconds]
Creatornator has joined #crystal-lang
laaron has joined #crystal-lang
<FromGitter> <j8r> I don't succeed how to `{{debug}}` `class_getter?`, does anyone know how to do?
<FromGitter> <j8r> I try to know how works `(class_)getter? do ... end` because calling the getter doesn't seems to do anything...
ua has joined #crystal-lang
<FromGitter> <j8r> https://carc.in/#/r/60rf
<FromGitter> <Blacksmoke16> https://carc.in/#/r/60rh
<FromGitter> <Blacksmoke16> they dont take a block afaik
marmotini has joined #crystal-lang
<FromGitter> <j8r> yes they does (see my carc)
<FromGitter> <j8r> It perfoms what's inside the block if the variable is nil
<z64> @j8r class_getter? is a different macro code than class_getter. it doesn't do anything with the block. https://gist.github.com/z64/eba030d96d822a220452cd912e944a89
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <j8r> z64 thanks, that what I was starting to think
<FromGitter> <j8r> I will create an issue
<z64> `class_getter` has a specific macro branch if a block is passed https://github.com/crystal-lang/crystal/blob/master/src/object.cr#L350-L351 ; `class_getter?` does not, it is basically just the second (falsey) branch https://github.com/crystal-lang/crystal/blob/master/src/object.cr#L562-L582
<z64> yw
Creatornator has joined #crystal-lang
<FromGitter> <AllanKlaus> Hey guys, I'm think in develp an appplication in my company using crystal and amber, it will go to production and interact receiving request from other apis and accessing database. ⏎ ⏎ Do you think crystal is stable to use with a framework to do it?
trashhalo[m] has quit [Ping timeout: 252 seconds]
trashhalo[m] has joined #crystal-lang
jemc has joined #crystal-lang
jemc has quit [Client Quit]
jemc has joined #crystal-lang
spacemanspam has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <Blacksmoke16> long as you keep up to date/aware of breaking changes it shouldnt be a big issue
Creatornator has joined #crystal-lang
<FromGitter> <waghanza> Hi @/all, any idea about next release date ?
<FromGitter> <AllanKlaus> @Blacksmoke16 is hard to keep the last version updated?
<FromGitter> <Blacksmoke16> i more so meant, be aware of upcoming changes, and dont blindly update
<FromGitter> <Blacksmoke16> on debian its just `apt update && apt upgrade`
<FromGitter> <AllanKlaus> thank you
<FromGitter> <Blacksmoke16> Just keep an eye on the changelog (https://github.com/crystal-lang/crystal/blob/master/CHANGELOG.md) and should be fine
<FromGitter> <Blacksmoke16> it gets updated when a new version is near release
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
Raimondi has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron- has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
Raimondi has quit [Ping timeout: 240 seconds]
laaron has joined #crystal-lang
marmotini has quit [Ping timeout: 268 seconds]
Creatornator has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<oprypin> oh goddammit
<oprypin> just did `(0...File.size(filename)).bsearch { |pos| file.seek(p pos)`
<oprypin> `-733341162`
<oprypin> `Unhandled exception: Unable to seek: Invalid argument (Errno)`
<Yxhuvud> big file?
<mps> '(0..File.size(' ?
<oprypin> thankfully `0u64...File.size(filename)` works
<FromGitter> <drosehn> interesting.
<oprypin> big file indeed. https://haveibeenpwned.com/Passwords
<Yxhuvud> ranges with different integer types as the endpoints may be a underexplored area, when it comes to tests etc.
<FromGitter> <codenoid> how are you
<FromGitter> <dscottboggs_gitlab> ☝️ January 17, 2019 8:22 AM (https://gitter.im/crystal-lang/crystal?at=5c40819f27611d4204bae4bd) oh wow, that's great!
<oprypin> wow, so my passwords are somehow not compromised
<oprypin> made this script for paranoics like myself (even though there's a good API to check) https://gist.github.com/a7bef68fc4804ba384178ee129465e74
spacemanspam has quit [Read error: Connection reset by peer]
<FromGitter> <codenoid> my old password is `indomiegoreng212` , bcoz i love noodle
<oprypin> ok thanks for the information :o
<FromGitter> <codenoid> i already become social engineering target many times, then i change my password to `1nd0mi3g0re212`
<FromGitter> <greenbigfrog> hunter2
<FromGitter> <codenoid> you can't login without my email :p
<oprypin> are u being serious right now
spacemanspam has joined #crystal-lang
<FromGitter> <bmulvihill> Thanks for the script @oprypin, I didn't want to put my passwords into that search box :P
sevensidedmarble has joined #crystal-lang
<FromGitter> <maiha> Just started to create a library for TokyoCabinet. ⏎ https://github.com/maiha/tokyocabinet.cr
<FromGitter> <dscottboggs_gitlab> @codenoid you do realize this chat is bridged to IRC which is logged and public right?
<FromGitter> <dscottboggs_gitlab> even if it wasn't wtf lol
jemc has quit [Ping timeout: 252 seconds]
fanta7531 has quit [Quit: ...]
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab thanks, deff makes it easier to use
<FromGitter> <Blacksmoke16> had it throw a compile time error if each action param name isnt present in the route/query param list
<FromGitter> <dscottboggs_gitlab> oh, that's easy
<FromGitter> <dscottboggs_gitlab> nice
<FromGitter> <Blacksmoke16> like `Action parameter 'user_id' is not present in route/query parameter list`
<FromGitter> <Blacksmoke16> or something along those lines
<FromGitter> <Blacksmoke16> 💯
<FromGitter> <Blacksmoke16> also made https://github.com/crystal-lang/crystal/issues/7316, will need that for more awesomeness to work
<FromGitter> <Blacksmoke16> now to think of what else that could i could do with that hehe
<FromGitter> <dscottboggs_gitlab> nice
<FromGitter> <dscottboggs_gitlab> I like it and will certainly give it a try next time I'm doing something that could make use of it
jemc has joined #crystal-lang
<FromGitter> <Blacksmoke16> <3
<FromGitter> <Blacksmoke16> have some ideas for future stuff as well
<FromGitter> <Blacksmoke16> like idea being some modular handlers you can do like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c40e2697a0f4d5b19c5c682]
<FromGitter> <dscottboggs_gitlab> and the included module would intercept the request at some point? that's great
<FromGitter> <Blacksmoke16> which would plop in a global (in this case) handler that would parse out a bearer token from request headers and set a `current_user` var, so then in all your actions would have access to `self.current_user` for custom auth or whatever
<FromGitter> <Blacksmoke16> security module is on my list but would require some hashing out to figure out how i want it to work
<FromGitter> <Blacksmoke16> current idea would be something like: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c40e3469bfa375aab191759]
<FromGitter> <Blacksmoke16> :shrug: see how it goes, am sure some other people here would have some feedback on how to best handle it
<FromGitter> <dscottboggs_gitlab> I really need to set aside some time to look over how Athena works, it seems pretty cool
<FromGitter> <Blacksmoke16> annotations and structs for the most part
<FromGitter> <Blacksmoke16> use structs as the payload of the router, which stores static data defined from the annotations at compile time
<FromGitter> <Blacksmoke16> so only thing that happens at runtime is route matching and param conversion
<FromGitter> <Blacksmoke16> what have you been working on lately?
<FromGitter> <dscottboggs_gitlab> Spent some time learning a bit of C++, Qt, reading the Rust book, and finishing up some demo projects so that hopefully I can get a job soon
<FromGitter> <dscottboggs_gitlab> I've been writing some Go the past couple days and it's so limiting next to crystal
<FromGitter> <Blacksmoke16> ah nice, good luck
<FromGitter> <Blacksmoke16> every lang i look at just doesnt look appealing compared to crystal for sure :p
<FromGitter> <dscottboggs_gitlab> thanks, I gotta go for a bit, I'll be on later though
<FromGitter> <Blacksmoke16> o/
spacemanspam has quit [Read error: Connection reset by peer]
spacemanspam has joined #crystal-lang
spacemanspam has quit [Read error: Connection reset by peer]
<FromGitter> <girng> o/
<FromGitter> <elorest> I feel like this is simple but I'm off somehow. ⏎ ⏎ I can set commands to a usb com port via bash but can't seem to get it in crystal. ⏎ ⏎ https://gist.github.com/elorest/81e97bd30152cb34aa25b4241907e4ca [https://gitter.im/crystal-lang/crystal?at=5c40f7e19bfa375aab199bc9]
<FromGitter> <elorest> `File.write("/dev/ttyUSB0", "\x05\x40\x10\x08\xA3".to_slice)` also works. I'd think it should be possible without closing the IO every time though.
CommanderViral has joined #crystal-lang
<FromGitter> <girng> possible to convert a boolean value to 1 or 0 based on true or false?
<FromGitter> <elorest> bool ? 0 : 1
<FromGitter> <maiha> @elorest `usb0.print` rather than `puts` ?
<FromGitter> <girng> @elorest ty
<FromGitter> <elorest> @maiha thanks. I tried, puts, write, <<, etc
<FromGitter> <maiha> ok. And two points. `IO#flush` and `open(..., "w")` ?
<FromGitter> <elorest> I'm trying to read responses as well which is why I used `a+`
<FromGitter> <elorest> I'll look into `IO::Flush`
<FromGitter> <Blacksmoke16> @girng https://play.crystal-lang.org/#/r/60y9
<FromGitter> <girng> should i do the ternary or to_unsafe?
<oprypin> ternary 100%
<oprypin> Blacksmoke16, pls
<FromGitter> <Blacksmoke16> `to_unsafe` does tenary
<FromGitter> <Blacksmoke16> so like, whats it matter? :p
<oprypin> and how exactly is that relevant
<FromGitter> <Blacksmoke16> i dont see the difference if its doing the same thing under the hood
<FromGitter> <Blacksmoke16> could have a better name, like `to_i`
<FromGitter> <elorest> @maiha I've tried this but it still doesn't work. ⏎ ⏎ ```File.write("/dev/ttyUSB0", "\x05\x40\x10\x08\xA3".to_slice)``` [https://gitter.im/crystal-lang/crystal?at=5c40fddc20b78635b63dc503]
<FromGitter> <Blacksmoke16> to match `to_s` which does the same thing but returns string representation
<FromGitter> <girng> @Blacksmoke16 i like to_unsafe better, see here (https://i.gyazo.com/0df8c62d4957e90249e2e0f9af621f9b.png). but iguess it's personal preference. gonna use to_unsafe, ty
<FromGitter> <Blacksmoke16> its literally the same thing
<oprypin> you're so hopeless
<FromGitter> <Blacksmoke16> what?
<FromGitter> <elorest> @girng I think `#to_unsafe` implies something untrue in this case
<FromGitter> <elorest> It's not returning a pointer or something.
spacemanspam has joined #crystal-lang
<FromGitter> <Blacksmoke16> should be named `.to_i` imo
<FromGitter> <Blacksmoke16> nothing unsafe about it
<oprypin> we have a function that is meant for C bindings interoperation, which, even though it's not named like what you want to do, happens **at the moment** to do what you want
<oprypin> if there was a `to_i` then you might use it, but there isn't, and it isn't about naming, it's about entirely different purposes
<oprypin> you don't just go around using **unsafe** things because they **at the moment** have a piece of code that you like
<FromGitter> <Blacksmoke16> then replace `to_unsafe` with `to_i` and implement that in the future
<FromGitter> <Blacksmoke16> problem solved
<oprypin> it is not a replacement because `to_unsafe` has special interactions with C bindings
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <girng> i agree, naming is important. going back to ternary
<FromGitter> <girng> i'm sorry
<FromGitter> <Blacksmoke16> should at least add a note to the docs then
<FromGitter> <Blacksmoke16> makes it seem like thats what its mean to do
<oprypin> yes. and (technically) yes
<FromGitter> <Blacksmoke16> ill make a PR for `to_i` seems like it would be useful
<FromGitter> <maiha> @elorest `print` is wrong. It should be `write`, sorry. It seems `usb0.close` is essential at last.
<FromGitter> <Blacksmoke16> esp since the other method is special, can prob nodoc it at that point, otherwise would be even more confusing
<oprypin> maiha, `print` seemed odd to me, but i started digging and i thought that it ended up doing the same thing anyway
<oprypin> regarding the previous - sorry for my tone.
<FromGitter> <elorest> @maiha Ah ok. Thats what I was afraid of. Thanks.
Raimondi has joined #crystal-lang
<FromGitter> <maiha> Yep. Both `> foo` on shell and `File.write` would call `fclose(3)`. 😺
<oprypin> @Blacksmoke16, @girng, https://github.com/crystal-lang/crystal/pull/7320
spacemanspam has quit [Read error: Connection reset by peer]
<FromGitter> <codenoid> i can't write beautiful code with crystal
<FromGitter> <girng> are you using a formatter on save plugin?
<FromGitter> <codenoid> yes, crystal-sublime
<FromGitter> <codenoid> somebody need to maintenance https://github.com/datanoise/mongo.cr
<FromGitter> <girng> @codenoid is the formatter working? it should beautify your crystal code on save
<FromGitter> <elorest> I know vim-crystal works well.
<FromGitter> <elorest> I've seen people using sublime-crystal and it seems pretty slick as well.
<FromGitter> <codenoid> idk, sometimes my go code looks cooler than my crystal code
<FromGitter> <codenoid> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c41059ac45b986d1179a3fe]
<FromGitter> <codenoid> too many custom thing that's make my code looks bad
<FromGitter> <codenoid> like naming variable or function, code flow, damn
<FromGitter> <codenoid> at least my application is working fine,
Raimondi has quit [Ping timeout: 240 seconds]
laaron- has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <girng> am not sure what you mean codenoid sorry >_<
sagax has quit [Quit: Konversation terminated!]
<RX14> oprypin, i don't think that bool warning is discouraging enough :P
Raimondi has joined #crystal-lang
<FromGitter> <elorest> @codenoid Not sure what you mean. Last time I checked even good GoLang code looked worse than bad CrystalLang code lol.
<FromGitter> <girng> golang, more like gogetarthritis