Topic for #ruby is now Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/
Tick-Tock has joined #ruby
<banisterfiend> shevy: if u troll him again im going to bet yo candy ass
<shevy> banisterfiend offer him my deepest condolences please
Targen has joined #ruby
<banisterfiend> shevy: u need to apologize personally markus!
<shevy> banisterfiend but I don't know him!
<shevy> where is he
<shevy> is he on IRC?
<banisterfiend> shevy: yeah on #zen-cms
<shevy> hmm that channel has a '-'
<danryan> banisterfiend: ok thanks, my understanding is solid then. I tried it previously using your example, but I get a nomethodError because the block is nil: https://gist.github.com/2004181#file_test
<danryan> just updated the gist to show the #action definition
tommyvyo has joined #ruby
Helius1 has joined #ruby
<banisterfiend> shevy: join #zen-cms
<banisterfiend> shevy: you can apologize in german btw, he speaks it fluently
<banisterfiend> shevy: hehe can u translate into english? http://www.youtube.com/watch?v=v0FVm_H_D18
emocakes has joined #ruby
startling has joined #ruby
rtyler has quit [#ruby]
<danryan> banisterfiend: huzzah! It's working: https://gist.github.com/2004181#file_working
<banisterfiend> danryan: cool, congrats
burns180_ has joined #ruby
<danryan> the block var in my previous examples were indeed nil because I was mistakenly defining a method that took a block, when indeed I wanted to define a method that called the block passed by self.action
<danryan> banisterfiend: thanks for the shove in the right mental direction :)
musha68k has joined #ruby
tatsuya_o has joined #ruby
dmn001 has joined #ruby
danheberden has joined #ruby
jacktrick has joined #ruby
marcuspat has joined #ruby
john___ has joined #ruby
lkba has joined #ruby
Chattaboxa has joined #ruby
armyriad has joined #ruby
musl has joined #ruby
armyriad has joined #ruby
t0mmyvyo has joined #ruby
max_ has joined #ruby
bwlang has joined #ruby
Synthead has joined #ruby
thecreators has joined #ruby
tomzx has joined #ruby
pu22l3r_ has joined #ruby
neurodrone has joined #ruby
neurodrone has joined #ruby
hadees has joined #ruby
wookiehangover has joined #ruby
lbotos has joined #ruby
burns180_ has joined #ruby
undersc0re has joined #ruby
thone_ has joined #ruby
n8ji has joined #ruby
john_smith has joined #ruby
i8igmac has joined #ruby
codezombie has joined #ruby
Norrin has joined #ruby
ZachBeta has joined #ruby
looopy has joined #ruby
BrokenCog has joined #ruby
bitrot has joined #ruby
startling has joined #ruby
looopy has joined #ruby
rramsden has joined #ruby
banisterfiend has joined #ruby
badabim_ has joined #ruby
iamjarvo has joined #ruby
<iamjarvo> this is pretty awesome http://rubyfiddle.com/
t0mmyvyo has joined #ruby
caiges has joined #ruby
hadees has joined #ruby
Avanine_ has joined #ruby
libertyp1ime has joined #ruby
robert_ has joined #ruby
<banisterfiend> iamjarvo: what's awesomea bouti t
Amorsen has joined #ruby
<iamjarvo> banisterfiend: i guess one could use irb. but sometimes im on a mobile device and want to try a snippeted
ascarter has joined #ruby
<iamjarvo> just a nice addition to the toolset
<banisterfiend> iamjarvo: there's a tonne of sites like that: tryruby, ideone (i think it's called) and a number of others
<banisterfiend> iamjarvo: it's not a particularly new idea ;)
<Boohbah> puts IO.readlines('h').grep /#{IO.readlines's'}/
<Boohbah> can you make it shorter?
<iamjarvo> banisterfiend: ahh i see,
aengusmcmillin has joined #ruby
Drewch has joined #ruby
badabim has joined #ruby
burns180 has joined #ruby
Avanine has joined #ruby
S1kx has joined #ruby
S1kx has joined #ruby
looopy has joined #ruby
h4mz1d has joined #ruby
seanstickle has joined #ruby
voodoofish430 has joined #ruby
fayimora has joined #ruby
Teomari has joined #ruby
coreydaley has joined #ruby
y_matsu_ has joined #ruby
igotnolegs has joined #ruby
_john has joined #ruby
td123 has joined #ruby
xpot-mobile has joined #ruby
MrGando has joined #ruby
drake10 has joined #ruby
drake10 has quit [#ruby]
felipe_Brz has joined #ruby
<felipe_Brz> can I use class_eval to initialize an insatnce variable?
<felipe_Brz> instance*
choffstein has joined #ruby
burns180_ has joined #ruby
libertyprime has joined #ruby
phantasm66 has joined #ruby
liluo has joined #ruby
<Boohbah> felipe_Brz: yes, but why not open the class and define methods directly?
<Boohbah> oh errr instance variable... no i don't think so
sbanwart has joined #ruby
al3xnull has joined #ruby
blueadept has joined #ruby
pu22l3r has joined #ruby
jellosea has joined #ruby
burns180_ has joined #ruby
pdtpatr1ck_ has joined #ruby
nonotza has joined #ruby
shtirlic_ has joined #ruby
<Boohbah> nice
banister_ has joined #ruby
stephenjudkins has joined #ruby
mvangala_ has joined #ruby
russfrank has joined #ruby
<russfrank> hi, does anyone know of somewhere I can find the minimum version of ruby that vim would need to be compiled against? i'm trying to compile vim with ruby support and seeing this https://gist.github.com/275dbc17e6c012f4258a
<russfrank> ruby version is 1.8.5 (it's EL5)
Sailias__ has joined #ruby
eywu has joined #ruby
Sailias_ has joined #ruby
headius has joined #ruby
Sailias__ has joined #ruby
Sailias_ has joined #ruby
albemuth has joined #ruby
<td123> russfrank: you should probably look into reusing the package code used to build the EL5 vim
<td123> just because it uses such old versions
sacarlson has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
vraa has joined #ruby
<russfrank> td123: that version of vim doesn't have other stuff I want, haha
burns180 has joined #ruby
<russfrank> (namely the necessary matching constructs for jslint vim integration)
<russfrank> so I figured I'd just upgrade vim as a whole, but this appears to be a version mismatch as to what the ruby-vim integration was written for
shadoi has joined #ruby
<td123> russfrank: which vim is this?
<td123> seems, debian uses vim 7.1 with ruby 1.8.7
cloke has joined #ruby
sizz_ has joined #ruby
pu22l3r has joined #ruby
MrGando has joined #ruby
pu22l3r_ has joined #ruby
<russfrank> td123: I'm trying to build vim 7.3 against ruby 1.8.5
<russfrank> td123: centos 5
<td123> hmm, ya, I probably would try ruby 1.8.7 at least if you want to use vim 7.3
<td123> in sid http://packages.debian.org/sid/vim-gtk deb uses rb 1.8.7 with vim 7.3 so there's a good chance that'll work :)
zaydana has joined #ruby
<td123> although they also patch a lot so I'm not certain
Araxia has joined #ruby
pdtpatr1ck has joined #ruby
cloke has joined #ruby
kevinbond has joined #ruby
ZachBeta has joined #ruby
drake10 has joined #ruby
cloke has joined #ruby
crodas has joined #ruby
drake10 has quit [#ruby]
A124 has joined #ruby
nobitanobi has joined #ruby
libertyp1ime has joined #ruby
MasterIdler_ has joined #ruby
pcboy has joined #ruby
zulax has joined #ruby
drake10 has joined #ruby
Kiall has joined #ruby
burns180_ has joined #ruby
nobitanobi1 has joined #ruby
yoklov has joined #ruby
CheeToS has joined #ruby
sizz has joined #ruby
Rishi_ has joined #ruby
drake10 has quit ["Linkinus - http://linkinus.com"]
Kiall has joined #ruby
blueadept has joined #ruby
rippa has joined #ruby
ScottNYC has joined #ruby
looopy has joined #ruby
s0ber has joined #ruby
nobitanobi has joined #ruby
robertjpayne has joined #ruby
nobitanobi has joined #ruby
nobitanobi has joined #ruby
moshee has joined #ruby
moshee has joined #ruby
mvangala_ has joined #ruby
rohit has joined #ruby
rramsden has joined #ruby
cloudgeek has joined #ruby
<cloudgeek> how i can see the output of this ruby programm
<cloudgeek> i just ruby string.rb
<cloudgeek> check a string as palidrome with this code
apok has joined #ruby
<td123> you need to use that function
<cloudgeek> i tried palindrome?("papa")
keymone has joined #ruby
<cloudgeek> it is not working
<cloudgeek> td123: how to do that , i am new to ruby
burns180 has joined #ruby
<td123> well, your code doens't print anything out when the string isn't a palindrome
<cloudgeek> td123: i making some chnage in code
radic has joined #ruby
nobitanobi has joined #ruby
<cloudgeek> td123: http://pastie.org/3553042
nobitanobi has joined #ruby
Richmond has joined #ruby
<cloudgeek> now also not working
<cloudgeek> td123: hey i don't how get output with this progamm , can help ,how can i get output
<cloudgeek> means what exactly need to write in bash
<td123> cloudgeek: http://codepad.org/TFTkT37T
<td123> works for me*
<td123> you shouldn't need to write anything in bash.. this is ruby (unless you want to write a shell script to pass in values which is kind of weird)
pu22l3r has joined #ruby
ed_hz_ has joined #ruby
startling has joined #ruby
stefanp_ has joined #ruby
simao_ has joined #ruby
PaciFisT has joined #ruby
CannedCorn has joined #ruby
Bosma has joined #ruby
<cloudgeek> td123:thanks
<cloudgeek> td123: i am not writing the 9th line in code
<cloudgeek> td123: now i got it
allaire has joined #ruby
nfluxx has joined #ruby
kenperkins has joined #ruby
<allaire> How come in ruby it's possible to call outside methods directly in the class, and not in any methods, like that: http://pastie.org/private/ggdydsdvglvguvv9ttbxvg
startling has joined #ruby
<shadoi> It's possible, they just have to be a class method
startling has quit [#ruby]
<shadoi> or maybe I don't get your questio.
<shadoi> +n
<allaire> Well, in C for exemple, I can't simply drop a line in my class calling another class's method
<allaire> I don't know if it makes sense?
<shadoi> You're not programming in C. :)
<allaire> Yeah I know that, but I'm wondering how it's possible, or what's the logic behind it
<allaire> in my pastie, I'm calling an init method form a gem class
<allaire> I just dropped it in my class, not even in a constructor, and it worked, how come?
<shadoi> why not?
gianlucadv has joined #ruby
<shadoi> The class is defined, why shouldn't you be able to call it's class methods?
<allaire> I know I can call the Parse.init method, but how come I can call it directly in the class, in no methods
libertyp1ime has joined #ruby
<shadoi> Because all classes are just an instance of Class
<allaire> lol...
<allaire> I see
<allaire> when they say ruby is 100% object, it's trully 100% object, hehe
<shadoi> It's a very common idiom to call class methods in the body, a lot of DSLs work this way.
MrGando has joined #ruby
<allaire> DSLs?
<shadoi> domain specific languages
<Boohbah> not to be confused with digital subscriber lines
<shadoi> hehe right
<allaire> oh
<allaire> but ruby isn't a DSL, so it's weird that we can do that :P
tonesfrommars|2 has joined #ruby
<Boohbah> ruby makes it easy to write DSLs
<Boohbah> or so i've heard
headius has joined #ruby
<seanstickle> Almost as easy as Haskell or SML
MrGando has joined #ruby
<A124> Anyone knows a good Ruby framework for flatfile databases?
cool has joined #ruby
kah has joined #ruby
hasrb has joined #ruby
<seanstickle> CSV
kah has joined #ruby
burns180_ has joined #ruby
twqla has joined #ruby
<stephenjudkins> A124: what do you mean "flatfile databases"?
<A124> stephenjudkins: Flatfile storage.
badabim has joined #ruby
<stephenjudkins> i have no idea what that means
sdrgh has joined #ruby
<A124> stephenjudkins: Or to be specific, I would like to store tens of thousands of small images of few kB each.
sdrgh has quit [#ruby]
<kah> this is more for Ruby on Rails but no one is responding there. .. can someone explain this to me a different way? http://pastie.org/3553200 specifically "This provides the Test::Unit::TestCase class inherited from on the next line
<stephenjudkins> and access them how?
<A124> Doesn't has to be flatfile.
<stephenjudkins> by key?
<stephenjudkins> is random access important?
<A124> Through Ruby, by keay, yes.
io_syl has joined #ruby
<A124> stephenjudkins: Access depends, can be both. The files will mostly not even change.
<allaire> shadoi: Last question, can I only call class methods directly in an class, or I can call praticaly everything, just as in a method
<stephenjudkins> leveldb is very fast and efficient
ringotwo has joined #ruby
<stephenjudkins> also, sqlite could probably do the job fine
<A124> stephenjudkins: Thank you, will have a look. Ether you search better, or you already know them, it seems :)
<shadoi> allaire: it's bad form to instantiate stuff and call instance methods I'd say. otherwise, yeah.
<stephenjudkins> A124: also consider just storing in your filesystem
<stephenjudkins> i think there are some filesystems that do it really efficiently
<shadoi> A124: I highly recommend kyotocabinet
<A124> stephenjudkins: Can you give me any hint? I already stored them in a FS, but the size overhead and speed is not decent.
<shadoi> it has storage engines for most scenarios
<A124> stephenjudkins: Oh. Umm.. I heard of kyoto, not tried though, Thank you.
<stephenjudkins> A124: no, i can't remember now... i think XFS was it? i'm really not sure
<stephenjudkins> good luck
<A124> Yup, xfs is possible, as xfs was used for newsgroup servers.
<A124> Thank you a lot ^^
hooper has joined #ruby
<A124> shadoi: Thanks for link to youtoo, sir.
Guest29310 has joined #ruby
bkirz has joined #ruby
MrGando has joined #ruby
Seisatsu has joined #ruby
panpainter has joined #ruby
wyhaines has joined #ruby
MrGando has joined #ruby
xiaotian has joined #ruby
chimkan_ has joined #ruby
fenec2 has joined #ruby
branliu has joined #ruby
branliu has quit [#ruby]
wilmoore has joined #ruby
Richmond has joined #ruby
senthil has joined #ruby
libertyp1ime has joined #ruby
Seisatsu has joined #ruby
MrGando has joined #ruby
Avanine has joined #ruby
krz has joined #ruby
Bosma has quit [#ruby]
bier has joined #ruby
banjara has joined #ruby
choffstein has joined #ruby
burns180_ has joined #ruby
eywu has joined #ruby
CannedCorn has joined #ruby
libertyp1ime has joined #ruby
tonesfrommars has joined #ruby
araujo has joined #ruby
araujo has joined #ruby
tonesfrommars|2 has joined #ruby
emmanuelux has joined #ruby
panpainter has joined #ruby
i8igmac has joined #ruby
rramsden has joined #ruby
rohit has joined #ruby
<Boohbah> hi rohit :)
<rohit> Boohbah: Hey
bgupta has joined #ruby
<MauvePussy> so test {:lol => 'wat'} would call test with a weird block, but test :lol => 'wat' calls test with an hash (I don't know how they call it in ruby)?
<MauvePussy> would it be the same as test({:lol => 'wat'})
<banister_> MauvePussy: Yeah
<MauvePussy> ty
<MauvePussy> is it dangerous to start using rails without knowing ruby that much?
symb0l has joined #ruby
<banister_> MauvePussy: not dangerous but perhaps more confusing
Eric_HOU has joined #ruby
<tonesfrommars> MauvePussy: you will learn ruby pretty fast that way out of necessity (which is what I'm doing right now) :-)
<tonesfrommars> Check this out, it's fantastic: http://rubykoans.com/
<banister_> tonesfrommars: either that, or you join #ruby even 2 years after you've been a 'rails programmer' still asking basic ruby questions (as is common here)
lewis1711 has joined #ruby
MrGando has joined #ruby
<tonesfrommars> banister_: I bet. Seems like all the helpers in rails makes it pretty easy to rush headlong without really getting a grip on the underpinnings of the language (which can be slippery from what I can tell)
Karmaon has joined #ruby
burns180 has joined #ruby
wmoxam has joined #ruby
libertyp1ime has joined #ruby
Morkel has joined #ruby
Richmond has joined #ruby
greenarrow has joined #ruby
Synthead has joined #ruby
kyle has joined #ruby
x0F_ has joined #ruby
Eric_HOU has joined #ruby
timonv has joined #ruby
sacarlson has joined #ruby
Emmanuel_Chanel has joined #ruby
adurity has joined #ruby
cloke has joined #ruby
flippingbits has joined #ruby
bobby has joined #ruby
eywu has joined #ruby
A124 has joined #ruby
amesha has joined #ruby
KL-7 has joined #ruby
<banister_> KL-7: good afternoon
<KL-7> banister_: hi
<banister_> KL-7: do you use stack_explorer ?
<KL-7> banister_: I was going to, but didn't have good use case for it recently.
<banister_> KL-7: ah ok np
marcuspat has joined #ruby
timonv has joined #ruby
burns180_ has joined #ruby
therion has joined #ruby
fbernier has joined #ruby
odinswand has joined #ruby
cloke has joined #ruby
therion has quit [#ruby]
al3xnull has joined #ruby
rushed has joined #ruby
flippingbits has joined #ruby
amesha has joined #ruby
c0rn has joined #ruby
cmasseraf has joined #ruby
ph^ has joined #ruby
justicefries has joined #ruby
cool has joined #ruby
Vert has joined #ruby
flingbob has joined #ruby
sacarlson has joined #ruby
MrCheetoDust has joined #ruby
csprite has joined #ruby
liluo has joined #ruby
csprite has quit [#ruby]
Spockz` has joined #ruby
n1x has joined #ruby
fbernier has joined #ruby
gokul has joined #ruby
sgmac has joined #ruby
amesha has joined #ruby
burns180 has joined #ruby
GoBin has joined #ruby
CheeToS has joined #ruby
CacheMoney has joined #ruby
fixl has joined #ruby
bkirz has joined #ruby
sgmac has quit [#ruby]
Gesh has joined #ruby
zakwilson_ has joined #ruby
marvin_ has joined #ruby
robertjpayne has joined #ruby
webusnix has joined #ruby
mafolz has joined #ruby
ed_hz_ has joined #ruby
nachtwandler has joined #ruby
hadees has joined #ruby
yann_ck has joined #ruby
madmax_ has joined #ruby
davidcelis has joined #ruby
hadees_ has joined #ruby
flippingbits has joined #ruby
ephemerian has joined #ruby
shruggar has joined #ruby
startling has joined #ruby
wulfgarpro has joined #ruby
amesha has joined #ruby
Avanine has joined #ruby
fr0gprince_mac has joined #ruby
Avanine has joined #ruby
ryanf has joined #ruby
gianlucadv has joined #ruby
tolland has joined #ruby
amesha has joined #ruby
adeponte has joined #ruby
burns180_ has joined #ruby
cyri_ has joined #ruby
banisterfiend has joined #ruby
FlyingFoX has joined #ruby
<tolland> hi, i am going have to spend the next few weeks digging about in a ruby project for a client, its a plugin for logstash
amesha has joined #ruby
<tolland> is there a good ide ?
<tolland> whats the eclipse for ruby?
<tolland> or is it literally eclipse for ruby?
<banisterfiend> tolland: most ruby programmers dont use ides
<ezkl> tolland: RubyMine is NetBeans/IntelliJ crap for Ruby. It sucks.
<ezkl> There are stories about RubyMine 4's speed. They are lies spread by charlatans.
<ezkl> and marketing dudes
<banisterfiend> hehe
<cool> lol
KL-7 has joined #ruby
trivol has joined #ruby
<banisterfiend> cool: very ambitious nickname
<banisterfiend> cool: can u live up to it
<cool> Yeah, I am cool :P
amesha has joined #ruby
<banisterfiend> cool: like fonzy?
simao has joined #ruby
<banisterfiend> ezkl: Templin?
<ezkl> banisterfiend: Yessir
<banisterfiend> ezkl: ah, i just github'd u
<banisterfiend> :)
<cool> banisterfiend, I am cool like cool (recursion FTW! :P)
musha68k has joined #ruby
InBar has joined #ruby
CacheMoney has joined #ruby
pdtpatr1ck has joined #ruby
tonini has joined #ruby
twqla has joined #ruby
symb0l has joined #ruby
LMolr has joined #ruby
pupoque has joined #ruby
cableray_ has joined #ruby
amesha has joined #ruby
startling has quit [#ruby]
robertjpayne has joined #ruby
fr0gprince_mac has joined #ruby
atmosx has joined #ruby
paissad has joined #ruby
trivol has joined #ruby
Helius has joined #ruby
thecreators has joined #ruby
Chris_Zeta has joined #ruby
amesha has joined #ruby
Chris_Zeta has quit ["Sto andando via"]
heftig has joined #ruby
pp01bit has joined #ruby
davidpk has joined #ruby
<davidcelis> RubyMine -= 1
<banisterfiend> davidcelis: what's wrong with it, dave?
<davidcelis> its like NetBeans/IntelliJ crap for Ruby
waxjar has joined #ruby
<davidcelis> also the resource usage
<davidcelis> mother of god, the resource usage
<davidcelis> it just sucks up all your RAM until there's none left
<davidcelis> none left for precious
<banisterfiend> davidcelis: who's precious
<banisterfiend> a buddy?
<banisterfiend> oh, that fat black chick
burns180 has joined #ruby
<banisterfiend> didnt know she coded ruby
<davidcelis> my precioussss
<davidcelis> it takes the preciouses
<davidcelis> the precious RAMs
CannedCorn has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
liluo has joined #ruby
Nss has joined #ruby
blacktulip has joined #ruby
liluo has joined #ruby
simao has joined #ruby
ukwiz has joined #ruby
MasterIdler has joined #ruby
undersc0re has joined #ruby
ikaros has joined #ruby
FarhanKhalaf has joined #ruby
tvw has joined #ruby
kajisap has joined #ruby
DuoSRX has joined #ruby
jlebrech has joined #ruby
keymone has joined #ruby
musha68k_ has joined #ruby
shruggar has joined #ruby
mengu has joined #ruby
pwnfactory_ has joined #ruby
seoaqua has joined #ruby
GoBin has joined #ruby
fixl has joined #ruby
igaiga has joined #ruby
nsadmin has joined #ruby
nsadmin has joined #ruby
burns180 has joined #ruby
francisfish has joined #ruby
stringoO has joined #ruby
KL-7 has joined #ruby
sam113101 has joined #ruby
trivol has joined #ruby
banisterfiend has joined #ruby
sam113101 has joined #ruby
trivol has joined #ruby
sam113101 has joined #ruby
yann_ck has joined #ruby
banister_ has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
pen has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
Redjack1964_ has joined #ruby
sam113101 has joined #ruby
undersc0re has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
adambeynon has joined #ruby
sam113101 has joined #ruby
tatsuya_o has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
akem has joined #ruby
odinswand has joined #ruby
sam113101 has joined #ruby
trivol has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
iocor has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
workmad3 has joined #ruby
sam113101 has joined #ruby
sacarlson has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
fr0gprince_mac has joined #ruby
sam113101 has joined #ruby
sam113101 has joined #ruby
<Vadim> guys i am learning ruby.... can somebody help.... why this code didnt work? http://pastebin.com/X63TLmxx
amesha has joined #ruby
sam113101 has joined #ruby
<Vadim> i wanna encode arrays element
sam113101 has joined #ruby
<matti> Eh.
<matti> :)
<banister_> Vadim: too bad, you're not allowed
<matti> Haha
<matti> banister_: :)
<matti> Vadim: This is like Ruby 101 "go figure read about arrays" question :)
sam113101 has joined #ruby
sam113101 has joined #ruby
burns180_ has joined #ruby
sam113101 has joined #ruby
ccapndave has joined #ruby
<matti> Vadim: Would that do? https://gist.github.com/2005964
sam113101 has joined #ruby
etehtsea has joined #ruby
WhereIsMySpoon has joined #ruby
sam113101 has joined #ruby
<WhereIsMySpoon> hey, im just starting to learn ruby as an on the side thing and im doing a few exercises
<matti> WhereIsMySpoon: :)
<WhereIsMySpoon> http://pastie.org/3554747 why doesnt this work? and can someone tell me how to do it properly?
sam113101 has joined #ruby
<matti> WhereIsMySpoon: Try Ruby Koans http://rubykoans.com/
<WhereIsMySpoon> matti, im following a tutorial
<matti> WhereIsMySpoon: Tutorials are too slow ;p
<matti> WhereIsMySpoon: And there is no spoon :P
<matti> ;D
<WhereIsMySpoon> >.<
<WhereIsMySpoon> can you please help me :P
<matti> [ Could not resist ;p ]
<matti> WhereIsMySpoon: Sure, ask the question kind Sir :)
sam113101 has joined #ruby
<WhereIsMySpoon> i did
bondar has joined #ruby
<matti> Oh, sorry ;]
<WhereIsMySpoon> also, im pretty sure this is the friendliest programming channel to date
<matti> Haha :)
<WhereIsMySpoon> i havent been eaten yet by hordes of elitist jerks :P
<banister_> WhereIsMySpoon: #C is more friendly
<matti> Ruby community is awesome :)
<WhereIsMySpoon> banister_, really? i doubt it
<matti> banister_: NO WAI
<WhereIsMySpoon> xD
<WhereIsMySpoon> i tried ##c++ the other day
<WhereIsMySpoon> that was a mistake
sam113101 has joined #ruby
<banister_> hehe #C++ is friendly compared to #C ;)
<WhereIsMySpoon> i could believe it
Talvino has joined #ruby
<WhereIsMySpoon> i quite like what i see of ruby so far
<WhereIsMySpoon> it seems very compact
sam113101 has joined #ruby
<WhereIsMySpoon> how does its performance fare compared to python/java/c++?
<matti> WhereIsMySpoon: "splitstuff = #{stuff.split(","}" -- syntax error.
<WhereIsMySpoon> i got that far :)
<WhereIsMySpoon> irb told me so
<Vadim> <matti> yes... thx you...
sam113101 has joined #ruby
<WhereIsMySpoon> matti, any idea on how to fix it? :P
sam113101 has joined #ruby
<matti> Vadim: Welcome :)
<matti> WhereIsMySpoon: Add missing ')' there.
sam113101 has joined #ruby
<matti> WhereIsMySpoon: A variation: https://gist.github.com/2005993
<WhereIsMySpoon> er
<matti> WhereIsMySpoon: #{} will cause variable interporation / execute code inside.
<WhereIsMySpoon> matti, i made a syntax error in typing it to pastie
<WhereIsMySpoon> one sec
<matti> Oh.
<matti> Haha
<matti> WhereIsMySpoon: Check my gist.
<WhereIsMySpoon> refresh it
<matti> Oh, sorry :)
sam113101 has joined #ruby
<matti> WhereIsMySpoon: You do not need #{} around split there.
<WhereIsMySpoon> ah
<WhereIsMySpoon> ok
<WhereIsMySpoon> yay
<WhereIsMySpoon> :3
<matti> WhereIsMySpoon: https://gist.github.com/2005993 -- variation :)
<WhereIsMySpoon> i saw iot
sam113101 has joined #ruby
<WhereIsMySpoon> it
<matti> WhereIsMySpoon: No, get "dudes" in order.
<WhereIsMySpoon> :)
<WhereIsMySpoon> sorry matti /
<WhereIsMySpoon> ?
<WhereIsMySpoon> what you mean
<matti> WhereIsMySpoon: Since the nature of Hash is that is not ordered (at least not in 1.8.x), you need to retrieve keys, and sort them :)
<WhereIsMySpoon> they came out sorted
<matti> WhereIsMySpoon: So you print dude1 then dude2 ...
<matti> WhereIsMySpoon: Oh, I am using 1.8 :)
<matti> ;p
<matti> I have to stop ;p
<WhereIsMySpoon> how do i check what im using
sam113101 has joined #ruby
<matti> WhereIsMySpoon: ruby -v
<WhereIsMySpoon> ah nvm
<WhereIsMySpoon> im 1.9.2
<matti> :)
sam113101 has joined #ruby
n1x has joined #ruby
<WhereIsMySpoon> i hope ruby will be more kind to my brain than c++ was
<WhereIsMySpoon> i tried for couple months to learn cpp after knowing java and python
<WhereIsMySpoon> was really hard
sam113101 has joined #ruby
<matti> Was it?
<matti> ;]
<matti> Go C man!
<WhereIsMySpoon> no
<matti> Embrace malloc and curly braces :)
<WhereIsMySpoon> im not learning C
<WhereIsMySpoon> waste of my time
<matti> Hehe
<WhereIsMySpoon> nobody programs in C
<WhereIsMySpoon> :p
<matti> I do!
<matti> :<
<WhereIsMySpoon> nah people do
<Vadim> and students
<WhereIsMySpoon> its just not what i want to do
<matti> Vadim: And kernel hackers ;)
<matti> WhereIsMySpoon: AYe aye
<matti> :)
* WhereIsMySpoon hacks matti's kernel
<WhereIsMySpoon> *with an axe
<WhereIsMySpoon> :p
<WhereIsMySpoon> thanks anyhow matti :)
pencilcheck has joined #ruby
Asher has joined #ruby
<jlebrech> is there a guard script to open newly created files?
Vert has joined #ruby
emocakes has joined #ruby
<WhereIsMySpoon> matti, how would i replace the stuff entries in the hash? if i just go through stuff[0], stuff[1] etc that counts the spaces and commas too, i just want to go over them via comma and replace them
al3xnull has joined #ruby
fayimora has joined #ruby
<WhereIsMySpoon> anyone? :P
machine1 has joined #ruby
<matti> WhereIsMySpoon: You mean, the key or the value under the key?
<WhereIsMySpoon> the values
<WhereIsMySpoon> like '1, 2, 3'
<WhereIsMySpoon> how would i replace them with '4, 6, 4' or 'banana, orange, tomato'
<WhereIsMySpoon> er wait
<WhereIsMySpoon> no
<WhereIsMySpoon> how would i replace them all with banana
<WhereIsMySpoon> so i have 'banana, banana, banana
<WhereIsMySpoon> '
gyre007 has joined #ruby
<WhereIsMySpoon> argh no that isnt it either lol
<WhereIsMySpoon> sorry start again
<WhereIsMySpoon> i have a hash
<WhereIsMySpoon> dudes = { 'dude1' => '1,2,3', 'dude2' => '2,3,4', 'dude3' => '3,4,5,6' }
<WhereIsMySpoon> i want to replace every 3 with banana
amesha has joined #ruby
<WhereIsMySpoon> and make it a permanent change
aiurea has joined #ruby
banisterfiend has joined #ruby
<aiurea> Hi.
<aiurea> I have a string '"Pachet XX",', and I'm trying to parse it with CSV in ruby 1.9.3. I'm getting Illegal quoting in line 1.
<aiurea> CSV.parse(s) fails with illegal quoting, CSV.parse('"Pachet XX",') works
symb0l has joined #ruby
iocor has joined #ruby
tayy has joined #ruby
Jake232 has joined #ruby
igaiga has joined #ruby
symb0l has joined #ruby
Squarepy has joined #ruby
burns180 has joined #ruby
madhatter has joined #ruby
Squarepy has joined #ruby
LMolr has joined #ruby
<aiurea> oh, it's even weirder. I'm reading the string from a file. With string = File.read('f'); I get string.size = 13. With string = '"Pachet XX",'; I get string.size = 12
DMKE has joined #ruby
<matled> aiurea: so? take a look at the string and see what makes the difference
<aiurea> f[0] => "
kajisap_ has joined #ruby
<aiurea> matled: it's an empty character
<aiurea> f[0] => ""
amesha has joined #ruby
<aiurea> the file does not have an trailing whitespace
<aiurea> oh wait, actually it does, but it's not visible in vim.
<robertjpayne> is there an easy way to split a string every X characters? So I have lines each of 64 chars?
stefanp has joined #ruby
stefanp has joined #ruby
skim1776 has joined #ruby
fayimora has joined #ruby
<skim1776> hello there, how can I store class constants? in class variables?
amesha has joined #ruby
Clooth has joined #ruby
negative has joined #ruby
<banisterfiend> skim1776: who cares
<skim1776> banisterfiend, what do you mean who cares?
<banisterfiend> well i personally dont care :))
canton7 has joined #ruby
<skim1776> banisterfiend, does it seem right to you - @@SOME_CLASS_CONSTANT
<banisterfiend> skim1776: seems pretty weird tbh
<skim1776> banisterfiend, for me too
<skim1776> that's why I'm here
<banisterfiend> why nto just use SOME_CLASS_CONSTANT
<banisterfiend> without the @@
sirdeiu has joined #ruby
wulfgarpro has joined #ruby
tayy has joined #ruby
<skim1776> banisterfiend, but then it would be created for all instances of the class and it's wrong since the variable belongs to the class
<banisterfiend> skim1776: then just store it in a class ivar, @class_blah
<skim1776> banisterfiend, @class_blah is also an instance variable - it's created for all the instances of the class
<banisterfiend> skim1776: no, it's only created for the class if u define it outside an instance method
<matled> skim1776: if you have a constant within a class there is only one object, not one per instance. the assignment is executed once when the class is defined.
<skim1776> matled, you mean a class variable(@@class_variable) or just a simple constant(SOME_CONSTANT)?
<matled> skim1776: class Foo; BAR = whatever; end
Dirkpitt has joined #ruby
<skim1776> matled, I got it, thanks
<Jck_true> in a nitpicking mood right now - (1..100).each do |x| - is there no way to make that count backwards?
<banisterfiend> Jck_true: (1..100).reverse_each
<Jck_true> ohhh reverse.each
<Jck_true> Thanks :D
<banisterfiend> no that wont work
<banisterfiend> oh yes it will
<Jck_true> Hehe ruby is like a showoff in language goodies haha :D
sirdeiu_ has joined #ruby
amesha has joined #ruby
<skim1776> Jck_true, there's also downto method 100.downto(1) do |x| ...
robert_ has joined #ruby
<Jck_true> skim1776: Even more sexy
tomzx has joined #ruby
MrGando has joined #ruby
<WhereIsMySpoon> i have a hash
<WhereIsMySpoon> <WhereIsMySpoon> dudes = { 'dude1' => '1,2,3', 'dude2' => '2,3,4', 'dude3' => '3,4,5,6' }
<WhereIsMySpoon> <WhereIsMySpoon> i want to replace every 3 with banana and make the change permanent
<WhereIsMySpoon> how do i do it
tk__ has joined #ruby
<matti> WhereIsMySpoon: Isn't the tutorial showing that?
<WhereIsMySpoon> not the one im following
<shevy> WhereIsMySpoon several ways. the easiest is to iterate through each pair and build a new hash
<heftig> dudes.each { |k,v| v.gsub!('3','banana') }
<WhereIsMySpoon> the exercise says to change the data struct
<matti> :>
<WhereIsMySpoon> ok cool :)
mdw has joined #ruby
<matti> WhereIsMySpoon: You can also do this in a little bit more manual way: get value, split on comma, replace 3rd item in the resulting array, put banana there, and join again, and put values back into the hash under a key.
<WhereIsMySpoon> matti/heftig i want to do it with dudes.collect do | k,v |
<WhereIsMySpoon> so that it prints it all out after im done
<banisterfiend> WhereIsMySpoon: are you in 1.9 or 1.8?
<WhereIsMySpoon> 1.9
<matti> WhereIsMySpoon: Get Learn Ruby the Hard Way, seriously.
sat has joined #ruby
<banisterfiend> WhereIsMySpoon: dudes.collect { |k, v| v == 3 ? 'banana' : v }
<banisterfiend> no
<banisterfiend> u get the point
<banisterfiend> hmm
<WhereIsMySpoon> cool
<WhereIsMySpoon> yea i got it
<banisterfiend> maybe collect doesnt return a hash in 1.9 im not sure
<WhereIsMySpoon> dudes.collect do | k,v |
<WhereIsMySpoon> v == 3 ? 'banana' : v
<WhereIsMySpoon> end # of do
<banisterfiend> no it doesnt
<banisterfiend> sorry
<shevy> great comment
<banisterfiend> you have to do boring stuff
<WhereIsMySpoon> prints this
<WhereIsMySpoon> => ["1,2,banana", "2,banana,4", "banana,4,5,6"]
<WhereIsMySpoon> which is what i wanted
<banisterfiend> Yeah
<banisterfiend> i thought u wanted a hash?
<matti> ;D
<shevy> lol
<WhereIsMySpoon> hm
<WhereIsMySpoon> lol
<WhereIsMySpoon> thats an array
iocor has joined #ruby
<dagobah> Easiest way to "[[:bob,:fred,:wilma,:betty]]" into an array without eval?
zommi has joined #ruby
<shevy> WhereIsMySpoon, but you already have the modified hash from heftig
<banisterfiend> dagobah: jesus christ
<shevy> why dont you simply print it out
<banisterfiend> dagobah: yuo were here asking this *exact* same queston lik 2-3 months ago
<banisterfiend> dagobah: are you insane?
<matti> LOL
<WhereIsMySpoon> lol
<matti> banisterfiend: :)
<WhereIsMySpoon> he's secret troll
<WhereIsMySpoon> ;)
<shevy> dagobah build your array and split the string on ','
Jake232 has joined #ruby
sirdeiu has joined #ruby
<shevy> what an odd nick he has got
<WhereIsMySpoon> what are most people using? 1.8 or 1.9
amesha has joined #ruby
<banisterfiend> WhereIsMySpoon: Hash[dudes.map { |k, v| [k, v.gsub(/3/, "banana")] }]
<shevy> WhereIsMySpoon 1.8 of course
<WhereIsMySpoon> no of course about it :) im new
<WhereIsMySpoon> but ok
<WhereIsMySpoon> so should i revert to 1.8?
<WhereIsMySpoon> or what
liluo has joined #ruby
<banisterfiend> WhereIsMySpoon: 1.9 is best
<WhereIsMySpoon> ok
<shevy> what do you mean with revert
<shevy> it's very little work to make things work on both
<WhereIsMySpoon> stop using 1.9
<WhereIsMySpoon> i have no idea shevy
<WhereIsMySpoon> i started yesterday
<jlebrech> i'm trying to resist saying "java don't scale" at work
<shevy> no your question is odd, make it work on both versions man
<robert_> morning, shevy :D
<shevy> hai robert_ :D
<robert_> hai :D
MrGando_ has joined #ruby
burns180_ has joined #ruby
daniel` has joined #ruby
amesha has joined #ruby
liluo has joined #ruby
unwitting has joined #ruby
<daniel`> I’m using Rake to run my tests, and the 5 lines of output Rake prints when a test fails ("rake aborted!", "Command failed ...", "", "Tasks: TOP => ...", "(See full trace...") annoys me; any idea how to suppress some of that? (neither --quiet nor --silent affect it)
<unwitting> I'm not sure about the Ruby best practice, can anyone give me some opinions on my simple Navigation helper, http://is.gd/VpHrVE
davidpk has joined #ruby
fayimora has joined #ruby
apeiros_ has joined #ruby
skim1776 has joined #ruby
sirdeiu has joined #ruby
g0bl1n has joined #ruby
g0bl1n has joined #ruby
canton7 has joined #ruby
gianlucadv has joined #ruby
MrGando has joined #ruby
adman65 has joined #ruby
amesha has joined #ruby
jcr has joined #ruby
looopy has joined #ruby
zulax has joined #ruby
Indian has joined #ruby
amesha has joined #ruby
Spockz has joined #ruby
<shevy> unwitting seems simple enough isn't it?
Rishi_ has joined #ruby
<WhereIsMySpoon> is there a good ide for ruby?
twqla has joined #ruby
cha1tanya has joined #ruby
<apeiros_> WhereIsMySpoon: most people prefer a good text editor
<apeiros_> but there's rubymine, netbeans and probably a couple of others
iocor has joined #ruby
iocor has joined #ruby
<apeiros_> rubymine looks nice, but is a resource-hog and occasionally quite a bit laggy (the latter being the main reason that I don't use it)
<shevy> WhereIsMySpoon the only real IDE for ruby that will work is the human brain
<WhereIsMySpoon> ah theres a netbeans plugin?
<shevy> WhereIsMySpoon, just ask apeiros_ what he is using
<skim1776> shevy, and you, which text editor do you use?
<apeiros_> WhereIsMySpoon: afaik there's a ruby/rails specific netbeans edition
<apeiros_> not just a plugin
<WhereIsMySpoon> oh i see
<unwitting> shevy: yeah I guess so, I thought maybe there was some flaws in the code. Or a different approach where I pass the Navigation instance as an argument to the Item.
<undersc0re> WhereIsMySpoon: Aptana is a pretty good idea
nanderoo has joined #ruby
seoaqua has joined #ruby
<shevy> skim1776 bluefish mostly, sometimes vim
<WhereIsMySpoon> undersc0re, whats the difference between aptana and netbeans in terms of featuers
<shevy> I still want a ruby editor written in ruby and independent of java :(
<seoaqua> is it possible to get several elements from a hash at one time?
OpenJuicer has joined #ruby
hello24816 has joined #ruby
hello24816 has quit [#ruby]
<apeiros_> seoaqua: see Hash#values_at
burns180 has joined #ruby
burns180 has joined #ruby
amesha has joined #ruby
<apeiros_> also, learning core api by heart is a good idea IMO
<undersc0re> WhereIsMySpoon: pretty sure NetBeans dropped Ruby support
Clooth has joined #ruby
A124 has joined #ruby
<OpenJuicer> Hi everyone!
<WhereIsMySpoon> undersc0re, i see it did but some group continued it
<skim1776> apeiros, learning all the API? sounds impossible
<OpenJuicer> I have problem using gem with rbenv by default
<OpenJuicer> it didn't work
<apeiros_> skim1776: core isn't that big
<apeiros_> skim1776: you know a dozen times more english words
<WhereIsMySpoon> wait hang on
<WhereIsMySpoon> aptana looks just like eclipse
<skim1776> apeiros_, you're right
<apeiros_> skim1776: also, most of it is pretty mnemonic
<undersc0re> WhereIsMySpoon: it's based off of eclipse
<skim1776> apeiros, also, implementing all design patterns in ruby would be cool
<WhereIsMySpoon> undersc0re, is it as slow?
<undersc0re> i don't think it is
Scorchin has joined #ruby
<shevy> hey
<shevy> where java is inside, slowness is unavoidable
<shevy> skim1776 80% of the API is english more or less. .include? .has_*? .exist? and so on
<shevy> it's more like "hello mister hash, do you have this element?"
LMolr has joined #ruby
<seoaqua> apeiros_, ok
<shevy> or "good old friend file, please tell me whether I exist or not?"
<apeiros_> shevy: actually, that's not quite true
davorb_ has joined #ruby
<WhereIsMySpoon> shevy, http://arcadia.rubyforge.org/ ?
<shevy> WhereIsMySpoon hmm
<shevy> I dunno what was with it last time I tried it
<shevy> lemme try again :D
<OpenJuicer> I got following error when updating gem with rbenv
<seoaqua> apeiros_, i want any several elements ,just the same as ' 10.times {var << hash.shift}
pu22l3r has joined #ruby
negative has joined #ruby
<Scorchin> Is there any way to get around having 'include Logging' for all classes that I want to expose some module methods to? In this case for a globally configurable Ruby Logger. Example code: https://gist.github.com/2d32eee3f45840ab5a27
<apeiros_> seoaqua: you mean you want the first N key/value pairs?
<Jck_true> Why am i getting an error on "dt = Date.new(year,month,1)" Saying it's an uninitialized constant?
<Jck_true> Oh because i haven't included the lib
<Jck_true> my bad
<WhereIsMySpoon> :D
michael_mp has joined #ruby
Vert has joined #ruby
<WhereIsMySpoon> hm
Clooth has joined #ruby
<WhereIsMySpoon> when i run arcadia it says *** LOAD ERROR ***
<WhereIsMySpoon> ----------------------------------------------
<WhereIsMySpoon> Arcadia require ruby-tk extension
<WhereIsMySpoon> and tcl/tk run-time
<WhereIsMySpoon> you must install before run ..
<WhereIsMySpoon> but i have tk and tcl
<WhereIsMySpoon> what gives
oponder has joined #ruby
daniel` has quit ["Killed buffer"]
<WhereIsMySpoon> oh wait nvm
amesha has joined #ruby
<WhereIsMySpoon> hm nope still same error
<WhereIsMySpoon> D:
poga has joined #ruby
<shevy> WhereIsMySpoon exactly my experience too
<shevy> tcl and tk should die
dbgster has joined #ruby
<WhereIsMySpoon> lol
<WhereIsMySpoon> why so shevy
`brendan has joined #ruby
<workmad3> WhereIsMySpoon: because they're ancient, arcane and require blood sacrifice to get working?
<WhereIsMySpoon> lol
<WhereIsMySpoon> i see
<WhereIsMySpoon> well
maasha has joined #ruby
<workmad3> are you just wanting something for playing with GUI stuff in ruby? if so, I can recommend a variant of shoes :)
<WhereIsMySpoon> workmad3, no i want an ide for ruby
<workmad3> WhereIsMySpoon: oh... aptana studio 3 has some good support, or if you're willing to pay, RubyMine
<WhereIsMySpoon> workmad3, aptana looks too much like eclipse for my taste =/
<workmad3> or create your own IDE-esque environment using Vim or emacs, or consider Sublime Text 2
<shevy> workmad3 uses vim :D
<WhereIsMySpoon> i am not willing to pay
<WhereIsMySpoon> ew
<workmad3> WhereIsMySpoon: that would be because it *is* eclipse ;)
<WhereIsMySpoon> i aint using vim or emacs
<WhereIsMySpoon> those things are the devil
<shevy> yeah
<shevy> there are not many other alternatives though
<workmad3> vim is good, once you've gotten it customised and learnt the basics
<WhereIsMySpoon> nope
<WhereIsMySpoon> not happening
<WhereIsMySpoon> :p
<undersc0re> I use QVim!
<shevy> for the next 50 years there will be a "vim vs. emacs" war... but no alternative in this
<workmad3> WhereIsMySpoon: your choice... I was just giving you options ;)
<shevy> it's not like ... "vim vs. emacs vs. eclipse"
<WhereIsMySpoon> hehe no worries workmad3
<workmad3> you could look at netbeans, not sure what the state of play with ruby integration is there
<skim1776> I'm using vim but I'm in doubts after listening to the rubyrogues podcast on text editors and ides
dql has joined #ruby
<workmad3> skim1776: are you happy, efficient and comfortable with vim?
<skim1776> workmad3, I don't know, I'm not using it on 100%, still learning
<workmad3> skim1776: yeah, that's true with vim... I'm still learning it... I'm more efficient with it than I ever was with aptana or rubymine though :)
<workmad3> (I've only been using it for a paltry 18 months though)
<maasha> vim <3
<skim1776> workmad3, have you tried emacs?
<apeiros_> ed! vim! vi! cat! nano!
<maasha> vimtutor and 10 minutes after you are flying free.
<workmad3> skim1776: I wish I could cauterize that section of my memory out of my brain... but yes, I did use emacs once
<maasha> emacs and you are stuck in a tar pit with the dinosaurs (flame bait)
<workmad3> I wrote a presentation using emacs and latex.... never again
<maasha> workmad3: hehehehe
MrGando has joined #ruby
bondar has joined #ruby
schovi has joined #ruby
<skim1776> workmad3, have you used it for a while?
<maasha> presentations is like the one place where you actually want WYSIWYG
<apeiros_> maasha: in free fall, you mean, yes?
<workmad3> skim1776: well, I spent about 1.5 months learning emacs in conjunction with latex in order to write that presentation...
adambeynon has joined #ruby
<workmad3> skim1776: but no, I've never really used it aggressively
<maasha> apeiros_: the funny thing about vim is that I keep discovering new smart features. and I forget them and rediscover them after a few years.
<shevy> lol maasha
<shevy> well actually you are right
<skim1776> workmad3, I think, it's not enough to judge about it. I'm going to spend some time for emacs after vim
<Jck_true> netbeans 7.0 broke the RUby extension - So hold you horses on that one
<shevy> 4 years ago I knew a lot more about vim than I do today, I forgot 80%
<maasha> so I get twice the pleasure!
<skim1776> shevy, are you serious?
<shevy> skim1776, yes
<workmad3> skim1776: it was enough for me to judge it and find it wanting :)
<skim1776> shevy, why?
<shevy> you need to wire the vim-way into your brain by constant practice
<maasha> shevy: once a year I spend a day or so identifying work tasks in vim that I can solve faster and smarter.
<workmad3> vim (and I posit, any good text editor) is mostly muscle memory, not knowledge
<workmad3> you need to get to the point where you don't think 'I want to copy so I press ctrl-c', you just think "I want to copy this text from here to there" and your fingers are already moving (or done)
<maasha> heh, year, some of the those visual block commands I cannot explain to people asking. Its in the fingers only!
<shevy> yeah
<maasha> visual blocks, folding and refactoring.
<shevy> I think if I could extend vim in pure ruby rather than this ugly vim-language I'd still use it
<workmad3> shevy: you mean like you can, if you compile ruby support into vim?
<skim1776> yeap, I use Ctrl+C for switching to the normal mode, even in notepad++ or visual studio
<shevy> workmad3 I dont think you can
<maasha> autocomplete words and lines.
<dbgster> Would it be correct to say Ruby is closer to javascript (being a prototype-oriented language or instance-based) compared to a class-based language?
amesha has joined #ruby
<dbgster> since all classes are actually instances of Object, kinda like javascript.
<shevy> for instance, what is the ruby-way for this vim extension: function sort() :%!sort endfunction
<maasha> "Ruby is Perl's younger and prettier sister!"
<workmad3> shevy: you can get ruby support into vim, I know that
<workmad3> shevy: and command-t.vim requires it (and has .rb files in the plugin)
<skim1776> maasha, ruby is a girl? I like that
<workmad3> I have no idea if it's *good*, but it's possible :)
<shevy> hmm I am going to look at those rb files
<Jck_true> maasha: Sadly still so young you get in trouble putting your hands on her ;)
<workmad3> also, the vim that you get pre-packaged with OS X doesn't have ruby support despite them both being standard, but MacVim does
pencilcheck has joined #ruby
<WhereIsMySpoon> dbgster, surely that means it's also very much like java?
<shevy> maasha ruby is quite old too :D
<dbgster> WhereIsMySpoon: how so?
<WhereIsMySpoon> java has an object superclass
<workmad3> (and that in part is why I moved away from the command-t plugin to molly.vim)
<workmad3> WhereIsMySpoon: the java object model is substantially different
<WhereIsMySpoon> all things that arent primitive types are objects
<workmad3> WhereIsMySpoon: and there isn't a 'primitive' type in ruby
<WhereIsMySpoon> oh i see
<WhereIsMySpoon> hmn
<workmad3> WhereIsMySpoon: superficially, I know what you mean though... but once you dig slightly beneath the surface, the differences are very apparent :)
gokul has joined #ruby
<shevy> workmad3, interesting https://wincent.com/products/command-t is indeed a ruby script
<WhereIsMySpoon> yea workmad3
<workmad3> shevy: yeah... but looking at the github repo, there's also some C in there, and probably some vimscript :)
<shevy> yeah it is a bit strange lol
linoj has joined #ruby
<dbgster> WhereIsMySpoon: but when you define a class, it isn't an instance of anything….
<workmad3> molly.vim is *much* simpler and gives mostly the same functionality :)
<workmad3> dbgster: you can get class objects in Java
<shevy> WhereIsMySpoon it is hard to compare java and ruby
<shevy> java is like the strict OOP general
<workmad3> dbgster: it's not even that hard... but it's certainly not the same thing as in ruby :)
<shevy> ruby is like the philosophizing aristoteles in your own garden
<WhereIsMySpoon> hehe
<WhereIsMySpoon> i think ruby looks a lot like python
<shevy> in parts
<workmad3> WhereIsMySpoon: you take that back!!!
<WhereIsMySpoon> but has some really nice oo stuff as well
<shevy> it does not have the:
<workmad3> :)
<WhereIsMySpoon> haha
<shevy> def foo(self)
<WhereIsMySpoon> i like python
<shevy> thingies
<WhereIsMySpoon> yea
<workmad3> I'm not fond of python... I find it too verbose
<shevy> yeah, I dont think a real OOP language need to have an explicit self
<dbgster> workmad3: ok, I was just saying ruby and javascript seem to be similar, but maybe I'm wrong…. prototype based seemed kinda the same…but i'm still learning
skim1776 has quit [#ruby]
<shevy> I like that you can omit the end though
<workmad3> dbgster: oh, you were talking about javascript, not java
<WhereIsMySpoon> haha yea i know what you mean about it being verbose
<WhereIsMySpoon> yea sorry
<WhereIsMySpoon> i took over a bit
<WhereIsMySpoon> <_>
<shevy> I still hope there comes the day for a language to dethrone python and ruby at the same time
<dbgster> workmad3: yes javascript
<workmad3> dbgster: again, it's a bit different... but you can certainly make javascript act like ruby (or vice-versa :) )
<workmad3> that's more because both javascript and ruby have a form of MOP though :)
<WhereIsMySpoon> workmad3, for some reason ive been thinking your name was "workmonad" in my head and have only just noticed it's workmad
<workmad3> WhereIsMySpoon: no, my name isn't a shortening of the common haskell epithet 'work, monad, work!!!'
adman65 has joined #ruby
<workmad3> ;)
<WhereIsMySpoon> what's mop?
<workmad3> MOP - MetaObject protocol
<WhereIsMySpoon> i see
<workmad3> it's basically a way to get in and rewrite how the object system works
<WhereIsMySpoon> ah right yea
<WhereIsMySpoon> ive seen that
<WhereIsMySpoon> that looks pretty nifty
virunga has joined #ruby
<workmad3> if you want to learn about MOP stuff explicitly though... have a look at common-lisp :)
<WhereIsMySpoon> although i cant see why you'd want that vs making a subclass
<WhereIsMySpoon> and use that
<WhereIsMySpoon> so that people dont get confused
<shevy> well
fr0gprince_mac has joined #ruby
<shevy> subclassing is probably the easiest thing to extend objects with functionality
<workmad3> it's also the most abused :)
<WhereIsMySpoon> whats the different between subclassing and mop
<WhereIsMySpoon> why would you want mop instead
fayimora has joined #ruby
<workmad3> MOP isn't an actual thing... I think you might be confused with 'module' now ;)
<shevy> mop?
<WhereIsMySpoon> er
<shevy> isn't that what you use to clean a floor?
amesha has joined #ruby
<WhereIsMySpoon> xD
<WhereIsMySpoon> i mean the thing where you open up an objects internals and change it
<shevy> modules are a lot worse than subclassing really
<WhereIsMySpoon> so that e.g. Array does something different
<shevy> WhereIsMySpoon, well you modify core classes, you can modify any ruby class
<workmad3> WhereIsMySpoon: that's part of the metaobject protocol
<WhereIsMySpoon> but why
<shevy> class Array
<WhereIsMySpoon> why not just subclass
<shevy> def something_here
<apeiros_> shevy: why do you consider modules worse than subclassing?
<workmad3> WhereIsMySpoon: but certainly not all of it... and why? because sometimes it's the cleanest, or best, or only way to do what you want
<WhereIsMySpoon> how can it be the only way? and when is it the best way?
<shevy> apeiros_, I always feel that when I have to use a module I am more limited than when I have to use a class. For instance, when I want all my objects in a project to have a @debug variable, it always was easier to do by subclassing
<workmad3> WhereIsMySpoon: FileUtils shows how it's a clean way. That reopens the File class and adds extra functionality but only once you actually need it
burns180_ has joined #ruby
<shevy> WhereIsMySpoon, well you dont have to modify class Array at all, you can subclass too
mengu has joined #ruby
<WhereIsMySpoon> workmad3, but why wouldnt you just make your own MyFile class
<WhereIsMySpoon> then if another programmer comes along in a year he wont get confused
<shevy> there is a lot of things over how you can get confused
<shevy> some ruby code of others confuses me a lot
<workmad3> WhereIsMySpoon: because it makes sense for the functionality to be on the File class... as opposed to cluttering the global namespace up with 'MyFile' and 'YourFile' and they both define the same method but do differeth things
<shevy> *by others
<workmad3> *different
<WhereIsMySpoon> hmm i guess
<workmad3> WhereIsMySpoon: and in reality, the confusion doesn't happen like people worry it will (unless you're going crazy with it)
<WhereIsMySpoon> oki :)
<WhereIsMySpoon> i guess as long as its documented properly
<WhereIsMySpoon> :)
<workmad3> WhereIsMySpoon: and FileUtils is part of the ruby standard library ;)
<WhereIsMySpoon> :)
cmasseraf has joined #ruby
<workmad3> WhereIsMySpoon: as for when it's the only way... you're using some published gem, and it contains a massive bug, but you don't have time to rewrite the gem and you don't want to maintain a fork of it...
<shevy> the less you have to modify core aspects of ruby, the better, if you want to distribute it to others
<workmad3> WhereIsMySpoon: so you can open up the class, correct just the specific bit that has a bug and you're sorted
yawniek has joined #ruby
<shevy> I think he speaks of his own experience here :D
<WhereIsMySpoon> workmad3, yea i guess thats a good example :)
<workmad3> WhereIsMySpoon: ideally, you'd make it so that the patch turns off if correct behaviour gets added in an update
<workmad3> shevy: heh :) not quite my own experience... but I've come close to doing it a couple of times ;)
<workmad3> shevy: or a couple of times where I just realised I was being stupid... but it is a potential use-case
<shevy> most of the time bugs in ruby projects that don't get fixed are dead projects, which makes me sad
<workmad3> yeah
clockwize has joined #ruby
<workmad3> but if it's on github, you could always take a project fork, update it and become the maintainer ;)
<shevy> they are planning to make all of stdlib gems though right now, which I think is nice
wyhaines has joined #ruby
<shevy> yeah
<workmad3> and yes, I like the idea of gemifying the stdlib
<shevy> I plan to do this with ruby-fpdf
<shevy> but my own projects get priority for a bit longer before I try at that
Jackneill has joined #ruby
<workmad3> pull in the parts you need, and uncouple the stdlib release cycle from the ruby release cycle :)
<shevy> yeah
<shevy> I think it is also psychological
<shevy> no difference to other gems anymore :)
<shevy> same that require 'rubygems' is no longer needed too
<shevy> I wonder why matz never thought about gems before they were written!
<workmad3> yeah... I got caught by that with FFI the other day
<workmad3> I had to work with 1.8.7 on a client server (1.9.3 just would not compile :( ), FFI gem installation requires the rubygem library pulled in but doesn't do it explicitly
<workmad3> had to remember how to use RUBY_OPT
<workmad3> (or is it RUBYOPT ?)
<apeiros_> RUBYOPT iirc
<workmad3> whichever it was, I put it into the profile so it wouldn't happen again and I could forget about it :)
<apeiros_> RUBYOPT is usually a bad idea IMO. makes you unaware of portability issues.
amesha has joined #ruby
<workmad3> the client is planning to get 1.9.2 or 1.9.3 onto the server, but because their infrastructure is a mess, they need to arrange with a different department to get the solaris package installed into the global zone which will then be replicated into their zone at the next update cycle
gokul has joined #ruby
<WhereIsMySpoon> D:
<workmad3> at which point, the -r rubygems I put into rubyopt won't be necessary and it being there won't be a problem
<workmad3> I'm still decompressing from the 2 days of 'fun' that was getting a rails 3.2 app installed on a badly managed, badly organised solaris zone :/
<apeiros_> ^^
<apeiros_> that's why you have this nick? :D
<workmad3> heh :) no, the nick is because that was my autogenerated uni username and it stuck
emocakes has joined #ruby
john_smith has joined #ruby
<WhereIsMySpoon> just out of interest
<WhereIsMySpoon> why are many servers run on solaris
<workmad3> because it is good... if you know what you're doing
jcr has joined #ruby
<shevy> hmm
choffstein has joined #ruby
<workmad3> zones are ZFS are the key things, I believe
iamjarvo has joined #ruby
mdw_ has joined #ruby
<workmad3> one of the guys I work with said 'Solaris is brilliant... as long as I never have to touch it'
<Tasser> you can actually run linux in zones
yxhuvud has joined #ruby
<workmad3> still, I'm away from that now :)
eldariof has joined #ruby
Zolrath has joined #ruby
looopy has joined #ruby
fayimora has joined #ruby
ephemerian has joined #ruby
td123 has joined #ruby
simao has joined #ruby
burns180 has joined #ruby
burns180 has joined #ruby
<undersc0re> workmad3: Solaris... :|
<pcboy> Does anyone know why the Date class hasn't anymore the ::load method to unmarshall it in ruby 1.9? I try to unmarshall old 1.8 objects and it fails because of that.
amesha has joined #ruby
<apeiros_> marshal isn't guaranteed to work across ruby versions afaik
<apeiros_> and Marshal.load(Marshal.dump(Date.today)) works fine
keymone has joined #ruby
lorandi has joined #ruby
mdw has joined #ruby
<seoaqua> apeiros_, sorry ,just got your msg. sort of yes, i need any first N pairs, even random
<apeiros_> well, you'll have to do a shift N times then, Hash#shift doesn't accept a param
<apeiros_> or convert it to an array…
Zolrath has joined #ruby
<pcboy> apeiros_: Yeah I know. But I didn't find a convenient way to marshal my data in fact. Marshal.dump is ultra convenient because it works all the time. I have some objects with complex attributes and .to_json doesn't work, so I need to define it for complex data types.
<pcboy> But in my case I still have Dalli::DalliError (Unable to unmarshal value: class Date needs to have method `_load'):
<apeiros_> pcboy: monkey patch it
emocakes has joined #ruby
choffstein has joined #ruby
Richmond has joined #ruby
john_smith has joined #ruby
sbanwart has joined #ruby
amesha has joined #ruby
bwlang has joined #ruby
geekbri has joined #ruby
ryannielson has joined #ruby
cpruitt has joined #ruby
mdw has joined #ruby
ninor has joined #ruby
Spockz has joined #ruby
cpruitt has quit [#ruby]
burns180_ has joined #ruby
<pcboy> apeiros_: I've done it. It works. But know I need to implement it correctly. That's another thing..
<fayimora> please whats the ruby indentation convention..2 spaces or 2 tabs and what the difference btw both of them
<unwitting> What is the best approach for configuration in a ruby gem? Should I create a singleton Configuration class or should I have a lot of class variables in my main class and use a setup() method to configure them?
<apeiros_> fayimora: 2 spaces
vraa has joined #ruby
amesha has joined #ruby
<apeiros_> unwitting: personally I hate gems that force me to have a single config only
<apeiros_> unwitting: consider e.g. a gem with a twitter-api, allowing only a single config - why does the author think I'd only want to connect to a single account in my app?
<fayimora> apeiros_: ok thanks..so whats the difference..it doesn't seem to make any difference when i shane it in text mate or sublime
<unwitting> apeiros_: you got a point
cantbecool has joined #ruby
<apeiros_> fayimora: there's no functional difference. it's only about style.
<fayimora> hmmm ok
cantbecool has quit [#ruby]
OpenJuicer has joined #ruby
bwlang_ has joined #ruby
schovi has joined #ruby
neurodrone has joined #ruby
neurodrone has joined #ruby
nari has joined #ruby
amesha has joined #ruby
v0n has joined #ruby
burns180_ has joined #ruby
fbernier has joined #ruby
iocor has joined #ruby
adambeynon has joined #ruby
Spockz_ has joined #ruby
nachtwandler has joined #ruby
io_syl has joined #ruby
bondar has joined #ruby
ceej has joined #ruby
bondar has joined #ruby
philcrissman has joined #ruby
EvanR has joined #ruby
EvanR has joined #ruby
bwlang_ has joined #ruby
crankycoder has joined #ruby
albemuth has joined #ruby
eka has joined #ruby
al3xnull has joined #ruby
phantasm66 has joined #ruby
Sailias has joined #ruby
WhereIsMySpoon has quit ["Leaving"]
mikewintermute has joined #ruby
amesha has joined #ruby
fearoffish has joined #ruby
burns180 has joined #ruby
<pcboy> apeiros_: What I don't understand is that the major and minor versions of Marshal didn't changed. But I still can't make a Marshal.load(str) in Date._load(str). It makes a dump format error. I'm on ruby 1.9.3..
<apeiros_> pcboy: it may well be a change in the way Date let marshal dump itself
<apeiros_> so while the marshal format itself didn't change, maybe the format of date in that marshal changed…
krz has joined #ruby
<pcboy> Mh yeah maybe.
davidpk has joined #ruby
tayy has joined #ruby
drake10 has joined #ruby
<pcboy> apeiros_: Do you know a good alternative to Marshal? Something very fast and that works out of the box like Marshal?
drake10 has quit [#ruby]
pdtpatr1ck has joined #ruby
tayy_ has joined #ruby
<apeiros_> pcboy: YAML
kpshek has joined #ruby
<apeiros_> but marshal is faster
<apeiros_> iirc about 3x
<Tasser> apeiros_, how about json?
timonv has joined #ruby
<apeiros_> Tasser: sucks ass
<apeiros_> try json on anything that isn't an array, hash, string or numeric
yoklov has joined #ruby
<pcboy> Yaml is too slow. And the dumped too dense.
<apeiros_> pcboy: you could use yaml to just migrate the data from old ruby to new ruby
Azure has joined #ruby
<pcboy> Yeah that's right. That's also something I wanted to try.
pencilcheck has joined #ruby
<pcboy> But I'm wondering if these case will happen often or not.
<pcboy> I need to find an alternative if that's the case.
<apeiros_> changes in marshal are rather rare IME
asobrasil has joined #ruby
<pcboy> apeiros_: Yeah but like you said, the change is not in Marshal here, but in Date.
<apeiros_> changes in yaml are even rarer, so using yaml to migrate when you upgrade your app is a viable generic strategy IMO
amesha has joined #ruby
<apeiros_> pcboy: ok, let me rephrase: changes to marshal and/or marshal-serialization of objects
dv310p3r has joined #ruby
BrianJ has joined #ruby
<pcboy> mh. Ok. I hope so.
wmoxam has joined #ruby
<shevy> yaml gets really slow once it gets large, I played around a bit with +1.3 MB yaml files, that is no fun
<apeiros_> pcboy: you could try extprot, at least I think that was its name
<apeiros_> it aimed to be a) faster than marshal, b) produce a more compact output and b) be available in other languages
bkirz has joined #ruby
PaciFisT has joined #ruby
akem has joined #ruby
akem has joined #ruby
v0n has joined #ruby
Drewch has joined #ruby
Targen has joined #ruby
wroathe has joined #ruby
<pcboy> apeiros_: Yeah I've seen it some time ago. But you still need to describe how to serialize your complex data structures. I also remember another one http://msgpack.org/ . But still the same problem, doesn't work out of the box for most of types.
amesha has joined #ruby
bwlang_ has joined #ruby
amesha has joined #ruby
burns180_ has joined #ruby
fmcgeough has joined #ruby
daniel_hinojosa has joined #ruby
iocor has joined #ruby
eka has joined #ruby
nari has joined #ruby
kevinbond has joined #ruby
Husel has joined #ruby
dr_bob has joined #ruby
Squarepy_ has joined #ruby
timonv has joined #ruby
ascarter has joined #ruby
<pcboy> There is still something I don't get. If I look at the load method of Date in 1.8.7 it's def _dump(limit) Marshal.dump([@ajd, @of, @sg], -1) end . And the _load method takes that array and create a new Date with it. So that's just an array. I shouldn't have a dump error in 1.9.3.
amesha has joined #ruby
aldodelgado has joined #ruby
ed_hz_ has joined #ruby
bbttxu has joined #ruby
arturaz has joined #ruby
oponder has joined #ruby
cha1tanya has joined #ruby
mikepack has joined #ruby
bwlang_ has joined #ruby
Afal has joined #ruby
td123 has joined #ruby
marcuspat has joined #ruby
v0n has joined #ruby
flagg0204 has joined #ruby
lkba has joined #ruby
wmoxam has joined #ruby
bitrot has joined #ruby
KL-7 has joined #ruby
mikepack has joined #ruby
amesha has joined #ruby
CannedCorn has joined #ruby
cantbecool has joined #ruby
ascarter has joined #ruby
mikepack has joined #ruby
ezkl has joined #ruby
burns180 has joined #ruby
SegFaultAX has joined #ruby
evilgeenius has joined #ruby
ckrailo has joined #ruby
<evilgeenius> I want to create my own simple exception Class, but not sure what the best Exception class is to inherit from in Ruby. Which is it?
ethd has joined #ruby
johndbritton has joined #ruby
alx- has joined #ruby
amesha has joined #ruby
rippa has joined #ruby
tayy has joined #ruby
malkomalko has joined #ruby
Russell^^ has joined #ruby
hasrb has joined #ruby
malkomalko has joined #ruby
matthewjalayer has joined #ruby
<keymone> evilgeenius: inherit from RuntimeError
<evilgeenius> keymone: Why not StandardError?
bwlang_ has joined #ruby
<keymone> that's semantics. runtime error inherits from standard error. are you trying to catch something during runtime? yes => inherit from runtime error.
axl_ has joined #ruby
theRoUS has joined #ruby
pater has joined #ruby
waxjar has joined #ruby
<keymone> all depends on what information your error provides - just check this http://rubylearning.com/images/exception.jpg and inherit from whatever suites your needs better
BeLucid_ has joined #ruby
<BeLucid_> hi, I have a question about IO.open and file descriptor 3 and 4 in ruby 1.9.3
Evixion has joined #ruby
<BeLucid_> I'm using a library, written for ruby 1.9.2 that seems to want to get ahold of stdin and stdout like this:
ezkl has joined #ruby
<BeLucid_> input = IO.new(3)
<BeLucid_> output = IO.new(4)
<BeLucid_> that doesn't work in ruby 1.9.3, you get: The given fd is not accessible because RubyVM reserves it (ArgumentError)
<Phrogz> ! :)
<BeLucid_> what's the right way to open stdin and stdout on 1.9.3?
tayy_ has joined #ruby
<Phrogz> Can you not just use the existing STDOUT and STDIN constants (or the reopenable $stdout and $stdin)?
* Phrogz doesn't know much about file descriptors.
CannedCorn has joined #ruby
CheeToS has joined #ruby
<Phrogz> Oops, that was meant to be http://stackoverflow.com/q/9637092/405017
schovi has joined #ruby
fayimora_ has joined #ruby
ed_hz_ has joined #ruby
akem has joined #ruby
amesha has joined #ruby
amesha has joined #ruby
fbernier has joined #ruby
kenperkins has joined #ruby
baroquebobcat has joined #ruby
MasterIdler has joined #ruby
akemrir has joined #ruby
bwlang has joined #ruby
fayimora_ has joined #ruby
wilmoore has joined #ruby
Synthead has joined #ruby
caiges has joined #ruby
Pheen has joined #ruby
jgrevich has joined #ruby
burns180_ has joined #ruby
amesha has joined #ruby
davidcelis has joined #ruby
jgrevich has joined #ruby
blueadept has joined #ruby
Smooz has joined #ruby
Drewch has joined #ruby
fayimora has joined #ruby
fayimora has joined #ruby
Synthead has joined #ruby
neurodrone has joined #ruby
neurodrone has joined #ruby
fayimora has joined #ruby
wookiehangover has joined #ruby
Zolrath has joined #ruby
wilmoore has joined #ruby
rippa has joined #ruby
mikepack has joined #ruby
amesha has joined #ruby
ascarter has joined #ruby
schovi has joined #ruby
porco has joined #ruby
baroquebobcat has joined #ruby
MrCheetoDust has joined #ruby
CacheMoney has joined #ruby
ringotwo has joined #ruby
Helius has joined #ruby
td123 has joined #ruby
cloke has joined #ruby
Tearan has joined #ruby
bkirz has quit [#ruby]
Eiam has joined #ruby
pedryvo has joined #ruby
SolarisBoy has joined #ruby
cmasseraf has joined #ruby
amesha has joined #ruby
pantsman has joined #ruby
punkrawkR has joined #ruby
pdtpatr1ck has joined #ruby
Drewch has joined #ruby
SegFaultAX|work has joined #ruby
gianlucadv has joined #ruby
wallerdev has joined #ruby
eywu has joined #ruby
atmosx has joined #ruby
i8igmac has joined #ruby
adac has joined #ruby
Araxia has joined #ruby
ghanima has joined #ruby
mdw has joined #ruby
c0rn has joined #ruby
amesha has joined #ruby
burns180 has joined #ruby
apeiros_ has joined #ruby
gyre007 has joined #ruby
KL-7 has joined #ruby
adeponte has joined #ruby
superguenter has joined #ruby
Smooz has quit [#ruby]
chimkan has joined #ruby
cbuxton has joined #ruby
greenarrow has joined #ruby
artOfWar has joined #ruby
apok has joined #ruby
cpruitt has joined #ruby
bwlang has joined #ruby
amesha has joined #ruby
skim1776 has joined #ruby
df11 has joined #ruby
<skim1776> is there any method for hash to add only those elements of the argument hash which don't exist in the first one?
<apeiros_> merge, either reversing receiver & argument, or with a block
<skim1776> apeiros_, which block?
<skim1776> apeiros_, ah, okay, got to the documentation, thanks
<apeiros_> blocks are those `do/end` and `{…}` things that you pass to methods
jgrevich has joined #ruby
ringotwo has joined #ruby
Vert has joined #ruby
adamkittelson has joined #ruby
lorandi has joined #ruby
alx- has joined #ruby
Alex-_ has joined #ruby
wilmoore has joined #ruby
amesha has joined #ruby
mrsolo has joined #ruby
bwlang has joined #ruby
<robert_> so, if I pass in a block to a class with several methods defined inside of said block, would it be possible to call one (or more) of the methods inside that blocK?
sroy2 has joined #ruby
systmkor has joined #ruby
Avanine has joined #ruby
LMolr has joined #ruby
<apeiros_> robert_: you can't pass things to classes
jlogsdon has joined #ruby
<apeiros_> you can only pass things to methods
bwlang_ has joined #ruby
burns180_ has joined #ruby
amesha has joined #ruby
dikim33 has joined #ruby
<dikim33> Can anyone tell me what happens after this? (1..10).find {|i| if i > 2}
<apeiros_> dikim33: what do you mean "after this"?
<apeiros_> what happens after that would depend on the code after that…
<dikim33> After this, there is no output of (1..10).find {|i| i > 2}
<dikim33> thanks, apeiros_
<apeiros_> dikim33: well, it will return the first value that matches the condition in the block
<robert_> er, not a class; but whatever. same difference. :p
<robert_> it's the initialize method
<apeiros_> you don't have any code there that outputs anything…
<robert_> (the constructor)
<apeiros_> robert_: you can store the block that is passed to a method, yes
<dikim33> or any out from inject statement after the wrong statement.
<apeiros_> and you can invoke that stored block later on, yes
<apeiros_> you use &block syntax for that: def foo(&block); @stored_block = block; end
<robert_> the block has functions defined inside it, though. I want access to those methods.
<apeiros_> robert_: hu?
<apeiros_> that makes no sense to me - pastie?
<apeiros_> dikim33: output and return values are two different things.
<dikim33> apeiros_: yes, I understand the syntax of inject but the question is after I put the wrong block statement, the inject statement does not return anything.
<apeiros_> dikim33: everything returns something
<dikim33> OK, apeiros_ : what I expected the normal behavior after the wrong block in inject.
dhruvasagar has joined #ruby
fayimora has joined #ruby
sizz_ has joined #ruby
<apeiros_> dikim33: look, how about you make a coherent question? paste the code, the input, what you expect to happen and what happens instead.
<dikim33> Sure, apeiros_ http://pastebin.ca/2126451
<dikim33> here it is.
<robert_> apeiros_: http://pastebin.com/8y7b0qar
<apeiros_> dikim33: you should not use irb with simple prompt
<apeiros_> it doesn't tell you that you're in a nesting
<apeiros_> which is what you're experiencing there
<apeiros_> exit from irb, restart it, then try again
<apeiros_> as of line 21 in your pastie, irb is waiting for that if statement to be closed.
<dikim33> I see. is there any way to go to the verbose prompt? I am new to ruby and it started this way on my mac.
Gesh has joined #ruby
<dikim33> apeiros_: ?
<apeiros_> dikim33: yes, create a file ~/.irbrc
<apeiros_> wait, I get the contents for it…
manojhans has joined #ruby
<apeiros_> oh, hm, I use a custom prompt and I don't remember the normal prompt by heart…
amesha has joined #ruby
<apeiros_> ah, I think this should do:
<apeiros_> IRB.conf[:PROMPT_MODE] = :DEFAULT
<dikim33> It seems to be surprising that I know how to go to the simple prompt with --simple-prompt option but I can not find to turn back to the normal.
robbyoconnor has joined #ruby
<dikim33> on the command line.
<dikim33> OK. apeiros_
<apeiros_> yeah, iirc osx has an irbrc that sets the prompt to simple. bad thing IMO
<apeiros_> oh, rails also (used, at least) was hard coded to set the irb prompt to simple (horrible idea, and the person who did it should be spanked)
cr_ellis has quit ["Leaving"]
<dikim33> apeiros_: OK, what about now? http://pastebin.ca/2126454
<robacarp> hmm...I don't think I've ever messed with the irb prompt
<apeiros_> dikim33: you see the number between : and > ?
<dikim33> what went wrong with my trial?
<apeiros_> usually it's :0>
<dikim33> Yes.
<apeiros_> that's the nesting depth
<dikim33> So, how can I go back to 0?
<apeiros_> on line 21 you can see that it becomes :1>, means you're nested one level deeper
<apeiros_> you close that `if` from line 20
bwlang_ has joined #ruby
<apeiros_> your syntax in line 20 is broken
<dikim33> I do know that my syntax is broken.
<apeiros_> but since irb doesn't evaluate it until you terminate the if, you don't get a syntax error
ephemerian has joined #ruby
<dikim33> ok. apeiros_
systmkor has joined #ruby
<apeiros_> you can close it by writing `end`
<Mon_Ouie> You can hit ^C to restart typing an expression
<dikim33> but I used the code block.
<dikim33> I see. apeiros_
<apeiros_> or what Mon_Ouie says
<dikim33> OK, Mon_Ouie
<apeiros_> in some cases on OS X, irb uses edit-line instead of readline, ctrl-c only works then when you also hit enter after ctrl-c (totally annoying)
tayy has joined #ruby
<dikim33> I am just curious.. the code block should make sure my if statement is complete, isn't it?
<apeiros_> ?
<apeiros_> code itself doesn't care about your syntax
<apeiros_> your interpreter (in that case irb) does
ceej has joined #ruby
<apeiros_> and since irb allows spreading a statement over multiple lines, it won't complain until your statement is considered "complete"
<dikim33> apeiros_: my question is code block is not just like block in the for loop or something in other languages?
<apeiros_> no
<apeiros_> it can be used in a similar fashion
MrGando has joined #ruby
<dikim33> apeiros_ : OK. at the beginning, it seems to be a little confusing. I think I know what happened now. Thanks a lot for your help.
amesha has joined #ruby
ringotwo has joined #ruby
ringotwo has joined #ruby
yoklov has joined #ruby
symb0l has joined #ruby
nobitanobi has joined #ruby
<shevy> dikim33 hmm that has no return value at all for you in irb?
<shevy> ah ok
<shevy> the "if" expected a matching "end" and thus waited
gianlucadv has joined #ruby
<nobitanobi> I have an array of JSON objects like this: [{"playerid":1 , "visits":2, "goals": 5}, {"playerid":2 , "visits":4, "goals": 10}] I would like to have an average of goals per visit for all the set of players (not the average of each player). I have done it doing each and accumulating each average and then doing the average of all those stored values. But, how would I do this in a ruby/cleaner way?
DMKE has joined #ruby
hashpuppy has joined #ruby
<shevy> well you need to gather all values
<shevy> I think .each is a very ruby way
<shevy> as for cleaner... hmmmm
<dikim33> shevy: yes, I happened to play with malformed if statement in inject and I did not know what happened but it is still confusing that irb does not check that my code block has the complete statement or not.
<hashpuppy> > user.class => User(id: ...). > user.is_a?(User) => false why?
burns180 has joined #ruby
<shevy> depends what you mean with cleaner nobitanobi ... you could try to play around with inject like:
<shevy> [ 5,2,52,52,2,54,5444 ].inject(0) { |x,y| x+y } # => 5611
<hashpuppy> user.class.to_s == "User" => true
<shevy> but I myself hate .inject and dont use it
<nobitanobi> actually, I shouldn't use cleaner
<shevy> dikim33 well it could not return earlier or?
<nobitanobi> it's like sometimes I get really amazed on how one liners in ruby help my eyes
<nobitanobi> >)
<shevy> it is actually indicating that you are in a nested way
amesha has joined #ruby
<shevy> the minor counter increased:
<shevy> irb(main):009:1>
<shevy> I changed my irb prompt, I hate this display :)
<shevy> my irb prompt is ""
<shevy> empty
<dikim33> no, it did not return anything until I put the 'end' statement after the code block. shevy
skim1776 has quit [#ruby]
<dikim33> shevy: and also, it was surprising that irb did not complain of the incomplete if-statement in my code block.
danishkhan has joined #ruby
<shevy> I really dont know this behaviour you describe
<dikim33> but if this is how ruby works, I have to live that way. http://pastebin.ca/2126454
<dikim33> shevy:
<shevy> yes I can see the code
<hashpuppy> oh
<shevy> how shall ruby know when you want to use an end and when not dikim33? :)
<hashpuppy> reload! seemed to screw things up
shruggar has joined #ruby
tvw has joined #ruby
voodoofish430 has joined #ruby
<dikim33> Well, I thought the code block should be completed.
NotMyself has joined #ruby
<shevy> remember that do/end is often synonymous with {} syntax too and that it is also a hash
<dikim33> shevy:
lolzie has joined #ruby
<shevy> yes but only the { and } you started a new one within the block though
<dikim33> I see. shevy
<shevy> you can use one-liner if/unless checks
<shevy> return true if 5 > 4
<shevy> it's all a bit complicated to parse
<shevy> you can also do
<shevy> if foo
<shevy> end.unless 5 < 5
<lolzie> Hi guys, could somebody please explain in a nutshell why string[0..0] returns the first character, and string[0..0] not?
<shevy> or even funnier
<shevy> class Foo
<shevy> end.something_here
<dikim33> Yes, I like the way that ruby deal with the if statement and other control flow. shevy
<shevy> I am confusing myself... don't do any of that please, it makes the head explode :D
<apeiros_> lolzie: you sure you wrote what you wanted to? :)
<shevy> lolzie ok what is the difference
<shevy> to me it looks as if you wrote 2x the same thing
<shevy> unless there is some invisible character
<lolzie> oops. I meant string[0...0] ;)
<shevy> ah that
<apeiros_> because 0...0 is from zero to zero excluding zero
edakiri has joined #ruby
davidpk has joined #ruby
<apeiros_> and since you just excluded the only offset you had…
<shevy> looks like a smiley face
<lolzie> apeiros_: ohhh I see, my understanding was the wrong way round! thanks
<shevy> lolzie it gets easier if you do this on numbers
edakiri has quit ["Ex-Chat"]
tayy has joined #ruby
shadoi has joined #ruby
<shevy> or ranges
<shevy> ('a'..'f').to_a # => ["a", "b", "c", "d", "e", "f"]
<shevy> ('a'...'f').to_a # => ["a", "b", "c", "d", "e"]
<lolzie> Cheers
mdw has joined #ruby
shruggar has joined #ruby
eka has joined #ruby
<hashpuppy> can you mixin protected methods?
philips has joined #ruby
<hashpuppy> mixin methods that you want protected
al3xnull has joined #ruby
<hashpuppy> maybe i should just inherit
<shevy> I myself think the more you can avoid mixins the better
akem has joined #ruby
akem has joined #ruby
<shevy> I actually dont know the answer, but I would assume that it is not possible
<shevy> hmm
<Mon_Ouie> When you include a module in a class, all instance methods from the module are accessible to instances of that class
<Mon_Ouie> Regardless of visibility
DrShoggoth has joined #ruby
<Mon_Ouie> (Visibility is preserved, though)
amesha has joined #ruby
SullX has joined #ruby
<shevy> aha
<shevy> hashpuppy, I guess you can mixin a protected method without a problem:
<shevy> hashpuppy, seems not possible http://pastie.org/3559032
<shevy> oops
<shevy> hashpuppy, seems possible http://pastie.org/3559032
<hashpuppy> :)
<hashpuppy> thanks
<shevy> apeiros_ are you giving similar interview questions too? :)
shruggar has joined #ruby
<apeiros_> shevy: hm?
<shevy> hehe
<shevy> thought you interview people
<apeiros_> ?
<apeiros_> why'd I do that?
<apeiros_> oh, or you mean as in: job interview?
<shevy> yeah
<shevy> to cause sweat on the forehead effects!
SullX has joined #ruby
<apeiros_> and similar to what?
<shevy> I dunno, all kind of hard-to-answer questions. I am sure there are plenty of ruby weird things to know
johnduhart has joined #ruby
<shevy> things like... trace_var
<shevy> __END__
<shevy> hmm things like that
<apeiros_> no, people fail already at easier things
<shevy> hehehe
n3m has joined #ruby
robbyoconnor has joined #ruby
amesha has joined #ruby
bwlang_ has joined #ruby
<apeiros_> shevy: but right now I'm curious
<apeiros_> we hired a perfect ruby noob
<apeiros_> and I'm training him
<apeiros_> I'm really curious how far I'll have gotten him in 3, 6 and in 12 months
<shevy> cool
<shevy> he was not exposed to ruby before? but to programming at least?
<ddv> isn't it better to hire someone who knows ruby :/
<apeiros_> ddv: if you can *find* one, sure
<ddv> or has a CS degree or something
<apeiros_> CS degree without ruby knowledge sadly is just an expensive trainee
A124 has joined #ruby
<ddv> hire a medior or senior then
<shevy> aren't they lazy past 30 years!
<td123> apeiros_: you can learn ruby in like a week
<ddv> yeah
<ddv> td123: the language
<ddv> td123: not the std lib :D
<td123> ya, that'll come with practice, I'm just saying that hiring based on knowledge of a language shouldn't be a deciding criteria imo
<apeiros_> td123: yes, that's what I did, but I know ruby for close to 8 years now and occasionally learn a thing
Uni has joined #ruby
robertjpayne has joined #ruby
<ddv> td123: yep
dark_soul has joined #ruby
<apeiros_> ddv: you say that as if they were there like sand on the beach
<apeiros_> hint, they aren't
<ddv> apeiros_: of course they aren't
<apeiros_> in the local rails community, half of the people visiting it are searching devs
dark_soul has quit [#ruby]
<td123> it's a positive if they already know ruby though :P
<apeiros_> it's really difficult to find rails devs at all, it's exceptionally difficult to find a *good* rails dev
dark_soul has joined #ruby
dark_soul has quit [#ruby]
<apeiros_> and since we don't have infinite time to search, we hired somebody who is intelligent, has basic knowledge and can be trained
<apeiros_> we're still looking for another rails dev, though
<ddv> I work at fairly large Dutch IT company as a Ruby dev and we also have trouble getting good developers
burns180_ has joined #ruby
<ddv> But I do expect people to teach themselves which is usually not a problem with grad students
mdw has joined #ruby
axl_ has joined #ruby
<apeiros_> oh, of course. the guy does homework
ilyam has joined #ruby
schovi has joined #ruby
<shevy> hehe
amesha has joined #ruby
<shevy> "as part of your homework, carry my backpack to my car"
<ddv> apeiros_: He is not allowed to learn on during working hours?
<ddv> -on
<ddv> lol
SolarisBoy has quit [#ruby]
<apeiros_> define 'learn'. of course he learns during work hours. we pair for programming.
Helius has joined #ruby
<apeiros_> so he learns the whole time.
<ddv> apeiros_: reading documentation, reading books, experimenting etc
<apeiros_> reading docs & books is homework
<ddv> apeiros_: Weird why is that homework?
<apeiros_> experimenting to an extent. he gets tasks assigned.
<apeiros_> it's like - things he has to do in order to get the expected skill are mostly homework
jschuur has joined #ruby
<apeiros_> while things he does to create products are at worktime
hippyphysicist has joined #ruby
symb0l has joined #ruby
yrrep has joined #ruby
<apeiros_> of course, to a certain degree you'll have to read docs and do research in order to create products, so it's not like it was a sharp line
<ddv> apeiros_: Ok
statbot has joined #ruby
<apeiros_> we're not a big IT shop, we're an internal IT department, and we're rather small (currently 4 people + that new guy)
<ddv> oh I work in a team of about 20 developers
<apeiros_> s/IT department/Software development department/ - we have a separate IT Services dep
<apeiros_> well, we're 2 devs :)
Sailias_ has joined #ruby
<apeiros_> 1 dba and 1 "leader" (hard to describe what he currently does)
maxok has joined #ruby
shruggar has joined #ruby
<ddv> we have juniors, mediors, seniors and leads
<apeiros_> on a total different topic: man, why didn't they consider adding a check-digit to phone numbers? :-S
<apeiros_> *totally
amesha has joined #ruby
<ddv> apeiros_: a dba on a 4 man team?
<apeiros_> ddv: the dba existed even waaaay before the software departement…
<ddv> apeiros_: Oh
<apeiros_> which makes sense - they had most software dev outsourced, but not the data
<apeiros_> so having a dba was a necessity, having a software dep wasn't
<apeiros_> but it was a smart move to create a software dep
<ddv> of course you say that :D
<apeiros_> (or: it was stupid to outsource software dev)
<apeiros_> yeah, no, I don't just say that :)
mlevin has joined #ruby
doug has joined #ruby
wmoxam has joined #ruby
<apeiros_> it's not difficult to hornswoggle somebody without proper knowledge…
<apeiros_> it's also rather easy to get caught in unfavorable lock-in situations
<apeiros_> and last but not least - you're handing out *a lot* of core competence and knowledge
mlevin has joined #ruby
<shevy> yeah
<shevy> in prison!
hadees has joined #ruby
<shevy> very unfavourable lock in situation that one is
aim-On has joined #ruby
<ddv> apeiros_: this is why we require all our devs to have different areas of expertise, we don't have one db who knows all things db, we expect everyone to attain this knowledge to a certain level, else we would be in big trouble if someone left the team (we use scrum mostly)
mlevin has joined #ruby
<ddv> *db guy*
<doug> ok, i gotta make this more terse:
<doug> "%.2f" % (((hours * 60 * 60) - (Time.now - Time.parse(punchedout, Time.at(Time.now - 24 * 60 * 60))))/(60 * 60))
<doug> (that's preceded by hours = 23.5; punchedout = "4:00pm"; require 'Time')
<apeiros_> ddv: well, we don't require it - but there's no need for a formal requirement - we simply couldn't work if we weren't all all-rounders…
amesha has joined #ruby
<doug> replacing by 60 * 60 by 3600 isn't what i'm talking about, either.
<apeiros_> ddv: we do the full stack, from server setup, over server maintenance, to app development, interface design, testing, etc.
<ddv> apeiros_: sure
<apeiros_> not that I'm completely happy with that
<apeiros_> but it does make for a nice experience
<apeiros_> doug: wth?
<apeiros_> doug: what is it supposed to do?
Keva161 has joined #ruby
<apeiros_> (also, require 'time', not 'Time')
<apeiros_> Time.at wants an epoch-time (integer), but Time.now - seconds returns a Time
<doug> apeiros: make it easy for me to trim my hours when i leave my harvest punchclock running overnight
<Sou|cutter> doug: 86400 and 3600
<Sou|cutter> these are very standard numbers
<rippa> apeiros_: works on windows (☞゚∀゚)☞
<apeiros_> rippa: yes, but it's redundant
lateau_ has joined #ruby
<apeiros_> Time.at(Time.now) == Time.now
<apeiros_> it's pointless to do
<doug> hm, do i have that?
<apeiros_> Time.at(Time.now - 24 * 60 * 60)
<apeiros_> yes, you do
<doug> i'm doing that so that the punchedout is interpreted as happening yesterday
<apeiros_> Time.at(Time.now - 24 * 60 * 60)) == Time.now - 24 * 60 * 60
<doug> ah, ok
hippyphysicist has joined #ruby
<nobitanobi> I have a question... I have an object with the following attributes: @attributes={"id"=>1, "matches"=>10, "goals"=>"13"}
<nobitanobi> When I try to do values_at("goals", "number_of_matches") -- I get undefined method `values_at' for
CannedCorn has joined #ruby
<apeiros_> nobitanobi: you do @attributes.values_at(…), yes?
amesha has joined #ruby
<nobitanobi> mmm, no
<nobitanobi> that's right
<nobitanobi> I need to access the attributes
<nobitanobi> I was doing object.values_at
<apeiros_> well, your object doesn't have a values_at method
<doug> good enough for now i spose
<doug> apeiros_++
<rippa> you can implement it though
<rippa> do a pass-through to attributes
Sailias_ has joined #ruby
<nobitanobi> rippa: spend_per_visit.attributes.values_at
<nobitanobi> this made it
doug has quit [#ruby]
ceej has joined #ruby
hippyphysicist_ has joined #ruby
hashbangchris has joined #ruby
mengu has joined #ruby
malkomalko has joined #ruby
pedahzur has joined #ruby
axl_ has joined #ruby
hippyphysicist_ has joined #ruby
tommyvyo has joined #ruby
burns180 has joined #ruby
amesha has joined #ruby
lateau_ has quit [#ruby]
<pedahzur> I am dealing with a ruby application (that is not mine) running on a server (that is mine) that is regularly taking 100% CPU. The dev says there is nothing in there that should cause that kind of CPU usage (no CPU bound stuff, no busy loops). strace shows a lot of stuff like this: http://pastie.org/3559341 Any hints as to where I should start the trouble shooting? Thanks!
audrius has joined #ruby
<apeiros_> pedahzur: public facing app?
<apeiros_> pedahzur: anyway, the dev should probably just profile the app
c0rn has joined #ruby
<pedahzur> apeiros_: No, server side.
<pedahzur> apeiros_: Yeah, profiling would be good. I'll have to see if he can replicate our entire environment in a dev env. Is there a way to attach to a running ruby VM to profile?
marcuspat has joined #ruby
<RubyPanther> pedahzur: You could always just put your BOFH hat on and shut them down until they find their problem.
<apeiros_> that depends on what you use to run the app
<apeiros_> but most likely not
<pedahzur> RubyPanther: Umm...the application is part of our testing infrastructure. I'd have LOTS of people really mad at me if I tried that. :)
Vert has joined #ruby
kaneda has joined #ruby
<pedahzur> apeiros_: It's just the standard C ruby VM, I believe.
<pedahzur> apeiros_: ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
<apeiros_> pedahzur: you can run any ruby app with ruby -rprofile
<apeiros_> but beware, it can run up to a 100x slower
<apeiros_> there's better profilers
<hashbangchris> Hi rubyists, is there a way to make a string containing '#{something}' evaluate this /later/ on? This would be very useful for me however I can't figure it out.
<apeiros_> hashbangchris: other than eval? no
<apeiros_> hashbangchris: that's what template engines are there for. see ERB and consorts
<hashbangchris> thanks, so I guess I should write more elegant code then :)
scalebyte has joined #ruby
<shevy> hashbangchris always
<scalebyte> i have something like... @user.about_me.blank?
<apeiros_> hashbangchris: the simplest solution is a proc
<shevy> elegance, beauty...
<shevy> scalebyte, not giving up on rails are you? :D
banisterfiend has joined #ruby
<scalebyte> can i do something like @user.about_me.length = 500 ?
<scalebyte> shevy: this is pure ruby
<shevy> if you have control over the code, sure
<apeiros_> scalebyte: = is assignment. == for comparison.
<shevy> def length=(i)
<shevy> @length = i
<RubyPanther> hashbangchris: You just us a sprintf like '%s' % [something] and your something can happily live in the substitution array and if you want to do it later, you just don't use the % operator yet
<shevy> but I think you dont have control, you seem to just want to glue together some railsy things
danishkhan has joined #ruby
<apeiros_> hashbangchris: as of ruby 1.9, sprintf/String#% also can do keyword substitution:
king313 has joined #ruby
<apeiros_> "Hello %{entity}" % {:entity => "World"} # => "Hello World"
<hashbangchris> RubyPanther, apeiros: Hey, I'm on 1.9.3 so that helps a lot, thank you!
fungoat has joined #ruby
tomzx has joined #ruby
zodiak has joined #ruby
<i8igmac> i have a client, when the server closes the connection, i need the client to check if its closed then exit
<i8igmac> socket.closed? will always read false until the client closes the socket
moemen has joined #ruby
<i8igmac> how do i check if the server closed the socket
<scalebyte> shevy: can i check in a single line : unless @user.about_me.length = 500
<shevy> what are you doing man
<hashbangchris> Oh, that's really nice, it helps me to be MVC in something that would have been a really ugly or very long script otherwise.
<shevy> you must learn ruby
<shevy> you are going to die
<shevy> you did not read what apeiros_ wrote either
iamjarvo has joined #ruby
<shevy> return false unless @user.about_me.length == 500
<scalebyte> shevy: whats the better way ? can I compare it directly or
<shevy> you can do that
amesha has joined #ruby
<i8igmac> if socket.eof==true; exit
<scalebyte> shevy: yes I am indeed using == for comparing
<scalebyte> apeiros_: ^^
<iamjarvo> is it possible to append a string to a symbol so say you have :foo i want to doo :foo + bar and make :foorbar
<iamjarvo> im guessing not
mdw has joined #ruby
<scalebyte> shevy: lenght is not a method
<scalebyte> shevy: length
<hashbangchris> lamjarvo: I always imagined symbols being similar to something in assembler so I'm very sure the answer is no :)
hippyphysicist_ has joined #ruby
<scalebyte> shevy: length == :)
<shevy> why do you tell me this
<shevy> I have no idea what @user.about_me returns
<shevy> you probably dont know either
<shevy> otherwise you would know what @user.about_me is
hippyphysicist__ has joined #ruby
<shevy> ruby strings know .size and .length
<shevy> "abc".length # => 3
<shevy> so whatever shit @user.about_me returns, I bet it is not a string in that case if the above code snippet does not work for you
shruggar has joined #ruby
<RubyPanther> If you apply the Principle of Least Surprise, @user.about_me would be least surprising if it returned a string or nil
<i8igmac> so, ca some one show me how to check if a connection to the server is still active?
Uni has joined #ruby
yann_ck has joined #ruby
<shevy> i8igmac I would if I'd know but I don't so I can't
<i8igmac> socket.closed? will always read false until the client does a socket.close
<RubyPanther> i8igmac: Generally, you write to it and check if it succeeds
neozen has joined #ruby
neozen has quit [#ruby]
<i8igmac> is there a another way?
<RubyPanther> Otherwise any attempt to decide is theory and might be wrong. Assuming ethernet.
hippyphysicist_ has joined #ruby
<i8igmac> ill give it a shot
<pedahzur> apeiros_: Thanks. I'll see what I can do.
cmasseraf has joined #ruby
vandemar has joined #ruby
Seisatsu has joined #ruby
amesha has joined #ruby
hippyphysicist has joined #ruby
<hashpuppy> can someone help me get this working: http://paste.pocoo.org/show/cxkiMlLDqil2GhytdFRD/
<hashpuppy> the hash looks something like this, if it's not obvious: {:location=>[:format], :start_date=>[:not_date_range_date], :end_date=>[:not_date_range_date], :user=>[:not_user]}
<Tasser> 閣 <- that was 'ät' somewhen - how did this happen?
nfluxx has joined #ruby
<apeiros_> Tasser: cosmic interdimensional bitmutation
<shevy> hehe
hippyphysicist_ has joined #ruby
<scalebyte> truncate(@user.about_me, :length => "6").strip_html unless @user.about_me.blank? not working
<hashpuppy> what i have doesn't make sense, but i hope you can see the intent
hippyphysicist_ has joined #ruby
skrewler has joined #ruby
<shevy> well
<shevy> you have a hash, whose keys point to one-member arrays
<shevy> that is not soooooo untypical even though it is a little odd
<shevy> (atypical? Hmm)
<hashpuppy> in this example they only have one
<shevy> guess it is "atypical"
<shevy> please pastie.org is so much better than paste.poopoo.org
<shevy> als "not working". you dont provide any error message.
neozen has joined #ruby
adamjleonard has joined #ruby
neozen has quit [#ruby]
pedahzur has quit ["Konversation terminated!"]
<hashpuppy> well, i don't think the code makes much sense. but i can provide an error message
<hashpuppy> undefined method `<<' for nil:NilClass
burns180_ has joined #ruby
<hashpuppy> in block in on
<hashpuppy> i know why that is
<hashpuppy> i wonder if it's possible to do this w/o an instance variable, though
hippyphysicist has joined #ruby
kirun has joined #ruby
rramsden has joined #ruby
<hashpuppy> ok, well i got it by passing in output
<hashpuppy> does lin #10 make much sense: yield(true) if block_given?
<hashpuppy> i'm just going to rewrite this
skrewler_ has joined #ruby
sgmac has joined #ruby
chimkan has joined #ruby
<shevy> not sure what the true means
sgmac has quit [#ruby]
chimkan_ has joined #ruby
<shevy> yield if block_given? I see a lot
<shevy> yield(true) if block_given? hmm first time I see it actually, I think
<shevy> what is it doing :)
<SullX> I have a hunch that how I am doing this makes it vulnerable to hackers but what do you guys think? When the following url is requested '/custom/:item' , item is substituted into a mysql query. The query is basically "select value from #{item};"
nemesit has joined #ruby
<SullX> is this setting myself up for someone to mess with my database?
axl_ has joined #ruby
CacheMoney has joined #ruby
<apeiros_> SullX: yes, that's called sql injection what can be done there
<apeiros_> and the way around is well known as bind-variables
<SullX> apeiros_: thanks googling now
<apeiros_> every sane db connector can handle them. it works like: execute("SELECT value FROM table WHERE item=?", item)
neozen has joined #ruby
<apeiros_> the alternative is to sanitize the variable. but bind-variables are a bazillion times better and less likely to get exploited.
<SullX> apeiros_: mm, I see. so this way of writing the query prevents sql injection?
<SullX> bind-variables that is
<apeiros_> yes
<SullX> great, thank you
web0 has joined #ruby
<shevy> cool
AxonetBE has joined #ruby
amesha has joined #ruby
<shevy> learned something myself too
<apeiros_> as a bonus, they enable prepared statements, which allow better peformance
hippyphysicist has joined #ruby
<apeiros_> (except for mysql, which doesn't really have a query-planer/-optimizer)
<hashpuppy> ok, this is a better question with rewritten code that makes more sense. can this be rewritten any better? http://pastie.org/private/dyctha3dvzco3hl4ulu0q
<apeiros_> hashpuppy: if not --> unless
<hashpuppy> because i'm making 5 "on" calls for each hash pair
<apeiros_> also, conditions can be combined
<apeiros_> if a then if b then … end end --> if a && b then … end
ethd has joined #ruby
<hashpuppy> thanks
Natch| has joined #ruby
sizz has joined #ruby
kirun has joined #ruby
nobitanobi has joined #ruby
<SullX> apeiros_: would the ruby-mysql gem happen to be one of the in-sane db connectors?
<apeiros_> SullX: I don't think so
amesha has joined #ruby
<apeiros_> mysql knows bind variables
<SullX> dbh.query("select itemnumber from ?", item) throws an error
sizz has joined #ruby
<apeiros_> it just can't (unlike almost every other rdbms) optimize prepared statements
Indian has joined #ruby
<apeiros_> SullX: well, I don't know its API
<apeiros_> you'll have to read the docs
Redjack1964_ has joined #ruby
<SullX> okie doke, will do
snip_it has joined #ruby
waxjar has joined #ruby
<apeiros_> from the readme, it looks like with ruby-mysql it works like this:
<apeiros_> my = Mysql.connect('hostname', 'username', 'password', 'dbname'); stmt = my.prepare('insert into tblname (col1,col2) values (?,?)'); stmt.execute 123, 'abc'
bwlang has joined #ruby
bosborne has joined #ruby
<scalebyte> how can I get a boolean object in a checkbox ?
<SullX> apeiros_: I couldn't find a readme for the ruby-mysql gem... and the syntax above looks different then what I am using, could you link me?
undersc0re has joined #ruby
* SullX bows
<SullX> you are a superior googler
<SullX> thank you
<apeiros_> I don't google such things
superguenter1 has joined #ruby
amesha has joined #ruby
burns180 has joined #ruby
<apeiros_> rdoc.info, ruby-doc.org, rubygems.org, github.com and ruby-toolbox.com are addresses a rubyist must/should know
<apeiros_> oh, and rubyforge.org
<apeiros_> though it has been mostly supplanted by github
nobitanobi1 has joined #ruby
<jlogsdon> rdoc.info is literally the coolest doc resource on the web
<apeiros_> jlogsdon: the only thing I miss from it are comments
gen0cide_ has joined #ruby
<jlogsdon> apeiros_: hm, yeah...
philcrissman has joined #ruby
<jlogsdon> they should just tack one of those "cloud" comment systems on it, so they don't have to worry about all the database crap that would go with it
<SullX> apeiros_: I am wondering if what you have above only works for values in a table, the query I have needs to switch tables based on which url is called. stmt=dbh.prepare('select itemnumber from ?') throws an error
bwlang has joined #ruby
SolarisBoy has joined #ruby
burns180_ has joined #ruby
amesha has joined #ruby
lorandi has joined #ruby
hydrozen has joined #ruby
xpot-arcturus has joined #ruby
malkomalko has joined #ruby
<apeiros_> SullX: I don't have mysql here, so I can't reproduce, sorry.
<SullX> its all good, thanks
<scalebyte> apeiros_: i have a boolean and want to use it in a checkbox... how can I do that ?
<scalebyte> apeiros_: I am getting can't convert Symbol into Integer error for this : = check_box_tag "[:education][:visible]", true, boolean_to_int(@user.profile.detail[:education][:visible])
bwlang_ has joined #ruby
c0rn has joined #ruby
waxjar has joined #ruby
hadees has joined #ruby
amesha has joined #ruby
vectorshelve has joined #ruby
TaTonka has joined #ruby
<vectorshelve> if a = "true" value = 1 else value = 0 how can I simplify this ?
<Mon_Ouie> It doesn't work in the first place
<Mon_Ouie> It's equivalent to value = 1
<Mon_Ouie> Because you used a = "true", instead of a == "true"
<vectorshelve> return 1 if a = "true" else return 0
<vectorshelve> Mon_Ouie: ^^ how to simplify this ?
y3llow has joined #ruby
s0ber has joined #ruby
<Mon_Ouie> That's just invalid Ruby, you can't have a post-line if condition with an else clause
<vectorshelve> Mon_Ouie: actually i need to use a a boolean inside a checkbox... so I cant convert the falseclass or trueclass into int.. so trying to do this the indirect way
<vectorshelve> Mon_Ouie: that return was the last line for a function
<Tasser> vectorshelve, ask in #rubyonrails, they might have something
<vectorshelve> Tasser: I am banned there...
<vectorshelve> Tasser: neverthless this is pure ruby right
<vectorshelve> Tasser: any suggestions on making the line small ?
y3llow has joined #ruby
<Mon_Ouie> My point was that it wasn't Ruby. Did you try that line at all?
<vectorshelve> Mon_Ouie:
<vectorshelve> Mon_Ouie: No
amesha has joined #ruby
<vectorshelve> Mon_Ouie: this is what I am doing : https://gist.github.com/2008739
CoderCR|work has joined #ruby
y3llow has joined #ruby
<Mon_Ouie> You need a "then" after the end of the condition (i.e. after "true")
<Mon_Ouie> (or a semicolon, or a newline)
bwlang_ has joined #ruby
workmad3_ has joined #ruby
<vectorshelve> Mon_Ouie: https://gist.github.com/2008739 this will work ?
<Mon_Ouie> I'd suggest you take some time reading some tutorial about Ruby before going on
y3llow has joined #ruby
<Mon_Ouie> And yes, it would work
<Mon_Ouie> Wait no, it needs an end too
bosborne has quit [#ruby]
hasrb has joined #ruby
Phrogz has joined #ruby
lorandi has joined #ruby
sizz has joined #ruby
<SullX> ok, because I can't figure out bind-variables how can I go about sanitizing the html. Recap: I have a sinatra app and when the following url is requested '/custom/:item' , item is substituted into a mysql query. The query is basically "select value from #{item};"
thecreators has joined #ruby
<SullX> this works well
<SullX> but opens me up to sqli
<SullX> any suggestions on how I can prevent these attacks in sinatra ?
amesha has joined #ruby
yeltzooo has joined #ruby
burns180 has joined #ruby
KL-7 has joined #ruby
asobrasil has quit [#ruby]
nemesit has joined #ruby
<ddv> SullX: #sinatra
<Phrogz> SullX: What are you using for your DB adapter? Sequel?
bwlang_ has joined #ruby
<Phrogz> (And if not, why not? :)
<SullX> Phrogz: er, the ruby-mysql gem is my db adapter
jbw_ has joined #ruby
<Phrogz> Aw. So sorry.
badabim has joined #ruby
<SullX> what adapter are you speaking of?
<ddv> SullX: are you ignoring me?
<Phrogz> ddv: This is more of a db adapter question than Sinatra, and it's wholly Ruby anyhow.
<ddv> #sinatra is a far better place though
<Phrogz> SullX: with Sinatra that'd be DB[item.to_sym].all and sanitized.
<apeiros_> sequel
<Phrogz> Er, yeah. That.
<apeiros_> :)
<apeiros_> gn8
<Phrogz> Be well.
<SullX> thanks Phrogz
i8igmac has joined #ruby
waxjar has joined #ruby
dbgster has joined #ruby
marvin_ has joined #ruby
SolarisBoy has quit [#ruby]
systmkor has joined #ruby
amesha has joined #ruby
<robert_> shevy: hai. :D
KL-7 has joined #ruby
fr0gprince_mac has joined #ruby
KL-7 has joined #ruby
waxjar has joined #ruby
amesha has joined #ruby
vraa has joined #ruby
<nobitanobi1> How can I consume specific parts of an array? Say, I want to get just from index 3 to index 4
<nobitanobi1> or from index 3 to index X
<nobitanobi1> like an each with inferior and superior limits
john_smith has joined #ruby
nfluxx has joined #ruby
<ddv> nobitanobi1: you mean array slicing?
<ddv> nobitanobi1: use a range
<ddv> nobitanobi1: .., or ...
<nobitanobi1> mmm, yeah but I don't even want to perform the slice
<nobitanobi1> I want to do additions of the values
<nobitanobi1> by ranges..
<nobitanobi1> like... add_from_3_to_10 + ...
<nobitanobi1> sorry
<nobitanobi1> add_from_3_to_10 = each from 3 to 10
<nobitanobi1> basically I am creating an histogram of intervals
<nobitanobi1> from values in an array
philcrissman|afk has joined #ruby
<nobitanobi1> oh, I see this: a[1..3]
<nobitanobi1> awesome
wyhaines has joined #ruby
<ddv> yes
emocakes has joined #ruby
webusnix has joined #ruby
<audrius> is this possible to add methods to mixins(modules) just like to classes.
BHensley has joined #ruby
<ddv> audrius: you can add methods to modules yes and use the module as a mixin if i'm not mistaken
<ddv> not sure if method is the correct, more like a global function
burns180_ has joined #ruby
philcris_ has joined #ruby
<ddv> audrius: why don't you just try :)
<audrius> ddv, got error "Enumerable is not a class" don't know how to start
<nobitanobi1> How would I do a oneliner to add the values of the hashes inside an array. Like [{"id" => 1, "value" => 5},{"id" => 2, "value" => 10},..] --
TaTonka has joined #ruby
csprite has joined #ruby
BHensley has quit ["Leaving"]
aetaric has joined #ruby
amesha has joined #ruby
virunga has joined #ruby
BHensley has joined #ruby
<audrius> how will i add method to such a object "[1,2,3,2,1]" ?
<shevy> yo robert_
AxonetBE has joined #ruby
eignerchris has joined #ruby
Azure has joined #ruby
philcrissman|afk has joined #ruby
systmkor has joined #ruby
<robert_> blah.. is there any reason why http://pastebin.com/WaCUw4KR refuses to do anything with VersionBlock?
<nobitanobi1> Anyone can help me with this: How would I do a oneliner to add the values of the hashes inside an array. Like [{"id" => 1, "value" => 5},{"id" => 2, "value" => 10},..] --
ryanf has joined #ruby
<robert_> shevy: how goes? :D
Squarepy has joined #ruby
Squarepy has joined #ruby
c0rn has joined #ruby
SolarisBoy has joined #ruby
dv310p3r has joined #ruby
amesha has joined #ruby
<cout> nobitanobi1: a.inject { |h,t| t['value'] + h['value'] }
<nobitanobi1> cout I have done this: map{|bucket| bucket.value}.reduce(:+)
<nobitanobi1> going to try it though
CoderCR|work has quit ["Linkinus - http://linkinus.com"]
<cout> nobitanobi1: bucket['value'], but yeah
wilmoore has joined #ruby
patjoh has joined #ruby
<nobitanobi1> I find difficult to understand how inject works
<cout> me too :(
<nobitanobi1> you just give "two values" h, t?
<nobitanobi1> when accessing arrays by ranges I have to specify the limit always right? I can't do stuff like a[2..]
<nobitanobi1> meaning from 2 to the end
sizz_ has joined #ruby
superguenter has joined #ruby
pu22l3r has joined #ruby
amesha has joined #ruby
tommyvyo has joined #ruby
ashp has quit [#ruby]
burns180 has joined #ruby
somazero has joined #ruby
fowl has joined #ruby
ezkl has joined #ruby
odinswand has joined #ruby
thecreators has joined #ruby
wulfgarpro has joined #ruby
keymone_ has joined #ruby
amesha has joined #ruby
nfluxx has joined #ruby
jameshyde has joined #ruby
janissary has joined #ruby
shadoi has joined #ruby
Quirrell has joined #ruby
akem has joined #ruby
nobitanobi has joined #ruby
amesha has joined #ruby
* robert_ notify-spams shevy :P
burgestrand has joined #ruby
al3xnull has joined #ruby
robertjpayne has joined #ruby
hadees has joined #ruby
bbttxu has joined #ruby
i8igmac has joined #ruby
Pikkachu has joined #ruby
Pikkachu has quit [#ruby]
<eignerchris> nobitanobi: you can do [0..-1]
Pheen has joined #ruby
<nobitanobi> uhm, nice eignerchris
amesha has joined #ruby
burns180_ has joined #ruby
zul_ has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
dwon has joined #ruby
<robert_> eignerchris: hi. got a few minutes to read over some code I have on a pastebin?
ph^ has joined #ruby
<eignerchris> robert_: maybe. shoot me a link
fowl has joined #ruby
<robert_> eignerchris: http://pastebin.com/WaCUw4KR
<eignerchris> robert_: something not working? it's hard to read. the only case for camel case is in class/module names typically. everything else is underscores
CoderCR|work has joined #ruby
<robert_> I'm experimenting with trying to get (more or less) an add-in system working where I don't have to manually add a reference to my add-in to some collection somewhere
<robert_> but it doesn't seem to be registering the version information correctly
CoderCR|work has quit [#ruby]
n8ji has joined #ruby
amesha has joined #ruby
<shevy> robert_ hey sorry, awfully busy right now
sbanwart has joined #ruby
<robert_> it's fine.
<robert_> I'm just hanging out here while I'm working on this concept code
jergason has joined #ruby
amesha has joined #ruby
<shevy> hehe
<robert_> :p
Seisatsu has joined #ruby
johndbritton has joined #ruby
__main__ has joined #ruby
phantasm66 has joined #ruby
amesha has joined #ruby
<robert_> eignerchris: better? :p
Sailias_ has joined #ruby
<eignerchris> robert_: a bit ya. thanks
<robert_> yup. :D
<robert_> I kept VersionInfo camel-case because of the class it's pretending to be
<robert_> heh
zul_ has joined #ruby
<zul_> hi all
paissad has joined #ruby
<zul_> I get "stack level too deep (SystemStackError)" when I do padrino rake dm:create ( I Use rvm 1.9.2)
<robert_> zul_: #padrino
<zul_> ok sorry
baroquebobcat has joined #ruby
<robert_> nahj
<robert_> nah*, it's just they can help you more with their framework. :p
systmkor has joined #ruby
<zul_> mmm nobody help me in that channel.. few people there
<robert_> wait around
<zul_> ok guys
carlyle has joined #ruby
<eignerchris> robert_: cleaned this up a bit. you dont need to define all the setters if you use attr_accessor
burns180 has joined #ruby
wyhaines has joined #ruby
<robert_> yeah
<robert_> I was going to move those back into accessor
<zul_> robert are you in padrino channel?
sonkei has joined #ruby
<robert_> yes
<zul_> uhh
<robert_> I've used the library a bit
<zul_> this is for me the first time
<robert_> eignerchris: I kept it VersionBlock because it's shadowing the class
symb0l has joined #ruby
<Phrogz> shevy: Was it you working on Sinatra authentication earlier?
dhruvasagar has joined #ruby
hadees has joined #ruby
kyledr has joined #ruby
tommyvyo has joined #ruby
twock has joined #ruby
MasterIdler_ has joined #ruby
looopy has joined #ruby
apeiros_ has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
looopy has joined #ruby
timonv has joined #ruby
mikepack has joined #ruby
<Phrogz> nobitanobi: a.inject{ |h1,h2| h1.merge(h2){ |a,v1,v2| v1+v2 } }
<Phrogz> (Late answer.)
<sullx-away> Phrogz: haha, I was just writing the one liner myself 2 hours later :P
<nobitanobi> hehe, thanks
<robert_> Phrogz: any ideas about my issue? heh
<Phrogz> robert_: What's your issue? Can you summarize?
<Phrogz> (Leaving in 5 minutes.)
<robert_> oh
symb0l has joined #ruby
shevy has joined #ruby
<robert_> I'm trying to write an add-in system using instance_eval and for some reason the instance of the VersionInfo class that's getting bound to the AddIn class isn't getting populated
voodoofish430 has quit [#ruby]
<Phrogz> I don't know what an "add-in" system is, nor what the VersionInfo or AddIn classes are :/
<robert_> Phrogz: <eignerchris> http://pastebin.com/s54g10Jv
robertjpayne has joined #ruby
robbyoconnor has joined #ruby
<Phrogz> robert_: Line 37 calls line 26 which creates a new version block, but the block you are passing isn't passed along.
<Phrogz> Lines 38-43 are never executed, I believe. You need the method on line 26 to accept the block and yield to it.
<Phrogz> (Or instance_eval it, as you did earlier.)