<FromGitter>
<faultyserver> If I have an array that I know will only have fewer than 255 entries (like, on average there will be 2), how can I get the size of that array as a `UInt8`?
<FromGitter>
<faultyserver> `.size` returns a `Int32`, which can't be casted
Kug3lis_ is now known as Kug3lis_off
<FromGitter>
<johnjansen> out of interest, whats the reason for casting it down … just for my curiosity
<FromGitter>
<faultyserver> context: I'm writing to a binary file and the format specifies the a single byte for number of arguments to an instruction
<FromGitter>
<solisoft> Error in src/mustache_cr.cr:22: undefined method 'as_h' for JSON::Any:Class ⏎ puts Crustache.render renderer, json.as_h
<FromGitter>
<straight-shoota> your object `json` should be an instance of `JSON::Any`, not the class itself
<FromGitter>
<solisoft> All I want it to have this script working https://codeshare.io/aVvbXQ , can you help me please ?
<FromGitter>
<solisoft> basically I want to create a command line tool to run mustache generation
<FromGitter>
<solisoft> Ruby version is so slow...
<hightower2>
"All I want" is the beginning of your troubles! :)
<FromGitter>
<straight-shoota> Your assigning `JSON::Any` to `json` in line 8
<FromGitter>
<straight-shoota> If you want to restrict the type, use `json : JSON::Any`
<FromGitter>
<straight-shoota> `json = ...` in the block will not refer to that variable but create a new local one
<FromGitter>
<straight-shoota> You should not put everything in module scope, but rather in a method or global scope
<FromGitter>
<solisoft> Ok I see for my json variable
<FromGitter>
<solisoft> `parser.on("-j JSON", "--json=JSON", "JSON data to load") { |j| json = JSON.parse(j).to_h }` is raising an error :/
<FromGitter>
<solisoft> Expected Array for # (index : Int), not Hash(String, JSON::Type) (Exception)
<FromGitter>
<straight-shoota> `as_h`
Kug3lis has joined #crystal-lang
<FromGitter>
<solisoft> argh yes ... but : cast from Array(JSON::Type) to Hash(K, V) failed, at /usr/local/Cellar/crystal-lang/0.22.0/src/json/any.cr:230 (TypeCastError)
<oprypin>
well casting from Array to Hash, how is that not going to fail
<FromGitter>
<saggit> hello, I am use crystal with mongodb, mongo.cr ⏎ ⏎ how to write a limit query? i try there: ⏎ collection.find({ "$query" : { "inspire" : { "$ne" => true } } }, limit=5 ) do |doc| ⏎ ... [https://gitter.im/crystal-lang/crystal?at=593e57106549436c7d3c7b1b]
<FromGitter>
<saggit> Thank You very much. it works
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kug3lis has joined #crystal-lang
<FromGitter>
<JJJollyjim> Hmm, my understanding is that if a method is in Enumerable but not Iterator, I can call it on an Iterator but it won't be lazy. Is that right?
<FromGitter>
<bew> yes
<FromGitter>
<JJJollyjim> Is there usually a good reason for such a method to exist, or just "nobody implemented it"?
<FromGitter>
<JJJollyjim> (wondering specifically about `#chunks` right now)
<FromGitter>
<JJJollyjim> Oh hold on, it's called `#chunk` in `Iterator`...
<FromGitter>
<JJJollyjim> And `#chunks` in `Enumerable`
<FromGitter>
<JJJollyjim> Why would that be?
<FromGitter>
<ultra2mh> Hi , is there any jetbrain plugin or ide for crystal lang ?
<FromGitter>
<bew> no yet!
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<bew> there are a few plugins for common editors like vim, emacs, atom (and maybe others) but currently no support for more IDE-like functionnalities (like autocompletions)
<FromGitter>
<ultra2mh> what is this line of code mean ? ⏎ what is |value| role???? ⏎ elements.each do |value|
<FromGitter>
<ultra2mh> @jwaldrip
<hightower2>
-join #rubz
Kug3lis has joined #crystal-lang
<hightower2>
Oh sorry, didn't realize the previous typo went into the channel
<hightower2>
ultra2mh: "each" loops over each item in "elements", and in each loop it calls your block specified with {...} or do...end, and in variable 'value' (or any name inside |...|) it passes you the element currently being looped over
<FromGitter>
<JJJollyjim> Hmm anyone used gprof with crystal before?
<FromGitter>
<JJJollyjim> Wiki says it "should work"
<FromGitter>
<JJJollyjim> ** docs do
<FromGitter>
<JJJollyjim> But in C you compile with a profiling flag, and that causes the program to write a file with profiling data
<FromGitter>
<JJJollyjim> I can't find such a flag for the crystal compiler
hightower3 has joined #crystal-lang
<FromGitter>
<bew> it seems that you can generate object files, then link them using `gcc` and pass the `-pg` option at linking time
<FromGitter>
<JJJollyjim> Ooh I'll check that out thanks
<FromGitter>
<JJJollyjim> However adding `--release` gave a 10x boost so I'm no longer in a rush to profile ;)
<FromGitter>
<bew> ahah ;)
hightower4 has quit [Ping timeout: 240 seconds]
duckqlz has quit [Ping timeout: 255 seconds]
duckqlz has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
Swey_Hey has quit [Quit: Going offline, see ya! (www.adiirc.com)]
olek_poz has quit [Ping timeout: 260 seconds]
splitty_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 255 seconds]
olek_poz has joined #crystal-lang
<crystal-gh>
[crystal] MakeNowJust opened pull request #4553: MatchData: improve error message when refer no matched existed capture group (master...fix/regex-match-data/improve-error-message) https://git.io/vH9fn
snsei has joined #crystal-lang
<crystal-gh>
[crystal] MakeNowJust opened pull request #4554: MatchData: raise KeyError instead of ArgumentError by #[](key: String) (master...fix/regex-match-data/raise-key-error) https://git.io/vH9JG
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
snsei has quit [Remote host closed the connection]
<FromGitter>
<sdogruyol> cool
<hightower2>
indeed.
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<crystal-gh>
[crystal] akzhan opened pull request #4555: HTML.escape - Switch to Rack::Utils.escape_html behavior by default. … (master...classic-HTML.escape) https://git.io/vH93G
hightower2 has quit [Ping timeout: 240 seconds]
olek_poz has quit [Ping timeout: 260 seconds]
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/vH9nO
<crystal-gh>
[crystal] asterite closed pull request #4551: Few small fixes (master...few-small-fixes) https://git.io/vHSfh
mark_66 has quit [Remote host closed the connection]
Kug3lis_off is now known as Kug3lis_
Kug3lis_ is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis_
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<paulcsmith> This is probably an easy problem to solve, but I can't figure it out. When using `run` in a macro I can it working and generating code correctly, but the code is also printed to stdout. Is there a way to generate code without also printing to stdout? Here's the most bare bones example to show what I mean https://gist.github.com/paulcsmith/23530877b2a7e31e9134b037ab93cd42
<FromGitter>
<bew> do you mean "it prints on stdout during build ? or during run ?
<FromGitter>
<paulcsmith> During compile time, but that is very distracting when you're rebuilding the server every time you make a change :S
<FromGitter>
<bew> how are you compiling ?
<FromGitter>
<bew> using `crystal build main.cr` didn't print anything for me
z64 has joined #crystal-lang
<oprypin>
paulcsmith, describe your system and how you're running this
<FromGitter>
<paulcsmith> @bew Hmm you're right. That example doesn't print the generated code to stdout. But the real code I have definitely does. I'll try to figure out what the difference is between the two. Hmmm...
<oprypin>
ok do that then
<FromGitter>
<asterite> You are probably requiring `yay.cr` with a `require .../**` too, so that it gets compiled in the main program
<RX14>
@asterite btw are we waiting for anything for a release?
<FromGitter>
<asterite> I'm not the one in charge of releases anymore, so you should ask someone else, maybe @waj @spalladino @mgarcia or @bew
<FromGitter>
<asterite> Not @bew, @bcardiff
<FromGitter>
<bew> ahahahahah
<FromGitter>
<asterite> (bad autocomplete from gitter :-P)
<RX14>
i don't think anyone should be "in charge" of releases...
<FromGitter>
<asterite> Well, I don't want to be "in charge" of releases :-)
<oprypin>
while we're at it, RX14, maybe you know a good replacement example
<FromGitter>
<bew> np, the day I'll launch a release by myself will be a great day (in my imagination..)
<RX14>
but i get people using discordcr asking for the websockets fix every day
<RX14>
i'm tired of getting them to edit their stdlib to add a flush call
<oprypin>
by example i mean some method call that can accept Random::System as Random
<oprypin>
that deck shuffling is not good indeed
<FromGitter>
<paulcsmith> @asterite That was it! Thank you :D
<FromGitter>
<asterite> :tada:
<FromGitter>
<paulcsmith> I figured it was something simple :P I didn't think of that at all though
<FromGitter>
<asterite> It happened to me a couple of times too. You can try to use another extension, maybe .cr.run, and then explicitly using that name. I think the `require /**` won't take it then
Raimondii has joined #crystal-lang
<FromGitter>
<paulcsmith> Oh that's an interesting idea. I'll give that a shot :thumbsup:
<FromGitter>
<jeromegn> I've also been wondering when the next release will be cut
<Disrecollection>
I think the most annoying thing with Crystal, even considering the lack of newbie support, is the fact that when I look up "crystal something-something" on google, I get videos about witchcraft and stuff instead of the lang, and I have to go and revise my search.
<FromGitter>
<bew> always type "crystal lang" for now, until it popular for google :)
<FromGitter>
<bew> it gets*
<Papierkorb>
Disrecollection: Are you using google to find api docs pages?
<Disrecollection>
Nah, I open up one API doc, and then I just clone it to new tabs and search.
<FromGitter>
<straight-shoota> There are several Crystal Lang on facebook... :smile:
<Disrecollection>
Finished my webscraper with crystagiri. Sorta hacky, but certainly led to better understanding of Crystal(and ruby) syntax. Working on messing with concurrency stuff now.
<RX14>
?xy
<DeBot>
it seems like you are asking for a specific solution to a problem, instead of asking about your problem. This often leads to bad solutions and increases frustration for you and those trying to help you. More: http://meta.stackexchange.com/a/66378
<RX14>
well
<RX14>
that still works at least jhass
<jhass>
heh
<jhass>
I just forget what keys I set in which channel :P
<RX14>
i like ?ask
<RX14>
thats what it's always been to me
<RX14>
?ask and ?xy
<DeBot>
and: Don't ask to ask. Just ask your question, and if anybody can help, they will likely try to do so.
<RX14>
huh it strips spaces
<RX14>
bad bot
<jhass>
:D
<jhass>
didn't even remember that
<jhass>
anyway, have to say nighty night
<Papierkorb>
gn8
<RX14>
night
<Disrecollection>
Gnight.
<Disrecollection>
So, as I understand it, fibers mut voluntarily give up control; so long as any given fiber doesn't have something like a sleep or yield, the fiber manager will never wrest control from them. ??
<RX14>
yup
<RX14>
they're cooperatively scheduled
<RX14>
in practice it doesn't really crop up often
<Papierkorb>
Disrecollection: Waiting for I/O, channel, ... will also yield a fiber, giving another one a chance of doing something useful
<RX14>
but it can be an issue if you're doing lots of computation and no IO
<RX14>
annoying thing is that File IO never blocks
<Disrecollection>
Alrighty, good to know. Thanks!Esp. with the IO etc, always forget.
<Disrecollection>
Yeah, I've got that baboy open rn.
<Disrecollection>
Sometimes it's better for me to ask people though, cause often I'll read something and forget some of the minor things or exceptions.
<crystal-gh>
[crystal] asterite pushed 2 new commits to master: https://git.io/vHHlQ
<crystal-gh>
crystal/master 5370faf Ary Borenszweig: Optimize Range#size for integers
<crystal-gh>
crystal/master c8ec408 Ary Borenszweig: Optimize Range#map for integers
<FromGitter>
<elorest> In response to crystal meetups discussion earlier. Until we have more people in the community we can combine meetings online. For instance my talk last wednesday in Salt Lake City was also streamed to denver.cr.