jhass

Activity Graph

Page 1 of 252 | Next »

2019-06-06

[08:30:45] jhass: let's just rename it to #ruby-blockchain-ai or so
[08:30:46] jhass: I'm sure that'll help
[08:32:23] jhass: !memo zenspider maybe
[08:32:26] jhass: no, that's not it
[08:32:49] jhass: okay we never did it for this one
[08:33:02] jhass: there's... MemoServ?
[08:33:47] jhass: yup, /msg MemoServ SEND zenspider heyho
[08:35:21] jhass: gotta upload your election results somehow
[08:36:29] jhass: https://securityaffairs.co/wordpress/62826/hacking/ccc-hacked-pc-wahl-software.html "Hacked" through not secured/bad passwords FTP servers essentially
[08:37:52] jhass: I'm sure a lot of webshop's "deployment pipeline" still is filezilla :D
[08:38:21] jhass: I mean if you click some random shared web hosting, FTP is still the primary access method for sure
[08:42:43] jhass: rsync requires ssh access
[08:42:51] jhass: like real ssh access, sftp ain't enough
[08:43:14] jhass: had to use lftp or something the other day because I didn't want to give real ssh access to something
[08:46:08] jhass: sftp is a fine protocol, only things it has in common with ftp is the letters in the name and the usecase of copying files from one machine to another
[08:46:31] jhass: well or generally modifying a remote file tree
[09:17:11] jhass: shouldn't be hard to build actually, so would surprise me if there isn't somewhere
[09:17:16] jhass: but would be nice if it ships with openssh, yeah
[09:24:10] jhass: sfcp() { echo "put \"$1\" \"$1\"" | sftp "$2" } gets you half-way there already I guess
[09:25:29] jhass: jasmin: I'd try plain authentication. Given startssl... oh well
[09:34:39] jhass: jasmin: I'd try plain authentication. Given starttls you really don't need to protect your credentials
[09:35:16] jhass: isn't login using some challenge/response mechanism? It looks like you gave rails one instance of the challenge response rather than your actual credentials
[11:10:15] jhass: jasmin: with the same credentials as when using plain inside a starttls session using openssl s_client -starttls smtp -connect foo:587
[11:23:11] jhass: jasmin: you got me a bit confused as to what your state is. To clarify: you should use plain as auth method, do set true for enable_starttls_auto and use your plain credentials as you got or set them at OVH, without any encoding or hashing
[11:29:41] jhass: still the same error message?
[11:39:28] jhass: jasmin: I guess you could patch your local copy of the mail gem (bundle show mail) to set Net::SMTP's debug output: https://ruby-doc.org/stdlib-2.6.3/libdoc/net/smtp/rdoc/Net/SMTP.html#method-i-debug_output-3D here https://github.com/mikel/mail/blob/master/lib/mail/network/delivery_methods/smtp.rb#L112
[11:40:08] jhass: that hopefully dumps you the SMTP session somewhere

2019-05-30

[21:48:40] jhass: Rails.application.config.secret_token = ENV["SECRET_KEY_BASE"] should do I think

2019-05-29

[13:23:21] jhass: ZAJDAN: https://stackoverflow.com/a/28201705/2199687
[14:29:29] jhass: basically the fragment shouldn't even be sent to the server, it's interpreted by client side JS in this case
[14:29:38] jhass: not sure you'll have much success with mechanize here
[14:29:58] jhass: might be better to reverse engineer the internal API the client JS app uses
[14:30:14] jhass: Guest39: wasn't for you, but for AndreYuhai :)
[14:33:33] jhass: specifically the post request to https://public.tableau.com/vizql/w/EDB-1/v/AllEntries/bootstrapSession/sessions/467792DBF519404690515526E6987DCF-0:0
[14:33:47] jhass: which returns Base64 encoded JSON
[14:34:09] jhass: ah no Base64 encoded semicolon separated data
[14:34:18] jhass: some fields of which have JSON
[14:38:27] jhass: AndreYuhai: and I'm saying you don't even need to solve this because it will only let you arrive at the more fundamental problem
[14:40:56] jhass: I'm saying trying to scrape the site with mechanize most likely is a lost cause. But given there seems to be a JS client interpreting those fragments, there probably is an internal API that JS client uses which you can try to use to scrape the content
[14:44:41] jhass: ok it looks like you can just ignore the fragment
[14:44:46] jhass: where did you find a link with it?
[14:59:08] jhass: then just shift it to 0-255, .pack("C*") and pass the result a gzip deflater
[14:59:44] jhass: .map {|b| b + 128 }
[15:06:08] jhass: https://stackoverflow.com/a/1366187/2199687
[15:06:27] jhass: well or the stuff from the question
[15:06:33] jhass: whatever works for you
[15:07:05] jhass: er, what deflating is compressing
[15:07:08] jhass: always confusing me
[15:07:14] jhass: so the inflate one below :D
[15:11:26] jhass: it doesn't really matter

2019-05-28

[17:47:40] jhass: with created do you mean written into the database?
[17:51:57] jhass: istrasci: ^
[18:08:10] jhass: no I don't suppose I have
[18:09:10] jhass: sounds like... a lot of work :D
[18:09:36] jhass: did somebody get ruby running in WASM yet? 🤔
[19:44:11] jhass: nah, GCs are :P
[20:13:53] jhass: what glyphs would that use?
[20:15:32] jhass: no, ASCII has 127 characters, many not visible
[20:16:09] jhass: not visible = control characters like backspace, newline, bell and so on
[20:16:28] jhass: what does that mean "store as base256"
[20:17:21] jhass: base256 doesn't exist afaik
[20:17:58] jhass: any string encoding of a number is likely less space efficient than it's binary representation
[20:20:14] jhass: &>> [124453423].pack("L").bytesize
[20:20:40] jhass: &>> 124453423.to_s(36).bytesize
[20:21:10] jhass: as a 32bit integer
[20:21:13] jhass: hence 4 bytes
[20:21:44] jhass: (32/8 = 4)
[20:22:18] jhass: you asked for the most space effecient method
[20:23:05] jhass: what, no why would it
[20:23:21] jhass: &>> `uname -a`
[20:23:44] jhass: ah I blocked it :D
[20:23:56] jhass: be assured it's a 64bit kernel :P
[20:25:40] jhass: still that makes no sense
[20:26:56] jhass: no, the latter is the binary string representation, that is the binary representation as a string
[20:27:14] jhass: of course each of those 1 and 0s takes up 1 byte
[20:27:30] jhass: but what is a string? it's a sequence of codepoints, aka numbers
[20:27:44] jhass: &>> "10011".codepoints
[20:27:55] jhass: &>> "1dotk".codepoints
[20:28:13] jhass: now we want to store a number, why would we encode that number into a sequence of smaller numbers
[20:28:28] jhass: and then store those smaller numbers
[20:28:35] jhass: let's just store the number directly
[20:30:40] jhass: that's what you do if you don't use a string, 123 <- direct number "123" <- string
[20:31:09] jhass: if you need to write it to disk from ruby, use Array#pack
[20:31:51] jhass: &>> [2318312].pack("L")
[20:32:54] jhass: easiest is probbaly just export GEM_HOME="$HOME/.gems" from your shellrc
[20:33:21] jhass: might make your system gems unavailable, not sure
[20:33:32] jhass: so you might also need to readd them to GEM_PATH
[20:33:43] jhass: gem env is great for debugging such
[21:10:12] jhass: read_nonblock
[21:42:39] jhass: what's the advantage towards the mentioned methods?
[21:43:09] jhass: then why use it?
[21:44:07] jhass: I think that's just confusing when a solution was already found
[21:44:28] jhass: without at least mentioning tradeoffs compared to the other solutions
[21:46:15] jhass: the docs here don't paint a great picture on the tradeoffs here to be honest
[21:46:41] jhass: esp. if you don't already have experience around the tradeoffs between buffered and non-buffered IO
[21:47:54] jhass: good thing none of use would ever refer to van gogh's works as a reference for writing ruby code

2019-05-24

[12:58:31] jhass: ytti: got an example?
[12:59:24] jhass: maybe it happens to be valid yaml or something
[13:04:56] jhass: fun, but I fail to spot where it's syntactically invalid?
[13:05:11] jhass: unless the dots are actually in there
[13:06:27] jhass: well, just using the XML is no option?
[13:08:37] jhass: well converting the XML is just the wrong approach in the first place
[13:08:47] jhass: you want your internal models/data classes to serialize to both
[13:13:59] jhass: ytti: just for fun: https://carc.in/#/r/6yy6
[13:17:20] jhass: not sure I'd actually use it, feels kinda hackish (esp compared to just using the XML), but I guess it works :)
[13:17:48] jhass: yeah no idea what the additions thing is about
[15:14:57] jhass: jstrong:no because you simply don't know that point, given you can reopen the class at any point
[15:18:04] jhass: jstrong: common approach is to wrap your "class method DSL" into a block passed to another method. build_validator do; validate_a; validate_b; end; where build_validator does something like: b = Builder.new; b.instance_eval(&block); b.build;
[15:24:09] jhass: no, class level instance variables are more interested. "class methods" actually don't exist in ruby, they're instance methods of the class' #singleton_class
[15:24:17] jhass: eh, more used
[15:24:58] jhass: so any instance variables they reference belong to that singleton class
[15:30:58] jhass: sure why not. I'd add some validations on self.filters and maybe store @filters directly rather than keeping the builder around. Also I assume that's just a simplified example since you don't actually need to know there when "adding filters" is done
[15:32:04] jhass: you can just open the singleton class with class << self;
[15:32:15] jhass: and treat it like you would any other class
[15:37:56] jhass: well attr_accessor is just what it is, in a singleton class too. So it defines Custom.search_class and Custom.search_class=
[15:38:46] jhass: (the inheritance works here because a child class' singleton class inherits its parent class' singleton class)
[15:39:25] jhass: yeah, self.search_class = :test in the class body context
[15:39:39] jhass: else you're just assigning a local variable
[15:59:38] jhass: no idea how you would arrive at string interpolation for that problem statement :D
[16:00:00] jhass: array.each {|e| particular_method(e) }
[16:00:08] jhass: guess I didn't fully get ya ;)
[16:05:05] jhass: iirc instance_eval also yields the receiver, so you could do 'do |e| foo.each {|v| e.argument v }; end
[16:05:19] jhass: if not you could of course capture self before the each into a local
[16:05:49] jhass: or if the call is really that simple you could also do .each(&method(:argument))
[16:06:07] jhass: there's also a new shortcut syntax for that, let me look it up...
[16:10:02] jhass: https://carc.in/#/r/6yyk
[16:10:28] jhass: eh ignore the |b| in the second example
[16:11:12] jhass: with Ruby 2.7 you can also do .each(&.:add)
[16:11:28] jhass: &. is just a shorthand for &method()
[16:11:50] jhass: well kinda
[17:05:42] jhass: the difference between do/end and braces is binding precedence. foo bar do end is foo(bar) do end; foo bar { } is foo(bar do end)
[17:06:50] jhass: yes because the block binds to the closer expression with braces
[17:07:02] jhass: of you do foo(bar) { } it's the same as foo bar do end
[17:07:42] jhass: so foo(bar) { } and foo bar do end are equivalent, so is foo(bar do end) and foo bar { }
[17:08:44] jhass: well, argument list
[17:34:46] jhass: that's what instance_eval does
[20:25:11] jhass: codefriar: how do you define lines?
[20:25:19] jhass: maybe it's not actually lines
[20:27:23] jhass: https://carc.in/#/r/6yzw
[20:27:25] jhass: seems fine
[20:30:21] jhass: codefriar: could you try to provide a self contained example like this that reproduces your issue?
[20:31:36] jhass: ah, ok. .each always returns the receiver so that's expected in a repl session

2019-05-23

[18:15:09] jhass: sound's like you're reinventing Hash#dig
[18:18:04] jhass: where does the string come from?
[18:48:31] jhass: you can, just prepend a *
[18:48:51] jhass: data.dig(*the_array)
[18:49:24] jhass: * is called the splat parameter, it passes each array element as an individual argument to the method
[18:50:05] jhass: works in general for any method call of course
[18:51:09] jhass: view it as the inverse of a varargs argument in a method definition, that is a method parameter that collects all (remaining) positional arguments into an array: def foo(*args)
[19:12:25] jhass: not without context context context
[19:13:31] jhass: call example?
[19:14:01] jhass: looks like terrible code tbh :D
[19:14:52] jhass: my current best guess is Does Not Exist
[19:16:47] jhass: yup, Hash#fetch's block get's called when the given key does not exist in the hash
[19:18:33] jhass: in the argument list it binds any given block argument to the given variable name (as a proc)
[19:18:51] jhass: in the call it does the reverse essentially, it passes the given proc as a block argument
[19:19:29] jhass: >> def foo(&block); block; end; a_proc = foo { 1 + 1 }; a_proc.call
[19:19:59] jhass: eh, whatever
[19:20:35] jhass: second example: def foo; 1 + yield; end; a_proc = proc { 1 }; foo(&a_proc)
[19:23:35] jhass: no if there, but yeah
[19:23:57] jhass: if there's no block if_dne will be nil and &nil will just pass no block
[19:24:35] jhass: simple terms: Product#[] forwards any given block to Hash#fetch
[19:45:20] jhass: I think the id&. is a really big smell here btw
[19:45:34] jhass: why would you ever pass nil there and silently handle it
[21:04:45] jhass: .sort_by {|hash| hash["values"].last }
[21:05:34] jhass: .sort_by returns a new sorted array, sort_by! sorts the existing array in place
[22:07:57] jhass: ruby is entirely pass by reference, there's no pass by value whatsoever, all copying has to happen explicitly via .dup and .clone
[22:09:05] jhass: now BigDecimal#- returns a new instance, x -= y is just a shorthand for x = x - y
[22:11:37] jhass: &>> require "bigdecimal"; x = BigDecimal(10); y = x; x -= 1; x.object_id == y.object_id
[22:13:40] jhass: ah looks like BigDecimal#dup just returns self because it's immutable
[22:14:37] jhass: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2558
[22:15:08] jhass: given they made it pointless to use it, yeah
[22:31:36] jhass: %(jpg jpeg gif png).include? filetype
[22:32:50] jhass: haven't seen anybody use member? :D
[22:33:35] jhass: no I haven't just mentioning it!
[22:43:14] jhass: !fact add helpa I need somebody! !help. Not just anybody. !help. You know I need someone. !help
[22:43:27] jhass: I know :P

2019-05-21

[08:32:31] jhass: marz_d`ghostman: in Ruby we tend to prefer modules for these kind of cases
[09:00:41] jhass: marz_d`ghostman: you cannot have a module inherit a class, only include other modules. You'd have your descendants inherit Podio::Item directly and include the module
[09:02:59] jhass: yes that's what I understood
[09:03:32] jhass: if Podio::Item is your class, maybe it could be a module too
[09:18:37] jhass: well I suspected your example is just that, because it seems rather pointless tbh
[09:19:43] jhass: stubbing external dependencies is right, but when that ends up the test just verifying a particular implementation rather than any behavior I just skip those tests
[15:26:40] jhass: Jonopoly: you might want to take a look at capybara which provides such primitives (wait for condition with timeout)

2019-05-20

[17:25:44] jhass: DeBot: opl
[17:26:08] jhass: DeBot: n1
[17:28:53] jhass: that's cheating :P
[17:29:45] jhass: DeBot: id
[17:38:17] jhass: bored? Looking for an adventure? Try Crystal!
[17:38:21] jhass: ACTION hides
[17:38:41] jhass: it has methods...
[17:39:22] jhass: I don't know how...
[19:16:48] jhass: yep, you answered your own question :D
[19:17:02] jhass: two simple lines are better than one complicated one
[21:03:50] jhass: File.write("tmp.svg", svg_data); system("eog tmp.svg")

2019-05-19

[17:02:18] jhass: uhm, can you show the full backtrace? your code doesn't seem to parse any json
[17:17:36] jhass: def foo(a, b); do_stuff_with_a_only; end

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: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