apeiros has quit [Remote host closed the connection]
apeiros has joined #ruby-lang
skade has quit [Quit: Computer has gone to sleep.]
<hfp>
I have another one. Consider this: http://pastie.org/8683906. Why was a variable used rather than a literal? I would say it's for concision. Am I missing something?
elliotec has quit [Remote host closed the connection]
feinbergscott has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<centrx>
hfp, Yes, it is for clarity
<rickhull>
is there a way to use fork, and have the parent capture the child's output?
specialblend has quit [Quit: specialblend]
<hfp>
centrx: Alright, thanks
<rickhull>
i know i can make an io pipe to do so explicitly
ric__ has quit []
thiagoborges has joined #ruby-lang
thiagoborges has quit [Remote host closed the connection]
thiagoborges has joined #ruby-lang
kurko__ has joined #ruby-lang
jsrn has quit [Quit: Leaving]
rushed has joined #ruby-lang
jamto11 has quit [Remote host closed the connection]
kurko_ has quit [Ping timeout: 252 seconds]
makoto_ has quit [Remote host closed the connection]
bin7me has quit [Read error: Connection reset by peer]
tkuchiki has joined #ruby-lang
symm- has quit [Ping timeout: 245 seconds]
mistym has quit [Remote host closed the connection]
brettweavnet has quit [Quit: Bye]
mistym has joined #ruby-lang
tkuchiki has quit [Remote host closed the connection]
micalexander has joined #ruby-lang
mikecmpbll has quit [Quit: i've nodded off.]
anulman has joined #ruby-lang
|jemc| has quit [Ping timeout: 264 seconds]
enebo has quit [Quit: enebo]
micalexander has quit [Remote host closed the connection]
Lewix_ has quit [Remote host closed the connection]
micalexander has joined #ruby-lang
Lewix has joined #ruby-lang
nonnatus has quit [Read error: Connection reset by peer]
Lewix has quit [Remote host closed the connection]
ric__ has joined #ruby-lang
seanlinsley has quit [Quit: …]
ric__ has quit [Remote host closed the connection]
ric__ has joined #ruby-lang
ric__ has quit [Remote host closed the connection]
vlad_starkov has quit [Read error: Connection reset by peer]
workmad3 has quit [Ping timeout: 252 seconds]
ric__ has joined #ruby-lang
ric__ has quit [Client Quit]
nathanstitt has joined #ruby-lang
futureshocked has quit [Remote host closed the connection]
yfeldblu_ has quit [Remote host closed the connection]
saarinen has quit [Quit: saarinen]
tkuchiki has joined #ruby-lang
|jemc| has joined #ruby-lang
nonnatus has joined #ruby-lang
rushed has quit [Quit: rushed]
kalehv_ has joined #ruby-lang
CaptainJet has quit []
kalehv has quit [Ping timeout: 260 seconds]
havenwood has quit [Remote host closed the connection]
rushed has joined #ruby-lang
Szop_ has quit [Ping timeout: 264 seconds]
havenwood has joined #ruby-lang
snarfmason has quit [Remote host closed the connection]
snarfmason has joined #ruby-lang
nonnatus has quit [Ping timeout: 245 seconds]
dm78 has joined #ruby-lang
enebo has joined #ruby-lang
hagabaka has quit [Quit: No Ping reply in 180 seconds.]
makoto_ has joined #ruby-lang
vlad_starkov has joined #ruby-lang
hagabaka has joined #ruby-lang
ssb123_ has joined #ruby-lang
ssb123_ has quit [Remote host closed the connection]
hahuang65 has quit [Ping timeout: 248 seconds]
dm78 has quit [Ping timeout: 252 seconds]
ssb123 has quit [Ping timeout: 240 seconds]
makoto_ has quit [Ping timeout: 265 seconds]
nonnatus has joined #ruby-lang
plurt has joined #ruby-lang
elliotec has joined #ruby-lang
mykoweb has joined #ruby-lang
kalehv_ has quit [Remote host closed the connection]
tylersmith has quit [Remote host closed the connection]
rushed has quit [Quit: rushed]
enebo has quit [Quit: enebo]
seanlinsley has joined #ruby-lang
<hfp>
Is `hash` a special variable or something? hash.class returns Fixnum, hash.empty? doesn't exist and hash.size is 8 on my machine but 4 on repl.it. What gives?
plurt has quit [Quit: Computer has gone to sleep.]
<rickhull>
hash is a method on Object or Kernel i think
<rickhull>
you can assign to it, to create a local var with that name
<rickhull>
but unless the local var exists, you're actually calling a method
kalehv has joined #ruby-lang
<whitequark>
yorickpeterse: open an issue
<ledestin>
rickhull: popen? or alternative popen3
<rickhull>
yeah, really i need nonblocking behavior
<rickhull>
which popen/3 may provide, not sure
<ledestin>
well, just use read_nonblock
<rickhull>
i mean, the call to popen will block until the command finishes
cored has quit [Ping timeout: 245 seconds]
<rickhull>
though maybe there is a flag or different method. i want to create N subprocesses in the background, and then wait on them and capture their status and outputs
<ledestin>
IO.popen returns io if you don't pass block
makoto_ has joined #ruby-lang
<rickhull>
ok, cool. i think i'm just a bit brain damaged from using popen in a blocking fashion for years
<drbrain>
rickhull: checkout Process.spawn too
<drbrain>
rickhull: it's easier than using popen, IMO
<rickhull>
drbrain: yeah, a coworker pointed me there since i asked the q in here
<rickhull>
haven't digested it yet, but i think that's what i'll do
nathanstitt has quit [Read error: Connection reset by peer]
vlad_starkov has joined #ruby-lang
ric__ has joined #ruby-lang
kalehv has joined #ruby-lang
yfeldblum has joined #ruby-lang
thmzlt has quit [Remote host closed the connection]
kalehv has quit [Ping timeout: 253 seconds]
sepp2k has quit [Read error: Connection reset by peer]
thmzlt has joined #ruby-lang
yfeldblum has quit [Ping timeout: 252 seconds]
<Lewix>
anyone here need a contractor?
thmzlt has quit [Ping timeout: 269 seconds]
|jemc| has quit [Ping timeout: 252 seconds]
tylersmith has joined #ruby-lang
|jemc| has joined #ruby-lang
danijoo_ has quit [Read error: Connection reset by peer]
danijoo has joined #ruby-lang
retro|cz has quit [Ping timeout: 272 seconds]
mistym_ has quit [Remote host closed the connection]
makoto_ has joined #ruby-lang
Wardrop has joined #ruby-lang
Kabaka has joined #ruby-lang
Lewix has quit [Remote host closed the connection]
<Wardrop>
Just to double check, if I run a bunch of external commands using the #system method in multiple Ruby threads, those external commands will run in parallel correct?
makoto_ has quit [Ping timeout: 265 seconds]
vlad_starkov has quit [Read error: Connection reset by peer]
Cakey has joined #ruby-lang
havenwood has quit [Remote host closed the connection]
lfox has quit [Quit: ZZZzzz…]
lfox has joined #ruby-lang
lfox has quit [Client Quit]
therealtesseract has joined #ruby-lang
<centrx>
Wardrop, I assume so, it spawns a new process
<centrx>
Wardrop, You could also use #spawn to do it in one thread
<centrx>
from one thread
<Wardrop>
I've just worked out that LibreOffice is single threaded. I'm using `soffice` to convert Word documents (among others) to PDF. It seems only one `soffice` process can actually do anything at any given the moment. The rest of the instances wait around. It surely must be terribly designed software to have to have separate independent processes wait on one another. Dodgy.
<Wardrop>
centrx: I was using the `peach` gem to actually handle the threading.
lsegal has joined #ruby-lang
hahuang65 has joined #ruby-lang
yfeldblum has joined #ruby-lang
RobertBirnie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jsullivandigs has quit [Remote host closed the connection]
anulman has quit [Quit: Leaving.]
dorei has quit []
face has joined #ruby-lang
faces has quit [Ping timeout: 264 seconds]
vlad_starkov has joined #ruby-lang
charliesome has quit [Ping timeout: 252 seconds]
kitak has quit [Remote host closed the connection]
charliesome has joined #ruby-lang
dvorak has quit [Remote host closed the connection]
JoshuaPaling has joined #ruby-lang
havenwood has joined #ruby-lang
dvorak has joined #ruby-lang
insidious has quit []
jsullivandigs has joined #ruby-lang
jsullivandigs has quit [Remote host closed the connection]
jsullivandigs has joined #ruby-lang
kitak has joined #ruby-lang
nathanst_ has quit [Quit: I growing sleepy]
jsullivandigs has quit [Ping timeout: 248 seconds]
skade has joined #ruby-lang
rahul_j has joined #ruby-lang
havenwood has quit [Ping timeout: 252 seconds]
jsullivandigs has joined #ruby-lang
havenwood has joined #ruby-lang
skade has quit [Client Quit]
mistym has joined #ruby-lang
arooni-mobile has joined #ruby-lang
skade has joined #ruby-lang
Cakey has quit [Ping timeout: 252 seconds]
makoto_ has joined #ruby-lang
goatish_mound has quit [Read error: Connection reset by peer]
havenwood has quit [Remote host closed the connection]
nonnatus has joined #ruby-lang
rsl has joined #ruby-lang
jsullivandigs has quit [Remote host closed the connection]
makoto_ has quit [Ping timeout: 264 seconds]
vlad_starkov has quit [Read error: Connection reset by peer]
<RobertBirnie>
i've got a ruby method that is reaching out to a web API. it seems somewhere i'm getting a random never ending method. like something isn't timing out that should
<RobertBirnie>
it works fine 99% of the time and i can't reproduce it
<RobertBirnie>
any ideas on what you'd do to track down where it gets stuck?
NemesisD has quit [Ping timeout: 265 seconds]
snarfmason has joined #ruby-lang
apeiros_ has quit [Remote host closed the connection]
jamto11 has quit [Remote host closed the connection]
knu has joined #ruby-lang
riffraff has joined #ruby-lang
vlad_starkov has joined #ruby-lang
skade has quit [Ping timeout: 252 seconds]
skade has joined #ruby-lang
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
charliesome has joined #ruby-lang
jamto11 has joined #ruby-lang
kitak has quit [Remote host closed the connection]
dm78 has joined #ruby-lang
charliesome has quit [Ping timeout: 264 seconds]
dm78 has quit [Ping timeout: 272 seconds]
kitak has joined #ruby-lang
AKASkip has joined #ruby-lang
skade has quit [Ping timeout: 245 seconds]
Lewix has joined #ruby-lang
RobertBirnie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jamto11 has quit [Remote host closed the connection]
dagobah has joined #ruby-lang
makoto_ has joined #ruby-lang
jamto11 has joined #ruby-lang
rsl has quit [Read error: Connection reset by peer]
rsl has joined #ruby-lang
makoto_ has quit [Ping timeout: 272 seconds]
elliotec has quit [Remote host closed the connection]
vlad_starkov has quit [Read error: Connection reset by peer]
rsl has quit [Read error: Connection reset by peer]
rsl has joined #ruby-lang
AKASkip has quit [Ping timeout: 264 seconds]
centrx has quit [Quit: Leaving]
fragamus has joined #ruby-lang
phansch has quit [Remote host closed the connection]
tylersmith has quit [Remote host closed the connection]
kitak has quit [Remote host closed the connection]
tylersmith has joined #ruby-lang
jamto11 has quit [Remote host closed the connection]
mistym_ has quit [Remote host closed the connection]
tylersmith has quit [Ping timeout: 265 seconds]
amclain has quit [Quit: Leaving]
elliotec has joined #ruby-lang
ruby-lang484 has joined #ruby-lang
<ruby-lang484>
Hey guys. How can I remove a block of text in a file which begins with "[blockxy]"?
elliotec has quit [Remote host closed the connection]
kitak has joined #ruby-lang
<ruby-lang484>
Can someone help?
nifoc has joined #ruby-lang
ruby-lang205 has joined #ruby-lang
<ruby-lang205>
Can someone help?
ruby-lang484 has quit [Ping timeout: 245 seconds]
yfeldblum has quit [Ping timeout: 272 seconds]
kitak has quit [Remote host closed the connection]
kitak has joined #ruby-lang
<ledestin>
ruby-lang205: use sed(1)
<ljarvis>
moin
jamto11 has joined #ruby-lang
<ljarvis>
ruby-lang205: also agreed you should use sed, but if you want to use ruby, you'd need to rewrite the file line by line without that block if text
arBmind has quit [Quit: Leaving.]
vlad_starkov has joined #ruby-lang
jamto11 has quit [Remote host closed the connection]
solars has joined #ruby-lang
mykoweb has quit [Remote host closed the connection]
jamto11 has joined #ruby-lang
apeiros has joined #ruby-lang
fragamus has quit [Ping timeout: 245 seconds]
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jamto11 has quit [Remote host closed the connection]
ruby-lang205 has quit [Ping timeout: 245 seconds]
RoxasShadowRS has joined #ruby-lang
knu has quit [Ping timeout: 252 seconds]
rahul_j has quit [Quit: rahul_j]
knu has joined #ruby-lang
symm- has joined #ruby-lang
lsegal has quit [Quit: Quit: Quit: Quit: Stack Overflow.]
arBmind has joined #ruby-lang
nifoc has quit []
skade has joined #ruby-lang
makoto_ has joined #ruby-lang
Voker57 has quit [Ping timeout: 264 seconds]
cnivolle has joined #ruby-lang
makoto_ has quit [Ping timeout: 248 seconds]
vlad_starkov has quit [Read error: Connection reset by peer]
benlovell has joined #ruby-lang
relix has joined #ruby-lang
AKASkip has joined #ruby-lang
tbuehlmann has joined #ruby-lang
tbuehlmann has quit [Remote host closed the connection]
tbuehlmann has joined #ruby-lang
arctaruz has joined #ruby-lang
phansch has joined #ruby-lang
mikecmpbll has joined #ruby-lang
nifoc has joined #ruby-lang
mucker_ has joined #ruby-lang
mucker has quit [Read error: Connection reset by peer]
yfeldblum has joined #ruby-lang
jsrn has joined #ruby-lang
yfeldblum has quit [Ping timeout: 252 seconds]
korpz has joined #ruby-lang
solars has quit [Ping timeout: 240 seconds]
vlad_starkov has joined #ruby-lang
francisfish has joined #ruby-lang
marr has joined #ruby-lang
rahul_j has joined #ruby-lang
benlovell has quit [Ping timeout: 260 seconds]
feinbergscott has joined #ruby-lang
benlovell has joined #ruby-lang
<yorickpeterse>
morning kids
nofxx has quit [Ping timeout: 272 seconds]
jamto11 has joined #ruby-lang
Mon_Ouie has joined #ruby-lang
|jemc| has quit [Ping timeout: 252 seconds]
benlovell has quit [Ping timeout: 272 seconds]
jamto11 has quit [Ping timeout: 252 seconds]
<yorickpeterse>
support request:
<yorickpeterse>
"If I push to http://foo.bar I get a 301 moved permanently"
<yorickpeterse>
it uses SSL
<yorickpeterse>
this is documented
<yorickpeterse>
you can't redirect POST
* yorickpeterse
facedesk
<ljarvis>
:/
<ljarvis>
you have the funnest problems
elia has joined #ruby-lang
feinbergscott has quit [Ping timeout: 265 seconds]
solars has joined #ruby-lang
feinbergscott has joined #ruby-lang
nifoc has quit []
nifoc has joined #ruby-lang
benlovell has joined #ruby-lang
makoto_ has joined #ruby-lang
stef_204 has joined #ruby-lang
<yorickpeterse>
meh, I'd prefer it if these EC2s would actually tell me why they are slow
makoto_ has quit [Ping timeout: 245 seconds]
<apeiros>
it's friday. they're slacking off.
<yorickpeterse>
they have been for a week now
makoto_ has joined #ruby-lang
<ljarvis>
bad week
makoto_ has quit [Ping timeout: 245 seconds]
vlad_starkov has quit [Read error: Connection reset by peer]
yatish27 has quit [Remote host closed the connection]
rahul_j has quit [Quit: rahul_j]
<yorickpeterse>
I find it amazing how hard it actually is to get an accurate picture of what is causing your network performance to go to hell on The Linux
arctaruz has left #ruby-lang ["Leaving"]
<yorickpeterse>
especially with Ruby
rsl has quit [Read error: Connection reset by peer]
ItSANgo has quit [Ping timeout: 272 seconds]
rsl has joined #ruby-lang
heftig has joined #ruby-lang
marr has quit [Ping timeout: 252 seconds]
rsl has quit [Read error: Connection reset by peer]
rsl has joined #ruby-lang
vlad_starkov has joined #ruby-lang
<yorickpeterse>
at least it's never boring
r0bgleeson has joined #ruby-lang
kitak has quit [Read error: Connection reset by peer]
kitak has joined #ruby-lang
<heftig>
any idea if Matijs van Zuijlen is on Freenode? Neither 'matijs' nor 'mvz' belong to him
<yorickpeterse>
not sure, don't think I've seen him around here
arBmind has quit [Quit: Leaving.]
rahul_j has joined #ruby-lang
francisfish has quit [Remote host closed the connection]
skade has quit [Quit: Computer has gone to sleep.]
skade has joined #ruby-lang
Mon_Ouie has quit [Ping timeout: 245 seconds]
rolfb has joined #ruby-lang
rsl has quit [Read error: Connection reset by peer]
goatish_mound has joined #ruby-lang
_tockitj has joined #ruby-lang
makoto_ has joined #ruby-lang
kitak has quit [Remote host closed the connection]
vlad_starkov has quit [Remote host closed the connection]
vlad_starkov has joined #ruby-lang
francisfish has joined #ruby-lang
makoto_ has quit [Ping timeout: 260 seconds]
workmad3 has joined #ruby-lang
benlovell has quit [Ping timeout: 272 seconds]
phansch has quit [Remote host closed the connection]
phansch has joined #ruby-lang
kirin` has joined #ruby-lang
benlovell has joined #ruby-lang
ItSANgo has joined #ruby-lang
ric__ has quit []
yfeldblum has quit [Ping timeout: 272 seconds]
arBmind has joined #ruby-lang
yatish27 has joined #ruby-lang
solars has quit [Ping timeout: 245 seconds]
vlad_starkov has quit [Remote host closed the connection]
robmiller has joined #ruby-lang
rahul_j has quit [Quit: rahul_j]
ledestin has quit [Ping timeout: 252 seconds]
yatish27 has quit [Ping timeout: 240 seconds]
thmzlt has joined #ruby-lang
solars has joined #ruby-lang
rghose has joined #ruby-lang
vlad_starkov has joined #ruby-lang
<rghose>
hello am getting Net::HTTPNotFound:0x000000028376b8
<yorickpeterse>
ok
diegoviola has joined #ruby-lang
<rghose>
I am trying to open an url and get the contents
<rghose>
but getting an 406
vlad_starkov has quit [Remote host closed the connection]
<yorickpeterse>
use the correct URL and/or Accept header?
<havenwood>
_tockitj: --version flag takes an argument, you can use <=, < etc
<_tockitj>
havenwood, thanks a lot!
<havenwood>
np ;)
<_tockitj>
i did not realize there was != version comparator
blarghlarghl has joined #ruby-lang
robbyoconnor has quit [Ping timeout: 245 seconds]
<blarghlarghl>
Hi all. Quick question: I see a lot of methods for transcoding a String's encoding from one to another (ie String#encode and so on). I don't see one for specifying its encoding (a la "No, you *think* that's UTF-8, but it's actually ASCII, here, treat it as ASCII, dumbass.")
arBmind has joined #ruby-lang
<blarghlarghl>
How do I do that?
__butch__ has joined #ruby-lang
loincloth has joined #ruby-lang
ecnalyr has joined #ruby-lang
vlad_starkov has joined #ruby-lang
__butch__ has quit [Client Quit]
__butch__ has joined #ruby-lang
sandbags has quit [Remote host closed the connection]
diegoviola has quit [Quit: WeeChat 0.4.2]
saarinen has joined #ruby-lang
saarinen has quit [Client Quit]
<_tockitj>
blarghlarghl, str.bytes ?
diegoviola has joined #ruby-lang
saarinen has joined #ruby-lang
<blarghlarghl>
_tockitj: not sure what you mean?
ecnalyr has quit [Ping timeout: 240 seconds]
havenwood has quit [Remote host closed the connection]
Cakey has quit [Ping timeout: 248 seconds]
vlad_starkov has quit [Read error: Connection reset by peer]
<_tockitj>
blarghlarghl, sorry it was wrong method
<_tockitj>
you should use offending_string.force_encoding('ascii-8bit')
<hfp>
Line 1 means that if I ask for a key that doesn't exist it will give it the value of the whole object? That's what the Hash.new([]) means?
<drbrain>
hfp: yes, but a new Array isn't created every time
<havenwood>
hfp: In your example, the Array literal `[]` is the same object so both "uno" and "dos" go into that same Array.
<drbrain>
it reuses the same array every time
makoto_ has quit [Ping timeout: 240 seconds]
arBmind has quit [Quit: Leaving.]
<hfp>
I still don't get it. I understant that `hash = Has.new("foo")` means that it will return "foo" for a key that doesn't exist or the value for that key if the key exists, correct?
<hfp>
understand*
<drbrain>
hfp: p h[:one].object_id, h[:two].object_id, h[:three].object_id
<arooni-mobile>
hey folks im trying to get a keyboard to work; i'm seeing this error message: connect-debounce failed, port 2 disabled .... when i try to plug in the keyboard. what can i do now?
<drbrain>
hfp: what result do you get for either of the three examples above?
<drbrain>
(two by me, one by havenwood)
<hfp>
drbrain: For the second one, I get ["uno", "dos"]
<hfp>
For the first one they all have the same object ID
<drbrain>
hfp: what do these things mean to you?
<drbrain>
can you describe what is happening?
jsullivandigs has quit [Remote host closed the connection]
elliotec has quit [Remote host closed the connection]
<hfp>
for the first one, it means that the object `h` is always the same, for the second example it means that whatever I put in hash goes into default?
arooni-mobile has quit [Remote host closed the connection]
jsullivandigs has joined #ruby-lang
<drbrain>
it's not that `h` is the same, what object is #object_id called on?
<drbrain>
for the second example, yes, everything goes into default
elliotec has joined #ruby-lang
nigerianceo has quit []
<drbrain>
also, for the example with default and the other two, what is the difference between `default = []; hash = Hash.new default` and `hash = Hash.new []`
<hfp>
it's called on h[:symbol]. Is h.object_id and h[:lala].object_id not the same?
<drbrain>
it wouldn't be the same for those examples because `h` is a hash and `h[:lala]` is the value in `h` at key `:lala`
vlad_starkov has joined #ruby-lang
__butch__ has quit [Quit: Leaving.]
vlad_starkov has quit [Read error: Connection reset by peer]
<drbrain>
hfp: please ask more questions :D
elliotec has quit [Remote host closed the connection]
<hfp>
But why are h[:one].object_id == h[:two].object_id == h[:three].object_id?
elliotec has joined #ruby-lang
<drbrain>
because of the way Hash.new is defined
<drbrain>
(that's not a good answer)
jamto11 has joined #ruby-lang
<drbrain>
The Hash.new documentation says: If obj is specified, this single object will be used for all default values.
robmiller has joined #ruby-lang
<drbrain>
since you have h = Hash.new [] then *the same* [] will be returned for all keys without values
<hfp>
Ok, that I understand.
<drbrain>
default = []; h = Hash.new default is an alternate way of writing this same thing
<centrx>
You may want: Hash.new { |hash, key| hash[key] = [] }
<hfp>
centrx: Do you mean this is equivalent to hash = Hash.new([])?
<drbrain>
hfp: not exactly
<hfp>
:'(
<centrx>
hfp, It is similar to it, but it solves your issue with it
<drbrain>
both provide default values to unset keys
<drbrain>
the block form creates new objects for each key
<centrx>
With Hash.new([]), Hash will use that same array [] you passed in for every default value.
<hfp>
centrx: I appreciate it, but the point of the exercise is to understand why it is happening; not fix it.
<centrx>
oh...
<drbrain>
default = []; Hash.new { |hash, key| hash[key] = default } and Hash.new([]) are equivalent
<hfp>
Right. Does [] refer to an empty array or something else in Hash.new([])
<drbrain>
hfp: [] refers to an empty array
<drbrain>
for the block form, the block is executed every time you access an unknown key
<havenwood>
hfp: [] == Array.new # it is know as an 'Array literal', and is the idiomatic way to create empty Arrays
brettweavnet has joined #ruby-lang
<drbrain>
so it creates a new empty array (rather than using the same default array as with Hash.new [])
<havenwood>
hfp: `{}` is a Hash literal, like `[]` is an Array literal and `""` is a String literal.
feinbergscott has quit [Ping timeout: 252 seconds]
smashwilson has quit [Quit: Leaving]
elliotec has quit [Remote host closed the connection]
<hfp>
Ok. So. When I do `hash = Hash.new([])`, it creates a new Hash with the name `hash` and puts en empty array for every possible key, right?
<havenwood>
hfp: not just 'an' empty Array, but the exact same empty Array (same exact object, which is the only way to end up with the same object_id).
<drbrain>
hfp: right
<havenwood>
hfp: Or `Hash.new('')` would mean the same String, so each default key would be modifying that same string, like in the example above where the String mutates.
<hfp>
Ok. Now why does `hash[:one] << "uno"; hash[:two] << "dos"; p hash[:uno]` return ["uno", "dos"] ?
<hfp>
Would it be different if it was hash[:one] = "uno"; hash[:two] = "dos" ?
feinbergscott has joined #ruby-lang
<hfp>
Yes I think I get it
<havenwood>
hfp: because `hash[:one].object_id == hash[:any_default].object_id`, you're putting them in the same Array.
<hfp>
<< adds the "uno" and "dos" after the empty array
<hfp>
Which is the same for all keys
<havenwood>
hfp: yup, into the same array, which isn't empty once the first goes in
<hfp>
whereas = removes the [] and replaces it by "string"
<havenwood>
hfp: Do you think this will be true or false?: hash = Hash.new([]); hash[:anything] << :stuff; hash[:whatever].empty?
<hfp>
havenwood: No, it will be false
<hfp>
I get it now
<hfp>
(please tell me it's indeed false havenwood)
<havenwood>
hfp: indeed! ;)
<hfp>
Awesome
<hfp>
I understand it now, thanks
<drbrain>
\o/
elliotec has joined #ruby-lang
<crankharder>
whyyy... can't I override == to change how Array#uniq works?
relix has joined #ruby-lang
<drbrain>
crankharder: because Array#uniq uses Hash equality
<drbrain>
crankharder: … it is documented
<hfp>
I juste hope I took me so long not because I'm slow but because it's hard to comprehand at the beginning...
<drbrain>
hfp: Hash.new [] vs Hash.new { |h,k| h[k] = [] } is a very common early stumbling block
<drbrain>
hfp: probably the most difficult thing to work through early on
<hfp>
drbrain: I'm getting there, it's the next question in the koans, we'll soon know if I can get it or will need more help :)
<crankharder>
drbrain: curious where you see those docs
<drbrain>
(that line is missing from the 1.9.3 documentation)
nszceta has quit [Remote host closed the connection]
bjh13 has quit [Quit: leaving]
<Senjai>
o/ drbrain
<drbrain>
Senjai: hi
elliotec has quit [Remote host closed the connection]
<Senjai>
drbrain: not sure if you remember me but I came to you asking for advice on what I should contribute to. Eventually got a job because of that
<drbrain>
Senjai: oh awesome! \o/
<Senjai>
drbrain: since Nov 1st
<drbrain>
I vaguely remember
<Senjai>
didn't apply or anything, just a company that uses the product
<drbrain>
nice
elliotec has joined #ruby-lang
nifoc has quit []
gianlucadv has quit [Ping timeout: 260 seconds]
<hfp>
Senjai: I'm curious, what did you do?
elliotec has quit [Remote host closed the connection]
robmiller has quit [Quit: robmiller]
<Senjai>
hfp: I ended up contributing to Spree
<Senjai>
and was getting tasks delegated to me in their IRC channel
robbyoconnor has joined #ruby-lang
elliotec has joined #ruby-lang
senj has quit [Quit: Sleep Now]
diegoviola has joined #ruby-lang
<hfp>
Senjai: Interesting, it's a competitor to Shopify, yes?
senj has joined #ruby-lang
robbyoconnor has quit [Excess Flood]
robbyoconnor has joined #ruby-lang
makoto_ has joined #ruby-lang
<Senjai>
hfp: Not really, shopify really doesnt involve code afaik. Spree is meant for developers as a springboard to creating an ecommerce store
<Senjai>
Spree requires a developer to get a store running, whereas shopify doesnt
enebo has joined #ruby-lang
<Senjai>
but there are some prety big companies running spree
prc has joined #ruby-lang
robbyoconnor has quit [Read error: Connection reset by peer]
robbyoconnor has joined #ruby-lang
<hfp>
I see. This is inspiring, I'm hoping to change careers and get into software development. I hope you don't mind my asking: were you working as a dev before?
<Senjai>
hfp: Nope. I was a Business Development consultant for a city, and before that I sold and promoted securities
postmodern has joined #ruby-lang
breakingthings has quit []
<hfp>
Senjai: Awesome, how long did it take you to be good enough to contribute to Spree? And what did you contribute specifically?
<Senjai>
hfp: I started in January seriously. I did hobbiest programming all my life, just never put any time into it
<hfp>
You are me haha
<Senjai>
hfp: whatever they delegated to me, mostly low hanging fruit around the API
makoto_ has quit [Ping timeout: 272 seconds]
<hfp>
I have time off now so I am learning more seriously to bridge the gaps
<Senjai>
I'm not good, and I'm still not good :P
<Senjai>
But I *tried*
<Senjai>
not all of my attempts at solutions made it in, but I got good feedback
<hfp>
What was the process like? Did you apply and they said "sure, please fix this" and eventually hired you?
<Senjai>
No, one of the other contributors owned the company I work at. He gave me something to attempt, gave me feedback and asked me to try again, then I tried it given that feedback.
<Senjai>
Afterwards he asked me to send him my resume
<Senjai>
I was also geographically near, so that helps
EngierkO_ has joined #ruby-lang
mistym has joined #ruby-lang
<hfp>
I see
<Senjai>
also got an interview from someone in #rubyonrails
<Senjai>
but I didn't get that position
EngierkO has quit [Ping timeout: 252 seconds]
<Senjai>
Same thing
<Lewix>
oh ya
<hfp>
One company I have in my sights have offices here but they require in the job offer that applicants are contributors to OSS and I'm not sure where to start with that
<Lewix>
is it from canada?
<Lewix>
Im looking for a job myself
<Lewix>
=)
<Lewix>
s/it/he
<Senjai>
Lewix: Victoria Canada yea
<hfp>
Yay Canada here too
<Senjai>
hfp: I just have everything I do open sourced, and I dont have many. I'd apply anyway
elliotec has quit [Remote host closed the connection]
seanlinsley has quit [Quit: …]
ssb123 has quit [Remote host closed the connection]
EngierkO_ has quit [Ping timeout: 252 seconds]
elliotec has joined #ruby-lang
<Lewix>
Senjai: ah I see. thanks
hhatch has quit [Ping timeout: 252 seconds]
<Senjai>
Not sure they're hiring atm
senj has quit [Quit: Sleep Now]
enebo has quit [Quit: enebo]
<hfp>
Aaaand I'm back with: `hash = Hash.new {|hash, key| hash[key] = [] }`. This means that for unknown keys it will return []. But it is different from the previous example because in this one it is not the same object so `hash[:one] << "one"; hash[:two] << "dos"` pushes the strings into separate and distinct empty arrays, correct?
brettweavnet has quit [Quit: Bye]
<drbrain>
correct
vlad_starkov has joined #ruby-lang
<hfp>
Yay
yfeldblum has quit [Remote host closed the connection]
<hfp>
When one does `Hash.new([])`, how does it work internally? Does it create every possible key with the object or are they created on the fly? And once you have accessed them, does that create them or do you have to explicitly do an assignation to create the keys?
brettweavnet has joined #ruby-lang
<hfp>
by on the fly I mean whenever a non-existent key is accessed
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<drbrain>
hfp: Hash.new([]) is a shortcut for `default = []; Hash.new { |hash, key| hash[key] = default }`
vlad_starkov has quit [Read error: Connection reset by peer]
phansch has quit [Quit: Leaving]
<hfp>
I see, thanks
<dacamp>
ls
<dacamp>
aahhh fuck, carry on.
<hfp>
su -
yfeldblu_ has joined #ruby-lang
<hfp>
Yeh, didn't think so
robmiller has joined #ruby-lang
<dacamp>
at least it wasn't a password
nathanstitt has quit [Quit: I growing sleepy]
nisstyre has joined #ruby-lang
workmad3 has joined #ruby-lang
flori has quit [Read error: Operation timed out]
jsrn has joined #ruby-lang
flori has joined #ruby-lang
mistym has quit [Remote host closed the connection]
elliotec has quit [Remote host closed the connection]
elliotec has joined #ruby-lang
workmad3 has quit [Quit: Lost terminal]
brettweavnet has quit [Quit: Bye]
MrZYX is now known as MrZYX|off
unlol_ has joined #ruby-lang
unlol_ has left #ruby-lang [#ruby-lang]
elliotec has quit [Remote host closed the connection]
robmiller has quit [Quit: robmiller]
lcdhoffman has quit [Quit: lcdhoffman]
abcxyz has joined #ruby-lang
elliotec has joined #ruby-lang
ssb123 has joined #ruby-lang
<abcxyz>
hi guys, I'm new to ruby and I was wondering if someone could explain why running the unit-tests found in the main repo takes so long. e.g. ./ruby test/ruby/test_yield.rb takes 4 seconds on my machine to run 12 tests, none of which seem very complex
<abcxyz>
it hangs on the last 3 or so, out of 12, for a couple of seconds
<abcxyz>
(in the above 'test/ruby/test_yield.rb' is in the top level directory of the repository)
andrewhl has quit [Quit: andrewhl]
dm78 has quit []
jsrn has quit [Quit: Leaving]
brettweavnet has joined #ruby-lang
dm78 has joined #ruby-lang
makoto_ has joined #ruby-lang
lfox has quit [Quit: ZZZzzz…]
<centrx>
abcxyz, Do you have a link?
<drbrain>
abcxyz: Finished tests in 3.237649s, 3.7064 tests/s, 7306.8452 assertions/s
<hfp>
If I wanted to find what does `string=<<EOS;foo;EOS` do in the doc, what should I search for? I tried `=<<` but no luck
ssb123 has quit [Ping timeout: 240 seconds]
<abcxyz>
drbrain: that was running the same test?
<centrx>
hfp, It is called a "heredoc" or "here document"
<drbrain>
considering there's nearly twenty-four thousand assertions I think that's pretty good
<drbrain>
abcxyz: yup
<hfp>
centrx: Thanks
<abcxyz>
drbrain: aahhh, I guess I misread something
<drbrain>
abcxyz: also, you should run `make test-all TESTS=ruby/test_yield.rb`
<drbrain>
that makes sure everything is set up correctly and you don't get pollution from gems, etc.
makoto_ has quit [Ping timeout: 245 seconds]
<drbrain>
abcxyz: some of the test files generate a ton of assertions on the fly
<drbrain>
so they don't look very big but end up doing lots of work
<abcxyz>
drbrain: I wanted to isolate the running of each test as I'm testing something in the interpreter.
<abcxyz>
So I am setting RUBY/RUBYLIB/PATH as is done in tool/runruby.rb
<abcxyz>
which seemed to be what is used to setup the running of test/runner.rb
<drbrain>
make test-all TESTS='ruby/test_yield.rb -n test_hash_each' then
brettweavnet has quit [Quit: Bye]
<abcxyz>
ah, thanks
<drbrain>
and if you don't know the test names, -v will show them
mrevd has quit [Quit: Leaving.]
<abcxyz>
k, that makes my life easier. Probably should have come here earlier instead of trawling through strace output to piece together what make test-all was doing :P