<FromGitter>
<mattrberry> Coming soon: crystal bindings to the imgui sdl2 and opengn3 backends :)
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 272 seconds]
f1reflyylmao is now known as f1refly
<FromGitter>
<mattrberry> Does anybody online right now have much experience dealing with c binding unions in crystal? ysbaddaden's sdl bindings are currently breaking and I'm trying to fix them 🤔
deavmi has quit [Read error: Connection reset by peer]
<FromGitter>
<mattrberry> When I try to restrict the type of `@event` to `LibSDL::Event`, it fails with this message: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ even though `ControllerAxisEvent` is in the `Event` union [https://gitter.im/crystal-lang/crystal?at=60badbc720e86942d2443234]
szutt has joined #crystal-lang
<FromGitter>
<HertzDevil> putting my thoughts yesterday into crystal-lang/crystal#10785
szutt has quit [Quit: Client closed]
<FromGitter>
<naqvis> Looks quite promising, but thinking getting rid of ‘Crystal::VirtualType’ will be quite huge effort.
crabbedhaloablut has quit [Remote host closed the connection]
<FromGitter>
<grkek> when the `new Value(isolate, v);` happens
<FromGitter>
<grkek> hm
arestifo has joined #crystal-lang
crabbedhaloablut has left #crystal-lang [#crystal-lang]
hholst6543 has joined #crystal-lang
<hholst6543>
OK I like that I did not need to authorize myself. That reminds me of the good old days of Internet when I could just connect to stuff, No questions asked :)
<FromGitter>
<oprypin:matrix.org> hholst6543, oh.. that's coincidental, people haven't gotten around to requiring it.
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<hholst6543>
so is there a page / FAQ explaining some of the breaking changes from 0.x that I need to be aware of and the best practice / recommeded changes for 1.0?
<FromGitter>
<Oblivious-Oblivious> Hello, I was wondering, does code from C bindings get garbage collected from Boehm in any way ? The reference page calls C bindings as unsafe code so I'm assuming that it cannot be collected. Is there any way that I can force allocations in C code to use the GC or even use Boehm itself in my C codebase (assuming it's more time consuming to port it to crystal in the first place) ?
<FromGitter>
<oprypin:matrix.org> @Oblivious-Oblivious: C code calls C malloc which is completely unknown to boehm and there's no way to let it know about it
<FromGitter>
<oprypin:matrix.org> the typical option is to make a wrapper object to call C dealloc when the wrapper is collected
<FromGitter>
<oprypin:matrix.org> the option you want could go a few ways: ⏎ ⏎ 1) change the C code to call Crystal alloc ⏎ 2) allocate memory in Crystal and then use it in C, not allocate it in C [https://gitter.im/crystal-lang/crystal?at=60bb6c4b81b45810b88776c0]
<FromGitter>
<oprypin:matrix.org> both require the C library to be kind enough to let you do that. i've done both. 1 is fairly successful; 2 is "better" but really finicky
<FromGitter>
<oprypin:matrix.org> please tag me directly when you reply
<straight-shoota>
Some C libraries also let you define callbacks for alloc operations and thus you could tell it to use GC alloc
<FromGitter>
<jrei:matrix.org> jhass: nice. I didn't see any mention on the site :/
<FromGitter>
<Oblivious-Oblivious> @oprypin:matrix.org I have thought of option 2 but that requires changing the interface (doable), I'll probably try option 1 as well. I assume, when you say wrapper object to call the C deallocator you mean overloading the finalise method correct ?
<FromGitter>
<oprypin:matrix.org> all correct
<FromGitter>
<jrei:matrix.org> a little rss logo on the front page would be awesome :)
<straight-shoota>
true
<FromGitter>
<Oblivious-Oblivious> @FromIRC @oprypin:matrix.org Is there any reference where I can see how to call the crystal allocator from C ?
<straight-shoota>
jhass, about the community page: I've mentally already discredited the unstable branch, it just gets in the way
<FromGitter>
<jrei:matrix.org> (english is not my first language) I see at https://crystal-lang.org/ "Crystal 1.0 Conference - Livestreamed on 8 July 2021 – 4pm–8pm UTC". Livestreamed is a past tense, 8 July 2021 would be the past?
<straight-shoota>
website sis updated now with the new IRC info
<FromGitter>
<Oblivious-Oblivious> @oprypin:matrix.org Ah, great that was what I was looking for, thanks :)
<FromGitter>
<jrei:matrix.org> one could add the matrix channel :P
<FromGitter>
<oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org): gitter sends you to matrix already. no need.
<FromGitter>
<oprypin:matrix.org> jhass[m], wait why use matrix via IRC if you could just be using Matrix
<jhass[m]>
Just would really not have done a squash merge there, now the branches are still diverged commit wise :/
<FromGitter>
<jhass:m.aeshna.de> Because I can! :P
<FromGitter>
<jhass:m.aeshna.de> Still was joined both rooms from before the bridge and didn't decide which to keep
<FromGitter>
<jhass:m.aeshna.de> Also this whole matrix stuff is just an experiment for me for mobile IRC
<FromGitter>
<jhass:m.aeshna.de> So likely will keep the IRC side to be able to op stuff
<FromGitter>
<jrei:matrix.org> I finally removed myself from Gitter
Guest1 has joined #crystal-lang
Guest1 has left #crystal-lang [#crystal-lang]
Guest22 has joined #crystal-lang
Guest22 has quit [Client Quit]
Guest8 has joined #crystal-lang
Guest8 has quit [Client Quit]
<hholst6543>
I forked a repo on Github and updated shard.yml and pushet it
<hholst6543>
I then changed the dependency in the project that used that repo to point to my repo, but it still does not pick up on the changed version, is anything cached somewhere that I do not realize?
<hholst6543>
yeah its strange it sees the original repo, not the forked one
<FromGitter>
<Blacksmoke16> What does the shard.lock say
<FromGitter>
<Blacksmoke16> Might need to delete that then install if you change the repo of the same shard
<hholst6543>
strace says shards is poking about in ~/.cache/shards
<hholst6543>
but what would be the correct way to don't look at cached stuff but consider a fresh pull
<hholst6543>
I dont even have a shard.lock file right now, still its pulling in 0.1.2 even tough my forked repo says 0.2.0
<hholst6543>
cleaned ~/.cache/shards as well, still same result
<hholst6543>
so that was probably a Red Herrin
<FromGitter>
<naqvis> and what version your `shards.yml` states for particular dependency?
<hholst6543>
no version specified
<hholst6543>
only dependencies.docker.github="hholst80/docker.cr" (in yaml)
<FromGitter>
<Blacksmoke16> your fork doesn't have a `v0.2.0` release either
<hholst6543>
do you mean it needs to have a git tag?
<hholst6543>
otherwise I need to specify a branch?
<hholst6543>
yes, that was it. :)
<FromGitter>
<Blacksmoke16> can you share your shard.yml? and are you sure you dont have a shard.lock? If you installed it should have written one
<FromGitter>
<Blacksmoke16> if you dont provide a version/branch/commit it'll default to the latest release
<hholst6543>
I think it wasn't in the spirit of least-surprise that it picked a "random" tag from the repo if I did only specify "github: hholst80/docker.cr"
<hholst6543>
What I would assume was that it picked whatever shard.yml said in the default branch
<FromGitter>
<Blacksmoke16> it wasn't a "random" tag, it was the latest one
<hholst6543>
Never seen that behavior before
<hholst6543>
if you are going to innovate you're bound to get some critique at first :) I can see how it could be useful. but its going to cause a lot of confusion on newbies
<hholst6543>
shards ... should say something about (checking tag X.Y.Z) or such to make it more obvious that its not pulling down master
<FromGitter>
<Blacksmoke16> or just go read the shards docs
<FromGitter>
<Blacksmoke16> or better yet, actually specify the version you want (which is the much better option)
<FromGitter>
<Blacksmoke16> otherwise there's nothing preventing a `shards update` from breaking your application if the upstream repo does a new release that isn't compatible with the previous one
<hholst6543>
if NOTHING is specified and a tool does something that is not agreed upon by 99.99% of the world population, the tool should tell me what its doing. I can submit a PR later on.
<FromGitter>
<Blacksmoke16> doesnt it say what version it's installing tho?
<hholst6543>
even git cli does this, notoriously bad UI as it has
<FromGitter>
<Blacksmoke16> prob wouldnt hurt to make it more clear that its falling back on it but :shrug:
<FromGitter>
<Blacksmoke16> theres another line that says what version it's installing
<FromGitter>
<Blacksmoke16> after it fetches everything
<hholst6543>
It would be a easy thing to add the tag / branch etc that it decided to use
<hholst6543>
yes, it says whatever version that is in shard.yml
<hholst6543>
but gives no explaination why it does not pick up on my changes (on master)
<hholst6543>
So it needs to tell me as well, when its fetching git data, from what branch/tag its pulling it down
<hholst6543>
Its already telling me something, so we can just make that line more complete
<FromGitter>
<Blacksmoke16> could prob make it more clear its falling back on latest release, but it's not like it does that silently, clearly would say "Using docker (0.1.2)"
<hholst6543>
I just wasted 2 hours on this
<hholst6543>
If we can just save ONE other person from the same xp. its 2 hours saved
<hholst6543>
wasted = learned something
<hholst6543>
but you understand what I mean :)
<hholst6543>
It was not my primary goal right now to learn this curiosity with shards and how it defaults to latest tag. interesting as it is I was trying to figure out other parts of the whole crystal language, mostly related to JSON parsing
<FromGitter>
<Blacksmoke16> i would advise *not* using `json_mapping` fwiw
<hholst6543>
anyways, thank you for explaining the workings of latest tag being default if nothing else is specified. I kind of like the idea that tags are stable releases on a unstable / dev master branch. having two perm branches (stable vs dev) is not a gitflow I like at all
<hholst6543>
I am just trying to get the library working first. I will rip it out
<hholst6543>
the lib is some 4yo
<FromGitter>
<Blacksmoke16> ah it was already dependent on it?
<hholst6543>
no the docker.cr wasnt even working with 1.0.0 but I assume the guy that worked on it moved on because its not touched since 2018
<FromGitter>
<Blacksmoke16> probably yea
<FromGitter>
<Blacksmoke16> @Dan-Do does it work when *not* in MT mode?
<FromGitter>
<Blacksmoke16> or if using `CRYSTAL_WORKERS=2` or something?
<FromGitter>
<Dan-Do> let me check
<FromGitter>
<Dan-Do> oops, sorry, the above error was built without preview_mt. I will compile with mt now
<FromGitter>
<naqvis> @Dan-Do you are rescuing `query` , but that exception is raised by `checkout`
<FromGitter>
<Blacksmoke16> oh well in that case there goes my theory
<FromGitter>
<Dan-Do> ahh, my bad :)
Guest52 has joined #crystal-lang
Guest52 has quit [Client Quit]
<FromGitter>
<Dan-Do> btw, is it correct that there is only one conn is checked out by a fiber/thread?
<FromGitter>
<Blacksmoke16> wonder why that would fail tho. Only 1 fiber would be executed at a time, the conn should be added back to the pool after the block so there should always be at least 3 other available connections
<FromGitter>
<Dan-Do> correct, I have the same question
<FromGitter>
<Blacksmoke16> oh, the query might block so could end up with n fibers in the process of running
<FromGitter>
<Dan-Do> the data in a conn are interfered by another
<FromGitter>
<Blacksmoke16> does it work if you change `n = 4`?
<FromGitter>
<Dan-Do> it works when n<=6
<devoid_>
Heh all, I'm looking for a human friendly config file format to use with crystal apps. I've been using toml-config, but it doesnt support crystal 1.0.0, which implies it isn't being developed further. Suggesttions anyone?
<FromGitter>
<Blacksmoke16> yaml?
<FromGitter>
<Dan-Do> the conn has a IO.memory buffer. The correct query should be `"conn id 1484317189181300726 before query\nconn id 1484317189181300726 after query\n"` ⏎ The interfered query is `""conncid 6n790i6d t314c85n4c081n976 8.e918e1nqu0r0272\ co5enf6ior69e7 f06r5eu3ry15108696\actonn ienn yii4 `
<FromGitter>
<Blacksmoke16> or could always just make a PR to fix that shard (or fork it if needed)
<FromGitter>
<Dan-Do> Do I need to use Mutex to lock the method `query`?
<devoid_>
Blacksmoke16: by 'human friendly' I guess I meant 'non it proficient' friendly. The .ini format used by toml is easily understandable by anyone.
<FromGitter>
<naqvis> stdlib does comes with .ini support, but if you are more into toml, then you might have to look for external shards :P
<FromGitter>
<Blacksmoke16> depending on how large/complex your config file is yaml is still pretty easy to figure out
<hholst6543>
(side note: i dont understand toml)
<FromGitter>
<Blacksmoke16> but sounds like your best option would be to just fix that shard and not worry about switching
<devoid_>
toml is pretty much .ini files, though it does support structured data types (arays, hashes) as values. I'm not too attached to it, but people are familiar with the syntax.
<FromGitter>
<naqvis> > Do I need to use Mutex to lock the method `query`? ⏎ ⏎ don't think you need to do that, as you are using Connection-Pool and every checkout ensure that only one thread has access to that
<FromGitter>
<naqvis> Mutex is required when you are dealing with shared data
<devoid_>
I've been using --ignore-crystal-version with shards update to get around the problem, and it does work fine. So if there are no better options I might see if the author can update it
<FromGitter>
<naqvis> if only shared data is connection pool, then you don't, as connection pool is taking care of its business
<FromGitter>
<Dan-Do> yeah, but the data is not correctly written.
<FromGitter>
<naqvis> how are you writing that data?
<FromGitter>
<naqvis> are you using shared state when you are inserting data?
<FromGitter>
<naqvis> if you are getting some rambled insertions, there is huge change that you are using shared state
<FromGitter>
<Dan-Do> No, I don't use shared state. I thought because there is only one conn instance is executing `query` at one time, the data is safe
<FromGitter>
<naqvis> you are using a pool of connections, don't know why you are assuming there is only one conn instance?
<FromGitter>
<naqvis> provided you have set the pool limit to 1 conn
<FromGitter>
<Dan-Do> I mean there are many conns are created in the pool, but they have theirs own memory to store variable data
<FromGitter>
<naqvis> and if you need to ensure that there is always only one writer to DB, don't think you will need to go through concurrency/parallelism path at all
<FromGitter>
<Dan-Do> I don't use DB, just create a small class to test
<FromGitter>
<naqvis> Pool means shares the resource
<FromGitter>
<naqvis> and in your example, that mean shares your `Connection` instance
<FromGitter>
<naqvis> Pool is used when you are dealing with expensive operations
<FromGitter>
<naqvis> DB connection is an expensive operation, so instead of creating/releasing connection for each and every call to DB, people tend to use same connection
<FromGitter>
<Dan-Do> but 2 fibers can not use one conn at a time right. Once `fiber1` checked out `conn1`, then `conn1` cannot be checked out be any other fibers until the query is completed (and resource is released)
<FromGitter>
<Dan-Do> *be -> by
<FromGitter>
<naqvis> true
<FromGitter>
<Dan-Do> so why this fiber can interfere data other fiber
<FromGitter>
<naqvis> its not, but its because when one fiber done with work, return it back to pool, another fiber use the same instance
<FromGitter>
<naqvis> and this instance already have initialized state
<FromGitter>
<Dan-Do> Your String.build has same issue
<FromGitter>
<Dan-Do> `"conn id 17393926773938212611 before query\nco"nn cdn 17 9319276677838c33126411a 2tef7qu0qyer\6"1"conn id 17393926773938212611 before query\nco"nn cdn 17 9319276677838c33126411a 2tef7qu0qyer\6"17\77on8 3 be0fo1r2e 9q3u1e144y3 afte\nqceonn "i"conn id 17393926773938212611 before query\nco"nn cdn 17 9319276677838c33126411a 2tef7qu0qyer\6"17\77on8 3 be0fo1r2e 9q3u1e144y3 afte\nqceonn "id 7823277008061177583
<FromGitter>
... after query\n"`
<hholst6543>
Is there a way to build a static binary by specifying some options in shard.yml?
<hholst6543>
i just found switches how to do it via crystal directly
<FromGitter>
<Daniel-Worrall> no, you'd have to shards build -static
<hholst6543>
ok fair enough
<FromGitter>
<Blacksmoke16> Ideally within Alpine Linux, e.g via docker
<FromGitter>
<Blacksmoke16> Is the easiest way to get fully statically linked binaries
Guest64 has joined #crystal-lang
Guest64 has quit [Client Quit]
<FromGitter>
<wyhaines> @ddd you do have a shared resource. It's your screen. You are running in multithreaded mode, right? Which means that you can have multiple threads sending output to your screen at the same time, and that is exactly what is happening in your code. ⏎ ⏎ Writing multithreaded code means that you have to protect your access to shared resources. Change your code so that you assign your conn.query to a local
<FromGitter>
... variable: `query = conn.query`. Then wrap just your prints inside a mutex synchronize block (both your query print and your finished print), and you will get the output that you expect.
<FromGitter>
<Dan-Do> Thanks @wyhaines , I turned off my laptop. I will try your guide tomorrow.
<FromGitter>
<Dan-Do> Btw, can I push the query result to an array?
<FromGitter>
<Dan-Do> a global array in main entry code
<FromGitter>
<Dan-Do> Then print to terminal after all fibers finished
deavmi_ has quit [Ping timeout: 268 seconds]
<hholst6543>
I'd love to hear how you think this code looks like to you, is it idiomatic CRLang style?
<FromGitter>
<Blacksmoke16> it'll write the json directly to the response, i.e. not load the entire JSON string into memory, just to write it
<hholst6543>
this is golden feedback, thanks a lot
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<Blacksmoke16> more of a personal pref thing, but i think `context.response.status_code = 500` could also be written as `context.response.status = :internal_server_error`
<FromGitter>
<Blacksmoke16> more of just an FYI
<FromGitter>
<Blacksmoke16> benefit of having the `State` struct is you can ofc define extra methods on it ⏎ ⏎ `if state.@ExitCode != 0 || !state.@Running` could become like `unless state.success?`
<FromGitter>
<Blacksmoke16> or something like that
arestifo has joined #crystal-lang
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
avane has joined #crystal-lang
hightower2 has joined #crystal-lang
<hightower2>
What's a good data type for representing a string essentially, but one that often receives 1 character updates anywhere within its content
<hightower2>
(updates == insertions/deletions)
<FromGitter>
<Blacksmoke16> `Array(Char)`?
<hightower2>
hm possibly... I'll check that option, thanks
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 245 seconds]
<hholst6543>
does crlang offer some kind of build config framework?
<hholst6543>
similar to .properties in java
<FromGitter>
<Blacksmoke16> not built in afaik
<FromGitter>
<Blacksmoke16> are some shards out there for handling configuration tho
<jhass>
you can define build time flags with -D but they don't have values
hholst6543 has quit [Ping timeout: 250 seconds]
<FromGitter>
<didactic-drunk> Supposed there's a possibly abandoned shard (https://github.com/noumar/base32) that I've forked and would like my fork to show up on shards.info & crystalshards.xyz until/if he returns. How would I go about doing that?
<FromGitter>
<Blacksmoke16> those two sites are just scraping things based on tags afaik, so should just work
<FromGitter>
<Blacksmoke16> i doubt there's a way on those sites to mark yours as a (temp) replacement tho, would appear as two unique shards, so would prob want to put something in the README
postmodern has joined #crystal-lang
dostoyevsky2 has quit [Quit: leaving]
dostoyevsky2 has joined #crystal-lang
<hightower3>
yeah will show automatically
<hightower3>
but I believe all 2-3 of them (all except shards.info) only display shards that have been updated within 1 year
<hightower3>
so if that shard is abandoned it should eventually no longer be displayed. (which isn't always good... I missed a couple shards I searched on them because of that)
<FromGitter>
<rishavs> Just read this; `We have made significant steps towards Windows support, with the sockets library being almost ready. ` 💃
<FromGitter>
<Daniel-Worrall> yeah, straight-shoota been bangin' out code
<FromGitter>
<rishavs> that's awesome!
<FromGitter>
<didactic-drunk> @Blacksmoke16 crystalshards ignores forks. I think shards.info keeps a database rather than querying github. Perhaps there's a way to get mine in?
<FromGitter>
<Blacksmoke16> Ahh does it? Not sure in that case then :/
<FromGitter>
<wyhaines> @didactic-drunk I have wondered the same thing.
<FromGitter>
<wyhaines> @rishavs Did you see my comment on the message from last week? If you still want to do it, there is now a shard that you can use to serialize/deserialize between hashes and classes or structs, like JSON::Serializable or YAML::Serializable.