<FromGitter>
<dscottboggs_gitlab> > why would a developer not want an overflow error? ⏎ ⏎ There is a cost associated with checking for an overflow. I'd say that *usually* it's better to use a type that does so automatically, because it's a mistake that can be avoided, but there are circumstances where it's not worth it.
<FromGitter>
<dscottboggs_gitlab> @girng ^^
wymillerlinux has quit [Remote host closed the connection]
wymillerlinux has joined #crystal-lang
<FromGitter>
<girng> Must be in the realm outside of my expertise. Like heavy mathematic formulas and whatnot?
<FromGitter>
<dscottboggs_gitlab> mainly stuff that has to happen within a strict latency. So called "real-time" code. Over my head too.
<FromGitter>
<girng> interesting
<FromGitter>
<girng> i view basically all code through the lens of game development, so my perceptions are a bit skewed
<FromGitter>
<girng> when i see code i've never seen before (or certain crystal syntax): my brain thinks: "how can i use this to my advantage in game development". that's it lol
<FromGitter>
<girng> i need to broader my horizons
<FromGitter>
<dscottboggs_gitlab> eh, I need to be more focused :p
<FromGitter>
<girng> that's why i have such issues with programming i think. it's like tunnel vision for me
<FromGitter>
<dscottboggs_gitlab> making games?
<FromGitter>
<Blacksmoke16> step 1, write tests
<FromGitter>
<girng> not making games, but like knowledge about programming in general. i only think of code that's applicable / useful for me. not in general. for example, i'd never probably use `&**`
<FromGitter>
<girng> so now that syntax is dead to me
<FromGitter>
<dscottboggs_gitlab> yeah I do that, kinda....
<FromGitter>
<dscottboggs_gitlab> Yeah I think you have to -- no one can learn everything. You've gotta focus on what's useful to you, or at the very least what you find interesting
<FromGitter>
<dscottboggs_gitlab> wait.... how is that different from `**`?
<FromGitter>
<girng> doesn't trigger the overflow
<FromGitter>
<dscottboggs_gitlab> Oh I see
<FromGitter>
<girng> LOL i asked the same thing
<FromGitter>
<dscottboggs_gitlab> yes, that's probably a good thing to just forget about. It's better to know where to look for that than to have it all in your head
<FromGitter>
<girng> i just was browsing crystal's github and saw a post by asterite with that syntax
<FromGitter>
<girng> i was like wtf does this do, and looked it up lol
<FromGitter>
<dscottboggs_gitlab> in my day-to-day I'll write 3 or 4 different languages, I can't memorize all those stdlibs and nuances -- just gotta know where the docs are
<FromGitter>
<girng> damn, which languages?
<FromGitter>
<girng> i guess i'm kinda the same. i cycle between SQL, gdscript, crystal and php. i usually go to the docs for them as well
<FromGitter>
<dscottboggs_gitlab> Python and BASH at work, JS and Crystal at home. movie time sorry ✌️
<FromGitter>
<girng> ✋ hf, ttyl
<FromGitter>
<Blacksmoke16> forgot how much stuff is involved with an angular project
<FromGitter>
<Blacksmoke16> could spent hours just playing with config options
<FromGitter>
<girng> what you making?
<FromGitter>
<Blacksmoke16> plan is to make an online store for a game i play
<FromGitter>
<Blacksmoke16> but we'll see how it goes
<FromGitter>
<girng> that one ship game?
<FromGitter>
<girng> are u gonna use crystal for the backend
<FromGitter>
<Blacksmoke16> yes, and thats the idea
<FromGitter>
<Blacksmoke16> partially for the game, partially to act as a real world test of my stuff
<FromGitter>
<Blacksmoke16> game has a nice API so can do some neat stuff
<FromGitter>
<Blacksmoke16> like send in game mails programmatically, read assets/contracts/wallets, etc
<FromGitter>
<girng> pretty cool
<FromGitter>
<Blacksmoke16> indeed
<FromGitter>
<girng> i remember you mentioning something like this last year and it's how you got into programming
<FromGitter>
<Blacksmoke16> it played a part thats for sure
<FromGitter>
<Blacksmoke16> plan is to use athena for api, mosquito for async stuff, and charon as the orm
<FromGitter>
<Blacksmoke16> with angular8 as client
<FromGitter>
<girng> as a vanilla js kinda guy, i don't think i'd touch angular or any js frameworks outside of game frameworks with a ten foot pole lol
<FromGitter>
<Blacksmoke16> they have some nice features you cant ignore tho
<FromGitter>
<Blacksmoke16> why reinvent the wheel
<FromGitter>
<girng> iuno, just seems so convoluted
<FromGitter>
<Blacksmoke16> going from angularjs to angular2+ is a big jump
<FromGitter>
<Blacksmoke16> requires a lot of extra stuff vs just adding a script tag
<FromGitter>
<dscottboggs_gitlab> @j8r sent me https://svelte.dev/ the other day -- it looks really cool.
<FromGitter>
<dscottboggs_gitlab> ( waiting on my bf to make some food :D )
<FromGitter>
<Blacksmoke16> now i just gotta remember how all this works heh
<FromGitter>
<Blacksmoke16> prob make the api first...
<FromGitter>
<girng> eh
<FromGitter>
<girng> that does look pretty cool not gonna lie
<FromGitter>
<Blacksmoke16> What? That svelte?
<FromGitter>
<girng> yah
return0e has quit [Remote host closed the connection]
<alex``>
how to reopen a tempfile once closed?
<alex``>
I use File.read(tempfile.path)
<FromGitter>
<watzon> I don't believe you can. They are temporary for a reason. I'm pretty sure they're deleted once closed.
<FromGitter>
<dscottboggs_gitlab> They are not
<FromGitter>
<dscottboggs_gitlab> You can `File.read tempfile.path` after it is closed. Or `File.open` either way\
<FromGitter>
<Blacksmoke16> But you should delete them
<FromGitter>
<dscottboggs_gitlab> yes
<FromGitter>
<watzon> Then his `File.read` should be working
<FromGitter>
<dscottboggs_gitlab> yup
<FromGitter>
<Blacksmoke16> He didn't say it wasn't :p
<FromGitter>
<watzon> Well I assume since he's asking lol
<FromGitter>
<Blacksmoke16> Are you getting a specific error
<FromGitter>
<Blacksmoke16> ?*
<alex``>
I was asking if it was the way to read temp files
<alex``>
is there a command to shellescape like Ruby?
<FromGitter>
<dscottboggs_gitlab> Backtics work in crystal
<FromGitter>
<dscottboggs_gitlab> you can use `Process` for more control`
<alex``>
I need to escape them to write something to a file
<alex``>
I have a list of <input> <output> arguments
<alex``>
and need to write to a file to be executed as a shell script
<FromGitter>
<Blacksmoke16> Could probably use ecr to generate the shell file
<alex``>
ecr?
<FromGitter>
<Blacksmoke16> But that would be at compile time
<FromGitter>
<Blacksmoke16> Similar to erb from rails
<FromGitter>
<bararchy> So, an idea why URI#to_s won't escape (encode) param values? seems obvious no?
<FromGitter>
<bararchy> or maybe we need URI#encode! or something
<oprypin>
bararchy, the query should have already been specified as escaped
<oprypin>
also there is no strict requirement for what "values" is in a query string. it;s just a completely arbitrary string
<FromGitter>
<bararchy> WDYM ?
<FromGitter>
<bararchy> `specified as escaped` where ?
<oprypin>
uri.query should already contain the escaped value
<FromGitter>
<bararchy> I see
<oprypin>
that is also what happens when using URI.parse - the original string contains the escaped query string as part of it, and that gets directly assigned to `query`
<FromGitter>
<bararchy> So, I I want to make sure it's encoded propery from a user supplied value. ⏎ I would need to encode it beforehand with HTTP::Param ?
<oprypin>
for sure
<oprypin>
i mean, this code is already kinda invalid
<oprypin>
the character `' '` is not allowed in an HTTP URI
<oprypin>
they never define the characters '&' or '=' for any purpose; an URI is not concerned with them
<FromGitter>
<bararchy> Let me try and explain my usecase better
<oprypin>
> buy HTTP::Params uses the `+` (form urlencoded rules)
<oprypin>
yep, that is indeed correct
<FromGitter>
<bararchy> So, in my usecase I add arbitery data to either HTTP::Pramas (body) or URI, I want a "sure" way to handle encoding. ⏎ for example, for URI `https://test.com/?bla=1` I might add a token like `<script>alert(1)</script>` which will result in `https://test.com/?bla=1<script>alert(1)</script>`, now, this is all nice and well, but, I want to make sure it's been rightly encoded when it's being sent to the target.
<FromGitter>
... ⏎ Currently I do some tests (target is body? parse with HTTP::Params, `to_s` encodes it , all good and well.) now, I do the same for URI, but, I need to manually change each `+` to the relevant `%20`
<FromGitter>
<bararchy> oprypin I know about this method, but, to use it I need to parse the string, go over each parameter value, esace it (+ or %20) and rebuild the whole string back ⏎ This is something I hoped URI can do for me, or at least a way to control which of the escapes `HTTP::Pramas` uses
<oprypin>
are you sure you need to go over each parameter value?
<FromGitter>
<bararchy> yes, otherwise URI.escape kills `=` and `&`
<FromGitter>
<bararchy> also, param names should never be escaped
<FromGitter>
<bararchy> Now in the query part, spaces may be encoded to either "+" (for backwards compatibility: do not try to search for it in the URI standard) or "%20" while the "+" character (as a result of this ambiguity) has to be escaped to "%2B".
<FromGitter>
<bararchy> (from the above StackOverFlow)
<oprypin>
it's not part of the URI standard because forms are not part of URI standard at all
<oprypin>
and that SO answer is frankly wrong then
<FromGitter>
<bararchy> So, it boils down to "use whichever you prefer" ?
<oprypin>
either works, yes
<FromGitter>
<bararchy> I see
<FromGitter>
<bararchy> if this is indeed the "RFC" if we can even call it that, then I'm good
<oprypin>
but if you go to the most used page of the most used website on the most used browser and type a space in the field, you end up getting a + in the URL
<FromGitter>
<bararchy> You seems to be right
<FromGitter>
<bararchy> I'll go that why then, it makes my life much easier
<oprypin>
ha, am i understanding this correctly that this is not in any standard?
<oprypin>
https://tools.ietf.org/html/rfc3875#section-4.1.7 : `For example, form submission from an HTML document uses application/x-www-form-urlencoded encoding, in which the characters "+", "&" and "=" are reserved`
<oprypin>
but the fact that it stats with 'x-' means it's not standardized
<oprypin>
basically +, & and = are pure convention and indeed not defined in a standard :>
<FromGitter>
<bararchy> the world of HTTP :(
<oprypin>
but as I was saying, an URI doesn't care about the contents of the query string whatsoever, but it does, indeed, define that it can contain percent-encoded characters and CANNOT contain some reserved characters
<FromGitter>
<bararchy> wait to see that Microsoft in IIS uses `\n` to split lines (headers, body, etc..) , while linux uses `\r\n` everywhere
<oprypin>
then the value (containing `%20` or `+`) is passed to a parser of `application/x-www-form-urlencoded`, which, if it sees `%20`, it knows already that it's a space by standard; but if it sees `+`, that is defined in the `www-form-urlencoded` standard (or just convention apparently, lol) to mean a space
<oprypin>
`HTTP::Params` plays the role of "parser of `application/x-www-form-urlencoded`" btw
<FromGitter>
<bararchy> btw, this means that `%20` == space always, while `+` == space only is `Content-Type` header is set to `x-www-form-urlencoded`
<oprypin>
this is not related to the header
<oprypin>
all current HTTP servers and clients assume the query string **purely by convention** to be `application/x-www-form-urlencoded`
<FromGitter>
<bararchy> I see, so this is the missing pieace of info I was missing
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
wymillerlinux has quit [Read error: Connection reset by peer]
alex`` has quit [Ping timeout: 258 seconds]
alex`` has joined #crystal-lang
<FromGitter>
<bew> hum.. this looks wrong: https://carc.in/#/r/70t4 why *inside* Bar I can say `def Bar.foo` and it works... I would expect it to throw an error on the line `def Bar.foo` saying that there is no type `Bar` in `Foo::Bar`, no?
<FromGitter>
<bew> adding a type `Bar` in `Foo::Bar` does the expected behavior though
<FromGitter>
<tenebrousedge> you could use `self` there just as easily
<FromGitter>
<bew> I know
<FromGitter>
<tenebrousedge> I'm not sure what you see as a problem there
<FromGitter>
<bew> basically, when you have a type like `module Foo; end` then you can do `def Foo.method; end` to add a module method to `Foo` (similar to reopening module like so: `module Foo; def self.method; end; end`)
<FromGitter>
<bew> the issue I'm trying to show is that from inside the module (`module Foo; ..HERE..; end`), if I reference the module I'm in (`Foo`), I can add methods to it.. I would expect that `def Foo.method; end` would lookup a type in the current scope (and there is no type `Foo::Foo`), not add the method to the existing `Foo`... (It's pretty hard to explain ^^)
<FromGitter>
<Blacksmoke16> well since you name your module `Foo::Bar`, it would be the same as like `module Foo; module Bar; def Bar.foo...; end; end`
<FromGitter>
<Blacksmoke16> which as you said would be same as `self.foo`
<FromGitter>
<Blacksmoke16> i still dont see what thats an issue?
<FromGitter>
<bew> actually, it's logical... since it can't find a type `Bar` in `Foo::Bar`, then it goes up to `Foo` and searches a `Bar` type, and finds it...
<FromGitter>
<bew> naa, all good :D
<FromGitter>
<Blacksmoke16> but it did find a type `Bar`
<FromGitter>
<tenebrousedge> hmmm, yeah, I should work on one or two of those later
<FromGitter>
<tenebrousedge> Heroku, y u no love me?
<FromGitter>
<Blacksmoke16> https://github.com/Blacksmoke16/athena DI stuff along with some nice refactors to configuration among others is now merged as well for those who like to be on the cutting edge
<FromGitter>
<j8r> mps: any news of jirutka, he is busy?
<mps>
j8r: it would be better to ask him. There were some kind of conflict but I don't know what exactly
<FromGitter>
<j8r> Is he usually in Alpine IRC?
<mps>
j8r: yes, but he doesn't 'speak' there, he is even channel OP. there were conflict with some developer and he stopped 'speak' there or on Alpine ML's although he still maintain a lot of packages
<mps>
he is still Alpine developer and respectable one
<mps>
but he doesn't 'speak' there. Maybe you can reach him on Adelie Linux IRC or ML, but I'm not sure about that because I never used Adelie comm's channels