Activity Graph

Page 1 of 4 | Next »


[08:51:53] ineb: Quit: WeeChat 2.2


[09:04:34] ineb: Ping timeout: 252 seconds
[10:25:41] ineb: has joined #ruby
[15:52:45] ineb: urgh how would i imeplement a long running task that returns something and reports its status? ret = { |progress| p progress }
[15:53:05] ineb: in this case its a push based design and if 'p progress' blocks, everything blocks.
[15:53:56] ineb: does some sort of async yield makes sense here? or does make a pull based approach more sense?
[15:55:20] ineb: job_status =; while job_status.finished?; p status.progress; job_status.value
[15:55:26] ineb: or something like that
[16:02:08] ineb: here are my two solutions i can think of
[16:03:19] ineb: whats the better variant for an api? like a fileupload or something
[16:08:38] ineb: phaul: yes
[16:11:53] ineb: me. its really just one possible task here
[16:12:10] ineb: no configuration needed so far
[16:13:05] ineb: ok thanks


[07:32:51] ineb: has joined #ruby


[08:57:57] ineb: Bish: Nokogiri::XML vs Nokogiri::HTML
[09:02:37] ineb: Bish: can you reproduce that in any way? or is it just like that in your main program?
[09:03:17] ineb: but it looks like that in the html code?
[09:03:36] ineb: maybe there is just <img alt />
[09:09:55] ineb: this is fixing it??
[09:17:21] ineb: whats troubling me is that you cant reproduce it
[09:17:32] ineb: therefore i think you are missing something
[09:17:38] ineb: and its not nokogiris fault
[09:17:42] ineb: but iam not sure ofc
[09:18:26] ineb: maybe carefully compare the questionable node on your broken system to a healthy one
[09:18:37] ineb: there may be some subtle difference whats causing nokogiri to parse it that way
[09:18:43] ineb: *render it thay way
[09:33:23] ineb: Bish: if you use #to_xhtml, you always get alt="" style
[09:35:40] ineb: Bish: thats just what iam observing here
[09:35:47] ineb: it does look like a bug to me now
[09:38:19] ineb: have a look at
[09:39:38] ineb: the new content gets encoded and i dont think thats the reason why value = value changes something
[09:40:02] ineb: i think THAT IS the reason
[09:41:12] ineb: but it does not look like you can seen this difference in ruby code
[09:41:41] ineb: so we make the same conclusion
[09:42:41] ineb: go file it as bug. its ambiguous behaviour.
[09:44:31] ineb: its correct html and not fatal but ambiguous behaviour and not intended that way
[09:44:45] ineb: plus to_xhtml and to_html render it differently which points to another issue
[09:45:26] ineb: nokogiri authors are glad if you open an issue about that.


[16:46:01] ineb: has joined #ruby
[16:51:41] ineb: whats the best way to make a ruby cli project binary include necessary code?
[16:51:59] ineb: i saw $LOAD_PATH.unshift 'lib' which obviously only works if one is inside the project dir
[16:53:06] ineb: actually, that is what 'bundle gem testbin --bin' does
[16:56:16] ineb: shouldnt that be '$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"' or something?
[16:57:34] ineb: thats what i mean
[16:57:57] ineb: $LOAD_PATH.unshift 'lib' makes assumptions about the current directory. or am i missing something with bundler here?
[17:25:37] ineb: here is where my confusion starts. binaries in bin/ are meant to be called from CLI and like the bundle gem skeleton, i also get `require': cannot load such file -- digest/sip_hash on your gem when calling it via ./bin/siphash
[17:29:42] ineb: havenwood: i see. i missed the part where gemspec sets up the load path and provides auto-generated binaries


[07:28:24] ineb: Ping timeout: 272 seconds


[13:52:31] ineb: Quit: WeeChat 2.2
[21:05:14] ineb: has joined #ruby


[08:12:14] ineb: qolq: it doesnt look right because its bad code :) but another way would be some_method.eql? true


[06:48:22] ineb: has joined #ruby
[07:58:58] ineb: alex```: it doesnt really matter, but you can write data[:a] = data[:a].to_human_size if options[:pretty]
[13:48:12] ineb: prestorium: you mean local sockets AF_UNIX?
[13:48:37] ineb: its available in recent windows releases
[13:50:23] ineb: prestorium: regarding your initial question, net/ssh is pure ruby afaik
[13:57:23] ineb: prestorium: yeah, i looked at the source and they only support pageant from putty
[14:02:07] ineb: prestorium: i would assume so aswell. on windows, i would check if i have UNIXSocket available in ruby, then patch out the win32 checks in
[14:02:36] ineb: or just overwrite Net::SSH::Authentication::PLATFORM for a quick hack
[14:20:51] ineb: prestorium: okay, ssh-agent on windows exposes a named pipe instead of a UNIX Socket, have you looked at that?
[14:21:38] ineb: prestorium: well, you cant use a UNIX Socket either if ssh-agent does not creates one
[14:22:03] ineb: or talks to one
[14:22:51] ineb: maybe
[14:26:09] ineb: prestorium: you just need something that does #read #send and #close to a named pipe
[14:27:51] ineb: prestorium: and provide your custom socket factory to Net::SSH::Authentication::Agent#connect!
[14:28:18] ineb: looks like you does not need to patch anything that way


[11:40:03] ineb: RougeR: probably just an alias for :describe
[15:18:45] ineb: Quit: WeeChat 2.2


[14:14:31] ineb: Ping timeout: 244 seconds
[14:14:57] ineb: has joined #ruby
[15:25:56] ineb: str.dup.force_encoding('UTF-8') would leave str untouched


[13:05:04] ineb: Sorry i dont understand your question
[13:08:32] ineb: You mean like [1,2,3] + "Whatever" ?
[13:09:15] ineb: with "Whatever" not really being loaded into the original array
[13:09:33] ineb: but the new object knows about [1,2,3] and "Whatever"?
[13:11:27] ineb: so you basically want an array with additional features?
[13:11:49] ineb: you can subclass array if you want
[13:12:10] ineb: but if you dont need the full feature set of an array for your purpose you can look into forwardable
[13:13:53] ineb: No problem, take a look at Ruby Interitance
[13:14:46] ineb: i agree. forwardable makes more sense
[13:15:20] ineb: but i wanted to distill the question. and it looks like its boils down 'how to enrich an existing class with features'
[13:15:28] ineb: which can be done by inheritance :)
[13:17:37] ineb: MrGrymReaper: iam still not sure what feature you want to implement. if its something for inventory management in a game, then its unlikely that it will land in the standard libraries :)
[13:17:48] ineb: however, you can extend and use them as you like in your own environment
[13:21:27] ineb: Okay, maybe you are just looking for a Hash?
[13:22:50] ineb: >> hash =; hash[:hello] = 5; puts hash[:hello]
[13:25:59] ineb: and how do you receive the values and subvariables?
[13:26:12] ineb: if not by index or by key
[13:27:18] ineb: and a subvariable is a reference to a value in the array?
[13:28:20] ineb: this doesnt provide any performance benefits regarding io
[13:29:56] ineb: well, of course it does in c where you could just store an array of pointers instead of copying the actual value
[13:30:16] ineb: but was that the case in VB?
[13:32:30] ineb: you can do that in ruby too
[15:40:27] ineb: i understand but this testing can get tedious very quickly
[15:40:44] ineb: you need to keep track of the function names and check for explicit calling
[15:40:55] ineb: which will change eventually and then your tests are instantly outdated
[15:42:40] ineb: just an example here, instead of send_info_to_third_party you could have an ThirdPartyInformant with #notify or something
[15:43:09] ineb: easy to mock and never needs to be touched in your controller tests
[15:44:50] ineb: its just what iam experiencing if iam using too much expects of have_received and so on
[15:45:11] ineb: better to make use of the facade pattern in your controllers case
[15:45:18] ineb: but idk ofc
[15:45:26] ineb: maybe it isnt worth the effort in your case
[15:45:41] ineb: time will tell how often you have to change your current tests :P


[13:22:54] ineb: peacetreaty: i think you are right


[12:06:54] ineb: hfp: so you are basically looking for glue code that passes arg1 to library in whatever ways
[12:07:17] ineb: in your scenario, your function cant do it.
[12:07:49] ineb: iam not asking why, because usually thats the job of a function that takes the two arguments arg1 and library
[12:08:26] ineb: then your thoughts were right. you can pass this glue code via block
[12:10:34] ineb: << def glue(arg1,library); yield arg1, library end; glue("1", "2") { |a,b| p a + b }
[12:11:08] ineb: >> def glue(arg1,library); yield arg1, library end; glue("1", "2") { |a,b| p a + b }


[12:05:31] ineb: because it is overhead
[12:07:19] ineb: wait. callee is self isnt it?
[12:09:30] ineb: apeiros: and Kernel#caller_locations does not hold this information?
[12:11:31] ineb: me neither. thats why iam asking :)
[12:12:18] ineb: and i also dont know if passing around the callers bindings would be overhead
[12:13:01] ineb: however, binding_of_caller is opening the debug inspector and i afaik this is overhead
[12:13:51] ineb: or better s/i // ^^


[16:51:42] ineb: var = function(foo) || do_this_instead


[16:47:36] ineb: hays: its not required but makes sense in most cases imho
[16:55:28] ineb: i would say by practicing
[16:55:45] ineb: havin a good structure in the first case helps here ofc
[16:57:45] ineb: i would say there is not much you can do here but relearning how nokogiri works again :)
[16:58:05] ineb: defining an interface makes sense if you dont need a full featured nokogiri interface object
[16:58:39] ineb: but if you need to do html/xml operations it doesnt make sense to create an interface
[17:00:37] ineb: yes, its an good idea. but in your case it sounds like you have not implemented the logic two months ago
[17:00:51] ineb: so the only thing you can do now is learning nokogiri and write the interface
[17:44:52] ineb: hays: just my head :/


[14:49:21] ineb: zerowaitstate: balo: do i understand something wrong? cant you do expect(mock).to receive(:foo).with(bar).and_return(baz)
[14:56:41] ineb: zerowaitstate: balo: i think balo already answered the question. if return values based on specific input is required, it needs to ne listed explicitly and not as return sequence
[14:57:16] ineb: for every possible input, a return value needs to be declared
[15:02:57] ineb: the mock for that can be build with a helper function which provides the desired functionality from zerowaitstate to build the mock from a hash
[15:04:06] ineb: it is. but can be used to mock subsequent db calls for every test needed
[15:04:13] ineb: if you dont want integration tests against a real db
[15:04:55] ineb: i have used it aswell for mocking http calls
[19:15:33] ineb: this_dude: or [1,2,9,2,3].inject { |sum, n| new_sum = sum + n; break sum if new_sum > 9; new_sum ; }
[19:15:59] ineb: >> [9,4,2].inject { |sum, n| new_sum = sum + n; break sum if new_sum > 9; new_sum ; }
[19:16:35] ineb: right ^^ u said 6
[19:24:13] ineb: havenwood: nice one
[19:24:21] ineb: should be easy then


[11:19:46] ineb: whats a good way to design enums in ruby? Something like ["LOW","HIGH","DEFAULT"]. I was thinking about subclassing String and only allow one of these values
[11:21:24] ineb: but i would call it bad design when subclassing a string just to restrict it
[12:00:54] ineb: vutral|kali: because its difficult to model COLOR::RED.is_a?(COLOR)
[12:02:53] ineb: plenty :)
[12:06:38] ineb: vutral|kali: looks like none of them implements it in a way where enums are actual instances of a class but constants
[12:07:01] ineb: which again would make COLOR::RED.is_a?(COLOR) not possible
[12:08:09] ineb: no RED is a constant that resides inside module COLOR
[12:08:37] ineb: no, that was your suggestion
[12:08:49] ineb: and the way ruby-enum and rails enum class are implementing them
[12:12:06] ineb: you mean something like class Color; def initialize(color) { @color = color }; RED =; BLUE =; end
[12:15:02] ineb: it would work.
[12:16:08] ineb: havent seen it anywhere yet.
[12:16:12] ineb: but that would mean nothing.
[12:16:18] ineb: or maybe i have and forgot about it :)
[12:17:03] ineb: java has real enums: enum Color { BLUE, RED; };
[12:21:49] ineb: vutral|kali: in java, BLUE.getClass().getName() would be 'Color' in my definition above
[12:22:03] ineb: i mean Color.BLUE.getClass().getName()
[12:22:43] ineb: but you are right with C enums
[12:25:45] ineb: it always is in this case


[07:19:14] ineb: has joined #ruby
[07:19:43] ineb: if you go the dynamic approach and generate a client api out of the REST specifications
[07:20:01] ineb: would you generate the actual ruby code via erb templates
[07:20:18] ineb: or load the specifications (json) and create the code via meta programming?
[13:51:02] ineb: wait. just #freeze and/or its members
[13:51:13] ineb: *just #freeze the struct
[13:58:25] ineb: dminuoso: i dont think its possible to easily unfreeze an object
[13:58:53] ineb: maybe with some hacks of the ruby interpreter


[18:45:04] ineb: Quit: WeeChat 2.1


[14:15:51] ineb: TonyTheLion: hmm, this isnt an issue of nix but the sandbox, isnt it?
[14:19:36] ineb: besides that, what has jekyll to do with ssl anyway?
[14:20:07] ineb: it creates static pages. and then 'jekyll serve' command offers plain http anyway afaik
[14:20:38] ineb: iam afraid its difficult to help you here


[10:23:06] ineb: any way wo write this shorter? (1..5).map{|x| h = {}; h[1] = x; h[2] = x*x; h } ?
[10:24:10] ineb: >> p 'thx'
[10:26:55] ineb: alex-kid: not in an easy/convienient way.
[10:27:10] ineb: it makes no sense in a typeless language if you think about it
[10:46:40] ineb: when in ruby mindset, there is rarely a situation where you need function signatures
[10:48:12] ineb: at least thats what iam experiencing.
[10:48:24] ineb: if you really need a distinction then you must do type checking one way or another
[10:50:52] ineb: the issue is the case statement before which returns symbols or procs
[10:52:59] ineb: one stupid way to fix the case for Symbol or Proc is to return a Proc in every case with needed actions inside that Proc
[10:53:16] ineb: lots of code duplication of course
[10:56:36] ineb: i dont know the code but in your example you only have one case which returns a Proc and it has empty arguments anyway
[10:57:06] ineb: why not [:inspect, Commands.to_h ] or something like that
[10:57:58] ineb: anyway.. all i want to say is that a requirement for function signatures in ruby is often a design smell
[11:01:08] ineb: "foo".match(%r{foo|bar}) ?


[09:35:17] ineb: just upgraded my rig with a gtx 1060. terminal is running so much smoother now
[10:10:41] ineb: Bish: graalvm with truffle is another option
[10:11:21] ineb: its a shame indeed. but dont look away from truffle because of this. they are not oracle and doing a good job
[10:11:59] ineb: well, some of them actually are oracle..
[10:13:03] ineb: i just randomly clicked on someone who is answering issues on gh, and he is oracle
[10:14:03] ineb: yes, i just wanted falsify my statement about truffle not being oracle
[10:15:45] ineb: yes. i have a project which mixes javascript and ruby and graal is working fine for that
[10:15:54] ineb: altough execjs is also fine
[10:17:03] ineb: regarding, mruby is 1.9 compatible
[10:17:45] ineb: just one more typo and were on 2.0 :)
[10:19:21] ineb: iam not sure if a typographical error is limited to one char
[10:19:31] ineb: i dont remember either :/
[10:28:10] ineb: by using opal you mean?
[12:25:13] ineb: Bish: but what VM on top of another VM (webassembly)? :<
[12:49:25] ineb: imperator: swagger can do it
[12:52:04] ineb: fernandobasso: why not skip until you there?
[13:00:02] ineb: fernandobasso: for collections, imperator gave an solution. another way would be collection.drop(N).each
[13:00:27] ineb: fernandobasso: but iterators dont always have a fixed length and therefore could be problematic in this manner
[13:00:34] ineb: however, its also possible to #drop there ;)
[14:07:57] ineb: bsamorim: almost always yes. cant you install the required gems relative as normal user via bundle install --path vendor/bundle or so?
[14:12:03] ineb: bsamorim: basically because you are running arbitrary code in root context. gem installation routines can include any thinkable statements and therefore damage your system
[14:12:30] ineb: *therefore _possibly_ damage your system
[14:14:26] ineb: bsamorim: not without running a privilege escalation exploit, no :)
[14:14:42] ineb: bsamorim: but you can of course sudo and stuff if your system is configured that way


[15:51:43] ineb: regedit: take a look at StringIO and treat it like a file
[15:52:22] ineb: regedit: you can do #gets, #read, #each_line, #each_char and so on there
[15:54:12] ineb: regedit: but if you say 9 megabyte of size... this shouldn be a problem. especially not if you preprocess it in chunks
[16:11:18] ineb: what does return? you want IO there
[16:11:34] ineb: regedit: if this is a full string it would explain your problems
[16:21:17] ineb: regedit: open_buffer was correct there
[16:22:17] ineb: CarrierWave::Storage::Fog::File should be an open IO stream already
[16:27:48] ineb: regedit: yeah because its not an actual file in this case. i dont know carrierwave
[16:28:00] ineb: maybe #path points to a file?
[16:29:19] ineb: you could also try and give that to open_buffer
[16:32:36] ineb: true but at least you have a sane StringIO there. if your code crashes at this location you can be sure that its a memory error
[16:42:15] ineb: regedit: well, you already noted that the gsub operation can cause problems
[16:42:24] ineb: you havent provided much more info on where your code exactly fails
[16:42:38] ineb: if its at random locations or always the same line?
[16:43:21] ineb: regedit: since the numbers seem somewhat formatted i would iterate through them one by one and do whatever operations needed
[16:57:22] ineb: regedit: okay, i cant spot critical errors there


[08:39:23] ineb: wasamasa: whats the question? generate 4 dimensional vectors with maximum sum of 5?
[08:39:43] ineb: can be done with Matrix::Vector i think
[09:07:31] ineb: wasamasa: yeah. reminds me of subset sum problem


[07:48:43] ineb: grr12314: only 2.0 iam afraid.
[07:49:04] ineb: or thinks like Float(2) etc.
[07:49:30] ineb: 2.to_f being another option


[02:41:59] ineb: swagger-api has it with swagger-codegen
[02:42:42] ineb: but only for swagger apis.
[02:43:10] ineb: iam currently working with a rest api that is sometimes restfull and sometimes ill defined
[02:43:23] ineb: i cant change that though.
[02:55:46] ineb: baweaver: ok, i havent looked deeply.
[02:56:05] ineb: iam currently browsing the ghee gem which is a client for the github habe and goes with the dynamic approach
[02:56:26] ineb: looks like i can get inspired there
[02:57:33] ineb: comes close to what i had in mind