<FromGitter>
<Blacksmoke16> 1) 27.2 is the newest as well
<FromGitter>
<sam0x17> yes :/
<FromGitter>
<sam0x17> alpine is how everyone does static compilation, so I'm surprised it takes so long to get newer versions
<FromGitter>
<Blacksmoke16> indeed
fanta7531 has joined #crystal-lang
<FromGitter>
<Sija> @sam0x17 shouldn't be surprising that much, given the limited amount of resources Manas has, packages (aside of most popular ones, i.e. debian and homebrew) are solely maintained by their respective maintainers
<FromGitter>
<Sija> I'd love for one having nightlies working in Travis CI, but it still didn't happen and who knows when (or if) it will...
<mps>
sam0x17: test fails for 0.27.1 and 0.27.2 on Alpine, need fix in crystal
<mps>
it couldn't pass abuild check, so couldn't be upgraded in Alpine
<FromGitter>
<awws_twitter> Does anyone have any good pointers to a post on reading a yaml file (essentually an array of hashes) and transforming/pouring that into a struct of the same format? I am definitely doing something wrong here that woud work in ruby or elixir but assuming the type safety is casuing issues (ie. the types are the same but because I've defined the Array as a an array of struct X where struct X is a string: i32
<FromGitter>
... and then tried to load in the yaml into thar structure it's really really not liking it. Think I just need to see some canonical examples.
wakatara has joined #crystal-lang
wakatara has quit []
<FromGitter>
<girng> @sdogruyol eve online maybe?
<FromGitter>
<sdogruyol> :shrug: how's your game going on @girng ?
<FromGitter>
<j8r> mps is it the issue about encoding?
<mps>
j8r: failed tests? something with XML, iirc
<mps>
could be encoding with XML
<mps>
probably RX14 and straight-shoota could give better answers than I
<FromGitter>
<delef> Hi! Tell me how to remove Slice(UInt8) from memory? I work with a large binary database and I want to clear the memory of it after I do the parsing.
<FromGitter>
<maiha> `GC.collect` ?
<FromGitter>
<delef> @maiha I need to remove from memory only Slice(UInt8), will it help?
<FromGitter>
<silmanduin66> Hello i just started with a crystal websocket chat , my idea was to keep the messages in a database using granite and postgresql. Is this the right way to do this ? and what is the limit of messages that can fit into such database ?
<FromGitter>
<dscottboggs_gitlab> @delef if you're super insistent on controlling when you free a section of memory, you could use unsafe code for that section, but if you're going to do that I would recommend using a class to allow the GC to make sure your unsafe code is handled right. For example (I'm not super experienced at unsafe code so maybe it's not perfect) something like this: ⏎ ⏎ ```code paste, see link```
<FromGitter>
<j8r> @asterite I still don't get why you create a merge commit for single commit PRs... :|
marmotini_ has quit [Ping timeout: 245 seconds]
jemc has quit [Quit: WeeChat 2.2]
<FromGitter>
<yxhuvud> Because it is nice to see the meta info of that merge commit, like the PR number.
<FromGitter>
<yxhuvud> I wish github would have an option to rebase merges, but with `no-ff` flag set
rohitpaulk has quit [Ping timeout: 246 seconds]
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
marmotini_ has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter>
<asterite> @j8r I'm not in charge :-)
<FromGitter>
<j8r> I guess it's because someone haven't change the default merge option in GitHub
<FromGitter>
<j8r> I usually set it to rebase and merge, often that's what I want :)
<FromGitter>
<j8r> else it's a pain to search in the history with all this merge commits :(
<FromGitter>
<asterite> My understanding is that they explicitly removed the "rebase" option... for some reason
<FromGitter>
<j8r> or squash and merge?
<FromGitter>
<asterite> I like rebase
<FromGitter>
<j8r> for one commit PRs, rebase and squash is the same
<FromGitter>
<j8r> me too
<Yxhuvud>
rebase is nice, bit for multi commit PRs, it is not as nice as they can't be reverted in one go. hence, the need for rebase but no-ff
marmotini_ has quit [Ping timeout: 272 seconds]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Ping timeout: 246 seconds]
marmotini_ has joined #crystal-lang
oz has quit [Quit: EOF]
marmotini has joined #crystal-lang
marmotini_ has quit [Ping timeout: 246 seconds]
oz has joined #crystal-lang
marmotini has quit [Ping timeout: 250 seconds]
<FromGitter>
<Blacksmoke16> well the type of `subject` is different
<FromGitter>
<Blacksmoke16> in each module
<FromGitter>
<Blacksmoke16> hence the error you get
<FromGitter>
<Blacksmoke16> its a compile error saying, hey, you need to make sure this variable is the type you are expecting, as you cant call `hi` on type `String`
<FromGitter>
<hanneskaeufler> I get that, but `subject` is only a string in `A::B`, not `A::C`
<FromGitter>
<hanneskaeufler> Does that var get implicitly defined on `A` somehow?
<FromGitter>
<hanneskaeufler> Or is it simply a local variable not at all attached to a module? In which case I would understand the error and the fact that it runs when inside two separate files ...?
<FromGitter>
<dscottboggs_gitlab> what are they scoped to then?
<FromGitter>
<hanneskaeufler> *files* I guess? :D
<z64>
the issue in your code is that the union is introduced by closuring `subject` https://carc.in/#/r/6afm
<FromGitter>
<hanneskaeufler> Huh, now you lost me :D
<z64>
basically, when you write `it "foo" do..` you're registering a piece of code to be run *some time* at runtime. the compiler doesn't know when it will be executed. since "subject" is essentially global, it sees at one point you assign it as String, and at one point you assign it as Foo
<FromGitter>
<hanneskaeufler> So coming back around: I see that pattern used sometimes `subject = ...` in specs, and when I copy & paste multiple specs into a single file, that blows up
<FromGitter>
<hanneskaeufler> yeah okay thats more minimal
<z64>
well, i'd have to see a specific case. but in general, you have a few options. one is to not closure subject; i.e., subject is defined completely in scope of the spec block https://carc.in/#/r/6ag0
<z64>
another is to have `subject` be a method, which is actually scoped to the module https://carc.in/#/r/6ag3
<z64>
lastly, you can just give subjects special names. `b_subject = ..`, `a_subject = ..`
<FromGitter>
<hanneskaeufler> yep thanks for the suggestions!
<z64>
or i guess, if you keep specs organized by one type -> one file, `subject` will generally always be a single type, in which case it won't be an issue to share `subject` between tests
<z64>
yw
<FromGitter>
<hanneskaeufler> My problem is I'm running a third party tool over code that isn't under my control haha
<FromGitter>
<hanneskaeufler> Can I ... rescope files?
<FromGitter>
<hanneskaeufler> like in javascript I'd wrap files in a self-invoking function `(..)()` or something
<z64>
i don't really know what that means, but i'm inclined to say "no". `require` is a compiler mechanism, and is done once per file at compile time
<FromGitter>
<hanneskaeufler> That'd not be a problem, I am hooking into `require` through the ast :D
<z64>
what exactly is this...? i'm assuming some kind of code coverage tool?
<z64>
i imagine this is user code, and you don't want to expose any custom spec API so that everything works out of the box without any changes?
<z64>
@Blacksmoke16 not quite, you made changes inside of `module` :p
<FromGitter>
<Blacksmoke16> well something is going to have to change, running it a bunch of times isnt going to fix the problem :p
<FromGitter>
<hanneskaeufler> > *<z64>* i imagine this is user code, and you don't want to expose any custom spec API so that everything works out of the box without any changes? ⏎ Exactly that
<z64>
right, ok. yeah i'm not sure then. that's pretty brutal.
<FromGitter>
<hanneskaeufler> I'm just holding off running everything in a copied directory and writing the files back out for as long as possible
<FromGitter>
<hanneskaeufler> although thats probably the most compatible way ... :(
<FromGitter>
<hanneskaeufler> I started piping all the code into `crystal eval` at first, but that had it's own limitations
<FromGitter>
<asterite> variables anywhere in the top-level (inside modules, classes, etc.) all have the same scope. That's not very good, but that's how it is right now
<FromGitter>
<dscottboggs_gitlab> oh that's because I'm using `when` I see now
<FromGitter>
<dscottboggs_gitlab> > anywhere in the top-level (inside modules, classes, etc.) all have the same scope ⏎ ⏎ Oh I seee, that makes some sense, I was worried about cross-function variables being polluted, but if it's just top-levels then that's understandable
<z64>
i think the only reasonable thing you can do right now is just ask users to use meaningful names other than just "subject" everywhere. even if you have many specs, this is just a simple search/replace per-file. maybe there is a deeper hack you could do, but that's the best "workaround"..
<FromGitter>
<Blacksmoke16> or wrap everything in begin/end and use the fresh variable macro thing https://carc.in/#/r/6agp
<FromGitter>
<dscottboggs_gitlab> beat me to it by a second lol
<z64>
no, they can't change the users variables to fresh variables
<z64>
they are taking specs that someone has *already written* - they could be in any form, using any kind of convention or practice for writing specs
<FromGitter>
<Blacksmoke16> ah
<FromGitter>
<Blacksmoke16> hrm
<FromGitter>
<hanneskaeufler> yeah I'm trying to keep the specs *as is*, because it is after all valid crystal
<FromGitter>
<Blacksmoke16> yea, top level vars would be an issue if they conflict
<FromGitter>
<Blacksmoke16> if everything is within a like `describe` block that scopes the var
<FromGitter>
<dscottboggs_gitlab> I think you'd have to reimplement `describe` or `it` with your feature added?
<FromGitter>
<Blacksmoke16> or like how does this user code get into your modules?
<FromGitter>
<hanneskaeufler> Those modules aren't mine either
<FromGitter>
<hanneskaeufler> many crystal users write specs in modules though
<FromGitter>
<hanneskaeufler> makes them read less verbose
<FromGitter>
<hanneskaeufler> because the class names get much shorter if you use modules as namespaces
<FromGitter>
<silmanduin66> can someone tell me how to pass an array of value from crystal to javascript ( in the amber framework ) . For the moment i can only pass them by rendering them using slang and then access them with javascript . Is there a direct/ faster way to do it ?
sevensidedmarble has quit [Quit: Leaving]
<FromGitter>
<dscottboggs_gitlab> you can render the JSON, or connect to Amber using the amber.js library which allows you to communicate over websockets
<FromGitter>
<dscottboggs_gitlab> Or you could have the JS make an XHR to the server and get the data as a JSON response
<FromGitter>
<dscottboggs_gitlab> The last one is how I do it in flix.cr -- the web page is downloaded to the browser, displays a basic loading screen, then reaches out to the server for JSON-formatted application state
<FromGitter>
<silmanduin66> i'm using websockets for a chat , i want to the user access to maybe 20 messages that are in the database
<FromGitter>
<silmanduin66> yes using amber.js for now
<FromGitter>
<dscottboggs_gitlab> yeah if you already have a websocket connection, just send a message to the server (protocol is up to you) and pull the array across that as json
<FromGitter>
<silmanduin66> oh i see
<FromGitter>
<silmanduin66> thank you ill try that
<FromGitter>
<dscottboggs_gitlab> I should probably switch flix.cr to websockets for performance's sake... hm...
<FromGitter>
<kingsleyh> hey - how can I supply my own to_json for an Enum - I put a def to_json method on the Enum but it seems to ignore it
<z64>
how exactly are you defining it? it needs to be like `def to_json(builder : JSON::Builder)`, and then you write your values to that builder
<FromGitter>
<kingsleyh> oh I did't supply any paramter
<z64>
yeah. `#to_json` (with no parameter) is already defined on every type. that method is usually called - by you - on the outermost type, which internally makes a new `JSON::Builder` and passes it around via `#to_json(builder)` to that types components (or itself)
<FromGitter>
<kingsleyh> how do I access the value as a string within the to_json?
<FromGitter>
<dscottboggs_gitlab> @Sija thanks, I didn't know about that
<z64>
just as you would with an enum instance - to_s
<FromGitter>
<girng> i just saved a few lines of redundant code!
<FromGitter>
<girng> wow, i did about 85% of my marketplace code in php (listing, searching mod affixes, your item listings, sort by price and item affix values, cancel listing, etc). now, i'm doing the purchasing and retrieving an item (insert to inventory) on the gameserver. the simplicity of crystal DB's API is AMAZING compared to what i just coded in php 😆