RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
Raimondi has quit [Quit: WeeChat 2.3: ¡Chau!]
return0e has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
DmitryBochkarev has joined #crystal-lang
DmitryBochkarev has quit [Remote host closed the connection]
DmitryBochkarev has joined #crystal-lang
DmitryBochkarev_ has joined #crystal-lang
DmitryBochkarev has quit [Ping timeout: 268 seconds]
return0e has quit [Ping timeout: 255 seconds]
hightower3 has joined #crystal-lang
return0e has joined #crystal-lang
<FromGitter> <bew> @tenebrousedge I think you most likely want `each_char.cons` to avoid creating intermediate arrays (`chars` will allocate)
<FromGitter> <bew> Btw, why do we have all those aliases in https://github.com/crystal-lang/crystal/blob/60760a5460aa13a1f80c5a1a7410782dc4076b77/src/iterable.cr ? instead of requiring the user to explicitly do `each.some_method`?
DmitryBochkarev_ has quit [Quit: Leaving]
DmitryBochkarev has joined #crystal-lang
DmitryBochkarev has quit [Max SendQ exceeded]
DmitryBochkarev has joined #crystal-lang
DmitryBochkarev has quit [Max SendQ exceeded]
ashirase has quit [Ping timeout: 244 seconds]
ashirase has joined #crystal-lang
<FromGitter> <r00ster91> Probably for better readability and consistency with other underscore methods
sz0 has joined #crystal-lang
DmitryBochkarev has joined #crystal-lang
<FromGitter> <r00ster91> ```Error in line 1: can only use 'private' for macros``` ⏎ ⏎ Why can't I use `protected` for macros? I don't see why this shouldn't be allowed [https://gitter.im/crystal-lang/crystal?at=5ca5dd21f851ee043d5d42b8]
<jokke> heya
<jokke> any alternatives to gitbook?
<jokke> seems like the gitbook cli is deprecated
<jokke> oh mdbook looks cool
tdc has quit [Ping timeout: 245 seconds]
hightower3 has quit [Ping timeout: 246 seconds]
DmitryBochkarev has quit [Remote host closed the connection]
tdc has joined #crystal-lang
DTZUZO has joined #crystal-lang
DmitryBochkarev has joined #crystal-lang
tdc has quit [Remote host closed the connection]
tdc has joined #crystal-lang
DmitryBochkarev_ has joined #crystal-lang
DmitryBochkarev has quit [Ping timeout: 250 seconds]
hightower2 has joined #crystal-lang
<FromGitter> <straight-shoota> Jekyll (or any other static site generator) is also great for documentation
Liothen has quit [Ping timeout: 250 seconds]
Liothen has joined #crystal-lang
moei has joined #crystal-lang
DTZUZO has quit [Ping timeout: 244 seconds]
hightower2 has quit [Ping timeout: 246 seconds]
lucasb has joined #crystal-lang
<FromGitter> <drum445> Is there a way to get an array of files in a given directory sorted by created date please?
DmitryBochkarev_ has quit [Ping timeout: 255 seconds]
<FromGitter> <drum445> File.stat used to show time, it doens't exist now though
<FromGitter> <r00ster91> It has been replaced by `File.info(file)`
<FromGitter> <drum445> cheers, @r00ster91. I must be blind
<FromGitter> <r00ster91> you're welcome
<FromGitter> <j8r> there is no creation time, just modification time :(
<FromGitter> <r00ster91> Ed are you sure `File.stat` used to show the creation time and not the modification time?
<FromGitter> <j8r> just Access, Modify and Change
<FromGitter> <j8r> interestingly there is a Birth field
<FromGitter> <r00ster91> where? but Crystal doesn't access it?
<FromGitter> <j8r> I've seen this fields when using `stat` on a file
<FromGitter> <bew> > `ctime` is usually not what people want or think it is (they want `btime` which basically no filesystems support)
<FromGitter> <bew> If you need it, I think you can reopen the discussion about it by making an issue on github
<FromGitter> <bew> @drum445 ☝️ (@j8r)
<FromGitter> <j8r> Oh... I remember this discussion, thanks for the reference @bew
DmitryBochkarev_ has joined #crystal-lang
<FromGitter> <drum445> can't find a quick way to grab the latest file
<FromGitter> <drum445> dir could have 10ks
ua has quit [Excess Flood]
DTZUZO has joined #crystal-lang
ua has joined #crystal-lang
<FromGitter> <j8r> after appending ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ to `String`, I got `Error opening file '/app/s/r/c/c/o/m/p/i/l/e/r/c/r/y/s/t/a/l/c/r' with mode 'r': No such file or directory (Errno) ... [https://gitter.im/crystal-lang/crystal?at=5ca627b693fb4a7dc2d32132]
<FromGitter> <silmanduin66> hello i need help with databases . I m using granite and it s working so far for my small chat app with just one chat group . My database has a table which stores messages. Now i want to expand my app and let user create group chat. My question: how should i model that ? Can i just let users create / remove tables in my database? How do people usually programmate that?
<FromGitter> <j8r> users have specific rights on specific tables
<FromGitter> <j8r> and usually that's the app that deal with use permissions
<FromGitter> <j8r> usually the interactions are done through an API
<FromGitter> <silmanduin66> giving rights to specifc users is actually not a concern for me i can do that, the problem was that i saw on some forums people saying : "tables are used to defines types and rows are used to stores instances"
<FromGitter> <j8r> maybe, I don't SQL. What can I say is better having a safe API that is database agnostic
<FromGitter> <j8r> you can take ideas from https://matrix.org/docs/api/client-server/
<FromGitter> <tenebrousedge> tables = types and rows = instances is probably a reasonable analogy
<FromGitter> <tenebrousedge> probably a good start would be to have a "Groups" table
<FromGitter> <tenebrousedge> messages could have a "group_id", which would be a foreign key reference to the `groups` table
<FromGitter> <tenebrousedge> this is just a personal project, right? @silmanduin66
<FromGitter> <silmanduin66> yes it s my project
<FromGitter> <silmanduin66> but if i have 100 groups and 1 million messages it would be hard to manage right ? ( it won t happen but i try to understand the theory )
<FromGitter> <tenebrousedge> a million rows isn't "lots" for a database, but yes, with bigger numbers you would have lots of performance issues
<FromGitter> <silmanduin66> or should i create a database for each group ?
<FromGitter> <tenebrousedge> it's not really a good idea to design an app for a scale it won't operate on. Usually you can't plan that far ahead. The problems of the app with 100 users are not the same kind of problems as the app with 100M users. A full-scale chat app would probably want to look into distributing large chunks of the db to different geographical locations, because users will tend to be in the same place most of the
<FromGitter> ... time
<FromGitter> <tenebrousedge> but, if you design a good API, your chat client and most of the rest of the code won't have to care how your database servers are arranged
<FromGitter> <silmanduin66> hmm i get the idea that it should depend on the size of the product , but i still don t understand the theory behind thoses models. I have the same problem about a game that lets users create / remove countries ( in a fiction world ) and each country has a list of cities.
<FromGitter> <Blacksmoke16> prob could have a group table, that holds data about that, then a table that matches users to a group
<FromGitter> <silmanduin66> i m stuck at the same point
<FromGitter> <Blacksmoke16> where messages table would have `group_id` column that is either the group that message is from, or null if its not part of a group message?
<FromGitter> <Blacksmoke16> would need a mapping table since it would be many to many
<FromGitter> <silmanduin66> i think that it should work, but what if there are millions of message, and i want to get all the messages of 1 single group, i dont want to loop through all messages right ?
<FromGitter> <Blacksmoke16> thats what the `group_id` column would be for
<FromGitter> <tenebrousedge> you would want an index on the group_id column for best performance
<FromGitter> <Blacksmoke16> would do like `group.messages` which would be like `SELECT * from messages where group_id = ?`
<FromGitter> <Blacksmoke16> would be a FK so would have one inherently
<FromGitter> <tenebrousedge> the db may do that automatically for a foreign key index
<FromGitter> <Blacksmoke16> ey
<FromGitter> <silmanduin66> ok , so in this model i can keep all messages in a single table ?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <tenebrousedge> for a while :)
<FromGitter> <silmanduin66> ok ill try that :-D
<FromGitter> <Blacksmoke16> i mean eventually you could prob use like hadoop or something maybe?
<FromGitter> <Blacksmoke16> sounds good
DmitryBochkarev_ has quit [Ping timeout: 255 seconds]
<FromGitter> <Blacksmoke16> https://www.sqa.org.uk/e-learning/SoftDevRDS02CD/page_13.htm#UNF wouldn't hurt to understand normalization if you don't already. This site has a good example of what it is, and process of normalizing is like
<FromGitter> <Blacksmoke16> it really helped me make a better DB, much easier to maintain
<FromGitter> <silmanduin66> i have actually no idea about all that but i m willing to learn so why not but later :-D
<FromGitter> <Blacksmoke16> well if you're redoing your DB anyway it would be helpful to keep that in mind
DmitryBochkarev_ has joined #crystal-lang
DmitryBochkarev_ has quit [Max SendQ exceeded]
<FromGitter> <Blacksmoke16> the main jist of it is to move data to other tables so that it is only defined in one place in one row, then everything else that uses it, just uses the reference to that one other row
<FromGitter> <Blacksmoke16> granted, it also depends on use cases of what makes sense/how far to go. but is worth understanding
<FromGitter> <Blacksmoke16> https://www.sqa.org.uk/e-learning/SoftDevRDS02CD/page_17.htm#NormProcess2 sorry this is the correct link
<FromGitter> <tenebrousedge> "don't story any value twice" is a good rule of thumb. Usually you only run into problems with this at large scale
<FromGitter> <silmanduin66> ok thanks for your help ^^
rohitpaulk has joined #crystal-lang
ua has quit [Excess Flood]
DTZUZO has quit [Ping timeout: 250 seconds]
rohitpaulk has quit [Remote host closed the connection]
ua has joined #crystal-lang
tdc has quit [Quit: Leaving]
Jenz has joined #crystal-lang
<Jenz> Crystal/Ruby interop would be amazing
<Jenz> I mean, *really* amazing
<FromGitter> <tenebrousedge> it would certainly be interesting. How would that work, though?
<Jenz> Well, I dunno, I just thought it'd be amazing! XD
<Jenz> Is there some C library for embedding ruby?
<Jenz> I'd be suprised if there wasn't
<Jenz> Actually, that's probably a stupid question, of course there is such a thing
<FromGitter> <Blacksmoke16> added a new section based on some feedback i got from @jwoertink
rohitpaulk has joined #crystal-lang
* Jenz :D
<FromGitter> <j8r> Jenz: you can embed mruby, what remains is bindings
<FromGitter> <Blacksmoke16> enjoy jenz 😉
<FromGitter> <bew> I know there is someone who did an experiment, and wrote a ruby extension in Crystal
<FromGitter> <bew> *someone did
<FromGitter> <jwoertink> sweet. Thanks @Blacksmoke16
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <Blacksmoke16> np, feel free to ask any questions ofc
sz0 has quit [Quit: Connection closed for inactivity]
rohitpaulk has quit [Remote host closed the connection]
Jenz has quit [Quit: Lost terminal]
Jenz has joined #crystal-lang
Jenz has quit [Ping timeout: 245 seconds]
lucasb has joined #crystal-lang
olbat has quit [Quit: Bye ...]
hightower2 has joined #crystal-lang
olbat has joined #crystal-lang
<hightower2> hi olbat
<olbat> hi :)
<FromGitter> <ryanstout> @<Jenz> I've been working on a ruby extension using ruby-ffi and ```fun``` in the global scope in crystal
<FromGitter> <ryanstout> works pretty well
<FromGitter> <ryanstout> I was thinking of using crystal macros to automatically create a file for the ffi code on the ruby side. (and maybe releasing that as a shard)
<FromGitter> <ryanstout> I know there were a few projects to do ruby<->crystal integration, but none of them seemed to be active or that far along
sagax has joined #crystal-lang
moei has quit [Quit: Leaving...]
hightower2 has quit [Ping timeout: 246 seconds]
_whitelogger has joined #crystal-lang