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
<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
<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>
<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
<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>
<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!
<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>
<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 :(
<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>
<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
<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
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> ```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?