jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <thelinuxlich> how do I decode a Crystal DB ResultSet into a Array of NamedTuples?
<FromGitter> <thelinuxlich> trying this ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef1468547fdfd21eddc972f]
deavmi has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> have to do it manually, prob something like `{name: i.read(String), id: i.read(Int32)}`, where you call them in order
<FromGitter> <thelinuxlich> hmmmm
<FromGitter> <Blacksmoke16> oh wait
<FromGitter> <Blacksmoke16> are you using `query_all`?
<FromGitter> <thelinuxlich> thought this would work: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef14832613d3b3394017003]
<FromGitter> <Blacksmoke16> https://crystal-lang.github.io/crystal-db/api/0.8.0/DB/QueryMethods.html#query_all(query,*args_,args:Array?=nil,astypes:NamedTuple)-instance-method
<FromGitter> <Blacksmoke16> prob is what you want
deavmi has joined #crystal-lang
<FromGitter> <thelinuxlich> worked! thanks @Blacksmoke16 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef14b0254d7862dc4a1fec8]
<FromGitter> <Blacksmoke16> 👍
oddp has quit [Ping timeout: 264 seconds]
<FromGitter> <Daniel-Worrall> @watzon will that work with Chrome through ChromeDriver?
<FromGitter> <watzon> Yep. Chrome with chromedriver, Firefox with geckodriver, etc. It will fully support: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef16987ec4a341beee2e286]
<FromGitter> <watzon> Android and PhantomJS use a "remote" mode to connect to the actual browser, the others all use a driver
<FromGitter> <Daniel-Worrall> ooh
zorp_ has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <watzon> Well I should be mostly done with this tomorrow https://github.com/watzon/marionette/tree/develop
<FromGitter> <watzon> Man this has been a lot of work. Especially `actions.cr`. Still debugging that right now.
<FromGitter> <watzon> Should have a nice DSL for performing mouse and keyboard actions by the time I'm done though. Something like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef18abaec4a341beee325ce]
sorcus has joined #crystal-lang
<frojnd> Yesterday I tried played with HTTP::Client to call api but I was unsuccessful. This is curl in bash I'm trying to transfer to crystal: https://termbin.com/33dy any help appreciate
<FromGitter> <j8r> I'm gonna figure out what's the best for a 2D matrix: `Hash(Tuple(Int32, Int32), V` or `Hash(Int32, Hash(Int32, V))`
oddp has joined #crystal-lang
<jhass> frojnd: what did you try, how did it fail?
<FromGitter> <j8r> The first is probably better memory wise, but not sure about the lookup speed. Essentially, if `Tuple#hash` is as efficient as two `Int#hash`
<jhass> j8r: static and known bounds?
<FromGitter> <j8r> Static
<jhass> like you know it's a 64x64 grid and every cell always has an entry
<FromGitter> <j8r> Yep
<jhass> Array(Array(Int32))
<FromGitter> <j8r> Can't be
<jhass> or even just Array(In32) and some math
<FromGitter> <j8r> Array won't be good
<jhass> x + y*x
<jhass> eh, + y*x%N
<FromGitter> <j8r> Because I may access to the last element often
<jhass> then array is very good
<jhass> especially a flat one
<FromGitter> <j8r> Or the middle one
<jhass> yep
<FromGitter> <j8r> And all may not be loaded
<FromGitter> <j8r> Array means having a full matrix loaded in memory
<jhass> no
<jhass> especially flat array does not
<FromGitter> <j8r> How?
<jhass> and even nested is just a pointer load + offset into that pointer
<FromGitter> <j8r> For example, I need to load in memory (1, 4) and (56, 32) – only
<FromGitter> <j8r> But other may be loaded after, as needed
<FromGitter> <j8r> And other not used removed, etc
<jhass> yeah, that's just computing the pointer offset from the array base pointer and then two loads on those memory locations
<FromGitter> <j8r> Then I can use a single StaticArray
<FromGitter> <j8r> Right?
<FromGitter> <j8r> Hum no actually nvm
<jhass> you could it's probably just not faster if it's any big
<FromGitter> <j8r> Could you show me a carc.in of this please :)?
<frojnd> jhass: like this: https://termbin.com/dmb0 I don't get any response. I get no errors. Just nothing when calling puts
<frojnd> Oh... not sure how to add --data-raw..
<frojnd> I just noticed I missed that part entirelly...
<jhass> j8r: https://carc.in/#/r/9ba2 something like this
<jhass> frojnd: hehe yeah. You can just do HTTP::Client.post("https://host/path", headers: HTTP::Headers { "Authorization => ... }, body: {devid: ...}.to_json)
<jhass> that returns your a response on which you can puts response.body
<jhass> or pp response for more interesting output with status code and what not
<frojnd> jhass: Thank you. Gonna try that now :)
<jhass> need to require "json" for to_json to work :)
<FromGitter> <j8r> Thanks jhass, I will benchmark this
<jhass> might make it struct instead of class
<FromGitter> <j8r> Actually i think it will be faster than hash, no need to bench
<FromGitter> <j8r> `Array#unsafe_fetch` is `@buffer[index]`
<FromGitter> <j8r> Hum, the array is nevertheless continuous here
<FromGitter> <j8r> But I may make initial `nil` to have `Array(T?)` as a word-around
<FromGitter> <j8r> *work-around
<FromGitter> <j8r> Looks great nevertheless :D
<FromGitter> <j8r> And `T` is a StaticArray of StaticArray, this is a chunk
zorp_ has quit [Ping timeout: 264 seconds]
<jhass> there's crazy optimization techniques to stuff like that, like changing the group function such that values you access often together are also close by in memory. Say you'd always iterate this column first, you could swap x and y. Or you always look at pairs of (x, y) and (x + 1, y +1), could make sure they're stored next to each other in the array etc
<FromGitter> <j8r> Looks interesting :o !
<FromGitter> <j8r> In my case, I am still figuring out the design. It's already very good now, and even more thanks to you :)
<FromGitter> <j8r> `T` would be a tile of squares, which would be rendered to a PNG and sent to the client
<FromGitter> <j8r> `T` is a Chunk, which olds the grid of static arrays, and I plan also an array of entities
<FromGitter> <j8r> *holds
<FromGitter> <j8r> That's a way to know neighbouring entities to check collisions against them (of course I have to get those of the chunk near too)
<FromGitter> <j8r> That's if the entity is in between
sorcus has quit [Quit: WeeChat 2.8]
zorp_ has joined #crystal-lang
zorp_ has quit [Ping timeout: 260 seconds]
sorcus has joined #crystal-lang
<FromGitter> <manveru> is ther really no way to do a `Dir.chdir`?
<FromGitter> <manveru> do i have to spawn a new process for that?
<FromGitter> <roduquen> Hi, I have problem since update 0.35.1, I cant compile, the linking failed ⏎ ```/usr/share/crystal/src/openssl/bio.cr:24: undefined reference to `*HTTP::WebSocket::Protocol::StreamIO#write<Slice(UInt8)>:Int64' ⏎ /usr/bin/ld: /usr/share/crystal/src/openssl/bio.cr:24: undefined reference to `*HTTP::Server::Response#write<Slice(UInt8)>:Int64' ⏎ /usr/bin/ld: /usr/share/crystal/src/openssl/bio.cr:24:
<FromGitter> ... undefined reference to `*HTTP::Server::Response::Output@IO::Buffered#write<Slice(UInt8)>:Int64' ⏎ /usr/bin/ld: /usr/share/crystal/src/openssl/bio.cr:24: undefined reference to `*Compress::Gzip::Writer#write<Slice(UInt8)>:Int64' ... [https://gitter.im/crystal-lang/crystal?at=5ef1f4ff7ba3965373c3e528]
<FromGitter> <manveru> oh my
<FromGitter> <manveru> thanks, i totally overlooked Dir.cd :)
<jhass> roduquen: Try clearing the cache, rm -rf "$(crystal env CRYSTAL_CACHE_DIR)". If that doesn't help, I feel like that's not the full output, make sure to share the full one in a pastebin
<FromGitter> <roduquen> it works thanks
<yxhuvud> "Changes the current working directory of the process" Hmm, I wonder if that is fiber-safe.
<jhass> what's even the definition of fiber-safe for that
<yxhuvud> I'd say it is for two fibers being able to act independently and not affect each other. It would probably necessitate for the fiber to keep track a reference to current dir.
<jhass> so you want to check and potentially change the process directory on fiber context switch? Sounds expensive. And impossible in mult-thread mode
<yxhuvud> well, in practice it would change only when doing io. Potentially by rewriting relative urls into absolute.
<jhass> I don't think we can potentially capture everything that could potentially be affected by this in kernel property to sanely emulate it
<jhass> it also sounds like it would need a global lock around calling external libraries
<yxhuvud> true. Yeah, that doesn't sound fun
<yxhuvud> (actually it sounds absolutely horrible)
<jhass> yes :P
repo has quit [Ping timeout: 265 seconds]
<FromGitter> <j8r> jhass: the grid won't work for infinite maps :/
<jhass> of course, why do you think I asked the question I initially asked
<FromGitter> <j8r> Hopefully, I don't plan to have it ;)
<jhass> it can work for one dimenision unbounded, but the other needs to fixed
<jhass> or at least upper bounded
<FromGitter> <j8r> What would you chose for a 3D matrix, infinite?
<jhass> the question is not how many dimensions but whether their size and number is fixed
<FromGitter> <j8r> When I was working on the 3D matrix, not fixed
<FromGitter> <j8r> Infinite in all directions
<FromGitter> <j8r> So I guess for a 2D infinite map the solution will be the same then
<jhass> the same as?
<FromGitter> <j8r> than a 3D map
<jhass> I guess
<yxhuvud> big sparse maps tend to do well with a hash based representation. (except possibly if you are implementing linalg libraries. In that case, see whatever sparse matrix implementations exist. There is a couple of different formats in use)
repo has joined #crystal-lang
<frojnd> jhass: sorry for such long replies :) I tried HTTP::Client.post("https://host/path", headers: HTTP::Headers { "Authorization => ... }, body: {devid: ...}.to_json) but I get: Error: undefined method 'to_json' for NamedTuple(devid: String)
<FromGitter> <Blacksmoke16> did you `require "json"`?
<frojnd> I did it like this: body: {devid: "#{device_id}"}.to_json)
<frojnd> Ofcourse I did not
<FromGitter> <Blacksmoke16> well there you go :p
<jhass> "#{whatever}" -> whatever.to_s :)
<frojnd> Ah ok thank you,..
<frojnd> Can I somehow write this oneliner into multiple line other than with \ ?
<jhass> you shouldn't need any \
<FromGitter> <Blacksmoke16> what, that `HTTP::Client.post`?
<jhass> just put newlines pretty much wherever you like
<jhass> except inside string literals :)
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
<FromGitter> <jwaldrip> Is the core team going to get an apple development kit? Would hate to see mac support go away with the new changes coming from apple.
<FromGitter> <jwaldrip> Bonus, it would also bring native support for Crystal to the iPhone.
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
rocx has joined #crystal-lang
deavmi has quit [Client Quit]
<FromGitter> <watzon> Support for the new Apple silicon would be awesome. I imagine we're going to either have to wait on LLVM or have someone write a crystal assembler though.
deavmi has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
<FromGitter> <asterite> I think none of us is going to get the new arm mac for a while (pretty expensive here, nobody can fly to the us to grab some), so I think we'll support existing macs for a while... I'm not sure about arm though
<FromGitter> <jwaldrip> $500 mac mini is the transition kit here in the US. What does that go for down in Argentina?
<FromGitter> <jwaldrip> I'm sure we could start a campaign to get someone on the core team one.
<FromGitter> <jwaldrip> I myself would be willing to chip in.
deavmi has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
deavmi has quit [Client Quit]
deavmi has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
<FromGitter> <asterite> most probably more than $1000
deavmi has quit [Client Quit]
renich has joined #crystal-lang
deavmi has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
deavmi has quit [Client Quit]
deavmi has joined #crystal-lang
deavmi has quit [Client Quit]
deavmi has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
renich_ has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
renich has quit [Ping timeout: 240 seconds]
renich_ is now known as renich
renich has quit [Client Quit]
deavmi has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi_ has joined #crystal-lang
deavmi_ has quit [Quit: Eish! Load shedding.]
<FromGitter> <wontruefree> Is there a way to query the namespaces in the `inherited` hook
<FromGitter> <wontruefree> I want to add a method to the "parent" namespace when a class is inherited
<FromGitter> <Blacksmoke16> :thinking: just define it in the parent class then?
<FromGitter> <Blacksmoke16> or does it depend on some context of the child?
<FromGitter> <wontruefree> It would have no parent class it would just be namespaced
<FromGitter> <Blacksmoke16> got an example?
<FromGitter> <wontruefree> ```code paste, see link``` ⏎ ⏎ In this example when Baz is defined I want to also define baz on Foo [https://gitter.im/crystal-lang/crystal?at=5ef231747ba3965373c49b17]
<FromGitter> <Blacksmoke16> did you mean `class Foo`? because in this example there is no `Foo` class
<FromGitter> <wontruefree> sorry I compacted my usecase there is a foo class
<FromGitter> <wontruefree> it is actually a module in my code I dont know if that matters
<FromGitter> <Blacksmoke16> could prob do something like
<FromGitter> <Blacksmoke16> is `Foo` static?
<FromGitter> <wontruefree> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef231f254d7862dc4a43140]
<FromGitter> <Blacksmoke16> i.e. always ant to add it to there, for all children
<FromGitter> <Blacksmoke16> well to be clear that wont work because you cant have a class inherit from a module?
<FromGitter> <wontruefree> yeah
<FromGitter> <Blacksmoke16> unless you mean `class Baz < Foo::Bar`?
<FromGitter> <wontruefree> yep
<FromGitter> <Blacksmoke16> 👍 could prob do
<FromGitter> <wontruefree> trying to cut out some code so it is a little messy
<FromGitter> <wontruefree> right now I am using a gsub and some other string manipulation
<FromGitter> <wontruefree> I was hoping there was something a little more stable
<FromGitter> <Blacksmoke16> I'm assuming you just cant define it in `Foo` module directly?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9bbh
<FromGitter> <Blacksmoke16> could do something like that, but :shrug:
<FromGitter> <wontruefree> I like that way better then what I have done
<FromGitter> <wontruefree> but it wont work in my usecase because it is actually recursive
<FromGitter> <wontruefree> I wont always know the module name
<FromGitter> <wontruefree> so this works for the first case
<FromGitter> <Blacksmoke16> then how do you know what module to add the method to?
<FromGitter> <wontruefree> It would be the one directly in front of it in the namspacing
<FromGitter> <wontruefree> So in `Foo::Bar::Baz` it would always be the one before it
<FromGitter> <Blacksmoke16> of the parent type?
<FromGitter> <wontruefree> I dont know if they are called parents I think they are just left on the namespacing
deavmi has joined #crystal-lang
<FromGitter> <wontruefree> so `Foo` should have `#bar` and `Bar` should have `#baz`
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9bby
<FromGitter> <Blacksmoke16> not sure i totally follow, but maybe could do something similar to that
<FromGitter> <Blacksmoke16> updated link
<FromGitter> <jwoertink> Is there a macro method to tell if a TypeDeclaration value is actually a `raise`? `attr x : String = raise "oops"`
<FromGitter> <Blacksmoke16> does that actually compile?
<FromGitter> <jwoertink> yeah, it raises "oops"
<FromGitter> <jwoertink> I was curious if there was a way to tell that it will raise but at compile time instead of run time
<FromGitter> <jwoertink> like `raise "compile time message" if type_dec.value.is_a_raise`
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9bc8 that would prob do it
<FromGitter> <jwoertink> ah interesting. Ok, that might work. Thanks!
<FromGitter> <Blacksmoke16> but seems kinda odd thing to catch, like would that ever make sense?
<FromGitter> <Blacksmoke16> `attr x : String = raise "oops"` this i mean
<FromGitter> <jwoertink> Ok, maybe that won't work. If the value is legit like `x : String = "1"` then it fails with `undefined macro method 'StringLiteral#name'`.
<FromGitter> <jwoertink> In my case, if you do a raise there, it causes some other issues. I was just going to not allow a raised value
<FromGitter> <jwoertink> but I might have to rethink this
<FromGitter> <Blacksmoke16> well you can check what is passed
<FromGitter> <wontruefree> @Blacksmoke16 that is what I am doing but slightly different
<FromGitter> <Blacksmoke16> i.e. `if type_decl.value.is_a? Call`
<FromGitter> <wontruefree> I was hoping there was a way to do it without gsub or string maniputaltion
<FromGitter> <Blacksmoke16> if you could convert a `TypeNode` to a `Path` it gets a bit easier, but idt that exists atm
<FromGitter> <jwoertink> Ah, ok. If it's a Call and the name is "raise"
<FromGitter> <Blacksmoke16> yea, possible for someone to define their own `raise` method tho
<FromGitter> <Blacksmoke16> but meh
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
<FromGitter> <wout> Is there a way to know if a given class includes a certain module at compile time?
<FromGitter> <Blacksmoke16> something like `{{MyModule.includers.includes? MyClass}}`
<FromGitter> <wout> @Blacksmoke16 Exactly that. Thanks!
<FromGitter> <wontruefree> I think I am going to make an RFC for it
<FromGitter> <Blacksmoke16> for what, getting a `Path` from a `TypeNode`?
deavmi has quit [Quit: Eish! Load shedding.]
repo has quit [Ping timeout: 265 seconds]
deavmi has joined #crystal-lang
svipal has joined #crystal-lang
<svipal> yo
<FromGitter> <Blacksmoke16> hi
<svipal> is it possible to add methods to a class that' s been defined previously in another file ?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> just reopen the class again and add the method
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef2418dd65a3b0292a6cb29]
<svipal> Tried it with String and it tells me there's a conflict between String and File::String
<FromGitter> <Blacksmoke16> got an example? https://play.crystal-lang.org/#/cr
repo has joined #crystal-lang
<svipal> will try with diff modules
<svipal> not exactly the same but
<svipal> note : I'm very new to crystal and it's likely I'm overlooking something obvious
<FromGitter> <Blacksmoke16> yea idt that does what you think
<FromGitter> <Blacksmoke16> `A::C` and `B::C` are deff classes
<FromGitter> <Blacksmoke16> different*
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9bdd
repo has quit [Quit: WeeChat 2.8]
<svipal> so how do I open the old class in module B ?
<FromGitter> <Blacksmoke16> or a bit cleaner: https://play.crystal-lang.org/#/r/9bde
<svipal> ah, this is clean
<svipal> So to overload String I would have to
repo has joined #crystal-lang
<FromGitter> <Blacksmoke16> wait, you want to add something to `String`?
<svipal> yeah
<FromGitter> <Blacksmoke16> like what?
<FromGitter> <Blacksmoke16> can you share some code with what you're actually trying to do?
<svipal> I mean sure it's not something too complex
<svipal> It's includes_any? and includes_all? which is are variation of includes? with a string as an input
<svipal> which areù
<svipal> I could just define them as some modules functions but figured it would be cleaner as class methods
<FromGitter> <Blacksmoke16> :thinking: how would they be used?
<svipal> I'm writing a parser for a custom format. You would use them if you wanted to know if a string included any or all symbols from another string, can cook an example if you want but I don't think it's very relevant
<svipal> I'm trying to find the name of the module in which the class String is defined, can't find it
<FromGitter> <Blacksmoke16> its not in a module
<svipal> ok I cry now
<FromGitter> <Blacksmoke16> but arent those methods essentially just the same as like `str.includes? "foo"` and `str == "foo"`?
<svipal> nope they aren't
<svipal> includes?(search : String) returns true if the string contains the search string
<FromGitter> <Blacksmoke16> right
<svipal> includes_any?(characters: String) returns true if the string includes any of the characters. Includes_all returns trues if the string includes all of the character, regardless of the order
<FromGitter> <Blacksmoke16> gotcha
<svipal> so, is there any way to add to the String class or am I stuck with making them some module's functions ?
<FromGitter> <Blacksmoke16> ```class String ⏎ def includes_any? ⏎ ... ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ef246aa47fdfd21eddefc25]
<FromGitter> <Blacksmoke16> ?
<svipal> same problem I have, it doesn't add to the String class it makes a new String class
<FromGitter> <Blacksmoke16> right, thats not the same as what i have
<FromGitter> <Blacksmoke16> you're defining your own `String` class within your namespace, not adding it to the stdlib's type
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9bdi
<svipal> so you have to do that *outside* of a module !
<FromGitter> <Blacksmoke16> right, because the original class wasn't defined in a module
<svipal> right, I come from Haskell so it feels super weird for me to do anything outside of modules lol
<svipal> ok
<svipal> thanks a lot !
<FromGitter> <Blacksmoke16> yea if something isnt in a module, its said to be on the top level
<FromGitter> <Blacksmoke16> which is technically a namespace as well
<svipal> so there is no way to access the top level classes from within a module ?
<svipal> you can't do something like class ::String
<FromGitter> <wyhaines> @Blacksmoke16 Hey, do you know offhand of any sites that are using ANY Crystal webish stuff behind the scenes? Kemal, Lucky, Athena, Amber, whatever? Athena is your baby, right? ⏎ ⏎ I'm using Crystal in a side-project-that-has-mutated-to-a-core-feature-of-a-big-project for my employer, and while it's hella too late to not use Crystal, I'm being asked questions about it's usability for developing things
<FromGitter> ... that we've often done with Rails, and so we want to basically just be able to point to some existing sites somewhere in the world and say that they are using Crystal behind the scenes. Know of anything?
<FromGitter> <Blacksmoke16> svipal: https://play.crystal-lang.org/#/r/9bdk `::` prefix on a type tells it to do that
<svipal> awesome.
<svipal> I should just have tried
<svipal> thanks again !
sagax has quit [Ping timeout: 256 seconds]
sagax has joined #crystal-lang
<mps> Blacksmoke16: sorry to annoy you, did you worked on yaml issue in specs for oq?
<FromGitter> <Blacksmoke16> @wyhaines maybe try out https://github.com/crystal-lang/crystal/wiki/Used-in-production
<FromGitter> <Blacksmoke16> are also some topics on forums about it i think too
<FromGitter> <Blacksmoke16> mps: I'll have a new version out prob tomorrow
<mps> ok, thanks
<FromGitter> <didactic-drunk> @wyhaines There was a page listing places where crystal is used but I don't remember where. It listed businesses from a variety of boring industries (finance, legal, etc).
<FromGitter> <Uzay-G> did anyone share this: https://ptimofeev.com/go-vs-crystal-perfomance/
<FromGitter> <Uzay-G> pretty cool
<FromGitter> <Uzay-G> crystal is popping up more and more on hn!
<oprypin> Uzay-G, yes people shared it several times and no it's not a good article
<FromGitter> <watzon> Yeah unfortunately lol
<FromGitter> <watzon> All of these benchmark articles kinda suck, but oh well. It's nice to get exposure.
<FromGitter> <RespiteSage> Are constants always included in the size of the executable even if they're never used?
<oprypin> RespiteSage, why dont u try and see
<oprypin> `FOO = "totally unique string"`
<oprypin> `grep 'totally unique string' my_binary`
<oprypin> RespiteSage, seems good :> https://carc.in/#/r/9beh vs https://carc.in/#/r/9beg
<FromGitter> <RespiteSage> Oh, nice. I was thinking that a workaround could be using methods (which would be inlined if used) instead of constants, but it's nice that it works with constants.
<FromGitter> <Uzay-G> > *<oprypin>* @Uzay-G, yes people shared it several times and no it's not a good article ⏎ ⏎ i agree the benchmark is pretty thin but the discussion on the hn thread is nice
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
<FromGitter> <j8r> too bad no swap for Hash
<FromGitter> <j8r> Some says Hash should not be used as ordered, but it is in fact
<FromGitter> <j8r> Better use it a such :)
<FromGitter> <asterite> oprypin: that was clever
<oprypin> :>
<FromGitter> <alexherbo2> has fork be removed?
<FromGitter> <alexherbo2> > Error: undefined variable or method 'fork' for top-level
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> well at least made internal
<FromGitter> <wyhaines> Sort of. It still exists as a nodoc `Process.fork`, but since it is unsafe for threaded programs, it's been removed from the public API.
<FromGitter> <alexherbo2> what is the equivalent?
<FromGitter> <Blacksmoke16> is there a reason to use it? `Process.run` spawns a new fiber anyway
<FromGitter> <Blacksmoke16> not exactly the same thing, but prob more thread safe
<FromGitter> <alexherbo2> I need to run a block async
<FromGitter> <alexherbo2> in the block, run a command, and when finished send a message
<FromGitter> <Blacksmoke16> process.run already does that tho
<FromGitter> <Blacksmoke16> starts a process in its own fiber and waits for it to complete
<FromGitter> <alexherbo2> Process.run is async?
<FromGitter> <Blacksmoke16> kinda, however waiting for it to complete would probably block
<FromGitter> <Blacksmoke16> its essentially the same thing as like ⏎ ⏎ ```process = Process.new ... ⏎ ⏎ process.wait``` [https://gitter.im/crystal-lang/crystal?at=5ef26c2fec4a341beee586d6]
<FromGitter> <alexherbo2> I don't get how to make it work async without fork
<FromGitter> <Blacksmoke16> did you try just removing `fork do` and see what happens?
<FromGitter> <alexherbo2> no
<FromGitter> <alexherbo2> I don't get how it can be non blockant with the response I'm waiting for to send
<FromGitter> <alexherbo2> the command has to be finished to get the status
<FromGitter> <Blacksmoke16> right, the process itself happens in a fiber, but i think it'll block until its done
<FromGitter> <Blacksmoke16> not super familiar with this stuff, but maybe you could have another fiber/channel
<FromGitter> <alexherbo2> how?
<FromGitter> <watzon> Should be done with the docs today... I hope https://github.com/watzon/marionette/tree/develop
<FromGitter> <Blacksmoke16> not 100% sure on exact, code but something like: ⏎ 1) Have a channel specific for the finished responses ⏎ 2) use `spawn do` versus `fork do` ⏎ 3) Instead of directly calling `send`, send the response to the channel ⏎ 4) then do something like `send channel.receive` [https://gitter.im/crystal-lang/crystal?at=5ef26facbb149531edc84ec9]
<FromGitter> <Blacksmoke16> id maybe wait for someone more familiar with it to give their thoughts :p
<FromGitter> <didactic-drunk> IO.pipe
<FromGitter> <Blacksmoke16> but im also curious of some of the code:
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef27014e0e5673398ce7615]
<FromGitter> <Blacksmoke16> isnt this the same as like `Request.from_json STDIN`?
<FromGitter> <Blacksmoke16> similarly ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Same as `response.to_json STDOUT`? [https://gitter.im/crystal-lang/crystal?at=5ef27115bb149531edc851e8]
<FromGitter> <alexherbo2> @Blacksmoke16 Chromium sends the length of the message, we read that, then we read the message on that length.
<FromGitter> <alexherbo2> same for sending
<FromGitter> <alexherbo2> we give the message length, then the message itself
<FromGitter> <didactic-drunk> I sent him this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef272cf47fdfd21eddf70bd]
<FromGitter> <didactic-drunk> It needs small ajustments to read the message format.
<FromGitter> <Blacksmoke16> ah gotcha, that makes sense
<FromGitter> <alexherbo2> @Blacksmoke16 `send channel.receive` will not work
<FromGitter> <Blacksmoke16> rip
<FromGitter> <alexherbo2> the command can be long
<FromGitter> <alexherbo2> such as playing mpv in youtube
<FromGitter> <alexherbo2> for it will block the main block
<FromGitter> <alexherbo2> and we cannot run other commands then
<FromGitter> <didactic-drunk> If you wanted to process a stream of messages instead of a return value: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef27462405be935cdbb43a8]
HumanGeek has joined #crystal-lang
<FromGitter> <watzon> Thank God Selenium has pretty nice docs
<FromGitter> <watzon> This is making writing my own so easy
Human_G33k has quit [Ping timeout: 258 seconds]
svipal has quit [Remote host closed the connection]
rocx has quit [Quit: 👏 developers 👏 developers 👏 developers 👏 developers 👏 developers]
mps has quit [Quit: Lost terminal]