darkf [darkf!~darkf_dix@unaffiliated/darkf] has joined #ruby-lang
gnufied [gnufied!~gnufied@122.172.224.153] has joined #ruby-lang
lantins [lantins!~lantins@mx0.lividpenguin.com] has joined #ruby-lang
imperator [imperator!~Daniel@63-225-247-192.hlrn.qwest.net] has joined #ruby-lang
Pip [Pip!~Pip@176.214.13.82] has joined #ruby-lang
Pip [Pip!~Pip@unaffiliated/pip] has joined #ruby-lang
SuperTaz_work [SuperTaz_work!~supertaz_@38.99.52.59] has joined #ruby-lang
kitallis [kitallis!~kitallis@122.172.248.47] has joined #ruby-lang
RomyEatsDrupal [RomyEatsDrupal!~stickycak@cpe-69-203-115-155.nyc.res.rr.com] has joined #ruby-lang
gianlucadv [gianlucadv!~gianlucad@host61-81-dynamic.245-95-r.retail.telecomitalia.it] has joined #ruby-lang
yumike [yumike!~yumike@213.154.168.130] has joined #ruby-lang
<erikh>
google does that with their search results
<erikh>
open-uri can take a hash of options, although I'd have to do a source dive to find out how to specify them
<erikh>
I have some code around here that does it
<erikh>
at least sometime this month I did something resemblingt hat
<erikh>
ah I see
<erikh>
just specifying an unrecognized option makes it a header
<erikh>
andrewhl: ^^
<andrewhl>
hmm
<erikh>
so open(uri, "User-Agent" => "MSIE bla bla")
<andrewhl>
oh, very cool
wyhaines [wyhaines!~wyhaines@65.39.118.15] has joined #ruby-lang
<andrewhl>
what are valid user agents? Is there a list somewhere?
<RomyEatsDrupal>
hi...
<RomyEatsDrupal>
anyone in this room hear of Hungry Academy?
darkf [darkf!~darkf_dix@unaffiliated/darkf] has joined #ruby-lang
kylemcgill [kylemcgill!~kylemcgil@static-ip-202-90-56-14.watchdog.net.nz] has joined #ruby-lang
<esufan>
is there a fast way to get the directory of a file open in a folder?
<crassus>
RomyEatsDrupal: yeah why
<RomyEatsDrupal>
crassus: i wonder if thy are changing the program
<RomyEatsDrupal>
at first they wrote 5 months, and then 'you may be offered a position here'
<imperator>
esufan, not sure what you mean exactly; if you just want the directory of a file, File.dirname
<RomyEatsDrupal>
then i saw they had changed that to '18 month commitment required post acadmey'
savage- [savage-!~savage-@c-67-180-11-89.hsd1.ca.comcast.net] has joined #ruby-lang
<esufan>
C:\x\x\x\x\x\
<crassus>
RomyEatsDrupal: that was all there before
<esufan>
i want co copy
<crassus>
and besides, the application date has passed
<esufan>
and say cd
<esufan>
cd
<esufan>
cd \x\x\x\x
<imperator>
esufan, Dir.chdir(File.basename(dir)) - like that?
<RomyEatsDrupal>
crassus no, it had said '5 months, and then you may be offered a position here'
<imperator>
er, File.dirname(file)
<crassus>
right, and part of that offer means signing on for 18 months with them, if you get offered even
<RomyEatsDrupal>
crassus: yes, i already submitted my application. but after the program i wanted to be able to go back to New York instead of being trapped in DC
* imperator
looks up hungry academy
<crassus>
well, America is the land of at-will employment RomyEatsDrupal, no-one's gonna chain you to a desk ;)
hallucinations [hallucinations!~hallucina@111.93.148.118] has joined #ruby-lang
<crassus>
imperator: salve
<imperator>
crassus, heard the persians got ya
<crassus>
only my head
<RomyEatsDrupal>
crassus: i hope so. one of my friends said there might be substantial legal issues if one doesn't follow through with the commitment or leave early
<crassus>
RomyEatsDrupal: maybe you want to ask in #startups, there's probably people who've applied there
dfr|mac [dfr|mac!~dfr|work@ool-18baf7e7.dyn.optonline.net] has joined #ruby-lang
dreinull [dreinull!~dreinull@ip-78-94-220-161.unitymediagroup.de] has joined #ruby-lang
<shevy>
so I have a time object ... like Wed Jan 04 05:49:12 0000 2012
<shevy>
how to easily fetch just the "05:49" part?
<shevy>
oh wait
<shevy>
got it
<shevy>
.strftime works
<shevy>
x.strftime "%H:%M"
ovnimancer [ovnimancer!~anton@212.59.96.38] has joined #ruby-lang
hallucinations [hallucinations!~hallucina@111.93.148.118] has joined #ruby-lang
JackNorris [JackNorris!~JackNorri@92.48.86.35] has joined #ruby-lang
cynosure [cynosure!~cynosure@centrumnet.hu] has joined #ruby-lang
<shevy>
anyone knows offhand... how to use a Range object in yaml?
esufan [esufan!~nekid@c-24-6-170-1.hsd1.ca.comcast.net] has joined #ruby-lang
<shevy>
oh
<shevy>
I guess I can write this in irb, then save it into yaml and have a look
srbaker [srbaker!~srbaker@184.66.82.213] has joined #ruby-lang
molgrew [molgrew!~bozo20@85.182.139.18] has joined #ruby-lang
<manveru>
why is that using BigDecimal anyway, he's never using decimal
<manveru>
time for some hardcore forking action
<yorickpeterse>
"elsif version.to_str.starts_with? '1.1.3'" the fuck is this shit
<manveru>
:P
<manveru>
does anyone know what that silly Guardfile stuff is?
<manveru>
:q
<yorickpeterse>
Eh, it's some test tool if I believe
kitallis [kitallis!~kitallis@122.172.248.47] has joined #ruby-lang
thrcka [thrcka!~thrcka@ip-89-102-34-33.net.upcbroadband.cz] has joined #ruby-lang
<manveru>
what was the gem to control time again?
<manveru>
ah, timecop
gnufied [gnufied!~gnufied@122.172.224.153] has joined #ruby-lang
dc5ala [dc5ala!~dc5ala@stgt-5f70c875.pool.mediaWays.net] has joined #ruby-lang
jasox [jasox!~jasox@178.239.26.139] has joined #ruby-lang
<manveru>
maybe time-warp is nicer
enikar [enikar!~gil@cl-140.mrs-01.fr.sixxs.net] has joined #ruby-lang
davidw [davidw!~davidw@host228-251-static.95-94-b.business.telecomitalia.it] has joined #ruby-lang
shevy [shevy!~shevy@194-166-29-132.adsl.highway.telekom.at] has joined #ruby-lang
ovnimancer [ovnimancer!~anton@212.59.96.38] has joined #ruby-lang
ovnimancer [ovnimancer!~anton@212.59.96.38] has quit [#ruby-lang]
ryez [ryez!81c0c418@gateway/web/freenode/ip.129.192.196.24] has joined #ruby-lang
zmack [zmack!~zmack@78.97.143.6] has joined #ruby-lang
uniqanomaly [uniqanomaly!~ua@dynamic-78-8-82-230.ssp.dialog.net.pl] has joined #ruby-lang
<yorickpeterse>
There we go, pull request sent. Now lets hope this redmine plugin author is still active (last commit was in May :[)
ryez [ryez!81c0c418@gateway/web/freenode/ip.129.192.196.24] has joined #ruby-lang
<ddfreyne>
i don't have enough time to handle all the pull requests and issues that i get :(
<ddfreyne>
nor all the mailing list messages
<ddfreyne>
it's frustrating
<yorickpeterse>
I'd be happy to get any at all :)
hallucinations1 [hallucinations1!~hallucina@111.93.148.118] has joined #ruby-lang
<ddfreyne>
hehe
<ddfreyne>
it also tends to get a bit tedious since i don't get paid for it (apart from the occasional donation)
<ddfreyne>
and i'd have to spend a lot of time handling issues and pull requests
<ddfreyne>
74 threads (not messages) in my inbox, and that's for nanoc only (not my general inbox)
<ddfreyne>
i'd need a few fulltime days to go through all that
zmack_ [zmack_!~zmack@78.97.129.28] has joined #ruby-lang
zmack [zmack!~zmack@78.97.143.6] has joined #ruby-lang
robgleeson [robgleeson!~rob@subtle/contributor/robgleeson] has joined #ruby-lang
rippa [rippa!~splitta@85.158.54.234] has joined #ruby-lang
crudson [crudson!~doug@c-67-171-219-209.hsd1.or.comcast.net] has quit [#ruby-lang]
<yorickpeterse>
jezus
gianlucadv [gianlucadv!~gianlucad@rna.bio.disco.unimib.it] has joined #ruby-lang
WillMarshall [WillMarshall!~willmarsh@203.118.179.237] has joined #ruby-lang
<rue>
ddfreyne: Time to pass on maintainership?
<ddfreyne>
rue: nope, I still work on it, but I just can't cope with the volume of community related work
<ddfreyne>
still, a second maintainer would be useful
<josh9>
how to delete elements from array and save the deleted elements while doing it? b = a.delete_if{|num| num == 2 } set both a and b to the array without the elements.
<josh9>
and reject! is the same
<manveru>
josh9: partition
<manveru>
>> [1,1,2,2,3,3].partition{|e| e == 2 }
<manveru>
=> [[2, 2], [1, 1, 3, 3]]
<rue>
Need to reassign, then, but it's better than doing a #reject + #reject! or something…
<manveru>
yeah, it's not destructive
<rue>
Or I suppose. #dup.select might too?
<rue>
s/
<josh9>
manveru: partition looks great!
<manveru>
well, you can implement partition with select by running it twice and inverting the condition... but that's neither concise nor fast
<rue>
Same problem as #reject, yes
<manveru>
so yeah, you could do it with inject in one pass... but that would look quite mind-bending
<rue>
Damn it, I'm still not used to this FI layout keyboard. It's got a small enter key, so \, | is where enter normally is on a US keyboard, and the left shift is small, with ~ next to it instead of top left
<rue>
#partition is indeed probably the clearest
<manveru>
>> [1,1,2,2,3,3].each_with_object([[],[]]){|e,(i,o)| e == 2 ? i << e : o << e }
<manveru>
=> [[2, 2], [1, 1, 3, 3]]
RomD [RomD!~Roman@nrbg-d9322fd4.pool.mediaWays.net] has joined #ruby-lang
<manveru>
now i'm down to writing code i hate myself :)
<rue>
I think a better solution would probably be to have a method for that
<rue>
Or repurpose Array#delete_if since it's not bound by Enumerable
<manveru>
for what?
<rue>
To return the deleted items
<manveru>
nah
<manveru>
>> deleted = []; arr = [1,1,2,2,3,3].reject!{|e| deleted << e if e == 2 }; [deleted, arr]
<manveru>
=> [[2, 2], [1, 1, 3, 3]]
<manveru>
that's hardly worth making a new method for
<rue>
Well, the thing is, #delete_if and #reject! are the same except the latter can return nil; instead of that duplication, it might be useful to support this case instead
<rue>
It could be useful in a queue-type situation where you e.g. want to do something final with the removed elements. You can do it manually, sure
<josh9>
manveru: very nice implementation of partition!
Spooner [Spooner!~Miranda@host-78-144-139-130.as13285.net] has joined #ruby-lang
tekin [tekin!~tekin@cpc8-with5-2-0-cust208.1-4.cable.virginmedia.com] has joined #ruby-lang
havenn [havenn!~skipper@pool-72-67-31-69.lsanca.fios.verizon.net] has joined #ruby-lang
<manveru>
don't use the time-warp gem if you want nanosecond precision
<havenn>
**I've gotten pawn and knight rules mostly working, still a work in progress** >.>
<andrewvos>
mumble tdd mumble mumble
<robgleeson>
havenn: too much code for a quick review :)
<havenn>
aye, and TDD fail. Was too much of a meandering adventure to know what I was speccing. =P
<havenn>
I do love Minitest. =)
kyrylo [kyrylo!~kyrylo@46.118.236.196] has joined #ruby-lang
kyrylo [kyrylo!~kyrylo@subtle/user/kyrylo] has joined #ruby-lang
WillMarshall [WillMarshall!~willmarsh@203.118.179.237] has joined #ruby-lang
<havenn>
I should probably stop at this point, and add test coverage. Lack-thereof if getting painful, and there is a long way to go. It is congealed enough it should be painless.
gasbakid [gasbakid!~gasbakid@41.96.81.181] has joined #ruby-lang
<IanV>
can anyone help me re mocking a Web Server? basics etc. ie stubbing/mocking http requests, i currently use WEBrick::HTTPServer
<manveru>
IanV: using rack?
<IanV>
I not to sure what to use atm
dr0id [dr0id!~andy@unaffiliated/dr0id] has joined #ruby-lang
<IanV>
i was going to stub WEBrick::HTTPServer calls, bit low level i know, but still learning
<IanV>
i have a WEBRick server
<manveru>
well, rack provides Rack::Mock, which makes things a bit easier
<manveru>
also then you can use gems like rack-test, that help with multipart, cookies, and the like
jMCg [jMCg!~hiro@apache/committer/igalic] has joined #ruby-lang
<IanV>
do you know of any good tuts/egs? the search I didnt seem to help me mock out the request
<manveru>
plus you're not tied to webrick, you can use any other ruby server
<matti>
manveru: :)
<rue>
Hmm, Rack on WEBrick?
<manveru>
IanV: not sure about anything specific
<manveru>
i can write a blog post about it, if you want
<IanV>
lol
niklasb [niklasb!~codeslay0@p5B310883.dip0.t-ipconnect.de] has joined #ruby-lang
<IanV>
ok, im wording(thinking) about what my actually problem is! ...be back..
gokulnath [gokulnath!~gokulnath@115.111.177.122] has joined #ruby-lang
<manveru>
ok, timecop also handles nanoseconds
ramonmaruko [ramonmaruko!~marco@122.52.126.66] has joined #ruby-lang
<andrewvos>
IanV: Either use VCR, or perhaps BBC/rest-assured
<andrewvos>
IanV: Use VCR if you're writing ruby
gix [gix!~gix@e180025047.adsl.alicedsl.de] has joined #ruby-lang
stamina [stamina!~stamina@ip5452a9bc.speed.planet.nl] has joined #ruby-lang
chrismcg [chrismcg!~chrismcg@pdpc/supporter/active/chrismcg] has joined #ruby-lang
burgestrand [burgestrand!~burgestra@host.62.65.124.23.bitcom.se] has joined #ruby-lang
saLOUt [saLOUt!~rriemann@naqasl.physik.hu-berlin.de] has joined #ruby-lang
ryez [ryez!b49d0926@gateway/web/freenode/ip.180.157.9.38] has joined #ruby-lang
chrismcg [chrismcg!~chrismcg@devilfish.octopod.info] has joined #ruby-lang
dnyy [dnyy!u2106@gateway/web/irccloud.com/x-vjjdquvwomjirblj] has joined #ruby-lang
<stephenp>
is there a library for doing affine transforms in ruby? I need to take a rectangle, rotate it 30 and get the new coordinates of the vertices.
<manveru>
should be a lot faster for large files
<manveru>
hm, not much
<lianj>
if you want all lines anyway than then start processing these lines, why not split("\n")?
<manveru>
because it might be \r\n
<lianj>
hm, not in my world ;)
<manveru>
:)
<manveru>
uh
<manveru>
why is /usr/share/dict/finnish in codepage 1250?
<shevy>
because reindeers don't understand unicode
<manveru>
/usr/share/dict/french is UTF-8
<manveru>
german is ISO-8859-2
<shevy>
ONE ENCODING TO BIND THEM
<shevy>
ONE ENCODING TO RULE THEM
<manveru>
spanish is UTF-8
<manveru>
srsly, who is responsible for that mess?
<imperator>
tim bray
gianlucadv [gianlucadv!~gianlucad@109.53.215.226] has joined #ruby-lang
<shevy>
DHH
RomyEatsDrupal [RomyEatsDrupal!~stickycak@cpe-69-203-115-155.nyc.res.rr.com] has joined #ruby-lang
jacobwg [jacobwg!~jacobwg@204.sub-75-254-157.myvzw.com] has joined #ruby-lang
elux [elux!~peter@96.45.198.150] has joined #ruby-lang
rayners [rayners!~rayners@38.102.22.194] has joined #ruby-lang
<rue>
manveru: You're still reading the whole file
<andrewhl>
so I'm trying to use open-uri to access a google scholar page with certain get attributes. I'm getting a 503 error. I believe the issue can be resolved by declaring a user-agent, but I'm not sure on the syntax for it, or what user-agent to declare. Anyone have some insight into this?
<manveru>
rue: of course
<manveru>
andrewhl: i doubt you can set it with open-uri
<manveru>
use Net::HTTP, or just skip to mechanize
<manveru>
or if you like overkill, selenium :)
<any-key>
open-uri is a wrapper around Net::HTTP to make things really easy
<andrewhl>
ahh
<andrewhl>
it's working now. It wasn't working last night
<andrewhl>
must be google had blocked me temporarily
<any-key>
which API are you using?
<any-key>
there's quotas on a lot of them
<andrewhl>
i'm using nokogiri
<rippa>
manveru: you can set it with open-uri
<rippa>
it treats unrecognised options as headers
<andrewhl>
how can I avoid getting blocked? where's the information on it? Is it basically a certain amount of time between requests?
<any-key>
andrewhl: first of all, what website are you interacting with?
<rippa>
Note: The Google Web Search API has been officially deprecated as of November 1, 2010. It will continue to work as per our deprecation policy, but the number of requests you may make per day will be limited.
<manveru>
yeah, it had a big fat deprecation notice there a year ago
<any-key>
don't call it fat, that's meaaannn
savage- [savage-!~savage-@c-67-180-11-89.hsd1.ca.comcast.net] has joined #ruby-lang
<manveru>
so is life
<rue>
Wah-waaaaa
<manveru>
and rue
<rue>
Mwah-moiii
<imperator>
phat!
butchanton [butchanton!~butchanto@adsl-71-146-134-251.dsl.pltn13.sbcglobal.net] has joined #ruby-lang
<manveru>
rippa: the custom search is what i meant with useless
robgleeson [robgleeson!~rob@subtle/contributor/robgleeson] has joined #ruby-lang
<any-key>
I kind of wish Enumerable::include? took a block
<any-key>
even though that wouldn't make sense
<manveru>
how about any?
<any-key>
yeah that's what I used instead
<any-key>
makes more sense :P
<andrewhl>
is it possible to use nokogiri to open a locally saved html file?
<andrewhl>
i guess it must be... it's all dependent on what open-uri can do, no?
<burgestrand>
yes, yes, no
<manveru>
:)
<any-key>
you can feed nokogiri a raw string
<any-key>
so open the file and throw the results at nokogiri
<manveru>
also an IO
<any-key>
it'll gobble them up
<andrewhl>
what's the syntax for opening a local file then?
<manveru>
i usually write File.open, but they're pretty much the same in this case
<Cool_Fire>
How many threads can a single Ruby process run simultaneously?
<manveru>
1
<Cool_Fire>
...
<Okasu>
Cool_Fire: thereads in ruby futile, use fibers
takaokouji [takaokouji!~takaokouj@nat35.mable.ne.jp] has joined #ruby-lang
<burgestrand>
fibers can’t run in parallel
<manveru>
and you have to schedule them yourself
<burgestrand>
Cool_Fire: you can only run one thread in parallel on CRuby, but you can run many many concurrently
<Cool_Fire>
how many many?
<burgestrand>
My guess would be it’s limited to how many you can create before you run out of memory
<Cool_Fire>
My guess would be it's limited by the amount of file descriptors
<burgestrand>
But even if you do that, you can only run so many before the time it takes for ruby to manage the thread outweighs the benefits
<burgestrand>
It also depends a bit on which version of ruby you run, 1.8 or 1.9
<Cool_Fire>
It's not a matter of benefit in this case, but of being able to process all received input
<Cool_Fire>
In fact, it'd be faster without any threading
virunga [virunga!~virunga@151.64.16.113] has joined #ruby-lang
<burgestrand>
*shrug*
<burgestrand>
Anybody ever managed to up a vagrant box successfully?
<manveru>
aye
<burgestrand>
manveru: you ever had problems with the box not responding to SSH?
<manveru>
when you mentioned it the last time :)
<burgestrand>
:p
<manveru>
no
<manveru>
i only played with it a bit, sorry
<burgestrand>
third time doing it, third time new machine I’m testing it out on, third time it fails with the same issue :*
<manveru>
what do you do to keep ssh alive?
<burgestrand>
At least I’m not alone having this issue, but nobody appears to know how to fix it and the author of vagrant kind of closed it yesterday with the response "I don’t know how to fix it so closing" :(
<Cool_Fire>
Also, about threading, doesn't 1.9 use native OS threads?
<burgestrand>
Cool_Fire: it does
<burgestrand>
Cool_Fire: keeps a lock around it to make sure only one thread is running ruby code at a time, but if you write a C extension you can write truly parallel code, as long as it doesn’t execute any ruby
<burgestrand>
Cool_Fire: ruby does it for bignum, for example
<Cool_Fire>
So regardless of the actual amount of cores your system has, Ruby only executes one thread at a time, even with 1.9.x?
<burgestrand>
Cool_Fire: CRuby, yes
<Cool_Fire>
That seems ... odd to say the least
<burgestrand>
Cool_Fire: so you won’t see a difference if you run 64 cores or if you run 1 core
<bougyman>
unless you run multiple interpreters, or an alternate ruby (jruby)
<manveru>
bougyman: well, looks like it was resolved then?
<burgestrand>
manveru: acknowledged, but not resolved
<manveru>
burgestrand: is that only on ubuntu?
<manveru>
i've only used arch
<manveru>
sorry not gonna read all of that until i have to use vagrant again
<burgestrand>
manveru: not sure, I’m trying different ones at the moment :)
<burgestrand>
manveru: great tip with arch, appears to have had better luck with that one, ruby 1.9.3 didn’t seem to like net-ssh though, but 1.9.2 works fine
Pip_ [Pip_!~Pip@unaffiliated/pip] has joined #ruby-lang
* imperator
is baffled by a _mktemp failure on windows
<Cool_Fire>
imperator: I have a mouse by your name.
ascarter [ascarter!~ascarter@209.119.253.66] has joined #ruby-lang
andrewhl [andrewhl!~andrew@67.230.167.29] has joined #ruby-lang
RomyEatsDrupal [RomyEatsDrupal!~stickycak@cpe-69-203-115-155.nyc.res.rr.com] has joined #ruby-lang
<imperator>
dammit, netflix sound and picture are out of sync! i hate that!
* imperator
can't go on
SuperTaz_work [SuperTaz_work!~supertaz_@38.99.52.59] has joined #ruby-lang
kain [kain!~kain@151.64.233.209] has joined #ruby-lang
shivamib [shivamib!~darkside@187.45.255.123] has joined #ruby-lang
eydaimon [eydaimon!~eydaimon@unaffiliated/anywho] has joined #ruby-lang
flip_digits [flip_digits!~textual@c-76-122-14-228.hsd1.fl.comcast.net] has joined #ruby-lang
<eydaimon>
http://pastie.org/3179408 <-- this behavior always throws me off. thoughts on why it's like this?
<eydaimon>
am I missing something fundamental
<stderr->
get hasn't been called, what's to miss?
wallerdev [wallerdev!~wallerdev@72.44.102.30] has joined #ruby-lang
<eydaimon>
huh?
<eydaimon>
the problem is Moo::FOO
<eydaimon>
not 'get'
<imperator>
you haven't set FOO to anything
<imperator>
oh, i see what you're saying
<shevy>
he is saying Moo
<RomyEatsDrupal>
hi room, can anyone recommend an online hosting solution that allows root access so I can install gems and rails/etc via SSH/command line for affordable prices? I am NOT a company, just a single web developer/designer. I'd like to use it to deploy multiple blogs, CMS's, rails apps of my own curiosities, etc. Preferably pretty cheap, I do not anticipate more than a hundred hits a day (I'm only at 30 hits a day on my own per
<RomyEatsDrupal>
wordpress website). I heard people recommend Rackspace and Linode, anyone prefer one over the other? Thanks! <3 Romy
<eydaimon>
shevy: I often use a Cow class in my examples too :)
<RomyEatsDrupal>
(currently i use MediaTemple but it does NOT give root access which SUCKS)
apeiros_ [apeiros_!~apeiros@77-58-113-31.dclient.hispeed.ch] has joined #ruby-lang
<andrewhl>
basic question: I have a CSV I'm reading: CSV.foreach("test.csv") do |row|... how can I just read say the first 30 rows?
<andrewhl>
I guess this is a general question about loops... how do you restrict them to only running a certain number of times?
<apeiros_>
CSV.enum_for(:foreach, "test.csv").first(30).each do |row| …
<andrewhl>
wow, ok
<andrewhl>
.first can take an argument? cool
Yu\2 [Yu\2!~Yu@ubi-1-50-54.zif.uni-bielefeld.de] has joined #ruby-lang
<eydaimon>
no opinions about that anyone?
<apeiros_>
eydaimon: on what?
IanV [IanV!~chatzilla@host109-145-182-81.range109-145.btcentralplus.com] has joined #ruby-lang
mrsolo [mrsolo!~mrsolo@64.125.181.73] has joined #ruby-lang
<eydaimon>
apeiros_: http://pastie.org/3179408 <-- this behavior always throws me off. thoughts on why it's like this?
wmoxam [wmoxam!~wmoxam@pdpc/supporter/active/wmoxam] has joined #ruby-lang
davidw [davidw!~davidw@adsl-ull-122-110.51-151.net24.it] has joined #ruby-lang
<apeiros_>
eydaimon: use self.class::Foo
<apeiros_>
but no, I don't have an opinion on it.
toretore [toretore!~toretore@crr06-3-82-231-12-81.fbx.proxad.net] has joined #ruby-lang
mark_azevedo [mark_azevedo!~mark_azev@adsl-76-228-82-246.dsl.pltn13.sbcglobal.net] has joined #ruby-lang
indstry [indstry!~apple@c-71-238-98-243.hsd1.mi.comcast.net] has joined #ruby-lang
amerine [amerine!~mturner@67.204.184.82] has joined #ruby-lang
spleeze [spleeze!~Spleeze@173-15-131-114-BusName-Philadelphia.hfc.comcastbusiness.net] has joined #ruby-lang
darkf [darkf!~darkf_dix@unaffiliated/darkf] has joined #ruby-lang
macmartine [macmartine!~macmartin@069-064-227-254.pdx.net] has joined #ruby-lang
brianpWins [brianpWins!~brianpWin@S01060024369f54ba.vn.shawcable.net] has joined #ruby-lang
Weems [Weems!~the@nat.resnet.mc.edu] has joined #ruby-lang
Weems [Weems!~the@unaffiliated/weems] has joined #ruby-lang
lsegal [lsegal!jinx@modemcable249.109-177-173.mc.videotron.ca] has joined #ruby-lang
abentspoon [abentspoon!~micah@173.247.201.130] has joined #ruby-lang
<slyphon>
injekt: ping?
bglusman [bglusman!~bglusman@c-71-224-192-35.hsd1.pa.comcast.net] has joined #ruby-lang
mark_azevedo [mark_azevedo!~mark_azev@adsl-76-228-82-246.dsl.pltn13.sbcglobal.net] has joined #ruby-lang
<slyphon>
drbrain: around?
<drbrain>
hi
<slyphon>
hey, quick question
<slyphon>
sooo, i've written this internal rubygems distribution thing
<drbrain>
and?
<slyphon>
sorry, i'm getting there
<slyphon>
we have an openstack storage cluster, and i wrote something to sync gems down and reindex
<slyphon>
teh syncing down works, but when i run a "quick update" for the indexes, sometimes it doesn't "show up"
<slyphon>
new gems that is
<slyphon>
so i run gem generate_index --update -d /path/to/gems
<slyphon>
i'm not sure what to check
<drbrain>
it should print out more stuff with -V
robgleeson [robgleeson!~rob@subtle/contributor/robgleeson] has joined #ruby-lang
<slyphon>
hm, mmkay
* slyphon
tries that
shevy [shevy!~shevy@194-166-29-132.adsl.highway.telekom.at] has joined #ruby-lang
cylence [cylence!~cylence@64-71-24-18.static.wiline.com] has joined #ruby-lang
dnjaramba [dnjaramba!~dnjaramba@41.72.193.86] has joined #ruby-lang
lsegal [lsegal!jinx@modemcable249.109-177-173.mc.videotron.ca] has joined #ruby-lang
kamalreddy [kamalreddy!~coder@202.3.77.231] has joined #ruby-lang
<kamalreddy>
hi
g0bl1n [g0bl1n!~g0blin@unaffiliated/g0bl1n] has joined #ruby-lang
robbrit [robbrit!~rob@38.108.76.250] has joined #ruby-lang
andrewhl [andrewhl!~andrew@67.230.167.24] has joined #ruby-lang
<andrewhl>
I have this: CSV.enum_for(:foreach, "test.csv").first(5).each do |row|, which does the first five rows. How can I do a range of rows, like say rows 30-50?
kyrylo [kyrylo!~kyrylo@46.118.222.71] has joined #ruby-lang
kyrylo [kyrylo!~kyrylo@subtle/user/kyrylo] has joined #ruby-lang
<rue>
Depending, you might just do a #to_a, or then drop n and then grab m
tychobrailleur [tychobrailleur!~sebastien@176.61.72.130] has joined #ruby-lang
dfr|mac [dfr|mac!dfr|work@nat/google/x-pkwmhyvcdkkhjhux] has joined #ruby-lang
<apeiros_>
andrewhl: .first(50).last(20)
<andrewhl>
will that start at #50?
<apeiros_>
since the size of a row is undefined, you can't do something akin to skipping
<apeiros_>
no, that'll give you 30-50
<andrewhl>
I see
<apeiros_>
it first takes the first 50, and the last 20 out of those 50
<andrewhl>
ah
<andrewhl>
and if I want to say go from #30 to the end?
<apeiros_>
chaining always works on the result of the former method
<rue>
I'd go .drop(29).first(20) :)
<rue>
Or something.
<apeiros_>
probably more efficient…
<rue>
Or perhaps you want #each_slice instead
mdel [mdel!~mdel@pool-71-175-17-16.phlapa.fios.verizon.net] has joined #ruby-lang
<apeiros_>
andrewhl: if you need to do lots of index based operations on the csv, why don't you read it all into a table and use the normal [] method?
<andrewhl>
the csv is really simple, it's just one column
<apeiros_>
I think it was something like: csv = CSV.read(path); csv[row][cell]…
<apeiros_>
uh, then… read it all and use .transpose
niklasb_ [niklasb_!~codeslay0@p5B310883.dip0.t-ipconnect.de] has joined #ruby-lang
<andrewhl>
all I need to do is start at x and go to the end at this point
<andrewhl>
that should be easy enough, no?
<apeiros_>
drop(n).each, as rue suggested
<andrewhl>
ah interesting
<apeiros_>
or drop(n).to_a
<apeiros_>
if you just want it in an array.
<apeiros_>
also [[1],[2],[3]].transpose # => [[1, 2, 3]]
niklasb [niklasb!~codeslay0@p5B310883.dip0.t-ipconnect.de] has joined #ruby-lang
<andrewhl>
ok cool. thanks
<apeiros_>
oh wow, drop returns an Array? that's sad…
<rippa>
yes
<rippa>
we need new drop
<apeiros_>
I expected Enumerable#drop # => Enumerator
<rippa>
and lazy versions of other enumerable methods
<rippa>
like map
<rippa>
and select
<apeiros_>
mhm
<apeiros_>
would be more unixy too
<rue>
Hm, #drop hasn't been Enumeratorized yet?
<rue>
That's silly.
<manveru>
it doesn't take a block
<shevy>
drop('cats') { ' and bunnies' }
flip_digits [flip_digits!~textual@c-76-122-14-228.hsd1.fl.comcast.net] has joined #ruby-lang
<rue>
Well, the block isn't necessarily the point of an Enumerator
<rue>
Consider the #next-type generator usage
<apeiros_>
Enumerator vs. Enumerable
<rue>
(And obviously in this case, laziness to avoid reading who knows how many rows up front)
leonL [leonL!~leonl@CPE0024a5b652a3-CM000f21205d86.cpe.net.cable.rogers.com] has joined #ruby-lang
cschneid [cschneid!~cschneid@li291-24.members.linode.com] has joined #ruby-lang
robgleeson [robgleeson!~rob@subtle/contributor/robgleeson] has joined #ruby-lang
cschneid [cschneid!~cschneid@li291-24.members.linode.com] has joined #ruby-lang
zmack [zmack!~zmack@78.97.133.243] has joined #ruby-lang
benanne [benanne!~rijdier@2.185-241-81.adsl-dyn.isp.belgacom.be] has joined #ruby-lang
dfr|mac [dfr|mac!dfr|work@nat/google/x-rkljpvjisyiitpca] has joined #ruby-lang
<manveru>
well, try (1..(1/0.0)).drop(10)
<manveru>
drop relies on #each, just as everything else
<apeiros_>
manveru: yes, cases like that are kinda the point of wanting drop return Enumerator
<apeiros_>
that OTOH is not the point :)
<apeiros_>
of course it relies on .each, it doesn't need to try to convert the result to an array…
<apeiros_>
+but
shivamib [shivamib!~darkside@187.45.255.123] has quit ["Leaving"]
<manveru>
it can't be lazy if it has to find the last element first
<apeiros_>
hu?
<apeiros_>
it doesn't have to find the last element
adambeynon [adambeynon!~adambeyno@82-69-1-211.dsl.in-addr.zen.co.uk] has joined #ruby-lang
<apeiros_>
drop(n) drops the first n elements in the enumeration
<rue>
Precis
<manveru>
oh, not the last?
<manveru>
damnit
<apeiros_>
:)
<apeiros_>
but even with the last, it could be lazy
<apeiros_>
it'd need a buffer of size N, though
<rue>
Well, not lazy, but it wouldn't need to retain the dropped values
<apeiros_>
using a ringbuffer, that can be implemented relatively efficient
<manveru>
hm
<manveru>
drop_while returns an enum
<rue>
Ah! There's maybe a good reason for it being separate
<rue>
Probably not.
<rue>
s/separate/different/
<manveru>
well, only if you don't pass a block
<manveru>
so... not very helpful
guns [guns!~guns@c-98-228-72-208.hsd1.il.comcast.net] has joined #ruby-lang
ricardovaleriano [ricardovaleriano!~ricardova@189-69-29-244.dsl.telesp.net.br] has joined #ruby-lang
<dreinull>
it's geting late. I have users in my Array and want to group by user, not by role: {:admins => ary1, :moderators => ary2, users => ary3}
<apeiros_>
dreinull: you mean in aryN's you have users? or what?
<apeiros_>
so you want {user => roles, …}?
<dreinull>
apeiros_: yes, my fault. And there is no hierarchy
<dreinull>
apeiros_: yup
<dreinull>
I do have to sort them somehow, right? There is no readymade method for that I can think of right now.
<apeiros_>
by_user = Hash.new { |h,k| h[k] = [] }; by_roles.each do |role, users| users.each do |user| by_user[user] << role end end
* apeiros_
still doesn't get why there's no Hash#default_proc=
<manveru>
>> h = {admins: [1,2,3], moderators: [4,2,3], users: [7,5,4,1]}.invert
<apeiros_>
manveru: problem if users are in multiple roles
<manveru>
might not be helpful, but i guess i don't understand the problem
<manveru>
dreinull: what output do you want?
<apeiros_>
also I guess he wants single users as keys
<dreinull>
sec
<dreinull>
yes, users as keys and users can be in different roles
<dreinull>
manveru: no, I'm not looking for inversion.
spleeze [spleeze!~Spleeze@173-15-131-114-BusName-Philadelphia.hfc.comcastbusiness.net] has joined #ruby-lang
<manveru>
.each_with_object(Hash.new{|k,v| k[v] = []}){|(k,v),o| v.each{|u| o[u] << k }}
<manveru>
but yeah, same as apeiros_
<dreinull>
great, I had to reformat to see how it works :)
<dreinull>
thanks a lot.
<manveru>
yw
<dreinull>
{manveru:"<3", apeiros_:"<3"}
<rue>
Oh, anyone know about the keyword args proposal for 2.0?
<rue>
I think igrigorik was saying it'd replace the hash syntax, but that can't be…
<robgleeson>
they're always optional arguments
<robgleeson>
entire thread on redmine about them
robbrit [robbrit!~rob@38.108.76.250] has quit [#ruby-lang]
dejongge1 [dejongge1!~jonke@pD9E0DEED.dip0.t-ipconnect.de] has joined #ruby-lang
eydaimon [eydaimon!~eydaimon@unaffiliated/anywho] has quit ["WeeChat 0.3.6"]
zmack [zmack!~zmack@78.97.143.6] has joined #ruby-lang
dv310p3r [dv310p3r!~dv310p3r@host-208-68-238-122.biznesshosting.net] has joined #ruby-lang
butchanton [butchanton!~butchanto@vpn-sanfran.exacttarget.com] has joined #ruby-lang
Indian [Indian!~Indian@unaffiliated/londonmet050] has joined #ruby-lang
queequeg1 [queequeg1!~chatzilla@c-71-202-152-67.hsd1.ca.comcast.net] has joined #ruby-lang
Filuren [Filuren!~Filuren@x1-6-e0-46-9a-1f-97-a2.k617.webspeed.dk] has joined #ruby-lang
<Filuren>
Hello
cyri_ [cyri_!~cyri_@jem75-1-87-88-118-80.dsl.sta.abo.bbox.fr] has joined #ruby-lang
<visof>
Filuren: hi
<Filuren>
Is this a dead IRC? Lots of peeps connected, but no talk
<apeiros_>
we're using telepathy
<rippa>
that's called "IRC"
<rippa>
that's how it usually is
<apeiros_>
after years of bad questions and lots of assumptions in the sense of "it's obvious what I mean/everybody knows that", we finally developed that power…
<Filuren>
Would like to learn telepathy
<visof>
apeiros_: can i ask you question?
<visof>
it will be another bad question
<apeiros_>
visof: as long as it's in the channel, just go ahead
<visof>
yeah it's
<visof>
how many years you coded in Ruby?
<Filuren>
Is this the place to ask some noobish question? I am new to ruby
<apeiros_>
~7 I think
<visof>
Filuren: yeah sure
<apeiros_>
Filuren: yes. just ask.
<visof>
apeiros_: wonderful
<Filuren>
Cool! Okay, I recently joined the learning of Ruby and I really like the simplicity (only skimmed other languages, I have no prior experience in programming)
<Filuren>
What I fail to see, for what real world examples can Ruby be used? Which problems can it solve?
<apeiros_>
Filuren: ruby is a general purpose language, meaning you can use it for about everything
<apeiros_>
you wouldn't want to use it on embedded or other resource constrained machines, though.
<visof>
apeiros_: everything?
<apeiros_>
everything. note that this doesn't mean it is the best tool for everything.
<visof>
OK
<wmoxam>
program all the things with Ruby!
<Filuren>
wmoxam: lol
<Filuren>
apeiros_: do you have any great 'projects' for a noob? I know about loops, class, methods etc.
<Filuren>
Nothing complex, just something where I can try out the skills I learned
<apeiros_>
Filuren: nope, sorry. I think my first project was an irc bot
<apeiros_>
but what you could do - no idea. scratch an itch of yours?
<Filuren>
not familiar with that expression, what does "scratch an itch of yours" mean?
<visof>
Filuren: do you like Math?
<Filuren>
visof: Going to mention Project Euler? :P
<visof>
Filuren: yep
<Filuren>
I've taken a look, and I gotta say, I won't even know how I should approach with an advanced calculator
<Filuren>
The first few are simple, but I just don't know the algorithms to solve it
<visof>
Filuren: you can even write brainfuck interpreter
<Filuren>
++++,++++,> or how it looks
<visof>
maybe you can write regular expressions interpreter too
<apeiros_>
Filuren: it means if you have something that you need solved for yourself, try to solve that.
<apeiros_>
I needed something to operate an irc channel, that's why I wrote an irc bot. I scratched my own itch.
<shevy>
butler!
<apeiros_>
yes
<Filuren>
apeiros_: Ahh, I do have one thing I could try to make. Not sure if it's too complexed, but I will find out
<Filuren>
visof: What is regular expressiosns interpreter? Is it the same as regex?
<Filuren>
apeiros_: How did you teach yourself Ruby? Books, school or a personal trainer?
<visof>
Filuren: maybe
<apeiros_>
Filuren: irb, trial & error, irc, pickaxe - about in that order
<apeiros_>
oh, forgot ri
petercooper [petercooper!~petercoop@82.144.254.2] has joined #ruby-lang
<apeiros_>
I found ruby to be quite intuitive, and irc helped me a ton getting to write idiomatic ruby and undo years of php mutilation.
<apeiros_>
but having known perl before php and ruby helped
<apeiros_>
(ruby is highly influenced by perl)
artOfWar_ [artOfWar_!~artofwar@108-205-201-30.lightspeed.sntcca.sbcglobal.net] has joined #ruby-lang
WillMarshall [WillMarshall!~willmarsh@203.118.179.237] has joined #ruby-lang
<Filuren>
apeiros_: If I explained the application I wanted to develop, do you think you could tell if it's complex or simple?
<Filuren>
The idea is simple, not sure how simple it would be to write though
<apeiros_>
I doubt it. but try to reduce it to its barest minimum.
heftig [heftig!jan@archlinux/developer/heftig] has joined #ruby-lang
<apeiros_>
start there. when you've done the minimum you can start evolving it.
<Filuren>
Load a .txt file, scan for specific symbols, delete line if found, save to same .txt
<apeiros_>
a one liner for an experienced ruby programmer ;-)
<drbrain>
ARGF can do "in-place" edits
<Filuren>
So you think it's doable? I could use and eventually expand it
<apeiros_>
but yes, that surely works as a starting point
<Filuren>
What's ARGF?
<apeiros_>
and it's perfectly fine if you use a hundred lines for your first version
<drbrain>
Filuren: ri ARGF
<drbrain>
it's a virtual file stream for the files given to ruby on the command line
<Filuren>
What's a virtual file stream? New to Ruby/programming, not aware of those expressions yet
<drbrain>
Filuren: it acts like an IO but it's not a real IO
<drbrain>
if you list two files they appear to be one
<drbrain>
Filuren: there's no formal "virtual" in ruby like in C++
burgestrand [burgestrand!~burgestra@h-45-63.a155.priv.bahnhof.se] has joined #ruby-lang
Pip [Pip!~Pip@unaffiliated/pip] has joined #ruby-lang
jacobwg [jacobwg!~jacobwg@111.sub-75-227-140.myvzw.com] has joined #ruby-lang
ricardovaleriano [ricardovaleriano!~ricardova@177.33.17.13] has joined #ruby-lang
handygandy [handygandy!~handygand@adsl-76-193-165-222.dsl.chcgil.sbcglobal.net] has joined #ruby-lang
<handygandy>
Hello I have to do a topological sort in 1.9.1 is there alibrary that can help me?
<yorickpeterse>
Don't use 1.9.1
<yorickpeterse>
It's buggy and not supported anymore
<drbrain>
handygandy: tsort.rb in the standard library
<handygandy>
yorickpeterse: Until I fix my debian installation and upgrade it's what I am stuck with.
<drbrain>
handygandy: but, yeah, upgrade to 1.9.3
<jarib>
tsort works fine, if you need something more advanced, look at rgl
<yorickpeterse>
Wait, debian is still on 1.9.1? Ugh
<drbrain>
at one time it was debian policy to have ruby 1.9.2 ship in the ruby 1.9.1 package
<drbrain>
handygandy: does ruby -v say 1.9.1?
<wmoxam>
drbrain: still is
<wmoxam>
1.9.1 refers to compatibility version
<wmoxam>
handygandy: drbrain is correct, you are likely are running 1.9.2 unless you are running an ancient version of Debian
naz [naz!~n@70.44.2.190.res-cmts.bus.ptd.net] has joined #ruby-lang
Axsuul [Axsuul!~Axsuul@75-140-75-52.dhcp.mtpk.ca.charter.com] has joined #ruby-lang
Axsuul [Axsuul!~Axsuul@75-140-75-52.dhcp.mtpk.ca.charter.com] has joined #ruby-lang
Axsuul [Axsuul!~Axsuul@75-140-75-52.dhcp.mtpk.ca.charter.com] has joined #ruby-lang
Axsuul [Axsuul!~Axsuul@75-140-75-52.dhcp.mtpk.ca.charter.com] has joined #ruby-lang
Axsuul [Axsuul!~Axsuul@75-140-75-52.dhcp.mtpk.ca.charter.com] has joined #ruby-lang
mark_azevedo [mark_azevedo!~mark_azev@70-36-215-74.dsl.dynamic.sonic.net] has joined #ruby-lang
slyphon [slyphon!~weechat@pool-96-224-232-158.nycmny.fios.verizon.net] has joined #ruby-lang
slyphon [slyphon!~weechat@unaffiliated/slyphon] has joined #ruby-lang
context [context!context@november.xen.prgmr.com] has joined #ruby-lang
<context>
would anyone know what is going on with this? :x word_representation_accumulator
<apeiros_>
context: didn't get help in #rubyonrails? :)
<context>
no
<context>
hah
<apeiros_>
anyway, 10200 goes to write "two hundred" into the accumulator, then when you hit the 1, you go into the elsif ten_to_twenty?(digit_as_number, digit_count)
<apeiros_>
there you backtrack, so byebye 200
<apeiros_>
100200 fails too, it says "one hundred and two hundred" - the thousand goes missing…
* apeiros_
thinks that algorithm is flawed
dfr|mac [dfr|mac!dfr|work@nat/google/x-nmiyfhwsodkxptip] has joined #ruby-lang
<apeiros_>
I mean, beyond the obvious bugs.
<context>
i got it fixed up
<context>
hmmm
<context>
kk. yeah 20200 failed also , i didnt try 30200 though
<apeiros_>
if you need that productive, you probably better use some existing lib
<apeiros_>
if it's an exercise, I'd consider starting over
leonL [leonL!~leonl@CPE0024a5b652a3-CM000f21205d86.cpe.net.cable.rogers.com] has joined #ruby-lang
<lsegal>
messy looking.
<apeiros_>
lsegal: no more argv[0]?
<lsegal>
not since a while ago
<lsegal>
i would parse the number in triplets, and attach the "trillion" "million" "thousand" qualifier to the specific triplet you're on, not make it part of the standard digit parsing inside of the triplet
<context>
lsegal: yeah i found a fix for it, or shall i say, replacement
<context>
thats a lot easier to read
<lsegal>
then you only have to handle 0-999 per triplet
<lsegal>
which is fairly easy to do
<context>
eyah
postmodern [postmodern!~postmoder@c-71-237-178-98.hsd1.or.comcast.net] has joined #ruby-lang
<lsegal>
i feel like golfing this for fun
<context>
lsegal: its cause of the ten_to_twenty, is backtracking the accumulator, and pop'ing the 200 off
<context>
:x
* context
hides
wingless2434 [wingless2434!~chris@c-174-61-224-227.hsd1.wa.comcast.net] has joined #ruby-lang
wingless2434 [wingless2434!~wing@c-174-61-224-227.hsd1.wa.comcast.net] has joined #ruby-lang
RomyEatsDrupal [RomyEatsDrupal!~stickycak@dyn-207-10-142-100.dyn.columbia.edu] has joined #ruby-lang