« Back to channel list

#ruby - 28 May 2019

« Back 1 day Forward 1 day »
[00:00:36] phaul: dorian, class Foo < Bar {... is interpreted as a method call to !upcase method call Bar with a block. is that what's intended?
[00:00:54] phaul: I mean call method Bar
[00:01:45] phaul: you can inherit from expressions, so things that look like method calls will be taken as such
[00:01:46] dorian: maybe it would make more sense if i said the idiom was class Foo < Sequel::Model(arg) do ...
[00:02:27] phaul: I guess Sequel::Model is a method then..
[00:02:30] dorian: that method returns an anonymous class
[00:02:49] dorian: yeah and it takes a block where you tell it stuff
[00:03:01] phaul: ok makes sense
[00:03:27] dorian: yeah so i just want to stick that block in a hash with a bunch of other configuration data
[00:04:01] dorian: but that block is called in the context of (i think?) the resulting class
[00:04:25] dorian: so just trying to figure out how to massage a proc so that the context is correct
[00:05:06] dorian: "call this method with this proc as a block"
[00:05:24] dorian: i dunno if that's an instance_eval thing or if there's some other way to do it
[00:07:01] Swyper: has joined #ruby
[00:07:18] Wolland: has joined #ruby
[00:10:42] skryking: has joined #ruby
[00:11:54] phaul: but whoever receives the block decides what to do with it. If they decide to class eval it so be it, if they decide to instance eval it then that
[00:11:56] adam12: dorian: No idiom that I know for class X do (specifically do/end), but there _is_ an idiom for returning a module that might be OK.
[00:13:22] adam12: dorian: So with that, you might be able to make something work by returning a class (Class.new), but I've never personally tried it. Alternatively, use the common include SomeModule.new trick.
[00:13:34] dorian: i just mean like, i want to cut the block out, and stick it in a hash member
[00:13:47] phaul: but that should just work...
[00:13:48] dorian: and then i want to meta-code the execution of the block
[00:14:20] dorian: and my problem is that the resulting proc does not get run in the right context
[00:14:23] adam12: dorian: You could just make a proc/lambda here?
[00:14:29] dorian: that's what i'm doing
[00:14:32] adam12: dorian: or are you already that far?
[00:14:54] adam12: dorian: So you're missing context somehow. Can you put together a minimal example?
[00:15:14] dorian: say like, i have DISPATCH = { key: -> { this_should_run_as_if_inside_a_block } }
[00:15:41] dorian: but then i get a MethodError
[00:15:47] dorian: or just plain nothing
[00:17:04] phaul: can you call this_should_... on an explicit receiver? not self? would it work that way?
[00:17:20] dorian: that's what i don't know how to formulate
[00:17:47] phaul: a = self; ISPATCH = { key: -> { a.this_should_run_as_if_inside_a_block } }
[00:18:04] dorian: ohhhh yeah no
[00:18:31] dorian: the thing is voodooey DSL
[00:18:36] blerrp: has joined #ruby
[00:18:46] dorian: that's why i want to set the execution context of the proc
[00:19:42] dorian: write the proc as if it *is* the block, feed the block to the method, don't consternate any more about it
[00:20:37] P0rkD__: has joined #ruby
[00:20:45] dorian: just let me double-check something: if you call method(arg, &proc) does that do the same thing as method do # whatever's in the proc
[00:21:43] dorian: (because i tried that and it did nothing)
[00:21:47] phaul: more or less. they are semantically the same one being faster or the other
[00:22:25] phaul: the thing is once you hand over a block to a method, they are inc charge and can eval it whichever way they like
[00:22:31] dorian: that's fine
[00:22:48] phaul: that's including what self is
[00:23:38] dorian: yeah i want self to be exactly the self that would otherwise be in the inline block
[00:23:58] phaul: yeah, a = self; ISPATCH = { key: -> { a.this_should ...
[00:24:36] phaul: dont think there is any other way but to escape the block of actually unsing self
[00:24:41] orbyt_: has joined #ruby
[00:25:46] Nicmavr: has joined #ruby
[00:28:55] dorian: oneoff looks like this:
[00:28:56] dorian: warnlol = -> { one_to_many :token, key: :user }
[00:28:56] dorian: m.const_set :User, Class.new(Sequel::Model(db[:user], &warnlol))
[00:29:27] dorian: warnlol is never run
[00:30:24] rafadc: has joined #ruby
[00:30:54] dorian: but the idea would be to be like DISPATCH = { User: -> { one_to_many :token, key: user } } ...
[00:31:25] dorian: anyway maybe it's just an idiosyncrasy of that particular thing that the proc isn't getting run?
[00:31:29] dorian: or am i just doing it wrong
[00:32:46] haxx0r: what's the best gem to listen on WSS forever?
[00:33:19] phaul: is Class.new needed at all?
[00:33:29] haxx0r: not always
[00:34:10] dorian: well the ad-hoc way to define these things is like class MyTable < Sequel::Model(DB[:mytable]) do # specs here...
[00:34:51] phaul: I mean in the line m.const_set :User, .. would just Sequel::Model(db[:user], &warnlol) work?
[00:35:51] phaul: it's already returning a class why create a subclass yet again?
[00:36:42] dorian: i dunno i'm kinda cheating around the way it was designed
[00:37:16] dorian: like the way it's designed is you make a static class which is a subclass of whatever the method returns
[00:37:45] dorian: class MyTable < Sequel::Model(DB[:my_table])
[00:37:48] dorian: which takes a block
[00:37:54] dorian: where the configuration DSL goes
[00:38:03] phaul: I think if m.const_set :User,Sequel::Model(db[:user]) do was running the block so should the other syntax
[00:38:36] dorian: ostensibly it doesn't
[00:38:43] phaul: maybe a works and doesn't work example gists would help to understand
[00:39:03] dorian: it actually doesn't matter because i just discovered that the 'self' in the block is actually the resulting class
[00:39:08] dorian: like just this second
[00:39:57] dorian: so i can write vanilla procs and pass in the class as an argument and not have to care about what context they're being executed in
[00:40:12] dorian: i just didn't want to do that before in case it was some magic dsl voodoo
[00:41:07] dorian: anyway i think the problem was i was expecting that &proc syntax to do something visible and it didn't
[00:44:51] dorian: so maybe there's a subtle difference in the semantics that causes &procs passed in lieu of blocks to get silently disappeared?
[00:46:27] kapilp: has joined #ruby
[00:47:22] d^sh: has joined #ruby
[00:50:08] dorian: anyway that Sequel module is definitely opinionated
[00:50:32] dorian: i'm not entirely sure why those things are classes
[00:50:36] orbyt_: has joined #ruby
[00:50:54] dorian: or rather, they need a live instance of a connection to be created
[00:51:09] dorian: so you're mixing class and instance
[00:51:58] esp32_prog: has joined #ruby
[00:55:52] Kestrel-029: has joined #ruby
[01:01:01] jenrzzz: has joined #ruby
[01:06:20] nowhereman: has joined #ruby
[01:08:18] bambanxx: has joined #ruby
[01:08:55] P0rkD: has joined #ruby
[01:13:41] ozzloy: has joined #ruby
[01:13:45] a7d7p7: has joined #ruby
[01:15:37] hackeron: has joined #ruby
[01:21:05] tdy: has joined #ruby
[01:24:08] queip: has joined #ruby
[01:31:14] moei: has joined #ruby
[01:41:43] meinside: has joined #ruby
[01:47:32] doodlebug: has joined #ruby
[01:50:53] _dbugger: has joined #ruby
[01:51:36] jenrzzz: has joined #ruby
[01:55:15] rafadc: has joined #ruby
[01:58:39] mniip: has joined #ruby
[02:06:11] codefriar: has joined #ruby
[02:10:46] Nicmavr: has joined #ruby
[02:13:27] ltd: has joined #ruby
[02:20:41] ur5us: has joined #ruby
[02:23:42] P0rkD: has joined #ruby
[02:32:43] banisterfiend: has joined #ruby
[02:40:10] esp32_prog: has joined #ruby
[02:41:49] graft: has joined #ruby
[02:42:48] Fusl: has joined #ruby
[03:04:40] Azure|dc: has joined #ruby
[03:06:01] P0rkD: has joined #ruby
[03:09:05] jenrzzz: has joined #ruby
[03:09:22] braincrash: has joined #ruby
[03:16:35] hackeron: has joined #ruby
[03:19:26] LenPayne: has joined #ruby
[03:27:24] graft: has joined #ruby
[03:27:25] graft: has joined #ruby
[03:30:44] duderonomy: has joined #ruby
[03:45:35] laaron: has joined #ruby
[03:53:51] ur5us_: has joined #ruby
[03:56:02] tdy: has joined #ruby
[03:56:33] sagax: has joined #ruby
[04:05:55] jenrzzz: has joined #ruby
[04:18:14] P0rkD_: has joined #ruby
[04:26:47] Tempesta: has joined #ruby
[04:26:47] Tempesta: has joined #ruby
[04:27:29] banisterfiend: has joined #ruby
[04:28:29] esp32_prog: has joined #ruby
[04:33:10] dellavg_: has joined #ruby
[04:39:33] codefriar: has joined #ruby
[04:43:50] fphilipe_: has joined #ruby
[04:46:47] esrse: has joined #ruby
[04:54:03] jenrzzz: has joined #ruby
[05:09:31] orbyt_: has joined #ruby
[05:20:45] conta: has joined #ruby
[05:22:09] kyrylo: has joined #ruby
[05:26:15] cthulchu: has joined #ruby
[05:26:50] laaron: has joined #ruby
[05:28:44] Azure: has joined #ruby
[05:37:12] Azure: has joined #ruby
[05:45:21] brucebag: has joined #ruby
[05:46:11] brucebag: has joined #ruby
[05:53:52] hightower2: has joined #ruby
[05:57:21] schne1der: has joined #ruby
[06:04:25] fphilipe_: has joined #ruby
[06:10:47] Kestrel-029: has joined #ruby
[06:16:42] esp32_prog: has joined #ruby
[06:17:47] al2o3-cr: has joined #ruby
[06:30:28] hackeron: has joined #ruby
[06:30:53] banisterfiend: has joined #ruby
[06:44:06] lxsameer: has joined #ruby
[06:45:06] jenrzzz: has joined #ruby
[06:48:48] migalenkom_: has joined #ruby
[06:49:53] migalenkom_: has left #ruby: ()
[06:51:22] _dbugger: has joined #ruby
[06:53:25] TomyWork: has joined #ruby
[06:53:57] fphilipe_: has joined #ruby
[06:59:34] salerace: has joined #ruby
[07:01:55] jenrzzz: has joined #ruby
[07:02:08] powerbit: has joined #ruby
[07:12:16] TomyWork: has joined #ruby
[07:17:05] jenrzzz: has joined #ruby
[07:26:18] jefffrails35: has joined #ruby
[07:27:20] P0rkD_: has joined #ruby
[07:31:18] facest: has joined #ruby
[07:34:04] schne1der: has joined #ruby
[07:39:57] tjbp: has joined #ruby
[07:42:15] hackeron: has joined #ruby
[07:45:31] esp32_prog: has joined #ruby
[07:49:04] kapilp: has joined #ruby
[07:58:05] jenrzzz: has joined #ruby
[07:59:05] TomyLobo2: has joined #ruby
[08:03:04] jenrzzz: has joined #ruby
[08:07:19] banisterfiend: has joined #ruby
[08:19:40] comet23: has joined #ruby
[08:21:21] Fischmiep: has joined #ruby
[08:21:55] KeyJoo: has joined #ruby
[08:29:16] P0rkD__: has joined #ruby
[08:31:10] sphenxes: has joined #ruby
[08:37:26] banisterfiend: has joined #ruby
[08:39:09] ur5us: has joined #ruby
[08:46:25] TomyLobo2: has joined #ruby
[08:56:21] deepreds1: has joined #ruby
[08:56:34] banisterfiend: has joined #ruby
[09:01:12] banisterfiend: has joined #ruby
[09:01:23] dhollin3: has joined #ruby
[09:07:38] BlueNeXuS: has joined #ruby
[09:09:51] gigetoo: has joined #ruby
[09:10:20] grilix_: has joined #ruby
[09:10:52] Ai9zO5AP: has joined #ruby
[09:15:34] BlueNeXuS|2: has joined #ruby
[09:16:02] ur5us: has joined #ruby
[09:29:42] Jonopoly: has joined #ruby
[09:30:37] deepreds1: has joined #ruby
[09:30:51] m_antis: has joined #ruby
[09:31:31] P0rkD_: has joined #ruby
[09:31:55] Jonopoly: has joined #ruby
[09:33:25] laaron: has joined #ruby
[09:37:11] AJA4350: has joined #ruby
[09:37:57] Jonopoly: has joined #ruby
[09:44:13] Jonopoly: has joined #ruby
[09:48:31] ShalokShalom: has joined #ruby
[09:57:06] Jonopoly: has joined #ruby
[09:59:27] TomyWork: has joined #ruby
[10:00:43] RockStar_: has joined #ruby
[10:05:11] Jonopoly: has joined #ruby
[10:08:03] Jonopoly: has joined #ruby
[10:10:31] Sylario: has joined #ruby
[10:10:51] Nicmavr: has joined #ruby
[10:12:27] exmortus: has joined #ruby
[10:20:50] Jonopoly: has joined #ruby
[10:21:20] sagax: has joined #ruby
[10:25:52] Kestrel-029: has joined #ruby
[10:27:13] P0rkD__: has joined #ruby
[10:30:50] doodlebug: has joined #ruby
[10:37:54] conta: has joined #ruby
[10:38:07] wildermind: has joined #ruby
[10:44:56] nowhereman: has joined #ruby
[10:45:55] gaussblurinc1: has joined #ruby
[10:46:37] gaussblurinc1: Hi! Could anybody advise a ruby version in 2019? I would like to use it for tools as fastlane.
[10:49:17] laaron: has joined #ruby
[10:50:40] laaron: has joined #ruby
[10:55:45] RockStar_: has joined #ruby
[10:57:53] haxx0r: has joined #ruby
[10:59:13] balo: what do you mean gaussblurinc1 ? do you have any special requirement?
[10:59:21] laaron: has joined #ruby
[11:00:18] balo: in general, probably you are probably best off with the latest 2.6.x version of MRI https://www.ruby-lang.org/en/downloads/
[11:01:32] sagax: has joined #ruby
[11:03:16] Nicmavr: has joined #ruby
[11:08:01] sagax: has joined #ruby
[11:11:39] code_zombie: has joined #ruby
[11:19:51] ryouba: gaussblurinc1: ruby is not python is not python2 is not python2.7 is not python is not python3 is not python3.7 ;)
[11:24:20] ryouba: NL3limin4t0r: so `string.scan /regex/, '\1[\2](\3)'` should by all means yield the same 15 matches as can be seen at https://rubular.com/r/k1tkaZe0UMfDoa ? *if* i understood you correctly?
[11:26:17] ryouba: sorry, #scan only takes the one argument, obviously
[11:26:52] ryouba: oh *damn* it *does* yield 15 matches
[11:27:54] esp32_prog: has joined #ruby
[11:28:56] ryouba: and .gsub works just as well
[11:29:05] ryouba: phaul: apologies. i must have been braindead yesterday.
[11:33:31] NL3limin4t0r: ryouba: np, happens to the best of us
[11:37:02] Swyper: has joined #ruby
[11:38:15] ryouba: phaul: NL3limin4t0r: ytti: https://gist.github.com/sixtyfive/e1f70533598daac01931e611790aaea7
[11:46:56] banisterfiend: has joined #ruby
[11:49:46] laaron: has joined #ruby
[11:50:36] esp32_prog: has joined #ruby
[11:51:28] guest22: has joined #ruby
[11:54:37] NL3limin4t0r: ryouba: What if your match normally would span accros multiple lines? You currently have `STDIN.read.split("\n")` and then do stuff with just one sigle line.
[11:55:22] NL3limin4t0r: ryouba: eg. the fourth match in the rubular link.
[11:59:18] arahael1: has joined #ruby
[12:02:16] octos: has joined #ruby
[12:02:53] ryouba: NL3limin4t0r: keep reading. my point yesterday, though, was that that loop construct is pretty much superfluous.
[12:03:18] ryouba: and ytti's counter-argument was that when a regex becomes too complex you should better take the problem apart further.
[12:06:34] Fusl: has joined #ruby
[12:15:45] octos: has joined #ruby
[12:16:00] doodlebug: has joined #ruby
[12:25:49] NL3limin4t0r: ryouba: I'll read it later. For now I'd like to say that the provided text looks like perfectly valid markdown, with some nested links.
[12:27:16] Arahael: has joined #ruby
[12:31:37] NL3limin4t0r: ryouba: If you'd like to remove the nesting (and preserve the outer one) the following regex will do just fine: /\[\[([^\]]*)\]\([^)]*\)\]/
[12:34:50] ryouba: NL3limin4t0r: the objective was to get rid of the nested links
[12:35:18] ryouba: NL3limin4t0r: and what i'm doing is basically like your regex but mine is less elegant
[12:36:46] NL3limin4t0r: ryouba: I don't capture the match the last `(text)` since that part you place back anyways, that's why its so much shorter. `text.gsub(/\[\[([^\]]*)\]\([^)]*\)\]/, '[\1]')`
[12:41:00] NL3limin4t0r: This looks for two `[` characters, followed by any amount of none `]` characters captured in group 1. Then matches `](`, followed by any amount of non `)` characters, followed by `)]`.
[12:48:37] ryouba: seems good regexes require pretty dynamic thinking
[12:48:51] ryouba: i do understand now :}
[12:51:35] laaron: has joined #ruby
[12:52:57] KeyJoo: has joined #ruby
[12:53:12] ryouba: interesting, that did do *some*thing a little different ... enough for git to register each modified line in the output TOC.
[12:53:39] ryouba: so much cleaner than mine ... thank you NL3limin4t0r :)
[12:55:46] Nicmavr: has joined #ruby
[12:56:54] conta1: has joined #ruby
[13:01:48] jefffrails35: has joined #ruby
[13:03:16] NL3limin4t0r: ryouba: Git(hub) doesn't always have the best change detection. When commiting haml files it sometimes marks the whole document as changed, despite adding only one line and indenting some other parts.
[13:07:36] schneider: has joined #ruby
[13:10:47] Kestrel-029: has joined #ruby
[13:19:34] zodd: has joined #ruby
[13:19:40] vondruch: has left #ruby: ()
[13:21:33] vondruch: has joined #ruby
[13:21:49] budonyc: has joined #ruby
[13:25:30] laaron: has joined #ruby
[13:26:00] cthulchu_: has joined #ruby
[13:27:37] cthu|: has joined #ruby
[13:28:09] ryouba: hmm i never had that before. if a line is changed, then it's changed. sometimes i'll have to go look with a hex editor but if i do i always find something.
[13:30:23] jcalla: has joined #ruby
[13:34:00] P0rkD_: has joined #ruby
[13:39:36] Nicmavr: has joined #ruby
[13:42:02] al2o3-cr: has joined #ruby
[13:43:35] doodleb87: has joined #ruby
[13:45:10] tdy: has joined #ruby
[13:45:35] Inline: has joined #ruby
[13:51:10] al2o3-cr: has joined #ruby
[13:52:34] P0rkD_: has joined #ruby
[13:53:03] laaron: has joined #ruby
[14:01:50] laaron: has joined #ruby
[14:05:15] laaron: has joined #ruby
[14:06:44] WhereIsMySpoon: has joined #ruby
[14:06:44] WhereIsMySpoon: has joined #ruby
[14:08:24] gaussblurinc1: has joined #ruby
[14:11:30] jrafanie: has joined #ruby
[14:16:36] jeremycw: has joined #ruby
[14:32:04] AlHafoudh: has joined #ruby
[14:33:36] donofrio: has joined #ruby
[14:35:29] cthulchu: has joined #ruby
[14:37:42] cthulchu: has joined #ruby
[14:38:00] TomyWork: has joined #ruby
[14:39:11] doodleb80: has joined #ruby
[14:43:00] codefriar: has joined #ruby
[14:43:50] brendan-: has joined #ruby
[14:44:14] grilix_: has joined #ruby
[14:46:31] galaxie: has joined #ruby
[14:50:41] rippa: has joined #ruby
[15:04:45] kapilp: has joined #ruby
[15:07:09] octos: has joined #ruby
[15:16:26] AlHafoudh: has joined #ruby
[15:25:43] jrafanie: has joined #ruby
[15:26:57] hightower3: has joined #ruby
[15:32:22] d^sh_: has joined #ruby
[15:37:34] P0rkD__: has joined #ruby
[15:41:07] spiette_: has joined #ruby
[15:42:11] graft: has joined #ruby
[15:45:29] gix: has joined #ruby
[15:48:38] tdy: has joined #ruby
[15:49:59] gaussblurinc1: has joined #ruby
[15:50:37] Ripcode: has joined #ruby
[15:53:41] schne1der: has joined #ruby
[16:05:39] dar123: has joined #ruby
[16:10:18] Fusl: has joined #ruby
[16:29:02] RiPuk: has joined #ruby
[16:30:21] jenrzzz: has joined #ruby
[16:38:28] octos: has joined #ruby
[16:38:49] esp32_prog: has joined #ruby
[16:44:01] kyrylo: has joined #ruby
[16:46:12] kyrylo: has joined #ruby
[16:48:51] Guest75268: has joined #ruby
[16:50:39] cd: has joined #ruby
[16:51:30] hiroaki: has joined #ruby
[16:53:50] gigetoo: has joined #ruby
[16:55:25] leah2: has joined #ruby
[16:59:19] duderonomy: has joined #ruby
[17:00:55] nowhereman: has joined #ruby
[17:05:23] sameerynho: has joined #ruby
[17:09:18] codefriar: has joined #ruby
[17:18:46] jenrzzz: has joined #ruby
[17:32:47] tdy: has joined #ruby
[17:37:37] robotcars: has joined #ruby
[17:38:16] ricekrispie: has joined #ruby
[17:39:17] ltem: has joined #ruby
[17:40:42] jinie_: has joined #ruby
[17:43:38] skryking: has joined #ruby
[17:43:48] esp32_prog: has joined #ruby
[17:57:02] deepreds1: has joined #ruby
[17:58:28] hiroaki: has joined #ruby
[17:59:01] johnp: has joined #ruby
[18:01:57] cthulchu: has joined #ruby
[18:02:50] dar123: has joined #ruby
[18:07:54] brucebag: has left #ruby: ()
[18:08:44] naught-fowl: has joined #ruby
[18:10:57] Kestrel-029: has joined #ruby
[18:37:48] jefffrails35: has joined #ruby
[18:40:57] tdy: has joined #ruby
[18:44:18] sezuan: has joined #ruby
[18:58:42] TvL2386: has joined #ruby
[18:59:51] gaussblurinc1: has joined #ruby
[19:02:36] ravenousmoose: has joined #ruby
[19:08:00] reber: has joined #ruby
[19:10:21] salerace: has joined #ruby
[19:17:52] chrisseaton_: has joined #ruby
[19:18:56] polishdub: has joined #ruby
[19:19:03] codefriar: has joined #ruby
[19:22:45] jenrzzz: has joined #ruby
[19:25:32] galaxie: has joined #ruby
[19:30:16] catbusters: has joined #ruby
[19:32:02] esp32_prog: has joined #ruby
[19:36:48] al2o3-cr: &>> X = Class.new; 20.times.map { X.new }; ObjectSpace.each_object(X).map(&:__id__).each_cons(2).map { |x, y| y - x }
[19:36:53] rubydoc: # => [180, 400, 160, 1360, 4180, 260, 780, 2720, 1040, 400, 460, 160, 400, 580, 320, 1540, 160, 80, 240] (https://carc.in/#/r/701k)
[19:40:41] havenwood: &>> X = Class.new; 20.times.map { X.new }; ObjectSpace.each_object(X).map { |obj| obj.__id__ << 1 }.each_cons(2).map { |x, y| y - x }
[19:40:42] rubydoc: # => [240, 17280, 2320, 240, 480, 360, 400, 240, 240, 280, 440, 520, 1360, 280, 280, 600, 2160, 840, 840] (https://carc.in/#/r/701l)
[19:43:40] al2o3-cr: memory is weird.
[19:44:00] nowhereman: has joined #ruby
[19:44:11] jhass: nah, GCs are :P
[19:48:25] orbyt_: has joined #ruby
[19:50:46] fphilipe_: has joined #ruby
[19:51:28] octos: has joined #ruby
[19:53:08] brool: has joined #ruby
[19:57:21] cd: has joined #ruby
[20:08:59] englosh: has joined #ruby
[20:09:06] englosh: what is the reason for ruby supporting only base 36?
[20:09:18] englosh: and not 256 for example
[20:10:42] claudiuinberlin: has joined #ruby
[20:13:53] jhass: what glyphs would that use?
[20:14:46] englosh: isn't base 256 still in the ASCII range?
[20:15:26] al2o3-cr: englosh: no
[20:15:32] jhass: no, ASCII has 127 characters, many not visible
[20:15:53] englosh: oh so that would actually be less space-efficient then to store a number as base256
[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:16:52] englosh: to store a number somewhere on a server for example
[20:17:05] englosh: as base 256 but that's not efficient as I just learned
[20:17:21] jhass: base256 doesn't exist afaik
[20:17:40] englosh: I mean you of course always want something to take up as little space as possible
[20:17:45] englosh: so what about base127?
[20:17:58] jhass: any string encoding of a number is likely less space efficient than it's binary representation
[20:18:05] codefriar: has joined #ruby
[20:20:14] jhass: &>> [124453423].pack("L").bytesize
[20:20:19] rubydoc: # => 4 (https://carc.in/#/r/701t)
[20:20:40] jhass: &>> 124453423.to_s(36).bytesize
[20:20:41] rubydoc: # => 6 (https://carc.in/#/r/701u)
[20:21:01] englosh: is that 124453423 encoded as base 127? in the first code?
[20:21:10] jhass: as a 32bit integer
[20:21:13] jhass: hence 4 bytes
[20:21:44] jhass: (32/8 = 4)
[20:22:04] englosh: hmm but why storing it as a 32 bit integer?
[20:22:07] ltem: has joined #ruby
[20:22:18] jhass: you asked for the most space effecient method
[20:22:47] al2o3-cr: englosh: on a 64bit system the byte size would be 13
[20:23:05] jhass: what, no why would it
[20:23:21] jhass: &>> `uname -a`
[20:23:28] rubydoc: # => "" (https://carc.in/#/r/701z)
[20:23:44] jhass: ah I blocked it :D
[20:23:56] jhass: be assured it's a 64bit kernel :P
[20:24:17] al2o3-cr: jhass: yep, no. you're right.
[20:25:30] al2o3-cr: jhass: i meant characters
[20:25:40] jhass: still that makes no sense
[20:26:14] englosh: hmm I'm a bit confused. what did you mean by "any string encoding of a number is likely less space efficient than its binary representation"? the string representation of 2318312 is "1dotk" but the binrary representation is "1000110101111111101000". That's way bigger.
[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:45] rubydoc: # => [49, 48, 48, 49, 49] (https://carc.in/#/r/7026)
[20:27:55] jhass: &>> "1dotk".codepoints
[20:27:56] rubydoc: # => [49, 100, 111, 116, 107] (https://carc.in/#/r/7028)
[20:28:10] al2o3-cr: &>> require 'rbconfig/sizeof'; RbConfig::LIMITS['LONG_MAX'].to_s(36).size
[20:28:11] rubydoc: # => 13 (https://carc.in/#/r/7029)
[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:29:02] fphilipe_: has joined #ruby
[20:30:16] englosh: yes thats probably a good idea to 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:31:53] rubydoc: # => "\xE8_#\x00" (https://carc.in/#/r/702d)
[20:32:15] depesz: what is the proper way to configure gem, so that it will install to $HOME, by default, and will load from there first ?
[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
[20:37:28] depesz: thanks a lot. works :)
[20:53:15] lucasb: has joined #ruby
[20:54:09] salerace: has joined #ruby
[20:56:42] balo: depesz: do you have the same nick on github? the other day i found the postgres explain analyze stuff you made, it's priceless
[21:00:21] jenrzzz: has joined #ruby
[21:07:20] koala_man: has joined #ruby
[21:07:52] koala_man: how do I read available data from stdin? like STDIN.read(1024) but returning whatever data's available without waiting for the buffer to fill up
[21:08:11] koala_man: similar to how C read(2) works
[21:08:33] P0rkD: has joined #ruby
[21:10:12] jhass: read_nonblock
[21:11:21] jenrzzz: has joined #ruby
[21:12:28] koala_man: thanks! actually readpartial but yes
[21:13:40] ltem: has joined #ruby
[21:16:47] SeepingN: has joined #ruby
[21:20:24] esp32_prog: has joined #ruby
[21:23:01] ellcs: has joined #ruby
[21:27:12] Harlin: has joined #ruby
[21:40:43] laaron: has joined #ruby
[21:41:42] n13z: has joined #ruby
[21:41:42] al2o3-cr: koala_man: my might want to consider sysread?
[21:42:16] koala_man: good to know, thanks
[21:42:39] jhass: what's the advantage towards the mentioned methods?
[21:42:54] al2o3-cr: jhass: none at all.
[21:43:09] jhass: then why use it?
[21:43:46] al2o3-cr: just giving them the other alternative to read(2)
[21:44:07] jhass: I think that's just confusing when a solution was already found
[21:44:26] al2o3-cr: jhass: whoa! sorry.
[21:44:28] jhass: without at least mentioning tradeoffs compared to the other solutions
[21:45:07] al2o3-cr: jhass: they can at least read the docs for differences
[21:46:09] niceperl: has joined #ruby
[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:46:57] al2o3-cr: jhass: neither did van gogh's.
[21:47:54] jhass: good thing none of use would ever refer to van gogh's works as a reference for writing ruby code
[21:48:35] al2o3-cr: they're pretty clear what each does imho.
[21:48:36] jenrzzz: has joined #ruby
[21:48:43] bambanx: has joined #ruby
[21:48:49] al2o3-cr: but whatever
[22:00:15] ruby[bot]: has joined #ruby
[22:00:15] ChanServ: +o ruby[bot]
[22:04:37] depesz: balo:i do.
[22:04:45] galaxie: has joined #ruby
[22:20:28] nowhereman: has joined #ruby
[22:21:28] octos: has joined #ruby
[22:22:29] houhoulis: has joined #ruby
[22:24:17] Talion: has joined #ruby
[22:30:08] kapilp: has joined #ruby
[22:35:59] robotcars: has left #ruby: ()
[22:40:45] RyanMcCoskrie: has joined #ruby
[22:44:31] NightMonkey_: has joined #ruby
[22:45:25] graft: has joined #ruby
[22:45:25] graft: has joined #ruby
[23:08:36] esp32_prog: has joined #ruby
[23:14:34] Exuma: has joined #ruby
[23:36:29] brool: has joined #ruby
[23:45:09] salerace: has joined #ruby
[23:46:24] haxx0r: has joined #ruby
[23:46:48] haxx0r: i'm generating random numbers for a roulette game with hashes we get provided as a seed.
[23:47:18] haxx0r: `seed = block_hash.to_i(16)
[23:47:57] haxx0r: i use those numbers to play roulette. i've seen, that we had 13x black in a row.
[23:48:07] haxx0r: i wonder iv this has something tody with Random
[23:58:22] phaul: while there might be something wrong somewhere it also might not. there a natural intuition about random / cognitive bias that makes ppl think that patterns in random should occur less often. There was an article about asking ppl to coin toss, and write down the result. The sequence given by cheaters was easily recognised as they generated too short repeating sequences
[23:58:44] orbyt_: has joined #ruby