<ridders24>
hey guys, I cant see to get Dir.foreach("C:/users/ridders/pictures/test.txt") {|x| puts "Got #{x}" } to find test.txt. it says it can not find file or directory......why?
<brokenladder>
well, i'm not familiar with windows, but what happens if, inside of a ruby file, you output File.dirname(__FILE__)
<Defusal>
andrewvos, you know that 0.upto(size - 1) == size.times
<andrewvos>
heh yeah
SkramX has joined #ruby-lang
mark-_ has joined #ruby-lang
<Defusal>
added min=0, max=-1 args and a block to modify the string that is compared, perfect :)
<andrewvos>
cool
S2kx has joined #ruby-lang
jxie has joined #ruby-lang
flak has joined #ruby-lang
SkramX has joined #ruby-lang
lsegal has joined #ruby-lang
<Defusal>
andrewvos, and made it filter to the longest matching start string
<andrewvos>
Defusal: Hope you're still using my tests
<Defusal>
yea i just didn't use the class
<Defusal>
i added it to Array
<andrewvos>
why?
<andrewvos>
Oh ok
rippa has joined #ruby-lang
chimkan has joined #ruby-lang
vesan has joined #ruby-lang
dous has joined #ruby-lang
pxjorge has joined #ruby-lang
tekin has joined #ruby-lang
dejongge has joined #ruby-lang
udzinari has joined #ruby-lang
ChattChittoRG has joined #ruby-lang
ChattChittoRG has quit [#ruby-lang]
<shevy>
anyone knows if there exists, for ruby: audio instruction -> translate into command. specifically, I'd like to use this when doing a $stdin.gets user input, optionally
vesan has joined #ruby-lang
wmoxam has joined #ruby-lang
Clordio_ has joined #ruby-lang
vesan has joined #ruby-lang
esad has joined #ruby-lang
seanstickle has joined #ruby-lang
Radium has joined #ruby-lang
rue has joined #ruby-lang
futurechimp has joined #ruby-lang
Clordio_ has joined #ruby-lang
vesan has joined #ruby-lang
slyphon has joined #ruby-lang
gregf has joined #ruby-lang
francisfish has joined #ruby-lang
SkramX has joined #ruby-lang
SkramX has joined #ruby-lang
esad has joined #ruby-lang
dhruvasagar has joined #ruby-lang
arooni-mobile has joined #ruby-lang
Nisstyre has joined #ruby-lang
io_syl has joined #ruby-lang
tekin has joined #ruby-lang
publicvoid has joined #ruby-lang
savage- has joined #ruby-lang
matti has joined #ruby-lang
mbriggs has joined #ruby-lang
dhruvasagar has joined #ruby-lang
anildigital has joined #ruby-lang
anildigital has quit [#ruby-lang]
bawer has joined #ruby-lang
ahs3- has joined #ruby-lang
jmeeuwen has joined #ruby-lang
ahs3- has joined #ruby-lang
ahs3- has joined #ruby-lang
andrewhl has joined #ruby-lang
dhruvasagar has joined #ruby-lang
wallerdev has joined #ruby-lang
Radium has joined #ruby-lang
jmeeuwen has joined #ruby-lang
vesan has joined #ruby-lang
nofxx has joined #ruby-lang
naz has joined #ruby-lang
dhruvasagar has joined #ruby-lang
vesan has joined #ruby-lang
wallerdev has joined #ruby-lang
savage- has joined #ruby-lang
Sulfur has joined #ruby-lang
dhruvasagar has joined #ruby-lang
<andrewvos>
shevy: Mechanical turk?
<shevy>
lol wat
rue has joined #ruby-lang
<any-key>
mechanical turk can solve quite a few problems if done correctly :P
<any-key>
I used it at a startup I interned at...you just have to vette the results because people will try to rip you off
Luxx_ has joined #ruby-lang
bawer has joined #ruby-lang
dhruvasagar has joined #ruby-lang
dhruvasagar has joined #ruby-lang
sepp2k has joined #ruby-lang
greenhat has joined #ruby-lang
wallerdev has joined #ruby-lang
toretore has joined #ruby-lang
ridders24 has joined #ruby-lang
<ridders24>
how do I set part of a string on each line within a txt file as a variable, so that I can search the C drive for files containing part of all of that name?
Spooner has joined #ruby-lang
<drbrain>
any-key: an easy solution is to run the results three times through the turk
<drbrain>
don't let anyone re-answer, and let the results vote
<drbrain>
ridders24: like grep?
bettyna has joined #ruby-lang
<ridders24>
drbrain: yh I guess, the string would be like abc-11 but will vary
<drbrain>
ridders24: look at File#each_line and String#=~
<drbrain>
and Regexp.escape
<ridders24>
drbrain: thankyou I'll have alook
<lsegal>
File.readlines("file.txt").grep(/match/)
<lsegal>
where match could be like abc-11
zmack has joined #ruby-lang
cirwin has joined #ruby-lang
Clordio_ has joined #ruby-lang
<Defusal>
i just realized how inefficient rsync is for my current use case
<Defusal>
and i found out about zero-copy, which sounds great
<drbrain>
Defusal: what is your current use case
<drbrain>
Defusal: is this the same project you've been working on the last couple days?
<Defusal>
would a good approach be to store an identifier for each file being monitored, such as the modified timestamp and maybe size, and then use zero-copy to sync files that have changed?
<Defusal>
drbrain, yes its the same project
jnraine has joined #ruby-lang
<Defusal>
it'll be to sync files that are watched with inotify
<Defusal>
and also to sync bulk files for installation
mephux has joined #ruby-lang
<Defusal>
i'll have to benchmark and see how well it performs with a lot of files for installation, i havn't come across a gem that passes bulk files to zero-copy with native code, i'd think that looping through each file recursively in ruby would be a bit slow
<Defusal>
i also want to minimize cpu load, so zero-copy sounds perfect
<drbrain>
Defusal: timestamp + size seems decent
ericmuyser has joined #ruby-lang
<drbrain>
Defusal: maybe a secure hash digest too
<drbrain>
Defusal: why isn't rsync suitable?
<Defusal>
drbrain, rsync wastes a lot of CPU and IO having to read and process the files to make the transfer efficient, while thats great for large files with small changes over a network, it can slow it down and waste a lot of resources for local files, especially for installing bulk files
<Defusal>
i saw a benchmark with a large file just now where it took almost double the time to update a small change, compared to when it copied the whole file the first time
<drbrain>
Defusal: maybe rsync -W?
<Defusal>
but im also thinking about cpu usage, zero-copy is far more efficient than anything in the user space
<Defusal>
the game servers running on this server will be using most of the resources on most cores, i wouldn't want the management platform to use any more resources than possible, as that will cause performance issues
<drbrain>
Defusal: likely, but I would think rsync would use zero-copy APIs too (not to force you back to rsync, if it won't work for you)
<Defusal>
drbrain, hmm, i will do some research, if that is the case, i will just tell it to copy the whole files
<Defusal>
i didn't see anything about that when i was looking for a comparison of rsync vs zero-copy
<drbrain>
there's a bunch of rsync options for changing the behaviors
<drbrain>
if you're lucky, you can find a set of rsync options that might save you some implementation time
<drbrain>
when I watch top with rsync, though, typically I see a 50/50 split between rsync and ssh on an idle box
<Defusal>
yeah
<Defusal>
i just havn't seen any option about zero-copy
<Defusal>
i already have rsync implemented for all my file syncing
dhruvasagar has joined #ruby-lang
andrewsmith has joined #ruby-lang
<any-key>
drbrain: yeah that's the approach we took
<drbrain>
any-key: I think the best thing about Mechanical Turk is that such a solution is cheap to implement
<any-key>
yeah we had our own in-house thing for doing it programatically, it got fairly fancy after a while
andrewsmith has quit [#ruby-lang]
gouthamvel has joined #ruby-lang
dhruvasagar has joined #ruby-lang
<Asher>
is the best way to get an index from a regexp match to pass the match back in to the string with String#index?
srbaker has joined #ruby-lang
<erikh>
are you sure you don't want to use capture references?
<Asher>
well i need the index
<erikh>
e.g. string.gsub(/(foo)/, '\1')
<erikh>
ok
<Asher>
i'm doing a look-ahead regexp match and then slicing it and everything before the match goes into a var
vesan has joined #ruby-lang
<erikh>
sounds like you want a proper grammar system, imo
<Asher>
how do you mean
<apeiros_>
Asher: actually, =~ returns the index
<erikh>
being able to define "slough my_token" and then pull it apart programmatically
<erikh>
e.g., yacc
<Asher>
apeiros_ - perfect, thanks
<Asher>
erikh - it's for parsing url paths i think a parser would be a little heavy
<erikh>
actually there's BNF for parsing URLs, you might be surprised
<erikh>
a proper url parser is a lot harder than people give credit to
<drbrain>
erikh: if it's a context-free BNF you should be able to do it with regexp
<erikh>
drbrain: should and "is a smart idea" are two different things
<erikh>
anyhow :)
<any-key>
the URI library does a good job, or am I missing the problem?
<drbrain>
yeah, but I think URI in ruby uses just regexp
<erikh>
URI is just regexp? I'm surprised by that.
ahs3- has joined #ruby-lang
<any-key>
I'd imagine it'd be a real parser of sorts
<Asher>
hm what if i want the index and the match?
<drbrain>
it's really weird inside, there may be some context, but it seems to mostly glue together reusable regexp parts
<Asher>
oh use last match i guess eh
<drbrain>
Asher: $&, too
<Asher>
how is $& different from $~
<erikh>
one of them is the whole match and the other's the MatchData object
<erikh>
I can't remember which is which
<drbrain>
$~ is a MatchData object, $& is just the string matched
<drbrain>
you can get $& from $~ by calling a method (I forget which one)
<cirwin>
erikh: pretty much — though you have to also re-order some combining characters
Radium has joined #ruby-lang
justinmcp has joined #ruby-lang
<duckinator>
why does $SAFE=3 block ENV[], as opposed to just ENV[]=? there's no real benefit: I've found two ways to get items inside it. nicest of which is Hash[ENV.to_a]
<duckinator>
The other method I tried, before I remembered Hash#to_a, has to be more tailored to the key you want. ie, ENV.inspect.split('"SSH_CONNECTION"=>"')[1].split(' ')[0] gets the first word from ENV['SSH_CONNECTION'] if it's set, which is the IP of whoever started the process
dfr|mac has joined #ruby-lang
<drbrain>
ugh, one bug left ☹
<drbrain>
duckinator: $SAFE = 3 and $SAFE = 4 are designed for sandboxing
<drbrain>
but I think $SAFE = 3 is not considered very useful
<drbrain>
there's a ticket open to remove $SAFE in ruby 3
<duckinator>
hmm
Nisstyre has joined #ruby-lang
<imperator>
death to $SAFE!
<duckinator>
drbrain: i'm basically using it for disabling file/socket access, tbh -- i could probably achieve similar things by blocking require and Object.instance_eval{remove_const "blah"}
<imperator>
Sandboxes FTW
<duckinator>
the awesome fakefs gem handles files, actually...hmm
<duckinator>
i might not need $SAFE at all after some tweaking, bahahaha
<drbrain>
$SAFE is not super useful, unfortunately
<duckinator>
but yea, i know what $SAFE is for -- but blocking ENV[] seems just plain silly, considering the multitude of ways around it
S1kx has joined #ruby-lang
kesor has joined #ruby-lang
prsimp has joined #ruby-lang
prsimp has quit [#ruby-lang]
ahs3- has joined #ruby-lang
ahs3- has joined #ruby-lang
<andrewvos>
duckinator: Whoa! You've found something in Ruby that's silly!
<duckinator>
andrewvos: astounding, right?!
<shevy>
I found something too
<shevy>
Encoding
<shevy>
:>
ahs3- has joined #ruby-lang
retro|cz has joined #ruby-lang
<cirwin>
shevy: Encoding is great!!! you can have a string in any encoding you like and you can set the encoding to anything you like!!!
ahs3- has joined #ruby-lang
srbartlett has joined #ruby-lang
<shevy>
cirwin yeah
<shevy>
I always needed this
mikeric has joined #ruby-lang
vesan_ has joined #ruby-lang
rushanuk has joined #ruby-lang
jordan` has quit [#ruby-lang]
udzinari has quit ["ERC Version 5.3 (IRC client for Emacs)"]
ahs3- has joined #ruby-lang
ahs3-_ has joined #ruby-lang
rushanuk has joined #ruby-lang
<andrewvos>
hhahaahah
<andrewvos>
hahah
<andrewvos>
ha
<andrewvos>
h
<matti>
LOL
<matti>
andrewvos: Do a christmas tree now!
<andrewvos>
I would, but I might end up in #ruby.
<matti>
Don't worry.
<matti>
You've nearly classified.
<matti>
:)
chimkan_ has joined #ruby-lang
<andrewvos>
Dear diary, Today shevy was hilarious.
Spooner has joined #ruby-lang
ahs3- has joined #ruby-lang
bawer has joined #ruby-lang
postmodern has joined #ruby-lang
Stalkr_ has joined #ruby-lang
m3nd3s has joined #ruby-lang
<shevy>
andrewvos I rock
<matti>
shevy: Do you have gruppies already
<matti>
?
<shevy>
matti hmm half a handful of loyal followers
<shevy>
we will change the world
<matti>
:>
benanne has joined #ruby-lang
<matti>
shevy +1
thone has joined #ruby-lang
fgomez has joined #ruby-lang
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
heftig has joined #ruby-lang
kvirani has joined #ruby-lang
rking has joined #ruby-lang
jnraine has joined #ruby-lang
t has joined #ruby-lang
fgomez has joined #ruby-lang
deryl has joined #ruby-lang
deryl has quit [#ruby-lang]
tonesfrommars has joined #ruby-lang
nofxx has joined #ruby-lang
dfr|mac has joined #ruby-lang
Stalkr_ has joined #ruby-lang
Jay_Levitt has joined #ruby-lang
seanstickle has joined #ruby-lang
woollyams has joined #ruby-lang
Tearan has joined #ruby-lang
justinmcp has joined #ruby-lang
tyfighter has joined #ruby-lang
andkerosine has joined #ruby-lang
nanothief has joined #ruby-lang
<andkerosine>
HTML/CSS/JS to GTK: even remotely feasible?
<seanstickle>
Yes. Remotely feasible.
<andkerosine>
Fuckin' asymptotes: how they do work?
fgomez has joined #ruby-lang
bglusman has joined #ruby-lang
vesan has joined #ruby-lang
dous has joined #ruby-lang
Jay_Levitt has joined #ruby-lang
codewrangler has joined #ruby-lang
<heftig>
andkerosine: what exactly?
curtism has joined #ruby-lang
WillMarshall has joined #ruby-lang
<andkerosine>
heftig: What?
<andkerosine>
That is, "what exactly" what?
<heftig>
...you mean by "HTML/CSS/JS to GTK"
<andkerosine>
Are you familiar with GTKBuilder?
<heftig>
i've played around with glade
<andkerosine>
Mm-hmm. Well, I'm tempted to try my hand at converting a "Web" layout to a GTK interface.
<andkerosine>
But the more I think about it, the more it strikes me as way too ambitious.
<heftig>
you could use a webkit widget
<andkerosine>
I know.
mattonrails has joined #ruby-lang
<andkerosine>
The problem is pretty much solved, I guess, but I was mostly interested in the actual guts of the problem.
<andkerosine>
Converting JavaScript to signals and so forth.
sora_h has joined #ruby-lang
<chris2>
Enumerable#select == Enumerable#find_all
<chris2>
Hash#select != Hash#find_all
<chris2>
who thought that was a good idea?
<any-key>
Matz
<any-key>
and don't you DARE question Matz
<chris2>
reasoning?
<any-key>
ask him
<any-key>
chris2: find_all is courtesy of enumerable, whereas select is implemented in Hash
<chris2>
yes
<any-key>
Hash isn't really the same as an array so the behavior is slightly different
<any-key>
although I can't give you a good reason
<andkerosine>
Is it possible to define UTF-8 unary methods?