<FromGitter>
<parruda> Hey guys, I am trying to create a FIFO and I saw a very old IRC suggesting I could use `LibC.mkfifo`. I was wondering what the arguments are?
<FromGitter>
<parruda> Name of the fifo and permissions?
<oprypin>
parruda: first of all, "create a first in first out" does not make much sense in general. also, what are you trying to do?
<FromGitter>
<parruda> I am trying to do in crystal the same thing I can do when I run the command mkfifo
<oprypin>
i don't know that command and no, that's not an end goal
<FromGitter>
<parruda> But I am having trouble writing to the named pipe. I have tried `File.open(“./pipe”, “w+”).puts “test”` and some other variations, but it hangs.
<FromGitter>
<parruda> What’s the correct way of doing this?
<FromGitter>
<icyleaf> `forward_missing_to` is used inside of Object, i want use outside of it and without passed nothing instance vars
blove has joined #crystal-lang
blove has quit [Quit: WeeChat 2.2]
_whitelogger has joined #crystal-lang
<FromGitter>
<proyb6> ::HTTP::Server.new
<FromGitter>
<proyb6> I'm always curious what is the :: before the HTTP?
<FromGitter>
<proyb6> just seen in Icyleaf swagger code as well
<FromGitter>
<anamba> @proyb6 think of it like a leading / in a file path. in this case, it refers to the top level HTTP in stdlib (there is probably another HTTP in the same scope as that call that would take precedence without the ::)
<FromGitter>
<proyb6> @anamba I see, I prefer to clearly declare from stdlib to avoid devs misassuming and use the wrong scope, is there a way to fully declare naming?
<FromGitter>
<proyb6> X
<FromGitter>
<anamba> i guess you could always write it as `::HTTP::Server` but that would be sort of unusual i think?
rohitpaulk has joined #crystal-lang
<FromGitter>
<proyb6> Yeah, looks a bit alien to me and for newbies
sp3ncer has joined #crystal-lang
<FromGitter>
<icyleaf> This is also use in Ruby :)
<FromGitter>
<proyb6> Oh, could be fine 😁
<FromGitter>
<Qard> Is there a good way to recursively convert a JSON::Any to the corresponding primitive types?
<FromGitter>
<Qard> Maybe there's a module that does that already somewhere?
<FromGitter>
<jemc> There's not really a good way to do that if you don't statically know the shape of the object you want to deal with. The `JSON::Any` abstraction is sort of a necessary part of dealing with that uncertainty in the type system
<FromGitter>
<Qard> In theory I could make a pull request to add support for JSON::Any to that module, but I figured there might be a simpler way than manually writing my own conversion, whether that be in my own code or in a PR to that.
<FromGitter>
<jemc> hm, you know I guess I was assuming that type aliases couldn't be directly recursive, but apparently, they can: `crystal eval 'alias JSON = Nil | Bool | Int64 | Float64 | Array(JSON) | Hash(String, JSON); p [nil, true, [false, [true] of JSON] of JSON] of JSON'`
<FromGitter>
<jemc> I'm coming from another language (Pony) where we did JSON the same way as `JSON::Any` because of that limitation, but in Crystal the direct type alias recursion seems to work (unless there are other pitfalls I'm not seeing)
<FromGitter>
<kingsleyh> hi - I'm trying to build crystal_lib on my mac - and getting this error - could anyone point me in the right direction to fix it?
Vexatos has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
t1|Mike has joined #crystal-lang
<FromGitter>
<vladfaust> It would be so great if we had some kind of knowledge base where developers could share such tips
<jokke>
anyone in the vicinity of frankfurt germany who'd be interested in a crystal meetup?
<jokke>
i'm pretty sure i could organize one at our offices
<jokke>
would be cool to meet people and exchange ideas
return0e has quit [Ping timeout: 268 seconds]
rohitpaulk has quit [Ping timeout: 252 seconds]
return0e has joined #crystal-lang
<FromGitter>
<asterite> @jemc Yes, it was recursive before but it's a bit more cumbersome and unintuitive to work with. There's an explanation here: https://github.com/crystal-lang/crystal/pull/5183 . To this day I can't choose which alternative is better, but not having recursive aliases in the language (I'd like to remove them) simplifies the language a lot
<FromGitter>
<DRVTiny> Hello4all! ⏎ How to implement structure for usage with libc which will be aligned to "long" type boundary?
<FromGitter>
<DRVTiny> I want to implement POSIX::Semaphore class, but i dont know how to declare sem_* functions, which operates on/with sem_t
Jenz has joined #crystal-lang
<Jenz>
>> p +-+-10
<Jenz>
How was it, did we have a bot in here?
<Jenz>
(That can eval crystal code)
<FromGitter>
<DRVTiny> Oh, yes. I have to do it, because i need to implement "guarding thread" to do cleaning work after program finished by some exit signal like TERM, INT, etc. ⏎ Standard Crystal implementation of signal handlers is awful, because signal handlers useless with any spawned code which is doing long calculations.
<FromGitter>
<DRVTiny> @FromIRC 10
* Jenz
O_o
<jokke>
is there any ETA for 0.27.1
<jokke>
?
<jokke>
for those thinking crystal isn't suited for anything but small projects or micro services: my current project has a codebase with >3k lines of code (not including the lib and spec directory) and it works like a charm.
<jokke>
including lib and spec it's a whooping 33k lines
* Jenz
:O
<Jenz>
How long does it take to compile?
<FromGitter>
<kingsleyh> great question!
<jokke>
without --release: 0.52s user 0.10s system 6% cpu 9.506 total
<Jenz>
0.52s user? What shell (framework) do you use!
* Jenz
XD
<jokke>
:D that's because it's run in docker
<Jenz>
Oh
<jokke>
i have to compile for 0.26.0 because that's the only version working in alpine
<Jenz>
Haha, ok, either 9.5 is really nice
<Jenz>
s/either/either way/
<jokke>
yeah it's quite ok
<Jenz>
On my old MacBook Air though...
<jokke>
(i need alpine, because i'm statically linking and deploying as a docker image based on the scratch image)
<jokke>
with --release it takes ages though
* Jenz
doesn't know what a scratch image is
<jokke>
Jenz: it's empty
<jokke>
there's nothing there
<Jenz>
oh ok
<jokke>
so you can just copy the statically linked binary into the image and then set CMD to ["/bin/your-program"]
<jokke>
with --release: 0.56s user 0.10s system 0% cpu 1:38.63 total
<jokke>
but that's done by the CI anyway
<FromGitter>
<Blacksmoke16> depends on what your project is doing, my project + ameba (is the only lib) and is ~14k lines
<FromGitter>
<Blacksmoke16> but build in release takes like less than a sec
<FromGitter>
<Blacksmoke16> granted most of those lines are specs
<FromGitter>
<j8r> I've just further improved the performance of https://github.com/j8r/con#benchmarks, 10% faster than stdlib's JSON for parsing, 50% faster for building
<Jenz>
Oh wow, I like, @j8r!
<jokke>
j8r: nice! starred
<FromGitter>
<j8r> thanks :) I hope the work could be reused to improve the JSON parser back
<Jenz>
_Cretin_ Object Notation, huh
<jokke>
j8r: hm any reason you're implementing mapping instead of serializable?
<jokke>
i _love_ JSON::Serializable
<FromGitter>
<j8r> (my mapping implem still need work like specs) Because I think it's too complicated
<jokke>
hmm
<jokke>
it is much more flexible though
<jokke>
and it's not that complicated
<FromGitter>
<j8r> we can already use what we already have
<FromGitter>
<j8r> getter, setter, property and ivars with type annotation
<FromGitter>
<j8r> to defined them as `String`, or `String?` if nillable etc
<Jenz>
Anyone got around to play with annotations yet?
<jokke>
j8r: but what if i want to use camel cased keys and store them in snake cased vars?
<jokke>
and what about converters?
<FromGitter>
<j8r> like `"CamelCase_var": somekey`
<jokke>
of course the simple scenario is always simple. With JSON::Serializable even more so since you literally don't have to do anything else than include it.
<jokke>
j8r: i mean if your serialized format uses camelCaseThing and your model has the attribute camel_case_thing
<FromGitter>
<j8r> which will iterate in all instance vars.
<jokke>
yeah
<jokke>
you will have to use @[JSON::Field(ignore: true)] to ignore something, that's correct
<FromGitter>
<j8r> jokke: this is white listing vs black listing.
<FromGitter>
<Blacksmoke16> there are some downfalls of serializable i tried to overcome with my shard
<FromGitter>
<Blacksmoke16> like if you use `key` it uses that for both deserialization and serialization
<FromGitter>
<Blacksmoke16> ignore does on both as well
<FromGitter>
<Blacksmoke16> id really like to implement like a `path` annotation that would traverse the JSON structure and set the ivar to that value, but is WIP
<FromGitter>
<drum445> What is the preferred way to store things like db credentials or ports to listen on, in PHP I would use a .env file and load from there?
<FromGitter>
<Blacksmoke16> env would prob best best bet yea
<FromGitter>
<Blacksmoke16> if you use docker thats easily configurable
<FromGitter>
<j8r> You'll have https and simple conf :)
<FromGitter>
<drum445> so if I'm using kemal, I would serve it on port 3000, then nginx/caddy would reroute an http(s) call to 3000 without having to specify the port?
<FromGitter>
<j8r> @ed i strongly recoend you setting up services - if your app/server crash/reboot, your app will be down
<FromGitter>
<DanilaFe> What you can do with nginx (and probably caddy) is to accept requests on port 80 / whatever the ssl port is, and route them to 3000 etc depending on what the URL even is
<FromGitter>
<DanilaFe> and yeah, I personally use systemd to manage my running kemal instances
<FromGitter>
<drum445> @j8r yeah I will do thanks mate. So Nginx basically just reroutes requests from port 80/443 to a localhost:PORT depending on the requet's path?
<FromGitter>
<j8r> @ed by default Caddy will expose https/443. If you write example.com, it's https://example.com(:443)
<FromGitter>
<drum445> Yeah I'm using let's encrypt/apache for most my stuff currently
<FromGitter>
<j8r> Yes, that a reverse proxy
<FromGitter>
<drum445> so you'd still run it in the same way I am ⏎ $ nohup ./app & ⏎ but you'd make that not face the internet and nginx route to it instead?
<FromGitter>
<drum445> well a service actually instead of that nohup stuff
<FromGitter>
<DanilaFe> Yeah, a service
<FromGitter>
<j8r> The good point of nginx/caddy and even haproxy is loadbalancing. You told me you have multiple servers. If one goes down, your app will still be available :)
<FromGitter>
<DanilaFe> you can configure it to auto-restart if it crashes
<FromGitter>
<drum445> ah lovely, think I've got it now - will get it running as a service and behind nginxor caddy tomorrow. Thanks fellas!
<FromGitter>
<DanilaFe> Good luck!
<FromGitter>
<drum445> It's the problem with just letting our ops team sort most of the server side stuff out ;)