ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.30.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> <stronny> further, I think you should overload window with and without block, and remove it from method signature
<FromGitter> <JohnDowson> Is that considered a good style?
<FromGitter> <stronny> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7adc4505fd37169515dbea]
<FromGitter> <stronny> good style is what works for you, not what other people decided
<FromGitter> <stronny> but for what it's worth I saw it in stdlib more than once
<FromGitter> <Daniel-Worrall> Use ? Instead of Nil union
<FromGitter> <Blacksmoke16> its essentially the same thing just shorter
<FromGitter> <stronny> it's exactly the same thing
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
<FromGitter> <asterite> it's not about good style, you can't do that `unless block`, a method with a block always receives a block. Doing it the overload way is the only way to do it
_whitelogger has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
chemist69 has quit [Ping timeout: 246 seconds]
chemist69 has joined #crystal-lang
absolutejam1 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 246 seconds]
DTZUZU has quit [Quit: WeeChat 2.2]
DTZUZU has joined #crystal-lang
ht_ has joined #crystal-lang
absolutejam1 has joined #crystal-lang
<companion_cube> so what makes Int? so hard to support? the fact it's not a reference class?
ht_ has quit [Remote host closed the connection]
absolutejam1 has quit [Ping timeout: 265 seconds]
absolutejam1 has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <j8r> For example sending an http request, waiting user input, etc
sorcus has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.5]
hypercore has joined #crystal-lang
<hypercore> hello everybody, i'm getting "column posts.id does not exist" when i try to follow the "lucky gen.resource.browser Post title:String" command on the lucky index page
<hypercore> anyone have an idea of what i could be doing wrong?
<FromGitter> <stronny> what database are you using?
<hypercore> postgres
<hypercore> only change i made to db config was to set the db name manually
<FromGitter> <stronny> ```\c <dbname> ⏎ \d+ posts``` [https://gitter.im/crystal-lang/crystal?at=5d7b6f142e8fd94630c56cbf]
<hypercore> only has the "text" field
<hypercore> sorry, the "title" column
<hypercore> isn't a primary key (id) added automatically?
<hypercore> as well as "created_at" or something similar
<FromGitter> <stronny> ```lucky db.drop ⏎ lucky db.create ⏎ lucky db.migrate``` [https://gitter.im/crystal-lang/crystal?at=5d7b6ffa53bbf77ee0569747]
<hypercore> still getting that error
<hypercore> lucky -v
<hypercore> 0.17.0
<hypercore> i'll try creating a new app and see if the error persists
<FromGitter> <stronny> can you show us your migrations from `db/migrations/`?
<FromGitter> <stronny> to answer your questions, neither of above are created automatically, there should be code for both https://luckyframework.org/guides/database/migrations ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7b72073cc2b87edff6472f]
<hypercore> ah then that must be what i'm doing wrong, i was explicitly adding those two fields in my posts migration
<hypercore> yep that fixed it, thanks for the help!
<FromGitter> <stronny> glad to help
hypercore has quit [Quit: hypercore]
absolutejam1 has quit [Ping timeout: 246 seconds]
DTZUZO has quit [Ping timeout: 246 seconds]
DTZUZO has joined #crystal-lang
absolutejam1 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 246 seconds]
absolutejam1 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 265 seconds]
DTZUZO has quit [Ping timeout: 240 seconds]
absolutejam1 has joined #crystal-lang
DTZUZO has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 246 seconds]
absolutejam1 has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
ua_ has quit [Ping timeout: 268 seconds]
<FromGitter> <didactic-drunk> How do I get a constant when I have a variable pointing to a class? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7babaeb84cb24c7ec19ee1]
absolutejam1 has quit [Ping timeout: 265 seconds]
<FromGitter> <Blacksmoke16> afaik constants are similar to class methods, you would have to define a getter or use `C::CONST`
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7k2q
<FromGitter> <Blacksmoke16> maybe that something that could be improved?
Flipez has quit [Read error: Connection reset by peer]
Flipez8 has joined #crystal-lang
Flipez8 is now known as Flipez
absolutejam1 has joined #crystal-lang
ua has joined #crystal-lang
devil_tux has joined #crystal-lang
<FromGitter> <didactic-drunk> Improvement, otherwise I have to monkey patch.
absolutejam1 has quit [Ping timeout: 265 seconds]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
ht_ has joined #crystal-lang
DTZUZO has joined #crystal-lang
alex`` has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
<FromGitter> <stronny> indirect constants require caution
<FromGitter> <stronny> it's easy to access a wrong one
DTZUZO has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.5]
<FromGitter> <kinxer> @watzon I spent far too much time thinking about your tokenization problem last night: https://play.crystal-lang.org/#/r/7k4p
<FromGitter> <kinxer> I didn't find much improvement, though.
alex`` has joined #crystal-lang
devil_tux has quit [Remote host closed the connection]
<FromGitter> <asterite> @watzon @kinxer this works twice as fast: https://play.crystal-lang.org/#/r/7k5b
gangstacat has quit [Ping timeout: 276 seconds]
<FromGitter> <stronny> does this help though? `grouping = grouping.downcase unless downcase?(grouping)`
<FromGitter> <kinxer> @asterite You're a wizard. It looks like it also uses 1/5 of the memory.
absolutejam1 has joined #crystal-lang
<FromGitter> <asterite> @kinxer indeed :-)
<FromGitter> <asterite> @stronny maybe not. In the example it leads to less memory, but maybe slightly slower
alex`` has quit [Ping timeout: 245 seconds]
gangstacat has joined #crystal-lang
<FromGitter> <kinxer> With `unless downcase?(grouping)`: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7bcfb353bbf77ee0597a1d]
<FromGitter> <kinxer> It looks like adding it improves both memory and speed.
<FromGitter> <kinxer> Oh, wait. I misread.
Human_G33k has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 265 seconds]
absolutejam1 has quit [Ping timeout: 245 seconds]
<FromGitter> <kingsleyh> @watzon I was looking for eval originally but instead I managed to find a solution that worked for me
<FromGitter> <kingsleyh> It probably won't help you but in my case - I generate a hash map of method base name to a proc of code to execute - and at runtime I lookup the base method in the map and execute the proc
<FromGitter> <kingsleyh> I'm moving this to an annotation based solution at the moment
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
alex`` has joined #crystal-lang
hypercore has joined #crystal-lang
<hypercore> is lucky production ready?
<FromGitter> <tenebrousedge> define 'production ready'
<hypercore> can i use it to build generic apps without having any major problems
<hypercore> excluding some scenarios where some esoteric shards don't exist
<hypercore> obviously it's still a new platform so that would be understandable
<FromGitter> <tenebrousedge> people do build apps with it
<FromGitter> <Blacksmoke16> an HTML site i imagine?
<hypercore> yeah like a generic saas app
<hypercore> if such a thing exists
alex`` has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
Yxhuvud has joined #crystal-lang
<FromGitter> <fridgerator> quite a few people are using crystal in production, I believe Lucky as well
<FromGitter> <fridgerator> There is a Lucky gitter channel too, you might get more specific info there
<FromGitter> <watzon> Holy crap @asterite @kinxer
<FromGitter> <watzon> I'll plug that in later and see what happens
<FromGitter> <watzon> Hmm, now here's a question. How do you prevent people from abusing `while` and `for` loops in a REPL type environment where the REPL is a bot?
<companion_cube> ulimit
<FromGitter> <Blacksmoke16> the playground has a limit on execution time
<FromGitter> <watzon> I already have that, but `while` loops use a lot of memory really quickly if you just do something like ⏎ ⏎ ```while true ⏎ puts "fuck this" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d7bea683cc2b87edff9f809]
<FromGitter> <Blacksmoke16> `loop do` 😉
<companion_cube> waiiiit what
<FromGitter> <watzon> I also need to set a flood limit on my bot. I've got an asshole DOSing it with requests.
<companion_cube> why does a loop use memory? :s
<FromGitter> <stronny> because it allocates a string
<FromGitter> <watzon> A lot of strings very quickly in this case
<FromGitter> <stronny> Chris, you are allowing random people to run arbitrary code on your harware
<FromGitter> <stronny> limits are the least of your concerns
<companion_cube> ah ok, and the compiler can't hoist the string outside the loop
<FromGitter> <watzon> It's in a docker container
<FromGitter> <stronny> set the limits for it
<FromGitter> <stronny> or rather start each binary inside its own cont and set the limits there
<FromGitter> <watzon> That would end up making things terribly slow
<FromGitter> <stronny> OS?
<FromGitter> <watzon> For? The host or the containers?
<FromGitter> <stronny> containers do not have its own OS
<FromGitter> <watzon> They run an OS, do they not? Alpine Linux in this case.
<FromGitter> <watzon> The host is debian
<FromGitter> <stronny> running a process in docker has a really small overhead
<FromGitter> <stronny> it's not a VM
<companion_cube> it's the same kernel but not the same distro, in a way
<FromGitter> <watzon> I guess I haven't learned how Docker really works underneath
<FromGitter> <stronny> they don't run an OS, they run one process at start
<FromGitter> <stronny> that can fork, sure
alex`` has quit [Quit: WeeChat 2.5]
<FromGitter> <stronny> now, docker on mac os or windows -- that's an entirely different story
<FromGitter> <stronny> there it has to bootstrap an honest vm
alex`` has joined #crystal-lang
<companion_cube> on linux it uses some container API, which is why it's more lightweight indeed
absolutejam1 has joined #crystal-lang
hightower2 has quit [Ping timeout: 245 seconds]
<hypercore> anyone know why i get "Error: can't find file './fizzbuzz/*' relative to '/tmp/crystal/fizzbuzz/spec'" when i add "require './fizzbuzz/*' to the top of my spec file?
<FromGitter> <Blacksmoke16> sure you dont mean like `require "../src/fizzbuzz"`?
<hypercore> oh that work, thank you
<hypercore> lots of resources seem to all have: require "./<app>/*"
<hypercore> did this syntax change recently?
<FromGitter> <Blacksmoke16> hm?
<hypercore> or is that saying i should put fizzbuzz in spec?
<FromGitter> <Blacksmoke16> normally you require your project files in spec helper, then just require the spec helper in your specs
beepdog has quit [Read error: Connection reset by peer]
olbat[m] has quit [Remote host closed the connection]
ternarysolo has quit [Read error: Connection reset by peer]
erdnaxeli has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> ```require "spec" ⏎ require "../src/fizzbuzz"``` [https://gitter.im/crystal-lang/crystal?at=5d7bff1936461106bb1296f5]
<FromGitter> <Blacksmoke16> which it does for you by default when you init the app
<hypercore> oh didn't notice that
<hypercore> thanks
beepdog has joined #crystal-lang
DTZUZO has quit [Ping timeout: 246 seconds]
ht_ has quit [Quit: ht_]
<hypercore> is is possible to speed up compile times while working in dev? currently takes about 10s just to change a template
alex`` has quit [Quit: WeeChat 2.5]
<FromGitter> <watzon> @asterite seems to work pretty well, but it's having some trouble with some characters it seems https://play.crystal-lang.org/#/r/7k8p
<FromGitter> <absolutejam_gitlab> remember to run it as non-root
<FromGitter> <absolutejam_gitlab> or use user name spaces for multiple
<FromGitter> <absolutejam_gitlab> Podman looks interesting in that regards. no daemon
ternarysolo has joined #crystal-lang
olbat[m] has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <watzon> Already running as non-root :)
<FromGitter> <zbaylin> can someone please explain this error to me: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7c117f5d40aa0d7d301ae3]
<FromGitter> <zbaylin> where is it that I am not initializing workbook??
<FromGitter> <zbaylin> it happens for all the other instance variables too
<FromGitter> <watzon> @zbaylin try using ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7c1265d3283306ba389791]
<FromGitter> <zbaylin> the @'s produce the same result
<FromGitter> <watzon> Although I think your problem is actually the fact that you're using `self` in one of the initialilzers
<FromGitter> <zbaylin> oh you're right
<FromGitter> <zbaylin> that's my bad
<FromGitter> <zbaylin> i guess that's not doable, correct?
<FromGitter> <zbaylin> because the object hasn't been initialized yet
<FromGitter> <watzon> Pretty much. You can always make the reference nilable and add it after the fact.
<FromGitter> <watzon> Not a perfect solution, but it works
<FromGitter> <zbaylin> okay thanks
<FromGitter> <Blacksmoke16> hypercore I'm assuming you're not building in release mode?
<hypercore> sorry, should've been more explicit, i'm using Lucky framework
<hypercore> normally my frameworks pretty much reload the page instantly when i make a change to a template or css, but maybe this is the tradeoff with crystal?
<FromGitter> <watzon> hypercore you may want to ask Lucky questions here https://gitter.im/luckyframework/Lobby
<FromGitter> <watzon> Idk if they have a bridge though
<FromGitter> <watzon> I don't think they do
<hypercore> yeah i don't think they do
<FromGitter> <Blacksmoke16> Crystal is compiled, so whenever you make a change it has to be recompiled
<FromGitter> <Blacksmoke16> Vs like Ruby or python
<hypercore> yeah i suppose it's a small tradeoff for the safety component of crystal/lucky
absolutejam1 has quit [Ping timeout: 276 seconds]
<FromGitter> <Blacksmoke16> Mhm
absolutejam1 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 276 seconds]
<FromGitter> <asterite> @watzon what's the problem? I guess you want graphemes instead of codepoints?
<FromGitter> <watzon> Possibly, there are just some weird characters in the output
<FromGitter> <watzon> Also I tried plugging it in and running it, I ended up getting this ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7c26a45d40aa0d7d30a1d7]
sorcus has quit [Ping timeout: 276 seconds]