ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.23.1 | Fund Crystal's development: | GH: | Docs: | API: | Gitter:
hightower3 has joined #crystal-lang
hightower4 has quit [Ping timeout: 258 seconds]
<FromGitter> <Qwerp-Derp> @faustinoaq Maybe there should be a feature that places an `end` statement automatically when you type stuff like `class` or `module` etc.? I personally don't use the extensions, I prefer to type the class and stuff out.
<FromGitter> <Qwerp-Derp> ^ This is for the VSCode plugin
<FromGitter> <bew> maybe this could be done by snippets, I personally have 15-20 snippets in my crystal workflow (in vim), to auto-add end, indentation, define a method, add brackets for macros, add a block (with/without args), etc.. @faustinoaq I don't know if vscode allows plugins to define snippets, if it is, I think it would be the way to go!
<FromGitter> <Qwerp-Derp> There's already something like where you type `class` for example and press Tab, the whole thing extends to a full `class`
<FromGitter> <Qwerp-Derp> With like an end statement
<FromGitter> <Qwerp-Derp> But I personally don't use it (don't ask me why :P), I think the auto-`end` with things like `class`, `def`, `case` and stuff would be great
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <bew> Oh ok, so there's already some snippets 🆒
<FromGitter> <Qwerp-Derp> Yeah, my phrasing was a bit odd :P, by "extension" I meant things like that `class` and Tab thing
<FromGitter> <bew> But then what's the difference for you between the already-there class snippet, and the auto-end you're suggesting?
<FromGitter> <bew> Does the class snippet do too much things for you?
<FromGitter> <Qwerp-Derp> Nah, the Tab just feels unnatural to me for some strange reason, since there's already auto-indentation
<FromGitter> <bew> Then change the key bound for the expand-snippet action? (Or sth like that)
<FromGitter> <Qwerp-Derp> Yeah, good point
<FromGitter> <bew> I personaly have it to the key above tab (not existant on some keyboard)
<FromGitter> <Qwerp-Derp> Can you make a function that takes a type as an argument?
<FromGitter> <fridgerator> ??
<5EXAAEL4X> [crystal] bcardiff closed pull request #5059: Fix socket initialization (master...fix/socket-initalization)
<07IAA92P8> [crystal] bcardiff pushed 1 new commit to master:
<07IAA92P8> crystal/master b830899 Brian J. Cardiff: Fix socket initialization (#5059)...
<travis-ci> crystal-lang/crystal#b830899 (master - Fix socket initialization (#5059)): The build passed.
andrewzah has quit [Ping timeout: 252 seconds]
andrewzah has joined #crystal-lang
<FromGitter> <jsilverMDX> hey guys, finally got Livepost running on Linux Mint 64
<FromGitter> <jsilverMDX> I think the answer to #1269 is that Debian needs to remove their libyajl patch..
<FromGitter> <jsilverMDX> I tried changing linker options as suggested and it didn't work.
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #crystal-lang
<FromGitter> <faustinoaq> > Maybe there should be a feature that places an end statement automatically... ⏎ ⏎ @Qwerp-Derp @bew Already exists an extension for this [0] ⏎ ⏎ (( "autoend")) ... []
sz0 has joined #crystal-lang
_whitelogger has joined #crystal-lang
balduin has quit [Ping timeout: 258 seconds]
<FromGitter> <bararchy> Papierkorb tuntap is awsone ! I'm gonna use it for interface management , thanks for it :)
<FromGitter> <Qwerp-Derp> @faustinoaq Wow that's so cool :D every time I want something there's a plugin for it in VSCode :P
<livcd> I cant wait for Crystal to actually happen :S
<txdv> what will happen with crystal?
sz0 has quit [Quit: Connection closed for inactivity]
Papierkorb_ has joined #crystal-lang
<livcd> txdv: to reach 1.0 :D
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<txdv> livcd: they promised a lot
<txdv> i doubt it will be easy to achieve
<txdv> M:N threading model
<txdv> rust promised it too
<txdv> they didn't deliver
<FromGitter> <ekremkaraca> Good morning!
<FromGitter> <ekremkaraca> Have a good week!
<FromGitter> <elorest> Good morning
<FromGitter> <ekremkaraca> Less than a month to go to army 🔫
<txdv> army?
<txdv> what country?
<livcd> i suspect israel :-)
<livcd> txdv: there's lots of things to be done before 1.0 :S we will see
<txdv> is there a list?
<FromGitter> <ekremkaraca> It's Turkey
<txdv> A great country with a great leader!
<FromGitter> <ekremkaraca> You mean Ataturk, the founder?
<txdv> yeah
<FromGitter> <ekremkaraca> Or RTE, incumbent one?
<FromGitter> <ekremkaraca> Thanks so much
<livcd> txdv: my biggest worries are related to windows support and compilation times :)
<FromGitter> <ekremkaraca> I am so glad to be heard praises like this
<txdv> does the turkish government monitor irc?
<Papierkorb_> Compilation times for me too. I'm wondering what could be done with LLVM though.
<txdv> i bet IRC is so irrelevant that nobody is listening to that
<txdv> :D
<FromGitter> <ekremkaraca> Irc is very less used here
<FromGitter> <ekremkaraca> So, there's no need to track it
<FromGitter> <bararchy> also, IRC uses SSL (if configured right) :)
<FromGitter> <ekremkaraca> But recently github was blocked
<FromGitter> <crisward> Github really?
<FromGitter> <crisward> That'd hurt
<FromGitter> <ekremkaraca> Yep
<Papierkorb_> IRC is easy to monitor. It's meant for public discussions anyway
<FromGitter> <bararchy> yeha that's true
<FromGitter> <bararchy> depends on server
<FromGitter> <bararchy> if it's a private one, no need to log
<Papierkorb_> And everyone to use TLS. And only allowing known users.
<Papierkorb_> And not doing something funny to the physical machine
<txdv> its cleartext anyway
<FromGitter> <bararchy> and everyone uses GPG with physical signiture verification ? ;)
<FromGitter> <bararchy> I made a Ruby client that was suposed to talk with other client's using GPG PKI, but IRC maximum lines rules kicked in hahah
<Papierkorb_> txdv: TLS..?
<FromGitter> <crisward> Is circumventing country based internet censorship difficult? Surely vpn's can just bypass it?
<txdv> not tls
<txdv> but a lot of people using irc just connect without encryption
<Papierkorb_> crisward, as long they're not simply blocking VPN protocols for the home users
<txdv> lol to stop email leaks
<txdv> poor old people dont understand how this shit works
<FromGitter> <ekremkaraca> Wikipedia is still blocked here
<Papierkorb_> crisward, Or go full China and scan all connections for suspicious behaviour
<txdv> the people responsible for the leaks are not even using github, google drive or dropbox
<FromGitter> <bararchy> well Papierkorb_ , you can always exfil data using multiple protocols if really needed
<txdv> china is fucked up
<txdv> i have to block it entirely
<FromGitter> <crisward> @ekremkaraca I can see why, their are lots of articles on there about censorship in turkey. Kind of cyclical.
<txdv> because if you don't block china and forget a patch for 1 week, your server will be compromised
rohitpaulk has joined #crystal-lang
<Papierkorb_> bararchy, of course you can. But it's still a cat & mouse game.
<FromGitter> <bararchy> in the end, I say, block all or allow all, middle ground is for noobs hahah
<Papierkorb_> Of course, but most users *are* noobs
<FromGitter> <bararchy> most users are not why you block github
<FromGitter> <bararchy> XD
<Papierkorb_> Not that long ago, you could surf for free from an airplane because they didn't deny outgoing DNS, which is great for tunneling. 1) Holy shit we can go online while crossing continents?! 2) Lawl.
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> VPlane (nextGen VPN) , it's an idea for a new service, hahah
<FromGitter> <bararchy> can never be targeted by a single state
<FromGitter> <bararchy> LOL
<FromGitter> <ekremkaraca> @crisward because of expressing that having a relationship between one of our minister and so called Islamic State
ShalokShalom has joined #crystal-lang
<FromGitter> <bararchy> Anyway, it's time for Crystal & Chill ⏎
<FromGitter> <ekremkaraca> Our government have some demands from Wikipedia like paying taxes
<FromGitter> <ekremkaraca> Yep, sorry for going off-topic
unshadow has joined #crystal-lang
<FromGitter> <bararchy> @ekremkaraca off-topic is a great way to grow as a community :) it bonds people together
unshadow has quit [Client Quit]
<FromGitter> <ekremkaraca> You right @bararchy
unshadow has joined #crystal-lang
alex`` has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
alex`` has quit [Ping timeout: 248 seconds]
alex`` has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
Groogy_ is now known as Groogy
<Groogy> Oi! o/
<Papierkorb_> Guten Tag
alex`` is now known as alexherbo2
alexherbo2 is now known as alex``
<FromGitter> <bew> Bonjour ;)
mark_66 has joined #crystal-lang
<FromGitter> <ansarizafar> I am want to port this wonderful validation library from Nodejs to Crystal. Can someone give me some pointers. The idea is to define different rules and a validate method to validate given object. ⏎ ⏎ ```code paste, see link``` []
rohitpaulk has joined #crystal-lang
sz0 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <mjago> wayland
<Papierkorb_> ansarizafar, that rule-syntax looks inherently incompatible with Crystal. Not that it's technically possible, but it'll always be plain bad.
<Papierkorb_> We have proper types, including ranges. You can even check for those.
rohitpaulk has quit [Ping timeout: 240 seconds]
<Papierkorb_> ansarizafar, First architecture that comes to my mind: have a `abstract class Rule`, and then `class RequiredRule < Rule` etc. Now, you add a method to the RuleSet class you just created called `#rule`. You overload this method for each Rule sub-class, basically passing through all arguments to the Rule's #initialize. The kicker is now that the #rule method is defined like: `def rule(requires); @rules <<; end`. Now,
<Papierkorb_> the user can write `rules.rule(requires: "Foo")`.
<Papierkorb_> Do note that this kind of library is *only* useful to validate variable "structures" like Hash, which are *no that common* in good Crystal code. In fact, I wouldn't use a library like this in my normal code. I'd instead simply use JSON.mapping with a custom converter for checks. Or even better, contribute a `validator:` option to the JSON.mapping function.
<FromGitter> <ansarizafar> In my use case, I want to validate parameters, sent by the users to a common Api endpoint(a variable Hash ). Keys are not known in advance so JSON.mapping can't be used.
<Papierkorb_> Is that shared API endpoint really required, or can you fix it?
<Papierkorb_> In any case, what I wrote above still holds: Using OOP paradigms instead of a random-rule-string gets you many benefits: 1) Type safety 2) The compiler complains when you mis-type 3) Nicer to read and write in general 4) It may be a ns faster.
<FromGitter> <ansarizafar> It's a Graphql inspired data layer(Single end point for all api calls), that I am trying to port from Nodejs. I have successfully ported most of the code including jwt authentication and role based authorization only the last part parameter validation is left.
<Papierkorb_> In that case, yes if there's not already a suitable validation shard for you (check, you do need a lib like this. As long you don't replicate the exact validation API, you'll be fine
<FromGitter> <ansarizafar> I have searched but no luck.
<FromGitter> <ansarizafar> I guess my use case is different
<Papierkorb_> Surprising, would've guessed there's already a dynamic-structure validation lib
<Papierkorb_> ansarizafar, please take my apologies then. Many devs coming from dynamic languages try to cram their dynamic knowledge into a static language, so I generally advise to check those static solutions first instead.
<FromGitter> <ansarizafar> You are right. I am still thinking in JavaScript.
<FromGitter> <ansarizafar> Forget the syntax. I am looking for a good validation lib for dynamic structures.
<Papierkorb_> Without thinking about the details, I think you could create something nice to use by either 1) overloading a common #rule method 2) having a method per kind-of-rule (#requires, ...) - Benefit of 2) is that the text editor has an easy time to auto-complete, easier to understand, and less ambigoous
<FromGitter> <ansarizafar> The idea of a Validator class with separate methods for each rule is good. But I don't want to write multiple statements to apply multiple validators for each parameter key in each api method. I need to automate the process somehow. ⏎ ⏎ ```validate(parameters, rules)``` []
<Papierkorb_> You could exploit `with X yield` for this. It's a bit advanced, but it lets you define the implicit self for the time of the block yield. Say you have `validate("foo"){ requires("bar"); in_range(1..4) }`. #validate could build a ``, with yield that to the block. That Dsl class then has the `#requires` etc. methods. Then you save typing, but can keep the logic
<Papierkorb_> Even more interesting, this would allow you to effortlessly define schemas for hierarchies.
<FromGitter> <krypton97>
<FromGitter> <krypton97> Some nice stuffs from google
<FromGitter> <krypton97> Courious to see if it outperforms react-native or nah
<FromGitter> <schoening> Has anyone been working on android / ios build recently?
<Papierkorb_> schoening, would also be interested hearing about Android
claudiuinberlin has quit [Read error: Connection reset by peer]
puskuruk has joined #crystal-lang
<Groogy> @ansarizafar it sounds like you want contract tests then? It's what I have implemented
<Papierkorb_> Groogy: he wants to validate data structures, not method arguments (... maybe that too?)
<Groogy> In my use case, I want to validate parameters, sent by the users to a common Api endpoint
<Groogy> oh yeah you are right I just misread that part
<Groogy> yeah no my library is not for that
<Papierkorb_> ... I mean you could add that to your lib lul. if it works with dynamic and static structures, allowing to (only) validate structures and/or method arguments at once, that'd be kinda cool
<Groogy> hmmm could you write up example what you mean?
<Groogy> you mean like "oh this hash should have a format sort of like this"?
<Papierkorb_> yes
<Papierkorb_> It's right now not exactly what your lib is after as far I understand, and while it's not directly the core usage for it(?), it may be an interesting addition on the long run.
<Groogy> hmm attached to a hash obj or whenever it enters a function?
<Groogy> well the library is more "a contract" between the programmer and the lib/class. Telling oyu what it expects, and what it ensures will be true
puskuruk has quit [Ping timeout: 260 seconds]
<Groogy> where this can kind of fit
<Papierkorb_> Well, for a function contract, like you're already doing. After that it'd be interesting to be able to invoke a validation on a structure alone
<Papierkorb_> Groogy: To catch stupid input from the programmer, and from the user too?
<Groogy> Well the code is not added when you compile in release mode by default. Contract programming is an extension of defensive programming. "Let the application fuck up and catch it as early as possible"
<Groogy> though you could of course enable it in release mode without much overhead but just like normal asserts, if you do a stupid test it is gonna be super slow
<Groogy> could have a requires_r, ensures_r and invariant_r which are always compiled in release mode as well or something like that
<Papierkorb_> Honestly, I think it's a security issue when asserts are removed in release mode builds (Same in C, meh)
<Groogy> Or you know what! I could just do a static list you can build yourself
<Groogy> marking certian classes as always generting their contracts
<Groogy> CrystalClear::RELEASE_CONTRACTS << FooBar
<Groogy> i.e I always want this to fail, even in release
<Papierkorb_> I'd actually prefer an explicit opt-out rather than opt-in
<Groogy> hmm the overhead should be quite negible with the new design actually.. so yeah
<Papierkorb_> I'd use your lib to e.g. shield me from malicious user input. If I forget in the heat of the moment to opt-in my class, I'd be f'd.
<Groogy> you can also catch the exception so :)
<Groogy> should probably allow some how custom exception in the contract if you want to
<Papierkorb_> And even if the checks are expensive (not because of unnecessary overhead, but because the check the programmer wrote is) then ... so what? Apparently, it's a complex thing to check for.
<Papierkorb_> Really interesting would be if somehow, you could call only the method contract (without the underlying method), to test validations in specs easily
<Papierkorb_> Without having to catch an exception, it returning the error message or nil (or even Bool) would be great for that
<Groogy> Actually I can do that super easy papier :D
<Papierkorb_> That on_contract_fail hook sounds useful
<Groogy> though you should probably run the tests, because the ensure test is usually on what you return fro mthe function
<Groogy> so you would have ot mock the return value somehow
<Papierkorb_> you have ensure contracts?
<Groogy> yeah
<Groogy> requires, ensure and invariants(class tests, run before and after every method call)
<Papierkorb_> ah, well, could you separate them from the argument contracts for the spec thing?
<Groogy> could just ignore running them yeah
<Papierkorb_> So that one could write some table-esque spec as test. Hopefully more readable than having to think up arguments that should trigger an ensure
<Groogy> actually talking about this, I should focus bit more on the library and make it so it integrates well with the specs system in Crystal
<Groogy> would be cool if I could autogenerate specs from contracts somehow
<Groogy> since the information is "literally there"
<Papierkorb_> Allowing calling the validations on their own, and a neat chapter explaining this (and/or sample code) would be fine I guess
<Papierkorb_> You can do that for simple tests. But is it worth it?
<Papierkorb_> Are you then testing the contracts intention, or the contracts code the programmer just wrote?
<Groogy> contracts intention, what the contract "guarrantees"
<Groogy> I mean like so you can do crystal spec
<Groogy> and get reasonable info back
<Papierkorb_> `requires(foo, to_equal: "Bar")`. you can check that, but what if I actually meant to write "barr" instead?
<Groogy> nah was thinking just a spec helper that scans the constants in CrystalClear module and dynamically creates tests for you or some such
<Groogy> so you get the dots and F's, etc.
<Papierkorb_> Oh a `expect_that_it(requires(foo, to_equal: "bar"))` macro?
<Groogy> kind of yeah
<Papierkorb_> You could do that, yep.
<Groogy> and then voila you don't have to write two different sets of tests, you can just magically use crystal spec
<Papierkorb_> And would rather nicely. I mean, the it text would almost always say what the block does almost exactly anyway
<Papierkorb_> Oh, I would've used spec in any case
<Papierkorb_> A shard not offering spec integration doesn't prevent specs (thankfully)
<Groogy> No no, but I mean I can integrate better with specs than currently
<Papierkorb_> Yes
<Groogy> damnit I was only supposed to do a small face lift xD
sz0 has quit [Quit: Connection closed for inactivity]
<Groogy> hmmmmmm is there a flag turned on when you are running specs that my macros could look at?
<Groogy> because I could literally do ( condition ).should eq true
<Papierkorb_> The generated code of the users business logic shouldn't change
<Groogy> hmmm true
<Groogy> so it has to be applied outside of the contracts somehow
<Papierkorb_> Just pull the pre and post checks into their own methods, which you also call from the "real" code, and then you can call these like normal
<Papierkorb_> In fact, that might turn out to be an interesting feature for edge-cases (in non-testing logic), while being helpful for testing
alex`` has quit [Quit: WeeChat 1.9]
<Groogy> #meth_name_pre_tests #meth_name_post_tests i.e
<Groogy> and maybe some methods to introspect on them if that need becomes evident
<Papierkorb_> If you use that suffix notation, make sure to check (and move) questions and bangs too
<FromGitter> <sdogruyol> Have a great week everyone
<Groogy> you too @sdogruyol
<Groogy> oh right that's true
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
<Groogy> might make it a post fix just to make my life easier
alexherbo2 is now known as alex``
<Groogy> contract_pre_method_name, contract_post_method_name
<Groogy> prefix I mean
<crystal-gh> [crystal] straight-shoota closed pull request #4727: Add NamedTuple#update(other : NamedTuple) to merge values but keep type (master...named-tuple-update)
<Groogy> expect_contract_pass { foo.do_something }, expect_contract_fail { foo.do_something_bad }
alex`` has quit [Ping timeout: 258 seconds]
<Groogy> and then can add a variety of those probably to only test requires or ensures
<Groogy> or invariants
<Papierkorb_> `expect_contract_pass(foo.something(some, arguments, here))`. Then you can do the conversions in the outer macro easily
<Groogy> hmm you think argument is better than using a block?
<Groogy> block lookes pretty
<Papierkorb_> It looks pretty, but harder to extract the data from
<Groogy> though might make the macro more comples
<Groogy> yeah
alex`` has joined #crystal-lang
<Groogy> can also allow with arguments mock return values
<Groogy> expect_contract_fail(foo.something(args), mock_return)
<Groogy> if you want to be sure your ensure contract should fail
<Papierkorb_> Can't you split the pre/post steps there too?
<Groogy> yeah so you can do expect_require_contract_fail(...) if you want to etc.
<Papierkorb_> If I want to make sure the ensures are correct, I don't want the test to fail because I didn't think of some random arguments
<Papierkorb_> That could work
<Groogy> yeah that's what I mean you can do a mock return value to test on that you are 100% sure should fail the value
<Groogy> and if it doesn't, the contract is wrong
<Papierkorb_> yes
<Groogy> maybe should name it expect_contract_fail! (with a bang) then will actually call the method on the object while the expect_require_* and expect_ensure_* and expect_invariant_* will only do the tests
<Groogy> or hmmm
<Groogy> problem becomes ensure needs the return value
<Groogy> or *an* return value, will think on it during the day
<Papierkorb_> ffs. Hitting `e` while in a random file of someone elses github repository will fork the whole thing and put you into editing mode of that file, without asking if you want to
<FromGitter> <bararchy> Yap, happend to me to, github shourtcuts
ShalokShalom is now known as ShalokShalom2
balduin has joined #crystal-lang
balduin has quit [Ping timeout: 248 seconds]
ShalokShalom has joined #crystal-lang
ShalokShalom2 has quit [Ping timeout: 258 seconds]
LastWhisper____ has joined #crystal-lang
p0p0pr37 has quit [Ping timeout: 258 seconds]
sz0 has joined #crystal-lang
<FromGitter> <jwaldrip> @asterite looking like a release this week?
<FromGitter> <jwaldrip> Im drooling over the upcoming changes, on the edge of my seat...
<FromGitter> <bew> ahahah we still need these 2 to be fixed
p0p0pr37 has joined #crystal-lang
p0p0pr37 has joined #crystal-lang
<Papierkorb_> int128 looks neat. have to update code in various shards though >_>
<FromGitter> <sdogruyol> we have a hugeee diff from 0.23.0
<FromGitter> <bew> Papierkorb how are you using/gonna use Int128?
unshadow has quit [Quit: unshadow]
<FromGitter> <crisward> Can travis test against unreleased versions?
<FromGitter> <sdogruyol> nightly?
<FromGitter> <crisward> Ah, of course, Kemal does that doesn't it?
<Papierkorb_> bew, IIRC some shards of mine had to map integer types around, so I'd need to tell those about a whole new primitive
<FromGitter> <bew> ah ok
<FromGitter> <bew> wow ` 291 files changed, 9884 insertions(+), 2519 deletions(-)` between `0.23.1` & `master`
<FromGitter> <bew> (with ~4000 insertions in `` & `html/` 😂 )
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
Papierkorb_ has quit [Quit: Konversation terminated!]
p0p0pr37 has quit [Ping timeout: 246 seconds]
p0p0pr37_ is now known as p0p0pr37
linuksz has joined #crystal-lang
<linuksz> i have the following code:
<linuksz> it outputs:
<linuksz> false
<linuksz> true
<linuksz> why does the 'yes' process terminate after the sleep?
<FromGitter> <jose-rodrigues> Maybe because he don't have output.
<linuksz> but why doesn't do it before sleep?
<FromGitter> <jose-rodrigues> Probably because he don't ready tried to write to stdout at this moment
<linuksz> is it possible to reopen a file descriptor to another without crashing the program that writes to it?
<FromGitter> <bew> what are you trying to do?
<linuksz> i want to write a shell, but i now learning it yet, and currently i'm getting familiar with file descriptors.
<FromGitter> <jose-rodrigues> output ca be a Filedescriptor
<FromGitter> <jose-rodrigues> So you can rederict output to a file
<linuksz> i try the solution of every part of the basic shell before writing it entirely.
<linuksz> i have a background job. it's output is /dev/null.
<linuksz> and i run 'fg 1' in the shell
<linuksz> how should i do it?
<linuksz> i thought this:
<linuksz> my_process.output.reopen STDOUT
<linuksz> so the process will now print its output to the terminal
<FromGitter> <bew> and in some advanced programming in UNIX books
<FromGitter> <bew> and no, your solution won't work (the reopening)
<linuksz> why?
<linuksz> does it close the fd first?
<FromGitter> <bew> iirc a background job has no specific fd modification, it just don't run, or if it runs (like with `bg` it uses the same stdout/err as the shell (see the link above)
<FromGitter> <jose-rodrigues> What is the bash equivalent of what you want to do?
<FromGitter> <bew> probably `fg`
<linuksz> 'yes &'
<linuksz> this: 'fg 1'
<FromGitter> <jose-rodrigues> OK but why are you trying to play around with outputs?
<FromGitter> <jose-rodrigues> yes& keep the stdout
<linuksz> oh. indeed.
<linuksz> now tried it. :|
<FromGitter> <bew> linuksz, when you run `yes &` is `sh`, you'll see that the output still flow as hell ^^
snsei has joined #crystal-lang
<linuksz> then bash don't have a an equivalent for this
<FromGitter> <jwaldrip> @bew they are marked as approved. Is there work to be done on them still?
<linuksz> i want to redirect the output of bg jobs to /dev/null, and reopen to STDOUT with the 'fg' command
<linuksz> maybe a SIGSTOP first, then reopen, then SIGCONT?
<FromGitter> <jose-rodrigues> I don't this this is possible
<FromGitter> <bew> either way, linuksz: when you want to change the fd of a process you're executing (like: for a redirection to a file), you need to 1. fork, 2. open the files with proper fd & 3. exec the program. you can't change the fds of another process, anly your own
<FromGitter> <jose-rodrigues> @bew 42sh trained you well :D
<FromGitter> <bew> @jose-rodrigues ahah yes exactly ;)
<FromGitter> <sdogruyol> who's 42sh?
<FromGitter> <bew> and I wasn't even on the process execution part of the project! ^^ @sdogruyol it's a project at Epitech, were we need write a basic shell
<FromGitter> <jose-rodrigues> @sdogruyol Epitech is a french dev school
<FromGitter> <sdogruyol> lol
<FromGitter> <sdogruyol> good one
<FromGitter> <jose-rodrigues> Sorry my sentence was wrong. so you thinked it was a person. :)
<linuksz> oh, i now see that LibC.dup2 closes the fd before modifying it
<linuksz> it's not clear for me what reopen does. i thought that if fildes1 is reopened to fildes2, then anything written to fildes1 will go to fildes2. but why does it return a file descriptor? the C function dup2 returns int.
<crystal-gh> [crystal] mverzilli closed pull request #5022: Increase the precision of Time and Time::Span to nanoseconds (master...feature/time)
<FromGitter> <bew> did you read the man page of this function?
<FromGitter> <bew> @jwaldrip #5022 merged by @mverzilli 🎉
<FromGitter> <bew> only #5007 missing
<FromGitter> <jwaldrip> 1 more!!!
<FromGitter> <jwaldrip> thats the one I want is #5007
<FromGitter> <bew> go ping the issue!
<crystal-gh> [crystal] mverzilli pushed 1 new commit to master:
<crystal-gh> crystal/master 3335450 Ary Borenszweig: YAML revamp...
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<travis-ci> crystal-lang/crystal#3335450 (master - YAML revamp): The build was broken.
alex`` has quit [Ping timeout: 240 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
<travis-ci> crystal-lang/crystal#ab30165 (master - Increase the precision of Time and Time::Span to nanoseconds): The build passed.
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <DRVTiny> Hello, all! I was implemented the HTTPException class is such manner: ⏎ ⏎ ``` @status_code = 999 ⏎ @status_type = "kjk"``` ⏎ ⏎ :( []
<FromGitter> <DRVTiny> How to avoid stupid variable initialization in my class?
snsei has quit [Remote host closed the connection]
<FromGitter> <mverzilli> suppose the compiler let's you get away without initializing @status_type. What happens if you catch that exception outside of HTTPException and then call `type()` on it?
snsei has joined #crystal-lang
<FromGitter> <DRVTiny> ```Unhandled exception of the type Exception catched: Illegal HTTP status code received``` ⏎ ⏎ I dont need to call "type()" on "some", because i know that "some" is not an HTTPException (i've checked this earlier) []
<FromGitter> <DRVTiny> code and type methods are not defined in the class Exception, so i have to check Exception class, i must know that before doing anything with exception object (how to operate with the object of possibly unknown class?)
Xadusons has joined #crystal-lang
Xadusons has left #crystal-lang [#crystal-lang]
mark_66 has quit [Remote host closed the connection]
snsei has quit [Remote host closed the connection]
alex`` has joined #crystal-lang
LastWhisper____ has quit [Quit: Textual IRC Client:]
<FromGitter> <mverzilli> so you know that "some" is not an HTTPException but the compiler doesn't. Crystal checks that you properly initialized all ivars. You can for example initialize @status_type in the rescue clause of the HTTPException constructor so that all codepaths result on it being correctly initialized
<FromGitter> <mverzilli> you can declare @status_type as `String?` and initialize it to `nil` to signal that it's not set
Groogy2 has joined #crystal-lang
Groogy has quit [Disconnected by services]
Groogy2 is now known as Groogy
Groogy_ has joined #crystal-lang
<Groogy> ah finally home, time for some crystal <3
linuksz has quit [Quit: Leaving.]
<Groogy> bew you here?
<Groogy> oh right gotta tag you like @bew since you are on gitter :P
<FromGitter> <bararchy> how can I "sample" from hash ?
<FromGitter> <mverzilli> calling `sample` on `keys` doesn't cut it?
nikkkk has joined #crystal-lang
<FromGitter> <bararchy> yeha, that's what I do, just wanted to know if there is a sample that will return a k=>v pair
<Groogy> I don't get why I get two "doing 'require' var > 5 here
<Groogy> as far as I can see the call is only done once :/
<Groogy> if I remove the previous_def it only does it once
<Groogy> huh... seems like the definition of the method is still donewhen I do method_added, so I don't have to... define it again?
pawnbox has joined #crystal-lang
<FromGitter> <krypton97> just found there's a 24h coding event in my city *_*
<FromGitter> <krypton97> **
<FromGitter> <krypton97> assured food and 1k/0.5k euro prizes... what can I ask for more
<FromGitter> <jose-rodrigues> @krypton97 which city?
<FromGitter> <krypton97> Well,'s for students
<Groogy> hmm let's say #foo is a module method, is there some way to call it as if obj called it?
<Groogy> without including the module
<Groogy> using the module as a namespace to hide helper methods generated by my contracts
<FromGitter> <jwaldrip> w00t YAML revamp got merged
<FromGitter> <jwaldrip> Does that mean a release is going to be cut?
<FromGitter> <jwaldrip> Ah... other than the fact that we have a failing build in master
<Groogy> @bew I am getting the infinity loop on the contracts after changing a little :(
<Groogy> not sure it is being saved properly in the array
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
nikkkk has quit [Quit: Textual IRC Client:]
pawnbox has quit [Ping timeout: 240 seconds]
alex`` has quit [Ping timeout: 258 seconds]
Dimas has joined #crystal-lang
cyberarm has quit [Ping timeout: 258 seconds]
<Groogy> Papierkorb & @bew thx for the help earlier :) Done now with the base, spec integration to go
<Groogy> most of the stuff is also placed in a sub module under the class to keep the namespace clean
<crystal-gh> [crystal] straight-shoota opened pull request #5069: Fix for YAML spec failure with new nanoseconds precision (master...fix-yaml-spec-nanoseconds)
Dimas has quit [Quit: Page closed]
<FromGitter> <bew> Groogy, still there?
<FromGitter> <bew> During some refactor and trying to figure it out, I fixed it :p
<FromGitter> <bew> (maybe it was when I removed the 2 `\{{method}}` that are not useful? no idea, don't have to find why r8t now ^)
pawnbox has joined #crystal-lang
<crystal-gh> [crystal] akzhan opened pull request #5070: Time constructor now expect nanoseconds instead of milliseconds. (master...time-constructor=now-expect-nanoseconds-instead-of-milliseconds)
<FromGitter> <jwaldrip> @akzhan I about jumped on the breaking changes too.
<FromGitter> <jwaldrip> @akzhan @straight-shoota : good job on #5069 and #5070 ... SO EXCITED FOR THIS RELEASE
pawnbox has quit [Ping timeout: 240 seconds]
<Groogy> @bew I got it to work by just "hashing" it kinda
<Groogy> seemed like the instances would differ
<Groogy> of the Def object
<Groogy> what I ended up with
<FromGitter> <bew> Groogy I don't get what you're trying to do with the CLASS_DATA things
<FromGitter> <bew> Also, maybe you didn't see it, you can replace: `\{{("contract_pre_" + name.stringify).id}}` by `contract_pre_\{{name}}`
<FromGitter> <bew> (And the same apply for all your added methods)
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
<FromGitter> <Qwerp-Derp> Why does JSON have `JSON::Any` and `JSON::Type`? Isn't it better to replace all uses of `JSON::Type` with instances of `JSON::Any`?
cyberarm has joined #crystal-lang
<FromGitter> <georgeu2000> How should I run a server and Rack-like Crystal app? ⏎ Is this the server I should use?
<FromGitter> <georgeu2000> Are there any tutorials on this?
<FromGitter> <jose-rodrigues> @georgeu2000You don't want to use a framework?
<FromGitter> <opensas> @Qwerp-Derp it's a wrapper for all json types, allowing you to traverse unknown json structures. Once I had to implement a generic method to traverse unkwon json structures and I could do it just fine using JSON::Type, a case statement and recursive calls, have a look at: