jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.28.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> <Daniel-Worrall> okay, so Websocket has Protocol which has StreamIO
<FromGitter> <Blacksmoke16> might be able to interact with that
<FromGitter> <Daniel-Worrall> yeah
<FromGitter> <Daniel-Worrall> Is there a get_instance_var in Crystal?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <Blacksmoke16> to do what?
<FromGitter> <Daniel-Worrall> To get an instance variable that doesn't have a getter
<FromGitter> <Daniel-Worrall> or should I just reopen WebSocket and define it as a getter
<FromGitter> <Blacksmoke16> kinda, but you should use a getter
<FromGitter> <Blacksmoke16> `model.@ivar` prob works
<FromGitter> <Daniel-Worrall> yup, ty
<FromGitter> <Blacksmoke16> but is kinda a hack
<FromGitter> <Daniel-Worrall> yeah, I just want to interface with the streamIO to see if it'll even work with what I want
<FromGitter> <Daniel-Worrall> If not, I'll scrap it
<FromGitter> <watzon> Ok I've been fighting with this issue all day. How can I make this work as expected? https://carc.in/#/r/6y9s
DTZUZO has quit [Ping timeout: 250 seconds]
<FromGitter> <Blacksmoke16> make it a `class_property` and just have it within the module you want
<FromGitter> <Blacksmoke16> vs trying to include it
<FromGitter> <watzon> I know that I could do that, it's not what I need though
<FromGitter> <Blacksmoke16> i dont have any other ideas
<FromGitter> <watzon> i feel like I've tried every possible combination of `property`, `class_property`, `include`, and `extend`
<FromGitter> <Blacksmoke16> :shrug:
blassin42 has joined #crystal-lang
blassin4 has quit [Ping timeout: 246 seconds]
alexherbo23 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 258 seconds]
<FromGitter> <Daniel-Worrall> So what I did was just do ⏎ ⏎ ``` io = IO::Memory.new(m) ⏎ handle_io(io) ⏎ end`````` [https://gitter.im/crystal-lang/crystal?at=5ce3701c83ae782aeea34094]
hightower2 has quit [Ping timeout: 246 seconds]
_ht has joined #crystal-lang
<FromGitter> <Daniel-Worrall> oh boi, #5375 just caught me off guard
<DeBot> https://github.com/crystal-lang/crystal/issues/5375 (Different behaviour of #write action between SSL client socket and TCPSocket)
<FromGitter> <Daniel-Worrall> having to call #flush when using an SSL socket
sagax has joined #crystal-lang
<FromGitter> <watzon> Some thoughts https://redd.it/br65qi
<FromGitter> <watzon> And heres part 2 of my Doing Crystal series
Raimondii has joined #crystal-lang
Raimondi has quit [Read error: Connection reset by peer]
Raimondi^1 has joined #crystal-lang
Raimondii has quit [Ping timeout: 258 seconds]
Raimondi^1 is now known as Raimondi
DTZUZO has joined #crystal-lang
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 246 seconds]
return0e_ has quit [Remote host closed the connection]
_whitelogger has joined #crystal-lang
ashirase has quit [Ping timeout: 250 seconds]
tdc has quit [Quit: Leaving]
alexherbo23 has quit [Ping timeout: 255 seconds]
return0e has joined #crystal-lang
<FromGitter> <Prutheus> @Prutheus ⏎ I am using Kemal: Problem: I have a post request with a lot of data (lot of images, base64 coded) .... but my Kemal is blocking this request, it is too large, how to fix that? ⏎ Please help me
<FromGitter> <Prutheus> I am using Kemal: Problem: I have a post request with a lot of data (lot of images, base64 coded) .... but my Kemal is blocking this request, it is too large, how to fix that? ⏎ Please help me
<FromGitter> <Prutheus> Upps. Sorry. But please
alexherbo23 has joined #crystal-lang
<FromGitter> <watzon> What I wan't to know is why are you sending so many base64 encoded images? Why not send links? @Prutheus
<FromGitter> <j8r> @Prutheus do a post for each image
<FromGitter> <j8r> or use another appropriate technology to send the data
<FromGitter> <Prutheus> because I upload them to my database via that method
<FromGitter> <Prutheus> @j8r it is right, this would be the best solution, but is it not possible to say to my Kemal to allow larger posts?
<FromGitter> <Prutheus> I don't want the right solution, I just want to allow a large post
<FromGitter> <j8r> don't do this, what happens if the connection is lost?
<FromGitter> <j8r> you will nee to reupload everything?
<FromGitter> <Prutheus> it is ok, in this system it would be very complex to do separate posts, please help me solve this with allowing a big post
<FromGitter> <Prutheus> @j8r you know if it is possible?
<FromGitter> <pynixwang> store image in db is bad idea
<FromGitter> <pynixwang> post is to big.
<FromGitter> <pynixwang> maybe
<FromGitter> <Prutheus> yes it is @pynixwang
<FromGitter> <Prutheus> but I need to do it, I can't change other things in the system
<FromGitter> <pynixwang> store in a cloud storage
<FromGitter> <Prutheus> can you tell me how to allow such big posts in Kemal?
<FromGitter> <pynixwang> how big?
<FromGitter> <pynixwang> 10M?
<FromGitter> <j8r> post this into https://gitter.im/sdogruyol/kemal @Prutheus
<FromGitter> <Prutheus> some data + 20 images, resolution mx. 1080p
<FromGitter> <pynixwang> folder size.
<FromGitter> <pynixwang> hava a look
<FromGitter> <Prutheus> circa 1MB
<FromGitter> <pynixwang> not too big
<FromGitter> <pynixwang> maybe crystal long string has no optimization.
<FromGitter> <pynixwang> ...
livcd has joined #crystal-lang
<FromGitter> <Prutheus> no there is no crash
<FromGitter> <Prutheus> I just get a not allowed by Access Control Origin
moei has joined #crystal-lang
<FromGitter> <Prutheus> when I have too much pictures, with just 7 it works.
<FromGitter> <r00ster91> When there is multithreading, wouldn't it be possible to execute multiple compile stages (the ones you see with `--stats`) at once for faster compile times?
<livcd> what has the biggest impact on compile time ?
<jhass> they're stages because the output of one is the input of the next one
<FromGitter> <r00ster91> ooh right
<jhass> biggest impact so far are actually LLVM phases, codegen (AST to LLVM IR and LLVM IR to bytecode) and in release builds optimizer pass on the LLVM IR
<jhass> not saying that there's nothing crystal can do, it probably can generate LLVM IR that's easier to digest for LLVM or simply less of it
ashirase has joined #crystal-lang
<FromGitter> <r00ster91> yeah Crystal can definitely do something. 30k lines of LLVM IR for a hello world is way way way too much
<FromGitter> <r00ster91> 69 009 lines of LLVM IR*
<FromGitter> <r00ster91> not even 30k
<jhass> well it contains the entire runtime
<jhass> given all IO is evented by default in crystal that's simply quite a bit
<FromGitter> <r00ster91> Wouldn't it be at least somewhat better if Crystal would generate LLVM IR that looks like asm.js? So LLVM can convert it to assembly faster. So no newlines or spaces where it's not needed, no comments etc.
<FromGitter> <r00ster91> unless the user adds `--emit llvm-ir`, then it should generate clean, readable LLVM IR again
<jhass> you mean generate asm.js assembly or LLVM IR like emscripten?
<jhass> for the former I cannot imagine that speeds anything up, for the latter somebody has to try, but it would surprise me still to make a big difference
<FromGitter> <r00ster91> asm.js-like LLVM IR I mean
<FromGitter> <r00ster91> e.g. ` %91 = icmp ugt i64 %90, %75` becomes `%91=icmp ugt i64 %90,%75`. No extra spaces, newlines or anything. So LLVM can parse it faster
<jhass> I really doubt it's about raw parsing performance
<jhass> would surprise me a lot
<jhass> that is it seemed CPU bound to me, not IO bound
<FromGitter> <umutuluer> Hi guys
<FromGitter> <Blacksmoke16> o/
<FromGitter> <umutuluer> Who uses emacs for crystal
<FromGitter> <pynixwang> no
<FromGitter> <umutuluer> i have a trouble about crystal mode, emacs says obsolete package and deleted it when it is loading
<FromGitter> <umutuluer> version is 26.2, system is OSX
<FromGitter> <pynixwang> vim user
<FromGitter> <Blacksmoke16> crystal version is 0.26.2?
<FromGitter> <Blacksmoke16> if so thats 2 minor versions out of date, might be reason for the obsolete package error
<FromGitter> <vladfaust> Crystal YAML has no support for tags, right? E.g. `foo: !bar baz`
<FromGitter> <pynixwang> yaml2.0?
<FromGitter> <vladfaust> 1) 2, I guess
<FromGitter> <vladfaust> Ah, their specs are more complicated than I thought. Nevermind, then
<FromGitter> <vladfaust> Well, tags are supported, but it's not easy to get them from `YAML::Any`
<alexherbo23> I want to write a syntax highlighter for Kakoune editor
<alexherbo23> Where I can find the list of keywords?
<alexherbo23> Is there a place documented, or a way to retrieve it from Crystal?
<jhass> not sure that's kept up-to-date :D
<FromGitter> <Blacksmoke16> is at least a start :P
<FromGitter> <Blacksmoke16> prob could also checkout like the playground highlighting, or sublime etc
ShalokShalom has quit [Ping timeout: 244 seconds]
<jhass> https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/syntax/lexer.cr calls to check_ident_or_keyword also gets you a long way I guess
coderobe5 has joined #crystal-lang
coderobe has quit [Killed (wolfe.freenode.net (Nickname regained by services))]
coderobe5 is now known as coderobe
coderobe is now known as Guest74578
DTZUZO_ has joined #crystal-lang
DTZUZU2 has joined #crystal-lang
early` has joined #crystal-lang
jokke1 has joined #crystal-lang
Guest74578 has quit [Client Quit]
coderobe has joined #crystal-lang
DTZUZO has quit [*.net *.split]
ua_ has quit [*.net *.split]
early has quit [*.net *.split]
FromGitter has quit [*.net *.split]
Vexatos has quit [*.net *.split]
go|dfish has quit [*.net *.split]
dom96_ has joined #crystal-lang
FromGitter has joined #crystal-lang
dannyAAM has quit [*.net *.split]
DTZUZU has quit [*.net *.split]
dom96 has quit [*.net *.split]
jokke has quit [*.net *.split]
ua_ has joined #crystal-lang
<alexherbo23> do you have a link to the playground highlighting?
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
return0e has quit [Ping timeout: 268 seconds]
<FromGitter> <pynixwang> how about method annotation and args annotation?
Vexatos has joined #crystal-lang
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <Blacksmoke16> what about them
return0e has joined #crystal-lang
<FromGitter> <pynixwang> cool feature
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <advancedwebdeveloper> > @advancedwebdeveloper -> https://faastruby.io/ ⏎ ⏎ So you are trying to say that there is some support for MIPS?
<FromGitter> <dscottboggs_gitlab> no faastruby is a functions-as-a-service thing, didn't you ask two questions around that time?
<FromGitter> <dscottboggs_gitlab> There's no reason MIPS *wouldn't* work, it just hasn't been done *yet*
<FromGitter> <dscottboggs_gitlab> As long as there's a GLibC or Musl LibC for the platform, and LLVM can target it, you can run crystal code
<FromGitter> <dscottboggs_gitlab> @advancedwebdeveloper ^^
<FromGitter> <pynixwang> method annotation is implemented
<FromGitter> <Blacksmoke16> yes
<FromGitter> <pynixwang> NoInLine.
<FromGitter> <pynixwang> AlwaysInLine
<FromGitter> <pynixwang> but it 's primitive
<FromGitter> <mwlang> When building out a JSON::Serializable class, does it not work until the whole thing is built?
<FromGitter> <Blacksmoke16> it would just ignore the fields you dont have properties for
<FromGitter> <advancedwebdeveloper> > no faastruby is a functions-as-a-service thing, didn't you ask two questions around that time? ⏎ ⏎ Sorry, forgot - thanks for the answer
<FromGitter> <mwlang> I'm using TDD to build a rather big one, but just get back blank results on the first three or four fields I've already coded.
<FromGitter> <Blacksmoke16> :thinking:
<FromGitter> <mwlang> ok, I'm going to assume it's me and not the compiler for now. :-)
<FromGitter> <Blacksmoke16> okey dokey
<FromGitter> <mwlang> found it... ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce436160ac9852a951855a5]
<FromGitter> <mwlang> I had same getter name twice due to copy/paste
<FromGitter> <mwlang> only, I wasn't getting a compiler error until I started commenting stuff out.
<FromGitter> <Blacksmoke16> that would do it
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <mwlang> Is it possible to serialize into a named tuple?
<FromGitter> <Blacksmoke16> an obj into named tuple i assume?
<FromGitter> <Blacksmoke16> oh
<FromGitter> <Blacksmoke16> or json string into named tuple?
<FromGitter> <mwlang> json into tuple. For example, Binance array of filter types: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#iceberg_parts
<FromGitter> <Blacksmoke16> should just be able to do like
<FromGitter> <mwlang> each filter has it's own name and one or more supporting fields.
<FromGitter> <Blacksmoke16> `NamedTuple(name: String, age: Int32).from_json json_str`
<FromGitter> <mwlang> but can it be dynamically determined at runtime?
<FromGitter> <Blacksmoke16> no
<FromGitter> <dscottboggs_gitlab> What's the property of an operator called where it doesn't matter what side you put it on? Like how you can do `1_u16 - 1_i32` or `1_i32 - 1_u16` and they both mean the same thing (or don't the point is the word for that property of the `-` operator)
<FromGitter> <dscottboggs_gitlab> idk how to google that
<FromGitter> <dscottboggs_gitlab> lol
<FromGitter> <mwlang> associative.
<FromGitter> <dscottboggs_gitlab> > the associativity of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses. ⏎ ⏎ No I mean like... lemme think of an example that isn't this way...
<FromGitter> <dscottboggs_gitlab> never mind I found it
<FromGitter> <dscottboggs_gitlab> I was looking for "commutative"
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <mwlang> hmmm...can I use filterType to select the right struct to load?I was wrong, https://www.purplemath.com/modules/numbprop.htm
<FromGitter> <mwlang> and yes, it's commutative.
<FromGitter> <mwlang> hmmm...can I use filterType to select the right struct to load? :-)
<FromGitter> <mwlang> For example.
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab did something with that
<FromGitter> <mwlang> so I would define serializable structs or classes for PriceFilter, PercentPrice, and LotSize in this case.
<FromGitter> <Blacksmoke16> the challenge is actually picking which one to use
<FromGitter> <mwlang> and I would want the JSON::Field annotation to pick on the "filterType" name.
<FromGitter> <dscottboggs_gitlab> the solution I came up with was kinda hacky
<FromGitter> <mwlang> macros, perhaps?
<FromGitter> <dscottboggs_gitlab> 1 - an entry in the object had to be placed before anything else, which told what type it was
<FromGitter> <dscottboggs_gitlab> so `{ "kind": "PriceFilter", .... } `
<FromGitter> <dscottboggs_gitlab> but it has to be physically first in the file or it raises a runtime error
<FromGitter> <dscottboggs_gitlab> which is the hacky part
<FromGitter> <mwlang> as far as I can tell, Binance is consistently presenting the filterType field first for every entry.
<FromGitter> <Blacksmoke16> seems kinda brittle
<FromGitter> <dscottboggs_gitlab> the only other requirement is that all of the other stuff inherit from the same interface, which can even just be a blank module or a Union
<FromGitter> <dscottboggs_gitlab> > seems kinda brittle ⏎ ⏎ I ageee
<FromGitter> <dscottboggs_gitlab> I'd like it if there was a better solution
<FromGitter> <dscottboggs_gitlab> you could always just read into `JSON::Any`
<FromGitter> <mwlang> hmmm....I'm thinking to just have one Filter class.
<FromGitter> <Blacksmoke16> sec
<FromGitter> <mwlang> and as many properties as it takes for every permutation out there.
<FromGitter> <dscottboggs_gitlab> @gring (I guess he's not around anymore 😦 ) discovered that it's not actually any slower to use `JSON::Any
<FromGitter> <Blacksmoke16> kinda not true
<FromGitter> <dscottboggs_gitlab> > and as many properties as it takes for every filter type out there.
<FromGitter> <Blacksmoke16> the initial parsing of it is the same, afterwards serializable is faster
<FromGitter> <dscottboggs_gitlab> oh I see
<FromGitter> <mwlang> and do the properties as optional. or am I assuming too much that Json::Serializable will seamlessly skip properties not presented by the server.
<FromGitter> <dscottboggs_gitlab> yes
<FromGitter> <dscottboggs_gitlab> it does that
<FromGitter> <dscottboggs_gitlab> gotta go
<FromGitter> <mwlang> ok, I'll run with this idea. thanks for chiming in.
<FromGitter> <Blacksmoke16> if they are nilable
<FromGitter> <mwlang> I'll make 'em nilable.
<FromGitter> <Blacksmoke16> or have default valu
<FromGitter> <Blacksmoke16> otherwise would raise saying expected x to be a y but got nil
return0e has quit [Ping timeout: 272 seconds]
<FromGitter> <Blacksmoke16> @mwlang @dscottboggs_gitlab https://play.crystal-lang.org/#/r/6yd8 :shrug:
<FromGitter> <Blacksmoke16> prob not super efficient, but prob good enough
<FromGitter> <mwlang> @Blacksmoke16 thanks for that. That gives me an idea on how to improve what I just wrote (which surprisingly worked on first compile attempt)
return0e has joined #crystal-lang
<FromGitter> <Blacksmoke16> could prob combine array/single obj into one method
<FromGitter> <Blacksmoke16> so like if its an array do that else just assume its an obj and return a single one
<FromGitter> <mwlang> This is what I have so far: https://play.crystal-lang.org/#/r/6ydc
<FromGitter> <mwlang> I think, ideally, if I'm getting a bunch of exchange filters back, I ought to just capture them during serializable and then pluck and assign each one to it's own property.
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <mwlang> I recognize that what Binance did here was allow flexibility to add new filters in the future without breaking a structure they have going...so trick for maintaining this library is detecting when a new one comes along later and handling it.
<FromGitter> <Blacksmoke16> yea, theres not really a way to do that so its bulletproof without keeping up on it
<FromGitter> <Blacksmoke16> unless they have some file/endpoint that lists them all?
<FromGitter> <Blacksmoke16> and the schema for each
<FromGitter> <mwlang> just the documentation
<FromGitter> <Blacksmoke16> oh well, just add an else block to the switch and if/when that errors you'll know
<FromGitter> <Blacksmoke16> :S
<FromGitter> <Blacksmoke16> or better yet, add logging to else block but just skip that one so it still works, just excludes unsupported types
<FromGitter> <Blacksmoke16> vs raising an exception
<FromGitter> <Blacksmoke16> holy crap, TIL the forums have a dark theme 💯
<FromGitter> <Blacksmoke16> now github just needs to get one and ill be set
<FromGitter> <mwlang> Do I need to write a string to float converter for the JSON serializer or does one already exist?
<FromGitter> <Blacksmoke16> would have to make one
<FromGitter> <mwlang> ok
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce46e4a9404bf2aed87bd1e]
<FromGitter> <Blacksmoke16> that should work, off the top of my head
go|dfish has joined #crystal-lang
return0e has quit [Ping timeout: 272 seconds]
return0e has joined #crystal-lang
renich has joined #crystal-lang
moei has quit [Quit: Leaving...]
return0e has quit []
return0e has joined #crystal-lang
<renich> Hello! o/
<renich> I don't quite get the message here. Why doesn't this one work? https://play.crystal-lang.org/#/r/6yec
<FromGitter> <Blacksmoke16> prob because of your `bios` section
<FromGitter> <Blacksmoke16> are giving it a sequence (array) when it should be just key value pairs
<FromGitter> <Blacksmoke16> sec
<renich> Blacksomke16: OK
<FromGitter> <Blacksmoke16> i give give a working version in a bit after dinner if you still need
<renich> Blacksmoke16: Thanks! I don't want to disturb you. I'll wait.
<renich> ... and try to figure it out myself, hehe.
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6yem
<FromGitter> <Blacksmoke16> id also look int ohttps://crystal-lang.org/api/0.28.0/YAML/Serializable.html
<FromGitter> <Blacksmoke16> @renich ^
<FromGitter> <asterite> That's why I think String from yaml should allow "float" values... the ve
<FromGitter> <asterite> the bios revision isn't really a float
<FromGitter> <asterite> I hope we agree to fix this
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/5798 yes, was the issue i filed when i first started with crystal :P
<FromGitter> <Blacksmoke16> similar thing going on id imagine
<FromGitter> <Daniel-Worrall> Is there any way to yield from inside a proc
<FromGitter> <Daniel-Worrall> wait no that's a dumb question
<renich> Blacksome16: Awesome, let me try
<FromGitter> <Blacksmoke16> if you need the bios version to be a string, would have to write a converter to parse it as a string
<renich> Blacksmoke16: got it.
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/blob/master/src/yaml/from_yaml.cr#L245 something like one of those
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.28.0/String/RawConverter.html should be able to use this but it seems its missing the methods for yaml
<FromGitter> <Blacksmoke16> prob make a PR for it