Topic for #ruby-lang is now Ruby 1.9.3p0: http://ruby-lang.org | Paste >3 Lines of Text on http://pastie.org
wyhaines has joined #ruby-lang
Austin__ has joined #ruby-lang
butchanton1 has joined #ruby-lang
achiu has joined #ruby-lang
wmoxam has joined #ruby-lang
tomzx has joined #ruby-lang
<youngin> Can somebody help me back up the SoundCloud comments at http://soundcloud.com/flyinglotus based on http://developers.soundcloud.com/docs/api/?
Karmaon has joined #ruby-lang
<injekt> youngin: what problems are you having?
<youngin> Well I'd just like to back up the comments, incase my account gets hacked or whatever.
daglees has joined #ruby-lang
<injekt> youngin: right, but what have you tried? i mean, of course i know you're not expecting anyone to write it for you
<S1kx> I'm trying to use tire with kaminari, but I always get the same 10 results, even though I pass in the page in the options-hash: Item.tire.search("talisman", page: params[:page])
<youngin> injekt: No I'm not, but I'm asking for some general pointers on how to get started
<S1kx> in the rails console i can confirm that Item.tire.search("talisman", page: 1).first == Item.tire.search("talisman", page:1000).first
<injekt> youngin: start messing with net/http and building http requests, and use the json gem (data seems to be returned as json)
<injekt> S1kx: #ror might help you more brah
<youngin> thanks a lot injekt
<S1kx> injekt: tire isn't exclusively for activemodel
<injekt> S1kx: I know, i never said it was rails specific, but there's bound to be more people in there who have used kaminari than in here
<S1kx> ill ask there anyways
<S1kx> yep, thx for the advice ;P i meant to ask there instead of here anyways
<injekt> :)
jredville has joined #ruby-lang
<shevy> hmm
<shevy> somehow it seems as if my brain no longer wants to learn vim :(
<Rabbitt> you could switch to emacs :-)
<Rabbitt> (not that I use it mind you)...
<Rabbitt> ok. I admit it wasn't very funny. on a serious note though, have you heard of Sublime Text? (http://www.sublimetext.com/)
<Rabbitt> pretty awesome editor - has a vi mode too
butchanton has joined #ruby-lang
bryancp has joined #ruby-lang
<shevy> Rabbitt well I feel both would require shitlots of mastering
<Rabbitt> fair enough
<shevy> (vim and emacs)
<Rabbitt> To be honest, I actually started with emacs way back when (due to gdb integration) and then switched to vim and finally said screw it and went with nano ..
<shevy> and it's really sad but I no longer want to know everything. I am happy learning more about ruby, but I (or rather my brain) no longer want(s) to invest any real time into editors like vim or emacs
<shevy> haha
<shevy> nano is nice. lacks a few things though
<shevy> one can't jump to a specific line with it right?
<Rabbitt> [control-w][control-t]
<Rabbitt> then line number
Gekz has joined #ruby-lang
Gekz has joined #ruby-lang
<Rabbitt> or: nano +line <file>
<brownies> i use sublimeText, it's highly tolerable
<shevy> oh
<Rabbitt> brownies: I just linked to that - I'm actually loving it
<shevy> let me try that in nano
<injekt> never write code with nano :|
<brownies> yea word
<injekt> edit config files with nano
<shevy> wow
Luxx_ has joined #ruby-lang
<Rabbitt> I've written a /lot/ of code with nano
<shevy> I never knew you could jump to a specific line with it
* injekt stabs a kitten
<Rabbitt> yuppers
<brownies> Rabbitt: it does this annoyingly terrible autocomplete when i'm writing dictionaries in JSON and trying to use Tab to line everything up -- angers me everytime, but other than that i like it a lot.
<Rabbitt> brownies: there's a plugin you can get that will line things up for you
<shevy> I am impressed now
<brownies> Rabbitt: !
<brownies> Rabbitt: which?
<Rabbitt> shevy: heh - yeah, even does syntax highlighting..
<injekt> :/
<Rabbitt> brownies: lemme look at which ones I have installed
<injekt> this is like a nightmare actually happening
<Rabbitt> lol
<brownies> you're using the package manager right?
<injekt> wait, i thought you were talking about nano
<injekt> not ST2
<brownies> injekt: nano is too heavy for me, i usually just code at the command line and use pipes and cat
<injekt> lol
<shevy> an editor like nano, written in ruby, would be nice
<Rabbitt> brownies: it's called, rather appropriately, "Alignment"
<injekt> S1kx: diakanos
<injekt> shevy: ^
butchanton has joined #ruby-lang
<Rabbitt> injekt: sorry, was switching between talking about nano/ST2
<injekt> Rabbitt: yeah i was confused massively
<shevy> oh :(
<shevy> @configs << { filename: filename, source: including_filename }
<shevy> they switched to 1.9.x
<injekt> thank god
<injekt> you're actually not on 1.9? :|
<shevy> still not, nope
<brownies> Rabbitt: found it. thanks!
<injekt> shevy: wtf?
dfr|mac has joined #ruby-lang
<shevy> my main project had a "circular requires" crash
<Rabbitt> I honestly prefer the old style hash rocket..
<shevy> I decided to start from scratch with it and rewrite it
<shevy> so once that rewrite is done, I'll see whether 1.9.x is happy now
<injekt> shevy: rewrite it for 1.9...
<injekt> dont check it when it's DONE
<injekt> write it for 1.9
<injekt> writing for ruby versions ruby developers hardly use seems silly
<shevy> man 1.9.x is a bitch, it complains about a gazillion things
<Rabbitt> I'm liking 1.9 actually - esp. fibers. though, the segfaults I keep getting on string#dup are rather annoying.
<injekt> it's not a bitch, it's the latest stable version of ruby
<injekt> move on!
<shevy> segfaults?
<injekt> Rabbitt: i haven't used fibers once even having used 1.9 since its initial release
<Rabbitt> yar
<shevy> how can this be, this is the stable ruby!
<Rabbitt> injekt: I haven't used them in a production setting - just been playing with them.
<shevy> but fibers are no problem for me, I dont use them yet :)
<injekt> if there's a bug, file the bug
<injekt> boom
<injekt> Rabbitt: ah
<erikh> shakalaka
<Rabbitt> injekt: I'm debugging still - waiting until I have a concrete way of replicating it
<injekt> ^
<injekt> Rabbitt: word
<injekt> threads are hard, lets write lexers
<Rabbitt> though, frustratingly, 'GC.disable = true' causes the segfaults to go away ;-)
<injekt> \o/
<Rabbitt> makes debugging with gdb a little more complicated
<Rabbitt> (/if/ it's actually a gc issue anyway)
Austin__ has joined #ruby-lang
<S1kx> yay i figured it out.
<shevy> segfaults rock
<S1kx> if anyone has read my problem above and is interested in the solution: tire wants you to specify both, page and per_page in the options hash
<shevy> I am dealing with one in dbus-glib right now ... make[4]: *** [example-service-glue.h] Segmentation fault
Austin__ has quit [#ruby-lang]
<shevy> hmm
Wardrop has joined #ruby-lang
<Rabbitt> mine pops is head in string.c:607: memcpy(RSTRING_PTR(str2), RSTRING_PTR(str), RSTRING_LEN(str)+1); <<--- somehow RSTRING_PTR(str) is NULL and the length is, obviously, 0
<shevy> if I'll be 10 years on 1.8.x I'll probably become very famous
<shevy> oh god that looks awful
<shevy> why isn't C code fun and also beautiful to work with?
<erikh> it is
<Rabbitt> I dunno, maybe I'm a little masochistic but, I kinda like it
<erikh> C's simplicity is marvelous
<Rabbitt> erikh: +1
<Rabbitt> there's a reason most every other major language is written in C
wmoxam has joined #ruby-lang
knu has joined #ruby-lang
<shevy> because no better language has dethroned C yet!
<injekt> 'better'?
<Rabbitt> shevy: I'll tell you what, ruby's C code is infinitely better looking and easier to follow than PHP, for example
<injekt> what does better mean?
<erikh> ruby's C interface is pretty awesome
<erikh> ruby's C internals are.... not as awesome
<Rabbitt> heh - I'm finding that out quickly
<Rabbitt> they have a nice set of macros
<erikh> yes, a very nice set
<erikh> especially coming from perl
<injekt> +1
<Rabbitt> hah!
<injekt> ghetto
<Rabbitt> definite +1
<erikh> XSUB is the most painful thing I have ever used
<erikh> well, ok.. ant is a close second
<Rabbitt> lol
<injekt> ant is okay, just kinda stupid
<erikh> we can agree to disagree
<erikh> :P
<injekt> :D
<Rabbitt> heh
<shevy> long live XML
<Rabbitt> wow.
<shevy> what
<shevy> someone else started!
* Rabbitt speechless
<erikh> hehe
<erikh> shevy: you are the best troller ever
<shevy> is XML still widely used in the Java world?
<seanstickle> Sadly
<erikh> well, to keep things in perspective
<shevy> well perhaps they'll get tired of it and move to something else one day. like json
<erikh> java and .net have *great* xml tools
<erikh> really really great
<injekt> ^
<seanstickle> Sort of like the tools Hercules had to clean the Aurean stalls
<injekt> wow I haven't written java in like 2 months
<shevy> lol
<injekt> new record
<shevy> that is the best comparison ever seanstickle
<seanstickle> :)
<Rabbitt> I'm /very/ happy to report that I haven't touch PHP in 4 years..
<injekt> I haven't touched php *properly* in about 2 years
<injekt> i hack it for 'fun' with a collegue sometimes
<Rabbitt> I /used/ to follow php internals... that was a mess.
<shevy> I touched my old php code a little bit... cleaned up some docu... then went back to ruby code, which is a lot nicer to look at
<Rabbitt> well, honestly, I still have sites (wordpress mostly) that still use it but, I don't really touch it.
<Rabbitt> shevy: +1
retro|cz has joined #ruby-lang
<shevy> :(
<shevy> I think I used php almost 2 years
<shevy> I actually liked it more than perl
<Rabbitt> I started using it around 97
<Rabbitt> or maybe 98
<Rabbitt> somewhere around there
<Rabbitt> though, I was still doing a bunch of stuff using CGI-Toolkit back then too
<cout> I one thought it was a good idea to write CGI programs in C
<cout> I wish I could go back in time and tell my former self what an idiot he was
<Rabbitt> tell me about it
wmoxam has joined #ruby-lang
kernel_ducky has joined #ruby-lang
<shevy> that's a damn long time ago Rabbitt
<shevy> 1997 ... that is 15 years man
<cout> it wasn't THAT long ago
<shevy> take someone who was ten years, 5 years ago, starting with ruby. he could already be a guru and know nothing about 1997
<cout> stop trying to make us feel old
<cout> my bones already tell me that story
<Rabbitt> heh - now that I have a (2yo) kid (and another on the way), 97 feels more like 30 years ago
QoQOoO has joined #ruby-lang
<shevy> see?
<shevy> old old old
<Rabbitt> well, I don't /feel/ older - just mroe tired ;-)
<Rabbitt> s/mroe/more/
<erikh> hehe
<erikh> I know the feeling.
<shevy> oh yeah
<shevy> :(
<shevy> but we gained wisdom!
<Rabbitt> well, one would hope anyway
<Rabbitt> though I'm sure my wife would disagree
<erikh> Return a tuple of function call statistics, if CALL_PROFILE was defined
<erikh> when Python was built. Otherwise, return None.
takaokouji has joined #ruby-lang
<erikh> I wish all this shit was in ruby
<Rabbitt> you could hire an intern to rewrite it all in ruby...
slimfit has joined #ruby-lang
gnufied has joined #ruby-lang
looopy has joined #ruby-lang
<injekt> erikh: what shit?
<injekt> erikh: call statistics?
<erikh> python's os and sys packages
<erikh> like, all of it
<injekt> ohh
<erikh> it's beautiful
<injekt> aye
<injekt> I agree
<injekt> I also want built in docs, but I HATE docstrings in method bodies
<WillMarshall> Is there a nice way to check whether a string like "32" contains an integerable value?
<WillMarshall> vs a string like "roger"
MistyM has joined #ruby-lang
<erikh> Integer("roger")
<injekt> Integer(str) rescue false
<erikh> Integer("32")
<erikh> try both
<injekt> too slow injekt
<injekt> too slow
<injekt> yeah try erikhs first
<injekt> that would make more sense
achiu has joined #ruby-lang
<WillMarshall> Can catch the exception, nice
<WillMarshall> Cheers :)
<injekt> catch all the things!
QaDeS_ has joined #ruby-lang
macmartine has joined #ruby-lang
<cout> rescue all the things imo
justinxxreese has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
SuperTaz_work has joined #ruby-lang
heftig has joined #ruby-lang
heftig has joined #ruby-lang
77CAAHYT4 has joined #ruby-lang
andrewhl has joined #ruby-lang
<77CAAHYT4> Hello
looopy has joined #ruby-lang
bryancp has joined #ruby-lang
h4y4shi has joined #ruby-lang
looopy has joined #ruby-lang
looopy has joined #ruby-lang
jxie has joined #ruby-lang
context has joined #ruby-lang
context has quit [#ruby-lang]
gnufied has joined #ruby-lang
brownies has joined #ruby-lang
erpuds has joined #ruby-lang
Jay_Levitt has joined #ruby-lang
fayimora has joined #ruby-lang
pp01bit has joined #ruby-lang
woollyams has joined #ruby-lang
hagebake has joined #ruby-lang
hagebake has joined #ruby-lang
srbartlett has joined #ruby-lang
imperator has joined #ruby-lang
Dreamer3 has joined #ruby-lang
mistym has joined #ruby-lang
sockmonk has joined #ruby-lang
bhrgunatha has joined #ruby-lang
looopy has joined #ruby-lang
srbartle_ has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
srbartlett has joined #ruby-lang
ryanf has joined #ruby-lang
srbartle_ has joined #ruby-lang
matti has joined #ruby-lang
crankharder has joined #ruby-lang
looopy has joined #ruby-lang
ascarter has joined #ruby-lang
niklasb_ has joined #ruby-lang
markstewie has joined #ruby-lang
niklasb has joined #ruby-lang
niklasb has joined #ruby-lang
wilkie_ has joined #ruby-lang
rohit has joined #ruby-lang
gokul has joined #ruby-lang
kasansweat has joined #ruby-lang
<kasansweat> How does one successfully retrieve a string containing ampersands (in my case, its filepaths) from an array? Been googling this for a while, can't figure it out. Thanks!
<bnagy> explain more?
<bnagy> %w( a dog cat frog&fish).grep(/&/) => ["frog&fish"]
bryancp has joined #ruby-lang
<kasansweat> Aha, "retrieve" may have been the wrong word. What I've got going on is a 2d array, basically the format is [filesize,fullfilepath]. I'm searching on filesize, and retrieving the fullfilepath -- everything works great except when it encounters a filename with an ampersand, it cuts off the rest of the filename
<bnagy> kasansweat: why not use a Hash, this is what they're meant for
<bnagy> oh wait, filesize, no won't be unique
<bnagy> why would you.. nevermind :)
rippa has joined #ruby-lang
<bnagy> so what cuts off the rest of the filename? Can you put some code onto codepad or pastie or something?
<kasansweat> yeah, I'm doing a kludgy but quick filesearching system that just screams at me when theres a filesize collision
<kasansweat> dont ask why :)
<bnagy> oh, if you WANT to find collisions then a Hash might work
<bnagy> you could just use has_key?
<bnagy> or just filesize=>[file1, file2]
<bnagy> and then select {||k,v| v.size > 1}
<hagebake> ruby doesn't do anything special with ampersand in strings, maybe you're using shell escape incorrectly
woollyams has joined #ruby-lang
<kasansweat> shell escape?
<hagebake> maybe you should just show the code
rohit has joined #ruby-lang
<kasansweat> well actually -- might it have something to do with the fact that I'm pulling the data from a text file (csv?)
<kasansweat> weird encoding?
<bnagy> code :)
<kasansweat> ha okay one sec
<hagebake> heh
<bnagy> yeah my idea works fine btw
<bnagy> hsh=Hash.new {|h,k| h[k]=[]}; Dir.glob('/Users/ben/**/*').each {|fn| hsh[(File.size(fn) rescue '??')] << fn}; hsh.select {|k,v| v.size > 1}
<bnagy> more collisions than I expected actually
kasansweat has joined #ruby-lang
<kasansweat> ha, thanks everyone -- I figured it out with your help. you're right, ruby doesn't mess with ampersands -- I was pulling filenames from a CSV and the filename has a COMMA. nothin' to do with ruby...
<bnagy> imagine our shock ;)
<kasansweat> hahaha :)
<bnagy> fwiw sounds like the ruby part could still be improved
<kasansweat> oh it's probably awful. doing this purely as a hobby :)
<kasansweat> at least for now
Banistergalaxy has joined #ruby-lang
kp666 has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
mistym has joined #ruby-lang
rue has joined #ruby-lang
woollyams has joined #ruby-lang
jeffmoss has joined #ruby-lang
QoQOoO has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
jredville has joined #ruby-lang
pemeon has joined #ruby-lang
ovnimancer has joined #ruby-lang
RomyRomy has joined #ruby-lang
lsegal has joined #ruby-lang
rohit has joined #ruby-lang
ryanf has joined #ruby-lang
kitallis has joined #ruby-lang
QoQOoO has joined #ruby-lang
brownies has joined #ruby-lang
x0F__ has joined #ruby-lang
rohit has joined #ruby-lang
Marco has joined #ruby-lang
butchanton has joined #ruby-lang
achiu has joined #ruby-lang
twittard has joined #ruby-lang
skryking has joined #ruby-lang
yxhuvud has joined #ruby-lang
amerine has joined #ruby-lang
thone has joined #ruby-lang
|Vargas| has joined #ruby-lang
uniqanomaly has joined #ruby-lang
Rakko has joined #ruby-lang
<Rakko> could someone explain to me the difference between --[no-]ri and --[no-]rdoc when installing gems?
<Rakko> also, the 1.9.3 version in the topic is old
h4y4shi_ has joined #ruby-lang
mytrile has joined #ruby-lang
<Rakko> I know rdoc creates ri files
<Rakko> but what sort of files do you get with gem install --rdoc --no-ri ?
<Rakko> html?
frangiz has joined #ruby-lang
<andkerosine> Are you using rvm, by any chance?
<andkerosine> Rakko: Yes, rdoc creates HTML. For example: http://docs.seattlerb.org/net-http-persistent/Net/HTTP/Persistent.html
<andkerosine> Specifically, it creates the documentation using ri, which is just a certain way of writing comments so that the tools can more effectively describe your objects and show relations between them.
<Rakko> thanks
<andkerosine> Wherever your gems are kept, there /should/ be a doc folder containing each gem's documentation, so long as it wasn't installed with -no.
achiu has joined #ruby-lang
<Rakko> Oh... well then I'm confused again about the difference between --rdoc and --ri
solars has joined #ruby-lang
<Rakko> and also I'm not sure where the docs are. I'm using rvm and I can't find the docs for RubyInline (which I just supposedly installed using `gem rdoc RubyInline`)
<andkerosine> Linux?
<Rakko> mac os x
<andkerosine> /home/YOU/.rvm
<Rakko> right
<andkerosine> Do you have that folder?
<Rakko> yeah, I'm in it
qpingu has joined #ruby-lang
<Rakko> I see some doc dirs with .rdoc files for things like rake
QoQOoO has joined #ruby-lang
<andkerosine> /gems/VERSION/doc
<Rakko> even though in my .gemrc I have install: --no-rdoc --no-ri and update: --no-rdoc --no-ri
<Rakko> ok
<andkerosine> Ah, you /don't/ want any doc?
<Rakko> normally not
<Rakko> but I just tried to generate (manually) the RubyInline doc
<Rakko> to see what it would create
<Rakko> but that gem doesn't have any doc in it
<Rakko> maybe I needed to specify --ri and/or --rdoc
<andkerosine> Hm.
<andkerosine> I... don't think those are options.
<Rakko> just for install and update, I guess
<Rakko> ah, here it is: /Users/eric/.rvm/gems/ruby-1.9.3-p0/doc/RubyInline-3.11.1/ri
<Rakko> I got that with ri --list-doc-dirs
<andkerosine> That's... exactly where I told you to look, my friend...
<andkerosine> Ah, well. Glad you found it.
<Rakko> I know
<Rakko> But I didn't even see a doc dir the first few times
<andkerosine> Ah.
<Rakko> oh!
<Rakko> I was looking for doc *under* RubyInline-3.11.1
<andkerosine> Ah, that'll do it. : )
<Rakko> is there a command to list the topics you can query ri for?
<andkerosine> Alas, I don't use it very much, sorry.
<Rakko> like ri rubyinline or RubyInline don't work, but specific classes from the gem do
<andkerosine> I don't believe those former two are use cases.
<andkerosine> That's what the rdoc is for. : )
aroop has joined #ruby-lang
<Rakko> cool
<Rakko> I've had ri/rdoc turned off for months because generating them seemed to slow gem down so much
<Rakko> especially on windows
<Rakko> but I want to see if it's better now
<andkerosine> Mm-hmm. I usually only install them when I know it's something I'll be using in future.
<Rakko> active* stuff takes a long time to generate docs
<Rakko> and I keep getting things like: unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README.rdoc, skipping
<Rakko> that's weird
<Rakko> I guess that's common
<Rakko> ok... how do I generate ri docs for built-in/stdlib stuff?
<andkerosine> Alas, dunno. : /
<Rakko> hmm
ryanf has joined #ruby-lang
<andkerosine> I mean, you can do `ri String.gsub` and so forth.
<andkerosine> But I don't know where all the doc that you can see on rubylang.org goes.
<Rakko> yeah, String.gsub and String#gsub don't work for me: Nothing known about String.gsub
chendo has joined #ruby-lang
WillMarshall has joined #ruby-lang
<andkerosine> `rvm docs generate`
<andkerosine> It'll take a while.
<Rakko> sweet. thanks
<andkerosine> Sure thing.
<Rakko> I found some more manual ways to do it, in ruby's source tree
Banistergalaxy has joined #ruby-lang
Faris has joined #ruby-lang
dr_bob has joined #ruby-lang
mikeric has joined #ruby-lang
kitallis has joined #ruby-lang
kitallis has joined #ruby-lang
kitallis has joined #ruby-lang
achiu has joined #ruby-lang
bjensen has joined #ruby-lang
<Rakko> thanks again, and
<Rakko> *andkerosine
<Rakko> good night
gianlucadv has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
Slackwise has joined #ruby-lang
Asher has joined #ruby-lang
dRbiG has joined #ruby-lang
Karmaon has joined #ruby-lang
futurechimp has joined #ruby-lang
<Silex> if I have a File object, is there a block version of "read" in f.read.scan(pattern) { |s| } ?
<Silex> ah, probably IO.foreach
<Silex> ah wait, #each or #each_line \o/
cyri_ has joined #ruby-lang
<Silex> hum, IO.foreach would actually simplify my File.open(file) { |f| f.each_line {|line| }} into IO.foreach(filename) { |line| }
<Silex> seems better
davidw has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
erikh has joined #ruby-lang
csherin has joined #ruby-lang
rolfb has joined #ruby-lang
d3vic3 has joined #ruby-lang
danishkirel has joined #ruby-lang
<bnagy> fwiw I always use File.open( blah, 'rb' ) {|io| # do stuff with io
<bnagy> cause then I don't have to look up what mode options etc are being used etc
<whitequark> bnagy: I always use Brainfuck. cause, you know, I don't need to look up any freakin' function names or such bullshit
JohnBat26 has joined #ruby-lang
<whitequark> rippa: unresolved
<whitequark> er wtf
<whitequark> my isp blocks 4chan? I'm switching
xjonc has joined #ruby-lang
saLOUt has joined #ruby-lang
francisfish has joined #ruby-lang
francisfish has joined #ruby-lang
tekin has joined #ruby-lang
<Silex> is there a way to write YAML comments using ruby's yaml? doenst' seem so
<Silex> it doesn't even seem to parse them in the tree
Faris2 has joined #ruby-lang
molgrew has joined #ruby-lang
zmack has joined #ruby-lang
solars has joined #ruby-lang
csherin has joined #ruby-lang
molgrew_ has joined #ruby-lang
<masterkorp> whitequark: you isp is smart
ramonmaruko has joined #ruby-lang
roadkith has joined #ruby-lang
gjaldon has joined #ruby-lang
<erikh> yeah, heh, sounds like they're doing you a favor.
sat has joined #ruby-lang
chendo has joined #ruby-lang
riffraff has joined #ruby-lang
ttilley has joined #ruby-lang
qpingu has quit [#ruby-lang]
yumike has joined #ruby-lang
PatrixCR has joined #ruby-lang
rue has joined #ruby-lang
adambeynon has joined #ruby-lang
rippa has joined #ruby-lang
PatrixCR has quit [#ruby-lang]
StevenRingo has joined #ruby-lang
alim has joined #ruby-lang
<roadkith> i wrote code that unfortunately uses dbi to access mysql and now a statement result returns rows with unsorted columns, is there a trick to make dbi return the column just like i wrote in the statement?
<roadkith> when i do "SELECT foo, bar, baz FROM table" instead of randomly sorted column names in that particular order
workmad3 has joined #ruby-lang
rohit has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
akahn_ has joined #ruby-lang
<Silex> what would be the best way to transform "a.b.c.d" into a hash like { 'a' => { 'b' => { 'c' => { 'd' => 'not translated' }}}} ?
lianj has joined #ruby-lang
lianj has joined #ruby-lang
<Silex> I was thinking something like s.split('.').inject({}) { |h, scope| h[scope] ||= {}; h }
stamina has joined #ruby-lang
<Silex> err, h[scope]
abuiles has joined #ruby-lang
<Silex> but then I have trouble doing the last part ("not translated")
csherin_ has joined #ruby-lang
<andrewvos> Silex: Are you the PHP sinatra-like web framework?
<Silex> no?
<Silex> I'm writing a rake task that greps all I18n translation strings and create the translation files
csherin_ has joined #ruby-lang
<Silex> (which are in YAML)
<Silex> then my goal is to diff the existing translations with those I found and make unused and untranslated sections etc
madsheep_ has joined #ruby-lang
<andrewvos> Silex: Use Hash#new
<Silex> andrewvos: atm I have http://codepad.org/YPauGpPa
<Silex> what do you mean?
<andkerosine> Dear God.
<andkerosine> Just use OpenStruct.
<andkerosine> Or, better, a Struct, if you know exactly which values you need.
dhruvasagar has joined #ruby-lang
<Silex> I just receive strings like "people.organization_name"
flexd has joined #ruby-lang
<Silex> sometimes with more scope, then I need to save those in YAML
<andrewvos> Whoa i didn't read this part: { 'a' => { 'b' => { 'c' => { 'd' => 'not translated' }}}}
<andrewvos> hahah
<Silex> ah
<Silex> I was about to say that OpenStruct really don't help here
<andrewvos> What are you trying to do, in 140 characters or less?
<andrewvos> Silex: ^
<Silex> you know I18n?
<Banistergalaxy> Andrewvos do you think andkerosine is a woman?
<andrewvos> Banistergalaxy: I have no idea
<Silex> <Silex> I'm writing a rake task that greps all I18n translation strings and create the translation files
<Silex> the translation files are in YAML
<andrewvos> Banistergalaxy: And where were you yesterday? I had a pry question and you were sleeping. Not cool.
<Silex> the translation strings are in "a.b.c.d.e" format
<Banistergalaxy> Andrewvos what was the q
<Silex> the translation files are like "a:\n b:\n c: sometranslation"
<Silex> do you need more infos?
<andkerosine> Banistergalaxy: Why the question?
<Silex> my goal was to transform a.b.c.d into the ruby hash representation of the YAML, then use YAML.dump
<Silex> tell me if you have a better idea
<andrewvos> Banistergalaxy: How do I run pry under bundle exec pry
<andrewvos> Banistergalaxy: But I realised I should run it under there after adding it to my Gemfile
madsheep_ has joined #ruby-lang
<andrewvos> Banistergalaxy: You are from SA right?
<Banistergalaxy> Andrewvos that question sucks, ask a more interesting one
<andrewvos> Banistergalaxy: Which one
<andrewvos> ?
woollyams has joined #ruby-lang
<Banistergalaxy> Bundle exec pry
<Banistergalaxy> Ask a more interesting pry question
<Silex> andrewvos: was I unclear?
<andrewvos> Silex: 140 chars or less
<Silex> transform "a.b.c" into { 'a' => { 'b' => { 'c' => 'not translated' }}}
<andrewvos> Silex: Recursion
<andrewvos> Silex: Recursion and OpenStruct :)
<andrewvos> Silex: Recursion, String#split, and OpenStruct :)
<Silex> why OpenStruct?
<andrewvos> Silex: Why not ?
<Silex> how does it help me getting an hash?
<bnagy> *a hash
<andrewvos> Umm, it doesn't. You recursion and a hash then. The answer here is recursion.
<andrewvos> bnagy: :)
<shevy> I suggest the answer to be 42
<shevy> hmm
<shevy> are andkerosine and andrewvos brothers?
<Silex> andrewvos: http://ideone.com/GK2ge
<Silex> what recursion are you talking about? I don't see how it would be useful
<tobiasvl> uh
<tobiasvl> recursion is the method you use to turn this string into a nested hash
<tobiasvl> what else would you use??
<Silex> you mean get the first token create the hash call the same function and when there's no more dot to split add the "untranslated" ?
<tobiasvl> you recurse to the end of the string and then return out, creating the inner hash first, then the outer one, then the outer one, etc
<Silex> tobiasvl: so I don't #split the full string?
<Banistergalaxy> Andrewvos do you like pry
<andrewvos> Banistergalaxy: yep
<andkerosine> shevy: Because our [0..2] is equal?
<tobiasvl> Silex: have you ever created a recursive method?
<shevy> andkerosine yeah!
<shevy> I mix you two up
<Silex> tobiasvl: yes
<roadkith> okay i found .fetch_array in dbi... now how do i find out the column name?
bjensen has joined #ruby-lang
<Silex> tobiasvl: http://ideone.com/7z3Ec
<tobiasvl> Silex: then the concept should be easy enough to grasp. you create a method where you split the first element off of the string and create a hash where the element maps to the result of calling the same method with the rest of the string
<Silex> now I have it the recursive way
<tobiasvl> with a test for empty string
<tobiasvl> okay
<Silex> but
<Silex> ah wait, I just add the "untranslated" when the string is empty
<tobiasvl> yep
<Silex> alright, thanks
<tobiasvl> there you go!
<tobiasvl> np
mytrile has joined #ruby-lang
<bnagy> Silex: http://ideone.com/ydBlJ if you want to avoid recursion
<bnagy> ruby has a pretty low recursion limit, I usually avoid it unless it's extremely elegant and I know for sure it won't blow the stack
<tobiasvl> yeah :(
<bnagy> but every recursive algorithm can be converted to iterative
virunga has joined #ruby-lang
<bnagy> worst case you make an explicit stack in an array
<bnagy> those can be a pain to read though :(
dhruvasagar has joined #ruby-lang
vish has joined #ruby-lang
<bnagy> 'a.b.c.d'.split('.').reverse.inject('untranslated') {|accum, item| accum={item=>accum}} => {"a"=>{"b"=>{"c"=>{"d"=>"untranslated"}}}}
<bnagy> ahhh there it is, I knew it was in the hindbrain somewhere
futurechimp has joined #ruby-lang
davidw has joined #ruby-lang
<davidw> riffraff, I found a way that I think works: anonymous modules
<davidw> I keep a class variable with a hash of them
<bnagy> Enumerable#inject is the golfing buddy you never want to talk to in real life :>
woollyams has joined #ruby-lang
m3nd3s has joined #ruby-lang
Fractality has joined #ruby-lang
<erikh> bah
<erikh> explicit stack + while is not hard to read at all :P
<Silex> bnagy: thanks
melter has joined #ruby-lang
judofyr has joined #ruby-lang
<Banistergalaxy> Erikh sup puppy
<erikh> SUP DAWG
zmack_ has joined #ruby-lang
<Banistergalaxy> I'm feeling Kinda moist
<Banistergalaxy> U
<judofyr> erikh: you're @erikhollensbe, right?
<erikh> that's... a little detailed
<erikh> judofyr: yes
<judofyr> \o/
<judofyr> why am I not following you then? …
<erikh> I don't know!
<judofyr> now I do!
<erikh> awesomesauce
<erikh> I mostly just rant about work though
<erikh> not too much going on between the ears
<Banistergalaxy> Judofyr you are a relentless social net worker
<bnagy> Silex: that wasn't to use, it was kind of a joke :/
<Banistergalaxy> Hehej
<judofyr> Banistergalaxy: social net worker? how so?
<Banistergalaxy> Youre not
<judofyr> banistergalaxy.capitalize: :)
<judofyr> lunch!
gjaldon has joined #ruby-lang
StevenRingo has joined #ruby-lang
tekin has joined #ruby-lang
Spooner has joined #ruby-lang
twelvechairs has joined #ruby-lang
<riffraff> davidw, I wish you could share the grandparent problem :)
fayimora_ has joined #ruby-lang
<davidw> riffraff, it's kind of complicated: I need to load some methods defined in files
<davidw> clearly, I don't want to do that each time an instance is created
<riffraff> (and as a probably related note, I wish #load(true) would return the anonymous module)
<davidw> not defined as in with ruby code, but some text that needs parsing
<riffraff> yeah that much is clear, what is dubious to me is why you need to switch on specific instances rather than keep a per-domain class loaded with the code in the "config" file
<riffraff> but I can understand it's a rather specific need :)
Jay_Levitt has joined #ruby-lang
<davidw> riffraff, each instance might have a different file associated with it
<davidw> so each instance needs its own methods, and should not be polluted with the methods of others...
<davidw> the easy way: just load everything when each instance is created. But that's kind of slow
m3nd3s has joined #ruby-lang
canton7 has joined #ruby-lang
dfr|mac has joined #ruby-lang
chendo has joined #ruby-lang
<roadkith> <3 recursion
<injekt> <3 recursion
<judofyr> <3 recursion
<dmathieu> SystemStackError: stack level too deep
<oddmunds> <3 tail recursion optimisation
<roadkith> </3 recursion for dmathieu
gjaldon has joined #ruby-lang
<riffraff> davidw, yeah, but what I see is: there is a certain group of instances (more than one that's why you cache the stuff) that share some methods defined in a module (which represent the behaviour of this instances). Which is more or less the definition of a "class"
<riffraff> no concrete difference would come out of this, so I'm not advocating changing your solution anyway
jxie has joined #ruby-lang
rohit has joined #ruby-lang
<erikh> <3 while
<erikh> nobody has any love for while
schlecht has joined #ruby-lang
publicvoid_ has joined #ruby-lang
<Silex> bnagy: still interesting :)
<roadkith> nobody has any love for for either :D
gjaldon has joined #ruby-lang
<erikh> well ruby's for is pretty wimpy
<roadkith> yeah i know :D
<roadkith> the pickaxe said so
<erikh> but loop vs. while
<erikh> I don't even know why loop exists
<bnagy> because while true is not poetic
<erikh> meh
<erikh> if I wanted poetic I'd read dickinson
<bnagy> no, that's if you wanted an excuse to cut yourself
<erikh> eh, same diff
<erikh> :P
rohit has joined #ruby-lang
stamina has joined #ruby-lang
bjensen has joined #ruby-lang
<roadkith> i thought ruby was all about poetry
<roadkith> .oO(even tho i write code like a butcher...)
<roadkith> or construction worker :D
QoQOoO has joined #ruby-lang
<rue> Bruce Dickinson, one of the finest prosaists
<andrewvos> Someone please suggest some amazing coding music
<andrewvos> And quick
<Muz> Taylor Swift.
<andrewvos> :(
<rohit> Ludico Einaudi
<roadkith> tron soundtrack
<rue> andrewvos: …Iron Maiden?
<andrewvos> roadkith: A bit boring
codewrangler has joined #ruby-lang
<andrewvos> rue: Hmm, good idea
<erikh> Bruce Dickinson is the greatest man alive
<erikh> well,
<canton7> http://www.rockyfm.com gets my vote. Don't judge it on the current song!
<erikh> Iggy Pop and Bruce Dickinson
<erikh> I'd like to see them and Lemmy fight
<Muz> andrewvos: what's wrong with Taylor Swift?
<erikh> like in a 3-way cage match
<erikh> it'd be awesome, 3 old men that aren't afraid to beat hte living tar out of each other
<roadkith> iggy pop is gonna lose no?
<erikh> have you seen a picture of that guy?
<roadkith> of iggy pop?
<erikh> I'm 33. He's pushing 60 and could probably kick my ass three feet into the ground
<bnagy> iggy pop is made of nothing but muscle, bone and crack cocaine. He would not lose.
<erikh> yes
<erikh> that.
<injekt> isn't he mainly skin?
<erikh> the dude is cut
<injekt> oh for sure
<injekt> but he's wrinkly like a ball bag, no?
<erikh> well he's old, yes
<injekt> haha
adambeynon has joined #ruby-lang
<Muz> injekt: speak for yourself. My ballsack is as smooth as a baby's behind.
<injekt> I guess it's my fault for bringing ballsacks into this
<andrewvos> haahhaa
<injekt> maan, I actually really like ST2
<roadkith> star trek?
<erikh> does it have vim bindings?
<injekt> I thought nothing could pull me away from vim
<erikh> if I wanted to spam my control key, I'd use emacs
<roadkith> oh sublime text?
<injekt> erikh: it has a 'vim mode' called vintage which vim people are improving all the time, but I haven't used it extensively yet, seems basic right now
<erikh> hrm, phooey
<injekt> roadkith: aye
mytrile has joined #ruby-lang
<erikh> I'd like to try something a little more modern than vim, but frankly, I don't want to move away from the whole vim editing paradigm
<roadkith> i dont like its configuration too much
<rue> Iggy's losing skin firmness
<injekt> I was surprised by how much it fit, I hit keys not knowing what they did and they kinda did exactly what I wanted
<roadkith> edit files instead click menus
<injekt> erikh: yeah, that was kinda my problem
<injekt> roadkith: I prefer that
<roadkith> i prefer menus for configuration
<injekt> roadkith: version control config files ftw
<erikh> honestly if I switch again it'll probably be back to emacs + viper-mode
<roadkith> :S
<injekt> erikh: one does not switch from vim to emacs :(
<erikh> eh
<erikh> I did the other direction years ago
<roadkith> and i wish ST had code completion like rubymine has
<erikh> emacs has improved a lot
<injekt> erikh: that's a good decision
<injekt> :D
<andrewvos> ONE DOES NOT SIMPLY SWITCH FROM VIM TO EMACS
<roadkith> offer methods from class definitions
<injekt> heh, probably yeah, I haven't touched it
<injekt> roadkith: huh? ruby autocompletion?
<roadkith> yeah
<injekt> that's easy to add, maybe there's a plugin already
<roadkith> i want that
<roadkith> huh?
<injekt> being able to browse/install plugins from the editor and install them without leaving it is a massive win for me
<erikh> eh
<erikh> vim has that
<injekt> it sure does
<erikh> no, hte ruby autocomplete
<roadkith> not just macros but real code completion?
<erikh> yes
<injekt> erikh: i mant that too
<injekt> meant*
<roadkith> i mean ST2 not vim
<erikh> oh
<roadkith> i dont want vim
<injekt> I still love vim
<roadkith> i dont anymore
<injekt> but st2 is really surprising me
<injekt> shits all on textmate
<roadkith> modal editing isnt for me anymore
<roadkith> textmate seems dead
<erikh> modal editing rules
<erikh> anyhow
RomyRomy has joined #ruby-lang
<erikh> silly argument
<bnagy> wat? vim vs emacs is silly??
<bnagy> ALL THESE YEARS! WASTED!
gjaldon has joined #ruby-lang
<roadkith> lol
<rue> Alanis Morissette, Bryan Adams, Bon Jovi, Tom Petty to Fleetwood Mac and the latest and best Rocksongs from Maroon 5, Daughtry, Nickelback, The Fray a
<rue> *facepalm*
<roadkith> anyway if a ruby code completion module can be found for ST2 that would indeed rock
<andrewvos> rue: Did you just paste that in here by mistake? I'm lost
<roadkith> injekt: btw have you updated to the latest release? :D
<roadkith> theres a new icon now :D
<injekt> roadkith: the orange button one?
<roadkith> orange S inside yes
<injekt> yeah, i changed it immediately lol
<roadkith> *g*
<roadkith> ah
<injekt> there's so many on dribbble
<roadkith> i dont think ST can really code complete
<oddmunds> it suggests words you've already used
<roadkith> yeah
<roadkith> but rubymine reads classes you've required and then suggests methods based on that
<roadkith> i like that
<erikh> yeah, vim just reads the whole of your libdirs
<oddmunds> i guess that might lead to false negatives?
looopy has joined #ruby-lang
<oddmunds> what rubymine does, i mean
<oddmunds> for dynamically created stuff
<roadkith> havent used it enough to tell
virunga has joined #ruby-lang
pemeon has joined #ruby-lang
<pemeon> Hi how can I eval code in function which includes module ?
mark_locklear has joined #ruby-lang
Sailias_ has joined #ruby-lang
at5l has joined #ruby-lang
anthony has joined #ruby-lang
retro-in-better- has joined #ruby-lang
chendo has joined #ruby-lang
seanstickle has joined #ruby-lang
bjensen has joined #ruby-lang
<rue> pemeon: You'll need to clarify your use case a little.
robotmay has joined #ruby-lang
tommyvyo_ has joined #ruby-lang
Karmaon has joined #ruby-lang
mistym has joined #ruby-lang
Kyril has joined #ruby-lang
enebo has joined #ruby-lang
willdrew has joined #ruby-lang
gjaldon has joined #ruby-lang
workmad3 has joined #ruby-lang
QaDeS has joined #ruby-lang
retro-in-better- has joined #ruby-lang
retro|cz has joined #ruby-lang
tbuehlmann has joined #ruby-lang
vmoravec has joined #ruby-lang
rippa has joined #ruby-lang
bulll has joined #ruby-lang
robbrit has joined #ruby-lang
Telmo has joined #ruby-lang
<Telmo> I've been to London, spent a week there for work but managed to visit a few places
<Telmo> mt
leonL has joined #ruby-lang
<Spooner> I've created a ffi-wrapper for a dll in Windows. The wrapper works perfectly, but Ruby freezes on exit (doesn't end and ignores ctrl-c). Any idea what I'm missing?
<bnagy> are you trapping INT?
<Spooner> bnagy: Nope.
<erikh> probably a deadlock
<erikh> or some other fd-related illness
<bnagy> I've had some stuff that will ignore ^C if it's in a blocking windows call
<bnagy> like windows ffi calls that are timeout -1 will just ignore you, you can change them to timeout( N ) in a loop...
<Spooner> I am not using threads. It even happens if I don't actually make any calls to the dll; just defining the wrapper (extend FFI::Library) is enough to make it a zombie.
<bnagy> well you don't _think_ you're using threads
<Spooner> bnagy: OK, I'm not explicitly using threads.
<bnagy> don't suppose it could be a wacked dll, that is hangin on dllstart?
<masterkorp> bnagy: windows ? i tought windows were devices to let see trough the walls
<rue> Does it hang/block otherwise, if you don't exit at that point?
<Spooner> I don't know. As I say, I can hook into it and call all the functions on it as much as I like; it is only when I get to the end and want Ruby to finish that it fails.
<bnagy> yes, lots of people who don't know better think that
<bnagy> Spooner: the code might help... are you wrapping in drb or...?
mytrile has joined #ruby-lang
Jay_Levitt has joined #ruby-lang
malev has joined #ruby-lang
<Spooner> bnagy: https://github.com/Spooner/gale/blob/master/lib/gale/dll.rb (is just the wrapper bit).
<bnagy> that looks fairly normal, but how do you interact with it?
<Spooner> I don't need to interact with it to make it fail on exit. Interacting works perfectly if I do do it.
<Spooner> bnagy: The rest of the files in that directory are the Ruby-esque wrapper for the Dll.
<bnagy> yeah, I mean, it's a module, how are you using it?
malev has joined #ruby-lang
<Spooner> e.g. : Dll.info @handle, Dll::Info::HEIGHT
<erikh> oh damn
<erikh> I love seeing that quit message
<ddfreyne> haha
yumike has joined #ruby-lang
<Spooner> I haven't used FFI directly before, but obviously have used it indirectly before.
<ddfreyne> it's probably a G-line anyway </pedantic>
toretore has joined #ruby-lang
fayimora_ has joined #ruby-lang
mgraham has joined #ruby-lang
malev has joined #ruby-lang
<Spooner> bnagy: Any idea how I can bodge it to close properly, even if I have no idea why it is doing it?
<Spooner> bnagy: I have to suspect the dll is fubar (presumably ffi has an at_exit that cleans up and calls "I'm done" on the dll?).
lenilson_dias has joined #ruby-lang
sockmonk has joined #ruby-lang
<Harzilein> is there a nice way i can specify time ranges in terms of whole days?
looopy has joined #ruby-lang
<Harzilein> i.e. specify Date.parse("2011-02-12") for 2011-02-12 00:00:00 to 23:59:59, specify two dates and get the range from the start of the first to the end of the last one?
<Harzilein> then query that range for number of hours, if some other date is within its bounds etc.
rayners has joined #ruby-lang
<bnagy> Spooner: sry, can't say, I never had any trouble like it
<Spooner> bnagy: OK, thanks. I'll investigate further.
<Spooner> bnagy: Just tried on 187 (was using 193) for the same effect (on ffi 1.0.9 and 1.0.11)
<Harzilein> anyone?
Sailias_ has joined #ruby-lang
tomzx has joined #ruby-lang
niklasb has joined #ruby-lang
aroop has joined #ruby-lang
Indian has joined #ruby-lang
solars has joined #ruby-lang
bjensen has joined #ruby-lang
Sailias_ has joined #ruby-lang
slyphon has joined #ruby-lang
mistym_ has joined #ruby-lang
bjensen has joined #ruby-lang
andkerosine has joined #ruby-lang
looopy has joined #ruby-lang
robotmay has joined #ruby-lang
<francisfish> Harzilein: I think you need Time.parse - date doesn't have a time component :)
<francisfish> if you subtract one from the other it gives a number of seconds
<Harzilein> francisfish: what i'm after is not having to use constants like "00:00:00", "23:59:59", 86400 in _my_ code
<francisfish> so if you want to know if a date is within the range subtract it from the latest date and see if the number is less than the one that defines your range
<Harzilein> francisfish: luckily its in the context of rails and i found the related convenience methods in activesupport now
<Harzilein> francisfish: like their DateTime#end_of_day mixin :)
tbuehlmann has joined #ruby-lang
DotMH has joined #ruby-lang
<Harzilein> francisfish: they don't have special support for "whole days", but with the convenience methods it becodes bearable to read
<francisfish> ok cool - but you can just go to the next day and subtract 1 to get 23:59 :) but hacky
<Harzilein> francisfish: that does not convey the intent very well...
<Rabbitt> Spooner: you could try using something like StraceNT (http://www.intellectualheaven.com/default.asp?BH=projects&H=strace.htm) to see where it's hanging
<francisfish> agree - I would wrap it up in something that did, not put the calculations in my code
<francisfish> Harzilein: which is (I suppose) what you're doing anyway with that mixin
bglusman has joined #ruby-lang
Jay_Levitt has joined #ruby-lang
simon_weber has joined #ruby-lang
looopy has joined #ruby-lang
vereteran has joined #ruby-lang
<necromancer> can gemspecs install dependencies from a git repo like bundler can?
<lenilson_dias> hi guys! dir.each {|n| puts "#{n} Directory? #{File.directory?(n)}"} works only for current directory? because if dir = Dir.open(another path) all n is a file :( minus "." and ".."
<mistym_> lenilson_dias: Are you trying to recurse into subdirectories?
Dreamer3 has joined #ruby-lang
<lenilson_dias> mistym_: yes!
bryancp has joined #ruby-lang
bjensen has joined #ruby-lang
petercooper has joined #ruby-lang
<lenilson_dias> mistym_: but works only with FileUtils.cd 'path' then open currrent dir
jredville has joined #ruby-lang
<andkerosine> lenilson_dias: Dir['**/*'].entries { |file| puts file }
<andkerosine> Will go through every single file in the current working directory, including those in subdirectories.
<andkerosine> With an each in there somewhere...
<mistym_> lenilson_dias: BTW, if you're creating objects for directories/files, might want to take a look at Pathname.
joshkraemer has joined #ruby-lang
<mistym_> Oh hey, why do I have an underscore? I shouldn't have an underscore.
<lenilson_dias> i want move some files from directory to another in the same directory structure
fayimora has joined #ruby-lang
<bjensen> If I do student = Struct.new :name, :address, :email; s = Student.new; how can I iterate through the fields?
<andkerosine> bjensen: Struct#members
<bjensen> cool thanks
<mistym_> lenilson_dias: If you move a directory, its children get moved along with it. So you don't actually need to recurse unless the files you're moving are in a subdirectory.
wyhaines has joined #ruby-lang
<lenilson_dias> sorry my english... what i need is move files from a subdirectory to another subdirectory in the same path
<mistym_> Oh, OK.
<mistym_> So, andkerosine's solution will work to recurse and see all files and their paths.
<Rabbitt> lenilson_dias: to be clear, you're saying you want to move files something like: from: /some/path/a/* to: /some/path/b/*
<mistym_> lenilson_dias: And if you're doing repeated operations on a single file (say, both expanding its full path and moving it), look up Pathname. It's a much pleasanter way to work with filesystem items.
<Rabbitt> mistym_: +1
<erikh> Dir["/path/to/a/files*"].each { |x| FileUtils.mv x, '/path/to/b' }
<erikh> also don't be afraid to use inject here
<erikh> it's great for this shit
codewrangler has joined #ruby-lang
frequency9 has joined #ruby-lang
<lenilson_dias> Rabbitt: yes
<lenilson_dias> erikh: i will try this...
<lenilson_dias> thank you all
<Rabbitt> erikh: why not: FileUtils.mv Dir['/path/to/a/files*'], '/path/to/b', :verbose => true
<Rabbitt> do it all in one go there
<erikh> lenilson_dias: ^
<erikh> Rabbitt: that would work too
<erikh> probably better as well
<erikh> you could adapt what I did above there
<injekt> im surprised the &method hasn't had much traction like symbol to_proc is used EVERYWHERE
<injekt> wow that sentence sucked but im not going to fix it
<shevy> lol
jeffmoss has joined #ruby-lang
<shevy> we all have our moments when we are drunk without having drunk anything :)
<injekt> that is, ARGV.map(&File.method(:expand_path))
<erikh> injekt: &method isn't as flexible
<erikh> right
<erikh> that's bugly
<erikh> as in butt-ugly
<injekt> oh yeah I totally agree
<injekt> but ugly didn't stop people before
<erikh> hehe
<shevy> hmm
<shevy> but making things complicated will make people stop doing so eventually
<Rabbitt> yeah, look at all those people out their creating but-ugly people.. it's never-ending..
<injekt> shevy: that's not true
<injekt> look at rails
<erikh> Rabbitt: it's a cycle of butt
<Rabbitt> lol
<injekt> butt..ception?
<injekt> I'll see myself out
<Rabbitt> better: a negative feedback loop
<Rabbitt> or, butt-ugly loop?
<erikh> buttception
<erikh> hahahaha
<Rabbitt> hehe
<erikh> thank you injekt
<injekt> <3
<shevy> yeah, we could make a book "collection of worst practices in production level ruby code" and put rails in there :)
<injekt> no, it's not that
<erikh> Object.tap
<erikh> tap tap tap
<erikh> tappity tap
<injekt> rails isn't necesserily (omg how do you spell that) written badly
<erikh> rails is written quite well
<injekt> ^
<shevy> when I read "tap" I have to think of a card game I used to play
<erikh> it just looks like ass on the inside
<injekt> ^
<Rabbitt> "pretty girl".tap
<injekt> ASS
<erikh> shevy: magic?
<shevy> yeah
<injekt> perfect
<erikh> I play the online one
<injekt> sounds applicable
virunga has joined #ruby-lang
<shevy> it's kinda wired in my brain, I find it hard to associate "tap" with something else now :(
<rippa> ruby 2.0 needs to make more use of flip-fops
<rippa> *l
<erikh> ah
<injekt> rippa: no
<injekt> no it doesn't
<injekt> please just no
<erikh> needs more goatse operator
<erikh> =()-
<erikh> =()=
<injekt> wow
<Rabbitt> lolz
<shevy> lol
<mistym_> shevy: You need 3 mana to tap that object
<injekt> cannot unsee
<erikh> it's a thing in perl
<shevy> mistym_ ah that makes more sense!
<rippa> =(3Е)=
<erikh> $foo =()= /(match)(this)/
<injekt> lol @ = () =
<shevy> ewww
<erikh> it makes sense
<shevy> what's becoming of #ruby-lang
<injekt> it does
<erikh> when you know about context
Faris has joined #ruby-lang
solars has joined #ruby-lang
<Rabbitt> so I'm about to do something fun... bout to print out the object_id of every String object that's about to be freed (during GC).. gonna make for a fun log file..
<injekt> your description of fun is odd
<erikh> hee
<injekt> I'm drinking beer right now
<erikh> I have a 0mq program for you
<injekt> im having lots of fun
<erikh> oh boy do I
<erikh> it's a test of my messaging system that sends off around 300k messages
<injekt> :D
<erikh> (oh yeah, and they all get run through marshal)
<Rabbitt> erikh: hah - I'm actually do this to find a bug in ruby (I think ruby is gc'ing an object that's still in scope) that is causing a segfault
<bjensen> can I get the name of the method the code that is being executed is currently in?
<Rabbitt> erikh: 0mq is pretty nice - I'm actually using that right now
<erikh> bjensen: __method__
<erikh> I believe
imajes has joined #ruby-lang
<bjensen> is it ill advised to use it?
<injekt> no
<erikh> depends on what you're doing
<erikh> as with most things
<bjensen> right, thanks
<injekt> tru.dat
<erikh> Rabbitt: what library are you using for 0mq?
<Rabbitt> ffi-rzmq
<erikh> oh, and you're hitting it with that?
<erikh> iiiiiintteresting
<erikh> I haven't seen that yet
<erikh> rbczmq still has some issues there but I've been working with the author a bit
<injekt> zing
<Rabbitt> well, I don't think it's ffi-rzmq causing the segfault yet
<Rabbitt> only because turning of GC makes the segfaults go away
<erikh> right
<erikh> time to run until you get an abort trap and bt
<Rabbitt> well, I 'break sigsegv' in gdb and then go up from there
<Rabbitt> also, I have been getting some assertion errors - though /far/ less frequently
<erikh> oh, you're not even letting ruby dump its trace?
<Rabbitt> oh, I did initially
<Rabbitt> but, now I'm past letting it do that and just catching it in gdb directly so I can walk up without having to use a core
<erikh> hrm. you shouldn't need to do that
<erikh> gdb --args ruby ....; run; bt
<Rabbitt> it's also nicer being able to access internal methods directly - which you can't do with a core
RomyRomy has joined #ruby-lang
<erikh> at least i've never had to do it that way
dfr|mac has joined #ruby-lang
macmartine has joined #ruby-lang
<erikh> as soon as the signal fires I can step around and have a blast dirtying up the internals
<Rabbitt> yeah, you can do that with a core too
andkerosine has quit [#ruby-lang]
<Rabbitt> s/core/core dump/
<erikh> my gdb-fu is probably weak
<erikh> I'm missing something here.
<Rabbitt> heh - mine is too. I don't touch gdb anywhere near as much as I used to 10 years ago
darkf has joined #ruby-lang
<bnagy> it always boggles my mind how people start with the opposite end of occam's razor
<bnagy> 'ruby is gc'ing an object that is still in scope'
<bnagy> and I'm the only person to notice :/
gnufied has joined #ruby-lang
<Rabbitt> bnagy: I'm all ears on what else it could be :)
JohnBat26 has joined #ruby-lang
<bnagy> Something Else :)
gnufied has joined #ruby-lang
<bnagy> ffi-rzmq?
<Rabbitt> then why does it go away when GC.disable = true ?
gianlucadv has joined #ruby-lang
<bnagy> did you accidentally assign a socket to a var instead of an ivar or something?
<Rabbitt> the segfault doesn't happen in ffi or rzmq or anything related
<bnagy> well disabling GC doesn't prove that ruby is GCing wrongly
<Rabbitt> it hapepns in String#dup
<bnagy> just that an object is getting used after free
<Rabbitt> sure, it's not definitely causation but it's certainly an interesting correlation
<bnagy> I spent hours hunting one of those in some ffi code, and it was just me being braindead and not keeping hold of a pointer
coreydaley has joined #ruby-lang
<bnagy> but I think you need to make room for the possibility that if GC just ate shit at random OM NOM NOM NOM then someone would have noticed by now
malev_ has joined #ruby-lang
<bnagy> but ffi stuff is particularly tricky I guess cause it does magic that I don't understand
<bnagy> to make it look like you don't need to worry about free() for your FFI::Pointers etc
<shevy> wicked black magic
<Rabbitt> bnagy: so how could a string object (or any for that matter) get used after it's garbage collected (which, as far as I can tell from the code, doesn't actually free the underlying RString itself - just as.heap.ptr)? that doesn't make sense to me
<Rabbitt> if it's in scope, it's marked and therefore shouldn't be swept, and shouldn't have a NULL ptr
<Rabbitt> but, it does at the time of #dup
justinxreese has joined #ruby-lang
rtl has joined #ruby-lang
<bnagy> Rabbitt: NFI without knowing the code :)
burgestrand has joined #ruby-lang
<bnagy> in normal ruby involving no ffi stuff at all I would love to see a PoC of that though
<bnagy> once you have FFI stomping over raw memory with its Alf slippers then anything can happen
<Rabbitt> bnagy: activeresource-3.1.3/lib/active_resource/base.rb line 1282 is where it segfaults
<Rabbitt> bnagy: very valid points - I'll look at some other zmq libraries and see if it goes away after switching
<bnagy> Rabbitt: if you can replicate, then the #zeromq guys are super responsive an helpful IME
<Rabbitt> good to know
<Rabbitt> tx
JohnBat26 has joined #ruby-lang
dejongge has joined #ruby-lang
kp666 has joined #ruby-lang
adambeynon has joined #ruby-lang
Lars_G has joined #ruby-lang
* Lars_G stabs zenspider lovingly
ascarter has joined #ruby-lang
<lenilson_dias> erikh: works fine! thank you guys!
<erikh> enjoy
francisfish has joined #ruby-lang
butchanton has joined #ruby-lang
SuperTaz_work has joined #ruby-lang
wyhaines has joined #ruby-lang
Luxx_ has joined #ruby-lang
looopy has joined #ruby-lang
NARKOZ has joined #ruby-lang
DefV has joined #ruby-lang
Carnage\ has joined #ruby-lang
frangiz has joined #ruby-lang
jMCg has quit [#ruby-lang]
mistym_ has joined #ruby-lang
Marco has joined #ruby-lang
malev has joined #ruby-lang
ivanoats has joined #ruby-lang
hagebake_ has joined #ruby-lang
amerine has joined #ruby-lang
m3nd3s has joined #ruby-lang
zerdman has joined #ruby-lang
aroop has joined #ruby-lang
benanne has joined #ruby-lang
imperator has joined #ruby-lang
lsegal has joined #ruby-lang
rushed has joined #ruby-lang
jasiek has joined #ruby-lang
cesario has joined #ruby-lang
havenn has joined #ruby-lang
hagabaka has joined #ruby-lang
jasiek has joined #ruby-lang
UziMonkey has joined #ruby-lang
jxie has joined #ruby-lang
andrewhl has joined #ruby-lang
Muz has joined #ruby-lang
Muz has joined #ruby-lang
nuclearsandwich has joined #ruby-lang
butchanton has joined #ruby-lang
butchanton has joined #ruby-lang
mark_locklear has joined #ruby-lang
havenn_ has joined #ruby-lang
ascarter has joined #ruby-lang
Kyril_ has joined #ruby-lang
achiu has joined #ruby-lang
wallerdev has joined #ruby-lang
Shvillr has joined #ruby-lang
gianlucadv has joined #ruby-lang
Marco has joined #ruby-lang
Marco_ has joined #ruby-lang
Marco has joined #ruby-lang
Marco_ has joined #ruby-lang
ryanf has joined #ruby-lang
mrsolo has joined #ruby-lang
Fullmoon has joined #ruby-lang
topaz has joined #ruby-lang
topaz has joined #ruby-lang
bjensen has joined #ruby-lang
bosie has joined #ruby-lang
ryanf has joined #ruby-lang
fayimora has joined #ruby-lang
tekin has joined #ruby-lang
brianpWins has joined #ruby-lang
burgestrand has joined #ruby-lang
mikeric has joined #ruby-lang
havenn has joined #ruby-lang
bryancp has joined #ruby-lang
workmad3 has joined #ruby-lang
jacktrik has joined #ruby-lang
<theoros> in a library, what's a sensible place for code which is completely self-contained but which isn't its own gem?
<theoros> basically third-party libraries
<rippa> be quiet in a library
<rippa> in a module
<rippa> where else
amerine_ has joined #ruby-lang
gix has joined #ruby-lang
<theoros> maybe i wasn't clear, i mean where in the directory on the file system should it go
<theoros> e.g., in rails you might have "vendor"
robbyoconnor has joined #ruby-lang
<injekt> theoros: vendor
<burgestrand> theoros: %
<burgestrand> … ^
robbyoconnor has joined #ruby-lang
<theoros> alrighty, if that's the convention for gems too, i'm down
<injekt> just put it in lib
* injekt would put it in lib
* burgestrand would put it in vendor
* burgestrand would not look twice if it was in lib
<theoros> :)
<injekt> I dont wanna add another dir to the load path, lib is enough, I would just put it in its own folder
<injekt> and make sure credit was given
<theoros> right
<RomyRomy> hm, a question on the term 'syntactic sugar' for programming in general--- would you say this word encompasses the parentheses and semicolon in, for example "orchid();" ?
qpingu has joined #ruby-lang
curtism has joined #ruby-lang
curtism has joined #ruby-lang
Jake232 has joined #ruby-lang
<shevy> RomyRomy not the ";" part at least
<shevy> hmm
<shevy> or perhaps too
CoverSlide has joined #ruby-lang
<shevy> there may also be semantic differences
<shevy> super vs super()
<shevy> I find I use only the latter
<injekt> I've not once used the latter
<Mon_Ouie> It's more often super or super(…)
<injekt> yeah
<qpingu> I've had to do super() before
<injekt> sure, when you want to make sure NO args are passed
<injekt> super with out parensthesis will pass the arguments
<qpingu> It's the only way to call super when the base class takes no arguments but the current class does
<burgestrand> RomyRomy: syntactic sugar for me is something that does something else (otherwise achievable) but with a different kind of syntax to make it easier on the eyes/fingers, haskell has a typical example of this with its’ do-syntax if you need an example of what I mean
<burgestrand> In other words, it depends on the context
jacktrik has joined #ruby-lang
Marco has joined #ruby-lang
<RomyRomy> TY burgestrand
<Mon_Ouie> Ruby has a += b, which is a syntax sugar for a = a + b
<Spooner> I'm with burgestrand, though the () is largely sugar too (except in the case of #super, when it has meaning).
<burgestrand> I call it sugar when it’s sweeter than the alternative :p
<rippa> leaving out () is sugar
<injekt> ^
<imperator> give me some sugar baby
Indian_ has joined #ruby-lang
headius has joined #ruby-lang
dejongge has joined #ruby-lang
<crankharder> how do I change this module: http://pastie.org/3449440 , such that Location.new.sup == 123 ?
<crankharder> bah, forgot to add is_branson to the Location class in that example...
<crankharder> updated: http://pastie.org/3449440
curtism has joined #ruby-lang
curtism has joined #ruby-lang
<injekt> crankharder: I dont even understand what you're trying to do
<crankharder> trying to set a default value on @sup on new instances of Location
<injekt> what does 'foo' represent? you want 123 but it's not in your pastie? that makes little sense
brownies has joined #ruby-lang
<burgestrand> would probably make sense to use extend instead of adding ClassMethods and an included hook
<burgestrand> crankharder: default value of what?
ascarter has joined #ruby-lang
<crankharder> @sup
<burgestrand> crankharder: no; where are you specifying the value that should be the default?
<crankharder> ..i dont know, that's what i'm asking
<burgestrand> I usually start out writing the API I’d like to support, only then can I know if I can implement it
<Rabbitt> bnagy: welp, I think I can rule out ffi as the cause of my segfaults having switch from ffi-rzmq -> zmq gem (which doesn't use ffi).
m3nd3s has joined #ruby-lang
Marco has joined #ruby-lang
jredvill` has joined #ruby-lang
singpolyma has joined #ruby-lang
dejongge has joined #ruby-lang
guest4567 has joined #ruby-lang
petercooper has joined #ruby-lang
Marco has joined #ruby-lang
curtism has joined #ruby-lang
curtism has joined #ruby-lang
bryancp has joined #ruby-lang
workmad3 has joined #ruby-lang
twittard has joined #ruby-lang
robbrit has quit [#ruby-lang]
malev_ has joined #ruby-lang
pemeon has joined #ruby-lang
apeiros_ has joined #ruby-lang
MistyM has joined #ruby-lang
fayimora has joined #ruby-lang
twittard has joined #ruby-lang
benanne has joined #ruby-lang
rtl has joined #ruby-lang
workmad3 has joined #ruby-lang
mssola has joined #ruby-lang
bosie has joined #ruby-lang
Nisstyre has joined #ruby-lang
slimfit has joined #ruby-lang
jkprg has joined #ruby-lang
Wardrop has joined #ruby-lang
havenn has joined #ruby-lang
beiter has joined #ruby-lang
nofxx has joined #ruby-lang
shajith has joined #ruby-lang
Indian_ has joined #ruby-lang
chimkan has joined #ruby-lang
davidw has joined #ruby-lang
markstewie has joined #ruby-lang
zerdman has quit [#ruby-lang]
razumasu has joined #ruby-lang
havenn has joined #ruby-lang
fayimora_ has joined #ruby-lang
erpuds has joined #ruby-lang
davidw has joined #ruby-lang
achiu has joined #ruby-lang
therealpatgat has joined #ruby-lang
<vereteran> is there any gem able to tell me files mime type *not using extension* (will be used for uploads)?
<workmad3> vereteran: not sure of a gem... but you could shell out, execute 'file --mime-type -b <filename>' and capture the response
<vereteran> workmad3, seems i've found one: ruby-filemagic
<workmad3> vereteran: is the gem easier than mime_type = `file --mime-type -m <filename>`.chomp ? :)
<vereteran> workmad3, yes, when you have ~2-3k requests / second :)
<workmad3> it does assume you have file available though :)
<vereteran> matti, yeah, found it
<matti> :)
<vereteran> now trying to make it return http format mime type, i.e. image/jpen
<vereteran> *jpeg
<workmad3> vereteran: you mean... a mime-type
<vereteran> yeah
<vereteran> not just textual description
<matti> vereteran: Eric Wong is a very good coder.
<vereteran> erm... and what should i do with that?
<workmad3> vereteran: I was going to do a benchmark comparing shelling out to ruby-filemagic... but the native extension wouldn't build on my mac :)
<matti> Figure how to use it?
<vereteran> matti, neah :P why isn't it on gemcutter yet?
<matti> Are you lazy or what?
<vereteran> also from what i see in sources of filemagic it won't do :(
<manveru> vereteran: ffi-magic
<matti> Hi manveru
<manveru> matti: oi
<matti> manveru: FFI binding to libmagic, nice :)
<matti> manveru: Quicker than writing native extension :)
<manveru> ruby -rffi-magic -e 'p Magic.new(Magic::MIME).file("spec/magic.png")'
<manveru> "image/png; charset=binary"
<manveru> :)
jacktrik has joined #ruby-lang
<matti> manveru: Nice ;]
virunga has joined #ruby-lang
<vereteran> FileMagic.new(FileMagic::MAGIC_MIME_TYPE).file('hangs.png')
<vereteran> as it finds out i've reading old sources
jamw has joined #ruby-lang
<manveru> matti: :)
<manveru> my libraries never get into the top charts
<manveru> guess i should make some propaganda using sex scandals and kittens
<injekt> those things are not supposed to mix
Sailias has joined #ruby-lang
seanstickle has joined #ruby-lang
wyhaines has joined #ruby-lang
Natch| has joined #ruby-lang
Stalkr_ has joined #ruby-lang
<matti> manveru: Hahah
<matti> manveru: Claim that you have an affair with drbrain.
<matti> manveru: Should be enough ;]
<matti> And no kitten will be hurt ;d
<matti> manveru: I, being mainly in Operations never even get to publish anything ;p
l0st1 has joined #ruby-lang
<matti> [ You should feel better about yourself now ;p ]
<manveru> ^^;
<matti> http://www.youtube.com/watch?v=aHjpOzsQ9YI -- dubstep meets violin. But quite nice.
eydaimon has joined #ruby-lang
<eydaimon> anyone using a macbook air for development?
Natch| has joined #ruby-lang
Asher has joined #ruby-lang
<matti> Hi Asher
manhunter has joined #ruby-lang
<manhunter> hi, is ruby writen/created using C language?
<manhunter> downloaded 1.9.3
<manhunter> extracted and saw many .c and .h files
<matti> Yes.
savage- has joined #ruby-lang
<matti> :)
willdrew_ has joined #ruby-lang
<matti> manveru: The core (VM and interpreter) are.
<matti> Ops.
<matti> manhunter I mean :)
<manhunter> matti: are you the creator of ruby?
<matti> LOL, no.
<matti> manhunter: Google for Ruby ;p
<manhunter> that was hirushiku matsumuro
gregf has joined #ruby-lang
chimkan___ has joined #ruby-lang
<manveru> you could just hang out a big red flag with blue lettering that says "troll alert" and it wouldn't be more effective :)
<manhunter> but i saw many .c file not only one for interpreter.
<shevy> problem is
<shevy> he is also writing the same on #ruby
<manveru> nobody is in #ruby anyway
<bougyman> why isn't Open3 working for me?
<bougyman> i'm obviously doing it wrong.
<shevy> and he also already got answered there as well ... :\ :/
<matti> manveru: Point taken ;p
<bougyman> I copied your thing from bacon.task, manveru
<bougyman> but i'm obviously braindead
<manveru> bougyman: you try using it in rbx?
ascarter has joined #ruby-lang
<bougyman> manveru: no.
dous has joined #ruby-lang
<manhunter> there are many folders inside ruby-1.9.3, there i see all ruby files(.rb)
<manhunter> but extracting the ruby-1.9.3 i see the .c and .h files , are those C files for ruby interpreter only?
<manhunter> is ruby interpreter called the parser of ruby language?
<shevy> yes
slimfit has joined #ruby-lang
gate has joined #ruby-lang
wmoxam has joined #ruby-lang
ascarter has joined #ruby-lang
<manhunter> ./configure --prefix=/usr/local --disable-install-doc --with-opt-dir=/usr/local/lib , what is --prefix ?
starburst has joined #ruby-lang
Swimming_Bird has joined #ruby-lang
<workmad3> manveru: it's the directory where 'make install' will copy your compiled interpreter to
ryanf has joined #ruby-lang
<workmad3> sort of
<gate> workmad3: he left
<workmad3> oh, so he did
achiu has joined #ruby-lang
shevy has joined #ruby-lang
havenn has joined #ruby-lang
xjustinxreese has joined #ruby-lang
Mchl has joined #ruby-lang
slimfit has joined #ruby-lang
chimkan___ has joined #ruby-lang
chimkan_ has joined #ruby-lang