baweaver changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.5.1, 2.4.4, 2.3.7, 2.6.0-preview2: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
AJA4350 has quit [Quit: AJA4350]
mikecmpbll has quit [Quit: inabit. zz.]
DTZUZO has joined #ruby
nowhere_man has quit [Ping timeout: 260 seconds]
darkhanb has joined #ruby
cthulchu_ has quit [Ping timeout: 260 seconds]
ua has joined #ruby
ur5us has joined #ruby
ur5us has quit [Ping timeout: 252 seconds]
vikaton has quit [Quit: Connection closed for inactivity]
bkxd has quit [Ping timeout: 252 seconds]
SeepingN has quit [Ping timeout: 246 seconds]
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
canurabus has joined #ruby
moei has quit [Ping timeout: 252 seconds]
Fernando-Basso has quit [Remote host closed the connection]
<canurabus> Hi all. I am having trouble trying to install a gem. I've installed gems before but I don't remember what I did to make it work. I'm using jruby and try to install the gem with the command "jruby -S gem install name_of_gem". I receive a permissions error (I'm on ubuntu)
<canurabus> ERROR: While executing gem ... (Errno::EACCES) Permission denied - /home/me/Packages/jruby/jruby-9.1.17.0/lib/ruby/gems/shared/cache/thread_safe-0.3.6-java.gem
bmurt has joined #ruby
<canurabus> Does anyone know how to get around this? I don't want to install using root; if I do this then I can't run any applications that rely on the gem without being root as well.
meinside has quit [Quit: Connection closed for inactivity]
canurabus has quit [Quit: Page closed]
bkxd has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
flips has quit [Quit: bbl ...]
elphe has quit [Ping timeout: 246 seconds]
bmurt has joined #ruby
bkxd has quit [Ping timeout: 252 seconds]
sameerynho has quit [Ping timeout: 240 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sgen has quit [Remote host closed the connection]
cagomez has joined #ruby
apparition has joined #ruby
venmx has quit [Ping timeout: 252 seconds]
bmurt has joined #ruby
bkxd has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bmurt has joined #ruby
moei has joined #ruby
tkdonut has joined #ruby
orbyt_ has joined #ruby
tkdonut has quit [Quit: Lost terminal]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gnufied has quit [Ping timeout: 246 seconds]
elphe has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elphe has quit [Ping timeout: 252 seconds]
braincrash has quit [Quit: bye bye]
Lytol has quit [Remote host closed the connection]
braincrash has joined #ruby
gix has joined #ruby
duderonomy has quit [Ping timeout: 252 seconds]
marmotini_ has joined #ruby
maryo has joined #ruby
dviola has quit [Quit: WeeChat 2.2]
fredlinhares has quit [Quit: WeeChat 1.4]
RougeR has joined #ruby
orbyt_ has joined #ruby
streiu has quit []
bkxd has quit [Ping timeout: 268 seconds]
apparition has quit [Quit: Bye]
elphe has joined #ruby
mzo has quit [Remote host closed the connection]
mzo has joined #ruby
mzo has quit [Remote host closed the connection]
bkxd has joined #ruby
bkxd has quit [Ping timeout: 252 seconds]
gnufied has joined #ruby
cagomez has quit [Remote host closed the connection]
MoritaShinobu has joined #ruby
elphe has quit [Ping timeout: 240 seconds]
gnufied has quit [Ping timeout: 252 seconds]
bkxd has joined #ruby
gnufied has joined #ruby
za1b1tsu has joined #ruby
<za1b1tsu> Hi, what do you folks about yard vs rdoc?
elphe has joined #ruby
cd has quit [Quit: cd]
graphene has quit [Remote host closed the connection]
graphene has joined #ruby
maryo has quit [Ping timeout: 246 seconds]
marmotini_ has quit [Ping timeout: 252 seconds]
RougeR has quit [Ping timeout: 244 seconds]
<apeiros> za1b1tsu: I think you accidentally a word :)
* apeiros prefers yard over rdoc
<za1b1tsu> apeiros: yeah, I did, morning here :D
<za1b1tsu> although I always do it.
<za1b1tsu> anyway, I'm thinking yard too, the syntax is so much cleaner
graphene has quit [Remote host closed the connection]
graphene has joined #ruby
reber has joined #ruby
LiftLeft3 has joined #ruby
LiftLeft has quit [Ping timeout: 250 seconds]
grenierm_ has joined #ruby
doubledup has joined #ruby
grenierm_ has left #ruby [#ruby]
maryo has joined #ruby
MoritaShinobu has quit [Ping timeout: 252 seconds]
troys has quit [Quit: Bye]
Xiti has quit [Read error: Connection reset by peer]
Xiti has joined #ruby
MoritaShinobu has joined #ruby
za1b1tsu has quit [Ping timeout: 268 seconds]
DarthGandalf has quit [Quit: Bye]
flips has joined #ruby
apparition has joined #ruby
anahtar has joined #ruby
<anahtar> Hello all. I try to use win32ole on windows with ruby 2.4. (also 2.5) with zwcad.
<anahtar> I see the ole functions z = WIN32OLE.connect("ZWCAD+.Application")
<anahtar> z.ActiveDocument.ModelSpace.ole_get_methods
<anahtar> returns the methods
<anahtar> and
<anahtar> z.ActiveDocument.ModelSpace.ole_func_methods
<anahtar> where i see the #<WIN32OLE_METHOD:AddLine> method
<anahtar> but when i call the z.ActiveDocument.ModelSpace.AddLine([0.0,0.0],[10.0,10.0])
<anahtar> ruby returns me an error
<anahtar> WIN32OLERuntimeError: (in OLE method `AddLine': )
<anahtar> <No Description>
<anahtar> OLE error code:80070057 in <Unknown>
<anahtar> in `method_missing'
<anahtar> is there any idea? :)
maryo has quit [Ping timeout: 252 seconds]
anahtar is now known as ustuntas
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
apeiros has quit [Remote host closed the connection]
rippa has joined #ruby
sleetdrop has joined #ruby
DarthGandalf has joined #ruby
ustuntas has quit [Quit: Leaving]
apeiros has joined #ruby
DTZUZO has quit [Ping timeout: 260 seconds]
sameerynho has joined #ruby
venmx has joined #ruby
clemens3 has joined #ruby
moei has quit [Ping timeout: 252 seconds]
apeiros__ has joined #ruby
desperek has joined #ruby
apeiros has quit [Ping timeout: 245 seconds]
elphe has quit [Ping timeout: 245 seconds]
elphe has joined #ruby
SCHAPiE has quit [Quit: ZNC - https://znc.in]
bkxd has quit [Ping timeout: 245 seconds]
SCHAPiE has joined #ruby
mike11 has joined #ruby
maryo has joined #ruby
maryo has quit [Max SendQ exceeded]
maryo has joined #ruby
maryo has quit [Max SendQ exceeded]
maryo has joined #ruby
doubledup has quit [Quit: Leaving]
maryo has quit [Max SendQ exceeded]
bkxd has joined #ruby
sleetdrop has quit [Quit: Textual IRC Client: www.textualapp.com]
beefjoe has joined #ruby
moei has joined #ruby
apparition has quit [Quit: Bye]
moei has quit [Ping timeout: 240 seconds]
<z4phod> hello !
<z4phod> I have rails question, i don't find with google :(
<z4phod> How do :
<z4phod> ActiveRecord::Base.transaction do { sql_within_transaction ; sql_without_transaction() } I tried use another connection, but that not working :/
<z4phod> The sql without_transaction is something like "processed += 1"
GodFather has joined #ruby
venmx has quit [Ping timeout: 252 seconds]
c0ncealed3 has quit [Remote host closed the connection]
c0ncealed3 has joined #ruby
venmx has joined #ruby
beefjoe has quit [Quit: <3]
RougeR has joined #ruby
RougeR has quit [Client Quit]
apeiros__ has quit []
Fernando-Basso has joined #ruby
cd has joined #ruby
<z4phod> the only way i found is to do Thread.new { sql_without_transaction } end.join #SO ULGY
elphe has quit [Ping timeout: 245 seconds]
TomyLobo has joined #ruby
graphene has quit [Remote host closed the connection]
AJA4350 has joined #ruby
graphene has joined #ruby
samort14 has joined #ruby
reber__ has joined #ruby
zenspider_ has joined #ruby
sriehl_ has joined #ruby
akhkharu has joined #ruby
chihhsin_ has joined #ruby
planigan_ has joined #ruby
miah_ has joined #ruby
bhaak_ has joined #ruby
catsed has joined #ruby
Sp4rKy_ has joined #ruby
n13z_ has joined #ruby
segy_ has joined #ruby
Koshian has quit [Ping timeout: 240 seconds]
brainslug has quit [Ping timeout: 240 seconds]
zenspider has quit [Read error: Connection reset by peer]
sriehl has quit [Ping timeout: 240 seconds]
raz has quit [Ping timeout: 240 seconds]
jtdowney has quit [Ping timeout: 240 seconds]
segy has quit [Ping timeout: 240 seconds]
matti has quit [Ping timeout: 240 seconds]
chihhsin has quit [Ping timeout: 240 seconds]
Siarkowy has quit [Ping timeout: 240 seconds]
reber has quit [Ping timeout: 240 seconds]
jp has quit [Ping timeout: 240 seconds]
r3dc0d3r has quit [Ping timeout: 240 seconds]
xMopx has quit [Ping timeout: 240 seconds]
Lyfe has quit [Ping timeout: 240 seconds]
miah has quit [Ping timeout: 240 seconds]
mattp_ has quit [Ping timeout: 240 seconds]
planigan has quit [Ping timeout: 240 seconds]
samort7 has quit [Ping timeout: 240 seconds]
bhaak has quit [Ping timeout: 240 seconds]
n13z has quit [Ping timeout: 240 seconds]
Sp4rKy has quit [Ping timeout: 240 seconds]
headius has quit [Ping timeout: 240 seconds]
cyberRodent has quit [Ping timeout: 240 seconds]
cats has quit [Ping timeout: 240 seconds]
TheMoonMaster has quit [Ping timeout: 240 seconds]
catsed is now known as cats
Sp4rKy_ is now known as Sp4rKy
segy_ is now known as segy
mniip has quit [Quit: This page is intentionally left blank.]
jtdowney has joined #ruby
r3dc0d3r has joined #ruby
xMopx has joined #ruby
moei has joined #ruby
cyberRodent has joined #ruby
mniip has joined #ruby
TheMoonMaster has joined #ruby
ujjain has quit [Ping timeout: 252 seconds]
ujjain has joined #ruby
akem has quit [Ping timeout: 260 seconds]
akem has joined #ruby
tdy has quit [Ping timeout: 246 seconds]
elphe has joined #ruby
bkxd has quit [Ping timeout: 252 seconds]
jp has joined #ruby
Mike111 has joined #ruby
Mike111 has quit [Max SendQ exceeded]
mike11 has quit [Ping timeout: 252 seconds]
beefjoe has joined #ruby
bkxd has joined #ruby
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhaak_ is now known as bhaak
nowhere_man has joined #ruby
akem has quit [Ping timeout: 268 seconds]
LiftLeft3 has quit [Ping timeout: 240 seconds]
ellcs has joined #ruby
LiftLeft3 has joined #ruby
beefjoe has quit [Quit: <3]
im0nde has quit [Quit: im0nde]
moei has quit [Ping timeout: 252 seconds]
galtgendo has joined #ruby
<galtgendo> when dealing with marshal dumps of somewhat complex data, is there some simple way to force all of the strings in that object (upon load or close to that) to utf8 ?
DTZUZO has joined #ruby
RougeR has joined #ruby
roshanavand has joined #ruby
oulanka has joined #ruby
<oulanka> Hi! Is there any good library to generate line charts in ruby, as images? I have code using gruff that technically works but charts are ugly as hell and gruff is a dead project. I looked for something better or at least alive, but I found only ones generating html files (mostly Google Charts based).
tdy has joined #ruby
<oulanka> For example I am currently generating something like https://i.imgur.com/xuMYrcM.png - and at this point exporting data to LibreOffice and making chart there would be probably better.
tdy has quit [Ping timeout: 240 seconds]
Sembei has joined #ruby
<havenwood> galtgendo: If only String class defined #_dump, I'd say: class String; def _dump _; super.force_encoding 'UTF-8' end end
<galtgendo> havenwood: :sigh: I've said 'somewhat complex'....anyway, the snippet from https://www.zendesk.com/blog/upgrade-the-road-to-1-9/ worked (after de-railing it)
nowhere_man has quit [Ping timeout: 268 seconds]
akem has joined #ruby
oulanka has quit [Ping timeout: 256 seconds]
samort14 has quit [Quit: Leaving]
mikecmpbll has joined #ruby
apparition has joined #ruby
hsiktas has quit []
deadnull has joined #ruby
arup_r has joined #ruby
hsiktas has joined #ruby
deadnull has quit [Quit: Textual IRC Client: www.textualapp.com]
ellcs has quit [Ping timeout: 252 seconds]
ice9 has joined #ruby
<ice9> do you think that vscode is the best IDE?
arup_r has quit [Remote host closed the connection]
desperek has quit [Ping timeout: 268 seconds]
User458764 has quit [Quit: Textual IRC Client: www.textualapp.com]
User4587_ has joined #ruby
akem has quit [Remote host closed the connection]
akem has joined #ruby
RougeR has quit [Ping timeout: 252 seconds]
User4587_ has quit [Quit: Textual IRC Client: www.textualapp.com]
DTZUZO has quit [Ping timeout: 268 seconds]
samort7 has joined #ruby
arup_r has joined #ruby
snickers has joined #ruby
Fernando-Basso has quit [Ping timeout: 246 seconds]
arup_r has quit [Remote host closed the connection]
arup_r has joined #ruby
apparition has quit [Quit: Bye]
venmx has quit [Ping timeout: 244 seconds]
sgen has joined #ruby
venmx has joined #ruby
MoritaShinobu has quit [Quit: Leaving]
tdy has joined #ruby
za1b1tsu has joined #ruby
prestorium has joined #ruby
madhatter has quit [Quit: brb]
akem has quit [Remote host closed the connection]
akem has joined #ruby
graphene has quit [Remote host closed the connection]
madhatter has joined #ruby
graphene has joined #ruby
arup_r has quit []
nertzy has joined #ruby
Eiam has quit [Ping timeout: 264 seconds]
nertzy has quit [Quit: This computer has gone to sleep]
nertzy has joined #ruby
madhatter has quit [Quit: leaving]
desperek has joined #ruby
sgen has quit [Ping timeout: 268 seconds]
nertzy has quit [Quit: This computer has gone to sleep]
ta_ has quit [Remote host closed the connection]
madhatter has joined #ruby
<madhatter> re
za1b1tsu has quit [Ping timeout: 252 seconds]
za1b1tsu has joined #ruby
hitchhikingcoder has joined #ruby
hitchhikingcoder has quit [Client Quit]
hitchhikingcoder has joined #ruby
za1b1tsu has quit [Ping timeout: 268 seconds]
orbyt_ has joined #ruby
hitchhikingcoder has quit [Quit: hitchhikingcoder]
hitchhikingcoder has joined #ruby
gnufied has quit [Ping timeout: 246 seconds]
nowhere_man has joined #ruby
hitchhikingcoder has quit [Quit: hitchhikingcoder]
gnufied has joined #ruby
samort7 has quit [Read error: Connection reset by peer]
arup_r has joined #ruby
prestorium has quit [Quit: prestorium]
arup_r has quit [Ping timeout: 268 seconds]
Fusl has quit [Ping timeout: 256 seconds]
Fusl has joined #ruby
arup_r has joined #ruby
za1b1tsu has joined #ruby
za1b1tsu has quit [Ping timeout: 252 seconds]
akem has quit [Remote host closed the connection]
akem has joined #ruby
dar123 has joined #ruby
RougeR has joined #ruby
zapata has quit [Quit: WeeChat 2.2]
dar123 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zapata has joined #ruby
za1b1tsu has joined #ruby
wojnar has joined #ruby
za1b1tsu has quit [Ping timeout: 268 seconds]
arup_r has quit [Ping timeout: 252 seconds]
<orbyt_> Anyone use rubymine?
<orbyt_> Any idea how to get the autocomplete working properly? IntelliJ usually will autoselect the first result so If I hit enter it will complete
<orbyt_> rubymine seems to requires hitting the down arrow to select the first result
<orbyt_> I found a hack by modifying the Registry, but wondering if theres just a simple setting for it instea
<orbyt_> instead*
wojnar has quit [Remote host closed the connection]
beefjoe has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
tdy has quit [Quit: WeeChat 2.2]
marmotini_ has joined #ruby
dinfuehr has quit [Ping timeout: 245 seconds]
dinfuehr has joined #ruby
reber__ has quit [Remote host closed the connection]
marmotini_ has quit [Read error: Connection reset by peer]
marmotini_ has joined #ruby
marmotini_ has quit [Ping timeout: 252 seconds]
za1b1tsu has joined #ruby
za1b1tsu has quit [Ping timeout: 268 seconds]
<i8igmac> how would you check if a file includes multiple strings File.read(f).downcase.include?(['one','two','th3'].each{|x|})
<i8igmac> like for regex, this example is like OR... /string|test/
<woodruffw> i8igmac: File.readlines(f).include?
<woodruffw> that's fine for a single line
<i8igmac> so, that is what im doing. im trying to make sure the file includes "string two three".split
clemens3_ has joined #ruby
<woodruffw> for multiple lines, you could you intersection: File.readlines(f) & ["foo", "bar", "baz"]
clemens3 has quit [Ping timeout: 268 seconds]
<woodruffw> (or something close to that)
<i8igmac> data.include?("string two three".split.each)
<woodruffw> you shouldn't need the `each`
<woodruffw> and `include?` only tests one element IIRC, you'll need to use `&`
<i8igmac> i see your example, it will work as you posted it?
<woodruffw> almost, & returns the intersection so you'll need to see if it's empty
<woodruffw> the full use would be something like (File.readlines(foo) & lines).empty?
<woodruffw> (you should test each of these in `irb` and see what works best for your use case)
<i8igmac> im not sure i understand what is done here.
<i8igmac> (File.readlines(f) & ["c","b","a"]).empty?
<i8igmac> the file for sure includes c,b,a
<woodruffw> oh, try this: (File.readlines(f).map(&:chomp) & ["c","b","a"]).empty?
<lupine> *sob*
<woodruffw> readlines doesn't remove the \n from each line :\
<lupine> now try doing it without holding the whole file in memory at one time
<havenwood> woodruffw: You can use the keyword argument: chomp: true
<woodruffw> good to know!
<woodruffw> lupine: i'm assuming this is for a script, i wouldn't use `readlines` in a production program
<woodruffw> ...not for largish files, anyways
<i8igmac> its a small example
<i8igmac> that is a nice tip.
<i8igmac> i have never seen this type of enum done before
<i8igmac> (File.readlines(f).map(&:chomp) & ["a","b"]).empty?
<woodruffw> actually it probably wouldn't be trivial to determine whether each line is in a given file without it entirely in memory, unless the order of the lines is guaranteed
<woodruffw> i8igmac: which part, the &:chomp shorthand?
<i8igmac> its like a search feature im working on... simply checking if multiple strings exist in the file...
<woodruffw> ah
<i8igmac> readlines() & ["string", "string2"]).empty
<i8igmac> is this a loop?
* baweaver wanders in
<woodruffw> not sure how to parse that, what do you mean by loop?
<i8igmac> what is the & doing
<woodruffw> it's performing a set intersection
<i8igmac> i see
<woodruffw> i don't know how it's implemented internally, probably with a loop
<i8igmac> and it only works with readlines and not File.read
<woodruffw> `File.read` returns a `String`, but `&` is an operator on `Array` in this case
Tharbakim has quit [Ping timeout: 264 seconds]
<woodruffw> if you wanted to use `File.read`, you could do `File.read.lines`, but that's probably no better than `File.readlines`
<i8igmac> oh, array of eachline read
<woodruffw> mhm
<i8igmac> i think i see whats going on
<havenwood> File.read(f).match? /^#{Regexp.union %w[a b c]}$/
<woodruffw> does Regexp.union escape special characters in its arguments?
<woodruffw> (i always forget)
<havenwood> >> Regexp.union '$1'
<ruby[bot]> havenwood: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<havenwood> #=> /\$1/
<woodruffw> that'll also only answer whether the file contains "a", "b", or "c" in that order, not whether it contains lines that strictly equal those
<woodruffw> and not necessarily in that order
<woodruffw> depends on what i8igmac wants, should the function return true if the file contains "b\na\nc\n"?
<havenwood> File.open(f) { |file| file.each.any? { |line| %w[a b c].any? { |s| line == s } } }
<havenwood> a chomp in there somewhere
<woodruffw> yeah, that looks pretty good to me
<woodruffw> definitely more readable than `&`
<baweaver> What're we up to now?
<i8igmac> so, the user will type in a search like "conductors service entrance building".
<havenwood> woodruffw: Seems i8igmac actually wants to ensure that all three things are included? Hard to say.
<havenwood> baweaver: Unsure!
<i8igmac> i have 1000 files im scanning to see what files include all strings supplied by the client
<havenwood> baweaver: i8igmac is doing a thing, and we're randomly guessing solutions without knowing what they're doing :)
<i8igmac> ,-)
<i8igmac> you are funny
<havenwood> i8igmac: so nothing to do with lines
<havenwood> i8igmac: basically, does this file have *all* of these substrings?
<baweaver> Might also stop looking once you find all the substrings
<baweaver> or if not all, the first occurrence .
<i8igmac> it can be done in lines, but the file it self must include the entire list of strings
<i8igmac> if each string exist at least one time is fine
<i8igmac> so, Dir.glob(/nec/code/book/*.txt){|f| if (File.readlines(f) & ["service","enter","building"]).empty?; puts f; end}
<i8igmac> this seems to be working
<i8igmac> i think lol.
<i8igmac> thats ugly and not working.
<havenwood> i8igmac: book = File.read filename; %w[a b c].all? { |substring| book.include? substring }
<havenwood> i8igmac: If you don't care about reading the whole thing into memory ^
<baweaver> >> %w(service enter building).zip([nil].cycle).to_h
<i8igmac> that might be a good idea, not to read the hole thing in memory
<ruby[bot]> baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<baweaver> break true if word_map.values.all?(true)
<baweaver> something like that
DTZUZO has joined #ruby
<havenwood> i8igmac: Going through the file by line, three times:
<havenwood> File.open(f) { |file| %w[a b c].all? { |substring| file.each { |line| line.include? substring } } }
<i8igmac> does that return true?
<havenwood> i8igmac: yeah
<baweaver> havenwood: Should you use find instead?
<baweaver> then maybe keep an offset in mind for the line
<havenwood> i8igmac: Or going through the file by line once (this looks weird):
<havenwood> File.open(f) { |file| substrings = %w[a b c]; file.each { |line| substrings.each { |substring| substrings.delete(substring) if line.include? substring } }; substrings.empty? }
desperek has quit [Quit: xoxo]
<havenwood> baweaver: I think all substrings need to be in the file. At least that's what I understood i8igmac's thingy to be.
<baweaver> on the each
<havenwood> I don't know if we need to know what line, or if one is missing, which, etc.
<i8igmac> correct. all strings Must exist
<i8igmac> just that the strings all exist
<havenwood> baweaver: oh, right - I meant to have an #any? - oops!
<havenwood> File.open(f) { |file| %w[a b c].all? { |substring| file.each.any? { |line| line.include? substring } } }
<havenwood> i8igmac: so each substring must be on any line at least one
<havenwood> i8igmac: ^
<havenwood> all the substrings are on at least any line
<havenwood> easier in memory ;p
<i8igmac> all substrings on at least any line
Nicmavr has quit [Read error: Connection reset by peer]
<havenwood> i8igmac: aye, i think that's ^ right
<havenwood> ah, and don't need the explicit each - since Enumerable is mixed in
<havenwood> i8igmac: my final answer:
<havenwood> File.open(f) { |file| substrings.all? { |substring| file.any? { |line| line.include? substring } } }
Nicmavr has joined #ruby
<havenwood> baweaver: What's a nicer way to write the single iteration over the file way? I have:
<havenwood> File.open(f) { |file| substrings = %w[a b c]; file.each { |line| substrings.each { |substring| substrings.delete(substring) if line.include? substring } }; substrings.empty? }
<i8igmac> you are doing stuff here i never seen before
GodFather has quit [Ping timeout: 268 seconds]
<baweaver> hm hm
<i8igmac> this is new tricks
<havenwood> baweaver: I could have that ^ abort early if the substrings are empty too.
<havenwood> It's just fugly.
<i8igmac> at what part of your final answer returns true that the entire file includes all strings
<i8igmac> dude your amazing
<i8igmac> havenwood: ;-)
<i8igmac> dude, if i had continued to do it my way, reading the hole file into memory... this machine would lock up real quick
<i8igmac> 1000 Files
<i8igmac> or i guess 882 files
<baweaver> def contains_all?(file, words) File.open(file) { |f| return true if f.find { |line| words.reject! { |s| line.include?(s) }.empty? } } end
<baweaver> ish
<havenwood> baweaver: i think it needs all three substrings in the file, not on one line.
<baweaver> reject!
<baweaver> :D
<i8igmac> the entire file must include "string one two or 3"
<havenwood> i8igmac: wait, "or" or "and"
<baweaver> "or" ?
<i8igmac> um.. oops
<baweaver> hax! hax!
<i8igmac> all strings Must exist in the file. does not matter what line or how many times... each string exist at least one time each
<baweaver> So reject and reject! do something subtly different.
<baweaver> reject! mutates, and we can abuse that fact.
<i8igmac> i can show you guys ;-)
<i8igmac> its nothing fancy. just a basic working example...
<i8igmac> i have not yet added bootstrap or any styles yet
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<i8igmac> this is a electrical codebook search indexer... any electricians in here?
orbyt_ has joined #ruby
<baweaver> i8igmac: Personally I'd use ripgrep for speed
donofrio has joined #ruby
<i8igmac> as long as i can process "cable service enter".split into the ripgrep
<havenwood> or mdfind or locate for even more speed with indexes
<i8igmac> i do appreciate your guys help
<havenwood> i8igmac: linux or bsd/macos?
<i8igmac> linux debian
<havenwood> i8igmac: man locate
<havenwood> i8igmac: sudo apt-get install mlocate -y
<i8igmac> i was doing something like `find -ilR public/nec/pg/*.txt string`
<i8igmac> or it was grep not find
<havenwood> i8igmac: ripgrep is super fast, mlocate cheats by indexing the filesystem
<i8igmac> ill read up on ripgrep
clemens3_ has quit [Ping timeout: 245 seconds]
<havenwood> i8igmac: I'd suggest checking out both ripgrep and mlocate. Compare the speed and options available for your case. They're quite different.
<i8igmac> im checking
<baweaver> The thing about Ruby is also knowing when to and when to not use it
<baweaver> in the case of a ton of text processing and finding something like RipGrep will be an order of magnitude or more faster.
<i8igmac> mlocate can read the file contents?
<havenwood> i8igmac: ooops, locate may not index file content like mdfind - I forget
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
za1b1tsu has joined #ruby
<havenwood> i8igmac: sorry for the misdirection - indexed searches are awesome but looking at locate I agree I don't see full file search - i just remembered wrong
<i8igmac> the problem i ran into with `grep -ilR nec/pg/*.txt conductor`
<i8igmac> i didnt know how to do the regex for /conductor & service & cable/
<havenwood> i8igmac: ripgrep and ag are both pretty fancy
za1b1tsu has quit [Ping timeout: 252 seconds]
orbyt_ has joined #ruby
RougeR has quit [Ping timeout: 268 seconds]
sgen has joined #ruby
<i8igmac> havenwood: a quick moment.
<i8igmac> %w[conductor cable building].all?
<i8igmac> @keyword="cable building conductor"
<i8igmac> %w[@keyword].all? <== fails
maqbool has joined #ruby
<i8igmac> im trying to place my @keyword in the place of the strings
<havenwood> i8igmac: %w makes an Array
<i8igmac> so i dont need %w for @keyword.split
<havenwood> i8igmac: an Array of Strings
<havenwood> i8igmac: %w[conductor cable building] == ['conductor', 'cable', 'building'] #=> true
<havenwood> i8igmac: Same as: "cable building conductor".split
<i8igmac> @keyword="cable conduct conductor"
<i8igmac> @keyword.split.all?
<i8igmac> thanks ;) you guys are good
<i8igmac> are you in the It field
<i8igmac> for me. its all just for fun and hobbies
ice9 has quit [Remote host closed the connection]
<havenwood> i8igmac: yup, we work at Square, which has a lot of Ruby
<i8igmac> like square space ?
<havenwood> nope, square.com
<i8igmac> do you make more then 100K
<i8igmac> lol personal question
sameerynho has quit [Ping timeout: 246 seconds]
venmx has quit [Ping timeout: 252 seconds]
elphe has quit [Ping timeout: 244 seconds]
millerti has joined #ruby
graphene has quit [Remote host closed the connection]
graphene has joined #ruby