ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.33.0 | 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
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #crystal-lang
f1refly has joined #crystal-lang
ukd1 has joined #crystal-lang
lvmbdv has quit [Quit: off to pump lead into the global elite]
darkstardevx has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 265 seconds]
HumanG33k has joined #crystal-lang
ur5us has quit [Ping timeout: 252 seconds]
ukd1 has quit [Quit: leaving]
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_ht has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 264 seconds]
postmodern has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 256 seconds]
ur5us has joined #crystal-lang
f1refly has joined #crystal-lang
f1refly has quit [Ping timeout: 256 seconds]
f1refly has joined #crystal-lang
f1refly has quit [Ping timeout: 256 seconds]
f1reflyylmao has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 265 seconds]
f1refly has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 240 seconds]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 240 seconds]
ur5us has quit [Ping timeout: 240 seconds]
snosk8r has joined #crystal-lang
_whitelogger has joined #crystal-lang
snosk8r has quit [Read error: Connection reset by peer]
snosk8r has joined #crystal-lang
return0e has quit [Remote host closed the connection]
postmodern has quit [Quit: Leaving]
f1reflyylmao has quit [Quit: bye fags]
f1refly has joined #crystal-lang
snosk8r has quit [Ping timeout: 240 seconds]
darkstardevx has quit [Ping timeout: 252 seconds]
darkstardevx has joined #crystal-lang
snosk8r has joined #crystal-lang
johnny101 has joined #crystal-lang
return0e has joined #crystal-lang
daemonwrangler has quit [Ping timeout: 256 seconds]
twistedpixels has quit [Ping timeout: 260 seconds]
daemonwrangler has joined #crystal-lang
twistedpixels has joined #crystal-lang
sagax has quit [Remote host closed the connection]
sagax has joined #crystal-lang
<raz> ^ halp! my macro doesn't want to iterate over my constant :<
DTZUZU has quit [Ping timeout: 252 seconds]
return0e has quit [Remote host closed the connection]
DTZUZU has joined #crystal-lang
FromGitter has joined #crystal-lang
<raz> oh meh, it looks like the gitter bridge died again
<FromGitter> <randiaz95> Guys!
<FromGitter> <randiaz95> I was wondering what the best way to check if the results is one or zero in a db.query api
<FromGitter> <randiaz95> db.query select do |rs| ? end
<FromGitter> <tenebrousedge> check and then do what?
<FromGitter> <randiaz95> I want to check if rs is empty or one value
<FromGitter> <randiaz95> I don't know the best practice
<FromGitter> <tenebrousedge> and then do what? Count those? return them?
<FromGitter> <randiaz95> if empty branch out
<FromGitter> <randiaz95> if one branch out
<FromGitter> <randiaz95> if more than one branch out to error
<FromGitter> <randiaz95> ( Preferably with a killswitch )
<FromGitter> <randiaz95> not having to loop through all of them
<FromGitter> <tenebrousedge> why is more than one result possible to store in the database if that represents an error condition??
<FromGitter> <randiaz95> It comes from a data science perspective
<FromGitter> <randiaz95> not an application logic perspective
<FromGitter> <tenebrousedge> this is a data modeling problem not an application logic problem
<FromGitter> <randiaz95> Kai, you saying my architecture is bad? lol
<FromGitter> <randiaz95> Ill just create a with statement in sql and dedupe there
<FromGitter> <tenebrousedge> yes, you should be solving that in SQL
<FromGitter> <randiaz95> Just perusing a data set in crystal lol I didnt architect the data just dumped the data in ther
<raz> https://play.crystal-lang.org/#/r/8t7o <- halp! my macro doesn't want to iterate over my constant :(
<FromGitter> <tenebrousedge> I don't know whether your model is good or bad, just the question was asking for something that is better handled at the data layer with other tools
<FromGitter> <randiaz95> Right.
<FromGitter> <tenebrousedge> raz, I think it has to do with how constants are handled. ⏎ https://play.crystal-lang.org/#/r/8t87
<FromGitter> <tenebrousedge> note if you add a call to `weeb` there it will also error out
<raz> hmmm
<raz> so how could i populate an array and iterate over it at compile time?
<raz> i thought i had done it this way with a constant in the past, but apparently my memory betrays me
<FromGitter> <tenebrousedge> what's the goal?
<raz> tenebrousedge: one macro puts stuff in the array, in another place i want to act on it
<raz> think registry pattern (iterate over all classes that invoked macro X)
<raz> tenebrousedge: hmmm. how would i find all classess that used @[MyAnnotation]?
sorcus has quit [Quit: WeeChat 2.7.1]
<raz> also in my sample above i'm kinda confused why it prints the correct value for FOO in the macro. but {% for i in FOO %} does not work
* raz scratches head
<raz> oh interesting. it seems to see a *different* FOO inside the {% %}. it says it's an ArrayLiteral, so the originally declared one.
* raz scratches head even more
sorcus has joined #crystal-lang
<raz> macro scoping just confuses me
Stephanie has quit [Quit: Fuck this shit, I'm out!]
Stephie has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> 1hr left before sleep ;D
<FromGitter> <randiaz95> LOL
<raz> ohhh, i got it
* raz smacks forehead
<FromGitter> <randiaz95> 1 hour left before I stop work lol
<FromGitter> <ImAHopelessDev_gitlab> hehehe
* raz had macro-time and runtime mixed up, as usual
<oprypin> raz, wee
<raz> :)
<repo> heya
<repo> anyone here use ale in vim? i wonder if there's a way to circumvent the problem of getting errors for every file that doesn't explicitly require all the files that define the constants that are referenced there?
<oprypin> repo, the solution: require all the files that define the constants that are referenced there
<repo> yeah i do that for my own code but unfortunately none of the frameworks do this
<oprypin> i hate it
<repo> same
<repo> but noone seems to care
<oprypin> welp, first time i hear of "ale"
<repo> it's pretty nice
<watzon> Yeah I've never heard of it either
<watzon> But it looks nice
<repo> yeah
<repo> it'd be nice if it would be somehow possible to configure ale to prepend the file with a custom line before checking it
<watzon> Does ale work with Crystal?
<repo> yeah
<repo> very well
<watzon> Hmm nice
<repo> but only if the file you're writing will compile
<repo> or
<repo> i mean it also works if it doesn't comile
<repo> compile
<repo> you will get the compiler error for the line which fails
<repo> but the problem with frameworks is that they never require anything in generated files
<watzon> Right and none after
<watzon> That's the usual issue
<repo> none after?
<repo> so basically i was thinking if i could tell ale to add a `require "src/app"` or something as the first line of each file, it should work
<watzon> I mean it shows the line that breaks, but if there are other things broken elsewhere it won't. At least that's what the case usually is, just because of the way it does error checking.
<watzon> We'll get a real working language server for crystal eventually though
<repo> oh, yeah sure
<repo> a working language server would be awesome!
<oprypin> repo, do any other people know that it's crystal + ale is a good combination? would be nice to publicize otherwise
<repo> apparently not :D
<deavmi> Anyebody done Socket programming incrystal as of recently? I have everything setup , AF type, socket type and protocol but on receviing into a buffer I get Unsupported family type
<deavmi> Which is strange
<deavmi> Maybe my crystal is out of date but I could have sworn last year when I tried it it, worked out :thincc:
<deavmi> Crystal 0.33.0 (2020-02-15) seems recent, mmmmmh
<repo> if i set a prelude, where does crystal look for it?
<oprypin> repo, if in doubt use absolute path
<repo> oprypin: is it possible to get the root of the project somehow?
<repo> never mind
<oprypin> repo, e.g. `crystal run --prelude array test.cr` ends up using /usr/lib/crystal/array.cr
<repo> yeah
<oprypin> so it's likely same resolution rules as for require
<oprypin> root of the project.. hummmmm. that's usually not a thinkg
<repo> hm
<repo> Error: can't find file '/home/jokke/code/projects/redo/api/ale-prelude.cr'
<repo> it's definitely there
<oprypin> oh huh, so it's *really* same resolution rules as for require
<repo> seems sos
<repo> so
<repo> oprypin: hmmm
<repo> just to test
<repo> crystal build --prelude ../../ale-prelude -o /dev/null src/models/task.cr
<repo> kinda works
<repo> but not really
<repo> so instead of getting Error: undefined constant BaseModel i get Error: undefined constant Task::BaseQuery
ur5us has joined #crystal-lang
<repo> content of ale-prelude.cr is just:
<repo> require "prelude"
<repo> require "./src/app
<repo> *"
<repo> it's weird because the app builds fine
<repo> maybe i'm not getting prelude
<oprypin> repo, to reproduce, try adding `require
<oprypin> repo, to reproduce, try adding `require "../../src/app"` to the top of src/models/task.cr
<repo> good idea
<oprypin> then run src/models/task.cr . are you getting the same issue?
<repo> nope
<repo> ah sorry
<repo> wrong file
<repo> sec
<oprypin> i think it's a problem with circular imports. something in ../../src/app/* relies on src/models/task.cr but it's already in the process of being imported
_ht has quit [Quit: _ht]
<repo> yeah that fails
<repo> yup seems so
<repo> damn
<oprypin> but that's weird
<oprypin> *why* do you need the file of the third party framework to be compilable
<oprypin> oh are you contributing to it?
<repo> no
<repo> i'm just using it
<repo> but for ale to work properly each individual file needs to compile
<oprypin> it should definitely abstract away third party code
<repo> so i was messing around with prelude to see if i could hack together a prelude that would enable me to compile any file from the project
<repo> it's not "third party code" it's generated
<oprypin> oh duh
<oprypin> fix that framework :>
<repo> (this is lucky)
<repo> i have other grudges with it as well
<oprypin> `crystal build --prelude ../../ale-prelude -o /dev/null your_own_project.cr` would work even if your_own_project requires a file of a third party library which is not compilable by itself
<repo> like defining everything in global namespace..
<repo> but it does many things very well
<oprypin> when i looked at Lucky i was just like 😱
<repo> at the code?
<repo> or the docs?
<oprypin> but that's just me using microframeworks all my life
<repo> yeah i get that
<oprypin> repo, the OOP shall we say
<repo> yeah
<repo> it's very rails-like
<repo> well i gave it a shot. time to ditch it agian
<repo> again
<repo> i'll put something together with athena agian
<repo> again
sz0 has quit []
sz0 has joined #crystal-lang
<FromGitter> <Blacksmoke16> 💯
<FromGitter> <Blacksmoke16> :p
<FromGitter> <randiaz95> :P
<FromGitter> <randiaz95> Athenation
<FromGitter> <randiaz95> Yo @Blacksmoke16
<FromGitter> <randiaz95> Do you know if i can use built in serialization of objects in crystal?
<FromGitter> <randiaz95> to flat file?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <randiaz95> like python pickle
<FromGitter> <Blacksmoke16> example?
<FromGitter> <randiaz95> object_i_want_to_store = ClassName() ⏎ ⏎ object_i_want_to_store.dump("filename.stored_object")
<FromGitter> <randiaz95> then in another file I read it in with something like ⏎ ⏎ previous_object = pickle.load("filename.stored_object")
<FromGitter> <Blacksmoke16> and it dumps what? like a JSON string of it or?
<FromGitter> <randiaz95> This is more than just json data because it keeps the methods too
<FromGitter> <randiaz95> an application i do at work is:
<FromGitter> <Blacksmoke16> *keeps the methods*?
<FromGitter> <Blacksmoke16> i mean cant you do this now via
<FromGitter> <randiaz95> @randiaz95 ⏎ ⏎ ```model = pickle.load("filename.model") ⏎ model.predict("new_data")`````` [https://gitter.im/crystal-lang/crystal?at=5e83bb98f2c75e2bc10260c7]
<FromGitter> <Blacksmoke16> ```obj = MyObj.new ⏎ File.write "filename.stored_object", obj.to_json``` [https://gitter.im/crystal-lang/crystal?at=5e83bbace0c6ca4b2e0479fc]
<FromGitter> <Blacksmoke16> then
<FromGitter> <Blacksmoke16> ```prev_obj = MyObj.from_json File.read "filename.stored_object"```
<FromGitter> <randiaz95> can u then use methods from prev_obj
<FromGitter> <randiaz95> ?
<FromGitter> <tenebrousedge> yes
<FromGitter> <randiaz95> 1) o
<FromGitter> <Blacksmoke16> it instantiates a `MyObj` based on the json ata
<FromGitter> <Blacksmoke16> i.e. for the ivars
<FromGitter> <tenebrousedge> any instance of a class has identical methods as every other instance
<FromGitter> <Blacksmoke16> ^
<FromGitter> <tenebrousedge> you're just serializing the internal state
<FromGitter> <Blacksmoke16> JSON is just an example here ofc, can also use YAML or etc
<FromGitter> <randiaz95> Thats the thing; you wouldn't want to pass the coefficients of hundreds of parameters manually. but if its abstracted then ok
<FromGitter> <tenebrousedge> you'd just define the serialization as part of the model
<FromGitter> <randiaz95> ok Sweet!
<FromGitter> <randiaz95> Ima try it tou
<FromGitter> <randiaz95> out*
<FromGitter> <Blacksmoke16> i also been working on a serialization shard, although its on the back burner atm
<FromGitter> <tenebrousedge> @Blacksmoke16 where's that exclusive case issue at?
<FromGitter> <Blacksmoke16> it got closed
<FromGitter> <Blacksmoke16> go to closed issues and sort by recently updated and should be near the top
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter> <tenebrousedge> kk thanks
lunarkitty has joined #crystal-lang
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
<raz> is there a way (with a macro) to iterate over all classes that have been defined?
* raz is weaving up a serious frankenmacro
<FromGitter> <Blacksmoke16> `Object.all_subclasses`? :p
* raz tries it!
<raz> hurrrrrrrr!
* raz bows to Blacksmoke16
* FromGitter * hugopl nice when you start writing a bug report about the type inference and in the middle you notice you were wrong and the type inference right...
<FromGitter> <randiaz95> How can a full stack developer be 60k salary?
<FromGitter> <randiaz95> if a backend developer is 60k and front end developer is 60k
<FromGitter> <Blacksmoke16> xD
<FromGitter> <randiaz95> What type of math did they do?!
<FromGitter> <Blacksmoke16> prob is assuming you sacrifice depth for broadness
<FromGitter> <randiaz95> Bruh..
<FromGitter> <randiaz95> they will pay double the salary anyways because they will take more than double the time
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <randiaz95> 6 months for simple app where as a front end and a back end can do it in 3 months or les
<FromGitter> <randiaz95> They forgot about the salary time continuum
<FromGitter> <randiaz95> Also full stack developers will leave as soon as they master all of the pieces.
<FromGitter> <randiaz95> why not develop apps for himself?\
<FromGitter> <randiaz95> Why suffer for another person when they can have the equity
lvmbdv7 has joined #crystal-lang
lvmbdv7 is now known as lvmbdv
lvmbdv has quit [Client Quit]
lvmbdv has joined #crystal-lang
<FromGitter> <tenebrousedge> 60k sounds pretty low for anyone who's not just graduating from a coding bootcamp