<crystal-gh>
[crystal] bcardiff opened pull request #5317: Allow less than expected digits when parsing time with decimals (master...feature/fewer-digits-time-parser) https://git.io/vFF7o
<FromGitter>
<cyclecraze_twitter> ```code paste, see link```
vivus has quit [Quit: Leaving]
<FromGitter>
<ezrast> You can at least do `p = Person.from_json "{}"`, no?
qard has joined #crystal-lang
<FromGitter>
<edwardloveall> Hi all!
<FromGitter>
<edwardloveall> I'm still a bit new to crystal
<FromGitter>
<edwardloveall> really enjoying it, and I'm trying to figure out how to use `crystal play`
<FromGitter>
<edwardloveall> I made a main.cr file and imported it into the playground, but it's saying `undefined constant Person`
<FromGitter>
<edwardloveall> so I feel like maybe I'm not understanding how playgrounds work
<FromGitter>
<edwardloveall> and I couldn't find any docs or tutorials on the website
<FromGitter>
<edwardloveall> if anyone has any advice or a tutorial to link to, that would be super helpful!
<faustinoaq>
@edwardloveall Try using work workbook section π
<FromGitter>
<edwardloveall> I'll check that out, thanks!
<FromGitter>
<ezrast> @edwardloveall Your example is compiling because there's a file named `main.cr` in Crystal's standard library. I'm not sure whether there's a way to require local files in the playground.
<FromGitter>
<ezrast> That should read "Your example's first line is compiling..."
<FromGitter>
<edwardloveall> ah ha
<FromGitter>
<edwardloveall> okay
<FromGitter>
<edwardloveall> i'll do some digging
<FromGitter>
<edwardloveall> thanks for the that info
<FromGitter>
<edwardloveall> mmm interesting. I did `Dir.current` and it listed the directory the file is in
<FromGitter>
<edwardloveall> I renamed the file to `scratch.cr` and tried to require it and got
<FromGitter>
<edwardloveall> > an't find file 'scratch.cr' relative to '.'
<FromGitter>
<edwardloveall> so yup, exactly like you said
<FromGitter>
<edwardloveall> ah I got it working in a workbook
<FromGitter>
<edwardloveall> with `require "./playground/person.cr"`
<FromGitter>
<edwardloveall> yup, works in normal playground too :D
<FromGitter>
<edwardloveall> thanks all
thews has quit [Ping timeout: 248 seconds]
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzzβ¦]
thews has joined #crystal-lang
thews has quit [Changing host]
thews has joined #crystal-lang
mbarbar has joined #crystal-lang
baweaver has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
mbarbar has quit [Ping timeout: 240 seconds]
<FromGitter>
<HCLarsen> Hey everyone, in case you're curious, I just wrote my first crystal tutorial blog. Check it out if you want:
<FromGitter>
<johnjansen> the data you supplied is already an array of hashes, but the type implies something more comples
<FromGitter>
<johnjansen> what you suggested is conceptually correct for the data you supplied, but then you dont need to convert it .. since its already a hash
<FromGitter>
<johnjansen> and array of hashes OR this OR that OR something else OR any number of things OR Nil
<FromGitter>
<johnjansen> not all even implement `each` ...
<FromGitter>
<johnjansen> so on the surface right from the outset there is a problem
<FromGitter>
<codenoid> okay, i just cast BSON type to string
<FromGitter>
<codenoid> bson = `{"fa":"fwf"}` just like json, and i do JSON.parse
<FromGitter>
<johnjansen> ok, you also have various number types, and regex and time to deal with β¦
<FromGitter>
<johnjansen> also, the bson turns out a JSON::Any β¦ so you just moved the issue
<FromGitter>
<johnjansen> what are you actually trying to do?
<FromGitter>
<johnjansen> more than of your types (in the union) might be deep data
<FromGitter>
<johnjansen> ^one^
<FromGitter>
<codenoid> thank @johnjansen ,i totally cast that type to only hash and string, π
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
snsei has quit [Remote host closed the connection]
hightower2 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
mbarbar has joined #crystal-lang
DTZUZU has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
snsei has quit [Remote host closed the connection]
claudiuinberlin has joined #crystal-lang
mark_66 has joined #crystal-lang
<Groogy>
Morning! o/
<FromGitter>
<unreadable> Morning all too
rohitpaulk has joined #crystal-lang
Papierkorb_ has joined #crystal-lang
<FromGitter>
<Qwerp-Derp> oprypin: `Font.from_file` doesn't work with files outside of `src`, I'm trying to do `Font.from_file("../resources/FiraCode.ttf")` and it simply doesn't work
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
rohitpaulk has quit [Read error: Connection reset by peer]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
<Papierkorb_>
Paths are resolved at runtime of your program. Relative paths are always relative to the current working directory of your process.
<Papierkorb_>
Qwerp-Derp
<FromGitter>
<Qwerp-Derp> Ah, OK. Fixed the issue, thanks!
<FromGitter>
<Qwerp-Derp> Wait... is there a difference between going `./foo` in the command prompt and clicking on the executable `foo`?
<FromGitter>
<Qwerp-Derp> `./foo` works fine, but when I click on the executable the program's file path references mess up
snsei has joined #crystal-lang
<Papierkorb_>
That's up to your file browser.
<FromGitter>
<Qwerp-Derp> Oh. After looking at an SO question, it turns out the working directory is my home directory when double-clicking using Finder.
<FromGitter>
<Qwerp-Derp> How do I change this function so that it affects the relative directory of the executable instead, using the command line?
<Papierkorb_>
Don't go around patching random methods. Either patch a single method which knows the root directory of assets (This is actually preferred), or if you know what you're doing, make the environment the expected environment
<FromGitter>
<Qwerp-Derp> I just placed it in my main `mirrors.cr` file
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter>
<bararchy> It's amazing that the Lexical scope issue is still here after so long :\
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 258 seconds]
<Papierkorb_>
RX14, could #5257 be merged until release of 0.24? Without the fix real-world code breaks on my end
<RX14>
just need to remind the rest of the team that it's a security issue and must be merged
<Papierkorb_>
kk
<FromGitter>
<JonnyCodewalker> quick question: why does `(flags.index.nil? ? 0 : flags.index).times do` complain that `times` is not defined for nil doesnt the tenary if assure that it can not be nil?
<Papierkorb_>
You're calling `flags.index` twice, the second call could return `nil` again
<FromGitter>
<JonnyCodewalker> but i only call it a second time if it is not nil
<Papierkorb_>
If you want *that* line to work, `(flags.index || 0).times` could work. But I'd actually prefer it to be rewritten in a fashion that gets a non-nil passed into, or set by a `if var =`
<Papierkorb_>
No you call it twice.
<RX14>
flags.index is a method
<RX14>
it can returnj different things every time
<RX14>
it probably doesn't
<RX14>
but the compiler cannot prove that
<Papierkorb_>
Consider this method: `def index; rand > 0.5 ? 123 : nil; end` Your check there calls this method twice, and thus is not sufficient to ensure its non-nil
<Papierkorb_>
This method may look outlandish at first, but it's the worst-case scenario, and the compiler has to consider this scenario
<FromGitter>
<JonnyCodewalker> aaaah. i misunderstood the shard i was using, yeah makes sense what you say
<FromGitter>
<JonnyCodewalker> for some reason in my brain it was not a method but a variable.
<RX14>
it's always a method in crystal
<FromGitter>
<JonnyCodewalker> yeah, that was what i was not aware of, but thats is why i am trying out stuff to understand :D
<RX14>
btw this logic also applies for @var and ::var instance/class variables because they can be changed by other threads inbetween the nil check and you using them
<RX14>
oops
<RX14>
@@var
<Papierkorb_>
Sidenote, tenary operators aren't super common in Crystal. *Usually* using `x || y` suffices instead of doing `x ? x : y`
<RX14>
^
<FromGitter>
<JonnyCodewalker> if it does that would be nice since it is more readable :)
<FromGitter>
<JonnyCodewalker> thanks for the help
<Papierkorb_>
RX14: Should I CC anyone into there
<Papierkorb_>
?
<RX14>
all the core team are watching the repo
<RX14>
pinging them doesn't actually do anyting extra
<Papierkorb_>
good to know, I would've @-ed people at basically random
<FromGitter>
<extremety1989> @bew only in javascript =)
<FromGitter>
<codem4ster> Hi everybody. How can I get a stream from a url and write to a file with Crystal? I couldn't understand IO operations in Crystal well. Would you share an example please? :)
<crystal-gh>
crystal/master f6a1fa1 Stefan Merettig: Make String#[] not read out-of-bounds if string ends in unicode char (#5257)...
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
<FromGitter>
<sdzyba> does anyone know what's holding back the 0.24.1 release? the issue with LLVM? β the reason I'm asking is because it was mentioned that 0.24.0 should be considered as a release candidate, not the regular "stable" version
rohitpaulk has joined #crystal-lang
<FromGitter>
<bararchy> I guess they are waiting for more users to try it and see if there are "BIG" issues that might effect usability
<FromGitter>
<bararchy> I'm using HEAD, and didn't see anything unusual (except thin-lto I mentiond above)
<FromGitter>
<extremety1989> @bew havent tried it yet
<FromGitter>
<extremety1989> @bew try it self =)
<FromGitter>
<extremety1989> @DRVTiny zdorova ))
<FromGitter>
<DRVTiny> @bew The problem is that there is no documnted anywhere, how to pass parameters to "asm" inlines and how to get results from it. Without this explanations, inline asm is totally useless feature.
<Papierkorb_>
The fiber.cr also uses tons of inline assembly
snsei has quit [Ping timeout: 252 seconds]
<FromGitter>
<bew> ah, page 15 in the pdf I linked: The general form of an asm call is `asm( βcodeβ : outputs : inputs : clobbers)`
<robacarp>
given a method that receives splat args, is there a quick way to add one element to the named tuple from the splat, and then pass that named tuple on to another function?
<robacarp>
I expected to be able to do something like: def a(**args); b(first: 1, **args); end
<FromGitter>
<bew> it should work
<robacarp>
perhaps I'm missing something then, the compiler gives "expected named argument, not **"
snsei has quit [Remote host closed the connection]
<FromGitter>
<sdogruyol> @extremety1989 jsonb is fast. What's normal types though?
<FromGitter>
<extremety1989> Ints Strigs
<FromGitter>
<sdogruyol> that's not a direct comparison
<Papierkorb>
JSONB and JSON are about their representation in the database, both are fast for different things
<FromGitter>
<extremety1989> @sdogruyol oh okey
<FromGitter>
<extremety1989> @FromIRC where can i get tutorials with jsonb and crystal ?
<Papierkorb>
JSONB and JSON work the same regarding the API you access them
<Papierkorb>
No idea how it works with Crystal.
<Papierkorb>
Also, my name is in the < >, @FromIRC is a bot.
<FromGitter>
<extremety1989> @FromIRC okey,thanks
* robacarp
headdesk
watzon_ has quit [Ping timeout: 240 seconds]
watzon_ has joined #crystal-lang
daemonwrangler is now known as derek-away
watzon_ has quit [Client Quit]
watzon_ has joined #crystal-lang
derek-away is now known as daemonwrangler
snsei has joined #crystal-lang
juni0r has joined #crystal-lang
daemonwrangler is now known as derek-away
derek-away is now known as daemonwrangler
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
daemonwrangler is now known as derek-away
derek-away is now known as daemonwrangler
Alibaba has joined #crystal-lang
<Alibaba>
Hi everyone
<FromGitter>
<abidon> Hello, @Alibaba and I are participating to an Hackathon for the next 46 hours where performance and efficiency is the key to win. We decided to use crystal as our backend server tech. There are chances we need your knowledge on some of the parts of the language that we may not master yet. We hope to make it good and promote the language π
<FromGitter>
<bararchy> @abidon Good luck guys
<FromGitter>
<sdogruyol> hey @abidon that's great to hear
<FromGitter>
<sdogruyol> is it a public hackathon?
<FromGitter>
<akzhan> looks like compiler progress stands on one point
<Alibaba>
Our goal is to create a search engine while consumming the least amount of ressources
<FromGitter>
<fridgerator> sounds cool, good luck guys
<Papierkorb>
hf&gl
daemonwrangler is now known as derek-away
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Read error: Connection timed out]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<Papierkorb>
Alibaba: I'm interested in search engines, their algorithms/structures. Will your sources be available later on?
faustinoaq has quit [Ping timeout: 264 seconds]
faustinoaq has joined #crystal-lang
<FromGitter>
<bew> @abidon cool, have fun ;)
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter>
<abidon> @Papierkorb I don't think our project will go deep in search engine algorithms. The main goal of the challenge is to raise awareness about "green coding". We only have to search inside a 1000 rows database. Our focus is definitely about producing optimized code, reducing bandwidth usage, reduce power consumption, ...
<FromGitter>
<abidon> By the way if we don't have restrictions on going public, we'll do it
<Papierkorb>
Don't play your efforts down. I'd be interest to hear about what you did differently to reduce power consumption
<Papierkorb>
That alone is a perfectly worthwhile insight :)
<FromGitter>
<bew> just to be sure (can't test now), a channel is bidirectional right?
txdv has quit [Ping timeout: 248 seconds]
<oprypin>
bew, it does not have any directions
<oprypin>
put things into it from anywhere, receive things from it anywhere
<FromGitter>
<bew> yeah right, a channel is not like a pipe, at all, thanks!
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 250 seconds]
<FromGitter>
<abidon> Just a small syntax question, how can i make ```{code: 10001}``` an Hash instead of a named tuple ?
<FromGitter>
<abidon> Found it, just forget about it
snsei has joined #crystal-lang
<Papierkorb>
In general, avoid using Symbol. They're not as ubiquous as in Ruby
<Papierkorb>
If you do need a Hash (Consider using a proper class if it's data of known structure instead), use String as key if you thought about using Symbol