jhass

Activity Graph

Page 1 of 251 | Next »

2019-04-16

[15:04:35] jhass: well you can just splat an array into Hash.dig, so create (and store) that array however you like
[15:05:00] jhass: depending on your keyspace a simple .split('.')/.join('.') might do

2019-04-13

[08:26:33] jhass: most people would just rely on nil being falsy and all numbers being truthy: found && found > 1
[12:23:01] jhass: regular expressions cannot properly parse arbitrarily nested parenthesized expressions
[12:23:10] jhass: it's a well-known limitation
[12:29:30] jhass: the keyword here is "arbitrarily"
[12:30:04] jhass: if you have a known limit it's certainly possible (wise to do... depends)
[12:30:20] jhass: just gets complicated quickly especially if you have more than one parenthesis type
[12:32:11] jhass: seems complicated for something that can be solved with just iterating char by char and keeping some state like open_expr_count +/-= 1
[16:50:12] jhass: *.net *.split

2019-04-11

[11:09:24] jhass: sounds like you're using a different rails environment?
[11:09:44] jhass: note the default test environment is meant to run unit and integration tests and the like
[11:09:57] jhass: for staging create a separate env or just use development
[11:10:23] jhass: what you're doing differently in the respective rails environments is hard to tell like this
[13:50:22] jhass: to me it looks like the spec code you shared is not the same as the one that produced the output you shared
[13:50:48] jhass: if it were it would say "expected: 7" and "got: 0", not vice versa
[13:51:06] jhass: so make sure you saved your file?
[13:52:16] jhass: then regardless of that, note that code outside of it, describe, context, before and after blocks is run first and once
[13:52:38] jhass: the spec code is not run sequentially as it's written into the file
[13:52:56] jhass: so api_response will be the same value for both of your it blocks
[13:54:19] jhass: oh wait, I got confused, you made the same typo in both of your it blocks
[13:54:27] jhass: so nvm regarding the wrong output
[13:54:41] jhass: it's just the second thing I mentioned
[13:56:02] jhass: you want to move your local variables inside your it blocks, or introduce more context blocks if you expect multiple specs with the same output and then use before blocks or let declarations inside
[21:53:34] jhass: in a browser websocket makes sense
[21:56:55] jhass: a socket is a socket but not a websocket
[21:57:03] jhass: websocket is protocol on top of http
[21:57:23] jhass: a plain socket is either TCP or UDP
[21:57:43] jhass: you really don't need rails here
[21:58:29] jhass: the next question you need to answer here is whether you want to work peer to peer or peer to server to peer
[21:59:16] jhass: do you have two clients connecting to a server or two clients connecting to each other
[22:16:03] jhass: for client to client you need to pick one of them to be the server and the other connect to it
[22:42:51] jhass: Ping timeout: 252 seconds
[22:52:40] jhass: has joined #ruby-offtopic
[22:52:40] jhass: has joined #ruby
[22:52:40] jhass: has joined #RubyOnRails

2019-04-05

[13:18:24] jhass: ConditionVariable#wait unlocks the mutex
[13:20:41] jhass: I can see performance benefits for coordinating between two threads of a set of n threads that contend for the same mutex
[13:22:10] jhass: since you can target which thread that's waiting for the thread first
[13:23:22] jhass: they're the same as Java's Object.wait/.notify/.notify_all
[13:24:44] jhass: pthread has them too, see the phtread_cond_* manpages
[13:27:34] jhass: eh, that once sentence came our garbled, I mean "since you can target which thread that's waiting for the mutex is woken up first"
[13:30:54] jhass: well in my scenario only two of them would coordinate with the condition variable, the others would just wait on the mutex
[13:32:11] jhass: https://en.wikipedia.org/wiki/Monitor_(synchronization)
[22:19:36] jhass: Read error: Connection reset by peer
[22:33:58] jhass: has joined #ruby-offtopic
[22:33:58] jhass: has joined #ruby
[22:33:58] jhass: has joined #RubyOnRails

2019-03-25

[13:30:04] jhass: Ping timeout: 264 seconds
[13:41:20] jhass: has joined #ruby-offtopic
[13:41:20] jhass: has joined #ruby
[13:41:20] jhass: has joined #RubyOnRails

2019-02-04

[09:25:12] jhass: Read error: Connection reset by peer
[09:33:40] jhass: has joined #ruby-offtopic
[09:33:40] jhass: has joined #ruby
[09:33:40] jhass: has joined #RubyOnRails

2019-01-28

[10:35:56] jhass: khalella: try prefixing the comamnd with bundle exec
[10:39:25] jhass: not necessarily, no
[10:39:48] jhass: especially since it errors out on trying to load a part of rake, which is loaded before Bundler gets a chance to restrict the load paths
[10:40:46] jhass: Looks like it was removed with rake 11
[10:40:52] jhass: https://github.com/ruby/rake/commit/f804fc2b56558100f840d2341823e74f25fc1e4a#diff-dbc34d9d73d6859840ceb61605d344c0
[10:41:18] jhass: so your AS version is either too old or your rake version is to new, depending on how you want to put it
[10:41:29] jhass: either restrict to an older rake version in your Gemfile or update your AS version
[10:42:23] jhass: well or maybe something else triggers it actually, given the trace part you showed is just the by AS overwritten version of require
[10:42:33] jhass: more of the traceback could hint the real culprit
[10:48:48] jhass: should be lib/tasks/import_to_tes.rake:5 then
[10:49:28] jhass: just remove that line and if that doesn't work out replace it with require 'rake/ext/string'
[10:56:52] jhass: (btw I guess the filename is typoed and meand to say test at the end :D)
[12:41:52] jhass: calaveraDeluxe08: https://guides.rubyonrails.org/action_controller_overview.html#json-parameters "wrap_parameters"
[12:45:39] jhass: this made more sense in the attr_accessible days I guess, so you could just MyModel.update params[:foo], nowadays with strong parameters you'd list the valid ones in the controller anyway so I don't see much point in it anymore tbh
[14:04:04] jhass: Tbh probably just https://api.rubyonrails.org/classes/ActiveRecord/Querying.html#method-i-find_by_sql
[14:05:01] jhass: it kinda forgoes the DB abstraction but for a couple of special queries per project that's usually handable
[14:05:28] jhass: just make it a nice helper in the model or some module somewhere, don't stuff it wherever you need it
[14:06:02] jhass: arel for CTEs? haven't seen that before
[14:06:47] jhass: I'd say it's a it depends, the abstraction may make it more opaque for these advanced things and you then have to know both well, the abstraction and the thing it tries to abstract
[14:07:56] jhass: basically here I would say do what your team is more comfortable with
[14:09:38] jhass: I guess that's actually somehow possible with arel but I never tried. And also not sure I agree, you kinda loose the benefits of either (portability on the one hand and one less thing to understand on the other)
[14:09:57] jhass: to answer your question I guess arel's docs would be https://www.rubydoc.info/gems/arel, but granted they're not awesome

2019-01-04

[14:09:46] jhass: sure, picture blocks as anonymous functions
[14:11:43] jhass: as soon as it's out of testing @ https://www.archlinux.org/packages/extra/x86_64/ruby/
[14:12:11] jhass: that is if that happens tomorrow, will be without laptop for the week after

2019-01-01

[17:54:56] jhass: I hope ruby 3 will finally drop the ?x syntax
[17:56:19] jhass: wasn't it introduced because String#[] used to return the codepoint?
[17:57:30] jhass: too bad, it's just confusing and we shouldn't be perl
[18:00:21] jhass: they are, ? is just confusing, forget about it
[18:02:59] jhass: ?a == 'a', thus (?a..?z) == ('a'..'z'). the right hand variant is the common one you should remember and use, forget about the ?a stuff

2018-12-20

[09:40:47] jhass: https://stackoverflow.com/a/11810594/2199687
[09:41:08] jhass: okay wait the comments say it's not working :D
[09:42:07] jhass: but something along those lines
[09:44:58] jhass: it's easy to test, if you close your browser now and open it again you should be signed out
[09:45:08] jhass: if you add it and do the same test again you should still be signed in
[09:46:12] jhass: https://www.rubydoc.info/github/plataformatec/devise/Devise/Models/Rememberable there are some options too
[09:48:23] jhass: you can also check the database on whether the field gets updated I guess
[14:58:57] jhass: I think it does different things on different platforms
[14:59:04] jhass: best effort basically
[15:25:38] jhass: mostly style
[15:25:51] jhass: there's a technical differencence in precedence
[15:26:16] jhass: foo bar do x end; # foo will receive the block
[15:26:28] jhass: foo bar { x }; # bar will receive the block
[15:27:16] jhass: but most people follow do/end for multiline, { / } for single line
[15:28:18] jhass: there's also a semantic style some people follow, see http://www.virtuouscode.com/2011/07/26/the-procedurefunction-block-convention-in-ruby/
[15:30:59] jhass: or for probably the earliest formulation https://web.archive.org/web/20041011120013/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc

2018-12-17

[12:41:56] jhass: phaul: well that solution might not be what they want as it doesn't allow for reoccurence of any letter and thus limits the space of possible sequences quite a bit
[12:42:07] jhass: also do you know why ?a is a thing? :P
[12:45:16] jhass: because before ruby 1.9 String#[] used to return the codepoint, and so did ?a then allowing for a quick way to check if a particular character is at a particular position in a string
[12:46:00] jhass: with 1.9 String#[] started to return a single character string and thus ?a was updated to represent that too to not break existing code in a subtle way
[12:46:21] jhass: but at the same time that change made the syntax quite obsoelete, which is why many frown on it
[12:48:56] jhass: I guess I'd gobble together Array.new and sample, so CHARSET = [*'a'..'z']; Array.new(10) { CHARSET.sample }.join
[12:50:26] jhass: or just "".yield_self {|s| 10.times { s << CHARSET.sample } }
[12:51:14] jhass: either is really pretty tbh
[12:51:19] jhass: eh, isn't
[12:53:13] jhass: usually those requirements come from generating some kind of opaque ID which you often can do quite nicely with an idea modulo some large prime and base36'ing the result
[12:53:32] jhass: with an ID I mean, dunno what's wrong with me today
[12:54:42] jhass: so it looks random to the user but knowing the prime you can go back in constant time
[13:02:29] jhass: I actually love it, I needed that behaviour more often than the other
[13:02:47] jhass: and it's much harder to reimplement efficiently
[13:03:18] jhass: .shuffle.take just breaks down once your input collection is big
[13:04:54] jhass: well I can only speculate but I would on more commonly useful and harder to do efficient compared to reimplementing the other behaviour efficiently
[15:44:10] jhass: exact same command to run in both cases?
[15:44:52] jhass: try require_relative instead
[15:46:02] jhass: given it's "ruby" that vanishes I wouldn't even rule out require doing something there
[15:46:19] jhass: anyway, what you're doing there is require_relative's job, let it do its work
[15:49:34] jhass: I'd still urge you to use require_relative ;)

2018-12-12

[03:52:51] jhass: Ping timeout: 250 seconds
[04:00:17] jhass: has joined #ruby-offtopic
[04:00:17] jhass: has joined #ruby
[04:00:17] jhass: has joined #RubyOnRails
[11:58:55] jhass: marz_d`ghostman: it seems you're still confused as to when code inside a context/describe block vs when code inside a before/it/let block is run
[11:59:04] jhass: I suggest you think about and review that
[11:59:45] jhass: try with a blank spec file and putting puts statement to confirm the order of execution that you think there is
[12:13:36] jhass: you could probably do exactly that, but it would be quite confusing to most over just consistently using let
[12:21:36] jhass: inner contexts and before blocks there can of course access let definitions of outer ones
[12:21:58] jhass: btw describe and context are technically just aliases, don't worry about differences there
[12:22:48] jhass: another scheme is to use @instance_vars in before blocks, but most people prefer let these days for its cleaner looks and lazy evaluation
[12:32:08] jhass: there's no general answer to that
[12:34:11] jhass: yes, let's throw away their value after each example
[12:38:36] jhass: you're still confused as to when code inside context/describe vs code inside let/before/it is run
[12:46:02] jhass: https://p.jhass.eu/76.rb
[12:46:11] jhass: marz_d`ghostman: ^
[12:57:49] jhass: oh, useful flag for rspec there might also be -f d
[13:00:17] jhass: rspec by default randomizes the order in which it runs your example
[13:00:22] jhass: *examples
[13:00:32] jhass: -seed gives a deterministic ordering
[13:21:10] jhass: now looking it --order defined is maybe the nicer option here to achieve that :D

2018-12-11

[16:10:34] jhass: Ookma-Kyi: running on what machine? Can't access it on which port? What machine does your hostname point to? What do you get when you try to access it? What did you try so far to resolve the issue?
[16:11:13] jhass: ah, fucking crosspost

2018-12-06

[12:33:20] jhass: dionysus69: wat
[12:44:06] jhass: pid = spawn ...; Process.waitpid pid if last
[12:45:44] jhass: if you really absolutely must exec; args = [...]; if last; exec *args; else; spawn *args; end
[12:47:32] jhass: I'd personally give Process.detach a chance first: pid = spawn ...; Process.detach pid
[12:49:45] jhass: I'm repeating myself: you're just reimplementing spawn there
[12:49:57] jhass: spawn is doing fork & exec for you

2018-12-05

[11:58:17] jhass: your best bet is https://bugs.ruby-lang.org/projects/ruby-trunk/search?utf8=%E2%9C%93&q=logger&scope=&all_words=&all_words=1&titles_only=&titles_only=1&issues=1&open_issues=1&attachments=0&options=0&commit=Submit
[12:57:47] jhass: 1) why use ruby for this over a shellscript? 2) why can't the ruby process be allowed to live on? 3) fork & exec is just reimplementing system()
[12:58:19] jhass: ah right it doesn't, system -> spawn
[13:00:17] jhass: for this simple case it'd be just what'd you write on the commandline and tacking an & at the end, but if you need secrets okay
[13:01:43] jhass: albeit if it's just one or two secret="$(ruby -ryaml -e "print YAML.load_file('config/secrets.yml')[ENV['RAILS_ENV']['secret']")" isn't too bad
[13:02:22] jhass: no, use spawn
[13:02:25] jhass: don't reimplement it
[13:05:17] jhass: actually try if you can just spawn six times and let the parent die, I'd expect the childs to get reparented
[13:34:35] jhass: spawn literally is fork & exec
[13:34:55] jhass: system is fork, exec & waitpid
[13:36:33] jhass: Kernel#` is fork, reopen stdout to a pipe in the parent, exec, read that pipe in the parent a& waitpid
[13:37:14] jhass: and then there's the open3 stdlib giving you a shitload more wrappers and options around doing fork & exec
[13:37:27] jhass: because it's actually hard to catch all the edge cases of doing it proper
[15:10:05] jhass: what's bundle -v?
[15:10:23] jhass: maybe something for #passenger or whatever the channel was
[15:12:29] jhass: does your Gemfile have a "ruby" line?
[15:12:35] jhass: if so, what is it?
[15:14:48] jhass: and ypur ruby version is what?
[15:17:41] jhass: mh, seems fine. As a workaround removing that line from the Gemfile should help

2018-11-29

[10:06:09] jhass: it doesn't render out as one query with a subselect?
[10:06:30] jhass: (which a good RDMS probably rewrites to a join)
[10:08:00] jhass: oh, I misread the parens
[10:13:01] jhass: just turn the .uniq.pluck into .distinct(:id)
[10:14:23] jhass: so it stays a relation and is interpolated as a subquery into the not in
[10:18:23] jhass: since id is the only field we want to select in the subquery it's fine
[10:19:01] jhass: mh, it's indeed undocumented at https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-where
[13:49:51] jhass: never looked at trailblazer before but I can't find where Wrap comes from
[14:00:21] jhass: but where is it defined? :/
[14:07:07] jhass: ah it's gone in the master branch
[14:10:44] jhass: ok idk this code is too hard to follow
[14:11:27] jhass: given the note about return values in the docs you linked, maybe something always returns something truthy there and it always stays on the right, idk
[16:05:38] jhass: cucumber specs are actually meant to be written by your buisness people, basically a formal format for user stories that you also happen to be able to write code for so they could be executed as tests
[16:05:44] jhass: if you don't need that, don't use it
[16:11:40] jhass: as providing this abstraction is all it does
[16:17:41] jhass: tests should test your code not your environment ;)
[18:42:26] jhass: i4: also think about whether you actually got your hash the right way around (the right things as keys and the right things as values) if you want to operate that much on the keyset
[18:42:59] jhass: or maybe you actually want an array of two element arrays
[18:45:46] jhass: do you ever do your_hash[:something]?
[19:00:38] jhass: are you abusing the i18n gem as a yaml loader there...?
[19:03:14] jhass: just call YAML.load_file?
[19:04:52] jhass: do you actually ever have keys not matching the pattern in the select? Do you actually ever make use of the anchors you define in your YAML?
[19:06:18] jhass: I'm talking about the first select, not the second
[19:06:42] jhass: btw there's never time wasted on proper variable/key names, abreviations you will not remember yourself in half a year
[19:19:01] jhass: I'd probably keep it simple, extract all redundant code to a partial/helper method and then do data[0], data[1], data[2], data[3..-1].each_slice(3) do |item|
[19:19:25] jhass: and make it into an array first
[19:23:24] jhass: btw you can define an array of objects in yaml like so https://p.jhass.eu/75.txt
[20:01:04] jhass: I guess it's akin to what they wanted. Not sure about what they needed :P
[20:01:26] jhass: I mean not sure akin to what they needed
[20:02:06] jhass: why do you use psych directly vs yaml?
[20:03:49] jhass: they usually don't come out of nowhere :P

2018-11-28

2018-11-27

[18:56:52] jhass: Quit: Bye
[19:00:53] jhass: has joined #RubyOnRails
[19:00:54] jhass: has joined #ruby-offtopic
[19:00:54] jhass: has joined #ruby

2018-11-22

[10:33:22] jhass: call .size on it

2018-11-21

[10:29:46] jhass: marz_d`ghostman_: because code outside of any blocks given to context, it or let is run before the one inside
[10:30:26] jhass: eh sorry strike context, that's actually invoked directly
[10:30:48] jhass: but let and it memoize their blocks to run them later
[10:36:51] jhass: line 23 is executed before line 16 because it's outside of a block given to it
[10:39:18] jhass: no, from the top of the file line by line, but `it` does not run the block given to it right away, however `context` does
[10:39:47] jhass: not right after, but in general yes
[10:45:29] jhass: marz_d`ghostman_: if we simplify what happens by a lot it'd look like this: https://carc.in/#/r/5l3l
[10:52:32] jhass: marahin: https://relishapp.com/rspec/rspec-core/docs/command-line/fail-fast-option
[10:52:50] jhass: not sure whether it listens to ctrl+c but worht a shot
[10:53:51] jhass: yeah as said, it's something I'd give a try, not its purpose but I see potential for having the effect ;)
[10:55:13] jhass: maybe just send it good ol' sigquit
[10:55:26] jhass: nobody remembers to handle it :D

2018-11-20

[14:13:51] jhass: if they come back, they either want .and_return(a, b) to return a for the first call and b for the second or setup one or two mocks that are restricted with .with() to the particular argument
[15:02:38] jhass: structure your code in a way that you can run just the relevant part from your tests
[15:02:45] jhass: that is extract to classes & methods

2018-11-19

[00:00:53] jhass: has joined #RubyOnRails
[00:00:54] jhass: has joined #ruby-offtopic
[00:00:54] jhass: has joined #ruby

2018-11-18

[23:07:16] jhass: Ping timeout: 264 seconds
[23:13:07] jhass: has joined #RubyOnRails
[23:13:08] jhass: has joined #ruby-offtopic
[23:13:08] jhass: has joined #ruby
[23:56:20] jhass: Quit: Bye

2018-11-14

[15:50:39] jhass: LinuxKnight: why is it inside a loop if it should run only once?
[15:57:43] jhass: what if it's a satelite control program?
[16:16:34] jhass: sans the ,
[16:17:38] jhass: eh, without
[16:19:57] jhass: https://en.wiktionary.org/wiki/sans
[16:21:02] jhass: before_save ?
[16:21:16] jhass: after the save it's obviously not changed anymore

2018-10-31

[16:51:57] jhass: not sure how I feel about copying implementation vs just setting @key and calling super, both is hackish but I think personally I'd prefer calling super