sylario has quit [Quit: Connection closed for inactivity]
rafadc_ has quit [Ping timeout: 259 seconds]
<phaul>
dorian, class Foo < Bar {... is interpreted as a method call to !upcase method call Bar with a block. is that what's intended?
<phaul>
I mean call method Bar
<phaul>
you can inherit from expressions, so things that look like method calls will be taken as such
<dorian>
maybe it would make more sense if i said the idiom was class Foo < Sequel::Model(arg) do ...
<phaul>
I guess Sequel::Model is a method then..
<dorian>
that method returns an anonymous class
<phaul>
gotcha
<dorian>
yeah and it takes a block where you tell it stuff
<phaul>
ok makes sense
<dorian>
yeah so i just want to stick that block in a hash with a bunch of other configuration data
<dorian>
but that block is called in the context of (i think?) the resulting class
<dorian>
so just trying to figure out how to massage a proc so that the context is correct
<dorian>
"call this method with this proc as a block"
<dorian>
i dunno if that's an instance_eval thing or if there's some other way to do it
Swyper has joined #ruby
Wolland has joined #ruby
skryking has quit [Ping timeout: 272 seconds]
wildermind has quit [Quit: Connection closed for inactivity]
Wolland has quit [Client Quit]
skryking has joined #ruby
<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
<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.
<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.
<dorian>
i just mean like, i want to cut the block out, and stick it in a hash member
<phaul>
but that should just work...
<dorian>
and then i want to meta-code the execution of the block
<dorian>
and my problem is that the resulting proc does not get run in the right context
<adam12>
dorian: You could just make a proc/lambda here?
<dorian>
that's what i'm doing
<adam12>
dorian: or are you already that far?
<adam12>
dorian: So you're missing context somehow. Can you put together a minimal example?
<dorian>
say like, i have DISPATCH = { key: -> { this_should_run_as_if_inside_a_block } }
<dorian>
but then i get a MethodError
<dorian>
or just plain nothing
<phaul>
can you call this_should_... on an explicit receiver? not self? would it work that way?
<dorian>
that's what i don't know how to formulate
kapilp has quit [Quit: Connection closed for inactivity]
sagax has quit [Ping timeout: 272 seconds]
sagax has joined #ruby
code_zombie has joined #ruby
<ryouba>
gaussblurinc1: ruby is not python is not python2 is not python2.7 is not python is not python3 is not python3.7 ;)
<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?
<ryouba>
sorry, #scan only takes the one argument, obviously
<ryouba>
oh *damn* it *does* yield 15 matches
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
esp32_prog has joined #ruby
<ryouba>
and .gsub works just as well
<ryouba>
phaul: apologies. i must have been braindead yesterday.
esp32_prog has quit [Ping timeout: 246 seconds]
<NL3limin4t0r>
ryouba: np, happens to the best of us
Guest22 has quit [Remote host closed the connection]
banisterfiend has quit [Ping timeout: 248 seconds]
<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.
<NL3limin4t0r>
ryouba: eg. the fourth match in the rubular link.
arahael has quit [Quit: WeeChat 2.2]
arahael1 has joined #ruby
octos has quit [Remote host closed the connection]
octos has joined #ruby
<ryouba>
NL3limin4t0r: keep reading. my point yesterday, though, was that that loop construct is pretty much superfluous.
<ryouba>
and ytti's counter-argument was that when a regex becomes too complex you should better take the problem apart further.
Fusl has quit [Excess Flood]
Fusl has joined #ruby
Swyper has quit [Remote host closed the connection]
RiPuk has quit [Ping timeout: 258 seconds]
octos has quit [Remote host closed the connection]
doodlebug has quit [Read error: Connection reset by peer]
octos has joined #ruby
arahael1 is now known as Arahael
doodlebug has joined #ruby
<gaussblurinc1>
balo: thanks!
gaussblurinc1 has quit [Quit: Leaving.]
Arahael has quit [Quit: WeeChat 2.2]
jcalla has quit [Ping timeout: 246 seconds]
<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.
Arahael has joined #ruby
<NL3limin4t0r>
ryouba: If you'd like to remove the nesting (and preserve the outer one) the following regex will do just fine: /\[\[([^\]]*)\]\([^)]*\)\]/
<ryouba>
NL3limin4t0r: the objective was to get rid of the nested links
<ryouba>
NL3limin4t0r: and what i'm doing is basically like your regex but mine is less elegant
<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]')`
<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 `)]`.
conta has quit [Ping timeout: 268 seconds]
KeyJoo has quit [Ping timeout: 258 seconds]
<ryouba>
hmm
<ryouba>
seems good regexes require pretty dynamic thinking
<ryouba>
interesting, that did do *some*thing a little different ... enough for git to register each modified line in the output TOC.
jefffrails35 has quit [Ping timeout: 248 seconds]
<ryouba>
so much cleaner than mine ... thank you NL3limin4t0r :)
Nicmavr has quit [Ping timeout: 245 seconds]
Nicmavr has joined #ruby
conta1 has joined #ruby
jefffrails35 has joined #ruby
<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.
<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.
grilix_ has quit [Ping timeout: 258 seconds]
jcalla has joined #ruby
cthulchu_ has quit [Ping timeout: 246 seconds]
al2o3-cr has quit [Quit: If the universe is a machine where the future is uniquely determined by its present state, it would not be possible to calculate what the future will be.]
P0rkD_ has joined #ruby
P0rkD__ has quit [Remote host closed the connection]
Nicmavr has joined #ruby
Guest6396 is now known as zodd_
wildermind has quit [Quit: Connection closed for inactivity]
<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.
<jhass>
no, the latter is the binary string representation, that is the binary representation as a string
<jhass>
of course each of those 1 and 0s takes up 1 byte
<jhass>
but what is a string? it's a sequence of codepoints, aka numbers
<depesz>
what is the proper way to configure gem, so that it will install to $HOME, by default, and will load from there first ?
<jhass>
easiest is probbaly just export GEM_HOME="$HOME/.gems" from your shellrc
<depesz>
thx
<jhass>
might make your system gems unavailable, not sure
<jhass>
so you might also need to readd them to GEM_PATH
<jhass>
gem env is great for debugging such
<depesz>
thanks a lot. works :)
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
naught-fowl has quit [Ping timeout: 256 seconds]
englosh has quit [Ping timeout: 256 seconds]
lucasb has joined #ruby
salerace has joined #ruby
<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
jenrzzz has quit [Ping timeout: 248 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
nowhereman has quit [Ping timeout: 258 seconds]
koala_man has joined #ruby
<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
<koala_man>
similar to how C read(2) works
P0rkD has joined #ruby
<jhass>
read_nonblock
jenrzzz has joined #ruby
grilix_ has quit [Read error: Connection reset by peer]
<koala_man>
thanks! actually readpartial but yes
Ltem has quit [Remote host closed the connection]
Ltem has joined #ruby
SeepingN has joined #ruby
esp32_prog has joined #ruby
ellcs has joined #ruby
esp32_prog has quit [Ping timeout: 272 seconds]
Harlin has joined #ruby
fphilipe_ has quit [Ping timeout: 272 seconds]
catbusters has quit [Quit: Connection closed for inactivity]
laaron has quit [Remote host closed the connection]
laaron has joined #ruby
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
n13z has joined #ruby
<al2o3-cr>
koala_man: my might want to consider sysread?
<koala_man>
good to know, thanks
jeremycw has quit [Ping timeout: 244 seconds]
<jhass>
what's the advantage towards the mentioned methods?
<al2o3-cr>
jhass: none at all.
<jhass>
then why use it?
<al2o3-cr>
just giving them the other alternative to read(2)
<jhass>
I think that's just confusing when a solution was already found
<al2o3-cr>
jhass: whoa! sorry.
<jhass>
without at least mentioning tradeoffs compared to the other solutions
<al2o3-cr>
jhass: they can at least read the docs for differences
niceperl has joined #ruby
<jhass>
the docs here don't paint a great picture on the tradeoffs here to be honest
Ltem has quit [Quit: bye]
<jhass>
esp. if you don't already have experience around the tradeoffs between buffered and non-buffered IO
<al2o3-cr>
jhass: neither did van gogh's.
<jhass>
good thing none of use would ever refer to van gogh's works as a reference for writing ruby code
jenrzzz has quit [Ping timeout: 272 seconds]
hightower3 has quit [Ping timeout: 268 seconds]
<al2o3-cr>
they're pretty clear what each does imho.
jenrzzz has joined #ruby
bambanx has joined #ruby
<al2o3-cr>
but whatever
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
galaxie has quit [Remote host closed the connection]
<depesz>
balo:i do.
galaxie has joined #ruby
moei has quit [Quit: Leaving...]
sameerynho has quit [Ping timeout: 244 seconds]
schne1der has quit [Ping timeout: 248 seconds]
P0rkD has quit [Remote host closed the connection]
nowhereman has joined #ruby
octos has quit [Remote host closed the connection]
octos has joined #ruby
houhoulis has joined #ruby
reber has quit [Remote host closed the connection]
hiroaki has quit [Ping timeout: 250 seconds]
Talion has joined #ruby
kapilp has joined #ruby
nowhereman has quit [Ping timeout: 258 seconds]
robotcars has left #ruby [#ruby]
haxx0r has quit [Ping timeout: 272 seconds]
polishdub has quit [Quit: leaving]
RyanMcCoskrie has joined #ruby
ellcs has quit [Ping timeout: 250 seconds]
NightMonkey_ has joined #ruby
NightMonkey has quit [Ping timeout: 252 seconds]
graft has joined #ruby
graft has quit [Changing host]
graft has joined #ruby
budonyc has quit [Quit: Leaving]
codefriar has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
niceperl has quit [Quit: Leaving...]
esp32_prog has joined #ruby
graft has quit [Ping timeout: 248 seconds]
esp32_prog has quit [Ping timeout: 258 seconds]
Exuma has joined #ruby
Exuma has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shansen has quit [Remote host closed the connection]
brool has quit [Ping timeout: 248 seconds]
jenrzzz has quit [Ping timeout: 272 seconds]
brool has joined #ruby
salerace has quit [Ping timeout: 248 seconds]
gaussblurinc1 has quit [Quit: Leaving.]
tdy has quit [Ping timeout: 246 seconds]
GodFather has quit [Ping timeout: 258 seconds]
code_zombie has quit [Quit: Leaving]
salerace has joined #ruby
haxx0r has joined #ruby
<haxx0r>
i'm generating random numbers for a roulette game with hashes we get provided as a seed.
<haxx0r>
`seed = block_hash.to_i(16)
<haxx0r>
i use those numbers to play roulette. i've seen, that we had 13x black in a row.
<haxx0r>
i wonder iv this has something tody with Random
RyanMcCoskrie has quit [Remote host closed the connection]
lucasb has quit [Quit: Connection closed for inactivity]
houhoulis has quit [Ping timeout: 252 seconds]
<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