ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.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
<FromGitter> <Blacksmoke16> oh
<FromGitter> <Blacksmoke16> crystal handles it for me
<FromGitter> <tenebrousedge> o.o
<FromGitter> <tenebrousedge> yay Crystal ?
<FromGitter> <Blacksmoke16> by handle it for me i mean it knows to not return the body
<FromGitter> <Blacksmoke16> so i can just define another action thats the same as the GET version
<FromGitter> <tenebrousedge> yay! :D
<FromGitter> <Blacksmoke16> Yea, makes my life easier
Nicolab has quit [Quit: Leaving.]
alex`` has quit [Quit: WeeChat 2.7]
ur5us has quit [Ping timeout: 260 seconds]
<sorcus> Good night everyone.
ur5us has joined #crystal-lang
_whitelogger has joined #crystal-lang
return0e has quit []
gangstacat has quit [Ping timeout: 248 seconds]
uu91 has quit [Remote host closed the connection]
gangstacat has joined #crystal-lang
duane has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter> <spTorin> How I can build crystal project without type filename.cr? Just `crystal build` in project dir don't work.
<FromGitter> <Blacksmoke16> then `shards build`
gangstacat has quit [Quit: Ĝis!]
<FromGitter> <grkek> @Blacksmoke16 how does granite handle the connections ? If I make a connection is it stored in the global scope ?
<FromGitter> <Blacksmoke16> is added to there
gangstacat has joined #crystal-lang
<FromGitter> <grkek> So as long as I require granite in some file I am able to access the connection right ?
<FromGitter> <spTorin> Oh, I see. If needed to compile one file - `crystal build`. If need build project - always use `shards build`. Tnx!
<FromGitter> <Blacksmoke16> should be fine yea, its defined on the class level
<FromGitter> <grkek> Nice
<FromGitter> <Blacksmoke16> by default if you dont supply a connection in your model it'll use the first
<FromGitter> <grkek> I also have weird errors when trying to shard install the deps
<FromGitter> <Blacksmoke16> about `crystal-db`?
<FromGitter> <grkek> yeah
<FromGitter> <grkek> couldn't resolve db ~> 0.7.0
<FromGitter> <grkek> 1) 8.0
<FromGitter> <grkek> you're a hero
<FromGitter> <Blacksmoke16> i try
<FromGitter> <grkek> thank you a lot
<FromGitter> <Blacksmoke16> @spTorin yea `crystal build` will compile a (single?) file, however `shards build` also does additional things like installing dependencies if needed
<FromGitter> <Blacksmoke16> before building each target
<FromGitter> <Blacksmoke16> `shards build --production` will not install develop dependencies for example
<FromGitter> <Blacksmoke16> as well as adding the `--release` flag
<FromGitter> <grkek> the --release flag is so tasty mmh
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16b4c0559755189046b5a8]
<FromGitter> <grkek> is this a known issue some sort of ?
<FromGitter> <grkek> @Blacksmoke16
<FromGitter> <Blacksmoke16> did you include an adapter?
<FromGitter> <Blacksmoke16> require*
<FromGitter> <grkek> oh my I forgot that
<FromGitter> <grkek> :D
<FromGitter> <Blacksmoke16> that would do it
<FromGitter> <grkek> Yeah it worked nicely
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <grkek> what is the engine for sqlite ?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <grkek> `User.migrator(table_options: "ENGINE=InnoDB DEFAULT CHARSET=utf8").create`
<FromGitter> <grkek> but for sqlite
<FromGitter> <grkek> that is for mysql right
<FromGitter> <grkek> ?
<FromGitter> <Blacksmoke16> yea
<FromGitter> <grkek> what does sqlite use
<FromGitter> <grkek> since I got this error
<FromGitter> <grkek> `no driver was registered for the schema "sqlite", did you maybe forget to require the database driver? (ArgumentError) ⏎ `
<FromGitter> <Blacksmoke16> no that means you didnt register a connection
<FromGitter> <Blacksmoke16> er
<FromGitter> <Blacksmoke16> nvm
<FromGitter> <Blacksmoke16> did you install the sqlite shard?
<FromGitter> <grkek> yeah
<FromGitter> <Blacksmoke16> and did like `require "granite/adapter/sqlite"`?
<FromGitter> <grkek> yes
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16b7d93679536f9633718a]
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16b7e50ba7b60f2049f197]
<FromGitter> <grkek> these two are currently what I am using
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> same issue if you remove mysql/pg stuff?
<FromGitter> <grkek> w8
<FromGitter> <grkek> yup
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16b882559755189046cc4c]
<FromGitter> <Blacksmoke16> whats your shard.yml look like
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16b8afbdcaea18911faa04]
<FromGitter> <Blacksmoke16> that error is coming from `crystal-db` so its like the driver shards aren't being required correctly
<FromGitter> <grkek> I'll do an Shards update
<FromGitter> <grkek> w8
<FromGitter> <grkek> db 0.7.0
<FromGitter> <grkek> nope, same issue
<FromGitter> <Blacksmoke16> hrm
<FromGitter> <grkek> It's a bug I guess ?
<FromGitter> <Blacksmoke16> dunno, let me see if i can reproduce i guess
<FromGitter> <grkek> Go for it
duane has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> also happens on db 0.8.0
<FromGitter> <grkek> the same thing ?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> not sure whats up
<FromGitter> <grkek> well, my first bug discovered :D
<FromGitter> <Blacksmoke16> ohh
<FromGitter> <Blacksmoke16> your connection string needs to supply the "protocal"
<FromGitter> <grkek> the protocol ?
<FromGitter> <grkek> where ?
<FromGitter> <Blacksmoke16> `sqlite3:./data.db`
<FromGitter> <grkek> I do have that
<FromGitter> <grkek> sqlite://./db.sqlite3
<FromGitter> <grkek> does it have to be like
<FromGitter> <grkek> sqlite3:
<FromGitter> <grkek> ?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <grkek> oml this is so stupid
<FromGitter> <grkek> why
<FromGitter> <grkek> is there a version of sqlite
<FromGitter> <grkek> other than 3
<FromGitter> <Blacksmoke16> prob 1 and 2? :p
<FromGitter> <grkek> used widely as the 3rd
<FromGitter> <grkek> Okay it worked nicely now
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <grkek> yet again a hero we need but we dont deserve
<FromGitter> <Blacksmoke16> you flatter me
<FromGitter> <grkek> global variables
<FromGitter> <grkek> are no where to be found ?
<FromGitter> <grkek> like does crystal not support them ?
<FromGitter> <Blacksmoke16> no
<FromGitter> <Blacksmoke16> can use a module with some class methods tho
<FromGitter> <Blacksmoke16> what are you trying to do?
<FromGitter> <grkek> nothing just interested
<FromGitter> <grkek> also wouldn't it be better to use structs for granite models ?
<FromGitter> <Blacksmoke16> no, because they should be mutable
<FromGitter> <grkek> oh right the struct is immutable
<FromGitter> <grkek> My framework went from 90k rps
<FromGitter> <grkek> to 124 in couple of secs
<FromGitter> <grkek> when I tried to create a db entry for each
<FromGitter> <grkek> request
<FromGitter> <grkek> I fucking hate sql databases and would love to use a built in one
<FromGitter> <grkek> a key/value one to be specific
<FromGitter> <grkek> like a leveldb
<FromGitter> <grkek> but that would mean no more multiple instances
<FromGitter> <Blacksmoke16> would always make a PR πŸ˜‰
<FromGitter> <Blacksmoke16> depending on what you're doing maybe use redis
<FromGitter> <Blacksmoke16> 124 sounds quite slow tho
<FromGitter> <Blacksmoke16> what are you doing?
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16c0f6821b826f5a8d187e]
<FromGitter> <grkek> its not the frameworks fault probably
<FromGitter> <grkek> t. not the sql guy
<FromGitter> <Blacksmoke16> you can do `Post.create name: "foo", body: "bar"` btw
<FromGitter> <Blacksmoke16> news it up with those args then saves it and returns the saved instance
<FromGitter> <grkek> damn nice
<FromGitter> <grkek> but yeah
<FromGitter> <grkek> 124 too slow
<FromGitter> <grkek> I might just go with levels db and no-sql
<FromGitter> <Blacksmoke16> why bother implementing a DB in the first place, leave it up for the user to decide which they want
<FromGitter> <grkek> Is postgres any faster
<FromGitter> <grkek> since this is a direct IO
<FromGitter> <grkek> operation
<FromGitter> <grkek> Same speed
<FromGitter> <grkek> :D
<FromGitter> <grkek> well this has been a great journey
<FromGitter> <grkek> my friends but I have to kill myself now
<FromGitter> <grkek> ill try with preview_mt now
<FromGitter> <grkek> it got worse
<FromGitter> <grkek> its at 41 now
<FromGitter> <grkek> why do sql databases even exist
ht_ has joined #crystal-lang
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16c36a3679536f9633ba56]
<FromGitter> <grkek> now that is tasty
ht_ has quit [Remote host closed the connection]
<FromGitter> <grkek> 22k for writes
<FromGitter> <grkek> damn nice
<FromGitter> <grkek> beat the minikeyvalue storage
<FromGitter> <grkek> george hotz made :D
return0e has joined #crystal-lang
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16d38691129970ca957b15]
<FromGitter> <grkek> this is what I came up with
<FromGitter> <grkek> `connection :database`
<FromGitter> <grkek> the symbol is treated as the path of the database
<FromGitter> <grkek> you can also pre-define it in a global context instead of accessing it directly
<FromGitter> <grkek> if you misspell the defined database and the connection a warning message will pop up
<FromGitter> <grkek> changed it to storage
<FromGitter> <grkek> so it is more explicit via naming
<FromGitter> <grkek> connection seemd a bit confusing :D
<FromGitter> <grkek> and decided to use json serializers
<FromGitter> <grkek> as my models
<FromGitter> <codenoid> very cool
<FromGitter> <grkek> @codenoid
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16db5b9c13050f1f9c9e51]
<FromGitter> <grkek> updated it
yukai has quit [Ping timeout: 268 seconds]
ur5us has joined #crystal-lang
Nicolab has joined #crystal-lang
<FromGitter> <Nicolab> Hello
<FromGitter> <grkek> Hi @Nicolab
uu91 has joined #crystal-lang
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16f42f3679536f9635028f]
<FromGitter> <grkek> the storage symbol acts as a path to the database
<FromGitter> <grkek> so basically doing this
<FromGitter> <grkek> `:"database_name/example"`
<FromGitter> <grkek> acts as if it were a table in the database
<FromGitter> <grkek> but in reality it creates another database in the database folder
<FromGitter> <j8r> little advice: avoid symbols, they are not type-safe
<FromGitter> <grkek> and if you want to access data from two tables you would do something like this
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16f4d1a74ac853777b743c]
<FromGitter> <grkek> the thing is that I convert the symbols to strings at the end so it doesn't matter
<FromGitter> <grkek> redefine the storage
<FromGitter> <grkek> to overwrite the previous definition
<FromGitter> <grkek> idk
<FromGitter> <grkek> if that looks awful
<FromGitter> <grkek> then you can do this
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e16f585c3950349026cca2e]
<FromGitter> <grkek> is it okay to use begin / rescue since I've had many warnings about avoiding begin
<FromGitter> <grkek> from ameba
<FromGitter> <grkek> @j8r
<FromGitter> <j8r> @grkek use strings then
<FromGitter> <j8r> using symbols to convert to strings is useless
<FromGitter> <grkek> hm
<FromGitter> <grkek> you are right
<FromGitter> <grkek> I thought it looked cool
<FromGitter> <grkek> :D
<FromGitter> <grkek> and it can be typed faster than strings
<FromGitter> <grkek> : <- one symbol
<FromGitter> <grkek> "" <- two symbols
<FromGitter> <grkek> nah I like symbols
<FromGitter> <grkek> ill let them in
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter> <grkek> or not
<FromGitter> <grkek> see you manipulated me
<FromGitter> <grkek> :D
DTZUZO has joined #crystal-lang
<FromGitter> <grkek> how to remove a property from a class programatically ?
<FromGitter> <j8r> there is talk to remove them in the future
<FromGitter> <j8r> that's not idiomatic Crystal
<FromGitter> <j8r> you can remove a property from a class, no sure to understand?
<FromGitter> <j8r> for example, `:ok` can be: ⏎ ⏎ ```enum Status ⏎ Ok ⏎ Ko ⏎ end``` ⏎ ⏎ something like that [https://gitter.im/crystal-lang/crystal?at=5e170c7709534142ca37251f]
<FromGitter> <grkek> that is very sad
<FromGitter> <j8r> so one can see all possible values
<FromGitter> <grkek> I like symbols
<FromGitter> <grkek> for example I have a password field in a json mapped user object
<FromGitter> <grkek> and I don't want to display that password field
<FromGitter> <grkek> what do I do then ?
<FromGitter> <j8r> just an ivar?
<FromGitter> <grkek> ivar ?
<FromGitter> <grkek> instance var
<FromGitter> <j8r> instance variable
<FromGitter> <grkek> it is an instance variable yes
<FromGitter> <j8r> `@password : String`
<FromGitter> <grkek> when it receives a string it encodes
<FromGitter> <grkek> true I have that
<FromGitter> <j8r> it is not exposed then
<FromGitter> <grkek> how do I make it temporarily disappear
<FromGitter> <grkek> when it is converted to json
<FromGitter> <grkek> with mapping
<FromGitter> <grkek> it is
<FromGitter> <j8r> I guess you'll have to write a custom `to_json` that deletes the value
<FromGitter> <j8r> that do `@password = ""`
<FromGitter> <grkek> instant kms
<FromGitter> <j8r> let me try
<FromGitter> <j8r> ok you can just do it manually at the end?
<FromGitter> <grkek> How can I do it manually ?
<FromGitter> <grkek> I mean I want to but how
<FromGitter> <grkek> one option is that
<FromGitter> <grkek> custom to_json function
<FromGitter> <grkek> ill edit the mapping macro
<FromGitter> <j8r> but there is still the possibility to use the standard, unsafe one
<FromGitter> <j8r> bad idea to edit the macro
<FromGitter> <j8r> by custom method I mean one that is in the object
<FromGitter> <grkek> why is it a bad idea to edit the macro ?
<FromGitter> <j8r> of the stdlib?
<FromGitter> <grkek> yeah
<FromGitter> <j8r> by monkey-patching, it will impact every object, and everyone using your lib
<FromGitter> <grkek> I wont monkey-patch it
<FromGitter> <grkek> I will rename
<FromGitter> <grkek> and re-define
<FromGitter> <grkek> it
<FromGitter> <j8r> ha ok, but not necessary
<FromGitter> <j8r> jut call the method
<FromGitter> <grkek> what are your suggestions
<FromGitter> <j8r> and do after the call `@password = ""`
<FromGitter> <j8r> give me several minutes
<FromGitter> <j8r> brb
<FromGitter> <grkek> okay
alex`` has joined #crystal-lang
<FromGitter> <j8r> https://carc.in/#/r/8d2q
<FromGitter> <j8r> same thing with mapping
<FromGitter> <grkek> thats a nice solution
<FromGitter> <grkek> but I came up with something else
<FromGitter> <grkek> thank you anyways !
<FromGitter> <j8r> and you will have to maintain the method if you just copy-paste and edit the stdlib method
<FromGitter> <j8r> there are new features sometimes
<FromGitter> <grkek> Yes I know that I will have to maintain the method thank you !
<FromGitter> <j8r> np!
Nicolab has quit [Ping timeout: 258 seconds]
<FromGitter> <grkek> i did it the stdlib way
<FromGitter> <Blacksmoke16> there are some stdlib options but nothing as nice :(
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e172448e409da486cef86c7]
<FromGitter> <grkek> i made that
<FromGitter> <grkek> the schema is a rename of
<FromGitter> <grkek> JSON.mapping
<FromGitter> <grkek> :D
<FromGitter> <Blacksmoke16> oh boy, fair enough
<FromGitter> <grkek> if it has hidden: true it skips to render it
uu91 has quit [Remote host closed the connection]
<FromGitter> <grkek> but now it requires an additional .to_safe
<FromGitter> <grkek> method
<FromGitter> <grkek> by default to_json renders it with the password
<FromGitter> <grkek> ```code paste, see link``` ⏎ ⏎ When does it produce this ? [https://gitter.im/crystal-lang/crystal?at=5e1725259c13050f1f9e9962]
<FromGitter> <grkek> I dont quite remember the stdlib call
<FromGitter> <grkek> also I hate the double space indentation
<FromGitter> <grkek> WHY NOT JUS TUSE TABS
<FromGitter> <grkek> WHAT IS WRONG WITH THIS LANGUAGE
<FromGitter> <j8r> tabs has also issues
<FromGitter> <j8r> look at Makefile
<FromGitter> <grkek> @j8r do you have any solution except a JSON.parse
<FromGitter> <grkek> i mean is there anyway to convert back to an object
<FromGitter> <grkek> fro ma string of json
<FromGitter> <grkek> withotu parse
<FromGitter> <grkek> :D
<FromGitter> <j8r> `Object.from_json`
<FromGitter> <grkek> I will probably think about that
<FromGitter> <grkek> when Itry to improve the performance
<FromGitter> <grkek> How to check if a class has a method or not ?
<FromGitter> <grkek> the method I want to execute ?
<FromGitter> <grkek> liek for example if u have .to.json
<FromGitter> <grkek> or not
<FromGitter> <grkek> or something like that
<FromGitter> <j8r> why
<FromGitter> <grkek> I found it
<FromGitter> <grkek> its okay
<FromGitter> <grkek> thank you
<FromGitter> <grkek> anyways
<FromGitter> <j8r> duck typing?
<FromGitter> <grkek> or not
<FromGitter> <grkek> I mean I want to know if a class has a .to_safe method or not
<FromGitter> <j8r> `to_safe` for the json?
<FromGitter> <grkek> no
<FromGitter> <grkek> for a calss
<FromGitter> <grkek> class*
<FromGitter> <j8r> what does this method?
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e172c56bdcaea189122c2af]
<FromGitter> <grkek> something like this
<FromGitter> <grkek> if content[1] has to_safe method
<FromGitter> <grkek> call to_safe
<FromGitter> <j8r> but what is to_safe?
<FromGitter> <grkek> if not call to_json
<FromGitter> <grkek> to_safe is my own method
<FromGitter> <grkek> liek to_json
<FromGitter> <grkek> but removes the secret stuff
<FromGitter> <j8r> ok, so it does json stuff also
<FromGitter> <grkek> yeah
<FromGitter> <j8r> it could be in a module
<FromGitter> <j8r> then, include it to any object you need
<FromGitter> <grkek> it is in a module
<FromGitter> <grkek> yes
<FromGitter> <grkek> but I need to check
<FromGitter> <j8r> so check the module
<FromGitter> <grkek> if the passed in value has the method or not
<FromGitter> <grkek> how do I d othat ?
<FromGitter> <grkek> do*
<FromGitter> <j8r> `.is_a? MyModule` ⏎ If true, it means it has `to_safe`
<FromGitter> <grkek> Aw thats so sick
<FromGitter> <grkek> Error: undefined method 'to_safe' for String (compile-time type is (String | User))
<FromGitter> <grkek> :(
<FromGitter> <j8r> have you use an intermediary variable?
<FromGitter> <j8r> `first_content = content[1]`
<FromGitter> <grkek> yes i use that
<FromGitter> <j8r> strange, can you carc.in a reduced example?
<FromGitter> <grkek> hmmm cant really reduce it now
<FromGitter> <grkek> ill try to figure it out
<FromGitter> <j8r> it compiles https://carc.in/#/r/8d31
<FromGitter> <grkek> there is nothing in that
<FromGitter> <grkek> carcin
alexherbo2 has joined #crystal-lang
<FromGitter> <grkek> okay I did it :D
<FromGitter> <Blacksmoke16> `if obj.responds_to? :to_safe`
<FromGitter> <grkek> is that a thing ?
<FromGitter> <j8r> better to check types instead
<FromGitter> <j8r> imho, better for understanding
<FromGitter> <grkek> right
<FromGitter> <j8r> @grkek the carc.in compile
<FromGitter> <grkek> try two different types
<FromGitter> <grkek> oh
<FromGitter> <grkek> its two different types
<FromGitter> <grkek> this is interesting
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e1733c1a74ac853777d3819]
<FromGitter> <grkek> Error: undefined method 'to_safe' for String (compile-time type is (String | User)) ⏎ ⏎ Did you mean 'to_unsafe'?
<FromGitter> <j8r> as said above, an intermediary var has to be used - and it would be more efficient
<FromGitter> <grkek> intermediary var
<FromGitter> <grkek> what is that
<FromGitter> <j8r> each `Array#[]` to a lookup
<FromGitter> <j8r> so `fist_content = content[1]`
<FromGitter> <grkek> it is not an array
<FromGitter> <grkek> it is a tuple
<FromGitter> <grkek> content
<FromGitter> <grkek> is a tuple
<FromGitter> <j8r> ha ok
<FromGitter> <Blacksmoke16> is `to_safe` required?
<FromGitter> <grkek> yeah it is probably
<FromGitter> <grkek> because when I try to
<FromGitter> <grkek> cast it to as(thing)
<FromGitter> <grkek> liek
<FromGitter> <grkek> as(Grip::DB::Mode;)
<FromGitter> <grkek> it works
<FromGitter> <grkek> ; - typo
<FromGitter> <j8r> don't know then
<FromGitter> <grkek> :D
<FromGitter> <grkek> its okay
<FromGitter> <grkek> I can link you the repo
<FromGitter> <grkek> if you want to see the source
<FromGitter> <j8r> I can take a quick look yes
<FromGitter> <Blacksmoke16> if its required for a model to implement id suggest putting an `abstract def to_safe : String` in it
<FromGitter> <grkek> https://github.com/grkek/grip/tree/feature/leveldb here is the branch
<FromGitter> <grkek> whoops
<FromGitter> <grkek> wrong one
<FromGitter> <grkek> sorry
<FromGitter> <grkek> no its the correct one
<FromGitter> <grkek> sorry again
<FromGitter> <grkek> here is the check
<FromGitter> <grkek> @Blacksmoke16 I think I hacked around it
<FromGitter> <grkek> so fat
<FromGitter> <grkek> far*
<FromGitter> <grkek> will try that later
<FromGitter> <grkek> thank you guys
<FromGitter> <grkek> hm
<FromGitter> <grkek> I didn't know about that
<FromGitter> <grkek> but I just wanted to create a small subset of res codes
<FromGitter> <grkek> for the "REST"
<FromGitter> <grkek> suite you know ?
<FromGitter> <grkek> :D
<FromGitter> <Blacksmoke16> im pretty sure you can just do `context.response.status = content.first`
<FromGitter> <Blacksmoke16> and not do the case
<FromGitter> <grkek> rlly ?
<FromGitter> <j8r> @grkek if you do `puts typeof(content)`.
<FromGitter> <j8r> what does it returns?
<FromGitter> <grkek> let me check
<FromGitter> <Blacksmoke16> symbol should be autocasted to the enum value, dont think it would work with `200` int tho
<FromGitter> <grkek> (String | User)
<FromGitter> <Blacksmoke16> its going to be a union of every action's return type
<FromGitter> <grkek> trueee
<FromGitter> <Blacksmoke16> gl :p
<FromGitter> <grkek> i already did it
<FromGitter> <grkek> tho
<FromGitter> <grkek> I got it to work its just too hacky
<FromGitter> <grkek> idk
<FromGitter> <grkek> its not a problem for me it just looks ugly af
<FromGitter> <j8r> and `String` is a `Grip::DB::Model`?!
<FromGitter> <j8r> that what the compiler is saying
<FromGitter> <grkek> no it is not
<FromGitter> <grkek> When the passed in object
<FromGitter> <grkek> is not a Grip::DB::Model
<FromGitter> <grkek> it goes to to_json routine
<FromGitter> <grkek> when it is it goes to a to_safe routine
<FromGitter> <grkek> to keep the secrets out of the response
<FromGitter> <grkek> @Blacksmoke16 the rps went down to 40k
<FromGitter> <grkek> still great compared to the sqlite3
<FromGitter> <grkek> massacre
<FromGitter> <grkek> also you can use granite as well with grip
<FromGitter> <grkek> you just have to install it with grip and confiugre it
<FromGitter> <grkek> configure thats it
<FromGitter> <grkek> Lost the multi threading with leveldb multiple instances but
<FromGitter> <grkek> I am going to make it work
<FromGitter> <grkek> somehow
<FromGitter> <grkek> :D
<FromGitter> <jgillich> When I do `Dir.mkdir_p "~/test"` I get a `~` dir in the current dir (so it's not resolved as $HOME). Does anyone know why that is?
<FromGitter> <Fryguy> File.expand_path was recently change to *not* expand home by default, so it's possible mkdir_p was using that under the covers?
<FromGitter> <Fryguy> (I honestly still don't understand why expand_path was changed that way...very confusing since it's no longer expanding my path)
<FromGitter> <Blacksmoke16> looks like it just splits on `/`
<FromGitter> <Blacksmoke16> prob should call expand path first, and give open to `mkdir_p` to expand home?
<FromGitter> <Blacksmoke16> workaround would be to just like `Dir.mkdir File.expand "~/test", home: true` i think would do it
<FromGitter> <Fryguy> `Dir.mkdir File.expand_path "~/test", home: true`
<FromGitter> <Blacksmoke16> oops, right yea ^
<FromGitter> <grkek> Okay switching it to redis
<FromGitter> <grkek> @Blacksmoke16
<FromGitter> <grkek> is it a good idea :D ?
<FromGitter> <Blacksmoke16> depends on what you want to do?
<FromGitter> <grkek> Use it as a DB
<FromGitter> <grkek> lmao
<FromGitter> <Blacksmoke16> i mean i suppose you could use it as a like JSON document DB, although prob not the best choice...
<FromGitter> <Blacksmoke16> more so meant as a cache
<FromGitter> <grkek> meh
<FromGitter> <grkek> it works so
<FromGitter> <grkek> doesn't really matter
<FromGitter> <grkek> ?
<FromGitter> <Blacksmoke16> id be more so in favor of not supporting any db and letting the user implement the one they want
<FromGitter> <grkek> At least support one of the quickie db's
<FromGitter> <Blacksmoke16> i wouldnt, that makes one db tightly coupled to your app, i.e. would be installed when installing your app
<FromGitter> <Blacksmoke16> which if i dont want to use i have a random dep that doesnt do anything
<FromGitter> <grkek> hmmm
<FromGitter> <grkek> so that sounds interesting
<FromGitter> <grkek> I am going to create a branch with it
<FromGitter> <grkek> then
<FromGitter> <Blacksmoke16> if anything have a separate shard that adds additional functionality for a given db
<FromGitter> <Blacksmoke16> to keep it optional
<FromGitter> <grkek> Ill have a branch
<FromGitter> <grkek> that sounds better
<FromGitter> <Blacksmoke16> as a temp thing to figure it out, or a perm thing?
<FromGitter> <grkek> perm thing :D
<FromGitter> <grkek> branch for a redis integration
<FromGitter> <grkek> i guess
<FromGitter> <Blacksmoke16> that sounds like an aweful idea
<FromGitter> <grkek> why tho
<FromGitter> <grkek> should I at least fork it ?
<FromGitter> <Blacksmoke16> now you have to maintain your app twice
<FromGitter> <grkek> or just create a shard
<FromGitter> <Blacksmoke16> and how would that work with releases
<FromGitter> <grkek> another shard
<FromGitter> <grkek> separate shard
<FromGitter> <Blacksmoke16> that would be better i think
<FromGitter> <Blacksmoke16> ideally the other shard wouldnt define the whole app, just add/alter functionality when required
<FromGitter> <grkek> jjust like kemal does
<FromGitter> <grkek> things
<FromGitter> <grkek> yeah that would be nice
<FromGitter> <grkek> done
<FromGitter> <grkek> :D
<FromGitter> <grkek> who is c17r and why does he view all of the messages ?
<FromGitter> <j8r> cr7?
<FromGitter> <j8r> Christiano Ronaldo reads our messages :)?
<FromGitter> <grkek> no
<FromGitter> <grkek> c17r
<FromGitter> <grkek> Christian Sauer
<FromGitter> <grkek> also how to overwrite a class with redefinition of the same class from a different shard ?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <grkek> nevermind
alex`` has quit [Quit: WeeChat 2.7]
alexherbo2 has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> ok
ht_ has joined #crystal-lang
Nicolab has joined #crystal-lang
<FromGitter> <grkek> Interestingly
<FromGitter> <grkek> I did
<FromGitter> <grkek> this guy
<FromGitter> <grkek> yay
<FromGitter> <grkek> basically you can plug in any key-value storage
<FromGitter> <grkek> so in the future ill just make a grip-keyvalue
<FromGitter> <grkek> and allow you to plug in any key/value storage you want
<FromGitter> <wontruefree> Chicago Crystal released a new video
<FromGitter> <wontruefree> the state of AI in crystal
<FromGitter> <wontruefree> https://youtu.be/TyC-mDIA0Us
duane has joined #crystal-lang
<FromGitter> <grkek> niceee
<FromGitter> <Blacksmoke16> did you just copy the whole handler?
Groogy has quit [Quit: WeeChat 2.7]
<FromGitter> <grkek> Yes I did
<FromGitter> <grkek> and then realized I could just change the method
<FromGitter> <grkek> and inherit from a calss
<FromGitter> <grkek> class*
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
<FromGitter> <Blacksmoke16> ill have to wait and see how that looks then
<FromGitter> <grkek> You were right I should let the user implement the db
<FromGitter> <grkek> :D
<FromGitter> <Blacksmoke16> :p
<FromGitter> <grkek> basically it is done so far
<FromGitter> <grkek> db's are pain in the ass
<FromGitter> <grkek> plus crystal is bitching about instance variables in macros
<FromGitter> <Blacksmoke16> or at least design things using interfaces that the user can define
<FromGitter> <Blacksmoke16> implement*
<FromGitter> <grkek> nah
<FromGitter> <grkek> fuck it
<FromGitter> <grkek> let em use granit
<FromGitter> <grkek> e
<FromGitter> <grkek> :D
<FromGitter> <grkek> Lets keep the keyvalue stores a bit off to the shore
<FromGitter> <grkek> does it really need 30 days
<FromGitter> <grkek> :D ?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <grkek> Cries in crystal
<FromGitter> <btihen> @thedracle - did you get a websocket working? How about onewithout SSL?
<sorcus> Hi.
<sorcus> Maybe someone know, is there a similar function in crystal stdlib? https://github.com/benbahrenburg/Ti.SlowAES/blob/master/SlowAES/aes.js#L679
alex`` has joined #crystal-lang
Nicolab has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
Nicolab has joined #crystal-lang
<FromGitter> <Nicolab> Hi, ⏎ ⏎ To be able to retrieve values from a config `struct`, I did this: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5e1786bbe52f635378b18a66]
<FromGitter> <Nicolab> ok `getter` makes the job :)
<FromGitter> <Blacksmoke16> if you're using class vars whats the point of using the sturct?
<FromGitter> <Blacksmoke16> struct*
<FromGitter> <Blacksmoke16> ```module DB ⏎ class_property uri : String = "postgres://..." ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e1787d191129970ca9a98bf]
<FromGitter> <Blacksmoke16> `class_property` is the same as `property` but defines a class level getter/setter
<FromGitter> <Blacksmoke16> is also `class_getter` and `class_setter` ofc
<FromGitter> <Nicolab> `module` is a class?
<FromGitter> <Blacksmoke16> `module` is a module
<FromGitter> <Nicolab> ok that's from who seemed to me
<FromGitter> <Nicolab> well what I'm trying to get is: `App.db.uri`, `App.mailer.credientals`, etc ⏎ ⏎ Also, the `App` module is my main module wich have some methods
<FromGitter> <Blacksmoke16> where do the values come from?
<FromGitter> <Blacksmoke16> or they just static hardcoded within the type?
<FromGitter> <Nicolab> just config data set at initialization (by hand and via ENV)
<FromGitter> <Nicolab> immutable
<FromGitter> <Nicolab> they are not intended to be changed at runtime
<FromGitter> <Blacksmoke16> then just do
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8d73
<FromGitter> <Blacksmoke16> would prob do it
<FromGitter> <Blacksmoke16> `class_getter db : DB.class = DB`
<FromGitter> <Nicolab> Great, thank you very much @Blacksmoke16 πŸ‘ πŸ‘
<FromGitter> <Nicolab> just for info a module is stored in the heap or the stack? As much as I get into good habit from the start in Crystal
<FromGitter> <Blacksmoke16> good question, its never actually instantiated so im not sure
<FromGitter> <Nicolab> ok
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alex`` has quit [Quit: WeeChat 2.7]
alex`` has joined #crystal-lang
ur5us has joined #crystal-lang
DTZUZO has quit [Ping timeout: 260 seconds]
DTZUZO_ has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<FromGitter> <tenebrousedge> what are people's opinions about react vs vue for a hopefully-simple frontend? I don't anticipate doing anything more complicated than listing and viewing resources (images)
duane has quit [Ping timeout: 240 seconds]
<alexherbo2> how to get the path to the program?
<alexherbo2> (at compile-time)
<alexherbo2> I want to embed a configuration file relative to the binary path
<alexherbo2> if you have examples of best practices for doing it you can shoot :p
<alexherbo2> thanks tenebrousedge
<FromGitter> <tenebrousedge> np
<alexherbo2> you think it's better to source a file relative to the binary path when running
<alexherbo2> or embed the configuration in the program
<alexherbo2> `executable_path` is at runtime no?
<alexherbo2> not sure how to differenciate
<alexherbo2> when doing compile or runtime
<FromGitter> <tenebrousedge> I don't think there's much difference. Using a config file written in Crystal can make it easier to express some things
duane has joined #crystal-lang
alexherbo20 has joined #crystal-lang
alex`` has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo20 is now known as alexherbo2
<FromGitter> <Blacksmoke16> one thing im doing for athena is load in the config file's contents via `read_file` macro
<FromGitter> <Blacksmoke16> then doing `.from_yaml` at runtime
<FromGitter> <Blacksmoke16> so you dont need to include the file with the binary on deploy
<FromGitter> <Blacksmoke16> move*
alex`` has joined #crystal-lang
<FromGitter> <Blacksmoke16> once custom yaml tag processor feature is done, it'll make it a bit cooler
<FromGitter> <Blacksmoke16> like add one to resolve env vars at runtime, to respect the current env
duane has quit [Ping timeout: 240 seconds]
duane has joined #crystal-lang
<FromGitter> <tenebrousedge> @Blacksmoke16 which do you prefer: react, vue, or a stab in the eye with a sharp stick?
<FromGitter> <Blacksmoke16> mm i never used either, i usually go with Angular :shrug:
<FromGitter> <tenebrousedge> people still use angular?
<FromGitter> <Blacksmoke16> not angularjs
<FromGitter> <Blacksmoke16> angular proper
<FromGitter> <Blacksmoke16> https://angular.io/ this one
ht_ has quit [Remote host closed the connection]
<FromGitter> <Nicolab> @tenebrousedge I have used Angular (long ago) and React. ⏎ This is only my personal opinion but I prefer React much more for reasons of productivity, maintenance and performance.
<FromGitter> <Nicolab> The only tricky thing with React is that you have to find your own organization (structure and good practices). Once found, it rubs
<FromGitter> <Nicolab> I am not a fan of all the marketing (hype) around React, a lot of article pumped on each other relay bad practices (in any case that does not lend itself to it shitting in a big project)
<FromGitter> <Nicolab> By avoiding some false good practices (you have to sort out the good and the bad), React is great.
<FromGitter> <Nicolab> Again, that's just my opinion :)
<FromGitter> <Nicolab> If you are looking for a less time-consuming store than Redux, I take pleasure in coding with plop https://github.com/Nicolab/storux ⏎ ⏎ Inevitably I like it, I designed them according to my ideals and those of my colleagues who also wanted a certain type of store respecting the pattern flux. ^^
<FromGitter> <Nicolab> https://www.gatsbyjs.org if you are looking for something already structured with some useful tools.
<FromGitter> <Blacksmoke16> angular is better for larger projects iirc
<FromGitter> <Blacksmoke16> but for small stuff prob is overkill
<FromGitter> <Nicolab> Why better?
<FromGitter> <Nicolab> At this level I think it's a matter of preference, I felt no limits with React.
yukai has joined #crystal-lang
<FromGitter> <Nicolab> I just understood what you meant (better for big projects than for small ones)
<FromGitter> <tenebrousedge> I'll take a look at storux
<FromGitter> <Nicolab> @tenebrousedge Note: that if you are new to React / Angular, perhaps it is better to start with a better documented store with examples of integrations with React or Angular. In a second time, once you see the interest of a state store, come back to try Storux.
<FromGitter> <straight-shoota> oprypin, how difficult was it to get the workflow on Github Actions set up?
<oprypin> straight-shoota, difficult in what sense
<oprypin> i honestly dont know the baseline of what should be difficult :D
<FromGitter> <straight-shoota> Did you need like a dozen try and error runs? Or more?
<oprypin> but i already had experience from https://circleci.com/gh/oprypin/crystal
<FromGitter> <straight-shoota> Yeah
<FromGitter> <Blacksmoke16> actions is pretty cool
<oprypin> it's quite a similar philosophy
<FromGitter> <Blacksmoke16> some stuff is missing tho, but prob not a big deal
<FromGitter> <straight-shoota> So it still took you 2 hours to get it running?
<oprypin> yea
<FromGitter> <straight-shoota> Great job πŸ‘
<oprypin> thanks
<FromGitter> <straight-shoota> Why do you build the compiler? The one coming with `crystal:latest` should already work.
<FromGitter> <straight-shoota> Btw GC should work on win32, so `-Dgc_none` is not necessary
<FromGitter> <straight-shoota> You're already building libgc anyways
<oprypin> straight-shoota, what do u mean, the point is to test crystal master, not test some old compiler
<oprypin> straight-shoota, the instructions are verbatim, so u may as well edit this out in the wiki then https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows
<FromGitter> <straight-shoota> Yeah, eventually we want to test the compiler. But the compiler itself is not ported yet. And cross compiling hello world or even the standard library should be totally fine with latest.
<oprypin> no, i'm not sure you understand
<FromGitter> <straight-shoota> For now there should be no strict requirement to build the compiler. I was just wondering if there was some reason that you needed a master build
<oprypin> if this CI is merged to Crystal, then, on any commit to Crystal master, this CI will test..... crystal latest release (always the same)
<oprypin> no i didnt need master build, just but like... master is what i want to test
uu91 has joined #crystal-lang
<FromGitter> <straight-shoota> Yes, I was just not expecting that for what is essentially a PoC :D
<FromGitter> <tenebrousedge> @Nicolab I've written my own version of redux at one point. I'll take a look at storux
<oprypin> hehe it's not just a PoC. it would already prevent regressions in producing a helloworld :p
<FromGitter> <straight-shoota> You're totally right!
<oprypin> but i see your point too
<FromGitter> <Nicolab> @tenebrousedge Oh ok! Nice :)
<FromGitter> <straight-shoota> And with #8664 this would be really useful
<DeBot> https://github.com/crystal-lang/crystal/pull/8664 (Add list of specs working on win32 in std_spec)
<FromGitter> <tenebrousedge> I wish the crystal api docs had a message at the top that said "you're looking at an old version, click here to get the latest"
<FromGitter> <straight-shoota> @tenebrousedge Yeah, that's much necessary
<FromGitter> <Nicolab> πŸ‘
uu91 has quit [Remote host closed the connection]