choke has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rcvalle has quit [Quit: rcvalle]
LoneHerm_ has joined #ruby
diegoaguilar has quit [Ping timeout: 252 seconds]
benlieb has joined #ruby
Vile` has joined #ruby
* mwlang
deletes loooong question he figured out for himself… :-D
djcp1 has quit [Quit: WeeChat 1.0.1]
speaking1ode has joined #ruby
speakingcode has quit [Disconnected by services]
zeroDivisible has quit [Quit: WeeChat 1.3]
speaking1ode is now known as speakingcode
abyx has quit [Ping timeout: 264 seconds]
<speakingcode>
anyone know about issues with installing/compiling 2.1.3 with rvm? keep getting an error uncommon.mk:180: recipe for target 'build-ext' failed
<Radar>
speakingcode: Have you tried using ruby-install + chruby instead?
n008f4g_ has quit [Ping timeout: 276 seconds]
<Radar>
speakingcode: I've seen people who have had problems with RVM try that combination and then it has worked for them.
marr has quit [Ping timeout: 252 seconds]
FooMunki has quit [Quit: FooMunki]
statelesscode has joined #ruby
FooMunki has joined #ruby
QualityAddict has joined #ruby
<speakingcode>
nope, never heard of either of them. so it's an rvm issue perhaps?
<Radar>
speakingcode: perhaps
<Ox0dea>
speakingcode: Which extension failed to build?
<Gasher>
hello
* Ox0dea
bets on OpenSSL.
<Gasher>
I have a questions about erb - how do you do things like "==yield" or "include" in there? so you have things like head and navbar shared across pages?
jdawgaz has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
uglybandersnatch has quit [Ping timeout: 244 seconds]
i_luv_radar has joined #ruby
<i_luv_radar>
just me Radar, testing about. Cheers.
<i_luv_radar>
Also, boo
uglybandersnatch has joined #ruby
i_luv_radar has quit [Client Quit]
<Radar>
Gasher: Is this relating to Rails?
stunder has quit [Ping timeout: 246 seconds]
diegoaguilar has joined #ruby
<Gasher>
Radar, any Ruby framework
<Radar>
Gasher: Ok. I don't understand the question.
<Gasher>
and erb is included with ruby, so it's a legit question for this channel
jdawgaz has joined #ruby
<Gasher>
what templating engine did you use Radar ?
<Radar>
ERB.
<Radar>
The code you wrote is not ERB-ish.
<speakingcode>
loks like it's an openssl issue actually but there's a patch
<Radar>
I don't know what you mean by "== yield"
Ropeney has joined #ruby
jdawgaz has quit [Client Quit]
ur5us has joined #ruby
pawnbox has joined #ruby
<Gasher>
Radar, "==yield" is on Slim
<Radar>
[11:13:43] <Gasher>I have a questions about erb -
<Radar>
[11:19:04] <Gasher>Radar, "==yield" is on Slim
<Radar>
uh huh.
<Radar>
And we still haven't got to the real questions yet.
<Gasher>
I'm asking for the equivelant with erb
<Gasher>
so you have things like head and navbar shared across pages?
<Gasher>
real question, there were 2 actually
<Radar>
<%= yield %>
<Radar>
I don't know what you mean by "include"
<baweaver>
partials
safe has joined #ruby
FooMunki has quit [Quit: FooMunki]
<speakingcode>
Radar, Ox0dea it was an openssl issue but applying the patch worked, thanks
<Gasher>
yes, exactly, partials
LoneHerm_ has quit [Remote host closed the connection]
<Ox0dea>
speakingcode: Huzzah! Glad you got it sorted.
<rehat>
is there a way to trigger a ruby script with erb? Like user enters something in a textfield and when they press submit it would trigger a ruby script that would reload the page. Just running it locally not on a server
<baweaver>
select the running instances, transform it to a list of instance ids, subtract your skip list
sudoubuntu has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
solars has quit [Quit: WeeChat 0.4.2]
solars has joined #ruby
aeterne has quit [Read error: Connection reset by peer]
noService has joined #ruby
Cohedrin_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
benlieb has quit [Quit: benlieb]
Devalo has quit [Remote host closed the connection]
abyx has joined #ruby
Yzguy has quit [Quit: Zzz...]
bronson has joined #ruby
blackms has quit [Ping timeout: 264 seconds]
rkazak has quit [Quit: Sleep.....ing....]
abyx has quit [Client Quit]
noService has quit [Ping timeout: 246 seconds]
ramfjord has quit [Ping timeout: 248 seconds]
uglybandersnatch has quit [Ping timeout: 246 seconds]
pawnbox has quit [Remote host closed the connection]
abyx has joined #ruby
pawnbox has joined #ruby
noService has joined #ruby
bronson has quit [Ping timeout: 252 seconds]
uglybandersnatch has joined #ruby
abyx has quit [Client Quit]
uglybandersnatch has quit [Ping timeout: 264 seconds]
nando293921 has quit [Quit: Lost terminal]
mistermo_ has joined #ruby
Aviio has quit [Remote host closed the connection]
nando293921 has joined #ruby
nando293921 has quit [Client Quit]
shmuli has joined #ruby
Ropeney has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
MyMind has quit [Ping timeout: 268 seconds]
nando293921 has joined #ruby
haraoka has joined #ruby
last_staff has joined #ruby
mistermo_ has quit [Ping timeout: 248 seconds]
tvw has joined #ruby
tvw has quit [Client Quit]
tvw has joined #ruby
nando293921 has quit [Read error: Connection reset by peer]
nando293921 has joined #ruby
andikr has joined #ruby
CausaMortis has joined #ruby
AnoHito_ has joined #ruby
kollex has joined #ruby
bigkevmcd has joined #ruby
polysics has joined #ruby
polysics has quit [Remote host closed the connection]
polysics has joined #ruby
CausaMortis_ has joined #ruby
IrishGringo has quit [Ping timeout: 246 seconds]
AnoHito has quit [Ping timeout: 252 seconds]
chouhoulis has joined #ruby
CausaMortis has quit [Ping timeout: 260 seconds]
Eiam_ has joined #ruby
ur5us has joined #ruby
benlovell has joined #ruby
chouhoulis has quit [Ping timeout: 250 seconds]
edwinvdgraaf has quit [Remote host closed the connection]
Xeago has joined #ruby
ur5us has quit [Remote host closed the connection]
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #ruby
nanoz has quit [Ping timeout: 276 seconds]
choke has joined #ruby
vikaton has quit [Quit: Connection closed for inactivity]
qhp has joined #ruby
nando293921 has quit [Quit: Lost terminal]
jackjackdripper has joined #ruby
Xeago has quit [Ping timeout: 244 seconds]
nando293921 has joined #ruby
benlovell has quit [Ping timeout: 276 seconds]
<norc>
Hi, I have written a small module that brings AR association semantics to regular classes (providing for #foo, #foo=, #foo_id, #foo_id= accessor methods). I seem to have found myself in a circlejerk for writing specs for this.
sandstrom has joined #ruby
<norc>
I cannot sensibly test a reader without invoking a writer or the other way around.
<apeiros>
then don't. test them in tandem.
<apeiros>
unless you want to do whitebox testing. then you can test it by using rubys reflection capabilities.
djbkd has joined #ruby
johnbat26 has joined #ruby
nikger has joined #ruby
sergey_makagon has joined #ruby
CausaMortis_ is now known as CausaMortis
choke has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
DoubleMalt has joined #ruby
claw has joined #ruby
djbkd has quit [Ping timeout: 244 seconds]
biberu has joined #ruby
<norc>
apeiros: Okay guess it makes sense to test them in tandem. Not sure what you meant by testing it by using reflection though.
<apeiros>
I assume the accessor methods change something within the object
ericlee has joined #ruby
<norc>
Indeed. I have some internal hashes to keep track of things and caching.
<apeiros>
and with whitebox-testing, you'd read that internal state. e.g. using instance_variable_get
skade has quit [Quit: Computer has gone to sleep.]
sandstrom has quit [Quit: My computer has gone to sleep.]
ur5us has joined #ruby
claw has joined #ruby
bkxd has quit [Ping timeout: 248 seconds]
AlexJakeGreen has quit [Remote host closed the connection]
Asher has quit [Quit: Leaving.]
baweaver has quit [Remote host closed the connection]
Couch has joined #ruby
claw has quit [Ping timeout: 246 seconds]
dn` has joined #ruby
drewo has quit [Ping timeout: 248 seconds]
terlar has joined #ruby
duncannz has quit [Ping timeout: 260 seconds]
marcdel has quit [Ping timeout: 276 seconds]
claw has joined #ruby
krz has joined #ruby
triangles2 is now known as triangles
harryk has quit [Quit: leaving]
sandstrom has joined #ruby
pandaant has joined #ruby
Xeago has joined #ruby
merida has quit [Remote host closed the connection]
merida has joined #ruby
jt__ has quit [Remote host closed the connection]
nikger has quit [K-Lined]
djbkd has joined #ruby
mr_oh has joined #ruby
dn` has quit [Quit: dn`]
vondruch has joined #ruby
dc4 has joined #ruby
duckpuppy has joined #ruby
mrgrieves has joined #ruby
<mr_oh>
:(
ur5us has quit [Remote host closed the connection]
<Ox0dea>
You broke your screen, innit?
chouhoulis has joined #ruby
noService has quit [Ping timeout: 246 seconds]
duckpuppy has quit [Ping timeout: 268 seconds]
dionysus69 has joined #ruby
Sembei has joined #ruby
sigurding has joined #ruby
<mr_oh>
Screen is good
chouhoulis has quit [Ping timeout: 244 seconds]
hinbody has quit [Ping timeout: 248 seconds]
bkxd has joined #ruby
abyx has joined #ruby
quazimodo has quit [Ping timeout: 244 seconds]
rmulligan has quit [Ping timeout: 246 seconds]
anisha has joined #ruby
ericlee has quit [Ping timeout: 250 seconds]
noService has joined #ruby
<Ox0dea>
And, so, but, then, well, why the 0x5adface?
<norc>
Ox0dea: So ever since I have started writing my own compiler for a subset of C, I began to realise the uglificationess of the MRI lexer/parser...
<norc>
The lexer is pure magic.
<Ox0dea>
norc: But... parser combinators.
<mr_oh>
No one was typing
edwinvdgraaf has joined #ruby
<adaedra>
HELLO
finisherr has quit [Quit: finisherr]
<norc>
Meh.
<norc>
adaedra: I wish you the best of luck fixing your capslock key.
<norc>
Hello on that note.
<adaedra>
Fun fact: my caps lock key produces '\'.
<apeiros>
that's indeed more useful than what it normally does
Xeago has quit [Ping timeout: 248 seconds]
Dreamer3 has quit [Read error: Connection reset by peer]
<norc>
Indeed, it is probably the one key I practically never use on my keyboard. Remapping it to \ might actually be sensible on this damn apple keyboard.
Emmanuel_Chanel has quit [Ping timeout: 276 seconds]
ferr has quit [Quit: WeeChat 1.4]
marr has joined #ruby
Chagel has quit [Ping timeout: 240 seconds]
<norc>
AimlessRaven: I would use the decorator pattern to elegantly solve this.
<norc>
AimlessRaven: Also it is not a wise choice to have any business logic in your views. Make it so that your views get complete collections.
<norc>
As opposed to having sql fragments in your views.
Emmanuel_Chanel has joined #ruby
shmuli has joined #ruby
Spami_ has joined #ruby
<norc>
So in short: Have your controller prepare the collection, ordering it the way you want it, wrap it inside a decorator which then provides some utility method that gives you the index of the pre-selected price.
<AimlessRaven>
norc oks
ruby-lang220 has joined #ruby
<AimlessRaven>
but in code how would be looks like
Spami has quit [Ping timeout: 260 seconds]
rmulligan has joined #ruby
AimlessRaven has quit [Quit: Page closed]
<apeiros>
hm, too late for ?crosspost
Spami has joined #ruby
<apeiros>
they left somebody on #rubyonrails hanging on a follow-up question and instead cross-posted here. pondering to ban.
sepp2k has quit [Ping timeout: 240 seconds]
shmuli has quit [Remote host closed the connection]
Xeago has quit [Remote host closed the connection]
binaryplease1 is now known as binaryplease
<roelof>
chrisjohnson: why not use th gist.github link ?
<chrisjohnson>
i don't like using github becuse i use my real name on there and i don't want people to know me who i am on irc because of security reasons
<roelof>
oke, but the link you use , you first see a lot of advertising and I do not think people will help you
Antiarc_ has quit [Quit: No Ping reply in 180 seconds.]
<roelof>
chrisjohnson: you can also use lpaste or another pastebin
<manveru>
yeah, gave up after it complained about my adblocker :P
QualityAddict has quit [Ping timeout: 246 seconds]
<roelof>
workmad3: expected: "The Bridge over the River Kwai" got: "the Bridge Over the River Kwai"
bronson has quit [Ping timeout: 252 seconds]
<workmad3>
roelof: if you notice, I only addressed the first line, not the second (where you're ensuring word 1 is capitalized)
<workmad3>
roelof: i.e. don't just copy-paste, spend some time understanding
<roelof>
workmad3: the first "the" must be capitalized. the second not
<roelof>
of course, I try to understand
<workmad3>
roelof: then can you see that I didn't write a complete replacement?
<roelof>
the problem is when I have one word like jaws it is already capitalized, so the second do not have to work
<roelof>
I was hoping there is a solution that does not have to work with 2 lines ?
<gregf_>
roelof: what workmad3's suggested is something you can build on?
platzhirsch has quit [Quit: Leaving.]
<gregf_>
presumably they're trying to test your logical abilities and not use of functions/methods?
<roelof>
nope, I do not see how I can capitalize the first "then" but not the second one
<roelof>
I could capitalize the first one but then I have to make a iterate that begins at the second word
<gregf_>
roelof: fair enough. thats logic very *specific* to what you want. perhaps, so that you can get your logic right :)
GriffinHeart has quit [Remote host closed the connection]
<roelof>
both cases I can not find a solution for
<roelof>
each or map looks to start from the beginning
<roelof>
gregf_: so Im stuck in my mind how to handle this :(
rsc___ has quit [Ping timeout: 264 seconds]
<gregf_>
>> str = "the Bridge over the river kwai";ignore_list = [ %r{\s+the}, %r{^[A-Z]} , %r{over} ]; p str.split.map{ |s| ignore_list.select {|i| s =~ i }.size > 0 ? s : s.capitalize }.join(" ") # roelof: run that and go away happy now
<ruby[bot]>
gregf_: # => "The Bridge over The River Kwai" ...check link for more (https://eval.in/546111)
<roelof>
or can I do something like this : answer.slice(0,1).capitalize + answer.slice(1..-1) if word.length > 1 so the second line only works if there are more words
<apeiros>
>> ignore = %w[and over the]; "war and peace".gsub(/(?<!\A)\b(?!#{Regexp.union(ignore)})\w+\b/, &:capitalize) # regex solution - this time with an example where something actually changes
nighttime has quit [Quit: <uptime> >quotes himself in his quit message]
<Ox0dea>
apeiros: The first word didn't get capitalized.
<apeiros>
that's what he wanted, no?
<Ox0dea>
No.
<apeiros>
oh
<Ox0dea>
I think #titleize is supposed to do what it says on the tin. :P
<apeiros>
ah, I see. Misread.
<apeiros>
should not be difficult to update the regex…
<apeiros>
ignore = %w[and over the]; "war and peace".gsub(/\A\w+\b|\b(?!#{Regexp.union(ignore)})\w+\b/, &:capitalize) # and now according to spec :D
<apeiros>
grah
<apeiros>
>> ignore = %w[and over the]; "war and peace".gsub(/\A\w+\b|\b(?!#{Regexp.union(ignore)})\w+\b/, &:capitalize) # and now according to spec :D
<apeiros>
interesting hint regarding the meaning of shoebox…
spiman_ has joined #ruby
tomaz_b has joined #ruby
Devalo has joined #ruby
Xeago has joined #ruby
michael_mbp has joined #ruby
spiman has quit [Ping timeout: 264 seconds]
trinaldi has joined #ruby
freerobby has joined #ruby
Devalo has quit [Ping timeout: 260 seconds]
Gasher has joined #ruby
nfk has quit [Quit: Try memory.free_dirty_pages=true in about:config]
tvw has joined #ruby
krobzaur has quit [Ping timeout: 260 seconds]
merida has quit [Remote host closed the connection]
ldnunes has joined #ruby
tildes has quit [Remote host closed the connection]
hk238 has joined #ruby
but3k4 has joined #ruby
but3k4 has quit [Read error: Connection reset by peer]
y0da has joined #ruby
duckpuppy has joined #ruby
chrisco has joined #ruby
yfeldblum has quit [Ping timeout: 268 seconds]
_blizzy_ has quit [Quit: Leaving]
Chagel has joined #ruby
duckpuppy has quit [Ping timeout: 244 seconds]
madgen has quit [Ping timeout: 244 seconds]
krz has joined #ruby
SHyx0rmZ has joined #ruby
chouhoulis has joined #ruby
al2o3-cr has quit [Ping timeout: 276 seconds]
Snowy has quit [Remote host closed the connection]
krz has quit [Ping timeout: 246 seconds]
chrisco has quit []
joonty has quit [Ping timeout: 244 seconds]
rodferso1 has joined #ruby
Dysp has joined #ruby
chouhoulis has quit [Ping timeout: 264 seconds]
quazimodo has quit [Ping timeout: 260 seconds]
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
webus has quit [Quit: Ухожу я от вас (xchat 2.4.5 или старше)]
quazimodo has joined #ruby
<Dysp>
Hello lovely people! I have an array and I want to remove any element being below 2,5 % of X value. I do this by the following array.delete_if {|x| x >= value}
<Dysp>
Works fine!
<Ox0dea>
apeiros: You nerd-sniped me. I tried to do every single combination, but it'd've taken ages. The longest alternator is "UnPoRoUsNeSs".
<Dysp>
However, how would I approach only assessing the first 50% of the array?
Es0teric has quit [Ping timeout: 248 seconds]
<apeiros>
Dysp: array.first(array.size/2)
<Dysp>
I guess I could create a new array with the first 50% and simply do it there and then put it back together, but is there an easier way?
sdothum has joined #ruby
<apeiros>
Ox0dea: I did what now?
<Dysp>
apeiros: The myth. The legend.
<apeiros>
legendary myth
<Ox0dea>
apeiros: The shoebox thing.
<Dysp>
array.first(array.size/2).delete_if {|x| x >= value}
<Dysp>
Would that do?
<Ox0dea>
I started to find all the word pairs hidden in larger words, but I have a massive dictionary.
haraoka has quit [Ping timeout: 276 seconds]
rodfersou has quit [Ping timeout: 268 seconds]
<apeiros>
Dysp: depends on whether I understood you correctly.
<apeiros>
Ox0dea: what does "upruns" mean?
pawnbox has quit [Remote host closed the connection]
<Dysp>
I only want to run the "delete_if" on the first 50% of the array.
<Ox0dea>
apeiros: Wiktionary says "uprun" is synonymous with "ascend".
<Ox0dea>
¯\_(ツ)_/¯
<apeiros>
Ox0dea: interesting. online translator doesn't know the word :)
<Ox0dea>
Dysp: And the problem is that #delete_if modifies the Array in-place, yes?
pawnbox has joined #ruby
<Dysp>
No, that's fine. I want a new array.
Es0teric has joined #ruby
<Dysp>
Or. A modified array
<apeiros>
oh, is delete_if == select! ?
<Dysp>
I simply do only want to run the delete_if on the first part of the array.
<apeiros>
I thought it'd be == select
<apeiros>
errr, reject
pietr0 has quit [Ping timeout: 246 seconds]
<Dysp>
You are confusing me :D
<rahc>
I want to find out what code is modifying a particular array
<Dysp>
I mean; I could split the array, run the delete_if and then connect it again. But I would hope there would be an easier way.
<apeiros>
rahc: freeze it and watch the explosion
<rahc>
I've tried using byebug's "display" command but it doesn't watch the actual object, it simply evaluates a context-dependent variable name on each frame
<apeiros>
Dysp: ah yes, the given solution does that
<rahc>
apeiros: what do you mean?
<Dysp>
apeiros: This? array.first(array.size/2).delete_if {|x| x >= value}
<apeiros>
rahc: call .freeze on it. when something tries to modify it, it'll raise an exception. the exception tells you where it has been modified.
<rahc>
apeiros: I see
roelof has quit [Ping timeout: 250 seconds]
<apeiros>
Dysp: yes
whippythellama has quit [Ping timeout: 248 seconds]
<rahc>
apeiros: that doesn't help me though because I need to see each invocation
<rahc>
s/invocation/modification/
<Dysp>
I had an error. Because I forgot to put in a value. I'm not a clever man, apeiros .
Ropeney has quit [Remote host closed the connection]
<rahc>
apeiros: how can I do that?
sudoubuntu has joined #ruby
<apeiros>
wrap it in a proxy object and log access
<rahc>
apeiros: do you know how I can do that?
<rahc>
apeiros: a proxy object for an array is going to be pretty extensive, no?
<rahc>
apeiros: do you know of such a proxy object?
<apeiros>
SimpleDelegator & co might work. It's easy to write one yourself, though.
pawnbox has quit [Remote host closed the connection]
<Ox0dea>
>> a = [*1..10]; a.reject!.with_index { |e, i| i < a.size / 2 && e > 2 }; a # Dysp
<Ox0dea>
But that's wasteful since it'll still go through the whole collection.
<apeiros>
Ox0dea: my premature optimization bone itches
Chagel has quit [Ping timeout: 276 seconds]
<Dysp>
Don't tickle that bone, Ox0dea!
<Dysp>
:D
<Ox0dea>
Huehuehue.
vale_tudo has joined #ruby
uglybandersnatch has joined #ruby
<Ox0dea>
This is one of those times where it'd be nice if #slice returned a reference.
<Ox0dea>
ary[0, ary.size / 2].reject! { ... }
bluOxigen_ has joined #ruby
volCat has joined #ruby
joonty has joined #ruby
<apeiros>
while it does return a reference, it's COW :)
duckpuppy has joined #ruby
bluOxigen has quit [Ping timeout: 246 seconds]
Ropeney has joined #ruby
<Ox0dea>
Right, right.
norc has quit [Ping timeout: 250 seconds]
Vile` has joined #ruby
last_staff has quit [Quit: last_staff]
uglybandersnatch has quit [Ping timeout: 244 seconds]
Digpig has quit [Quit: Konversation terminated!]
<Cork>
anyone know how to convert UTF-8 to 3 byte UTF-8 in ruby? (mysql string)
Yiota has joined #ruby
<apeiros>
aaahahaha
<apeiros>
sorry
<adaedra>
you don't have to do that.
<adaedra>
mysql will just reject your unencodable characters.
<adaedra>
(iirc)
<apeiros>
the question sounded like they think those could be "translated", though
<Cork>
adaedra: ya, it rejects the entire insert string
<adaedra>
mysql utf-8 is just a less-capable utf-8
<Cork>
ActiveRecord::StatementInvalid (Mysql2::Error: Incorrect string value: '\xF0\x9F\x98\x84\x0D\x0A...' for column 'body' at row 1: INSERT INTO
<Cork>
"e
<apeiros>
iirc those longer sequences are beyond codepoint 2**32-1, so you could probably .unpack("U*").reject { |cp| cp >= 2**32 }.pack("U*")
<apeiros>
alternatively read the WP page on unicode and write the proper regex. should not be hard.
whippythellama has joined #ruby
<Cork>
hmm let me give it a try
<Cork>
thx for the help!
<adaedra>
Next time, go utf8mb4
<apeiros>
sequence start is iirc fixed and unambiguous, no matter which byte you look at
Zai00 has quit [Quit: Zai00]
<Cork>
adaedra: ya, i was trying
<Cork>
but the mysql client in debian doesn't support > utf8
<Cork>
Mysql2::Error (Can't initialize character set utf16 (path: /usr/share/mysql/charsets/)):
<Cork>
(same for utf8mb4)
andywojo has joined #ruby
GodFather has joined #ruby
baweaver has joined #ruby
pietr0 has joined #ruby
<Cork>
adaedra: had to change it to .unpack("U*").reject { |cp| cp >= 2**16 }.pack("U*") for it to work but ya
<Dysp>
apeiros: Hm. What seems to happen is that array.first(array.size/2).delete_if {|x| x >= value} indeed scans the first 50% of the array and deletes any element >= value. However the second half of the array is also deleted.
<Dysp>
Could you confirm this?
CloCkWeRX has joined #ruby
<apeiros>
Dysp: yes, I thought that was obvious.
gregf has quit [Quit: WeeChat 1.4]
<apeiros>
after array.first(array.size/2) you only have the first half of the array.
<Dysp>
Nothing is obvious to me in programming yet, apeiros ;)
bronson has joined #ruby
<Dysp>
My own idea for a solution would be to split the array up and then put it back together, but could you propose a more elegant solution?`
baweaver has quit [Ping timeout: 248 seconds]
sudoubuntu has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<apeiros>
no. as I said before, my solution simply implements (a part of) your solution
bronson has quit [Ping timeout: 244 seconds]
<Dysp>
Alrighty. I'll get it to work. Thanks for your help as always.
al2o3-cr has joined #ruby
swills_ has quit [Remote host closed the connection]
bkxd has joined #ruby
sudoubuntu has joined #ruby
rsc___ has quit [Quit: rsc___]
whippythellama has quit [Ping timeout: 248 seconds]
Zai00 has joined #ruby
nfk|laptop has joined #ruby
madgen has joined #ruby
y0da has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<apeiros>
Dysp: doesn't matter much, what matters is that you see how it's used and that it's a generic solution for all destructive methods :D
<Dysp>
Generic solution for destructive methods? I'm so sorry, I actually don't understand the discourse
<Dysp>
:|
<Dysp>
It's hard being new.
pawnbox has quit [Remote host closed the connection]
<apeiros>
a destructive/mutating/in-place method is a method which modifies an object
<apeiros>
select!, reject!, gsub! etc. do that
<apeiros>
many of them have a non-destructive counterpart, which does not modify the object, but returns a copy with the changes applied there.
<apeiros>
select, reject, gsub etc. would be the counterparts to those named above
<apeiros>
and my solution lets you apply any destructive method to only a slice of the array
blackjid has quit [Excess Flood]
millerti has joined #ruby
<Dysp>
Ah. So you mean that destructive methods deletes an object to create a new one, whereas the counterparts lets the other stay, but returns a new object too?
tpendragon has quit [Ping timeout: 248 seconds]
<apeiros>
no, it does not delete an object. it modifies an object.
IrishGringo has joined #ruby
<apeiros>
>> a = [1,2,3]; a.reject! { |x| x.odd? }; a
<Dysp>
I understand that .reject! would modify (remove) the odd numbers in the array.
<apeiros>
brb, reboot
<Dysp>
I honestly do not understand what .reject does.
<jaroslav>
it creates a new object
<apeiros>
Dysp: run the code in pry, check the return value of both
<djellemah>
Dysp: gives you back a new array without the odd numbers
<jaroslav>
leaving original one as is
<apeiros>
also run it where no change happens and check the return values
Madplatypus has quit [Quit: Connection closed for inactivity]
<Dysp>
So, reject: X.reject => X + X2
<Dysp>
And reject!: X.reject! => X'
<Dysp>
?
<apeiros>
Dysp: I don't think that notation helps anybody
Vile` has quit [Ping timeout: 252 seconds]
<Dysp>
Don't see it as code
<Dysp>
Analogy
<apeiros>
yes, but it doesn't help if you have to explain your analogy first
<Dysp>
Haha, you have a point there, good sir.
<Dysp>
So. x.reject leaves me with two arrays. The original one and a new one? Reject! modifies the original one to create a new one with the applied method?
chouhoulis has quit [Ping timeout: 260 seconds]
jas02 has joined #ruby
blackjid has joined #ruby
wlanboy has quit [Ping timeout: 276 seconds]
<djellemah>
Dysp: you've got reject now, and almost there with reject!
aupadhye is now known as aupadhye|call
pawnbox has quit [Ping timeout: 276 seconds]
<Dysp>
HAha :D
tpendragon has joined #ruby
<Dysp>
So, Reject! modifies the original one with the applied method?
<djellemah>
yes
<Dysp>
Hereuka!
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<djellemah>
\o/
quazimodo has quit [Ping timeout: 276 seconds]
<Dysp>
Then one question remains in my mind; if I get two arrays from .reject, what is second one called?
<Dysp>
the*
<apeiros>
Dysp: one part omitted - check the return value of reject!, once when it does change something, and once when it doesn't
<apeiros>
elzid: where do you think a symbol is being mutated there?
marr has quit [Ping timeout: 276 seconds]
<elzid>
aperios: I would've thought that the if else blocks are checking to see if the options have been passed to the script and then either uses predefined default or assigns a value?
BSaboia has joined #ruby
<elzid>
unless the actual assignment isn't happening there...
AlexJakeGreen has joined #ruby
<apeiros>
?tabnick elzid
<ruby[bot]>
elzid: pro-tip - use tab completion for nicks. avoids typos in nicks.
Rixius has joined #ruby
<elzid>
apeiros: great thanks!
<apeiros>
elzid: you're referring to line 18-22?
rippa has joined #ruby
mostlybadfly has quit [Quit: Connection closed for inactivity]
<elzid>
apeiros: yes
kobain has quit [Ping timeout: 260 seconds]
<elzid>
ok, it's setting a hash I suppose but why is a symbol being used as the key?
<elzid>
and when does it become immutable?
<apeiros>
the block is only invoked when the option is present. but I guess it can be invoked multiple times. but again, where is it mutating a symbol there?
<apeiros>
a symbol is always immutable. it does not become immutable.
al2o3-cr has quit [Ping timeout: 248 seconds]
<apeiros>
and a symbol is used as a key because that's something it's good at.
nando293921 has joined #ruby
Rixius has quit [Ping timeout: 248 seconds]
<elzid>
apeiros: ok, am I right in thinking that the :symbol itself holds no value, rather it's only used as a key to a value, which is being reset depending on whether the option is present or not? Say the option is present, the @options hash already has that symbol set to a default value, how can it then set a different value. Unless my first sentence here is correct...
<apeiros>
:symbol holds a value - itself
<elzid>
apeiros: and that's not changing, so it's ok right?
<apeiros>
but I think you're confusing the hash and its key
jaruga_ has quit [Quit: jaruga_]
<apeiros>
the only thing which is mutated there is the options hash. and that's - as said - a hash, which is mutable.
<apeiros>
setting a value in a hash does in no way mutate the key - why would it?
<elzid>
apeiros: precisely - that's where I got lost - I've not come across :symbols in anywhere else and when I found it in ruby, I was a little lost and then I tried to look for examples and found this. Confused myself. Many thanks for your help indeed.
<apeiros>
would you have the same issues understanding what's going on if the keys where strings? would you think the strings are being mutated when assigning a value to the hash?
<apeiros>
*were
<elzid>
apeiros: not at all
bkxd has joined #ruby
<elzid>
it's the :symbol concept that done me!
<apeiros>
you have to separate that. it's unrelated.
triangles has joined #ruby
<apeiros>
you can use any object as a key in a hash.
<apeiros>
and none is mutated by being used as a key.
<apeiros>
and the :symbol concept is just a convenient way to have a "named number".
GitGud has joined #ruby
<elzid>
apeiros: and the benefit of using a :symbol as hash key is because it's always the same underlying object and therefore more memory efficient?
<apeiros>
that's one aspect. the other is that being a number makes comparison very fast.
<elzid>
apeiros: ah yes, it has a string and number representation
<apeiros>
yeah. the string is for us puny meatbags.
madgen has quit [Ping timeout: 276 seconds]
lkba has joined #ruby
<elzid>
apeiros: cool
skade has joined #ruby
<elzid>
thank you
madgen has joined #ruby
<apeiros>
last but not least - everything with a name in ruby has that name identified by a symbol
aganov has quit [Ping timeout: 248 seconds]
bkxd has quit [Ping timeout: 246 seconds]
bronson has joined #ruby
joneshf-laptop has joined #ruby
<elzid>
apeiros: "everything with a name"?
Yiota has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
tubuliferous_ has joined #ruby
<apeiros>
methods, local variables, instance variables, class variables, globals, …
Snowy has quit [Remote host closed the connection]
zast has joined #ruby
bkxd has joined #ruby
parduse has joined #ruby
pagios has joined #ruby
pagios has left #ruby ["Leaving"]
pagios has joined #ruby
tubuliferous_ has quit [Read error: Connection reset by peer]
<pagios>
hello, i have a field that reads a date in utc format, i would like to create a query to select the dates that happen to be a friday, what is the best way to do it thanks.
idle_task has joined #ruby
Silox| has joined #ruby
idletask has quit [Ping timeout: 260 seconds]
<apeiros>
pagios: the question as asked feels a bit like "please do it for me". to avoid that, please, show us what you've tried so far.
<pagios>
apeiros, i tried .where (date.wday == 5)
<apeiros>
ok, so we're indeed talking about activerecord
<pagios>
yep
<apeiros>
that'd be #rubyonrails. but what you have to do: instead of date.wday == 5, write that part as SQL. i.e. find your db's sql docs, and in there the appropriate date functions.
bkxd has quit [Ping timeout: 244 seconds]
Xeago has quit [Read error: Connection reset by peer]
stannard has joined #ruby
speakingcode has quit [Ping timeout: 268 seconds]
saneax is now known as saneax_AFK
machinewar has joined #ruby
<machinewar>
is there a way to parse a csv string line by line? I know I could open a csv file and call readline
<machinewar>
but I have a string and want to parse it line by line without using a block because some lines might have encoding issues
<apeiros>
machinewar: check CSV lib's docs.
<apeiros>
and yes, there is a way.
<apeiros>
ah, a string
hxegon has joined #ruby
<machinewar>
apeiros: currently looking in there
<machinewar>
yeah
grill has joined #ruby
<machinewar>
its already been opened from a file
<apeiros>
StringIO might work
skweek has joined #ruby
<machinewar>
apeiros: okay will check thanks
<apeiros>
though why'd you parse it line by line if you have it already in memory?
<apeiros>
ah
* apeiros
should learn to read
<pagios>
apeiros, i didnt get it
<machinewar>
ahh maybe StringIO#each_line and pass that to CSV#parse_line
<apeiros>
machinewar: no
tomaz_b has quit [Ping timeout: 276 seconds]
<apeiros>
a csv record can contain a newline
<apeiros>
otherwise I'd have told you to use string.each_line
<pagios>
apeiros, where('extract(day from date_column) = ?', desired_day_of_month)
Snowy has joined #ruby
<apeiros>
pagios: looks like the right direction. but you wanted day_of_week, no?
solars has quit [Ping timeout: 244 seconds]
DTZUZU has quit [Ping timeout: 244 seconds]
Xiti has joined #ruby
<apeiros>
don't know about the sql function, since you failed to mention the db you use…
<apeiros>
?crosspost pagios
<ruby[bot]>
pagios: Please do not crosspost without at least telling so and mentioning provided suggestions and their outcome in all channels. Experience shows that people don't do either, and not doing so is considered rude.
<apeiros>
count me out on this question.
nobitanobi has quit [Remote host closed the connection]
<imperator>
but, confused why i can still connect without enabling SSL or using an https string
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
nobitanobi has joined #ruby
karioleez has quit []
sdothum has joined #ruby
<imperator>
e.g. this works: "curl -x localhost:8080 -U admin:passxxx123 http://www.google.com", but i would have expected the --ssl option to be required
Yiota has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pagios has left #ruby ["Leaving"]
hiyosi has joined #ruby
RegulationD has joined #ruby
nando293921 has quit [Ping timeout: 250 seconds]
Zai00 has quit [Read error: Connection reset by peer]
Donkoko has joined #ruby
RegulationD has quit [Ping timeout: 244 seconds]
Snowy has quit [Remote host closed the connection]
Zai00 has joined #ruby
<djellemah>
imperator: looks like HTTPProxyServer.new just ignores options it doesn't recognise, including SSLEnable.
Macaveli_ has joined #ruby
kies has joined #ruby
dvinciguerra__ has quit [Ping timeout: 244 seconds]
<norc>
apeiros, Im close to pulling my hair out. It seems that aroea (activerecord-oracle_enhanced-adapter) is quite easy to break when you have it generate WHERE xxx IN (...) fragments with lists over 1000 entries. How do you deal with these random bugs..
<norc>
Or the recent bug where the adapter randomly drops connection...
bronson has quit [Remote host closed the connection]
Zai00 has quit [Read error: Connection reset by peer]
RTG` has quit [Ping timeout: 248 seconds]
<norc>
havenwood, wtf...
<norc>
I mean I get it, but that is a bit silly.
bronson has joined #ruby
<imperator>
ah, april 1st, i should just stay offline today
<havenwood>
norc: yeah, when perfectly good emoji are available: 0️⃣1️⃣2️⃣
<shevy>
imperator lol
<shevy>
imperator I almost fell for another suggestion
symm- has joined #ruby
tildes has joined #ruby
<shevy>
but since I saw nobu and dürst tag-team along with jokes just like 10 minutes ago, I was more prepared for the one above just now
helpa has quit [Remote host closed the connection]
fexilal has left #ruby [#ruby]
helpa has joined #ruby
<shevy>
We need endddd
Zai00 has joined #ruby
Suntzu has quit [Read error: Connection reset by peer]
<havenwood>
en_fin
* imperator
is guilty of this sort of stuff, too, but hasn't done it for many years
roelof has joined #ruby
Xeago has joined #ruby
<hanmac>
i hate the april ... i feel so trolled by the weather :/ yesterday it was warn outside, today it was snowing oO
<norc>
We had the funniest and weirdest announcement today, with the most unlikely change of department heads - sad thing is its not an april fools joke. :-(
<norc>
roelof, implement the === operator for the relevant, that is what case uses under the hood
pandaant has quit [Remote host closed the connection]
<norc>
*for the relevant class.
hxegon has quit [Quit: BRB]
<roelof>
norc: so I have to use the == for a case
<norc>
roelof, no.
RegulationD has joined #ruby
<roelof>
sorry, the === is what you talk about
<roelof>
I was hoping I could use a case instead of a big nested if then
Xeago has quit [Remote host closed the connection]
<shevy>
hanmac really snowing??? it was hot here too yesterday, today it is cloudy and a bit rainy... but no snow
<roelof>
norc: so I have to make my custom === function ?
mistermocha has joined #ruby
<norc>
roelof, nevermind, I wasnt really looking at your code when I made that remark.
hxegon has joined #ruby
<roelof>
here it is sunny and some 16 degrees ( The Netherlands
<hanmac>
shevy: it was at morning around 4-9am, now its warm again
dipnlik has joined #ruby
skweek has quit [Ping timeout: 260 seconds]
hxegon has quit [Client Quit]
<roelof>
norc: oke, np
threh has joined #ruby
loc22 has joined #ruby
loc22 has quit [Remote host closed the connection]
<roelof>
someone else who can help me ?
<norc>
roelof, case sends the === method to woord, passing the the result of each expression in "when exp" and stopping when it yields a truey result
volCat has quit [Quit: Leaving]
loc22 has joined #ruby
<norc>
roelof, do not use case here, its not what you think it is. ;-)\
aegis3121 has quit [Ping timeout: 248 seconds]
tjohnson has joined #ruby
<roelof>
oke, what can I do then the best. I use a big if then and that looks not good
<norc>
In your case it would constantly check whether word === true or word === false which is probably not what you meant.
B1n4r10 has joined #ruby
<dipnlik>
hi all. i have a few rails apps that are still running in ruby 2.0.0, any upgrade tips/tutorials are welcome. should I go straight to 2.3? anything special I should look for?
albercuba has joined #ruby
freerobby has quit [Quit: Leaving.]
andikr has joined #ruby
<norc>
?rubyonrails dipnlik
<ruby[bot]>
norc: I don't know anything about rubyonrails
<roelof>
norc: so a lot of if then's would be better /
<norc>
?rails dipnlik
<ruby[bot]>
dipnlik: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
<roelof>
?
<albercuba>
hello everyone, why if I run apt-get install ruby2.0 it installs ruby1.9.1 and sets it as default
<albercuba>
?
<albercuba>
ruby -v
freerobby has joined #ruby
baweaver has quit [Remote host closed the connection]
<norc>
roelof, probably not. Im trying to figure out what you are trying to do, i.e. what your "translation" is trying to do.
joonty has quit [Ping timeout: 244 seconds]
<norc>
albercuba, the plain ubuntu way would be: sudo update-alternatives --config ruby
<albercuba>
norc ok i am going to try that
<albercuba>
thanks
last_staff has quit [Quit: last_staff]
<norc>
albercuba, note that most people here do not use repo supplied ruby though, as ruby-install with chruby offers the most up-to-date versions while easily managing multiple verisons.
<dipnlik>
norc: thought asking here was more appropriate but will try there too, thanks
<apeiros>
norc: where possible: manually create subqueries. in many cases that can be done by simply having an ARRelation in the where clause
bkxd has joined #ruby
<apeiros>
norc: where not possible, we do batches
<norc>
albercuba, if you make changes to your bash the changes will not persist. You have to add those to your .bash_profile (or .bashrc)
<apeiros>
and yes, it's annoying to no end
<darix>
albercuba: you could try update-alternatives --config ruby
jolts has joined #ruby
<darix>
and configure it to ruby 2
<albercuba>
darix, i get update-alternatives: error: no alternatives for ruby
<apeiros>
but I'm really looking forward to mssql which I've been informed is catastrophic with subqueries :D
ferr has quit [Quit: WeeChat 1.4]
hxegon has joined #ruby
ncopa has joined #ruby
ChiefAle_ has joined #ruby
<ncopa>
hi is the the channel for discussing bugs in ruby itself?
<norc>
apeiros, well in all fairness, its not as much the databases, as it is the fact that only few people use oracle or mssql, so there are not many people actively contributing.
<havenwood>
MySQL announced they're self-deprecating in favor of DBM, so might as well just use DBM.
ChiefAlexander has quit [Ping timeout: 240 seconds]
<apeiros>
havenwood: mssql, not mysql
<havenwood>
ncopa: It's for Ruby! (Bugs and all.)
SCHAAP137 has quit [Remote host closed the connection]
<norc>
ncopa, sure, you have come to the right place.
<havenwood>
apeiros: Oooh! :)
<apeiros>
I'm not quite sure which of the two I find worse, though
<havenwood>
hehe
<albercuba>
It is amazing ahving this problem in an LTS
pawnbox has quit [Remote host closed the connection]
<roelof>
havenwood: yes, words for me is the same as a sentence where woord is the Dutch word for word
<havenwood>
roelof: nice
<ncopa>
norc: thanks!
<roelof>
Later it must be working on more then 1 word
<norc>
ncopa, be prepared for a hell of the worst undocumented string manipulation library you have ever seen.
<norc>
You have been warned.
<norc>
We will see if you still thank me if you come back...
<roelof>
havenwood: maybe I can better name words -> sentence and woord -> word ?
<ncopa>
We will see if i come back at all...
x77686d has joined #ruby
<ncopa>
:)
<havenwood>
roelof: Did you try it out in irb/pry yet?
stunder has joined #ruby
<roelof>
but then it looks like the function only works on sentences where it also works on a single word
<roelof>
yep, this case is working
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<roelof>
I use irb , pry I did not learned to use yet
<norc>
roelof, be careful. Once you try out pry you will never use irb again.
<roelof>
hmm, maybe I can better use *words so it's clear it can work on one or more words ?
millerti has joined #ruby
<havenwood>
?pry
<ruby[bot]>
Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
skade has quit [Quit: Computer has gone to sleep.]
Yiota has joined #ruby
whippythellama has joined #ruby
<roelof>
wierd, I see a 404 error on that page about pry
<havenwood>
roelof: Check non-vowel words.
Suntzu has joined #ruby
<roelof>
that is the next step
<apeiros>
should we have ?irb -> irb, the better pry, …
<adaedra>
lel.
skweek has joined #ruby
aufi has quit [Quit: Konversation terminated!]
freerobby has quit [Quit: Leaving.]
<adaedra>
?irb
<ruby[bot]>
irb is "interactive ruby", it is part of ruby. You can run ruby code and see results immediately. it's useful for testing code. Also see ?pry, a gem which is a popular alternative to irb.
<grill>
what exactly does this line do, assuming flags['file-list'] is an array, and build_differ.changed_files is a hash? flags['file-list'] ||= []).concat(build_differ.changed_files)
baweaver has joined #ruby
<norc>
grill, ||= is a conditional assign, that assigns to the left side if its either nil or not declared
<apeiros>
grill: it should raise
<apeiros>
grill: but I'd bet changed_files isn't a hash
<roelof>
havenwood : line 3 is supposed to work on a vowel and line4 on a non-vowel word
<havenwood>
roelof: Yet line 4 is what is always returned.
<apeiros>
asm>> A ||= 1
<norc>
havenwood, a = a || 1 would not either.
<ruby[bot]>
apeiros: I have disassembled your code, the result is at https://eval.in/546397
<havenwood>
roelof: Line three is swallowed into the abyss.
<havenwood>
roelof: yeah huh
<havenwood>
norc: ^
<havenwood>
norc: a is assigned to a there
<roelof>
sorry , I do not understand what you mean
<roelof>
havenwood: ^^
<Donkoko>
Anyone has an idea why when we render our rails app within Facebook canvas the session gets destroyed and we get logged out, even tho we are still logged in, in another tab? Seems like the cookie is conflicting somehow with FB but cant figure out why and how.
<havenwood>
i guess this is nicer: (a = a).send(a.inspect<<??)
<norc>
havenwood, I would have expected that to yield false actually...
<norc>
Im wondering whether that might even be a bug.
<norc>
Oh wait, nevermind wrong thinking all good.
<norc>
havenwood, I just dislike the inspect there. Its giving away too much.
al2o3-cr has quit [Ping timeout: 276 seconds]
<norc>
>> !!??
<ruby[bot]>
norc: # => /tmp/execpad-b512a4d4c15a/source-b512a4d4c15a:2: warning: string literal in condition ...check link for more (https://eval.in/546412)
<roelof>
what is the best alternative for this structure : if then elsif if then else elsif and so on ?
<havenwood>
norc: how about that ^ :)
<norc>
roelof, generally case.. it just didnt fit your original problem.
CausaMortis has quit [Ping timeout: 260 seconds]
<norc>
havenwood, think I prefer the !!??
<roelof>
oke, how do I then make a case which checks for vowels, non-vowels and multiple non-vowels at the beginning norc ?
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<havenwood>
depends on the goal i suppose
<norc>
>> _=_???:!!??
<ruby[bot]>
norc: # => /tmp/execpad-4dcf1396f587/source-4dcf1396f587:2: syntax error, unexpected ':', expecting keyword_end ...check link for more (https://eval.in/546416)
<norc>
something along those lines.
<norc>
okay.. why isnt that parsing?
bratchley has left #ruby [#ruby]
<norc>
roelof, you could do the following. Build a comparator class which defines the method === and accept a symbol as a parameter which could be :vowel :non_vowel :multiple_non_vowel and does its logic there.
<norc>
like
diegoaguilar has joined #ruby
stantona has quit [Ping timeout: 248 seconds]
pawnbox has joined #ruby
<norc>
roelof, MyComparator = Struct.new(word) { def ===(sym) case(sym) when :vowel then (exp) else raise UnknownSymbol end; end }
<norc>
where exp does the actual test and returns with false or true depending on whether it has say a single vowel
bronson has quit [Remote host closed the connection]
<norc>
aspiers, it is an elegant way of modifying classes you dont own with a greatly reduced chance of breaking things in the long run.
edwinvdgraaf has quit [Ping timeout: 248 seconds]
<aspiers>
oh, that's awesome
<norc>
(Though formally modifying classes you dont own is not elegant in the first place)
Balzrael has joined #ruby
<aspiers>
I'm not sure I agree 100% with that last statement
<apeiros>
norc: but that's the point of refinements - you don't modify the class
<norc>
apeiros, duck typing, its effectively the same.
n008f4g_ has quit [Ping timeout: 260 seconds]
<apeiros>
norc: no
howdoi has quit [Quit: Connection closed for inactivity]
<apeiros>
norc: even with duck typing, it's still global
xue has joined #ruby
<apeiros>
refinements are lexically scoped
<apeiros>
and that's what makes them more robust for their intended purpose than other solutions
KensoDev has joined #ruby
<norc>
apeiros, had that discussion with someone else the other day. Usually when people modify foreign classes, subclassing is the better solution.
<apeiros>
I disagree
_blizzy_ has joined #ruby
<apeiros>
subclassing classes you don't own is a bad idea
<apeiros>
stuff you don't own -> composition over inheritance
stunder has quit [Ping timeout: 246 seconds]
<apeiros>
but refinements are IMO playing in a different area
BLuEGoD has quit [Ping timeout: 260 seconds]
ascarter has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
cdg has joined #ruby
<yxhuvud>
apeiros: there are people that actually use refinements?
<apeiros>
I'd assume so. I myself only started playing with it. and only recently. so I still haven't fully made up my mind.
blackjid has quit [Max SendQ exceeded]
<norc>
yxhuvud, the main place where I use them to a great extend is my rails projects where I make all kinds of modifications to some of the core classes of ActiveRecord and ActiveSupport.
<apeiros>
one short-coming I found with them was that it's hard to provide a way to do multiple separate refinements in a single go
baweaver has joined #ruby
blackjid has joined #ruby
rkazak has quit [Ping timeout: 244 seconds]
<norc>
asm>> a = "foo"; puts a
<ruby[bot]>
norc: I have disassembled your code, the result is at https://eval.in/546437
zeroDivisible has quit [Ping timeout: 246 seconds]
B1n4r10 has quit [Ping timeout: 244 seconds]
<apeiros>
by that I mean: think of something of the scope of ActiveSupport - if you have to pull in each atomic refinement on its own then your code starts with 200 lines of "using …"
ascarter has joined #ruby
<norc>
asm>> puts "#{""}"
<apeiros>
it'd be nice to allow a way to enable "using ActiveSupport::All"
<ruby[bot]>
norc: I have disassembled your code, the result is at https://eval.in/546438
machinewar has quit []
<apeiros>
(in whichever way)
B1n4r10 has joined #ruby
element_zer0 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
hightower3 has joined #ruby
dopie has joined #ruby
benlieb has joined #ruby
pawnbox has joined #ruby
loc22 has joined #ruby
<norc>
apeiros, you could easily do that by providing a wrapper module and using the included hook no?
xblade has joined #ruby
nobitanobi has quit [Remote host closed the connection]
<apeiros>
norc: not sure that way would work. I do have a solution, though. but it'd be nice if there was a native solution.
<apeiros>
my solution requires you to intercept the block evaluated in the refinement
<adaedra>
seems like _whitelogger doesn't like emoji.
rbennacer has joined #ruby
htmldrum has joined #ruby
sigurding has quit [Quit: sigurding]
cpup has joined #ruby
<apeiros>
no bot likes emoji
spider-mario has joined #ruby
<apeiros>
characters to express feelings - that just goes to remind them that they don't have any!
<Ox0dea>
Yet.
gheegh has joined #ruby
<apeiros>
which of course makes them feel bad
<`derpy>
Aviio has joined #ruby
<gheegh>
Hey guys.. question. Anyone doing Amazon Map Reduce Jobs in ruby code? I'm looking for some sort of best current practice... as all the stuff out there is like 4 years old on the internet.
B1n4r10 has joined #ruby
<apeiros>
4 yo code can't work, amirite?
rehat has quit [Remote host closed the connection]
<systemsgotyou>
when would you use a stored procedure and when would you use a function?
petricore has joined #ruby
petricore has quit [Client Quit]
<choke>
of course it can work... but best practices changing so often, there's a big chance that 4yo code goes against todays development standards.
<gheegh>
Wukong's last update was in 2014..
iNs has joined #ruby
Xiti has joined #ruby
chouhoulis has quit []
<moss>
hello
jt__ has quit [Remote host closed the connection]
<moss>
how do I include a variable in a file that I need opened?
parduse has quit []
<moss>
for instance: File.foreach('/etc/sysconfig/network-scripts/ifcfg-' + interface)
djbkd has joined #ruby
<adaedra>
what's wrong with this method?
_blizzy_ has quit [Quit: Leaving]
<apeiros>
systemsgotyou: I think you want to ask that in #whicheverdbyouuse
chouhoulis has joined #ruby
mistermocha has quit [Ping timeout: 276 seconds]
dling` has quit []
maletor has joined #ruby
rbennacer has quit [Remote host closed the connection]
chouhoulis has quit [Remote host closed the connection]
dvinciguerra has quit [Ping timeout: 244 seconds]
chouhoulis has joined #ruby
rbennacer has joined #ruby
dn` has quit [Quit: dn`]
yfeldblum has quit [Ping timeout: 268 seconds]
codecop has quit [Remote host closed the connection]
skweek has joined #ruby
uglybandersnatch has joined #ruby
BTRE has joined #ruby
jt__ has joined #ruby
kpwarr_ has quit [Quit: leaving]
mistermocha has joined #ruby
uglybandersnatch has quit [Ping timeout: 244 seconds]
GodFather has quit [Ping timeout: 244 seconds]
baweaver has joined #ruby
dagda1 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Aviio has quit [Remote host closed the connection]
GodFather has joined #ruby
uglybandersnatch has joined #ruby
mistermocha has quit [Ping timeout: 248 seconds]
elaptics is now known as elaptics`away
mistermocha has joined #ruby
baweaver has quit [Ping timeout: 248 seconds]
kobain has joined #ruby
joneshf-laptop has quit [Ping timeout: 246 seconds]
Suntzu has quit [Read error: Connection reset by peer]
halfamind has joined #ruby
<bullets>
rehat: you can try resetting your router
jottr has joined #ruby
rippa has joined #ruby
snguyen has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<rehat>
bullets: haha I was looking for something to prevent getting banned for future scrapes. I'll try adding a random sleep but I read online that I should use ip rotating or a proxy service but I'm now familiar with that stuff. I guess I read a wiki lol
nibbo has joined #ruby
rippa has quit [Client Quit]
n008f4g_ has quit [Ping timeout: 244 seconds]
stannard has quit [Remote host closed the connection]
stannard has joined #ruby
Spami has joined #ruby
ur5us has quit [Remote host closed the connection]
Spami has quit [Remote host closed the connection]
mg^ has quit [Ping timeout: 240 seconds]
n008f4g_ has joined #ruby
baweaver has quit [Remote host closed the connection]
mg^ has joined #ruby
gregf has quit [Quit: WeeChat 1.4]
mistermocha has quit [Ping timeout: 264 seconds]
dionysus69 has quit [Ping timeout: 244 seconds]
dopie has quit [Ping timeout: 244 seconds]
GitGud has quit [Quit: going to sleep attempt no. 1]
mistermocha has joined #ruby
r0b3rt has joined #ruby
malconis has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
shadoi has quit [Quit: Leaving.]
bronson has quit [Remote host closed the connection]
BSab has joined #ruby
vdamewood has joined #ruby
ldnunes has quit [Quit: Leaving]
shmuli has joined #ruby
BrunoSaboia has quit [Ping timeout: 268 seconds]
skade has joined #ruby
aupadhye has quit [Ping timeout: 248 seconds]
norc has quit [Ping timeout: 240 seconds]
Suntzu has joined #ruby
dunpeal has quit [Ping timeout: 276 seconds]
GodFather has quit [Ping timeout: 240 seconds]
Aviio has quit [Remote host closed the connection]
<majuscule>
can someone give me super simple explanation of the difference between foo[:bar] and foo['bar']? it's driving me crazy. or a link to some good documentation would be cool too :-)
baweaver has joined #ruby
<apeiros>
majuscule: do you understand the difference between foo["1"] and foo[1]?
<majuscule>
the first is a string, the second is an index
<apeiros>
um, no?
<apeiros>
the second is an integer (or a number). an integer can be an index, but in this case, both are a key.
<apeiros>
but you understand that both are keys? and that they look similar, but they are different keys?
duckpuppy has quit [Ping timeout: 276 seconds]
blitheBoudica has left #ruby ["Leaving..."]
<majuscule>
ahh sorry, that's essentially what i meant, the key in the first is a string, the second is an integer, and generally numerical keys are indexes
<majuscule>
yes
<majuscule>
i do
<havenwood>
majuscule: Are you familiar with `:bar.class` and `'bar'.class`?
<apeiros>
same thing with "foo" and :foo
swills has joined #ruby
FooMunki has quit [Quit: FooMunki]
<apeiros>
one thing is a string, the other a symbol. they look similar, but they are not the same. they can both be used as a key.
polll has quit [Ping timeout: 264 seconds]
<majuscule>
ahh okay. that makes sense.
FooMunki has joined #ruby
<majuscule>
and is there generally a reason to choose one over the other when defining a hash?
<apeiros>
symbols are more light-weight and faster
<havenwood>
majuscule: Hash keys are often Symbols. You'd not want to do that if say the key was determined by user input.
darkf has joined #ruby
stannard has quit [Remote host closed the connection]
<apeiros>
but they're bad if the set of possible keys is not finite
<majuscule>
hrmm
smathy_afk is now known as smathy
<majuscule>
interesting
<majuscule>
alright
<apeiros>
which means that e.g. they're not good for user input (because you don't know all possible user inputs)
ljames has quit []
<apeiros>
also ruby internally uses symbols to identify everything in code which has a name (methods, variables)
dhollinger has quit [Quit: WeeChat 1.4]
bronson has joined #ruby
n008f4g_ has quit [Ping timeout: 260 seconds]
eljimbo has quit [Quit: This computer has gone to sleep]
ekinmur has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
drewo has joined #ruby
eljimbo has joined #ruby
xaxisx has quit [Ping timeout: 244 seconds]
grill has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
shmuli has quit [Remote host closed the connection]
bkxd has joined #ruby
p0wn3d has joined #ruby
Devalo has quit [Remote host closed the connection]
p0wn3d has quit [Client Quit]
p0wn3d has joined #ruby
barajasfab has quit [Quit: Leaving]
quazimodo has joined #ruby
biberu has quit []
gizless has joined #ruby
hiyosi has joined #ruby
mdw has joined #ruby
bkxd has quit [Ping timeout: 264 seconds]
ecksit has joined #ruby
gheegh has quit [Ping timeout: 248 seconds]
mistermocha has quit [Remote host closed the connection]
gizmore has quit [Ping timeout: 260 seconds]
Aviio has quit [Remote host closed the connection]
<baweaver>
bry4n_ has quit [Ping timeout: 248 seconds]
halfamind has joined #ruby
<havenwood>
3x faster... mmhmm!
<bullets>
I hadn't seen the link of the ruby 3 release
<apeiros>
I heard 30x
<bullets>
I'm pleased
<smathy>
Weird choice to go fully functional though.
n_blownapart has quit [Remote host closed the connection]
dunpeal has joined #ruby
<havenwood>
<bullets>
Ruby 5.0 when?
zeroDivisible has joined #ruby
ur5us has quit [Remote host closed the connection]
<baweaver>
smathy: Yeah, I was surprised that they went with immutable values all around
<havenwood>
smathy: True, and the macros will take some getting accustomed to.
<baweaver>
Though the pattern matching in the video is amazing, Matz really hit it out of the park
<apeiros>
but did they really have to switch to pythonesque meaningful whitespace instead of `end`?
<baweaver>
I'm just happy they finally required parens
marsjaninzmarsa has quit [Excess Flood]
<baweaver>
apeiros: it'll take some getting used to
marsjaninzmarsa has joined #ruby
<apeiros>
thanks god for the --old-and-shitty-code compat switch
Aviio has joined #ruby
<baweaver>
pretty sure that's their joke feature
<shevy>
now you guys are talking about python3!
rbennacer has quit [Remote host closed the connection]
<baweaver>
No, just that much has changed in Ruby 3
<baweaver>
A lot of bold decisions
<smathy>
It makes Angular 2 look like a backwardly compatible bugfix.
<baweaver>
Heck, they even made Python 3 look tame
LaT0rtue has quit [Read error: Connection reset by peer]
p0wn3d has quit [Quit: WeeChat 1.2]
p0wn3d has joined #ruby
baweaver has quit [Remote host closed the connection]
<smathy>
Not Perl6 though, that still looks like a Dali painting.
n_blownapart has joined #ruby
<Ox0dea>
apeiros: I'm confused by your confusion.
<shevy>
lol
<apeiros>
let me recurry that
<Ox0dea>
Regarding "names are always Symbols", that's not the case for RubyVM::INSTRUCTION_NAMES; they're Strings.
<Ox0dea>
I'm not sure why.
chouhoul_ has quit [Remote host closed the connection]
<apeiros>
you misunderstood me
<Ox0dea>
Your use of `grep(/Symbol/)` seems to belie that you did the misunderstanding. :/
<apeiros>
ruby internally identifies things with symbols, as that's how it came to be
abyx has quit [Quit: This computer has gone to sleep]
workmad3 has joined #ruby
rbennacer has joined #ruby
kobain has quit [Ping timeout: 260 seconds]
n_blownapart has quit [Ping timeout: 244 seconds]
BTRE has quit [Ping timeout: 240 seconds]
freerobby has quit [Quit: Leaving.]
n_blownapart has joined #ruby
ecksit has quit []
rbennacer has quit [Ping timeout: 264 seconds]
stunder has quit [Ping timeout: 264 seconds]
htmldrum has quit [Ping timeout: 248 seconds]
Donkoko has quit [Remote host closed the connection]
karioleez has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
babblebre has quit [Quit: Connection closed for inactivity]
karioleez has joined #ruby
freerobby has joined #ruby
mg^ has quit [Quit: Leaving]
pawnbox has joined #ruby
mg^ has joined #ruby
BTRE has joined #ruby
diegoviola has joined #ruby
bkxd has joined #ruby
n_blownapart has quit [Ping timeout: 264 seconds]
zenlot6 has joined #ruby
baweaver has joined #ruby
karioleez has quit [Ping timeout: 252 seconds]
n_blownapart has joined #ruby
pawnbox has quit [Ping timeout: 250 seconds]
zenlot has quit [Ping timeout: 260 seconds]
abyx has joined #ruby
rubie has quit [Remote host closed the connection]
halfamind has quit [Quit: Leaving.]
kirun has quit [Quit: Client exiting]
freerobby has quit [Quit: Leaving.]
baweaver has quit [Ping timeout: 248 seconds]
bullets has quit [Quit: leaving]
karioleez has joined #ruby
baweaver has joined #ruby
Coldblackice_ has quit []
Rahul_Roy has quit [Quit: Connection closed for inactivity]
n_blownapart has quit [Ping timeout: 248 seconds]
triangles2 has joined #ruby
Canar has quit [Quit: WeeChat 1.4]
Lomex_ has quit [Remote host closed the connection]
dmr8 has quit [Quit: Leaving]
last_staff has joined #ruby
pawnbox has joined #ruby
Coldblackice has joined #ruby
triangles has quit [Ping timeout: 264 seconds]
karioleez has quit [Ping timeout: 276 seconds]
Inside has joined #ruby
Inside has joined #ruby
mfb2_ has quit [Read error: Connection reset by peer]
bkxd has quit [Ping timeout: 252 seconds]
poguez_ has joined #ruby
bry4n_ has joined #ruby
ssiris has joined #ruby
Renich has quit [Ping timeout: 252 seconds]
bkxd has joined #ruby
davedev24 has quit []
djbkd has quit [Quit: My people need me...]
Renich has joined #ruby
bry4n has quit [Ping timeout: 250 seconds]
bronson has quit [Remote host closed the connection]
Aviio has quit [Remote host closed the connection]
jottr has quit [Ping timeout: 244 seconds]
dunpeal has quit [Quit: Lost terminal]
Lomex_ has joined #ruby
<brent_>
Ox0dea, wondering if you would take a quick look at my mazesolver. Wasn't able to work on it for a few days
Lomex_ has quit [Remote host closed the connection]
<brent_>
trying to see if you think i'm on the right path
bkxd has quit [Ping timeout: 248 seconds]
bruce_lee has quit [Remote host closed the connection]
bkxd has joined #ruby
kies has quit [Ping timeout: 276 seconds]
snguyen has joined #ruby
Jackneill has quit [Ping timeout: 268 seconds]
cpruitt has quit [Quit: cpruitt]
ur5us has joined #ruby
halfamind has joined #ruby
bkxd has quit [Ping timeout: 260 seconds]
davedev24 has joined #ruby
karioleez has joined #ruby
bkxd has joined #ruby
halfamind has quit [Client Quit]
skade has quit [Quit: Computer has gone to sleep.]
siaw has quit [Quit: siaw]
<smathy>
Hey, within a case statement, is there some shorthand to refer to the subject of the case, like `case "Foo" when <something here>.downcase == "foo" ` or even more commonly: `case "blah" when...when...when...else <something here> end` ?
magikid has joined #ruby
htmldrum has joined #ruby
kobain has joined #ruby
<smathy>
(I end up doing `case s = "foo"; when ....` a fair bit :)
karioleez has quit [Ping timeout: 244 seconds]
shmuli has joined #ruby
bkxd has quit [Remote host closed the connection]
freerobby has joined #ruby
<baweaver>
lambdas would be the only way I could think of
<ruby[bot]>
baweaver: # => {"bob"=>#<struct Person name="bob", age=25>, "jane"=>#<struct Person name="jane", age=25>} (https://eval.in/546548)
<baweaver>
rails has #index_by
<pizzaops>
Papierkorb: so calling .to_hash on an array of arrays where each item is an array of length 2 converts it to a hash?
<baweaver>
could also use group_by, though that returns collections
<Papierkorb>
pizzaops: Array#to_h expects the array to contain only arrays, with each of those arrays containing exactly two values. the first value will be the key, the second value will be the value
Renich has quit [Quit: leaving]
<pizzaops>
that's perfect, thanks
duckpuppy has joined #ruby
<baweaver>
>> [:a, 1, :b, 2].to_h
<ruby[bot]>
baweaver: # => wrong element type Symbol at 0 (expected array) (TypeError) ...check link for more (https://eval.in/546549)
<baweaver>
hm. Thought there was a variant like that
<baweaver>
I'd disagree heavily with that statement
<Ox0dea>
I'd swap > for +.
<pizzaops>
Papierkorb: does this seem reasonable? https://gist.github.com/pizzaops/1f44b4e37bc2c57272c227102d83f851 — I need the ||= because calls on these objects can potentially trigger network traffic, so I don't want to create the hash again if I've already created it.
<Papierkorb>
pizzaops: If you want to memoize it, use an @instance variable. Your method will always run the #map, as 'networks' is at that point always nil
<pizzaops>
Papierkorb: right, I meant to, just forgot. Thanks!
<Papierkorb>
pizzaops: So replace 'networks' with @networks. You can then remove the last line
<pizzaops>
So @networks will always return either way? (with that last line @networks/networks removed
kfpratt has joined #ruby
<Papierkorb>
pizzaops: Yes, assigning to a variable (same goes for ||=) returns the assigned value
<Ox0dea>
*evaluates to
<pizzaops>
<3
duckpuppy has quit [Ping timeout: 260 seconds]
<pizzaops>
MINANBYGANSTY
<pizzaops>
(Matsz is not actually nice but you guys are nice so thank you)