RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.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
<jokke2> isnt't ctrl + c sigint?
Liothen has joined #crystal-lang
<FromGitter> <pitosalas> Anyone want to tell me their favorite vscode adding for Crystal?
<FromGitter> <proyb6> This is ultimate guide on TLS
<FromGitter> <proyb6> https://tls.ulfheim.net/
<FromGitter> <proyb6> Every byte of a TLS connection explained and reproduced.
jemc_ has joined #crystal-lang
johndescs has quit [Ping timeout: 246 seconds]
johndescs has joined #crystal-lang
<FromGitter> <v9n> anyone know how I can run a script? and capture its stdout/stdout during script running. ⏎ ⏎ I'm doing this: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5bf36a134bad337eb90812e0]
non-aristotelian has quit [Quit: non-aristotelian]
blove has quit [Quit: WeeChat 2.3]
rohitpaulk has joined #crystal-lang
jemc_ has quit [Ping timeout: 252 seconds]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Ping timeout: 264 seconds]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Ping timeout: 250 seconds]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Ping timeout: 264 seconds]
rohitpaulk has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter> <wontruefree> not sure if this will help but I like https://github.com/Val/crun
_whitelogger has joined #crystal-lang
<FromGitter> <j8r> @v9n instead of IO::Memory you can set any IO output. Not tested, but you could define a websocket to send into the browser.
rohitpaulk has joined #crystal-lang
jokke2 is now known as jokke
jokke1 has quit [Disconnected by services]
jokke1 has joined #crystal-lang
jokke1 has quit [Client Quit]
ashirase has quit [Ping timeout: 240 seconds]
ashirase has joined #crystal-lang
marmotini_ has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <hello2dj> how to represent any value's type in crystal? we can use Reflect.Type in go? which can i use in crystal?
<FromGitter> <j8r> @hello2dj why do you need this?
<FromGitter> <hello2dj> i want to write a rpc demo by copying from a golang libray
<FromGitter> <hello2dj> it's requestMsg has a value field and a value type field
<FromGitter> <hello2dj> i just want to copy it, i am a newbie....
<FromGitter> <j8r> it can't be really any type, you can use an union of types it can have
<FromGitter> <j8r> for example it can't be `Pointer`, or `NoReturn` or `IO`
<FromGitter> <hello2dj> o thank you, but Struct also can't be reflected even though i use Union
<FromGitter> <j8r> If you want to build a container, because you have a dynamic mapping, you can look at `JSON::Any` https://github.com/crystal-lang/crystal/blob/master/src/json/any.cr#L18
<FromGitter> <hello2dj> cause Struct is abstract class
<FromGitter> <hello2dj> yeah i see it already
<FromGitter> <hello2dj> if i want to lookup if a value is_a? Struct, it will be a problem, cause i can't define a Union to contains all Strcut type
<FromGitter> <hello2dj> Union(Nil | Bool | Char | Number | Symbol | Pointer | Tuple | StaticArray | Reference)
<FromGitter> <j8r> You RPC lib, what types it support?
<FromGitter> <hello2dj> but 'struct Mem ... end can't not
<FromGitter> <rishavs> Need some help with the db api returning composite types. For example, my query uses a json_object_agg function. ⏎ My expected result for this is an array returning Array of json objects. How do I map it to a return type? ⏎ This is what I am trying to do; ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bf3ea5f4f4bb579f3a596c3]
<FromGitter> <hello2dj> o, it support Class and primitives
<FromGitter> <hello2dj> but i really want to know how to represent Struct now
<FromGitter> <j8r> can you show me a piece of code?
<FromGitter> <j8r> for code, please https://play.crystal-lang.org/#/cr
<FromGitter> <hello2dj> sorry
<FromGitter> <j8r> what's the Go library?
<FromGitter> <hello2dj> it's also my toy library
<FromGitter> <j8r> what's the wire protocol?
<FromGitter> <j8r> you pass the data as text?
<FromGitter> <j8r> sorry I try to understand Go - not experienced in it
<FromGitter> <hello2dj> i get it, there is no way to represent all type in crystal
<FromGitter> <hello2dj> thanks
<FromGitter> <j8r> nope
<FromGitter> <j8r> I try to understand how you rpc works in Go
<FromGitter> <hello2dj> ?
<FromGitter> <j8r> yes you can't represent all the types
<FromGitter> <rishavs> Sorry I might be comepletely wrong here, but can you have the go program send json and then parse it as a JSON:Any?
<FromGitter> <j8r> this usually means you want to do dynamic typing
<FromGitter> <hello2dj> o, thanks
<FromGitter> <j8r> @hello2dj you can also look at https://github.com/crystal-community/msgpack-crystal
<FromGitter> <hello2dj> ok
<FromGitter> <hello2dj> what's the 'as type' mean? @rishavs
<FromGitter> <hello2dj> what's the 'as type' mean? @rishavs
<FromGitter> <rishavs> I checked your comment. Sorry but I am completely off the base. I thought you wanted to send data from your go program to crystal and were having issues with the type mapping
ua has quit [Ping timeout: 244 seconds]
ua has joined #crystal-lang
marmotini has joined #crystal-lang
marmotini has quit [Remote host closed the connection]
marmotini has joined #crystal-lang
marmotini_ has quit [Ping timeout: 240 seconds]
marmotini has quit [Remote host closed the connection]
marmotini has joined #crystal-lang
<FromGitter> <rishavs> > Need some help with the db api returning composite types. For example, my query uses a json_object_agg function. ⏎ My expected result for this is an Array of json objects. How do I map it to a return type? ⏎ This is what I am trying to do; ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5bf3f483f9993b42673b7c79]
<FromGitter> <vladfaust> @rishavs finally use an ORM?
<FromGitter> <rishavs> T_T
rohitpaulk has quit [Ping timeout: 250 seconds]
<FromGitter> <j8r> @hello2dj `.as MyType`? This restricts the restriction
<FromGitter> <j8r> If the variable isn't of `MyType`, this will raise an exception. But usually it's better to use a custom type restriction with a if `var.is_a? MyType` to have a useful error
<FromGitter> <hello2dj> golang is simple, crystal ... harder
<FromGitter> <j8r> for me that's the contrary
<FromGitter> <j8r> matter of taste
<FromGitter> <j8r> golang spec may be simpler, but I find to be harder for the user to be DRY
<FromGitter> <hello2dj> yes, but the golang's reflect is good, interface is good...
<FromGitter> <hello2dj> yes
<FromGitter> <hello2dj> i have to learn more about crystal
marmotini has quit [Read error: Connection reset by peer]
marmotini_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <asterite> @Blacksmoke16 instance vars are known after the "finished" macro, because "finished" can add more instance vars
<FromGitter> <Blacksmoke16> gotcha, what was that in regards to?
<FromGitter> <bew> @asterite would be nice to have a hook that run after types are know, thus can only add methods (no new types)
<FromGitter> <ilanusse> Hey guys
<FromGitter> <ilanusse> I was wondering if you guys needed a Spanish translation for the docs
<jokke> god damn alpine... why don't they accept the pull request already
<jokke> ah ok
<jokke> seems they're waiting for 0.27.1
<FromGitter> <vladfaust> I'm trying to recreate an HTTP Server. I wonder why this code: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I've gone through the server code but could not find anything interesting. Maybe some kind of magic socket switches? ... [https://gitter.im/crystal-lang/crystal?at=5bf423adb86c70503f5eb97a]
<FromGitter> <kinxer> @ilanusse That sounds fantastic. You could create a pull request here (https://github.com/crystal-lang/crystal-book).
<FromGitter> <vladfaust> I took a lot from HTTP server: https://github.com/vladfaust/crack. The main performance issue (tracked with commented lines) is reading from the request IO. What did I do wrong?
jemc_ has joined #crystal-lang
<jemc_> in crystal, is it possible to run a Regex match starting at a particular byte offset in a String, without copying the bytes in the String?
<jemc_> (trying to prevent unnecessary allocations in my parser)
<FromGitter> <j8r> for parser often it's better to avoid regexes
<jemc_> yeah, that's what I'm using for non-Regex matching
<jemc_> I guess I'll just have to be less lazy and convert the rest of the Regex parts of my parser into proper PEG
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
marmotini_ has quit [Read error: Connection reset by peer]
marmotini_ has joined #crystal-lang
<FromGitter> <vladfaust> Why is this code is 2 times slower than similar HTTP Server even when it's not actually reading from a request and writing a static string? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bf42db21ad4155d3af50f2e]
<jokke> you _really_ like reinventing the wheel :D
marmotini_ has quit [Read error: Connection reset by peer]
marmotini_ has joined #crystal-lang
<FromGitter> <vladfaust> If speaking of TCPServer, it could be used outside of HTTP Server. And it's degraded performance would be confusing to a developer.
<FromGitter> <vladfaust> Also `reuse_port` doesn't have an effect 😕
<FromGitter> <vladfaust> Anyone?
<FromGitter> <bararchy> @j8r so, an idea, how about adding `Address.local` or `Interface.address ` to hardware?
<FromGitter> <bararchy> @vladfaust maybe because of peek
<FromGitter> <vladfaust> Nope, replacing `io.peek` with `request = HTTP::Request.from_io(io)` doesn't change the result
<FromGitter> <bararchy> @vladfaust what tcp settings are you using for sysctl.conf ? Maybe a few TCP tunning configs can speed it up
<FromGitter> <vladfaust> How is it related to HTTP Server being faster?
akaiiro has quit [Ping timeout: 272 seconds]
akaiiro has joined #crystal-lang
<FromGitter> <vladfaust> Oh, I got it. Single socket = single connection
<FromGitter> <v9n> @wontruefree thank you. Let me try `cryn` ⏎ @j8r Thank you. I think I get the idea, basicall y define some kind of object with same interface but instead of store data into some buffer it just pipe out to browser
<FromGitter> <v9n> let me try
<FromGitter> <j8r> @bararchy for networks addresses? Also, I'm thinking to replace the file parsing logic by directly do system C calls. But then, we'll need to gen/bundle bindings. Maybe use https://github.com/performancecopilot/pcp ,don't know. Then this will be a new project different to hardware
<FromGitter> <bararchy> @j8r yeha for network addresses, I just found my self in the need to programmable get the local address of the machine and its kinda sucky
<FromGitter> <j8r> there is `/sys/class/net/`. Yes there are lots of files after the symlinks :o
marmotini_ has quit [Ping timeout: 245 seconds]
notdaniel has joined #crystal-lang
notdaniel has quit [Client Quit]
pbodev1 has joined #crystal-lang
<jokke> crystal's markdown implementation doesn't support embedded html?
<jokke> this is the source: https://p.jokke.space/rBo8q/
<jokke> i'd be also happy if there's some other way to pass attributes to links
non-aristotelian has joined #crystal-lang
<jokke> hm looking over the parser it seems there's really no embedded html support
<FromGitter> <vladfaust> Yeah, I've done it: https://github.com/vladfaust/crack 😆 Many features are missing, i.e. cookies or WS, but it was fun!
<FromGitter> <j8r> @vladfaust i love the name :D
powerbit has joined #crystal-lang
<FromGitter> <vladfaust> Don't get hooked on it!
<FromGitter> <7sedam7> Hello guys
<FromGitter> <7sedam7> I have problem with making a simple get request with a custom headers
<FromGitter> <7sedam7> here is a snippet: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bf45efbed6bcf1ef83340ad]
<FromGitter> <7sedam7> same vars in ruby with Farady works normally: ⏎ `Faraday.new("#{BASE_URL}/#{API_VERSION}/items/get/list', headers: { "Cache-Control" => "no-cache", "X-Auth-Token" => API_TOKEN }).get`
<FromGitter> <Blacksmoke16> whats the error you get?
<FromGitter> <7sedam7> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bf4601aed6bcf1ef8334831]
<FromGitter> <Blacksmoke16> `:4443`
<FromGitter> <7sedam7> what about it
<FromGitter> <Blacksmoke16> nvm
<FromGitter> <bew> Maybe remove `https` from BASE_URL?
<FromGitter> <Blacksmoke16> thats it
<FromGitter> <7sedam7> how do i force https then?
<FromGitter> <7sedam7> because there is no http endpoint
<FromGitter> <Blacksmoke16> `HTTP::Client.new("#{BASE_URL}", PORT, tls: true)`
<FromGitter> <Blacksmoke16> which will use `https://`
<FromGitter> <7sedam7> 🙇
<FromGitter> <7sedam7> thank you :)
<FromGitter> <Blacksmoke16> np
jemc_ has quit [Ping timeout: 252 seconds]
<FromGitter> <bew> And please use `BASE_URL` not `"#{BASE_URL}`
<FromGitter> <bew> To avoid unnecessary memory alloc', string creation, etc..
<FromGitter> <7sedam7> yes, stayed from when i have put the whole url inside
<FromGitter> <7sedam7> thanks for the note :)
<FromGitter> <bew> Yw :)
jemc_ has joined #crystal-lang
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 264 seconds]
pbodev1 has left #crystal-lang ["Closing Window"]
powerbit has quit []
marmotini_ has joined #crystal-lang
notdaniel has joined #crystal-lang
powerbit has joined #crystal-lang
marmotini_ has quit [Ping timeout: 268 seconds]
powerbit has quit []
notdaniel has quit [Ping timeout: 260 seconds]
notdaniel has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
notdaniel has quit [Ping timeout: 245 seconds]
blove has joined #crystal-lang
<FromGitter> <iambudi> Any tips on how to properly add watch expression in vscode with native-debug extension?
<FromGitter> <iambudi> i’m using lldb-mi
jemc_ has quit [Ping timeout: 246 seconds]
baweaver is now known as lemur
lemur is now known as baweaver