jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.18.7 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
mounibec has joined #crystal-lang
matp has quit [Remote host closed the connection]
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Ping timeout: 244 seconds]
mounibec has quit [Quit: Textual IRC Client: www.textualapp.com]
Philpax has joined #crystal-lang
mkl0501 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
onethirtyfive has joined #crystal-lang
matp has joined #crystal-lang
Oliphaunte has joined #crystal-lang
<FromGitter> <kofno> https://carc.in/#/r/165z
<FromGitter> <drosehn> [from awhile ago] adam12: hmm. some time ago I implemented my own setproctitle() function for those OS's which didn't have one (and at the time, most OS's did not have one). It was kinda tricky to do it right. The thing is, I can't even remember what the project was where I wrote that.
<adam12> Heh
srabuini is now known as sebasr
<adam12> @drosehn: I think this is *kinda* there, for Linux anyways. But Darwin looks like it's going to be a pain so I abandoned. https://play.crystal-lang.org/#/r/1664
<FromGitter> <drosehn> portable-openssh has one in their compatibility libs, but I am not sure it covers all the cases I discovered when working on mine. But maybe it will give you some idea. https://github.com/openssh/openssh-portable/blob/master/openbsd-compat/setproctitle.c
Oliphaunte has quit [Remote host closed the connection]
Philpax has quit [Ping timeout: 250 seconds]
<FromGitter> <drosehn> I managed to find the version I wrote a long time ago. It kinda works on MacOS 10.10, but let me see if I can get it to work a bit better.
<FromGitter> <drosehn> Sorry. This seems to be some version before the one which was completely correct. Now that I realize what the bug is, I (vaguely) remembered hitting it before and fixing it. Too tired to figure it out right now.
<adam12> No worries.
the_drow has joined #crystal-lang
Philpax has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Ping timeout: 244 seconds]
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
the_drow has quit [Quit: This computer has gone to sleep]
<BlaXpirit> >> def f(*args, **kwargs); puts "f(#{args}, #{kwargs})"; end; f(5, a: "z")
<DeBot> BlaXpirit: f({5}, {a: "z"}) - more at https://carc.in/#/r/167d
<BlaXpirit> is there an easy way to reproduce something similar to the original code? to print `f(5, a: "z")`
<jhass> mmh, for args.join(", ") should be enough
<RX14> isnt there a method for that
<BlaXpirit> don't forget about the case where there is no args or no kwargs
<BlaXpirit> RX14, in macro hash there is argify i think
<RX14> yeah that one
<jhass> for kwargs ymmv, .to_s[1..-2] or .map {|k, v| "#{k}: #{v.inspect}" }.join(", ")
<RX14> argify's the one
<BlaXpirit> RX14, well I don't think I can use it?
<RX14> have you tried?
<BlaXpirit> I don't know how to try a macro method on a runtime value
<RX14> oh oops
<RX14> i thought it was a macro it's too early
<RX14> it not being a macro makes it a lot easier
<BlaXpirit> tuple.map is a tuple, namedtuple.map is an array :|
<jhass> guess because nobody specialized it yet
<BlaXpirit> anyhow, this is best i could do https://carc.in/#/r/167g
<jhass> doesn't look too terrible
<jhass> perhaps args.concat kwargs.map
<RX14> i wish there was a way to specialise map
<RX14> like
<RX14> generically
<RX14> Slice.map returns an array and that annoys me a lot of times
<jhass> not sure how that would look like
<RX14> yeah i don't think its possible while remaining efficient
<jhass> keep in mind all of these are still up for discussion
<jhass> if you think something should return something else, open a PR or issue
Philpax has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
Philpax has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Philpax has quit [Quit: Leaving]
matp has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 265 seconds]
mkl0501 has joined #crystal-lang
Philpax has joined #crystal-lang
Philpax has quit [Ping timeout: 258 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
sardaukar has joined #crystal-lang
RinkanaZ has joined #crystal-lang
sardaukar_ has joined #crystal-lang
Philpax has joined #crystal-lang
sardaukar_ has quit [Client Quit]
sardaukar has quit [Remote host closed the connection]
<RinkanaZ> Hey guys, i'm working on some HTTP::Client adjustments. And for that i want to add a new init property. However i do not like to pass all the parameters to get to the new one.
sardaukar has joined #crystal-lang
<jhass> well, can you find a sensible default value?
<RinkanaZ> Yeah, it can be empty
<RinkanaZ> But i'm more worried about the need to write the other parameters that would still retain the default values
<RinkanaZ> But then they are hard coded in the application.
ponga has joined #crystal-lang
<RinkanaZ> I was thinking of making a utility function that you can use to just set that variable.
<jhass> I'm not sure I quite follow what the problem is
<RinkanaZ> I was wondering if that is the recommended method or if i just use the parameter one
<jhass> Given the shortcut methods, (keyword) parameter passing is probably more ideal
<FromGitter> <sdogruyol> wow, 0.18.7 and master has 308 commits diff
<sardaukar> bodes well for the next release :D
sardaukar has left #crystal-lang ["Leaving"]
<FromGitter> <sdogruyol> indeed
sardaukar has joined #crystal-lang
<FromGitter> <sdogruyol> Still master doesnt have the MIME parser :/
<RinkanaZ> I have a WIP mime parser
<FromGitter> <sdogruyol> oh
<RinkanaZ> It works but the mime list is incomplete
<FromGitter> <sdogruyol> what i mean was https://github.com/crystal-lang/crystal/pull/2967 mime multipart parsing
<FromGitter> <sdogruyol> btw yours is also needed, good job :+1:
<RinkanaZ> Ah
<FromGitter> <sdogruyol> if you complete that mime list
<FromGitter> <sdogruyol> it'd be great and we dont have to rely on libmagic e.g
<RinkanaZ> True, but is quite some work to get useful mime header patterns
<FromGitter> <sdogruyol> yeah it takes time
<FromGitter> <sdogruyol> but as i see you already support pretty common types like JPG
<RinkanaZ> Yeah but the "official" mime list is huge
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> i need something like this for Kemal when sending files
<RinkanaZ> Yeah, thats why i built it in the first place :P
<FromGitter> <sdogruyol> haha
<FromGitter> <sdogruyol> great D
matp has joined #crystal-lang
<RinkanaZ> This might be an odd question but can i loop trough objects (by reference) untill a spesific function returns nil.
<RinkanaZ> The HTTP::Server has a build_middleware function that returns a single helper where all the other helpers are hidden in the .next
<RinkanaZ> And i want to append to that .next chain
<RX14> RinkanaZ, you want to add middleware while the application is running?
<jhass> .find &.foo.nil? ?
RinkanaZ has quit [Ping timeout: 250 seconds]
matp has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
matp has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
Philpax has quit [Ping timeout: 258 seconds]
onec has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
mkl0501 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
sardaukar has quit [Remote host closed the connection]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/v63q2
<crystal-gh> crystal/master 10ce3d1 Ary Borenszweig: Fixed #3102: incorrect `to_s` for `RegexLiteral`
<travis-ci> crystal-lang/crystal#10ce3d1 (master - Fixed #3102: incorrect `to_s` for `RegexLiteral`): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/150292448
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
onec has quit [Remote host closed the connection]
onec has joined #crystal-lang
onec has quit [Ping timeout: 258 seconds]
pawnbox has quit [Ping timeout: 264 seconds]
RinkanaZ has joined #crystal-lang
<RinkanaZ> What's up with this def:
<RinkanaZ> def self.new(uri : URI, tls = nil, handlers = [] of HTTP::Client::Handler)
<RinkanaZ> The compilier can not find "Client.new(URI.new)" any more
<RinkanaZ> It default to the initialize which expects an String.
pawnbox has joined #crystal-lang
<RinkanaZ> When i do Client.new(URI.new, nil, [] of HTTP::Client::Hander) it works as expected
<jeromegn> is there no way to have an initializer in an abstract struct? https://play.crystal-lang.org/#/r/16an
<jeromegn> oh crap, nevermind that
pawnbox has quit [Ping timeout: 260 seconds]
<jeromegn> the JSON mapping seems to break that functionality
pawnbox has joined #crystal-lang
<RinkanaZ> Without the macro it works
<FromGitter> <fridgerator> how can I delcare a property in a class of an array type? ⏎ `property? things : [] of Thing` is throwing an error
<FromGitter> <sdogruyol> things : Array(Thing)
<FromGitter> <sdogruyol> should work
<FromGitter> <fridgerator> ah, thanks
<FromGitter> <fridgerator> right, becuase i’m not instantiating a new array
<FromGitter> <fridgerator> got it
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> you're just annotating the type :)
<FromGitter> <Rinkana> Serdar, do you know why this is wrong? : ⏎ ```def self.new(uri : URI, tls = nil, handlers = [] of HTTP::Client::Handler)``` [https://gitter.im/crystal-lang/crystal?at=57a62555483751d50f2f03fd]
<FromGitter> <Rinkana> When i do ```Client.new(URI.new)``` it goes to the wrong init
<FromGitter> <sdogruyol> what's your `initialize` like?
<FromGitter> <Rinkana> ```def initialize(@host, port = nil, tls : Bool | OpenSSL::SSL::Context::Client = false, handlers = [] of Handler)```
<FromGitter> <Rinkana> And it defaults to this initialize function with the error saying that the first param needs to be a string and not an URI object
<FromGitter> <sdogruyol> it's definitely not calling `self.new`
<FromGitter> <sdogruyol> how do you call it?
<FromGitter> <Rinkana> ```typeof(Client.new(URI.new))``` in a spec
<FromGitter> <Rinkana> But ```typeof(Client.new(URI.new, nil, [] of HTTP::Client::Handler))``` works
<FromGitter> <sdogruyol> that matches the signature of self.new so it's normal
<FromGitter> <Rinkana> Yeah but what's odd is is that just with only an URI it does not work
<FromGitter> <sdogruyol> in your case it doesnt understand if you're passing an URI or a String when calling the method with just 1 param
<FromGitter> <sdogruyol> why don't you initialize @host like the others?
<FromGitter> <sdogruyol> i mean by default
pawnbox has quit [Ping timeout: 258 seconds]
<FromGitter> <Rinkana> This is currently in the code. I only added the ```headers = [] of Header``` part and then it does not work anymore
pawnbox has joined #crystal-lang
<FromGitter> <Rinkana> Hmm even ```Client.new(URI.new, headers: [] of Header)``` gives an error. Only when i add the tls option it finds the correct new function.
<jeromegn> RinkanaZ: yea the macro is what breaks it.
fedruantine has quit [Quit: client exited: Ex-Chat]
<BlaXpirit> if I have MyClass that defines to_unsafe, what's a nice way to convert MyClass? to MyClass* ?
<BlaXpirit> or Void* even
<BlaXpirit> a ? a.to_unsafe : Pointer(Void).null is the best i can come up with
fedruantine has joined #crystal-lang
<FromGitter> <Rinkana> Serdar, it seems that it has to do something with the specs itself. When i try it from the playground it works as intended.
<FromGitter> <Rinkana> This is odd. Is there some caching going one?
<FromGitter> <sdogruyol> uhm, not sure about spec but you can delete .crystal folder either in your project or home folder
<FromGitter> <Rinkana> Oh huh, my bad. I wrote crystal play in the terminal. And ofc that works as that is the source...
<FromGitter> <Rinkana> Argh, this is killing me ```Client.new(uri: URI.new)``` works too
<FromGitter> <sdogruyol> that's weird
<FromGitter> <Rinkana> Fml with this initialize function it works too ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=57a62fb22f03cf8749ccaca3]
<FromGitter> <Rinkana> Well then, we keep it like this...
onethirtyfive has joined #crystal-lang
Oliphaunte has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
onethirtyfive has joined #crystal-lang
RinkanaZ has quit [Ping timeout: 250 seconds]
onethirtyfive has quit [Remote host closed the connection]
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
pawnbox has joined #crystal-lang
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
jnylen_ has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
pawnbox has quit [Ping timeout: 258 seconds]
jnylen has quit [Ping timeout: 250 seconds]
jnylen_ is now known as jnylen
pawnbox has joined #crystal-lang
Oliphaunte has joined #crystal-lang
mroth_ has joined #crystal-lang
mroth has quit [Ping timeout: 244 seconds]
mroth_ is now known as mroth
kfpratt has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
_kfpratt has quit [Ping timeout: 258 seconds]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
onec has joined #crystal-lang
matp has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
onec has quit [Client Quit]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
matp has joined #crystal-lang
<jeromegn> how would you parse this timestamp, into a crystal Time instance? 1470515596.17639
<jeromegn> without loosing any precision
<jeromegn> > Time.parse("1470515596.17639", "%s.%L").epoch_ms
<jhass> do you have it as a string or Float?
<jeromegn> Float
<jeromegn> but I can convert it
<jeromegn> my thinking is to remove that dot and remove the last two digits, transform to Int and do Time.epoch_ms
<jhass> I thought you want to keep precision?
<jeromegn> ideally
<jeromegn> but I’m not sure that’s possible
<jeromegn> uhu, that redirects to https://carc.in/#/cr for me
<jhass> hrm
<jhass> and there the dropdown doesn't load?
<jeromegn> it does
<jeromegn> load
<jhass> mh
<jhass> can you try again
<jeromegn> redirect to #/crystal and then #/cr
<jeromegn> *redirects
<jhass> what do you get at https://carc.in/runs/16cu ?
<jeromegn> json :)
<jhass> weird
<jhass> it does the redirect when fetching that fails
<jeromegn> odd
<jhass> anyway Time.new(Time::UnixEpoch + (1470515596.17639 * Time::Span::TicksPerSecond).to_i64, Time::Kind::Utc)
<jeromegn> nce
<jhass> I think that's still within Time's precision, (Int64)
<jeromegn> Yes
<jeromegn> thanks jhass
<BlaXpirit> jhass, that was a typo https://carc.in/#/r/16ct e
<jhass> uh
<jhass> okay, no idea where the e came from
<jhass> :)
<jeromegn> I guess that doesn’t work anymore :) https://play.crystal-lang.org/#/r/16cw as per http://devdocs.io/crystal/api/0.18.7/enum#parse(string):self-class-method
<jhass> it's case sensitive https://play.crystal-lang.org/#/r/16cx
<jhass> the example is misleading I guess
<jeromegn> yes, easy to work around, that’s fine
<jeromegn> “blue” works too
<jeromegn> because it’s camelcased first
<jeromegn> maybe a .downcase.camelcase could be better
<jhass> perhaps
<jhass> but then enum Foo; Blue; BLUE; end is technically valid
<jeromegn> indeed
<jeromegn> I can’t override the from_json like this? https://play.crystal-lang.org/#/r/16d0
Oliphaunte has joined #crystal-lang
<jhass> from_json receives the string, not the pull parser
Oliphaunte has quit [Read error: Connection reset by peer]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
<jeromegn> Deep
<jeromegn> *derp
pawnbox has quit [Remote host closed the connection]
matp has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Oliphaunte has quit [Remote host closed the connection]
matp has joined #crystal-lang
pawnbox has joined #crystal-lang