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
alex`` has quit [Quit: WeeChat 2.2]
DTZUZO has quit [Ping timeout: 245 seconds]
sevensidedmarble has joined #crystal-lang
<FromGitter> <girng> @askn just saw this https://github.com/askn/crystal-by-example starred it instantly, ty so much!!
akaiiro has joined #crystal-lang
sevensidedmarble has quit [Read error: Connection reset by peer]
akaiiro has quit [Ping timeout: 240 seconds]
ua has quit [Ping timeout: 240 seconds]
ua_ has joined #crystal-lang
akaiiro has joined #crystal-lang
<FromGitter> <megatux> @icyleaf hi 👋 Maybe you could help me with some toy program I'm using to learn Crystal. I want to automate some website tasks, entering worked hours in current projects in a corporate site. I'm using your *halite* shard for web requests & *myhtml* for parsing, the site requires a login, using POST with the usual user/pwd combination, then I'll parse the next page and extract some tasks ids to create a few
<FromGitter> ... POSTs with the worked hs. ⏎ I'm having trouble with login, I'm using session support, sending form data, and even cookies but I'm unable to log in successfully. It always goes back to login page. No visible errors.
<FromGitter> <icyleaf> @megatux Do you try `client = Halite::Client.new` then `client.post(“url”)`?
<FromGitter> <megatux> @icyleaf yes, also #follow, let me share my code, if you have a minute
<FromGitter> <icyleaf> @megatux Of cause :)
akaiiro has quit [Ping timeout: 240 seconds]
akaiiro has joined #crystal-lang
akaiiro has quit [Remote host closed the connection]
<FromGitter> <Sevensidedmarble> is there anything like `class_variable_set` in crystal?
<FromGitter> <Sevensidedmarble> I want to set a class var with a name programmatically
<FromGitter> <Sevensidedmarble> so like i = "test"
<FromGitter> <Sevensidedmarble> @@i = some_value
<FromGitter> <Sevensidedmarble> where it'll end up as @@test
<FromGitter> <Sevensidedmarble> but its at run time, so a simple macro wont work
<FromGitter> <Sija> @Sevensidedmarble that won’t work in runtime, Crystal ain’t Ruby
<FromGitter> <Sija> why do you need that?
DTZUZO has joined #crystal-lang
<FromGitter> <Sevensidedmarble> I'm writing an interpreter
<FromGitter> <Sevensidedmarble> and I need to store variable value
<FromGitter> <Sevensidedmarble> but I guess I'll have to use hashes or something then
<FromGitter> <codenoid> @z64 is that still works ?
<FromGitter> <codenoid> i'll try
<FromGitter> <geolessel> I'm hoping to find some guidance on an implementation detail for a Crystal project I'm working on. It is a CLI app with a GUI in ncurses and needs to accept some long-form user input as text. I'd ideally like for it to work kind of like git works—it would suspend itself, open a temp file in your `$EDITOR`, then once you closed the `$EDITOR` with your edits it would bring the results into the Crystal
<FromGitter> ... program. Can any of you think of how I could make that happen?
<FromGitter> <ryanprior> I don't know any crystal-y way of doing that, @geolessel. I could give you some pointers maybe to the system calls you'd use if you want to go the C interop route. Let me know :)
<FromGitter> <geolessel> I'm new to Crystal dev, but would the C interop stuff work alongside Crystal?
<FromGitter> <fridgerator> I feel like someone has asked a similar question before, but I dont remember the answer
alex`` has joined #crystal-lang
druonysus has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter> <Sevensidedmarble> @geolessel I know this is a late answer but I would reccomend learning about how to do terminal ui's without curses
<FromGitter> <Sevensidedmarble> you can just send codes ⏎ to the terminal to change its state. thats what ncurses does under the hood. https://github.com/Sevensidedmarble/ANSI
<FromGitter> <Sevensidedmarble> curses was nice back in the day when not all terminals used the same escape sequences. nowadays you can trust that 99% of terminal emulators will use a select set.
<FromGitter> <Sevensidedmarble> you can also query the terminfo db in your linux machine using the tput command. you can do this in your application if you want to check which sequences are compatible with a given terminal.
hightower2 has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
ashirase has quit [Ping timeout: 260 seconds]
ashirase has joined #crystal-lang
<FromGitter> <docelic_gitlab> @geolessel I was thinking of porting Node.js' blessed (https://github.com/chjj/blessed) to Crystal and I actually got pretty far with it, but ran out of steam. Let me know if you'll want to join effort or something
<FromGitter> <j8r> it's similar to https://github.com/jroimartin/gocui ?
zorp has joined #crystal-lang
<FromGitter> <vladfaust> You've listened to the new Eminem album? It's awesome
<FromGitter> <vladfaust> How to install Crystal from master?
<FromGitter> <vladfaust> An easy way, I mean
shalmezad has joined #crystal-lang
<FromGitter> <j8r> git clone and make
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
<jokke> niiiice
<jokke> good job RX14
<jokke> this will become very prominent crystal software :)
<jokke> RX14: on which instance can i find you?
<RX14> that's secret
<jokke> RX14: srsly? :D
<FromGitter> <docelic_gitlab> j8r: at first glance gocui seems simpler... Blessed mentions at the end of github page that similar programs in Go are termui and termbox-go (but I didn't check them out to see if they really can compare to blessed or not)
<RX14> jokke, seriously, it's a personal account
<jokke> RX14: oh ok
<RX14> I don't really have a presence as "RX14" on fedi
<jokke> too bad :(
<FromGitter> <j8r> I've used termbox (C one), and moved away to build https://github.com/j8r/cride . Maybe I could help you a bit for the project, not sure if I've enough knowledge
<jokke> #crystal needs content ;)
<jokke> :)
alex`` has quit [Ping timeout: 240 seconds]
alex`` has joined #crystal-lang
akaiiro has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.2]
<FromGitter> <codenoid> ```code paste, see link``` ⏎ ⏎ is there a function that more effective than that? [https://gitter.im/crystal-lang/crystal?at=5b89535e11227d711df662ce]
<FromGitter> <codenoid> *v is born_year
<FromGitter> <bew> What represents `split_first`? What is you final hash supposed to represent?
<FromGitter> <codenoid> age = 43 ⏎ split_first = 4 # get 4 from 43 (this age beetween 40-50)
<FromGitter> <bew> (data, arr & v are pretty badly chosen variable names, i suggest you change them for your own good)
<FromGitter> <codenoid> oh , that doesn't work with < 20
<FromGitter> <bew> Instead of spliting you can also do `age / 10`
<FromGitter> <bew> (then to_s if you really wabt a string)
zorp_ has joined #crystal-lang
zorp has quit [Ping timeout: 244 seconds]
<FromGitter> <codenoid> okay, ✨
<FromGitter> <molnarmark> Hey guys. You might like this tiny shard I put together. :) https://github.com/crystalrealm/epilog
<FromGitter> <fridgerator> 👍
<FromGitter> <codenoid> it's cute
<FromGitter> <molnarmark> Also did https://github.com/crystalrealm/bargs, probably gonna switch over from doing OS JS to OS Crystal. I'd really like to see this language grow.
<FromGitter> <j8r> @molnarmark Your CLI builder is promising, I've also did one https://github.com/j8r/clicr
<FromGitter> <molnarmark> Great work. I really like the fact that so many shard ideas are available because the language isnt 1.0 yet
<FromGitter> <molnarmark> I'm also really thinking about creating a gshards cli app that would enable us to install command line applications written in crystal globally to a specified path
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <paulcsmith> I just released 4 new screencasts on crystalmastery.io https://www.reddit.com/r/crystal_programming/comments/9bundk/4_new_screencasts_at_crystal_mastery/ I hope you find it useful!
<FromGitter> <fridgerator> awesome 👍
alex`` has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <j8r> it is really worth it? @molnarmark It's quite simple now `crystal build src/myapp.cr && mv myapp ~/.local/bin`
<FromGitter> <molnarmark> @j8r I feel like new users might find it easier to just install it with a command rather than having to clone the CLI, build it, move it and then delete it
<FromGitter> <molnarmark> It would be just a simple wrapper around shards anyway
<FromGitter> <codenoid> hi, how to get total times of execution process without Benchmark lib
<FromGitter> <codenoid> ah yeah, @fridgerator answer ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b896650c2bd5d117afd17cb]
<FromGitter> <j8r> @molnarmark but new users has to install gc-dev, crystal, shards, llvm. Better to `crystal build --static`, they just download and run the binary
<FromGitter> <fridgerator> @codenoid what?
<FromGitter> <j8r> @molnarmark if they are new Crystal users, they already known a bit about compiling a crystal app 😄 . They just have to know what is putting a binary to their `PATH` and they are done!
alex`` has quit [Quit: WeeChat 2.2]
alex`` has joined #crystal-lang
<FromGitter> <codenoid> hi, how to find parent number like ⏎ ⏎ ```2 => 10 ⏎ 15 => 20 ⏎ 16 => 20 ⏎ 34 => 40``` [https://gitter.im/crystal-lang/crystal?at=5b896ad4cff55e561789d263]
<FromGitter> <molnarmark> https://crystal-lang.org/api/0.20.3/Math.html should have floor, round or ceil
<FromGitter> <codenoid> yeah, but i don't know what the function to do exactly like that
<FromGitter> <bew> @codenoid `((i / 10) + (i % 10 == 0 ? 0 : 1)) * 10` :D
<FromGitter> <bew> @molnarmark those methods apply on decimals, not integer
alex`` has quit [Quit: WeeChat 2.2]
<FromGitter> <bew> Hmm maybe you can play with `i.to_f / 10.0` and `ceil`
<FromGitter> <codenoid> <3
<FromGitter> <bew> Yeah `(i.to_f / 10.0).ceil * 10` should do it
<FromGitter> <bew> @molnarmark note that you gave the document link for an old version of crystal (0.20.3), current version is 0.26.1 !
<FromGitter> <molnarmark> @bew Happens, I just googled, didnt check the version
<FromGitter> <molnarmark> @bew If you google `crystal lang math round`, 0.20.3 comes up :)
<FromGitter> <bew> yeah i remember that problem, no idea how to fix that
shalmezad has quit [Quit: This computer has gone to sleep]
shalmezad has joined #crystal-lang
<FromGitter> <fridgerator> block old crystal versions using robots.txt ?
<FromGitter> <fridgerator> or meta tag
shalmezad has quit [Quit: This computer has gone to sleep]
shalmezad has joined #crystal-lang
<jokke> wasn't there a crystal lib for running stuff on filechange?
<FromGitter> <paulcsmith> @megatux RE: your question about requiring files: I still tend to only require files when necessary. The compiler will catch if you forget to require something so I've found it ok so far 👍
shalmezad has quit [Quit: This computer has gone to sleep]
<FromGitter> <j8r> I think only crystal latest should have a good SEO
<FromGitter> <j8r> Don't know how to do it
shalmezad has joined #crystal-lang
shalmezad has quit [Quit: Leaving]
DTZUZO has quit [Ping timeout: 245 seconds]
binBASH has quit [Quit: binBASH]
<RX14> aaaaaaaaaaaaaaaaaa https://golang.org/src/os/exec_windows.go?s=1263:1301#L42
<oprypin> :)
<FromGitter> <girng> im having problem with pinglatency and not sure if it's related to crystal
<FromGitter> <girng> for example, i ping my vps and get average response 54ms. however, when i connect through TCP and send message, get message back, and calculate difference, i get around 80ms
<FromGitter> <girng> is the ICMP ping faster than tcp ping? is that normal??
akaiiro has quit [Ping timeout: 240 seconds]
return0xe has joined #crystal-lang
<FromGitter> <Sija> @molnarmark `<link rel=“canonical” …>` was added in v0.25.0 but older versions are still indexed without it :(
return0e has quit [Ping timeout: 246 seconds]
<jokke> hm any ideas what's happening here? https://p.jokke.space/egY/
<jokke> why is the compile-time type Exception+ when i explicitly use the type discriminator ParamError?
<jokke> *type restriction
<oprypin> please make a runnable example that reproduces the problem
<jokke> i'll try
<jokke> not even ex = ex.as(MyError) helps
<jokke> i can't be the first one to run into this
<oprypin> yeah it's kind of a real problem
<oprypin> just make AError < MyError etc
<jokke> ok
<FromGitter> <Sija> https://carc.in/#/r/4uy7
<oprypin> can make it abstract as well
<FromGitter> <Sija> yup
return0xe has quit [Ping timeout: 245 seconds]
<FromGitter> <Sija> it might be worth reporting on the issue tracker though
<oprypin> it is known
<oprypin> it's that famous thing that was reverted
return0e has joined #crystal-lang
<oprypin> proof: https://carc.in/#/r/4uy8
<oprypin> the exact code works in 0.25.1
<FromGitter> <Sija> true that, sad story
<FromGitter> <girng> actually i think i'm thinking of latency vs response time
<FromGitter> <drosehn> wrt ping vs TCP packets: I wonder if you're running into problems with Nagle. I forget the exact situation where the nagle algorithm produces painful delays, but I have run into them. Not often, but it does happen, and it can really hurt throughput when it does happen.
<FromGitter> <drosehn> sorry for bringing it up in such a vague way. perhaps this will be a good starting point for understanding what is going on: ⏎ https://en.wikipedia.org/wiki/Nagle%27s_algorithm
<FromGitter> <girng> yeah i disabled it, still the same
<oprypin> it's true but response time should not be that long
<oprypin> * Processing time should not be that long
<FromGitter> <girng> o really? i need to make a minimal example then and isolate this to see what's causing it
<FromGitter> <girng> whether it's reading data in tcp, using json.parse, etc
<oprypin> girng, you can measure processing time
<FromGitter> <girng> i am going to make a client->server example and not use godot. then stick server on vps and check response time to see if it's the same
<FromGitter> <girng> if it's far less, something to do with godot
<FromGitter> <drosehn> Totally unrelated question. This is just something I'm curious about. If it doesn't already exist, then I'm not asking for anything. In a program I'm writing, I have a huge array. By being an array, it has all kinds of flexibility that I don't need. All I need is to loop through the array starting at the first element to the last element, in order. Is there something I could use which would be more
<FromGitter> ... efficient (in either size or processing-time) than an array?
<FromGitter> <Sevensidedmarble> is `StaticArray` faster?
<FromGitter> <drosehn> Dunno! I should check that! Thanks!
<FromGitter> <Sevensidedmarble> I have no idea if it is or not, but maybe
<RX14> if it's huge then staticarray is definitely not what you want
<RX14> staticarray is on the stack
<oprypin> drosehn, array already has the best overall characteristics for that
<RX14> ^
<RX14> a crystal array is already just a pointer to memory
<FromGitter> <Sevensidedmarble> whats the benefit of static array?
<oprypin> none
<RX14> none
<oprypin> array of structs vs array of classes, though, that's a whole different story
<FromGitter> <girng> lol
<RX14> anyone who actually needs staticarray isn't asking
<RX14> they're just using it because they've used one in C before
<oprypin> Sevensidedmarble, array needs to be allocated and garbage collected, staticarray does not. but in this case it seems like it's a whopping 1 allocation, so who cares
<RX14> there's certain low-level features of crystal like staticarray, uninitialized etc that if you have to ask you don't need them
<FromGitter> <Sevensidedmarble> gotcha
<oprypin> drosehn, sparse array could be a thing, of course, if what you have is actually sparse
<RX14> because the people who need them are performance experts who have already written a lot of C and have done the benchmarks
<FromGitter> <girng> man the docs on firefox when u scroll are extremely laggy. can i plz make an issue about this in crystal doc repo
<FromGitter> <girng> is*
<RX14> i'm on firefox, no issue
<oprypin> girng, disable smooth scrolling - solves everything
<RX14> using smooth scrolling
<FromGitter> <girng> quantum?
<RX14> ... latest
<RX14> 61.0.2
<FromGitter> <girng> same, what os?
<FromGitter> <drosehn> Yeah, this is a huge array. Currently 40,000 elements, but I'd like to make it larger. Not Sparse. Every element has a unique value.
<RX14> get a better laptop :P
<RX14> yeah, you want array
<FromGitter> <drosehn> Okay. If there was something faster/better than I'd use it, but this is fine.
<FromGitter> <drosehn> sigh. /than I'd/then I'd/
<oprypin> you havent mentioned about structs vs classes though
<RX14> are you having issues?
<RX14> or is this premature optimization
<FromGitter> <drosehn> Not at all right now, but I was thinking of making it much larger.
<oprypin> im having issues though, currently writing nested loops with each_permutation -> each_permutation -> each -> while
<oprypin> yeah that's not gonna fly
<FromGitter> <drosehn> Not premature optimization. Just curiosity.
<RX14> oprypin, wtf are you doing?
<FromGitter> <drosehn> This is also just for a goofy side project. nothing that needs to be done at all.
<RX14> seriously that sounds like a n! to me
<oprypin> just bruteforcing code generation for a videogame with Scratch-like programming in it
bds has joined #crystal-lang
<FromGitter> <fridgerator> hahaha
<FromGitter> <girng> "glory hole" rofl
<FromGitter> <fridgerator> the screenshot looks cool though
<oprypin> so like the problem here is that the workers check each direction in order, and that's not smart enough, i'm trying to find out like... if i've just gone northwest, which direction is best to check next, and then after that, etc
<bds> Ruby has offine console based docs (ri) for stdlib and installed gems. Does Crystal have something similar?
<oprypin> you can download html docs
<FromGitter> <Sevensidedmarble> something like zeal works very well for that bds
<FromGitter> <girng> console based docs? soujnds like sorcery
<bds> ty for suggestions <3. I am working on terminal window w/ tmux on a small laptop - so is nice to have code in one pane and documentaion in another and not have to move windows/workspaces
<bds> will download html docs and give a try in lynx
<oprypin> which reminds me to re-generate https://pryp.in/crystal.html
<bds> using the crystal-lang Docker image the docs are installed in /usr/share/doc/crystal/api/ - so I already had them and just didn't know :)
Raimondii has joined #crystal-lang
<oprypin> :o
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
<FromGitter> <j8r> @girng I experience slow crystal docs on mobile for me
<FromGitter> <asterite> A slice is a bit more efficient than an array. There's one less indirection
<oprypin> im curious about a benchmark. if we're making bets, mine would be 1% difference
<FromGitter> <girng> ok so im doing this simple clientserver thing to see response time differences
<FromGitter> <girng> this is only json bidirectional communication (intended, if anythign other than json, connection is dropped). this is just for my master game server, i will use enum command checking for gameserver with tick rate (plz no worry oprypin): ⏎ ⏎ server.cr: https://paste.ee/p/9uGEk ⏎ ⏎ client.cr: https://paste.ee/p/BPjFT ... [https://gitter.im/crystal-lang/crystal?at=5b89a9c91d3a5711b6c745fc]
<FromGitter> <girng> ok i'm getting ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b89ab0760f9ee7aa4bc3ab6]
Some_Person2 has joined #crystal-lang
<Some_Person2> Aⅼlah is doⅰᥒg
<Some_Person2> ѕuᥒ is ᥒot doing Ꭺllaһ іѕ ԁοіnɡ
<Some_Person2> pⅼanetѕ ɑrе ᥒⲟt doinɡ Aⅼⅼah ⅰѕ dⲟіᥒg
<Some_Person2> ѕtɑrs ɑre ᥒοt doinɡ Ꭺⅼlaһ is dοiᥒg
<Some_Person2> moon iѕ ᥒⲟt ԁoiᥒg Allɑh іѕ doing
<Some_Person2> gaⅼахіeѕ arе ᥒot doinɡ Аlⅼah ⅰs doing
<Some_Person2> οcеanѕ аre ᥒоt doiᥒg Αⅼlah ⅰѕ doіng
<Some_Person2> mоuᥒtainѕ arе ᥒot doing Allah iѕ dഠіᥒɡ
<Some_Person2> trᥱes arᥱ nοt doiᥒɡ Aⅼlɑһ is ԁoіᥒg
Some_Person2 was kicked from #crystal-lang by RX14 [Some_Person2]
<Some_Person2> moⅿ is ᥒot ԁoіng Аⅼlah iѕ doing
<Some_Person2> ԁaԁ іs ᥒot ԁഠinɡ Αllɑһ iѕ dоiᥒɡ
<Some_Person2> boss is not ⅾoⅰng Aⅼⅼаһ iѕ doiᥒg
<Some_Person2> ϳⲟb is ᥒοt ԁoiᥒg Αlⅼɑһ iѕ dοіᥒg
<Some_Person2> dolⅼar is nоt ⅾoіng Аⅼlah is doinɡ
<Some_Person2> dеgrеe is ᥒot doing Αllaһ ⅰs doіᥒg
<Some_Person2> meԁiϲine іs not dоⅰᥒg Αllɑh ⅰѕ doinɡ
<Some_Person2> ⅽustomеrѕ are not doinɡ Αllah іs doіᥒg
<Some_Person2> yഠu ϲaᥒ nоt gᥱt ɑ job wіtһഠ∪t thе pеrmission оf ɑⅼⅼah
sagax was kicked from #crystal-lang by RX14 [sagax]
<Some_Person2> yⲟu cɑᥒ ᥒot get mаrriᥱԁ without the perⅿissiⲟᥒ of aⅼlɑh
<Some_Person2> nⲟboԁу ϲaᥒ ɡеt angry at you ᴡitһout thᥱ pеrmisѕⅰഠn of aⅼⅼɑһ
<RX14> ffs
<RX14> not even the old spambots
<FromGitter> <girng> what the hell
<FromGitter> <drosehn> [slice] Hmm. Yes, that might be interesting to try.
<FromGitter> <girng> my response time is messed up somewhere. cause if i change pinger's sleep to 0.01 or something, my `ms` goes down to like 7-8m. which doesn't make sense lol wtf
sagax has joined #crystal-lang
<sagax> why?
<sagax> i not spam
<sagax> RX14:
<FromGitter> <girng> well cause the ping latency to my vps ip is a minimum of 45ms. how can the ms go below that
<RX14> sagax, yeah sorry about that I kicked you accidentally
<sagax> crystal - very awesome, i am glad that i am here
<oprypin> :)
<hightower2> :)
akaiiro has joined #crystal-lang
Creatornator has joined #crystal-lang
druonysus has joined #crystal-lang
bds has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
hightower2 has quit [Ping timeout: 240 seconds]
<FromGitter> <girng> can sum1 plz check my client.cr https://paste.ee/p/BPjFT and see why my pinger method and message_handler shows weird latency? if i ping for 1 second, it will show average 250ms. however, the connection to the vps IP is around 50-60ms on ping. where is extra 200ms or so coming from?
<FromGitter> <girng> response time*
<oprypin> girng, flush the socket maybe
<FromGitter> <girng> after .send?
<FromGitter> <girng> tried it, same thing
akaiiro has quit [Ping timeout: 244 seconds]
Creatornator has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <girng> ok i think i found the issue
<FromGitter> <girng> ```code paste, see link``` ⏎ ⏎ from server.cr, i am getting 533, 498, 497, 501, 502, 482 from `puts start2-start1`. that is where the delay is happening. am i reading tcp stream data wrong? [https://gitter.im/crystal-lang/crystal?at=5b89cf28d457a1406c8d2442]
<FromGitter> <girng> that's half a second isn't it?
hightower2 has joined #crystal-lang