Activity Graph

Page 1 of 12 | Next »


[19:22:58] ytti: intuitively i think anyone not knowing would guess is_a is instance_of not kind_of
[19:23:14] ytti: and i think lot of people who use is_a, assume it is exact
[19:23:49] ytti: i'd use instance_of? by default, and kind_of? when i have to


[11:31:55] ytti: Bish, what is expectation?
[11:32:19] ytti: it works like i expect
[11:36:13] ytti: Bish, if you want s to be return value of the block remove the parenthesis
[11:36:28] ytti: Bish, with parenthesis you are working on the return value of the assingment and you're disregarding that return value


[09:14:28] ytti: also openssh people have long tried to deprecate and discourage scp use over sftp
[09:14:42] ytti: i just wish there was scp like ui for sftp
[09:17:36] ytti: entirely no reason at all, could be even symlink and determine how it is called, to offer UI you want


[17:35:33] ytti: python and go make me unhappy, ruby and kotlin make me happy
[17:35:59] ytti: but i do have to write some python to get money
[17:39:08] ytti: i've also never used java at all, but kotlin drove me to it
[17:39:23] ytti: naltun, i think i'm partial to OO
[17:39:58] ytti: both ruby and kotlin have terrific design, and offer lot out of the box in terms of convenience and beauty (subjective) of code
[17:40:28] ytti: in python and go i feel like i constantly need to NIH simple things, and if NIH them, it's less thought design than what ruby and kotlin have out of the box
[17:40:41] ytti: arbitrary example, 'partition'
[17:40:54] ytti: i loooove object.method lambda style
[17:40:59] ytti: not-invented-here
[17:41:33] ytti: go is simple, in my opinion, to a fault
[17:41:47] ytti: but then again, for me, something like rust or c++ is too complex
[17:42:09] ytti: because my main responsiblity isn't programming, inveseting time to learn rust or c++ doesn't seem to pay dividends
[17:42:15] ytti: kotlin hits sweet spot for me
[17:42:33] ytti: honestly if you're gonna do kotlin, you're probably much happier in jvm world, because you'll have so much more libraries to use
[17:42:50] ytti: you could still compile the JAR to native binary with 'graalvm' native-compile
[17:43:04] ytti: and get *coughcough* 20MB binary for small program :)
[17:43:25] ytti: and as someone with 0 java background, kotlin communities seem very java focused
[17:43:39] ytti: you get weird reception if you don't have java background
[17:43:49] ytti: it was maybe 50lines, but it included ssh library
[17:44:12] ytti: i'm not sure if graalvm can do any-to-native
[17:44:20] ytti: i know it can do JAR to native, and it even worked
[17:44:48] ytti: most work for me learning kotlin, has nothing to do with kotlin, it's trying to understand the ecosystem, which is old news to java people
[17:45:14] ytti: i definitely didn't give any optimization parameters
[17:45:32] ytti: but just interesting point on how many ways you can skin the avocado in that world
[17:45:49] ytti: that was my initial attraction to kotlin, i can target so many domains with single language
[17:46:05] ytti: and then when i found similar beauty in kotlin as i've only found in ruby, i was sold
[17:47:54] ytti: dunno, some network monkey probably
[17:51:18] ytti: no objections here, havent written line of rails tho, so can't help


[10:28:06] ytti: personally i would go other way
[10:28:36] ytti: instead of doing complex regexp, i'd dos omething like this
[10:28:46] ytti: input.lines.each do |line|
[10:29:21] ytti: words = line.split
[10:29:41] ytti: next unless word[1][0..1] == '[['
[10:31:18] ytti: usually if you need help with regexp, then regexp was not the right solution
[10:31:40] ytti: in terms of readability and maintainability
[10:32:15] ytti: ryouba, sorry, i only saw first url, and it didn't have multilines
[10:32:44] ytti: ryouba, aah just didn't scroll
[10:32:55] ytti: the view rendered in 'test string' box didn't contain multilines
[10:33:28] ytti: i think multiple is possible with that loop still
[10:33:37] ytti: just push result to soem array, once result is complete
[10:46:50] ytti: StringScanner may also be your friend
[11:06:14] ytti: ryouba, looks cleaner to me, but indeed, matter of opinion
[11:07:31] ytti: slightly related question, that pattern is something i also often do
[11:07:35] ytti: foo = []
[11:07:56] ytti: something.each { |x| foo << something(x) if sometimes }
[11:08:18] ytti: is there more idiomatic version? like maybe
[11:08:36] ytti: foo = { |x| sometimes ? something(x) : nil }.compact
[11:08:58] ytti: or some other way to return different size enumerable
[11:10:06] ytti: i thought select returns itself
[11:10:11] ytti: when true
[11:10:34] ytti: where as typically you want to mutate the return value
[11:10:55] ytti: so you'd rather foo = something,select(&:sometimes).map ...


[10:23:31] ytti: squeeee, i made something cute -
[10:23:56] ytti: to_human(from_human(1.23, "Gbps")) == "1.23Gbps"
[11:00:20] ytti: i have proprietary device emitting broken JSON, I wonder if there is way way to unbroke it. Essentially I have array of objects, each of these objects contains one spcific name which is non-unique to that object, and the last one takes precedence
[11:00:26] ytti: i'd want the first one to take precedence
[11:00:50] ytti: i guess i'd need to write my own trivial JSON parser to drop the first one
[13:01:33] ytti: jhass, no, no it's JSON converted from XML and definitely invalid -
[13:02:27] ytti: jhass, the XML version
[13:02:43] ytti: which is actually valid, as same node can appear many times in XML
[13:02:56] ytti: so just bug in their conversion implementatino
[13:05:44] ytti: jhass, packet-information name appears twice in same object
[13:05:59] ytti: i broke indentation, why it looks ok
[13:06:42] ytti: certainly is, and i usually do
[13:06:51] ytti: first time trying the JSON :)
[13:07:32] ytti: ofc reported to vendor too, certainly a mistake i could see myself writing on such converter
[13:09:01] ytti: the XML is the single source of truth
[13:09:06] ytti: out of which CLI and JSON are generated
[13:09:14] ytti: i don't find fault in the design
[13:09:27] ytti: just a implementation bug
[13:16:20] ytti: jhass, huh, i was looking at JSON docs but didn't notice object_class
[13:16:30] ytti: jhass, i did try this JSON.load('{"hello": {"goodbye":"moi"}, "hello": {"moi": "jee"}}',{|e|p e},create_additions: true)
[13:16:41] ytti: jhass, just to see what the proc observes, but it wouldn't observe the duplicate
[13:16:44] ytti: jhass, thank you
[13:18:58] ytti: i'm definitely not going to use this for anything serious, mainly just wanted to see how mature it is, and answer appears to be not much
[13:19:06] ytti: but still that is very neat trick i'm happy to learn


[14:29:16] ytti: sequal is so great
[14:29:33] ytti: one of the main reasons i hate switching away from ruby
[14:29:42] ytti: haven't found anything as nice in other languages i'm considering
[14:37:50] ytti: i have, and i don't like it
[14:38:14] ytti: on python i use peewee
[14:40:26] ytti: example of peewee model:
[14:43:00] ytti: if i want sustainable and serious major project, i'm not going to choose python to begin with :)
[14:43:33] ytti: (nor ruby)
[15:01:46] ytti:


[18:50:09] ytti: 21:43 < Wolland> And it lets you know it’s an array
[18:50:15] ytti: no it doeesn't
[18:50:27] ytti: it lets you know object responds to [](arg) method
[18:50:39] ytti: i would also use #first
[18:51:16] ytti: no, it lets you know object responds to [](arg) method, nothing else
[18:52:21] ytti:


[09:34:53] ytti: all methods are idempotent which do only has local state and receive arguments which they do not modify and return value
[09:35:14] ytti: it's not a language feature, in that no language forbids idempotent functions and methods
[09:35:19] ytti: but some languages may enforce them
[09:35:39] ytti: i would say that idempotent code is not necessarily idiomatic ruby
[09:39:42] ytti: if method is idempotent or not?
[09:40:27] ytti: that is broad question, broader than i have time to answer in meaningful way other than you need to have sufficient competency as developer
[09:41:05] ytti: the original answer sets the constrains you have to test cognitively if it meets those constrains
[09:41:10] ytti: you don't enforce
[09:41:24] ytti: perhaps you could write static analyser which enforces and checks, unsure if that is possible
[09:41:50] ytti: i don't know
[09:42:06] ytti: people who put value in this type of things usually choose pure functional langauges
[09:42:23] ytti: it won't
[09:42:34] ytti: almost no language knows
[09:42:47] ytti: it's very atypical for langauge to enforce this by design
[09:42:50] ytti: such as?
[09:42:52] ytti: c doesnt
[09:42:55] ytti: java doesn't
[09:42:57] ytti: python doesnt
[09:43:03] ytti: c++ doesnt
[09:43:06] ytti: php doesnt
[09:43:09] ytti: perl doesnt
[09:43:16] ytti: which langauges are you talking about?
[09:43:40] ytti: aya, if you are comfortable with ocaml probably everything else will feel inelegant
[09:43:56] ytti: javascript won't know if function is idempotent
[09:44:08] ytti: perhaps look at elixir or haskell
[09:44:25] ytti: at any rate stay in functional languages, rather than OO
[09:46:33] ytti: ShalokShalom, that article contradicts you and supports me
[09:46:42] ytti: ShalokShalom, in that JS does not guarantee idempotent functions
[09:46:49] ytti: ShalokShalom, all langauges support idempotent functions, few guarantee
[20:20:01] ytti: picking up kotlin (no java experience) and really most work seems to be figuring out what are the 'de facto' libraries i should be using
[20:20:12] ytti: with ruby i don't really have to think much about that
[20:20:31] ytti: but java has so many competing libraries, no obvious winner and most of them not touched in years
[20:20:47] ytti: so i haven't really figured out effective way of choosing library in timely manner


[11:42:11] ytti: 10_000_00 seems outright passive aggressive
[11:42:49] ytti: three zeroes or i'll call HR
[11:43:17] ytti: also be sure you have appropriate class to deal with money
[11:43:32] ytti: money is special and using native types is not the right solution


[14:34:47] ytti: => [[1, 2], [3, 4], [5, 6]]
[14:34:47] ytti: [3] pry(main)> [1,2,3,4,5,6].each_slice(2).to_a


[15:52:56] ytti: in MRI implementation the threads wont run in parallel
[15:53:06] ytti: due to global lock
[15:53:13] ytti: in some other implementation they may


[18:20:02] ytti: varmaa joku 6 kertaa lätäkön yli



[15:08:31] ytti: Momentum, i don't understand the question, what does it mean to have maintained patch release?
[15:08:39] ytti: Momentum, or do you mean if 2.6 is maintained? that is indeed maintained
[15:11:18] ytti: very odd gemfile specification
[15:11:59] ytti: you want foo.required_ruby_version = '>= 2.6'
[15:16:21] ytti: probability of ruby 2.6.N+K being broken but 2.6.N working for your code is not something you should plan for
[15:29:55] ytti: rbenv utility is to install newer ruby version locally without super user permissions
[15:30:10] ytti: and to use different ruby versions simultaneously with convenience
[15:30:21] ytti: if you can avoid, do avoid, complexity needs justificaiton


[13:32:12] ytti: because initheader is not used
[13:32:27] ytti: Content-Type: "application/json"
[13:32:36] ytti: i guess that's not valid sym
[13:33:34] ytti: no is not
[13:33:45] ytti: it takes hash
[13:33:51] ytti: and the assingment returns said hash


[06:30:16] ytti: to me it makes sense
[06:30:34] ytti: there is no set in json, so you couldn't read anything back to set either
[06:31:06] ytti: casting it to array makes things more self-documenting
[06:52:55] ytti: how does it look whe nserialised? !ruby/set ...?
[06:53:35] ytti: havenwood, ok
[06:53:52] ytti: at that point, personally i'd look into other serailisation formats
[06:54:00] ytti: which offer transferable set support
[06:56:05] ytti: hmm protobuf doesn't support set either
[06:57:04] ytti: capnproto neither
[06:59:32] ytti: avro neither, well set seems surprisingly rare
[07:00:42] ytti: messagepack doesn't have set either
[07:02:29] ytti: thrift has set
[07:05:09] ytti: i would probably just use list and write in api specification that it should not contain duplicates :/
[07:05:23] ytti: and behaviour for list with duplicates is unspecified
[17:21:29] ytti: indeed in UTF8 ë can be 1 or 2 runes
[17:21:44] ytti: there is specific rune for it, but you can also compose it from two runes
[17:21:49] ytti: they will be rendered exactly the same
[17:22:12] ytti: and this leads to all kind of consufing behaviour
[17:27:56] ytti:
[17:28:40] ytti: macOS uses fully decomposed umlauts when creating screenshot name in international versions
[17:28:46] ytti: which i've never seen used anywhere else
[17:29:12] ytti: where as all users of those languages use exclusively fully composed versions
[17:29:27] ytti: further, differnt shells and tools interepret them as different or same
[17:29:41] ytti: so you may end up in siitaution where you have same file twice in fielsystem, but some tools will only see it once
[17:30:16] ytti: also renaming and overwriting may happen, as some tools implicitly convert to fully composed format


[06:48:24] ytti: garyserj, {:a => :4} is non-sensical, as 4 cannot be cast into a symbol
[06:48:48] ytti: garyserj, {a: 4} is syntactic sugar for {:a => 4}
[09:31:44] ytti: it should be noted that === does not test for exact class
[09:32:06] ytti: for exact test, #instance_of?
[09:32:53] ytti: Number === 1 is true, but 1.instance_of? Numeric is false
[09:32:58] ytti: s/Number/Numberic/
[09:33:06] ytti: jesus christ, without typos
[10:02:45] ytti: like everything in ruby === is in no way magic, it's just def ===(other)
[10:02:57] ytti: so class is free to do what ever it wants
[10:03:11] ytti: i.e. Class === Time is syntactic sugar for Class.===(Time)
[10:03:34] ytti: well, slightly magic, magic is that some methods can be called without .


[12:06:13] ytti: depesz, if it returns nil, the method is not ran but nil is returned
[12:06:50] ytti: x can be nillable in above example
[12:06:58] ytti: you don't have to know
[12:07:12] ytti: without &. it must be string, otherwise there is runtime error
[12:25:19] ytti: i think downcase&.start_with? is useless use of &.
[12:25:24] ytti: i don't thnk downcase can return nil
[19:18:27] ytti: wait till you see OpenStruct


[15:27:25] ytti: ryouba, define_method
[15:31:20] ytti: ryouba, attr_accessor create def method; @method; end and def method=(value); @method=value; end


[16:49:55] ytti: *.net *.split


[07:14:38] ytti: mhlei, no, but if youhave attr_reader getter method is created for you, in which case, yes
[07:15:05] ytti: 'member variable' is a term which i had to guess what you mean, as it's not term relevant to ruby
[08:02:15] ytti: mhlei, did you check the parent class, perhaps it implementes query method?
[08:03:52] ytti: mhlei, - here you go
[17:48:28] ytti: i use [var].flatten pattern a lot, when i want method to accept value or list of values
[17:48:42] ytti: but i'm not sure how this applies to hash, because are you then setting they key or value?
[17:48:52] ytti: you have just one variable, how do you create dummy hash out of it?
[17:49:12] ytti: like you can do {}.merge(hash).each
[17:49:19] ytti: but i don't understand where it would make sense


[13:41:36] ytti: for company stuff, top-level is company name for me
[13:42:02] ytti: may not be idiomatic and i don't feel very strong about it, just something i've done


[10:11:46] ytti: do remember that def, rescue, end is an option
[10:14:50] ytti: WhereIsMySpoon, def foo(input); JSON.parse! input; rescue # do stuff; end
[10:16:08] ytti: baz = JSON.parse!(input) rescue "poop"
[10:16:12] ytti: but this is discouraged
[10:16:28] ytti: generally not considered idiomatic
[10:16:35] ytti: but that doesn't mean you can't use it


[10:47:45] ytti: i don't think you're gonna like thte answer, but because #pack is Array method
[10:48:32] ytti: string.each_char.to_a.pack
[10:49:20] ytti: pack and unpack do the opposite things
[10:52:19] ytti: that seems reasonable
[10:52:51] ytti: another option is{|c|c.to_i(2).chr}.join
[10:55:39] ytti: usually pack and unpack are used to deal like wire coding
[10:55:52] ytti: so usually you know exactly how many you want to pack and unpack
[10:55:59] ytti: you don't know, and i wonder, why not
[11:00:06] ytti: you could do something like{|c|[c].pack("B*")}.join also
[11:00:17] ytti: i'm not sure i like the "" * ary.size
[11:00:53] ytti: usually your array would contain like fields, say ip source address, ip destination address, l4 port, ip protocl etc
[11:01:05] ytti: fixed set of values, that you know specificallyt how each needs to be coded
[11:01:16] ytti: then you'd pack it into a blob and send to the wire
[11:01:31] ytti: and conversely, once you read it from the wire, you'd use unpack to restore them
[11:01:57] ytti: but it is entirely possible i'm missing practical use case of not knowing how many items you need to pack


[17:29:59] ytti: i belive that'll read entire file to memory
[17:41:32] ytti: al2o3-cr, my point is, it'll be slow on large files
[17:42:37] ytti: al2o3-cr, coimparedto something like File.foreach(filename).reduce(0) { |sum, _| sum+1 }
[17:43:52] ytti: fair enough
[17:48:42] ytti: it offends my aesthethics too


[14:48:10] ytti: quite, rather many optimzation there could be
[14:48:31] ytti: like for example, you only need to figure out the lengths which are divisible by the total length of the string
[14:48:48] ytti: but premature optimsation is source of great many evil