RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.26.1 | 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
DTZUZO has quit [Ping timeout: 244 seconds]
DTZUZO has joined #crystal-lang
moei has joined #crystal-lang
<FromGitter> <girng> look at this nasty issue: https://github.com/godotengine/godot/issues/9913 maybe i should use crsfml?
<FromGitter> <girng> if i use crsfml, it binds crystal lang to SFML does that mean i can use any sfml extension as well?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
jhass has quit [Ping timeout: 260 seconds]
jhass has joined #crystal-lang
<FromGitter> <Timbus> Hm, wouldn't it be better if `File.open` took the access modes as enums, for type safety? Also things like start position, and the 'binary' mode, couldn't they be named args?
<woodruffw> @Timbus: IIRC there was some movement on unifying (or otherwise relating) symbols and enums that would make that a lot nicer, but as it is enums would probably make using `File.open` pretty tedious
<FromGitter> <Timbus> I thought symbols now resolved to enums
<FromGitter> <Timbus> in some cases
<woodruffw> oh, did that change go through?
<woodruffw> ah, 0.25 added support for enum literal symbols
<woodruffw> i'd be a big fan of making `File.open`
<FromGitter> <Timbus> All thats left is to turn symbols into frozen strings and the celebration can begin
<woodruffw> *'s arguments more type-safe
<FromGitter> <Timbus> Yeah the mode-string stuff just feels a bit old
<woodruffw> agree completely...one possible issue is representing multiple flags; something like `File.open "foo", :read | :write` would be really pretty, but probably also new syntax
asterite has quit [Ping timeout: 264 seconds]
jhass has quit [Ping timeout: 252 seconds]
asterite has joined #crystal-lang
jhass has joined #crystal-lang
<FromGitter> <Timbus> Yeah, it looks nice but I guess :r, :w and :rw are understandable and terse enough.
<woodruffw> yeah, i was looking at the PR that added symbol -> enum support and it'd probably be a real pain
v2px__ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
DTZUZO has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <j8r> I think this can Enum, and use it directly as an argument. This will bring compile time checking
Groogy1 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <drum445> Hi Guys, how do you all go about making HTTP requests, is there something similar to the requests lib that Python has?
<FromGitter> <drum445> Seen HTTP::Client but does that allow you to send files over http?
rohitpaulk has joined #crystal-lang
<FromGitter> <gdotdesign> There is crest https://github.com/mamantoha/crest which might be a good fit :)
<FromGitter> <drum445> That does look close, thanks for the suggestion
<FromGitter> <j8r> Send files over http? I think you can do already with the stdlib's HTTP::Client
<FromGitter> <drum445> ooh exciting, any docs?
<FromGitter> <j8r> hum, why simply do a File.read, and send the data over http?
<FromGitter> <j8r> If you want a protocol specially made for, maybe FTP (File Transfer Protocol) is what you are searching
<FromGitter> <j8r> there is no wrapper yet, but quite easy to do https://stackoverflow.com/questions/8659808/how-does-http-file-upload-work#8660740
zorp_ has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
v2px__ has quit [Ping timeout: 244 seconds]
<FromGitter> <girng> i love crystal!
rohitpaulk has joined #crystal-lang
<FromGitter> <f1refly_gitlab> Yeah me too :)
<FromGitter> <girng> :)
ashirase has quit [Ping timeout: 244 seconds]
ashirase has joined #crystal-lang
thews has quit [Ping timeout: 240 seconds]
<FromGitter> <drum445> 'tis great
thews has joined #crystal-lang
<FromGitter> <girng> love u all
<FromGitter> <girng> great community
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <drum445> @asterite makes some good points in that reddit post though about the problems the language faces
<FromGitter> <codenoid> something weird happend
<FromGitter> <codenoid> when i use `crystal-community/icr` , `Time.now # is my local time`,
<FromGitter> <codenoid> but when i use my app, 0.26.1, the time is UTC
<FromGitter> <codenoid> ugh
<FromGitter> <codenoid> it's same 0.26.1
<FromGitter> <codenoid> weirddd
<FromGitter> <codenoid> oh lol
<FromGitter> <codenoid> Time.now.to_s # my local time
<FromGitter> <codenoid> or in Mongo, a datetime will converted to UTC ?, idk
<FromGitter> <drum445> yeah I have the same issue with MySQL
<FromGitter> <drum445> the recent time changes made things a bit odd
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <straight-shoota> What's odd? @drum445
<FromGitter> <drum445> So in MySQL I insert a date using NOW()
<FromGitter> <drum445> When I read it from Crystal the timezone is wrong and can't be set
<FromGitter> <drum445> As when I convert it to BST it adds an Hour, which makes it the wrong time
<FromGitter> <codenoid> hmm 😕 same case
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <straight-shoota> Sorry, I don't follow
<FromGitter> <straight-shoota> How are you converting a MySQL datetime value to Crystal `Time` instance?
<FromGitter> <straight-shoota> Can you show some code?
<FromGitter> <codenoid> sorry for interruption, in `kalinon/mongo.cr` / Mongo ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b8fc633f5402f32aadf87c8]
shalmezad has joined #crystal-lang
<FromGitter> <drum445> The crystal-db shard
<FromGitter> <drum445> rs.Read(Time)
<FromGitter> <straight-shoota> This seem like an issue with the db data type mapping
<FromGitter> <straight-shoota> Are you using a DATETIME or TIMESTAMP column?
<FromGitter> <drum445> I'm not using db mapping, it is simply rs.read after doing a select from MySQL
<FromGitter> <drum445> I've posted the issue on the mysql github driver and the chap agrees it is an issue and the param needs to be overridable
DTZUZO has joined #crystal-lang
<FromGitter> <straight-shoota> `rs.read` maps MySQL data types to Crystal data types
<FromGitter> <straight-shoota> Can you send a link to that issue?
<FromGitter> <drum445> Was just a comment on a commit, unsure how to find it lol
<FromGitter> <drum445> But you're right re.read mapped it to a Time data type
<FromGitter> <drum445> Which defaults to utc if no timezone supplied
<FromGitter> <drum445> So my problem was I wanted to compare this to a BST time, so when I converted the time from the DB to BST it added an hour.
<FromGitter> <straight-shoota> Changing the location while preserving the local time representation is actually proposed in #6572
<FromGitter> <straight-shoota> But the real problem here is probably that you're using MySQL's time data types incorrectly
<FromGitter> <straight-shoota> MySQL doesn't keep track of time zone offsets, it just interprets every DATETIME value in the local time zone
<FromGitter> <trashhalo> Are there any good embedded keyval stores in crystal like golang has badger https://github.com/dgraph-io/badger ?
<FromGitter> <fridgerator> I've never used any, but there are some : https://crystalshards.org/?filter=key-value
<FromGitter> <j8r> you can use bindings for RocksDB or LevelDB @trashhalo
<FromGitter> <trashhalo> bojack ? ⏎ 🐴 The unreliable key-value store
<FromGitter> <trashhalo> lol
<FromGitter> <trashhalo> thanks for the link. will look around
<FromGitter> <trashhalo> oh yea thats a good idea. im weary of c bindings from all my time with go. but ive heard crystal its different
<FromGitter> <j8r> yeah bindings are pretty painless, just require the shard and have the `-dev` library and you're done. I think you best bet here is to go with RocksDB
<FromGitter> <trashhalo> good feedback. thank you
<FromGitter> <j8r> you're welcome @trashhalo , thanks for the Go link :) I've recently cgo to static link TiDB - I've to set `LDFLAGS='-linkmode external -extldflags "-static"'`
<FromGitter> <j8r> and there is no ffi overhead for when including C on a Crystal project (unlike Go) :D
<FromGitter> <trashhalo> really? thats pretty baller
<FromGitter> <trashhalo> I really like crystal. I switched from ruby to node and go professionally. I didnt even realize I missed ruby syntax.
<FromGitter> <trashhalo> just wish the release compile times were faster. go is wicked fast compilation but of course zero magic
shalmezad has quit [Quit: This computer has gone to sleep]
<FromGitter> <bajro17> I need help I try use each on json any type and it give me error Error in test.cr:9: undefined method 'each' for JSON::Any
wontruefree has joined #crystal-lang
<FromGitter> <trashhalo> @bajro17 I had that problem too. I solved it by calling .as_a first. example https://github.com/trashhalo/microservice-comparison/blob/master/crystal/microservice.cr#L8
<FromGitter> <trashhalo> Im not sure if thats the right way to do it
DTZUZO has quit [Ping timeout: 272 seconds]
<wontruefree> so the crystal docs tool generates an html file but is there any way to get more or an `ri` type doc?
<wontruefree> I was looking to not have a web browser when using docs
<wontruefree> I am not sure if this is something someone else has already worked on
<z64> wontruefree: not that i've seen. there is docs/index.json that is generated that you would have to parse. what i usually do is just grep lib/ inside my editor and just read them in the source code
<f1refly> I plan on building a simple xmpp library for practice purposes. Is there a way i could use the OpenSSL module from the standard library to get starttls?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
<wontruefree> z64: yeah I might build something. I have not looked through the json yet but that seems like a good place to start for a tool like that
<wontruefree> it would be nice to be able to display the doc in an editor
<wontruefree> at least the interface to the method
<wontruefree> does anyone know of a plugin that does that?
<FromGitter> <vladfaust> Hey @girng, you have GoDot avatar and writing in Crystal - are these things related? ;)
ua_ has quit [Ping timeout: 252 seconds]
<oprypin> vladfaust, he's making them related, trying to use godot with a server in crystal
<FromGitter> <vladfaust> Awesome. What's the progress?
<FromGitter> <vladfaust> Ah, I thought writing game code in Crystal
<FromGitter> <vladfaust> One day it would be possible
<oprypin> what do u mean lol
<oprypin> you can even write games for Windows in Crystal
<FromGitter> <vladfaust> GoDot supports multiple scripting languages IIRC. Crystal could be one of them
<oprypin> it's not scripting tho
<FromGitter> <vladfaust> It doesn't matter, you understand what I'm saying
<oprypin> although at this point this word doesn't even mean anything
ua has joined #crystal-lang
shalmezad has joined #crystal-lang
Groogy1 has quit [Ping timeout: 272 seconds]
<FromGitter> <xababafr> Hi there. Is it okay to ask for help on the language here?
<FromGitter> <j8r> I can't help you on that question @xababafr . I'm Kinding 😄 You're very welcome, ask anything about Crystal
<FromGitter> <xababafr> I'm looking for a way to create a class that can contain a data of any type. I'm using a Generic : "MyContainer(T)" which contains a property data, with the same type T. but since at the initialization the data will be nil (the object is filled later), I used the notation "property : data : T?". My question is : at the instanciation, a MyContainer(Nil) class will be created, since my data object is nil,
<FromGitter> ... right? Then, if I write some data, lets say a Int32 into my container, will I get a MyContainer(Int32) ? ⏎ ⏎ I hope I'm clear... :(
<FromGitter> <xababafr> thanks a lot for the welcome anyway :)
<oprypin> xababafr, no, that is not correct. youre using `T` in a context with `T | Nil` but that doesn't affect T itself, it will still always be Int32
<FromGitter> <xababafr> Wow, that's nice! thanks a lot! SImplifies what i'm trying to do quite a lot :)
<FromGitter> <j8r> The type of its instance variable will be `T | Nil`
<FromGitter> <j8r> Nils can be ennoying sometimes, depensing on your use case you might like to set a default value like `property data : Int32 = 0` for example
<FromGitter> <xababafr> Well.. So, im creating a channel class : you instanciate the channel between two entities, and then, when you want to send data, I want my channel to be typed with the same type as the Data. But I mean, even the data itself is typed as T | Nil , it's not a big deal. I can just cast it to T with a if nil? right?
<oprypin> right
<oprypin> but prefer `if x` over `unless x.nil?`
<wontruefree> +1
<FromGitter> <xababafr> perfect ! thanks for you help !
<wontruefree> unless is great to have in a language but in general if is more clear when I am reading code
<FromGitter> <girng> @vladfaust lol oprypin saying the word "trying". i already have a 100% functional bidirectional server code (crystal lang) that works flawlessly with godot's client side tcp. it works great too, godot's tcp api works great with crystal's tcp!
<FromGitter> <girng> i just had issues with the tcp_nodelay stuff that what causing my response time to be greater than normal. however, once u disable that for client and server, it's fine
<FromGitter> <vladfaust> That's great
<FromGitter> <vladfaust> However, writing a crystal server is a trivial taks
<FromGitter> <vladfaust> I hope one day I could write a game on a mature engine using Crystal
<FromGitter> <girng> yeah, i just have a lot of free time.. i like to spend it on crystal instead of going outside in the real world (partying, drugs, etc)
<FromGitter> <girng> yeah,i was looking into crsfml but i might choose it for a new project, too invested in my current one in godot
<FromGitter> <vladfaust> You could start implementing Crystal bindings for GoDot. Set up a Patreon or BountySource and when Crystal got released, you'll begin reaping a bounty from game devs
<FromGitter> <girng> the thing that i like about crystal's tcp as a server, as making "messaging" out of a stream is far more simple, and more streamlined if you will. for example, gets/puts will use the delimiter `\n`, or, you can just do `socket.read_bytes(Int32)`. basically turns the stream into messages (previously i was using a websocket server, and it was far more easier for message parsing, however i heard there is a tiny bit
<FromGitter> ... of added latency)
<FromGitter> <vladfaust> I'm thinking of why there's no system to collect donations and automatically resend a part to selected projects? E.g. if I collected donations for my OSS project on Crystal, sending a % to Crystal devs automatically. Or maybe Webpack devs could earn on every donation to a project which is using webpack?
<FromGitter> <girng> yeah, am not sure. gdscript language they have is soo popular not sure it would be worth it lol. iuno how to do bindings and stuff, i'm a newb :D
<FromGitter> <xababafr> @oprypin one last thing! when I define my data ( = my fifo) : "getter capacity : Int32, fifo : Array(T)?", shoukd I declare its type as Array(T) or Array of T ?
AndreasLutro has left #crystal-lang [#crystal-lang]
<FromGitter> <bew> Array(T)
<FromGitter> <vladfaust> Why is everyone so afraid of the money topic? Are we all robots without needs or all have rich daddies allowing us to do 24/7 what we like? What's bad on earning on what you love?
<FromGitter> <girng> i don';t know if bounty hunters supports sending a percent to another project
<FromGitter> <girng> bountysource*
<FromGitter> <j8r> Talking about money, how goes the creation of the Open Collective Crystal account?
wontruefree has quit [Quit: bye]
OvermindDL1 has joined #crystal-lang
wontruefree has joined #crystal-lang
shalmezad has quit [Quit: Leaving]
zorp_ has quit [Ping timeout: 245 seconds]
<FromGitter> <girng> man. i just exported my items table in mysql to csv instead of json... csv uses so much less data
<FromGitter> <girng> no redundant keys!!
<FromGitter> <straight-shoota> what??
hightower2 has quit [Ping timeout: 252 seconds]
hightower2 has joined #crystal-lang
<FromGitter> <bajro17> I try to benchmark this json from this repo https://github.com/kostya/benchmarks
<FromGitter> <bajro17> for me go be faster then crystal :(
<FromGitter> <j8r> With --release?
<FromGitter> <bajro17> Thank you
<FromGitter> <bajro17> I forgot it
<FromGitter> <bajro17> <3
<FromGitter> <bajro17> If there is any award for best group on internet this group really deserve it
wontruefree has quit [Quit: bye]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Excess Flood]
zorp_ has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 246 seconds]