ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.29.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
<FromGitter> <Blacksmoke16> 64bit?
<FromGitter> <mwlang> yes
<FromGitter> <mwlang> at the moment, it's the db stopping it running.
<FromGitter> <mwlang> if I run the image interactively with bash and attempt to run the executable: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1fe4f6bf25f013e7cddcd0]
<FromGitter> <Blacksmoke16> is the db actually running?
<FromGitter> <Blacksmoke16> maybe expose the port and try to connect from host
<FromGitter> <mwlang> well, DATABASE_URL is blank!
<FromGitter> <mwlang> so gotta get that set.
<FromGitter> <Blacksmoke16> that would do it
<FromGitter> <Blacksmoke16> should just be able to set it in the compose file and reup
<FromGitter> <mwlang> how can I tell if "db" is exposed to the "app" image? from bash shell on app?
<FromGitter> <mwlang> `No address found for db:5432`
<FromGitter> <Blacksmoke16> ``` environment: ⏎ - DATABASE_URL=postgres://user:pass@db:5432/dabase``` [https://gitter.im/crystal-lang/crystal?at=5d1fe72e5821f065d44d8a68]
<FromGitter> <Blacksmoke16> could try doing like
<FromGitter> <Blacksmoke16> ```ports: ⏎ - "5432:5432"``` [https://gitter.im/crystal-lang/crystal?at=5d1fe758c5f3c329aef1ddb2]
<FromGitter> <Blacksmoke16> which would allow the host to connect to it
<FromGitter> <mwlang> that ports one goes on the db service right?
<FromGitter> <Blacksmoke16> yea
<FromGitter> <mwlang> actually...how does the database get created? I don't think I have anything explicitly creating the db and initializing it.
<FromGitter> <Blacksmoke16> it happens when you build the container
<FromGitter> <Blacksmoke16> if you changed the user/pass you would have to remove the image and rebuild it
<FromGitter> <mwlang> I meant in the docker scripts.
<FromGitter> <Blacksmoke16> it just happens when you pull from `postgres:11.3`
<FromGitter> <mwlang> just by giving the database connection string, it knows to create a database called "database"?
<FromGitter> <Blacksmoke16> gets created with the env vars your provide
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1fe815ce3d0458f2b917d6]
<FromGitter> <Blacksmoke16> says to init the db with those creds
<FromGitter> <mwlang> Ah. I don't have that environment section in mine.
<FromGitter> <Blacksmoke16> yea you do
<FromGitter> <Blacksmoke16> `POSTGRES_DB` defaults to public i think
snsei__ has joined #crystal-lang
<FromGitter> <mwlang> The problem has to be "db" not being exposed to "app"
<FromGitter> <mwlang> "No address found for db:5432 over TCP"
<FromGitter> <Blacksmoke16> from within app container?
<FromGitter> <mwlang> yes
<FromGitter> <Blacksmoke16> could be `db` isnt valid within the container
<FromGitter> <Blacksmoke16> i.e. would have to provide the ip of the other container
<FromGitter> <mwlang> what I have at the moment: https://gist.github.com/mwlang/ae80c7fd402242cb6cdfcc8bf2a4db7f
<FromGitter> <Blacksmoke16> could just the good ol, tear it down and build it again
<FromGitter> <Blacksmoke16> assuming you dont have anything impt in the images?
<FromGitter> <mwlang> that's what I was doing for several minutes.
<FromGitter> <mwlang> removing about 40 images I had built.
<FromGitter> <Blacksmoke16> make sure `docker ps` is empty
<FromGitter> <Blacksmoke16> stop any that are reunning
<FromGitter> <Blacksmoke16> then do a `docker system prune -af --volumes`
<FromGitter> <Blacksmoke16> which will clear all the things
<FromGitter> <Blacksmoke16> then `docker-compose up`
<FromGitter> <mwlang> woah, I gotta remember that prune command.
<FromGitter> <mwlang> 3gb freed.
<FromGitter> <Blacksmoke16> :S
<FromGitter> <Blacksmoke16> just be careful with it, can be a pain to wipe away your local db
<FromGitter> <Blacksmoke16> can just leave off the `--volumes` in that case tho
<FromGitter> <mwlang> I don't have anything critical in the local dockers
<FromGitter> <mwlang> the redis one, I can just restart it any time.
<FromGitter> <mwlang> the data it holds in RAM is noncritical
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> so now when it builds it'll build a new db image
<FromGitter> <mwlang> its downloading everything fresh, too.
<FromGitter> <Blacksmoke16> yup
<FromGitter> <mwlang> is there material difference between postgres:11.3 and postgres:11.3-alpine which your file references?
<FromGitter> <Blacksmoke16> for the data volume? should be the same path
<FromGitter> <Blacksmoke16> `/var/lib/postgresql/data`
<FromGitter> <mwlang> I just mean the image
<FromGitter> <Blacksmoke16> oh
<FromGitter> <Blacksmoke16> yea
<FromGitter> <Blacksmoke16> alpine one is 70mb, the other is 300
<FromGitter> <mwlang> ok, only one image remains running after that.
<FromGitter> <Blacksmoke16> the db?
<FromGitter> <mwlang> yup
<FromGitter> <Blacksmoke16> same exec error?
<FromGitter> <mwlang> yup
<FromGitter> <Blacksmoke16> interesting
<FromGitter> <mwlang> still same "No address found for db:5432
<FromGitter> <Blacksmoke16> im pretty sure thats ok
<FromGitter> <Blacksmoke16> let me try something
<FromGitter> <mwlang> how so? (Socket::Addrinfo::Error)
<FromGitter> <mwlang> means its not resolving "db" to an ip address, right?
<FromGitter> <Blacksmoke16> but if you're in a bash session in the container that doesnt really mean much
<FromGitter> <Blacksmoke16> as `db` doesnt mean anything in that context
<FromGitter> <Blacksmoke16> would have to use the ip of the db container
sorcus has quit [Ping timeout: 276 seconds]
<FromGitter> <mwlang> ok, just noticed something in the database.cr that was probably the problem...it's constructing a database name from environment.database_name = "maestro_#{Lucky::Env.name}"
<FromGitter> <mwlang> (I should read the code more closely!)
<FromGitter> <mwlang> I'm hardcoding it for now.
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1ff0b711bfea0b67af7c7b]
<FromGitter> <Blacksmoke16> would also prob work
<FromGitter> <mwlang> thanks for explaining context of "db" -- I didn't realize in bash shell of the docker image that it was expected that doesn't resolve.
<FromGitter> <Blacksmoke16> its used by the docker network to resolve them using magic yea
<FromGitter> <Blacksmoke16> but within a container you my as well be typing int foo.com:5432
<FromGitter> <Blacksmoke16> as remember a container is just a vm basically
<FromGitter> <mwlang> same error.
<FromGitter> <Blacksmoke16> exec error?
<FromGitter> <Blacksmoke16> are you on mac?
<FromGitter> <mwlang> yes
<FromGitter> <mwlang> yes
<FromGitter> <mwlang> docker 2.0.0.3 if that matters
<FromGitter> <Blacksmoke16> try this
<FromGitter> <Blacksmoke16> start a new project with a hello world app and see if you can get that working
<FromGitter> <Blacksmoke16> like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1ff19b77c54c13e6090377]
<FromGitter> <Blacksmoke16> `docker build -t hello .`
snsei__ has quit [Ping timeout: 250 seconds]
<FromGitter> <Blacksmoke16> `docker run hello`
<FromGitter> <Blacksmoke16> (will need to define the target for shards build)
<FromGitter> <Blacksmoke16> ```targets: ⏎ hello_world: ⏎ main: src/hello.cr``` [https://gitter.im/crystal-lang/crystal?at=5d1ff1d15821f065d44dce8e]
<FromGitter> <mwlang> Do I need shards build at all?
<FromGitter> <Blacksmoke16> prob not
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1ff2ff07d71829adbd959f]
<FromGitter> <Blacksmoke16> `docker run hello`
<FromGitter> <mwlang> docker run hello just returns me to command line.
<FromGitter> <Blacksmoke16> did you build with `docker build -t hello `?
<FromGitter> <mwlang> however, with a little tweaking of what you gave me above, docker-compose gives me same exec format error
<FromGitter> <mwlang> docker-compose up
<FromGitter> <Blacksmoke16> in a new project or same one?
<FromGitter> <mwlang> new folder altogether.
<FromGitter> <Blacksmoke16> rgr, let me try it on my mac
<FromGitter> <Blacksmoke16> yea dunno worked fine for me
<FromGitter> <Blacksmoke16> lets go with the most minimal example
<FromGitter> <Blacksmoke16> new folder with
<FromGitter> <Blacksmoke16> hello.cr ⏎ ⏎ ```puts "hello"``` [https://gitter.im/crystal-lang/crystal?at=5d1ff49ece3d0458f2b96568]
<FromGitter> <Blacksmoke16> and Dockerfile
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1ff4c3bf25f013e7ce4bd4]
<FromGitter> <Blacksmoke16> `docker build -t hello .`
<FromGitter> <Blacksmoke16> `docker run hello`
<FromGitter> <mwlang> well, that worked.
<FromGitter> <Blacksmoke16> i might have an idea
<FromGitter> <Blacksmoke16> give me a sec
<FromGitter> <Blacksmoke16> alright yea
<FromGitter> <mwlang> while you were doing that, I got my first hello attempt working not using compose
<FromGitter> <Blacksmoke16> this isnt working because you had `CMD crystal build ...`
<FromGitter> <Blacksmoke16> but you also prob have a bin directory that has the file that was built on your mac?
<FromGitter> <Blacksmoke16> it was adding that binary and trying to exec the one built on your mac
<FromGitter> <mwlang> forehead smack
<FromGitter> <Blacksmoke16> vs the one built in the container
<FromGitter> <mwlang> nice find.
<FromGitter> <Blacksmoke16> so trying deleting your bin dir on your actual app and do a `docker compose up --build`
<FromGitter> <Blacksmoke16> and see if that fixes it
<FromGitter> <mwlang> you mean, delete my mac's ./bin folder, right?
<FromGitter> <Blacksmoke16> yea
<FromGitter> <Blacksmoke16> so there isnt a mac binary there
<FromGitter> <mwlang> building...
<FromGitter> <Blacksmoke16> thats the only reason i can think of that happening
<FromGitter> <Blacksmoke16> could maybe add a `.dockerignore` and add bin dir to it
<FromGitter> <Blacksmoke16> works like a .gitignore
<FromGitter> <mwlang> `starting container process caused "exec: \"/app/bin/maestro\": stat /app/bin/maestro: no such file or directory": unknown`
<FromGitter> <mwlang> I don't get it because... `Step 6/8 : RUN crystal build src/maestro.cr -o /app/bin/maestro --release`
<FromGitter> <Blacksmoke16> oo ok, diff error now
<FromGitter> <Blacksmoke16> are you doing `ADD . /app` after that?
<FromGitter> <mwlang> well, it's happening step 5 and it's `COPY . /app` not `ADD . /app`
<FromGitter> <Blacksmoke16> can you make another gist of the dockerfile?
<FromGitter> <Blacksmoke16> try removing ` image: maestro` from the compose file
<FromGitter> <Blacksmoke16> also dont need the `links` section
<FromGitter> <Blacksmoke16> lol no
<FromGitter> <Blacksmoke16> add a `RUN mkdir bin` before your crystal build
<FromGitter> <Blacksmoke16> er nvm that wasnt it
<FromGitter> <mwlang> I thought that image: tag just names it for docker ps
<FromGitter> <Blacksmoke16> `container_name`
<FromGitter> <Blacksmoke16> try removing your volumes in your compose file
<FromGitter> <mwlang> new error /app/bin/maestro not found
<FromGitter> <mwlang> (before removing volumes suggestion
<FromGitter> <Blacksmoke16> did removing them fix?
<FromGitter> <Blacksmoke16> it should if my theory is correct
<FromGitter> <mwlang> nope.
<FromGitter> <Blacksmoke16> really
<FromGitter> <Blacksmoke16> same file not found error?
<FromGitter> <mwlang> or maybe I broke something else...one more try.
<FromGitter> <Blacksmoke16> `docker-compose up --buidl`
<FromGitter> <mwlang> I took out /app/bin in front of "maestro" on both the crystal run and the CMD --- added it back and now trying again with full paths and no volumes.
<FromGitter> <mwlang> boom!
<FromGitter> <mwlang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1ffcb75e957c4d48dd7ca3]
<FromGitter> <Blacksmoke16> cool
<FromGitter> <Blacksmoke16> you're going to like this one why that worked
<FromGitter> <Blacksmoke16> im thinking the volume got created when your first did the compose up after wiping everything
<FromGitter> <mwlang> I'm guessing we were mapping volumes *after* we built it all.
<FromGitter> <Blacksmoke16> at that point there was not a bin dir with the binary
<FromGitter> <Blacksmoke16> but (i think) the volume doesnt get updated as your local changes so it kept mounting that version of your root
<FromGitter> <Blacksmoke16> prob better to replace that with like `- .:/app`
<FromGitter> <Blacksmoke16> so it'll just mount your whole current dir into the container
<FromGitter> <mwlang> well, that's find for local develop...but what would I do when I send this puppy into the cloud for real?
<FromGitter> <Blacksmoke16> you wouldnt be sending anything other than the binary
<FromGitter> <Blacksmoke16> i.e. build it statically on alpine and send that or something
<FromGitter> <Blacksmoke16> no need to include everything
snsei__ has joined #crystal-lang
<FromGitter> <mwlang> :lightbulb:
<FromGitter> <mwlang> so use to the source having to be present for the web app to run.
<FromGitter> <Blacksmoke16> :P
<FromGitter> <mwlang> never even occurred to me, "source code not needed"
<FromGitter> <Blacksmoke16> docker allows you to have multi stage builds
<FromGitter> <Blacksmoke16> so can build on alpine, then create a scratch container and copy the binary in
<FromGitter> <Blacksmoke16> and set the command to exec the binary
<FromGitter> <Blacksmoke16> would be statically built so dont need an os or anything
<FromGitter> <mwlang> pretty slick
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <mwlang> now I gotta figure out how to run migrations. :-p
<FromGitter> <mwlang> on mac, I did `brew install lucky` so I reckon I have to do the linux equivalent.
<FromGitter> <mwlang> then I can do `lucky db.migrate`
snsei_ has joined #crystal-lang
snsei__ has quit [Ping timeout: 252 seconds]
<FromGitter> <Blacksmoke16> or just look at what that command does
<FromGitter> <Blacksmoke16> or otherwise yea, install lucky into the image
<FromGitter> <Blacksmoke16> or better yet, have a container that gets started, does the migration if needed then exists
<FromGitter> <mwlang> that's the smart way.
<FromGitter> <mwlang> (3rd container)
<FromGitter> <mwlang> I'll have to flex my newfound docker skills to do that.
<FromGitter> <Blacksmoke16> it could use the same image as the main app, just a diff command
<FromGitter> <Blacksmoke16> like the main app does `lucky watch` while this one could do like `lucky db.migrate` should would exit after it compeltes
<FromGitter> <mwlang> with docker-compose up, is it guaranteed to bring up containers sequentially?
<FromGitter> <Blacksmoke16> whats what `depends_on:` does
<FromGitter> <Blacksmoke16> ```depends_on: ⏎ - db``` [https://gitter.im/crystal-lang/crystal?at=5d2001d05e957c4d48dd9f93]
<FromGitter> <Blacksmoke16> makes db come up first then starts app once db is ready
<FromGitter> <mwlang> Ah.
<FromGitter> <mwlang> I guess also, I need to put the command into the docker-compose.yml instead of in the Dockerfile?
<FromGitter> <mwlang> the other confusing thing...only one Dockerfile, but three entries in docker-compose
<FromGitter> <Blacksmoke16> yea the dockerfile doesnt need a command
<FromGitter> <Blacksmoke16> since you'll be sharing the image between services
<FromGitter> <Blacksmoke16> bit dated but should still work
<FromGitter> <Blacksmoke16> that doesnt involve alpine or static building
<FromGitter> <mwlang> I was reading that after you mentioned the multistage thing.
<FromGitter> <mwlang> definitely going to try it out.
<FromGitter> <mwlang> is it the `build: .` line that instructs the service to use the Dockerfile built image?
<FromGitter> <Blacksmoke16> to use the dockerfile in the current dir
<FromGitter> <Blacksmoke16> i usually have `Dockerfile` be for prod builds, then a `Dockerfile-dev`
<FromGitter> <Blacksmoke16> ``` build: ⏎ context: . ⏎ dockerfile: Dockerfile-dev``` [https://gitter.im/crystal-lang/crystal?at=5d2003b65821f065d44e4260]
<FromGitter> <Blacksmoke16> since the images are prob going to be diff for dev and prod
<FromGitter> <mwlang> oh, nice.
<FromGitter> <mwlang> I'm going to have to deep dive into docker one weekend and really get to know it's ins and outs.
<FromGitter> <Blacksmoke16> gl
<FromGitter> <Blacksmoke16> too much to discover :P
<FromGitter> <mwlang> thanks for your help tonight. You really got me over a big block there.
<FromGitter> <Blacksmoke16> np
<FromGitter> <Blacksmoke16> not making a JSON api are you? :P
<FromGitter> <mwlang> not any more!
<FromGitter> <mwlang> I'm putting it to work
<FromGitter> <mwlang> :-D
<FromGitter> <mwlang> I may start a BitMEX one next.
<FromGitter> <Blacksmoke16> was going to say if so, coughshouldhavetriedathenacough
<FromGitter> <mwlang> I can give it a go. I looked at it a bit while trying to learn crystal initially. Just trying out Lucky for a this experiment mostly.
<FromGitter> <mwlang> but planning to experiment with Athena next. Already played around with Amber.
<FromGitter> <Blacksmoke16> 👍 is pretty slick, but deff not as mature as amber/lucky
<FromGitter> <Blacksmoke16> lot of stuff is left up to you
<FromGitter> <mwlang> hmm...the app image never launches.
<FromGitter> <mwlang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d2005a207d71829adbe0aa1]
<FromGitter> <Blacksmoke16> whats compose file look like?
<FromGitter> <Blacksmoke16> it shouldnt depend on migrator
<FromGitter> <Blacksmoke16> since migrator wont ever be up for more than a few while it does the migrations
<FromGitter> <mwlang> oh, I thought you said that's what I needed to do to ensure migrator runs and completes before the app runs.
<FromGitter> <Blacksmoke16> ah no, it shouldnt matter
<FromGitter> <Blacksmoke16> just that db is up before the app
<FromGitter> <Blacksmoke16> the migrations can happen even if the app is running
<FromGitter> <Blacksmoke16> as its just running sql against the db, doesnt really have anything to do with the app
<FromGitter> <mwlang> but then the app crashes right off the bat when it starts with ```app_1 | Unhandled exception: relation "migrations" does not exist (PQ::PQError)```
<FromGitter> <mwlang> maybe it doesn't matter *after* the first migration to set things up...
<FromGitter> <Blacksmoke16> yea
<FromGitter> <Blacksmoke16> plus does `lucky watch` reload the code for you?
<FromGitter> <Blacksmoke16> on save or something
<FromGitter> <mwlang> if I use lucky, yes.
<FromGitter> <mwlang> but I'm compiling to get "maestro" app and that's what I'm running.
<FromGitter> <mwlang> I mean, I couldn't find *any* documentation on deploying, but intuitively, it seemed that I just needed to compile the main app and run it.
<FromGitter> <Blacksmoke16> pretty much
<FromGitter> <mwlang> something's still wrong...even removing "depends_on" migrator, the app's never launching.
<FromGitter> <mwlang> It still has depends on db
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <mwlang> whacked...commented out the migrator and it's not launching. :-/
<FromGitter> <Blacksmoke16> :thinking
<FromGitter> <mwlang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d2008c711bfea0b67b00f19]
<FromGitter> <Blacksmoke16> does it show up in docker ps
<FromGitter> <mwlang> yes
<FromGitter> <Blacksmoke16> maybe try stopping everything and re up
<FromGitter> <mwlang> geez
<FromGitter> <mwlang> i had the port wrong. used 3000
<FromGitter> <Blacksmoke16> :S
<FromGitter> <Blacksmoke16> nice one
<FromGitter> <mwlang> not sure when I changed that from 5000 to 3000
<FromGitter> <mwlang> well, with a working ecosystem, I think it's a good place to stop for the night.
<FromGitter> <Blacksmoke16> sounds good
laaron- has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
moei has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
moei has quit [Ping timeout: 245 seconds]
moei has joined #crystal-lang
laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
DTZUZO has joined #crystal-lang
absolutejam4 has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 268 seconds]
mistergibson has quit [Quit: Leaving]
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <girng> probably the worst article i've ever read https://www.thechrisoshow.com/2009/02/16/using-guard-clauses-in-your-ruby-code/
<FromGitter> <girng> "but if you’re writing uber long functions then you’re a terrible programmer.", nice. way to hit me when i'm down
<oprypin> girng, hey nobody ever backed up that claim about long functions, so maybe you'll be fine
<Yxhuvud> I remember back to a former workplace, that had a 4000 lines long for statement, in for levels deep of nested switches and if statements. That was a challenge to maintain.
ht_ has joined #crystal-lang
<FromGitter> <drum445> I use guard clauses, but I think a function only doing one thing is more important than line count
mps has quit [Ping timeout: 245 seconds]
mps has joined #crystal-lang
_whitelogger has joined #crystal-lang
absolutejam4 has joined #crystal-lang
sorcus has joined #crystal-lang
ua_ has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> they help with more than line count
<FromGitter> <Blacksmoke16> makes it way way more readable
<FromGitter> <Blacksmoke16> im not a big fan of long functions myself, but sometimes you cant avoid it (look at the the lexer in compiler)
<FromGitter> <Blacksmoke16> are things you can do help fight it, for example if you have a chunk of logic in a big function that is doing some task, just to get a single value or something, could probably pull that section of code out into a private method then the could would be like
<FromGitter> <Blacksmoke16> ```... ⏎ value = get_some_value ⏎ ...``` [https://gitter.im/crystal-lang/crystal?at=5d208941c74a8b447f7c867b]
<FromGitter> <Blacksmoke16> which can help, also makes that method reusable if you need to do the same logic multiple times
absolutejam4 has quit [Ping timeout: 258 seconds]
ua has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
absolutejam4 has joined #crystal-lang
<FromGitter> <mwlang> true story...I once worked on a project that had only *one* function in the entire app and couldn't convince the owner to break functionality out into multiple functions/methods. This was back in Windows 95 days and using Delphi. One day, that function got so big, it could no longer compile and fit into 64KB, which was the maximum amount of space a single routine could fit.
laaron has quit [Remote host closed the connection]
<FromGitter> <mwlang> The owner still wouldn't change his ways when we got to that point so I left the company figuring it a lost cause to continue to struggle with such a constraint needlessly.
<FromGitter> <j8r> @mwlang good one, wow 😮
<FromGitter> <j8r> he was duplicating code inside it, I suppose?
<FromGitter> <mwlang> It was a gigantic nested mess of if/else statements
laaron has joined #crystal-lang
<FromGitter> <mwlang> it's kinda sad when I reflect on it. Owner was a great guy. three of us came onboard the same week from another contract we were all let go from. He gave us a set of new features to build and the three of us tackled it together and immediately started unraveling that monolithic function into many. A week later when we had the code review, the owner was infuriated and made us roll it all back into the one
<FromGitter> ... function with no calls out (other than obviously to the standard library methods).
<FromGitter> <mwlang> we couldn't convince him over the course of four months or so that our way was ultimately better.
<FromGitter> <mwlang> and then when the thing stopped compiling and loading successfully, it took us a week of debugging to realize we'd grown beyond the 64kb barrier.
<FromGitter> <mwlang> what makes it sad is that the owner was one of the nicest and smartest guys I've met so you'd think when three sharp developers tell him one function is just bad, he'd listen, but I think hindsight, what probably was stopping him was he felt he was paying us to rewrite already existing and working code instead of for altogether new features and he just flat out didn't want to pay for that (in addition to just
<FromGitter> ... being caught in a "I know this, I don't want to change" fear trap.
<FromGitter> <Blacksmoke16> oh well
absolutejam4 has quit [Ping timeout: 248 seconds]
<FromGitter> <Blacksmoke16> btw, you should prob reenable your volume
<FromGitter> <mwlang> Question about what goes into git repo: Ruby projects, if a gem project do not commit Gemfile.lock, but Rails projects generally do. Reasoning is we don't want to lock down gems for consumers of those gems, but we provide guidelines for what minimum versions of each dependency will work. With Rails apps, on the other hand, we do want to lock down specific gem versions so dev environment matches production
<FromGitter> ... environment as closely as possible. Is the same reasoning applicable to when to commit shard.lock or gitignore it?
<FromGitter> <Blacksmoke16> i think thats the diff between `crystal init app/lib`
<FromGitter> <mwlang> oh, yeah. thanks for that reminder. I'm actually reading up on docker now.
<FromGitter> <Blacksmoke16> an app would be a consumer of the shards which could depend on specific versions
<FromGitter> <Blacksmoke16> but libraries dont need to be locked as they'll be locked by the applications that use them
<FromGitter> <mwlang> so for crystal apps, generally speaking, commit the lock file and for shards, do not. right?
<FromGitter> <Blacksmoke16> right
<FromGitter> <mwlang> Although this article is Ruby on Rails, it's got a lot of commentary in the context of a working environment I'm used to: https://semaphoreci.com/community/tutorials/dockerizing-a-ruby-on-rails-application
<FromGitter> <Blacksmoke16> id imagine its a big switch
<FromGitter> <Blacksmoke16> in how you go about doing things
<FromGitter> <Blacksmoke16> heres a question
<FromGitter> <j8r> but you can restrict versions on `shard.yml`
<FromGitter> <j8r> the lockfiles are mainly used for reproducible builds
<FromGitter> <j8r> and libraries don't have builds, no point of lockfiles
<FromGitter> <Blacksmoke16> the DB shard has a method ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Im trying to wrap that method so you can do like `MyModel.transaction do |tx|` vs having to do like `MoModel.adapter.database.transaction do |tx|` but i dont really know what im doing [https://gitter.im/crystal-lang/crystal?at=5d20a5cdc74a8b447f7d572d]
<FromGitter> <Blacksmoke16> im sure theres a way to do it...
waheedi has joined #crystal-lang
<waheedi> sup folks, I have an issue trying to make require works properly with a built from source installation
<waheedi> osx10.12
<FromGitter> <Blacksmoke16> whats the error?
<waheedi> its unable to find the lib "shard_name"
<waheedi> require "minitest" can't find the file
<FromGitter> <Blacksmoke16> did you do a shards install?
<waheedi> yes
<waheedi> and the shards.lock is there and the lib folder is tehre
<waheedi> there*
<waheedi> on what basis does require look for the library inside the lib folder?
<FromGitter> <Blacksmoke16> and you're just doing `require "minitest"`?
<FromGitter> <Blacksmoke16> thats all you should need to do
<waheedi> oh man
<waheedi> minutest is required and all is good guys
<waheedi> the thing is that crystal run/build complain about not finding the require shard
<waheedi> my question again, one what basis does the require look in the lib folder inside the project directory?
<FromGitter> ... somehow)
<FromGitter> <mwlang> when using docker for development and running deployed apps, what's the easiest way to have the Dockerfile or compose file "choose" the environment to build? For example, development, test, staging, or production? I realize I can set an ENV variable in the file, but that hard codes it and I'm thinking it needs to change according to where the containers are built somehow and consistently (meaning automated
<FromGitter> <Blacksmoke16> but my understanding it just looks for the lib that has the same name as you're typing based on the `name` key in the shard's shard.yaml
<FromGitter> <Blacksmoke16> could do something similar to https://github.com/Blacksmoke16/athena/tree/master/docs#configuration
<FromGitter> <Blacksmoke16> use a common yaml file and have a method that returns the corresponding env object from the yaml file based on the environment
<FromGitter> <Blacksmoke16> also would allow using yaml merge feature to share common settings between envs
laaron has quit [Remote host closed the connection]
<waheedi> Thanks @Blacksmoke16
<FromGitter> <Blacksmoke16> @mwlang https://docs.docker.com/compose/compose-file/#env_file might also help
laaron has joined #crystal-lang
<FromGitter> <mwlang> yeah, env_file is what I needed. thanks!
<waheedi> well, it seems the docs are a little bit unclear here ttps://crystal-lang.org/reference/syntax_and_semantics/requiring_files.html
<waheedi> when i do shards install
<FromGitter> <mwlang> @Blacksmoke16 can you use a macro on the model's class level to basically emit that block of code?
<waheedi> it installs the needs shards, but their structure is different from what expected, for example right now the structure is cr_project/lib/minitest/src/minitest.cr and not cr_project/lib/minitest/minitest.cr as the documentation say
<FromGitter> <Blacksmoke16> pretty sure its based on the shard name
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d20ae2c83f2a2270ec27e8d]
<FromGitter> <Blacksmoke16> seems to be the case
<waheedi> where does the ".lib/" come from? I can't seem to find it
<FromGitter> <Blacksmoke16> where does it get created?
<FromGitter> <asterite> yes, the docs for require resolution are wrong, they should be updated
<waheedi> make_relative_unless_absolute("#{relative_filename}/src/#{basename}.cr") where does "lib/" gets added
<FromGitter> <Blacksmoke16> dunno
<waheedi> asterite: what i'm missing from the docs?
<FromGitter> <asterite> saying that if you `require "foo"` it will also search "lib/foo/src/foo.cr"
<waheedi> return absolute_filename if File.exists?(absolute_filename) # file will not be there
<FromGitter> <Blacksmoke16> sanity check
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d20b6a4ae10eb58bd720bfb]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d20b6b6b2a6596c1a1faa83]
<FromGitter> <Blacksmoke16> i can see its starting and rolling back but the listing still gets saved
<FromGitter> <Blacksmoke16> let me try with raw pg shard
ht_ has quit [Quit: ht_]
<FromGitter> <Blacksmoke16> i think they're getting executed on different connections
<FromGitter> <Blacksmoke16> should that matter?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d20b9fd8193ce270f336799]
<FromGitter> <Blacksmoke16> that'll work for now...
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <mwlang> dockerizing this Lucky app is killin' me. :-p
<FromGitter> <Blacksmoke16> 😬
<FromGitter> <Blacksmoke16> now what
<FromGitter> <mwlang> well, to get the JS manifest files, I have to have yarn installed.
<FromGitter> <Blacksmoke16> shouldnt be too bad, just install it into the image?
<FromGitter> <mwlang> and after jumping through some hoops to figure that bit out, `yarn prod` command gives me an error.
<FromGitter> <Blacksmoke16> oh?
<FromGitter> <mwlang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d20bfa6fadb0544802e212e]
<FromGitter> <mwlang> I have version 1.16.0 locally on macOS and it's 1.16.0-1 on the docker container. `yarn prod` runs fine on macOS
<FromGitter> <mwlang> and inspecting that cli.js file, it appears to me to be identical on both.
<FromGitter> <j8r> and the node version?
<FromGitter> <mwlang> no idea. let me see if I can figure that out.
<FromGitter> <mwlang> Unpacking nodejs (4.2.6~dfsg-1ubuntu4.2)
<FromGitter> <j8r> lol
<FromGitter> <Blacksmoke16> seems quite old
<FromGitter> <Blacksmoke16> :
<FromGitter> <j8r> what image are you using, the official one?
<FromGitter> <mwlang> holy smokes, it's old.
<FromGitter> <mwlang> FROM crystallang/crystal:latest
<FromGitter> <j8r> my personal opinion is to use Alpine :)
<FromGitter> <j8r> The official one is based on Ubuntu 16.04
<FromGitter> <mwlang> hmmm....maybe high time I followed this guide and built my own. I'd really rather be working with ubuntu 18.04 since I know it extremely well. I know 16.04 too but it's sunsetting. https://manas.tech/blog/2017/04/03/shipping-crystal-apps-in-a-small-docker-image.html
<FromGitter> <Blacksmoke16> prob wouldnt be too hard to add npm
waheedi has quit [Quit: waheedi]
ht_ has joined #crystal-lang
mps has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> node*
snsei_ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
<FromGitter> <mwlang> kinda hard because I can't install curl. I'm assuming (but haven't verified) that a bunch of the package manager stuff was removed to reduce footprint.
<FromGitter> <mwlang> because apt-get install curl just says package not found.
<oprypin> mwlang, search for it. likely 'libcurl'
<FromGitter> <mwlang> to install yarn, I cheated by checking in the PGP key into the repo and just copying it over instead of using curl, but that's not really a good security practice.
<oprypin> could even have some version number as part of pkg name
waheedi has joined #crystal-lang
<oprypin> yea ok
<FromGitter> <mwlang> but then again, I am not at all sure crystallang::crystal image is based on Ubuntu or some ultra pared down debian image.
<FromGitter> <mwlang> since I'm learning docker more or less from the ground up, might as well learn how to build my own images so I do know what's in 'em. :-)
<FromGitter> <Blacksmoke16> Sounds like a plan
<FromGitter> <mwlang> I'm esp. curious about these multi-stage builds -- really awesome idea/feature.
<FromGitter> <Blacksmoke16> Mostly useful for prod builds
<FromGitter> <Blacksmoke16> Like build your js in one, then just copy the built files into nginx
<FromGitter> <tenebrousedge> pgp key sounds like an ENV var
<FromGitter> <mwlang> well, really, it needs to come from the source always since it's used to check signature of the debian package being installed.
<FromGitter> <mwlang> I was just forcing my way through a first time docker deploy/build and wanted to keep moving along.
<FromGitter> <Blacksmoke16> Works for me
<waheedi> would someone help me out with crystal env output?
<waheedi> for some reason I can see it trying to require some none sense path "/Users/Waheedi/projects/crystal/src/lib_c/x86_64-darwin/minitest/src/minitest/autorun/autorun.cr"
<waheedi> CRYSTAL_LIBRARY_PATH="/Users/Waheed/projects/crystal/src"
<waheedi> it seems this env var is related somehow
<FromGitter> <Blacksmoke16> pretty sure thats used for linking c libs
<FromGitter> <Blacksmoke16> `The compiler uses the CRYSTAL_LIBRARY_PATH environment variable as a first lookup destination for static and dynamic libraries that are to be linked. This can be used to provide static versions of libraries that are also available as dynamic libraries.`
<FromGitter> <Blacksmoke16> you still having trouble requiring minitest?
<waheedi> a problem requiring any shard
<waheedi> minutest is just an example
<waheedi> minitest*
<FromGitter> <Blacksmoke16> have some code to share?
<waheedi> why its looking for minitest there it should be looking in Dir.current + "lib/" + "minitest/src/minitest/autorun/autorun.cr"
<FromGitter> <Blacksmoke16> and then doing like `crystal src/test.cr`?
<waheedi> crystal run/build src/test.cr
<FromGitter> <Blacksmoke16> `crystal --version` `shards --version`?
<FromGitter> <cfsamson> Hi. Does anyone know where `puts` is implemented in the Crystal source code?
<waheedi> Crystal 0.29.0 [fbfe8b62f] (2019-07-06)
<waheedi> Shards 0.9.0
<waheedi> Shards 0.9.0 [81ea693] (2019-06-19)
<FromGitter> <cfsamson> Ha. Ok, so STDOUT is probably linking to some library then since that code didn't do much :)
<FromGitter> <cfsamson> Ok, interesting. Thanks
<FromGitter> <Blacksmoke16> stdout is just an IO `IO::FileDescriptor.from_stdio(1)`
<FromGitter> <dscottboggs_gitlab> Is there a way to make a reference type immutable, or to take a deep copy of a refence's value?
<FromGitter> <cfsamson> I see. Well somehow there is a lock on stdout when compiling for windows that doesn't seem to be released, so somwhere in the source there must be a conditional compilation for `stdout` on different arcitectures? It does work on Linux...
<FromGitter> <Blacksmoke16> hmm, let me try upgrading to new shards version
<waheedi> Thanks @Blacksmoke16
<FromGitter> <Blacksmoke16> what happens if you did like `rm -rf ~/.cache/shards/ ~/.cache/crystal/ shard.lock lib/`
<FromGitter> <Blacksmoke16> then try to install and run again
<FromGitter> <Blacksmoke16> :shrug:
<waheedi> same
<waheedi> the "lib/" is missing
<FromGitter> <dscottboggs_gitlab> It looks like I'm going to have to define a custom `#clone`
<waheedi> Something should be adding the "lib/" path but i can't find it if it exists?
<FromGitter> <dscottboggs_gitlab> oh, no there's a macro `def_clone` that's nice :)
<FromGitter> <Blacksmoke16> indeed :)
<FromGitter> <Blacksmoke16> let me try on my mac i guess
<FromGitter> <asterite> whaeedi: what's the output of `crystal env`, in particular CRYSTAL_PATH ?
<waheedi> CRYSTAL_PATH="/Users/Waheed/projects/crystal/src"
<waheedi> where crystal GitHub repo resides @asterite
<FromGitter> <asterite> how did you install crystal? It's missing the "lib" component in CRYSTAL_PATH
<waheedi> what does it show on your end `crystal env`
<FromGitter> <dscottboggs_gitlab> I wish crystal made immutabilty easier :/
<waheedi> i installed by make
<FromGitter> <asterite> make doesn't install crystal
<FromGitter> <asterite> it just creates a compiler
<FromGitter> <asterite> you have to install crystal using pkg, homebrew, ubuntu apt-get, etc.
<waheedi> yeah before that the first crystal I used was through brew
<waheedi> then i built crystal
<FromGitter> <asterite> how are you invoking crystal?
<FromGitter> <asterite> cool, then you need to use `bin/crystal` from the repo
<waheedi> then copied the crystal bin that I built as a crystal executable
<waheedi> ok
<waheedi> so I can't use the .build/crystal one?
<waheedi> I see
<FromGitter> <asterite> Oh, if you try to use `.build/crystal` it will be missing CRYSTAL_PATH
<FromGitter> <Blacksmoke16> `./bin/crystal` in the repo is a script that sets some env stuff
<FromGitter> <asterite> crystal is always executed through a wrapper that sets CRYSTAL_PATH
<waheedi> yeah and crystal env, shows all the env variables correctly
<waheedi> or not?
<waheedi> i can see all the vars being set when issuing crystal env, using the built crystal bin
<waheedi> ok
<waheedi> it works now
<waheedi> i thought it should be simpler than this :)
<FromGitter> <Blacksmoke16> 💯 nice
<waheedi> thanks @Blacksmoke16 and @asterite
<FromGitter> <Blacksmoke16> `brew install crystal`
oprypin has quit [Quit: No Ping reply in 180 seconds.]
oprypin has joined #crystal-lang
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab could you not use a record?
<FromGitter> <dscottboggs_gitlab> I don't mean a reference to an immutable type, I mean an immutable reference to a mutable type
<FromGitter> <dscottboggs_gitlab> Like an actual constant
<FromGitter> <Blacksmoke16> oh like `FOO = [1,2,3]` to make sure the values dont get changes or more values pushed/removed?
<FromGitter> <dscottboggs_gitlab> exactly
<FromGitter> <Blacksmoke16> we were just talking about this the other day
<FromGitter> <Blacksmoke16> ruby has the `freeze` method
<FromGitter> <dscottboggs_gitlab> Like i get the rationale for what we have, i just wish there was a way to do the other thing too
absolutejam4 has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> I'm having to use `#clone` which is not the most efficient. It's just tests so it's not a huge deal but in general taking a deep copy just to avoid changing a constant seems a little...wrong?
<FromGitter> <dscottboggs_gitlab> hm, maybe this could be implemented as a library using macros and annotations...
<FromGitter> <Blacksmoke16> maybe worth a forum post
<waheedi> so basically the only thing thats missing is the :lib directive in the env variable
<waheedi> CRYSTAL_PATH is used to look up the shards inside lib in that way
<waheedi> it basically do a lookup on all values in CRYSTAL_PATH
<waheedi> that's where the "lib/" comes from :)
<waheedi> so I can just use the built crystal bin directly :)
<FromGitter> <Blacksmoke16> sounds right
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab prob would be doable somehow
<FromGitter> <dscottboggs_gitlab> I'll take a look into it if I remember/have time this week
<FromGitter> <dscottboggs_gitlab> making a forum post about it
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> maybe something with the visitor methods
<FromGitter> <Blacksmoke16> on assign check if the instance is "readonly" and raise if so, i.e.
<FromGitter> <Blacksmoke16> ```@[Readonly] ⏎ FOO = [1,2,3] ⏎ ⏎ FOO << 4 # compile error``` [https://gitter.im/crystal-lang/crystal?at=5d20e3e1b2a6596c1a20e4ea]
<FromGitter> <Blacksmoke16> er assign would only catch `FOO = "foo"`, nvm
<FromGitter> <Blacksmoke16> id imagine you could catch that at compile time tho
<FromGitter> <Blacksmoke16> but :shrug: see how it goes
<absolutejam4> record Handler,
<absolutejam4> flag : String,
<absolutejam4> block : String ->
<absolutejam4> what's the arrow ^ ?
<absolutejam4> a lambda?
<absolutejam4> oh no
<FromGitter> <Blacksmoke16> type restriction on the block
<FromGitter> <Blacksmoke16> should only yield a string and return anything
<absolutejam4> ah
<absolutejam4> is -> return definition in a method?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <mwlang> *grrr* still at it with docker....now I have a working yarn
<FromGitter> <mwlang> but now need webpack installed.
<FromGitter> <dscottboggs_gitlab> it's there to represent a "proc"... see https://crystal-lang.org/reference/syntax_and_semantics/blocks_and_procs.html
<FromGitter> <dscottboggs_gitlab> @absolutejam4 ^^
<absolutejam4> I meant is it the same for methods, but that's `def foo : ReturnType`
<absolutejam4> and I'd not seen many examples of explicit return type. Guess the compiler is just that good
<absolutejam4> thanks dscoottboggs_gitlab
gangstacat has quit [Ping timeout: 252 seconds]
<absolutejam4> I feel `: String ->` is a bit ambiguous
<FromGitter> <Blacksmoke16> its unique to blocks `&block : YieldType -> ReturnType`
<FromGitter> <Blacksmoke16> `: String -> _` would be a bit more clear
<absolutejam4> yeah
<FromGitter> <Blacksmoke16> i mean thats a thing you can do, just wasnt in this case i guess
<FromGitter> <mwlang> Is it normal for ```docker-compose up``` to sit around for 2 to 5 minutes on Digital Ocean VPS with 0% CPU utilization?
<FromGitter> <mwlang> before the first command ever starts executing?
<FromGitter> <Blacksmoke16> prob not
<FromGitter> <mwlang> you, know...I think I had this sort of extreme lagging issue last time I tried to start a VPS in the SFO datacenter.
<FromGitter> <mwlang> gonna flip it over to NYC
<FromGitter> <Blacksmoke16> well could it just take that long to build the images?
<FromGitter> <Blacksmoke16> since the wouldnt be there already/already built
<FromGitter> <mwlang> it might take that long to build an image, but I should see step 1, step 2, etc. as it goes.
<absolutejam4> oh, that's clearer at least Blacksmoke16, thanks
<FromGitter> <mwlang> and besides... 0% CPU the whole time.
<FromGitter> <mwlang> almost like a DNS resolution time out issue rather than a VPS issue.
<FromGitter> <Blacksmoke16> yea doing that would make `yield "foo"` work, but `yield 123` would raise a compile error
<FromGitter> <Blacksmoke16> yea dunno
<FromGitter> <j8r> @dscottboggs_gitlab what about `#dup`?
<FromGitter> <dscottboggs_gitlab> #dup is only a shallow copy. In the case of a reference type, that creates a new pointer which points to the same area of memory
ashirase has quit [Quit: ZNC - http://znc.in]
absolutejam4 has quit [Ping timeout: 244 seconds]
moei has quit [Ping timeout: 244 seconds]
moei has joined #crystal-lang
absolutejam4 has joined #crystal-lang
gangstacat has joined #crystal-lang
<FromGitter> <Blacksmoke16> could also use your own images in other images
<FromGitter> <Blacksmoke16> like at work we have a base image that has the OS/common things, then other images just use that and add specific things depending on what they are going to be used for
<FromGitter> <j8r> no from scratch @Blacksmoke16 ?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <j8r> the best would be to build statically the binary on Alpine, then put it in a `from scratch` image (multi stage build)
<FromGitter> <Blacksmoke16> oh sorry i just meant in general using docker, not specific to crystal
<FromGitter> <Blacksmoke16> i tried that using your image but got some `"/bin/sh"` error
<FromGitter> <j8r> what I said can be also done in general too
<FromGitter> <j8r> `/bin/sh` errors?
<FromGitter> <Blacksmoke16> ill see if i can reproduce
<FromGitter> <j8r> keep it mind the interpreter isn't bash
<FromGitter> <Blacksmoke16> that was prob it
absolutejam1 has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 246 seconds]
alex`` has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
sorcus has quit [Quit: WeeChat 2.5]
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
alex`` has quit [Ping timeout: 246 seconds]
snsei__ has joined #crystal-lang
alex`` has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
jrayhawk has quit [Ping timeout: 244 seconds]
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
jrayhawk has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> made this a little while ago but made it a bit better
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d210813631d3433ba399c92]
<FromGitter> <Blacksmoke16> `field! type_id : Int32, annotations: ["@[Assert::Exists(model_class: EveShoppingApi::Models::Type)]"]`
<FromGitter> <Blacksmoke16> usage is say you have a record you are POSTing, can add this annotation to a field/property and assert the id supplied in the post body actually exists
<FromGitter> <Blacksmoke16> if it doesnt you get a ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d210864b2a6596c1a21df89]
<FromGitter> <Blacksmoke16> still using FKs in the database, but this way there is no code that has to check this in the controller code as it all happens on deserialization
<FromGitter> <mwlang> very nice.
ht_ has quit [Remote host closed the connection]
<FromGitter> <girng> only reason i'm for guard clauses is because of what blacksmoke did to my code yesterday lol. literally transformed it into a way more readable version
<FromGitter> <girng> that's.. a good reason too
<FromGitter> <girng> they also let the local variable be accessed underneath the clause which is amazing. i always thought local variables were bound to their block / inside if statement
<FromGitter> <alexherbo2> @mwlang Thanks you very much for you ws Gist
<FromGitter> <alexherbo2> and Crystal patterns
<FromGitter> <j8r> @dscottboggs_gitlab what about making `Fixtures` a struct?
<FromGitter> <j8r> (And `CONFIG` a getter)
<FromGitter> <dscottboggs_gitlab> `users` is an `Array(User)` which is a mutable reference type
<FromGitter> <dscottboggs_gitlab> obviously, one needs to copy the original memory referenced by the `CONFIG` value, but that, and the enforcement that it must not be mutated, should both be enforceable at compile time IMO
<FromGitter> <dscottboggs_gitlab> all of this is possible via macros though (I think)
<FromGitter> <dscottboggs_gitlab> although I'm probably wrong because @asterite says otherwise and he's usually right compared to me 😆
snsei__ has joined #crystal-lang
<FromGitter> <j8r> The constant would become a getter
<FromGitter> <j8r> That was we would like: a new `Fixtures` instance per spec
<alex``> is it possible for getter to have a type?
<alex``> getter/setter
<FromGitter> <dscottboggs_gitlab> That was my solution -- recursively `def_clone` on all types under `Config` so that it can be `#clone`d before every spec. However, the compiler should have been *capable* of at least warning me that I was about to mutate a value which is expected to be constant, if not totally fail compilation with a helpful stack trace
<alex``> don’t found this line right
<FromGitter> <dscottboggs_gitlab> alex, what?
<FromGitter> <dscottboggs_gitlab> OH! I see
<alex``> would be a way in the module definition to set `observers` to `[] of Observer`
<FromGitter> <dscottboggs_gitlab> That could just as easily be ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d2115b2ed8ed058b5967ef2]
<alex``> oh ok
<alex``> looks nicer
<alex``> is module `Observable(T)` and `include Observable(Observer)` required?
<alex``> could it be just `module Observable` / `include Observable`?
<FromGitter> <dscottboggs_gitlab> It could also be ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d21162532132d6c1bb549ff]
<FromGitter> <dscottboggs_gitlab> that's how I would do it
<FromGitter> <alexherbo2> `T` here represent `Observer` or `Fighter`?
<FromGitter> <alexherbo2> I don’t get why `(T)` is for
<FromGitter> <alexherbo2> @dscottboggs_gitlab why it’s not `getter observers : Array(Observer)`
<FromGitter> <dscottboggs_gitlab> ok so...it looks like cone would make a class which is independent of this library which inherits from `Observer`. This type must implement `#update(fighter)`, whatever `fighter` is ¯\_(ツ)_/¯
<FromGitter> <dscottboggs_gitlab> yep it probably should be @alexherbo2
<FromGitter> <dscottboggs_gitlab> Also, `Observer` could be an interface/module
<FromGitter> <alexherbo2> `T` has a special meaning?
laaron- has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> T is the conventional use for a generic tpye
laaron has quit [Remote host closed the connection]
<FromGitter> <dscottboggs_gitlab> like `Array(T)`
<FromGitter> <alexherbo2> `getter observers : Array(T) { [] of T }`, `{ [] of T }` is necessary?
<FromGitter> <alexherbo2> or I can drop it
<FromGitter> <dscottboggs_gitlab> so... that's a language feature which I really like but I'm not sure is a great Idea
<FromGitter> <alexherbo2> never used `{ ... }` part, I assume it’s for initializing the values
<FromGitter> <dscottboggs_gitlab> `property`, `getter`, and `setter` accept an optional block which lazily instantiates a default value
<FromGitter> <dscottboggs_gitlab> one can also eagerly instantiate a default value like `getter observers = [] of Observer`
<FromGitter> <j8r> @alexherbo2 yes that's memoization
<FromGitter> <alexherbo2> I never used the observer pattern, it looks very useful
snsei__ has quit [Remote host closed the connection]
alex`` has quit [Ping timeout: 258 seconds]
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab rip
<FromGitter> <Blacksmoke16> dont know enough about the type sys
moei has quit [Quit: Leaving...]
<FromGitter> <dscottboggs_gitlab> 🤞 here's hoping it's possible
<FromGitter> <dscottboggs_gitlab> shit crossed fingers emoji doesn't work in gitte
<FromGitter> <dscottboggs_gitlab> l;ame
<FromGitter> <Blacksmoke16> hm? i see it quite fine
absolutejam1 has quit [Ping timeout: 245 seconds]
waheedi has quit [Quit: waheedi]
<FromGitter> <girng> works here too
<FromGitter> <girng> 🤞🤞🤞🤞🤞🤞🤞🤞🤞🤞🤞🤞
<FromGitter> <Blacksmoke16> naw i see boxes
<FromGitter> <Blacksmoke16> on my desktop at least
<FromGitter> <girng> i thought you said you see it just fine
<FromGitter> <girng> now, boxes?
<FromGitter> <girng> what's going on
<FromGitter> <Blacksmoke16> phone was fine, desktop boxes
<FromGitter> <girng> you post on gitter on your phone?
<FromGitter> <girng> i'm on desktop, and see them
<FromGitter> <Blacksmoke16> when im lazy sitting on the couch its easier than getting up :P
<FromGitter> <Blacksmoke16> prob dont have fonts installed or something
<FromGitter> <girng> lol true dat
<FromGitter> <girng> i just ahte typing on the phone
<FromGitter> <girng> my thumbs are too fat
<FromGitter> <girng> and fingers
<FromGitter> <Blacksmoke16> if its more than a few words then ill get it
<FromGitter> <girng> anyways, i hate emojis
<FromGitter> <girng> i only liked text based ones
<FromGitter> <girng> there are so many variations of emojis, trying to have the same 1 for all devices is insane and not possible
<FromGitter> <girng> and might distort the emotion expressed by the user
<FromGitter> <girng> unless the emojis are used specific for a site (bbcode to emoji parser), then it's fine. but emojis from ASCII that are converted on the browser are cancer