asterite changed the topic of #crystal-lang to: #crystal-lang The Crystal programming language | http://crystal-lang.org | Crystal 0.6.1 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ - API: http://crystal-lang.org/api/ - Logs: http://irclog.whitequark.org/crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
ismaelga has quit [Remote host closed the connection]
<Dreamer3> what do i need to convert an enum uint8 back to a normal unit8 for type matching?
<Dreamer3> what do i need to convert an enum uint8 back to a normal unit8 for type matching?
<Dreamer3> in ./src/emulate/mem.cr:15: no overload matches 'Hash(UInt32, UInt8)#[]=' with types UInt32, Registers
<Dreamer3> in ./src/emulate/mem.cr:15: can't cast Registers to UInt8
<Dreamer3> so i'm not sure how to do it
bcardiff has quit [Quit: Leaving.]
<Dreamer3> so i'm not sure how to do it
<Dreamer3> ha
<Dreamer3> just add a to_u8 to the enum
<Dreamer3> so silly
<Dreamer3> so silly
strcmp1 has joined #crystal-lang
sfcgeorge has quit [Quit: Textual IRC Client: www.textualapp.com]
vikaton has joined #crystal-lang
<vikaton> we need some sort of playpen
Cidan is now known as zz_Cidan
shama has quit [Remote host closed the connection]
aemadrid has quit [Quit: Connection closed for inactivity]
zz_Cidan is now known as Cidan
Cidan is now known as zz_Cidan
waterlink1 has joined #crystal-lang
waterlink has quit [Ping timeout: 256 seconds]
asterite has joined #crystal-lang
<asterite> Dreamer3: there's Enum#value to get the underlying value
asterite has quit [Client Quit]
vikaton has quit []
vikaton has joined #crystal-lang
havenwood has joined #crystal-lang
zz_Cidan is now known as Cidan
willlll has quit [Quit: willlll]
waterlink1 has quit [Quit: Leaving.]
Cidan is now known as zz_Cidan
havenwood has quit []
waj has joined #crystal-lang
<Dreamer3> didn't work because not every other type of type used has a .value
<Dreamer3> adding .to_u8 to the enum worked though
HakanD has joined #crystal-lang
<Dreamer3> nice heroku changs
HakanD has quit [Ping timeout: 272 seconds]
DerisiveLogic has joined #crystal-lang
willlll has joined #crystal-lang
waj has quit [Quit: waj]
BlaXpirit has joined #crystal-lang
willlll has quit [Quit: willlll]
zz_Cidan is now known as Cidan
Cidan is now known as zz_Cidan
bcardiff has joined #crystal-lang
_whitelogger has joined #crystal-lang
vikaton has quit [Quit: Connection closed for inactivity]
willlll has joined #crystal-lang
willlll has quit [Quit: willlll]
willlll has joined #crystal-lang
willlll has quit [Client Quit]
BlaXpirit is now known as Guest27885
BlaXpirit_ has joined #crystal-lang
Guest27885 has quit [Killed (cameron.freenode.net (Nickname regained by services))]
BlaXpirit has quit [Quit: Quit Konversation]
DerisiveLogic has quit [Ping timeout: 240 seconds]
bcardiff has quit [Quit: Leaving.]
HakanD has joined #crystal-lang
havenwood has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
JBat has joined #crystal-lang
BlaXpirit has joined #crystal-lang
leafybasil has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
havenwood has quit [Ping timeout: 245 seconds]
sfcgeorge has joined #crystal-lang
ismaelga has joined #crystal-lang
<BlaXpirit> crystal build --link-flags '-L../../../repos/CSFML/lib -L../../../repos/SFML/lib' simple.cr
<BlaXpirit> /usr/bin/ld: warning: libsfml-window.so.2.3, needed by ../../../repos/CSFML/lib/libcsfml-window.so, not found (try using -rpath or -rpath-link)
<BlaXpirit> now what?
<BlaXpirit> copied all libs into current folder and LD_LIBRARY_PATH=. crystal build --link-flags "-L." simple.cr
<jhass> that seems double
<jhass> mh, try an absolute path for -L
<jhass> maybe the linker is executed in .crystal/foo/bar/baz/simple.cr
<BlaXpirit> i even tried LD_LIBRARY_PATH=../../../repos/CSFML/lib:../../../projects/repos/SFML/lib crystal build --link-flags "-L../../../repos/CSFML/lib -L../../../projects/repos/SFML/lib" simple.cr
<BlaXpirit> but it says /usr/bin/ld: warning: libsfml-window.so.2.3, needed by ../../../repos/CSFML/lib/libcsfml-window.so, not found (try using -rpath or -rpath-link)
<BlaXpirit> don't know where to put -rpath. and it doesn't work in --link-flags
<BlaXpirit> but whatever, this is fine. LD_LIBRARY_PATH=lib crystal run --link-flags "-Llib" simple.cr
vegai has left #crystal-lang [#crystal-lang]
JBat has quit [Quit: Computer has gone to sleep.]
<jhass> mh
<jhass> I'd still be curios if it works with LD_LIBRARY_PATH="$(realpath ../../../repos/CSFML/lib):$(realpath ../../../repos/SFML/lib)" or --link-flags "-L$(realpath ../../../repos/CSFML/lib) -L$(realpath ../../../repos/SFML/lib)"
<BlaXpirit> bet not
<BlaXpirit> hm it works
DerisiveLogic has joined #crystal-lang
<BlaXpirit> so I have Size_t = ifdef x86_64 UInt64 / UInt32
<BlaXpirit> how to convert to Size_t?
<BlaXpirit> should i make another function to convert?
<jhass> Size_t.cast(x)
<jhass> btw there's already LibC::SizeT
<BlaXpirit> riiight
<jhass> >> LibC::SizeT.cast(123).class
<DeBot> jhass: Sorry, that took too long.
<jhass> >> LibC::SizeT.cast(123).class
<DeBot> jhass: UInt32
<BlaXpirit> thanks
sardaukar has joined #crystal-lang
<sardaukar> hello
<sardaukar> anyone up?
<BlaXpirit> .
<jhass> sardaukar: hey
<sardaukar> hello!
<sardaukar> I'm trying to do a DSL
<sardaukar> how can I get a line like this to parse?
<sardaukar> get "/ab" => "ab#index"
<sardaukar> I get a token error on =>
<jhass> yes, you need explicit { } in crystal
<sardaukar> oh ok
<jhass> so get "/ab"/, to: "ab#index" might be nicer API :)
<jhass> er, sans the stray / there
<sardaukar> yeah, just curious about how it would work
<sardaukar> I got get({ "products/:id" => "products#show" }) to work
<sardaukar> doesnt without ()
<jhass> mh
<jhass> >> def foo(a); p a; end; foo {"a" => "b"}
<DeBot> jhass: Syntax error in eval:3: unexpected token: =>
<jhass> could be considered a bug I'd say
<sfcgeorge> Ruby has the same behavious
<sfcgeorge> It is treating the wiggly brackets as a block rather than a last hash parameter
<jhass> yeah, but it makes the {} optional
<sfcgeorge> Which is why Crystal's syntax should ideally do what Ruby does and allow the last parameter to be a hash without wiggly brackets
<jhass> asterite said recently it was a design decision not to, let me find it
<sfcgeorge> I would definitely be interested to see the reasoning. Cases like this make it seem like optional is nice. I ran across a similar case in my own app.
<sardaukar> so, to conclude: get "products/:id", { to: "products#show" } is the only way
<sardaukar> since the hash must be explicit, right?
<jhass> mh, can't find it
<jhass> sardaukar: no, you can make to a keyword arg, not a required one yet unfortunately
<sardaukar> ok
<jhass> >> def get(matcher, to=nil); p {matcher, to}; end; get "/ab", to: "a#b"
<DeBot> jhass: Syntax error in eval:3: unexpected token: }
<jhass> >> def get(matcher, to=nil); p({matcher, to}); end; get "/ab", to: "a#b"
<DeBot> jhass: {"/ab", "a#b"}
<sardaukar> so, I don't need to specify types here
<sardaukar> def get (regex : String, hash : {} of String -> String) ?
<jhass> that's a syntax error :P
<sardaukar> yes, trying to understand how hashes can be specified
<jhass> def get(regex, hash : String => String) would be one
<sardaukar> ok
<jhass> def get(regex, hash= {} String => String) optional hash param
<jhass> def get(regex, hash : Hash(String, String) String => String is just syntax sugar
<sardaukar> I don't get the hash= there
<sardaukar> why not hash : ?
<sardaukar> every other type def is something : type, right?
<sfcgeorge> = makes it an optional arg, setting the default to empty hash
<sfcgeorge> : is just specifying the required type with no default, so it's a required arg
<sardaukar> ah get it
<BlaXpirit> class Shape contains to_unsafe that returns CSFML::Shape
<BlaXpirit> class CustomShape < Shape
<BlaXpirit> everything worked well, then I made some seemingly unrelated changes
<BlaXpirit> now "tried to convert CustomShape to CSFML::Shape invoking to_unsafe, but can't deduce its type"
ismaelga has quit [Remote host closed the connection]
<jhass> meh, might be able to workaround by casting: def to_unsafe; @ptr as CSFM::Shape; end;
<jhass> but sounds like a type interference bug, just not easy to reduce I guess
<BlaXpirit> to_unsafe is in a module :s
<BlaXpirit> which I probably should've mentioned
<jhass> then maybe the "unrelated" changes made whatever to_unsafe returns there potentially another type?
<BlaXpirit> it must be something about SizeT
<jhass> but yeah, I ended up generating a to_unsafe for each class in my generated stuff https://github.com/jhass/crystal-gobject/blob/master/src/generated/notify/notification.cr#L6
<jhass> run into all kinds of type interference issues too
<jhass> *ran
<sardaukar> I'm building a "Rails-like" router
<sardaukar> and would like to store which action in a Controller to call
<sardaukar> how can I do that in Crystal?
<sardaukar> (other than having the actions being blocks)
<sardaukar> so, my routes are defined with get "/products/:id", { to: "products#show" } with creates a Route object with GET as @method, the path as @regex, products as @controllers, and show as @action
<sardaukar> how can I call the method on the controller programmatically?
<sardaukar> is it even possible?
<jhass> no it isn't
<jhass> I threw up a PoC for some other guy doing the same thing as you, but doesn't look like he uploaded anything to github yet, at least I can't find it
<jhass> let me see if I still have the concept
<sardaukar> thanks!
<sardaukar> I guess I could write a macro to just write out every possible route?
<sardaukar> like a huge switch statement
<jhass> sort of, but a bit smarter :)
<jhass> gotta clean up the spammer from my pastebin first though
HakanD has quit [Quit: Be back later ...]
<jhass> sardaukar: http://paste.mrzyx.de/p7ehafuct there it is
<jeromegn> haha, I was also working on something similar
<jeromegn> everybody wants to make a Rails-like thing for Crystal
sardaukar has quit [Ping timeout: 246 seconds]
HakanD has joined #crystal-lang
<jhass> SDL2 and Rails, yeah :P
<jeromegn> macros are hot
<jhass> somebody should do goworkers for crystal though
<jeromegn> background jobs?
<jeromegn> goworker or go-workers? :)
<jhass> eh, goworker
<jhass> oh, there are two of them?
<jeromegn> jhass: so, remember my segfault? I opened a ticket. It only happens when running the specs
<jhass> ah, resque vs sidekiq
JBat has joined #crystal-lang
<jeromegn> I think goworker would be simple
<jeromegn> I mean, it’s just a program waiting for on a Redis list
<jeromegn> *blocking
<jeromegn> dang, libbson is fast...
<jeromegn> 100K BSON objects in 0.1s
<jeromegn> 100K BSON objects to json is 0.2s
sardaukar has joined #crystal-lang
<sardaukar> jhass: thanks again! (dropped out for a sec there)
<sardaukar> yes
<sardaukar> this is awesome
<sardaukar> are there any docs on macros?
<sardaukar> (and btw, the topic's API link is dead)
<jeromegn> works for me
<jhass> yeah, me too
<jhass> check your client doesn't do anything funky
<jhass> like including the -
<sardaukar> firefox shows the href as http://crystal-lang.org/api/%C2%A0-
<sardaukar> yeah, that's what the text says :)
<jhass> asterite set it, guess OS X was "smart" again and inserted some weird space
ismaelga has joined #crystal-lang
<jeromegn> I’m on OS X and clicked it, all good!
<jeromegn> maybe the IRC client
<jhass> %C2%A0 is not a regular space
<jhass> %20 is
<jeromegn> yea
<sardaukar> what's with .id on arrays? like {% for method in %w(get post put delete patch) %} needing method.id ?
<sardaukar> jeromegn: I'm on the webclient
<sardaukar> (might be that)
<jhass> weechat does it too, it's in the topic
<jhass> it's not a proper space there
<jhass> sardaukar: so, %w(get post delete patch) is an ArrayLiteral consisting of StringLiterals, so you iterate through the StringLiteral
<jhass> if you don't want to insert the StringLiteral but only its body (or whatever the correct term is), you need .id
<sardaukar> is that gonna stick around?
<sardaukar> :)
<jhass> pretty sure it is
<sardaukar> not very cool
<sardaukar> but I understand the parser must be appeased
<jhass> huh?
<sardaukar> it violates the principle of least surprise - is that a thing over here? :D
<jhass> inserting the string literal is a valid usecase
<sardaukar> yeah, I guess
<jhass> you iterate over a bunch of string literals, the compiler magically turning them into MacroIds would surprise me
<sardaukar> the surprise is that they just look like normal strings (right?)
<sardaukar> and calling .id on a string is offputting
<sardaukar> but knowing about them being literals clears things up
<jhass> yeah, everything in the macro language is AST nodes
<sardaukar> so I can't use %w(...) outside of a macro?
<sardaukar> (also - .id being text and not an integer is also weird, maybe just me)
<jhass> well, every "value"
<sardaukar> oh ok
<jhass> so you can for example write a macro that gets a method definition passed as parameter
<jhass> then the parameter is the AST node of type Def (iirc)
<sardaukar> I see
waj has joined #crystal-lang
<sardaukar> wish the docs were more comprehensive :/
<sardaukar> for example, what does the ampersand in def matcher(method, path, &route : Request, Hash(String, String) -> String) mean?
<jhass> and with the macro you build a string that's fed back into the compiler, so it's sort of a template language operating with AST nodes
<jhass> that's converting a passed block into a Proc
<sardaukar> but it applies to route and the hash, right?
<sardaukar> so, it's like "proc from here on" ?
<jhass> >> def foo(&block : -> String); {block.class, block.call}; end; foo { "a" }
<DeBot> jhass: {( -> String), "a"}
<jhass> Request, Hash(String, String) -> String is the type
<sardaukar> aaaah
<sardaukar> sorry, getting used to reading it :D
<jhass> like A => B is syntax sugar for Hash(A, B), A -> B is syntax sugar for Proc(A, B), basically
<jhass> no worries ;)
<sardaukar> cool
<sardaukar> I have a ton more questions, hope I'm not boring you :D
<jhass> not at all
<sardaukar> ok, brb for now!
<jhass> so Request, Hash(String, String) -> String is a Proc with two parameters, a Request and a Hash(String, String) and that returns a String
<jeromegn> jhass: why would a ECR.process_file return a blank string? I created a file with <p>hello</p>. I’m doing String.build {|__str__| ECR.process_file(file_path) }
<jhass> jeromegn: String.build ignores the return value of the block iirc, .build do |io| io << ECR... should do
<jeromegn> that returns __str__ << "hello"
<jhass> (though I'm not sure why you do the String.build, doesn't process_file return a string?)
<jeromegn> process_file tries to use a buffer to append to
<jeromegn> you need to provide it the name of the buffer as a string… by default it’s __str__
<jeromegn> pretty confusing
<jhass> oh, I see what it does
<jhass> (never used ecr yet)
<jeromegn> :)
<jeromegn> seems like I might have to run/eval the result...
<jhass> can't you use the embed_ecr macro?
<jeromegn> I’m trying to do stuff dynamically a little bit
<jeromegn> reusing a generic View
<jeromegn> initialize with template path and data
<jhass> the idea is that process_file is run at compile time with the run macro and the resulting string is inserted
<jhass> I think you want a macro def there then
<jhass> mh, no that won't work either
<jeromegn> is templating doomed in Crystal?
<jhass> so basically your issue is that ECR is designed to be called compile time and you want to feed it runtime data
<jeromegn> indeed
<jeromegn> I could use run
<jhass> run is executed compile time, still
<jeromegn> ah
<jeromegn> no fun!
<jeromegn> I wanted to make a macro that defined a new Class view
<jeromegn> but that’s not allowed anymore
<jeromegn> macros can’t define classes
<jhass> I guess an approach to make runtime decision work with ECR is to add stuff to the macro language that allows to do a path glob and build a hash literal using that
<jhass> of filename => rendered template
<jhass> mh, no, that still lacks context
<jeromegn> yea
<jeromegn> compile to a proc?
<jeromegn> I might go back to that bson project quickly enough :)
<jhass> we should just implement a liquid parser
<jhass> I guess mustache and handlebars could be implemented as eval-less engines too
<jeromegn> I love Slim myself
<jhass> yeah, though it relies on arbitrary code for logic and interpolation too
<jeromegn> yea
HakanD_ has joined #crystal-lang
HakanD has quit [Ping timeout: 255 seconds]
<jeromegn> ok yea, back to BSON
<jeromegn> which mostly works...
<jeromegn> except for that issue I filed
<jeromegn> I’m not sure there’s a way around it
<jeromegn> and I can’t test it… just have to trust that it works hah
waj has quit [Quit: waj]
leafybas_ has joined #crystal-lang
leafybasil has quit [Ping timeout: 252 seconds]
<jhass> mh, do we already have an issue for macro const_missing? :P
vikaton has joined #crystal-lang
sfcgeorg_ has joined #crystal-lang
sfcgeorge has quit [Ping timeout: 246 seconds]
DerisiveLogic has quit [Ping timeout: 250 seconds]
<jeromegn> there’s one for method missing?
<jhass> yeah
DerisiveLogic has joined #crystal-lang
leafybas_ has quit [Remote host closed the connection]
bcardiff has joined #crystal-lang
leafybasil has joined #crystal-lang
<sardaukar> I'm trying to define multiple macros - is it possible in a loop?
<sardaukar> like this http://paste.mrzyx.de/poiw4ophs
<sardaukar> but I'm getting "undefined macro variable 'hash' "
<sardaukar> makes sense, but if I want to get at the hash var, I won't be able to get a valid class name - right?
<jhass> sardaukar: you have to escape the inner macro interpolations
<jhass> \{{hash iirc
<sardaukar> that just places the \{{hash.... string directly on the macro output
havenwood has joined #crystal-lang
<jhass> of the outer macro, so it can be interpreted by the inner macro
<jhass> no?
<sardaukar> undefined macro variable 'hash'
<sardaukar> I'm assuming you mean macro {{method.id}}(path, \{{hash}}) on that pastebin, right?
<jhass> no
<jhass> line 4 & 5, line 3 as it is on the pastebin
<jhass> er, line 2
<sardaukar> as I said, that just puts the {{hash... string on the macro's output
<sardaukar> right?
<sardaukar> what am I missing?
waj has joined #crystal-lang
<jhass> that's what we want at this stage
<jhass> the issue here is that it's interpreting the # as a comment
<jhass> random try: put a \ in front :P
<sardaukar> just did, no luck
<sardaukar> yeah, I see the issue now %)
<sardaukar> crap - can I use the ASCII/UTF-8 code for it?
<jhass> yeah, that should work
<jhass> >> '#'.ord
<DeBot> jhass: 35
<sardaukar> actually, double quotes fix it
<jhass> interesting
<sardaukar> makes sense, right?
<sardaukar> no? :D
<jhass> no :P
<sardaukar> yeah, it doesn't
<sardaukar> should I file an issue?
<jhass> yeah, minimal repro is: macro bar; '#'; end; bar (with ; replaced by newlines)
<waj> is it your BSON project shared somewhere? I’m joining late to the conversation and I’d like to understand what are you talking about :)
<sardaukar> jhass: so if double quotes would not work, what would the solution be?
<jhass> nah, they should work, I was missing something else
<jhass> waj: mind opping me shortly so I can fix something in the topic?
DerisiveLogic has quit [Ping timeout: 256 seconds]
willlll has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
<fowl> Iok
<jhass> ?
strcmp1 has quit [Quit: Leaving]
strcmp1 has joined #crystal-lang
<sardaukar> jhass: finished my route DSL parser, thanks for all the help
<jhass> yw
<sardaukar> one issue, though: all of the routes get called once after parsing
<jhass> well, my code calls them directly, yours should just store the blocks
<sardaukar> should I make the matcher method store the procs?
<sardaukar> yes, ok
wanderer_ has joined #crystal-lang
HakanD_ has quit [Quit: Be back later ...]
<sardaukar> how do I go about that anyway? store the return of yield on #matcher?
<jhass> no, route
<sardaukar> oh right
<sardaukar> and then yield the stored routes with the new requests and params
<jhass> in the matcher? no, just store
<jhass> call the stored proc in the request parser
blaix has joined #crystal-lang
strcmp1 has quit [Ping timeout: 255 seconds]
HakanD_ has joined #crystal-lang
<jeromegn> waj: what did you want to know about the BSON project? :)
<jeromegn> it’s not shared anywhere yet. I will push soon. I’ve written the tests I wanted to write. I just need to push some Time extensions to Crystal itself and maybe reorganize the code a little bit
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
vikaton has quit []
ismaelga has quit [Client Quit]
<waj> jeromegn: you said it works except for an issue
<jeromegn> I said that often :) the one I was talking about is fixed (one of the bindings didn’t declare the correct type)
<jhass> for the alignment issue just adding a bunch of padding worked?
<jeromegn> seems like it
<jeromegn> it works well now
<jeromegn> whatever operations I do
<jeromegn> so I think it’s all good
HakanD__ has joined #crystal-lang
sfcgeorg_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
HakanD_ has quit [Ping timeout: 272 seconds]
<crystal-gh> [crystal] jeromegn opened pull request #642: Implement Time.from_ms and Time#to_ms (master...time-ms) http://git.io/vUIBy
DerisiveLogic has quit [Ping timeout: 264 seconds]
DerisiveLogic has joined #crystal-lang
<jeromegn> jhass: ^ thoughts?
<jhass> commented ;)
<sardaukar> I can't start an HTTP server
<sardaukar> the handler http://paste.mrzyx.de/pdi6l5i8v
<sardaukar> and I'm just doing server = HTTP::Server.new port, HTTPHandler.new ; server.listen
<sardaukar> what am I missing?
<jhass> sardaukar: your handler is supposed to return an HTTP::Response
<jhass> not nil
<sardaukar> oh makes sense
<sardaukar> that's the kind of error I expect at runtime still :D
<jeromegn> sardaukar: what are you working on?
<sardaukar> CRAILS
<sardaukar> :D
<sardaukar> a kinda Rails-ish PoC
<sardaukar> it's my company's hackday today
<sardaukar> and I want to show everyone how cool Crystal is
<jeromegn> haha nice
<jeromegn> well that’s an ambitious project
<sardaukar> should be a 1 day thin g
<sardaukar> kinda dragging :/
<sardaukar> do I have to use private for every method?
<sardaukar> and not just private on a line, and everything is private from that point on?
<jhass> yes
bcardiff1 has joined #crystal-lang
<jeromegn> >> TimeSpan.new(Time.now_utc.ticks).milliseconds
<DeBot> jeromegn: Error in line 3: undefined method 'now_utc' for Time:Class
<jeromegn> >> TimeSpan.new(Time.utc_now.ticks).milliseconds
<DeBot> jeromegn: 547
<jeromegn> hmm
<jeromegn> >> TimeSpan.new(Time.utc_now.ticks).tota_milliseconds
<DeBot> jeromegn: Error in line 3: undefined method 'tota_milliseconds' for TimeSpan (did you mean 'total_milliseconds'?)
sfcgeorge has joined #crystal-lang
<jeromegn> >> TimeSpan.new(Time.utc_now.ticks).total_milliseconds
<DeBot> jeromegn: 6.35667e+13
<jeromegn> >> typeof(TimeSpan.new(Time.utc_now.ticks).total_milliseconds)
<DeBot> jeromegn: Float64
bcardiff has quit [Ping timeout: 264 seconds]
<jeromegn> >> TimeSpan.new(Time.utc_now.ticks).total_milliseconds.to_i
<DeBot> jeromegn: -2147483648
<jeromegn> lol
<jhass> yeah, not sure TimeSpan makes sense for representing epoch
<jhass> >> 5.seconds
<DeBot> jhass: 00:00:05
<jeromegn> >> TimeSpan.new(Time.utc_now.ticks).t_i
<DeBot> jeromegn: Error in line 3: undefined method 't_i' for TimeSpan (did you mean 'to_i'?)
<jhass> that makes total sense
<jeromegn> >> TimeSpan.new(Time.utc_now.ticks).to_i
<DeBot> jeromegn: 63566701811
<jhass> but epoch is a fixed point in time, thus Time
<jeromegn> I’d be more than happy to implement the recommendations in the PR’s comments. just trying to understand what’s hapepning
<jeromegn> so many methods
<jeromegn> >> TimeSpan.new(Time.utc_now.ticks).total_milliseconds.to_i.abs
<DeBot> jeromegn: -2147483648
<jhass> try to_i64
<jeromegn> I said abs bro
<jeromegn> >> TimeSpan.new(Time.utc_now.ticks).total_milliseconds.to_i64.abs
<DeBot> jeromegn: 63566701887292
<jeromegn> oh
<jeromegn> I thought it would figure out which type of Int to use
<jeromegn> that number seems off
<jeromegn> should look more like 1414703893000
<jhass> ticks isn't milliseconds
<jhass> oh, TimeSpan takes ticks, nvm
<jeromegn> I gave it ticks and I asked for milliseconds
<jeromegn> :)
strcmp1 has joined #crystal-lang
<jhass> anyway, as said I don't think it makes sense for Epoch
<jeromegn> I have no hard CS background, I’m self-taught in all the things :)
<jeromegn> so these concepts are elusive at the moment
<jeromegn> need to learn more
<jeromegn> for now I’ll just extend them in my project.
leafybasil has quit [Ping timeout: 256 seconds]
<jhass> I'm not sure if my CS studies added that much background to what I had previously :P
<jhass> the concurrency course was nice
shama has joined #crystal-lang
zz_Cidan is now known as Cidan
<sardaukar> I can't manage to require my dep code by path
<sardaukar> is there a trick?
<sardaukar> it only works with require "../crails/**"
<sardaukar> (on my project's root folder, the Crails code is in the folder up)
<sardaukar> my Projectfile has deps do ; path "../crails" ; end
<sardaukar> and I see a crails file on my project's "libs" folder
<sardaukar> but I get Error in ./app.cr:1: while requiring "crails": can't find file 'crails' relative to '/Users/bruno/Code/OWN/crails-hello-world' if I just do require "crails"
<sardaukar> other than that, it seems to be working :D got 200s and 404s working, gonna take the rest of the weekend to polish it up and maybe add a view layer
<jhass> it should be src/crails/crails.cr
<jhass> deps will make it libs/crails/crails.cr
<jhass> and require with expand search for crails.cr and if that's missing crails/crails.cr
<sardaukar> ah ok
<sardaukar> lemme try
<jeromegn> jhass: so whatever I name my repo on github, what’s important is the name of the file?
<jeromegn> I’m about to push the BSON stuff
<sardaukar> yes! thanks
<sardaukar> jhass: couldn't have done this today without your help! thanks a bunch
<sardaukar> I'll be around
<sardaukar> c ya
<jhass> jeromegn: I'm not sure tbh
<jeromegn> hmm
<jhass> I know it does something with dropping crystal- from repo names...
<jeromegn> that could be good enough too
<jeromegn> trying to find info about it
<jhass> source code :P
<jeromegn> yea
<jhass> so it actually does the require three levels deep? idk
<jeromegn> I’ll just name it bson.cr :)
sardaukar has quit [Ping timeout: 246 seconds]
HakanD__ has quit [Quit: Be back later ...]
<jhass> neat
<jeromegn> I should add inline docs
<jeromegn> and the spec library needs a lot more stuff!
<jeromegn> I don’t know how much is possible without meta programming
<jhass> I found a concept where let and before each hooks work, but it creates many classes -> slow
<jeromegn> ah
<jeromegn> well, can’t be slower than Ruby
<jeromegn> also, the tests are fast as hell at the moment :)
<jhass> well, slow to compile that is mainly
<jeromegn> hmm, how do I pass those sweet options to “crystal spec”? h/crystal/blob/0df531ede12efc4417519f8baf355a9d0e649f03/src/spec/spec.cr#L145-L163
<jeromegn> Error: '-v' is not a file
<jeromegn> Error: unknown command: -v
Tetsumi has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
<jeromegn> hmm, I need to install libbson on travis
<jhass> no, containers for you then!
<jhass> sudo: false; before_script: apt-get install libbson
<jhass> er, sudo: true
<jhass> and prolly sudo apt-get
<jhass> jeromegn: options seems to work when I just append them behind the filename
<jeromegn> interesting
<jeromegn> yea I usually run all my specs
blaix has left #crystal-lang [#crystal-lang]
willlll has quit [Quit: willlll]
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
waterlink has joined #crystal-lang
<crystal-gh> [crystal] Exilor opened pull request #643: Fixed type var for Array::IndexIterator's Iterator (master...patch-2) http://git.io/vULSu
JBat has quit [Quit: Computer has gone to sleep.]
DerisiveLogic has quit [Ping timeout: 265 seconds]
DerisiveLogic has joined #crystal-lang
abhips has joined #crystal-lang
abhips has quit [Client Quit]
bcardiff1 has quit [Quit: Leaving.]
willlll has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
havenwood has quit []
<jeromegn> jhass: how would you represent that in a lib in crystal “A NULL terminated vector of NULL-byte terminated strings."
<jeromegn> :D
<jhass> vector is just a fancy name for array
<jhass> or buffer
<jhass> so you take a pointer and iterate it until you hit a null pointer
<jhass> I think I have something for that, sec
canhtak has joined #crystal-lang
Cidan is now known as zz_Cidan
DerisiveLogic has joined #crystal-lang
zz_Cidan is now known as Cidan
Cidan is now known as zz_Cidan
zz_Cidan is now known as Cidan
DerisiveLogic has quit [Remote host closed the connection]
canhtak has quit [Quit: canhtak]
fraya_ has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vUtj9
<crystal-gh> crystal/master c87a511 Jacob: Fixed type var for Array::IndexIterator's Iterator
<crystal-gh> crystal/master 89d9b37 Ary Borenszweig: Merge pull request #643 from Exilor/patch-2...
sfcgeorg_ has joined #crystal-lang
fraya_ has left #crystal-lang ["Leaving"]
sfcgeorge has quit [Ping timeout: 264 seconds]
sfcgeorg_ is now known as sfcgeorge
leafybasil has joined #crystal-lang
<travis-ci> manastech/crystal#2317 (master - 89d9b37 : Ary Borenszweig): The build is still failing.
BlaXpirit has quit [Quit: Quit Konversation]
<Dreamer3> any easy way to get instance vars from a different class?
<waterlink> Expose method on that class
<jhass> >> class Foo; def initialize; @a = 1; end; end; Foo.new.@a
<DeBot> jhass: 1
<jhass> but maybe don't do that ;P
<waterlink> heh )
<Dreamer3> wtf
<Dreamer3> is that intentional?
<waterlink> breaks encapsulation )
<jhass> yeah, I had no issue for it to be removed
<Dreamer3> i'm tryign to do magic
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
<Dreamer3> klass=@type; klass.instance_vars doesn't seem to work
<Dreamer3> can you not do that in a macro?
<Dreamer3> grab the instance vars for a parcitular class?
<Dreamer3> can you not do that in a macro?
waj has quit [Quit: waj]
<crystal-gh> [crystal] Exilor opened pull request #644: Added iterators for Matrix (master...master) http://git.io/vUqcP
<waterlink> no you can't
<waterlink> macro is evaluated at compile time
<waterlink> and you operate over AST (Abstract Syntax Tree) nodes
<waterlink> ^ /cc Dreamer3:
<Dreamer3> right i just need th list
<Dreamer3> not the contents
<Dreamer3> it works inside the class but if i put it in a macro then run the macro inside the class it doesn't seem to work
<waterlink> Look here: https://github.com/manastech/crystal/blob/master/src/compiler/crystal/macros/methods.cr - This file contains everything you have on macroses
<Dreamer3> yep
<waterlink> you can still make macro generate some sort of method, which will get all variables and use it at runtime
<waterlink> ah, I see, there is method .instance_vars
<waterlink> But probably what you get is not a TypeNode
<waterlink> try: `type as TypeNode` ?
<waterlink> don't know if it will work, but could
<Dreamer3> i want to get a list of one classes instance variables inside another
<Dreamer3> so i could make macros to chain them together
<Dreamer3> it actually works if the macro is inside a class method
<Dreamer3> but then i can't define a class
<Dreamer3> but then i can't define a class
<Dreamer3> time to just look at how closures work
havenwood has joined #crystal-lang