<cloud69>
all the days ive wasted not knowing my .rb simply needed a `# encoding: utf-8` at the top
Guest84 has joined #ruby
<isene>
wnd: Thank you. This one did the trick; ruby -e '$stdin.each_line { |i| i.force_encoding("ISO-8859-1").scan(/<a:t>(.+?)<\/a:t>/).each { |j| puts(j) } }'
<wnd>
just understand what it means to have that
<cloud69>
isene: we need more ruby folks in #nuug, www.nuug.no, please join!
<isene>
cloud69: Hehe. I was semi-active in nuug many years ago. Freenode?
<cloud69>
nice! yup :D
jenrzzz has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
Kilo`byte has quit [Remote host closed the connection]
iamgr00t has quit [Remote host closed the connection]
Kilobyte22 has joined #ruby
iamgr00t has joined #ruby
Tuor has quit [Remote host closed the connection]
cnsvc_ has joined #ruby
cnsvc has quit [Remote host closed the connection]
Tuor has joined #ruby
sjums has quit [Ping timeout: 264 seconds]
<isene>
wnd: Now, the final hurdle; How to call that whole line from within Ruby (I need the external unzip). Because doing `unzip -qc F1_awesome_pres_v5.pptx | ruby -e '$stdin.each_line { |i| i.force_encoding("ISO-8859-1").scan(/<a:t>(.+?)<\/a:t>/).each { |j| puts(j) } }'] throws this error:
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
techsethi has joined #ruby
_whitelogger has joined #ruby
<arahael>
msiism: Ruby is a general purpose programming language, and will therefore surely do everything on that list.
<arahael>
msiism: Like practically any other language.
<nakilon>
msiism "yes" to all questions
vondruch has quit [Ping timeout: 260 seconds]
<nakilon>
the last one -- use '\' in the end of the line
<nakilon>
or HEREDOC syntax if it's about a multiline string
<msiism>
arahael: I see. My backgrund is shell scripting, Tcl and a tiny bit of C. None of those languages would satisfy all of those list items. That's why I asked.
<msiism>
nakilon: Okay, thanks.
<arahael>
msiism: On non-windows systems, ruby is an excellent scripting language.
<arahael>
msiism: On windows systems, ruby is meh, as good as they can be. Windows is a bit more iffy there - no real standard way of calling and running programs, as an example.
<arahael>
(Eg, applications on windwos do not neccessarily have an exit code, do not neccessarily have stdin/stdout/stderr, etc)
<havenwood>
arahael: Ruby can shell out to Windows as well as anything.
<arahael>
havenwood: I generally have more problems shelling out to windows applications than I do to linux applications. :)
<arahael>
That's all I'm saying
alexherbo2 has joined #ruby
<msiism>
Well, I'm running Linux, and BSD or Solaris occasionally.
<arahael>
Sounds like a fine choice. :)
<msiism>
arahael: I'm not all too sure about that. But I'll take it as a compliment. ;)
<arahael>
:)
MBip[m] has left #ruby ["User left"]
rwb has quit [Ping timeout: 264 seconds]
coniptor has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
coniptor has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
yann-kaelig has joined #ruby
vondruch has joined #ruby
greengriminal has joined #ruby
cnsvc_ has quit [Ping timeout: 268 seconds]
roadie has joined #ruby
BH23 has quit [Remote host closed the connection]
Rudd0 has joined #ruby
iNs has quit [Quit: bubye]
iNs has joined #ruby
greengriminal has quit [Quit: Leaving]
<nakilon>
I wonder why does Enumerator#drop isn't lazy (
<nakilon>
I've got a 2GB large CSV and I want to skip the first (row titles) row
<nakilon>
CSV.foreach("my.csv").take(1) works fast
<nakilon>
that's the most obfuscated way to make smileys
<nakilon>
and now is someone's favourite interview question
m27frogy has joined #ruby
bvdw has quit [Remote host closed the connection]
bvdw has joined #ruby
bvdw has quit [Remote host closed the connection]
bvdw has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
bvdw has quit [Remote host closed the connection]
bvdw has joined #ruby
jenrzzz has joined #ruby
bvdw has quit [Remote host closed the connection]
bvdw has joined #ruby
bvdw has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 264 seconds]
iNs has quit [Ping timeout: 268 seconds]
iNs has joined #ruby
linoge has joined #ruby
weaksauce has quit [Ping timeout: 265 seconds]
fercell has quit [Ping timeout: 265 seconds]
fercell has joined #ruby
techsethi has quit [Ping timeout: 272 seconds]
<wnd>
I wish I had the time to look at this in more detail. In short, I think this behaviour is related to '12345'.tr('12', 'x') .
msiism has left #ruby ["Leaving"]
dfucci has joined #ruby
<wnd>
If to_str runs out of characters, the last character (struct tr .now) is used to match from_str. Seems that when the end of a range is reached and there are no more chars in a range, whatever character was expected for the next round (struct tr *now) will be used.
dfucci_ has quit [Ping timeout: 264 seconds]
<nakilon>
I would say it's a bug
<wnd>
with lame execuses I'm going to leave this here, and I'm close to calling this a bug
<nakilon>
why was I supposed to think it should increment the last value of the range?
<nakilon>
then it's weird that "\\" didn't throw an error since it's an invalid escaping
<nakilon>
while invalid using the "-" throws the errors
<NL3limin4t0r>
The documentation says: The backslash character \ can be used to escape ^ or - and is otherwise ignored unless it appears at the end of a sequence or the end of a other_str.
<nakilon>
hmm... "ignored unless it appears at the end"
<wnd>
like String#tr, String#delete also ends up using strings.c#trnext to parse its arguments
<nakilon>
oh now I wonder if there is the same bug too lol
<NL3limin4t0r>
The #delete agument is not padded, so you shouldn't encounter the same issue as with #tr
<NL3limin4t0r>
Just don't use ranges if the begin and end are the same.
<NL3limin4t0r>
You could just do 'abcdef'.tr('a-e', '1') instead of 'abcdef'.tr('a-e', '1-1')
tpanarch1st has joined #ruby
dka has joined #ruby
dfucci has joined #ruby
dfucci_ has quit [Read error: Connection reset by peer]
<c355e3b>
Has anyone ever seen webrick swallow stdout when its run as the entry point of a docker container?
jenrzzz has joined #ruby
Swyper has joined #ruby
deviantfero has joined #ruby
Guest84 has joined #ruby
Guest84 has quit [Read error: Connection reset by peer]
<adam12>
c355e3b: No, but $stdout can be buffered.
<adam12>
c355e3b: Try $stdout.sync = true
<c355e3b>
thx
jenrzzz has quit [Ping timeout: 264 seconds]
<nakilon>
telling "don't cause the bug to happen" isn't a proper way to fix bugs though
<NL3limin4t0r>
But it indeed looks like ranges accepted by #tr are always expanded to at least to characters. So 1-1 becomes 11, 4-4 becomes 44 and the padded character is the successor of the last element in the last range.
<NL3limin4t0r>
In the above `a-z` becomes `abcdefgh....` and `1-14-4` becomes `11445555....` which I agree is fairly strange.
coniptor has joined #ruby
<NL3limin4t0r>
two* characters
dinfuehr has quit [Ping timeout: 246 seconds]
dinfuehr has joined #ruby
jla has joined #ruby
dnadev2 has joined #ruby
iNs has quit [Ping timeout: 268 seconds]
iNs has joined #ruby
Swyper has quit [Remote host closed the connection]
catbusters has joined #ruby
<dnadev2>
i have a question about the best way to call a service i created to query the db based on optional params sent to it. having difficulty figuring out how to pass in the optional params and when they are blank and having it not overwrite my defaults set in the selector initialize. here is the setup - https://dpaste.org/C7xe
<adam12>
dnadev2: Maybe filter the provided hash for empty values before merging.
<adam12>
dnadev2: Problematic if you expect empty values in some places.
<dnadev2>
adam12, that's the thing - it's gonna be used in many places, and some will have no options, and others will that may or may not be blank.
<dnadev2>
adam12, so you mean filter the options hash in my init to remove any present but blanks, then merge. right?
carbone5 has joined #ruby
<adam12>
dnadev2: Yes.
<adam12>
dnadev2: Outside of that, make an object (Struct, Dry::Struct) and use that for options.
Xiti` has joined #ruby
GodFather has joined #ruby
Xiti has quit [Ping timeout: 265 seconds]
<dnadev2>
adam12, .merge(options.reject(&:blank?)) -- thought that would work, but error: wrong number of arguments (given 1, expected 0)
<dnadev2>
i like the idea of filtering first, makes sense to me. will try to figure this out opposed to the struct for now.
<adam12>
dnadev2: Hash#reject receives two args. If you're on a recent version of Ruby; .merge(options.reject { _2.blank? })
TCZ has joined #ruby
rikkipitt has joined #ruby
jla has quit [Ping timeout: 246 seconds]
cuerbot has quit [Read error: Connection reset by peer]
<dnadev2>
adam12, hmmm undefined local variable or method `_2' -- i'm using 2.6.6 (rails4)
<adam12>
dnadev2: Not new enough. You'll need to assign to a variable like you normally would. reject { |key, value| value.blank? }
elcuervo has joined #ruby
<dnadev2>
adam12, boom! works great. .merge(options.reject { |key, value| value.blank? }) -- not to ugly imo. thank you very much
burgestrand has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cd has joined #ruby
<adam12>
dnadev2: yw!
DaRock has quit [Ping timeout: 265 seconds]
coniptor has quit [Ping timeout: 256 seconds]
DaRock has joined #ruby
coniptor has joined #ruby
neshpion has joined #ruby
rikkipitt has quit [Remote host closed the connection]
jenrzzz has joined #ruby
KnownSyntax has left #ruby [#ruby]
jenrzzz has quit [Ping timeout: 240 seconds]
fercell has quit [Ping timeout: 272 seconds]
GodFather has quit [Ping timeout: 246 seconds]
fercell has joined #ruby
Technodrome has joined #ruby
sylario has joined #ruby
TCZ has quit [Remote host closed the connection]
Swyper has joined #ruby
carbone5 has quit [Quit: carbone5]
DaRock has quit [Ping timeout: 260 seconds]
GodFather has joined #ruby
rikkipitt has joined #ruby
alexherbo2 has quit [Remote host closed the connection]