apeiros_ changed the topic of #ruby to: programming language || ruby-lang.org || Paste >3 lines of text in http://pastie.org || Rails is in #rubyonrails
banisterfiend has joined #ruby
ringotwo has joined #ruby
Cache_Money has joined #ruby
louism2 has joined #ruby
<phinfonet> in here have a user of bowline framework?
<monokrome> phinfonet: Like I said, no.
<phinfonet> you shoul helpme with one gem?
martman has joined #ruby
ozymandius has joined #ruby
<martman> kind of a weird question. in a gem im using theres a function called option_string that id like to "fix". i mean id like to take the return value of that and append something to it
<martman> if i create my own class of the same name i could add new variables and functions to it
<louism2> does anyone know how I get access to the ruby on rails channel
<martman> but is there anyway for me to redefined this function, and still be able to call the old one myself?
jwang has joined #ruby
<Cache_Money> louism2: type the command "/msg nickserv help register" => Should have instructions
<louism2> thanks cache_money
<Cache_Money> louism2: no problem
freeayu has joined #ruby
CoderCR|work has joined #ruby
sectionme has joined #ruby
alx- has joined #ruby
senthil has joined #ruby
Brainix has joined #ruby
Guedes has joined #ruby
kah_ has joined #ruby
phantasm66 has joined #ruby
<monokrome> Does Ruby have a map type?
<monokrome> (Something akin to std::map in C++ or a dict in PythoN)
<senthil> monokrome: Hash
netrealm has joined #ruby
<monokrome> Ah. Makes sense. Thank you, senthil.
<lectrick> Today, I learned how to use the Delegator class. :) https://gist.github.com/2305169
eywu has joined #ruby
banisterfiend has joined #ruby
<shadoi> lectrick: that's a little scary. :)
Telenull has joined #ruby
<lectrick> shadoi: Good. :)
fhil has joined #ruby
linoj has joined #ruby
Nathandim has joined #ruby
waxjar has joined #ruby
two- has joined #ruby
sectionme has joined #ruby
frishi has joined #ruby
shevy has joined #ruby
nari has joined #ruby
eywu has joined #ruby
Houdini has joined #ruby
havenn has joined #ruby
iamjarvo has joined #ruby
liluo has joined #ruby
alup has joined #ruby
Tomasso has joined #ruby
suborbital has joined #ruby
cloke_ has joined #ruby
cafesofie has joined #ruby
<senthil> how do I look into binding to find a value?
<ged> senthil: eval( "value", binding )
cloke_ has joined #ruby
<senthil> ged: thx
seanstickle has joined #ruby
Guest23301 has joined #ruby
Nisstyre has joined #ruby
CannedCorn has joined #ruby
macmartine has joined #ruby
adeponte has joined #ruby
CodeFriar has joined #ruby
Guedes has joined #ruby
rohit has joined #ruby
senthil has joined #ruby
dv310p3r has joined #ruby
Chryson has joined #ruby
rawk has joined #ruby
fhil has joined #ruby
philcrissman has joined #ruby
tommyvyo has joined #ruby
CheeToS has joined #ruby
eywu has joined #ruby
Clordio has joined #ruby
mxweas_ has joined #ruby
<monokrome> Hmm… A Proc isn't a function? :/
downtown has joined #ruby
ZachBeta has joined #ruby
<heftig> it's a closure
<shadoi> monokrome: aka an anonymous function
prometheus has joined #ruby
wookiehangover has joined #ruby
pac1 has joined #ruby
<monokrome> heftig, shadoi: Apologees for what is certainly going to seem to be rather poor code, but I am trying to figure out why processor isn't my lambda that I expect it to be here: http://codepad.org/C7WSIWP7
<heftig> you need to use processor.call
<davidcelis> woah
<davidcelis> dat tabbing
<monokrome> yeah
<monokrome> I thought that this editor saved it out to 4 space expanded tabs
<monokrome> but apparently not
renanoronfle has joined #ruby
<monokrome> heftig: Thanks, I'll try that
<monokrome> That worked!
<monokrome> Is there a more readable (or generally better) way to set up that hash at the beginning there?
<denysonique> hey
<denysonique> Is there a shortcut around this:
<denysonique> def full_name=(full_name)
<denysonique> @_full_name = full_name
<denysonique> end
<shadoi> monokrome: looks like it's not setting processor to anything.
<denysonique> ?
<shadoi> monokrome: run your lamda manually
<monokrome> shadoi: It set it to a Proc, now that I added .call it works
<shadoi> denysonique: attr_accessor :full_name
<denysonique> sorry
<shadoi> monokrome: *nod*
shtirlic has joined #ruby
<heftig> dyeske: if it was @full_name instead, you could use attr_writer or attr_accessor
<denysonique> I didn't paste full code, I will gist it
<heftig> er, denysonique
<denysonique> here ↑
<shadoi> denysonique: attr_accessor :full_name would create both of those methods
<heftig> denysonique: why is it @_full_name instead of @full_name?
<monokrome> Thanks again for both of your help (shadoi, heftig) , if anyone has ideas on making TOKEN_PROCESSORS more readable - I'd love to know
<heftig> monokrome: probably not
stevegozie has joined #ruby
<heftig> monokrome: by the way, you don't need to use |value|
<heftig> you can directly use |expression, processor|
<denysonique> If I don't have full name defined yet I want to return @first_name + ' ' + @last_name
<denysonique> as @full_name
<heftig> denysonique: yet you're using @_full_name instead of @full_name
<denysonique> is there a shorter way than mine?
<shadoi> denysonique: then just put that in the accessor
<monokrome> oooh! much better. Thank you, heftig
<heftig> denysonique: why is that?
<shadoi> denysonique: def full_name; @full_name ||= "#{@first} #{@last}"; end
<shadoi> or better yet just put that in the initialize for @full_name
<denysonique> shadoi: thanks man, this is what exactlly I was looking for. I was wondering myself what could here be optimized, as I felt something was here wrong
<heftig> shadoi: i wouldn't use ||=
<shadoi> heftig: it initialize anyway
<heftig> that way the full name gets set the first time it's accessed
<shadoi> in*
<denysonique> shadoi: I cannot put that into initialize as first and last is not known from the beginning
<heftig> and further changes to first or last name won't propagate
clancey__ has joined #ruby
<shadoi> heftig: true.
stevegozie has quit [#ruby]
<shadoi> denysonique: yeah if they're not required parameters then just use || in the accessor
<heftig> see my gist
<denysonique> || in the accessor?
<denysonique> heftig: yes, thanks
<denysonique> hmm
<denysonique> heftig: will that work?
<denysonique> def full_name
<denysonique> @full_name || "#{@first_name} #{@last_name}"
<denysonique> end
<heftig> yes
<heftig> mind that i renamed the instance variable from @_full_name to @full_name
<denysonique> oh right
<denysonique> attr_accessor
<denysonique> hmm
<shadoi> attr_writer, like in his gist.
<denysonique> sorry
<denysonique> yep I meant that
<shadoi> you'll be redefining the method anyway
poorlilrichboy has joined #ruby
<denysonique> heh
<denysonique> I am again to tired
<denysonique> bedtime
<shadoi> :)
<denysonique> I shouldn't be asking such a stupid question
radic_ has joined #ruby
sohocoke has joined #ruby
<monokrome> I'm guessing that hashes aren't ordered?
<denysonique> nor spaghetti coding
kevinbond has joined #ruby
<denysonique> however I have never used attr_accessor yet
<denysonique> err
<denysonique> attr_writer
<denysonique> in this manner
<monokrome> Actually, they probably are...
<denysonique> hmm
<denysonique> monokrome: Why are you questioning this?
<shadoi> monokrome: they are, but weren't before 1.9.x
<monokrome> denysonique: because the program that I am writing depends on them being ordered in the same order that they were inserted
<shadoi> yeah, wasn't true until recently, which sort of throws me off now.
senthil has joined #ruby
<monokrome> hmm
<monokrome> Is there a better solution with backwards compatibility in mind, or would you have to implement your own ordered hash?
<monokrome> Requiring Ruby 1.9.x isn't out of scope here, but a better solution that isn't more complicated wouldn't hurt
<rohit> You shouldn't depend on a Hash to be ordered in any way though. Am I right?
<heftig> monokrome: array.
<heftig> rohit: 1.9 hashes have ordering
<monokrome> heftig: Arrays can't have keys, right?
<heftig> you just need to iterate through it, don't you?
<monokrome> some_array[/someregex/]
<rohit> heftig, I know they are ordered according to insert order. But when you use a Hash you aren't supposed to depend on any kind of ordering right? Even if it does on 1.9 now.
<heftig> [[/regex/,lambda],[/regex/,lambda]]
<rohit> Store an array of arrays maybe like [[key, value], [key, value]]
<monokrome> heftig: I thought about that, but that's even worse for readability :/
<monokrome> I guess I can do that though
<rohit> Do you want the ordering or not?
<rohit> I think ActiveSupport provides a OrderedHash, maybe you can use that?
<heftig> monokrome: hang on, let me rewrite that gist
<monokrome> heftig: one sec, I'm already almost done with that change anyway
andrewhl has joined #ruby
<monokrome> heftig: http://codepad.org/GmOJAcoD
<monokrome> I understand that it doesn't require changing anything except the array itself
<monokrome> Readability is just hindered by it
<monokrome> heftig: That completely confused me
<monokrome> oh
<monokrome> That's a better way to do it for sure
<monokrome> Only issue is it's not in a class :/
blueadept has joined #ruby
<heftig> monokrome: hmm?
<monokrome> Yeah, not really an issue
<monokrome> Thanks again, heftig
<monokrome> That got rid of the {} also
<monokrome> I hate those
kah_ has joined #ruby
<Boohbah> monokrome: i love those
<monokrome> :
<monokrome> :'(
adamkittelson has joined #ruby
<kah_> hey can someone help me with this error http://pastie.org/3730701
<kah_> I'm getting a "can't convert Float into string"
<kah_> I tried adding .to_f that didn't seem to work.
<senthil> kah_: i'm guessing the params are in strings
<senthil> kah_: why don't you puts the params before that line and see their values
<kah_> senthil: yeah they are in strings
<kah_> senthil: guidance on how to solve? which method to use?
badabim_ has joined #ruby
stringoO has joined #ruby
<senthil> kah_: without knowing what exactly the params are, i d k
wilmoore has joined #ruby
<kah_> senthil: added them to the bottom
<senthil> kah_: Date.parse("2012","05", "01") this is what you're doing
<senthil> kah_: i'm guessing you want Date.parse("2012/05/01")
<kah_> senthil: yeah
<senthil> kah_: so use string interpolation then, not the best way, but it will work for now
Kichael has joined #ruby
<kah_> senthil: cool, I'll work with that, thank you.
<senthil> kah_: gl!
looopy has joined #ruby
ceej has joined #ruby
w400z has joined #ruby
<w400z> anyone know a workaround for timeout problems with 1.9.3?
<Boohbah> w400z: that's kind of vague
<Boohbah> what times out?
<w400z> net/http request
ceej has joined #ruby
<shadoi> that's rails specific, but the same thing works for all ruby code, just require 'timeout'
sacarlson has joined #ruby
<Boohbah> neat
<w400z> shadoi: thx trying now.
<shadoi> a more clear example with a 1.8 gotcha explained: http://woss.name/2011/08/30/ruby-timeout-woes-part-1/
stefanp_ has joined #ruby
rippa has joined #ruby
alx- has joined #ruby
QKO has joined #ruby
wallerdev has joined #ruby
<kah_> senthil: hey, sorry to bug you, my date is parsing in a weird way.. I was wondering if you had any insight? http://pastie.org/3730829
<senthil> kah_: why isn't there params before :year and others?
<senthil> "Date.parse("#{params[:year]} ..."
<kah_> senthil: yeah I should have had it, added it back in, still am getting this error http://pastie.org/3730844
<kah_> senthil: it also looks like the day changed ?_-
<senthil> kah_: try this http://pastie.org/3730860
<wallerdev> )
Cache_Money has joined #ruby
<senthil> kah_: p.s. that code won't work if any of the params returns empty strings (all? considers "" to be a valid value)
ZachBeta has joined #ruby
ryanf has joined #ruby
CannedCorn has joined #ruby
<kah_> senthil: I added in an extra bracket, new error http://pastie.org/3730883
<senthil> kah_: oops, add " ?" after any?
mxweas_ has joined #ruby
<kah_> senthil: sorry, I don't see an "any?"
<senthil> kah_: aaahhhh! my brain is shutting down...meant "all?"
<shadoi> @date = dates.all ? Date.parse(dates.join('/')) : Date.today
<senthil> @date = dates.all? ? Date.parse(dates.join('/')) : Date.today
<shadoi> ternary
<senthil> shadoi: all?
moshee has joined #ruby
moshee has joined #ruby
<senthil> unless an "all" method exists, i don't think so
<shadoi> ah
<kah_> senthil: I fucking love you man
<shadoi> yeah, typo :)
<kah_> senthil: I really appreciate the help.
<senthil> kah_: np
<kah_> senthil: ha, maybe a little over excited, but it really does help me
<kah_> senthil: what was wrong with it before?
kickandrew has joined #ruby
<kah_> senthil: what was wrong with the interpolation
<senthil> kah_: "params[:date], params .. ?" is not valid syntax
nonotza has joined #ruby
<senthil> kah_: commas are valid only inside arrays, hash or multiple assignment, afaik
bath has joined #ruby
<kah_> senthil: ah ok, cool cool
kickandrew has joined #ruby
<denysonique> within an instance method: when a local var is used and there is no local var defined it falls back to an instance variable of that name?
startling has joined #ruby
kickandrew has joined #ruby
<shadoi> denysonique: no
kickandrew has joined #ruby
<senthil> denysonique: not it falls to method
<shadoi> yeah, you'll get NoMethodError
<denysonique> hmm
<denysonique> so when I use attr_accessor on that var it becomes a method, right?
<denysonique> ok, yes
<shadoi> 2 methods
<shadoi> var and var=
<denysonique> so it falls on the intance method of that name
<denysonique> instance*
<shadoi> yes, but don't think of that as a local var, it's a method call.
<denysonique> ok
<denysonique> anyway
<denysonique> I was just confused why some piece of code worked
<denysonique> from my code
<denysonique> s/code/script/
dwon has joined #ruby
brngardner has joined #ruby
t_p has joined #ruby
<t_p> require 'socket' is error
<t_p> I am on ubuntu11.10 server
brianpWins has joined #ruby
poorlilrichboy has quit [#ruby]
poorlilrichboy has joined #ruby
wizardly has joined #ruby
kallisti has joined #ruby
<kallisti> can someone explain what "class << self" means?
<Banistergalaxy> kallisti: search on stack overflow
<Banistergalaxy> Your q has been asked 10000 times:)
<kallisti> oh nevermind I see.
<kallisti> what's strange about this particular usage of the idiom is that it appears to be within the class body itself.
<kallisti> which seems redundant to me, if the purpose is to special methods for a particular instance.
<kallisti> *specialize
<kallisti> oh static methods, I see.
<kallisti> because self in that context is the class.
simao_ has joined #ruby
aaronsnoswell has joined #ruby
<aaronsnoswell> Hi all
ZachBeta has joined #ruby
<aaronsnoswell> I'm currently trying to choose a new blogging engine and tossing up between octopress, jekyll and toto. Wondering if anyone here has any suggestions or advice?
senthil has joined #ruby
senthil_ has joined #ruby
savage- has joined #ruby
<KnowTheLedge> aaronsnoswell: You are looking for osmething strictly ruby based?
<seanstickle> ruhoh
nfluxx has joined #ruby
Zac_o_O has joined #ruby
byronb has joined #ruby
gokul has joined #ruby
drPoggs has joined #ruby
louism2 has joined #ruby
poindont` has joined #ruby
<aaronsnoswell> KnowTheLedge: Not at all, in fact I've never used ruby. I'm just looking for something that generates static files and uses Markdown.
benwoody has joined #ruby
ZachBeta has joined #ruby
Gm4n has joined #ruby
p-daxx has joined #ruby
KitsuneDrag0n has joined #ruby
laen_ has joined #ruby
rippa has joined #ruby
nfluxx has joined #ruby
malcolmva has joined #ruby
lol_ has joined #ruby
kevinbond has joined #ruby
<lol_> ruby.
kallisti has quit [#ruby]
crankyco_ has joined #ruby
daniel_hinojosa has joined #ruby
Banistergalaxy has joined #ruby
lol_ has quit [#ruby]
crankycoder has joined #ruby
rushed has joined #ruby
<Zac_o_O> hello all! anyone having trouble joining #rubyonrails
<Zac_o_O> I have a registered nick but it's still spitting out the message that I don't
<senthil_> Zac_o_O: nope, i'm there
<Zac_o_O> huh, i'm getting the "cannot join channel - you need need to be identified
<Zac_o_O> so i tried to identify but then realized i forgot my password. then when trying to retrieve it IRC spits out "you are not authorized to perform this action"
<Zac_o_O> :(
<senthil_> Zac_o_O: get someone on #freenode to reset your pass
<Zac_o_O> ah nice, I'll try that
ozymandius has joined #ruby
ameba has joined #ruby
d-snp has joined #ruby
Banistergalaxy has joined #ruby
shadoi has joined #ruby
a_a_g has joined #ruby
rushed has joined #ruby
hooper has joined #ruby
maletor has joined #ruby
thecreators has joined #ruby
paradisaeidae has joined #ruby
<Zac_o_O> night all!
tobago has joined #ruby
Morkel has joined #ruby
banjara has joined #ruby
rohit has joined #ruby
qos has joined #ruby
My_Hearing has joined #ruby
prometheus has joined #ruby
mxweas_ has joined #ruby
<hemanth> anyone working on watir-webdriver here?
<hemanth> having issues with xpath
Teddy2steper has joined #ruby
tsagadai has joined #ruby
wefawa has joined #ruby
Teddy2steper has joined #ruby
artm has joined #ruby
GoBin has joined #ruby
rohit has joined #ruby
sacarlson has joined #ruby
CheeToS has joined #ruby
andrewhl has joined #ruby
prometheus has joined #ruby
ben225 has joined #ruby
arturaz has joined #ruby
daniel_hinojosa has joined #ruby
arturaz has joined #ruby
sacarlson has joined #ruby
x0F__ has joined #ruby
mel0on has joined #ruby
Bonkers has joined #ruby
tobym has joined #ruby
GoBin has joined #ruby
schovi has joined #ruby
bgupta has joined #ruby
GoBin has joined #ruby
lurraca has joined #ruby
alem0lars has joined #ruby
shruggar has joined #ruby
prometheus has joined #ruby
djdb has joined #ruby
Helius has joined #ruby
a_a_g has joined #ruby
Gesh has joined #ruby
wookiehangover_ has joined #ruby
LMolr has joined #ruby
artm has joined #ruby
<bounce> in soviet russia, xpath has issue with you!
davidpk has joined #ruby
Vert has joined #ruby
Eartz has joined #ruby
JohnBat26 has joined #ruby
yxhuvud has joined #ruby
wookiehangover has joined #ruby
rohit has joined #ruby
MissionCritical has joined #ruby
InBar has joined #ruby
schovi has joined #ruby
apeiros_ has joined #ruby
deobald has joined #ruby
mephux has joined #ruby
Houdini has joined #ruby
antillas21 has joined #ruby
trivol has joined #ruby
wookiehangover has joined #ruby
aknewhope has joined #ruby
havenn has joined #ruby
rippa has joined #ruby
twinturbo has joined #ruby
shellox has joined #ruby
iocor has joined #ruby
etehtsea has joined #ruby
triptec has joined #ruby
riginding has joined #ruby
wookiehangover has joined #ruby
trivol has joined #ruby
neurotech has joined #ruby
bluOxigen has joined #ruby
emmanuelux has joined #ruby
<shevy> soviet russia was cool
<shevy> then came the oligarch who pillaged what the traitor jelzin gave them, and then came Zar Putin who fought the Oligarchs and established Gazprom to become his tactical tool
neurotech has joined #ruby
banjara1 has joined #ruby
ephemerian has joined #ruby
shruggar has joined #ruby
heeton has joined #ruby
louism2_ has joined #ruby
<louism2_> does anyone know how to log in to the ruby on rails chat?
<DefV> what has this channel become :-(
<DefV> louism2_: #rubyonrails
<louism2_> its saying I need to be identified with services
<louism2_> sorry... Im new to IRC
jenglish has joined #ruby
BiHi has joined #ruby
<DefV> yeah, you need to register with NickServ
<shevy> louism2_ it wants you to (1) register and then (2) identify
<shevy> so have a look at "register in freenode"
<shevy> once you registered, you must identify to NickServe, with a syntax like: /msg nickserv identify YOUR_PASSWORD_COMES_HERE
mengu_ has joined #ruby
mengu_ has joined #ruby
<louism2_> thanks guys
<louism2_> do you have to register every time you close down your chat program?
<louism2_> this is my second time on here and I had done this step once before
KL-7 has joined #ruby
Ammar01 has joined #ruby
louism2_ has quit ["Leaving"]
<shevy> hehe :)
<shevy> wonder if we ever see him again
ringotwo has joined #ruby
Synthpixel has joined #ruby
Synthpixel has joined #ruby
Indian has joined #ruby
ringotwo has joined #ruby
ringotwo has joined #ruby
troessner has joined #ruby
twinturbo has joined #ruby
jenglish has joined #ruby
akhkharu has joined #ruby
Synthpixel has joined #ruby
a_a_g has joined #ruby
emilkarl has joined #ruby
<sspiff> hmmm, is nokogiri still the go-to library for HTML parsing, or has that changed again?
greenarrow has joined #ruby
fr0gprince_mac has joined #ruby
banisterfiend has joined #ruby
roolo has joined #ruby
<shevy> dunno. nokogiri never worked for me so i gave up on html parsing
<shevy> a regex must be good enough to parse HTML ;)
alek_b_ has joined #ruby
jenglish has joined #ruby
falena has joined #ruby
alek_b has joined #ruby
<emilkarl> Can I make URI.escape or encode to also url encode & to %26?
jenglish_ has joined #ruby
lessless has joined #ruby
<Tasser> emilkarl, apparently it's not needed?
<emilkarl> hmm
<emilkarl> if I have this one… foo.com?param1=bar&desc=hello & welcome
<emilkarl> I guess I just can replace what with "and"
jenglish has joined #ruby
<Tasser> huh?
jlebrech has joined #ruby
ukwiz has joined #ruby
clockwize has joined #ruby
rtdp has joined #ruby
<lessless> hi! i'm looking for algorithm to create a unique identifier which will point to specific result of user testing, strong enough to handle any possible amount for a years. something like http://youtu.be/XXXX
<lessless> is rand(36**8).to_s(36) good enough? :))
banjara has joined #ruby
<arturaz> that is no unique
<arturaz> :)
<Tasser> lessless, there's uuid for that kind of stuff
<arturaz> (Time.now.to_f * 1000).to_s(36) + rand(36**4).to_s(36)
<arturaz> or poor mans solution :D
<Tasser> use uuid.
<arturaz> probably yeah
jenglish_ has joined #ruby
pen has joined #ruby
bier has joined #ruby
gyre007 has joined #ruby
dkamioka has joined #ruby
mdw has joined #ruby
visof has joined #ruby
Morkel has joined #ruby
alem0lars_ has joined #ruby
tomku|two has joined #ruby
jbhewitt has joined #ruby
francisfish has joined #ruby
blacktulip has joined #ruby
cascalheira has joined #ruby
<greenarrow> Does anyone know anything about how i can do RESTful calls to expedia's hotel api to get a list of hotels
fermion has joined #ruby
<greenarrow> a gem exists called suitcase
<greenarrow> but i prefer to do it manually
bluenemo has joined #ruby
bluenemo has joined #ruby
<lessless> Tasser, can it be more eye-candy?
<Tasser> lessless, define
mdw has joined #ruby
<lessless> like "b8d70fe0-612d-012f-ec08-00219be54d45" == "aCmzYJsPD70"
<lessless> more short :)
d3vic3 has joined #ruby
Ecio has joined #ruby
fermion has joined #ruby
<Ecio> hi all, i have a strange problem (im quite a ruby newbie): im tryin to do a regex on a multiline string. it works in IRB but it doesnt work in a .rb file
<ccooke> Ecio: have you run the file through irb? 'irb filename'
<Ecio> i tried now, it works via irb
<arturaz> lessless, (Time.now.to_f * 1000).to_i.to_s(36) + rand(36**4).to_s(36)
<arturaz> should be ok :)
<arturaz> (Time.now.to_f * 1000).to_i.to_s(36) + Thread.current.object_id.to_s(36) + rand(36**4).to_s(36)
mdw has joined #ruby
<arturaz> => h0nlmjq01jkwxmy
<Ecio> ccooke: nevermind i think im dumb
pw_ has joined #ruby
<ccooke> arturaz: not saf3 unless you can guarantee the ids will only ever be local to a single host
<ccooke> Ecio: *grin* happens to us all.
<keymone> lessless: or you could always base64 encode integer packed into string
<lessless> arturaz, thanx!
<arturaz> use it on only one host though :)
<lessless> so, it'll fail on heroku? :))
<arturaz> there is a theoretical possibility, that two hosts will do this in same millisecond, with same thread object id and pick up same random number
<arturaz> i'm not into statistics, but i'd think thats into 0.00000000001 range
<ccooke> arturaz: less, but it's per id generated.
<ccooke> it's very annoying, but real-world examples validate a certain amount of paranoia
<arturaz> well, then you need uuids
<arturaz> but I wouldn't worry about it
<arturaz> unless you're building youtube
<arturaz> and even youtube seems not to use uuids
<lessless> arturaz, but youtube use more short ids than uuid generate
<lessless> keymone, niceone, thanks Base64.encode64(rand(36**8).to_s(36)) :))
<ccooke> they do use uuids, just not rfc4122 uuids
<keymone> lessless: actually bit more complex but compact
<keymone> lessless: Base64.b64encode([rand(36**8)].pack("N"))
<ccooke> lessless: generally, a good uuid should include some5hing random, something related to the time and something unique to the service generating it
<ccooke> lessless: if you include something from all of those, you're not doing badly
<Ecio> hi, im workin on a regex using rubular: i successfully created a regex that gives me multiple match groups (and that's what i want), how can i use it then in my code?
<Ecio> this is the url http://rubular.com/r/P1NfiGBneK
rAg3-nix has joined #ruby
<pw_> hello i want to join rubyonrails channel but get "Error(477): #rubyonrails Cannot join channel (+r) - you need to be identified with services"
<egrouse> so read the message and do what it tells you to do
<pw_> how to identify? im not using irc too often
<keymone> lessless: forget that, Q is better but you will lose if int is bigger that what 64bit can hold
davidpk has joined #ruby
<ccooke> lessless: I suspect what youtube do is based on a unique database key. technically the ids would not be guaranteed unique if there were two instances of youtube, but I doubt they mind :-)
<ccooke> lessless: it's all about the scope you need uniquensss within
<lessless> ccooke, i hope at least 30k tokens per day :)))
tayy has joined #ruby
<ccooke> lessless: what's the system? db driven?
<lessless> yes
<lessless> postgresql
<lessless> i thought maybe some plqsl can do it on the database sid, it seems more logical to me :)
<ccooke> lessless: in which case, pick a table with a unique integer key, add a random number and base64 it. you now have a guaranteed uuid ;-)
<lessless> cool
<lessless> it means that just only unique index will work? :))
<ccooke> yee.
pw_ has quit [#ruby]
<ccooke> yes, even.
<lessless> cool
<lessless> thanks guys
<ccooke> but it's considered good practice to return opaque ids
catphish has joined #ruby
<ccooke> that way you can rebuild the db without having to build a translation layer from old to new ids
bluOxigen has joined #ruby
<Ecio> ok found, i can use string.scan
berserkr has joined #ruby
<keymone> lessless: ah! found it - Base64.b64encode([(Time.now.to_f * 1000).to_i].pack("w"))
kiwnix has joined #ruby
<lessless> ccooke, what does this mean?
<lessless> keymone, yes, this seems pretty good
<lessless> Base64.b64encode([(Time.now.to_f * 1000).to_i].pack("w")).rstrip ;)
<keymone> lessless: yeah, whatever you do to that - just reverse it so base64 can decode it back
<ccooke> lessless: that's a very unsafe uuid for a web-based service
<ccooke> lessless: since it will rfail badly if you ever get two requests in the same thousandth of a second - and that is almost guaranteed if you're going to generate 30k uuids per day
<keymone> you could also add another random number to that array to be more random'ish
<ccooke> no, you need to add something that's *not* random to make it safe
<ccooke> a DB id column would be perfect.
<ccooke> and wouldn't add much to the size.
<keymone> safe is relative term
<keymone> adding random stuff is tradeoff between speed and safety
<lessless> that's true, db's index is titanium-reliable :))
<ccooke> it is. There is plenty of evidence that just adding random + time is a bad gamble in the long run :-)
<keymone> problem with synchronized ids is that you lock your db to get one
<keymone> and with more requests and more locks - you wait more time
<ccooke> keymone: if you have an auto-increment field in your db, you're already doing that.
<matti> shevy: Hi ho here too.
<keymone> that's why you don't need them for that case :)
<ccooke> so you get your unique id for free.
<keymone> in case you have - then yes, just base64 your auto-inc'ed id
<keymone> completely agree on this
<ccooke> well, if your db is badly designed and has no unique keys at all, then you can't use the db as a uniqueness source without adding extra locking. But at that point your db is going to be so badly performing that I can't bring myself to care :-)
<ccooke> and if you have a unique key in the db... that's a source of uniqueness that you don't need any extra work to use.
<keymone> having well-designed db and having auto-ins has nothing to do one to another
ddv has joined #ruby
<ccooke> keymone: where did I say it does?
<shevy> hi matti. let's make babies
<keymone> ccooke: one could wrongly imply that from your message because that was in the context of conversation
<ccooke> keymone: no, I'm just saying that DBs are heavily optimised for use with at least one unique column per table
<ccooke> keymone: doesn't matter if that's an auto-increment or whatever.
<keymone> ccooke: sometimes you just don't want uniq indexes on your table because you can't spend time in locks for uniq checks, that doesn't mean db is poorly designed
<ccooke> keymone: I'd be interested to see what sort of use case you have there
<ccooke> keymone: and whether it's actually best lpaced for a db. It's certain that some operations *do* require faster transaction times than a db with locks can give you, but they're *rare*. And I can't think of a single example that's best implemented in a db
<keymone> ccooke: hundreds of millions of records use case for instance
<keymone> ccooke: i do sometimes have spikes in db when inserting into such table
<ccooke> (my employer has one example, where a single threaded bit of C code running on an mmapped file is used to mark a limited set of flags onto a resource set
ananthakumaran has joined #ruby
<ccooke> keymone: There are usually some methods you can take but, yeah, definitely not always.
<ccooke> keymone: if your schema supports it, partitioning can be amazing for that use case
<ananthakumaran> is there a way to check array equality without taking ordering into consideration
<ananthakumaran> ie [:x, :y] == [:y, :x]
<ccooke> keymone: and there are hardware routes that make a huge difference
<keymone> ccooke: i'm currently thinking about that solution, unfortunately not easy to migrate
<ccooke> keymone: how important is your data?
<ccooke> keymone: yeah, it's tricky. The difference can be huge, though
<ccooke> keymone: and what's your budget?
<ccooke> keymone: there are some interesting routes you can take depending on the answers to those :-)
<keymone> ananthakumaran: easiest and probably worst performing one is [:x, :y] - [:y, :x] == [] and sizes are equal
johndbritton has joined #ruby
<keymone> ccooke: data loses importance with time, budget - tight one :)
<keymone> ccooke: to be precise - latency for requesting data loses importance with age of that data
<ccooke> ananthakumaran: what sort of equality test? every key in array1 must exist in array2 *and* every key in array2 must exist in array1 *and* no keys in only one?
Squarepy has joined #ruby
<ananthakumaran> ccooke: yes
<ccooke> keymone: ah yes. That's a classic partitioning use case, then
<ccooke> keymone: another thing that's fun... have you looked at flashcache?
<ananthakumaran> i am thinking of using array1.sort == array2.sort
Squarepy has joined #ruby
<ccooke> keymone: linux based, kernel patch. Generates a new block device based upon two other devices, with one of them used as a (possible persistant) cache for the other
<ccooke> keymone: it can use memory for the cache - or, as we're using, an ssd
<keymone> ccooke: hmm not sure i can go that way
<keymone> ccooke: i'll look into partitioning of mysql table
bluOxigen has joined #ruby
Progster has joined #ruby
klip has joined #ruby
kiwnix has joined #ruby
sohocoke has joined #ruby
virunga has joined #ruby
iocor has joined #ruby
crankycoder has joined #ruby
shruggar has joined #ruby
banisterfiend has joined #ruby
iocor has joined #ruby
hackeron has joined #ruby
ringotwo has joined #ruby
waxjar has joined #ruby
Proggy has joined #ruby
dbgster has joined #ruby
frishi has joined #ruby
emmanuelux has joined #ruby
ameba has joined #ruby
philcrissman has joined #ruby
Dreamer3 has joined #ruby
gregorg has joined #ruby
gregorg has joined #ruby
mrwalker has joined #ruby
batmanian has joined #ruby
dkamioka has joined #ruby
sectionme has joined #ruby
sub_stantial has joined #ruby
nacengineer has joined #ruby
sh3ll0x_ has joined #ruby
alem0lars has joined #ruby
mcwise has joined #ruby
havenn has joined #ruby
Guedes has joined #ruby
alset has joined #ruby
arvidkahl has joined #ruby
havenn has joined #ruby
shruggar has joined #ruby
monokrome has joined #ruby
akl has joined #ruby
akl has joined #ruby
wolgo has joined #ruby
anekos__ has joined #ruby
rcs has joined #ruby
DuoSRX has joined #ruby
Neil___ has joined #ruby
LMolr has joined #ruby
<Neil___> The flightaware.com API is returning values like "estimatedarrivaltime":1333661400 for a flight arrival time. Does anyone know if the Time class can convert this to a Time object?
havenn has joined #ruby
<Neil___> I haven't seen integer like 1333661400 being used for Time / DateTime before...
<arturaz> <arturaz> % Time.at(1333661400)
<arturaz> <multibot_> 2012-04-05 21:30:00 UTC
justinmcp has joined #ruby
akhkharu has joined #ruby
Haydos has joined #ruby
wolgo has joined #ruby
rohit has joined #ruby
riginding has joined #ruby
rtdp has joined #ruby
iamjarvo1 has joined #ruby
<arturaz> neersighted|AFK,
<arturaz> hm, hes gone
alset has joined #ruby
mythmon has joined #ruby
monokrome has joined #ruby
thorncp_ has joined #ruby
rcs has joined #ruby
tectonic has joined #ruby
danheberden has joined #ruby
benwoody has joined #ruby
danheberden has joined #ruby
akl has joined #ruby
akl has joined #ruby
nari has joined #ruby
alset has quit [#ruby]
anekos has joined #ruby
sj26 has joined #ruby
KitsuneDrag0n has joined #ruby
flyingoctopus has joined #ruby
tdmackey has joined #ruby
nanderoo has joined #ruby
ex0a has joined #ruby
ex0a has joined #ruby
_root_ has joined #ruby
Vendethiel has joined #ruby
shruggar has joined #ruby
twinturbo has joined #ruby
sohocoke has joined #ruby
bigkm has joined #ruby
eldariof has joined #ruby
strife25 has joined #ruby
arvidkahl has joined #ruby
leweo has joined #ruby
<artm> is there a method like to_f but raising exception if string can't be parseable as float?
<matled> artm: Float("3.9")
<matti> artm: No. But you can try: begin ; Float(string) ; rescue ... ; end
Jake232 has joined #ruby
<artm> thanks
<artm> that's it
<artm> I was just looking at the documentation for Float and didn't see that :/
<matled> artm: yeah, it's under Kernel
<artm> hmm... that's annoying :)
fayimora has joined #ruby
<artm> is Float() a different thing than Float module?
<artm> no, i mean class
<matled> artm: yes, Float is a method defined in Kernel
<artm> ok.
havenn has joined #ruby
BiHi has joined #ruby
fhil has joined #ruby
Nathandim has joined #ruby
otters has joined #ruby
havenn has joined #ruby
eugynon has joined #ruby
eugynon has joined #ruby
Ammar_Frameworks has joined #ruby
<catphish> eww, Float *is* a method
<catphish> also, eww
<catphish> why isn't that defined as Float#initialize
<apeiros_> catphish: so is Integer, String and Array…
<apeiros_> because that would make no sense
<catphish> why?
<apeiros_> how'd you use it?
<catphish> Float.new(1)
<apeiros_> yeah, no
<catphish> why is it on kernel?
<apeiros_> because all pseudo-functions are on kernel
jbw has joined #ruby
<catphish> sure, but why do they exist? why not Float.new
lkba has joined #ruby
<apeiros_> you can't create a float. you can only use a literal or convert.
<apeiros_> if, then I'd argue for another class method on Float instead of Kernel#Float
<apeiros_> i.e. Float.coerce(val)
<catphish> yes, that would make more sense to me
<apeiros_> but I assume Kernel#Float was chosen for brevity
<catphish> ans String / Array are certainly creatable
<catphish> *and
<catphish> otherwise you create a precedent to define a pseudo method for every class, that creates it
<catphish> Kernel#Banana(other_fruit)
<catphish> but clearly that's the way it is and it can go in my incredibly small pile of things i don't like about ruby
<apeiros_> catphish: yupp
<catphish> and since i've never used it, it's obviously not a problem to me :)
<apeiros_> I agree with that part
theRoUS_ has joined #ruby
<apeiros_> i.e., that having a class method is preferable over a bazillion Kernel#<classname> methods
<Mon_Ouie> Plus capitalized method names confuse people about what's a constant and what is not
<apeiros_> I'm all for confusing people
<apeiros_> at least a little bit of fun is necessary :)
<banisterfiend> apeiros_: btw the answer to that q yesterday was that RipperParser was an autoloaded class
<banisterfiend> apeiros_: apparently autoloaded classes (that have't yet been loaded) appear under #constants
theRoUS_ has joined #ruby
<apeiros_> banisterfiend: heh, I wanted to tell you that, sorry, I forgot
<apeiros_> (I was at work when you asked)
<banisterfiend> apeiros_: but it was more broken than that, because the constant refused to autoload, yet autoload? seemed to indicate it had
<banisterfiend> so the only wayt o deal with it was to rescue the exception afaict
tomku has joined #ruby
<apeiros_> banisterfiend: still at work, ping me in the evening
jcromartie has joined #ruby
batmanian has joined #ruby
fhil has joined #ruby
<batmanian> is there a way to list a class's own (not inherited) attr setters?
CodeFriar has joined #ruby
<banisterfiend> batmanian: attr setters are not distinguished from ordinary methods
<banisterfiend> batmanian: though maybe you just want to search for methods ending in =
KL-7 has joined #ruby
mdw has joined #ruby
amscotti has joined #ruby
rippa has joined #ruby
<batmanian> banisterfiend I see. okay thanks for the information.
<banisterfiend> batmanian: you can also us instance_methods(false) to only search the current class, not its supers
<banisterfiend> use
mdw has joined #ruby
<batmanian> is instance_methods available inside the initialize method?
<banisterfiend> batmanian: no
<banisterfiend> batmanian: in that case use methods(false), because by the time you're in initialize you are in an INSTANCE no longer the class
<gogiel> banisterfiend: yes
<banisterfiend> gogiel: what? :)
dv_ has quit ["m00h"]
dv_ has joined #ruby
lorandi has joined #ruby
<gogiel> banisterfiend: sorry, meant batmanian
jenglish has joined #ruby
<shevy> lol
<shevy> batmanian and banisterfiend
<shevy> the new dream team
<shevy> though I don't like bats
* shevy starts to shoot at batmanian
<batmanian> gogiel?
<batmanian> :((
<shevy> gogiel ... I don't like that nick either. it reminds me of misspelled google...
<batmanian> Respect! I am the only one who can save ghotman city!
<batmanian> :D
* shevy starts to shoot at gogiel as well
<shevy> lol
<shevy> ghotman
<banisterfiend> gogiel: you mean instance_methods can be called inside #initialize? :P i'd like to see you prove it ;)
tommyvyo has joined #ruby
Danielpk|rdlBNC has quit [#ruby]
<jlebrech> i wish this were real
<Afal> "The page you were looking for doesn't exist.
havenn has joined #ruby
<gogiel> banisterfiend: self.class.instance_methods ?
<gogiel> no idea why it wouldn't work
<gogiel> tested. it works
<banisterfiend> gogiel: sure, it can't be invoked directly (which is what i thought he meant). And since you're inside an instance already, you may as well just use methods(false) instead, rather than unnecessarily calling on another object
<gogiel> yes, sure
`brendan has joined #ruby
<gogiel> if he's looking for methods defined in class and not in super class that's the way to do it
linoj has joined #ruby
tommyvyo has joined #ruby
havenn has joined #ruby
<batmanian> Is there a better style for writing a method like this? http://pastie.org/3732845
abionic has joined #ruby
kiwnix has joined #ruby
fmcgeough has joined #ruby
havenn has joined #ruby
<gogiel> batmanian: yes, you can use {symbol: value} instead of :symbol => value :)
<batmanian> gogiel yes, that's the Ruby 1.9 way of it… but overall I don't like to start the content of my method with { and end it with }
<gogiel> if symbol and method you are calling is not the same there's not better way to do it. if it is you can loop and use #send
<gogiel> and you can ommit self
neurotech has joined #ruby
paradoja has joined #ruby
Houdini has joined #ruby
<Mon_Ouie> I wouldn't call {sym: v} better than {:sym => v}
<Mon_Ouie> Just an alternative syntax
<gogiel> Mon_Ouie: shorter is better for me
pu22l3r has joined #ruby
mstratman has joined #ruby
<banisterfiend> that's not what she said
<Mon_Ouie> So I guess F is a better name than Float?
kW has joined #ruby
kW has joined #ruby
askTheUser has joined #ruby
<gogiel> Mon_Ouie: no. this is the same thing like ommiting brackets, ;, and {} in last argument.
tommyvyo has joined #ruby
dv310p3r has joined #ruby
Mo_ has joined #ruby
Mo_ has quit [#ruby]
jitesh_shetty has joined #ruby
<rking> gogiel: Hrm.. What do you mean by "{} in last argument"?
dv310p3r has joined #ruby
<gogiel> rking: method(a,sym: val) is the same as method(a,{sym:val})
<rking> gogiel: Oh, Ok. Is that a 1.9 thing?
<rking> gogiel: Also, hehe, I'm not sure what you mean by omitting brackets.
<gogiel> method(param) is the same as method param
<rking> OK, gotcha. (I call these brackets: [])
<Mon_Ouie> {sym:val} is a 1.9 thing, but foo(…) instead of foo({…}) isn't
banjara has joined #ruby
<rking> Mon_Ouie: Cool.
<rking> Thanks both. =)
seanstickle has joined #ruby
<gogiel> Mon_Ouie: do you have special mapping for symbols like … ?
monokrome has joined #ruby
<seanstickle> Does anyone remember the name of the video where a programmer was talking about a tool he wrote that allows you to drag around the values of constants in source code?
Nathandim has joined #ruby
nvez has joined #ruby
nvez has joined #ruby
<Mon_Ouie> gogiel: I use a weird french keymap with "easy" access to stuff like that (alt gr + .)
td123 has joined #ruby
clockwize_ has joined #ruby
strife25 has joined #ruby
bawer has joined #ruby
er1c_ has joined #ruby
dql has joined #ruby
ceej has joined #ruby
dazoakley has joined #ruby
netrealm has joined #ruby
CannedCorn has joined #ruby
nanderoo has quit [#ruby]
nanderoo has joined #ruby
waxjar_ has joined #ruby
kpshek has joined #ruby
headius has joined #ruby
wroathe has joined #ruby
pu22l3r has joined #ruby
carlyle has joined #ruby
Indian_ has joined #ruby
Indian_ has joined #ruby
hobbyist has joined #ruby
hobbyist has joined #ruby
bbttxu_ has joined #ruby
hobbyist has joined #ruby
hobbyist has joined #ruby
bigkm has joined #ruby
LBRapid_ has joined #ruby
ceej_ has joined #ruby
shaggy2dope has joined #ruby
g0bl1n has joined #ruby
nlc has joined #ruby
<frontendloader> http://bpaste.net/show/hHkTfc2NzJaQFG0WwlgG/ I've seen this class << self notation at the module level before, is it for singleton-like behaviour?
joachim_ has joined #ruby
<CannedCorn> are there any examples out there of how to reproduce TCPSocket with socket
<CannedCorn> im having a hard time handling the errors thrown by readpartial
<joachim_> what am I doing wrong: mydir = Dir.new('config/deploy') ; mydir.glob("*.rb")
phantasm66 has joined #ruby
brngardner has joined #ruby
heftig has joined #ruby
banjara has joined #ruby
bluOxigen has joined #ruby
Synthpixel has joined #ruby
vysakh0 has joined #ruby
<apeiros_> frontendloader: class << self opens the singleton_class of self, method definitions in that scope become "class methods"
<frontendloader> if a the module is the most immediate scope, they become module methods?
<frontendloader> and since as far as I understand, you can't instance a module, they're more or less singletons?
alx- has joined #ruby
bigkm has joined #ruby
qos has joined #ruby
kvirani has joined #ruby
<apeiros_> frontendloader: you can define "class methods" on any object (point being: class methods aren't really class methods, thus the quotes)
<apeiros_> x = "some string"; class << x; def foo; "foo!"; end; end; x.foo # => "foo!"
<apeiros_> since x can be any object, it can just as well be a module:
banisterfiend has joined #ruby
<apeiros_> module X; end; class << X; def foo; "foo!"; end; end; X.foo # => "foo!"
<frontendloader> maybe after a few more months of experience I'll see the usefulness of defining methods on the module directly is
<frontendloader> see what*
<apeiros_> frontendloader: usually singleton methods on a module should be done by using module_function
<apeiros_> see e.g. Kernel and Math
IrishGringo has joined #ruby
<apeiros_> you can do `require 'foo'` just as well as you can do `Kernel.require 'foo'` (e.g. in case require was overridden)
<apeiros_> same for Math: Math.sin(Math::PI), or: include Math; sin(PI)
<apeiros_> those methods are created using module_function
<apeiros_> other than that, a class method on a module can be used to e.g. have a global anchor/storage
<frontendloader> global anchor/storage makes sense
<apeiros_> yeah, but it's a bad pattern
<apeiros_> it's akin to the singleton pattern
<apeiros_> which is stupidly limiting.
<apeiros_> "nobody ever needs more than a single database connection, hence Database.connection!" yeah, great…
<frontendloader> well, I'm working with Celluloid and need to route messages between Actors depending on what they're listening to
headius has joined #ruby
<frontendloader> and I need to store what they're listening to somewhere...
bluOxigen has joined #ruby
<apeiros_> why wouldn't you store that in the Actor itself?
<apeiros_> I'm surprised that it doesn't already…
Vendethiel has joined #ruby
<apeiros_> after all, it is listening to something, so it has to know to what it is listening…
* apeiros_ gotta get the train
jgarvey has joined #ruby
<frontendloader> I think there just needs to be a Router actor that stores what everyone is listening to, and receives messages from everyone except itself
lorandi has joined #ruby
dkr has joined #ruby
steg132 has joined #ruby
fearoffish has joined #ruby
berserkr has joined #ruby
andy_ has joined #ruby
heftig has joined #ruby
niku4i has joined #ruby
v01d has joined #ruby
Drewch has joined #ruby
lateau has joined #ruby
entrenador has joined #ruby
Ripp__ has joined #ruby
yoklov has joined #ruby
trivol has joined #ruby
rrichardsr3 has joined #ruby
EzeQL has joined #ruby
lorandi has joined #ruby
geekbri has joined #ruby
ringotwo_ has joined #ruby
n3m has joined #ruby
booginga has joined #ruby
ringotwo has joined #ruby
savage- has joined #ruby
Sailias has joined #ruby
pwelch has joined #ruby
ghosTM55 has joined #ruby
nlc has joined #ruby
rippa has joined #ruby
alex__c2022 has joined #ruby
hobbyist has joined #ruby
d3c has joined #ruby
davidcelis has joined #ruby
davidcelis has joined #ruby
dazoakley has joined #ruby
fayimora has joined #ruby
ghosTM55 has joined #ruby
havenn has joined #ruby
ckrailo has joined #ruby
ghosTM55 has joined #ruby
kevinbond has joined #ruby
iocor has joined #ruby
iocor has joined #ruby
Beoran has joined #ruby
havenn has joined #ruby
cap10morgan has joined #ruby
cachoimechi has joined #ruby
`brendan has joined #ruby
<Synthead> is there a way in ruby to test if two vars equal one string? like if a, b = '' then ... end ?
<Synthead> or do I have to do a = '' and b = '' ?
hashpuppy has joined #ruby
CheeToS has joined #ruby
cdepue has joined #ruby
<canton7> Synthead, a == '' && b == ''. That, or a.empty? && b.empty?
<Synthead> canton7: right, but can I combine vars?
<Synthead> canton7: I guess in this case I could do a + b != ''
<canton7> Synthead, not in the way you're asking, for comparison, no
jgrevich has joined #ruby
<canton7> as someone reading your code, I'd prefer two separate comparisons over 'a + b == '' '
dazoakley has quit [#ruby]
<hashpuppy> i have [{"name"=>"M8", "project"=>"W", "blah"=>"20", "foo"=>"4.0"}, ...]; I want {"M8" => "W", "NAME2" => "D", ...}. is there a cleaner way of getting there other than the following solution: myhash.inject({}) {|h, x| h.merge({x["name"] => x["project"]})}
schovi has joined #ruby
<Synthead> canton7: yeah, kind of a hack
<Synthead> but not really
<canton7> Synthead, you could do [a, b].all?(&:empty?) if you really wanted. I'd rather recommend you didn't, though ;)
<Synthead> ah, I see
<Synthead> comparing two strings seems like it'd be faster, too
abionic has joined #ruby
<canton7> yeah, but don't worry about micro-optimisations
crankycoder has joined #ruby
rohit_ has joined #ruby
<canton7> hashpuppy, maybe myhash.inject({}){ |h,x| h[x['name']] = x['project']; h }, or use #each_with_object (1.9 only)
<hashpuppy> thanks
lkba has joined #ruby
apok has joined #ruby
<Synthead> concerning http://rubular.com/r/J9nnAgr9iJ, is there a way I can match (###-###-####) but return ###-###-#### (no parenthesis)?
<catphish> does anyone know what might cause Errno::EMSGSIZE Message too long when sending a large UDP datagram?
eywu has joined #ruby
fayimora_ has joined #ruby
<canton7> Synthead, \((\d{3}-\d{3}-\d{4})\)
<canton7> "(123-123-1234)"[/\((\d{3}-\d{3}-\d{4})\)/, 1] #=> 123-123-1234
lunchdump has joined #ruby
<Synthead> wow, that is awesome, thanks!
eataix has joined #ruby
alem0lars_ has joined #ruby
bbttxu_ has joined #ruby
trivol_ has joined #ruby
tommyvyo has joined #ruby
hobbyist has joined #ruby
<omry> how do I print an array of strings nicely? seems like whatever I do, it prints it without commas/spaces
<omry> tried inspect and to_
<omry> to_s
d2dchat has joined #ruby
<omry> ah, did inspect on the to_s
<omry> silly me :)
Teddy2steper has joined #ruby
<canton7> omry, you can also use "p my_array"
ringotwo has joined #ruby
<omry> p is a part of pp?
<omry> canton7, ^
<omry> which returns instead of printing by any chance?
<shevy> omry nah pp is different
<shevy> p is available always, for pp you must require 'pp' first
<shevy> but pp has nicer output than p
<omry> gotcha
<omry> I have an array of symbols : [:a,:b,:c], what's the easiest way to print it as "a","b","c" ?
<rippa> p object is like puts object.inspect
<omry> or just a,b,c ?
<canton7> [:a, :b, :c].join(',') mebbe?
apeiros_ has joined #ruby
<canton7> that does an implicit to_s on them
<omry> canton7, cool :)
<omry> thanks
booginga has joined #ruby
<canton7> if you want the quotes, [:a, :b, :c].map{ |c| "'#{c}'" }.join(','), or "'" << [:a, :b, :c].join("','") << "'"
rowanu has joined #ruby
fayimora has joined #ruby
DrShoggoth has joined #ruby
jeremy_ross has joined #ruby
eataix has quit [#ruby]
tommyvyo has joined #ruby
baroquebobcat has joined #ruby
thedonvaughn has joined #ruby
philips has joined #ruby
hirotoshi has joined #ruby
strife25 has joined #ruby
<shevy> oh man
<shevy> I should have never tried to rewrite my largest project
<shevy> I cant find motivation to continue :(
lyn4xliu has joined #ruby
nev3rkill has joined #ruby
hobbyist has joined #ruby
uris has joined #ruby
blueadept has joined #ruby
moomerman has joined #ruby
davidcelis has joined #ruby
brngardner has joined #ruby
burgestrand has joined #ruby
williamcotton has joined #ruby
kaneda has joined #ruby
artOfWar has joined #ruby
proffalken has joined #ruby
eywu has joined #ruby
<proffalken> Hi all, I'm looking to interact with Active Directories Scripting Interface (ADSI)
<proffalken> Has anyone tried this via COM objects?
<shevy> I have not
cloke has joined #ruby
Deele has joined #ruby
akem has joined #ruby
Synthpixel has joined #ruby
wyhaines has joined #ruby
joaoh82 has joined #ruby
artOfWar has joined #ruby
booginga has quit ["Leaving"]
williamcotton_ has joined #ruby
jgrevich has joined #ruby
jgrevich has joined #ruby
pencilcheck has joined #ruby
Eiam has joined #ruby
yoklov has joined #ruby
cwang has joined #ruby
Hexstream has joined #ruby
Hexstream has quit [#ruby]
prometheus has joined #ruby
iocor has joined #ruby
bbttxu_ has joined #ruby
philcrissman has joined #ruby
josefig has joined #ruby
Indian has joined #ruby
_kW has joined #ruby
burgestrand has joined #ruby
drknus has joined #ruby
bbttxu_ has joined #ruby
maletor has joined #ruby
adeponte has joined #ruby
jlogsdon has joined #ruby
savage- has joined #ruby
hmans has joined #ruby
wsean has joined #ruby
nik_-_ has joined #ruby
theRoUS has joined #ruby
mk03 has joined #ruby
lunchdump has joined #ruby
ben225 has joined #ruby
apok has joined #ruby
mengu_ has joined #ruby
apok_ has joined #ruby
robdodson has joined #ruby
<robdodson> If I'm using Awesome Print and I see something like this: attr_reader :stories = PivotalTracker::Story < Object does that mean that I can also print out that stories attribute? I've tried ap @project.stories and it just returns "PivotalTracker::Story < Object "
mlue has joined #ruby
cbuxton has joined #ruby
ozymandius has joined #ruby
axl_ has joined #ruby
Eldariof-ru has joined #ruby
tewecske has joined #ruby
Teddy2steper has joined #ruby
schovi has joined #ruby
nonotza has joined #ruby
CannedCorn has joined #ruby
<Synthead> is there a way I can return the first index of an array if it exists? if I put n[1] on a var without knowing if it's an array or if index 1 is declared, I may run into errors
<Synthead> maybe a method?
_kW has joined #ruby
a_a_g has joined #ruby
<moomerman> Synthead: n.first
<moomerman> Synthead: will return nil if no element exists
emmanuelux has joined #ruby
brianpWins has joined #ruby
<Synthead> NoMethodError (undefined method `first' for nil:NilClass)
io_syl has joined #ruby
<Mon_Ouie> You called it on nil, not on an array
<Mon_Ouie> also n[1] is the second element, not the first one
apok has joined #ruby
kvirani has joined #ruby
Sailias has joined #ruby
luckyruby has joined #ruby
<Mon_Ouie> You should just check if your variable references nil or not (if your_array then … end)
zakwilson_ has joined #ruby
<luckyruby> what's the method for finding an object id?
<moomerman> Synthead: n.is_a?(Array) ? n.first : nil
<Mon_Ouie> luckyruby: #object_id
Araxia has joined #ruby
johnmilton has joined #ruby
<Mon_Ouie> Not that there are many practical uses for an object id
<luckyruby> Mon_Ouie: ah. so close
<luckyruby> is there a way to modify an array via subtraction but maintain the same object id?
<luckyruby> foo = %w(a b c); foo = foo - %w(c)
<Mon_Ouie> There is, but I don't think there is a destructive variant of Array#-
<Mon_Ouie> It is possible to write it anyway
<luckyruby> Mon_Ouie: how would I accomplish that?
<luckyruby> I suppose alternatively, I could use an instance variable.
hartjus_ has joined #ruby
<Mon_Ouie> other = Set.new(other); array.reject! { |o| other.include? o }
atnight has joined #ruby
<Mon_Ouie> (You can skip the conversion to a set if you want, but Set#include? is more efficient for large arrays)
<apeiros_> ary.replace(ary-ary2)
<apeiros_> as an alternative
<luckyruby> apeiros_: i like
SegFaultAX|work has joined #ruby
emmanuelux has joined #ruby
willson has joined #ruby
monokrome has joined #ruby
nfluxx has joined #ruby
adamkittelson has joined #ruby
hobbyist has joined #ruby
ed_hz_ has joined #ruby
Sou|cutter has joined #ruby
vipaca has joined #ruby
vipaca has joined #ruby
Sou|cutter has joined #ruby
crankycoder has joined #ruby
Asher has joined #ruby
Indian has joined #ruby
Indian has joined #ruby
Houdini has joined #ruby
Asher has joined #ruby
kenichi has joined #ruby
jensn has joined #ruby
Vendethiel has joined #ruby
senthil has joined #ruby
dfibre has joined #ruby
<senthil> You can actually inherit from a method?
wyhaines has joined #ruby
<matled> senthil: you mean like def foo; SomeClass; end; class A < foo; end?
<senthil> matled: yea
<matled> senthil: you inherit from the class returned by that method
<senthil> it seems you can't have multiple classes inside "def foo"
<matled> senthil: foo is called and the return value is used for inheritance. one of the delegator implementations uses that too
<senthil> matled: how is that useful? for dynamic assignment of superclass?
havenn has joined #ruby
macmartine has joined #ruby
<matled> yes, like class Tempfile < DelegateClass(File)
<matled> (note that DelegateClass is a method, even though it starts with a capital letter)
<senthil> matled: cool! thx
voodoofish430 has joined #ruby
robdodson has joined #ruby
<lectrick> hey apeiros_ you dropped offline before I could show you yesterday but I iterated a bit on the idea you helped me with and figured out how to use a Delegator to implement it with even less code: https://gist.github.com/2305169
ABK has joined #ruby
Asako24 has joined #ruby
<Asako24> hello
<Asako24> is there any way to make rails stop showing deprecation warnings?
deobald has joined #ruby
<Asako24> DEPRECATION WARNING: metaclass is deprecated and will be removed from Rails 2.3
<Asako24> I really don't care since I don't plan to upgrade
Helius has joined #ruby
_ack has joined #ruby
bluOxigen has joined #ruby
shadoi has joined #ruby
heftig has joined #ruby
alem0lars has joined #ruby
baroquebobcat has joined #ruby
lessless has joined #ruby
Russell^^ has joined #ruby
eywu has joined #ruby
corroded has joined #ruby
cha1tanya has joined #ruby
<lectrick> Asako24: Yes but the exact way to do it depends on the rails version.
baroquebobcat has joined #ruby
havenn has joined #ruby
brngardner has joined #ruby
Jayvan has joined #ruby
imsplitbit has joined #ruby
deobald has joined #ruby
<Asako24> hmm, I don't even see rails installed
<Asako24> passenger (2.2.5)
shades_ has joined #ruby
headius has joined #ruby
stkowski has joined #ruby
<Asako24> my passenger log is just getting spammed with warnings
Deele has joined #ruby
<shevy> to convert hash {"b"=>"true", "a"=>"true"} into array, what is a simple way?
Tankado has joined #ruby
<apeiros_> lectrick: nice
<apeiros_> shevy: .to_a
Tankado has quit [#ruby]
lorandi has joined #ruby
<shevy> wheeeeee thanks
startling has joined #ruby
Deele has joined #ruby
nemesit has joined #ruby
wroathe has joined #ruby
fayimora has joined #ruby
ABK has joined #ruby
hooper has joined #ruby
c0rn has joined #ruby
ABK has joined #ruby
regularlambda has joined #ruby
ABK has joined #ruby
troulouliou_dev has joined #ruby
<troulouliou_dev> hi i do not remember or to make a regexp with or like : ((AAA) |(BBB))
<troulouliou_dev> i want to match either AAA or BBB
brianpWins has joined #ruby
n3m has joined #ruby
brianpWins has joined #ruby
davidd___ has joined #ruby
pdtpatrick has joined #ruby
ABK has joined #ruby
<burgestrand> troulouliou_dev: you just wrote it, but with a lot of parentheses
brianpWins has joined #ruby
monokrome has joined #ruby
<shevy> hehehe
<shevy> the more parens the better
<shevy> ruby remembers that code with parens is IMPORTANT
<shevy> (((( VERY_STRONG_CONSTANT_HERE )))
<shevy> hmm forgot a )
Synthpixel has joined #ruby
KryoTech has joined #ruby
vysakh0 has joined #ruby
<troulouliou_dev> burgestrand, ok my fault
crodas has joined #ruby
<burgestrand> troulouliou_dev: no no, your right
<troulouliou_dev> my fault to ask :)
askTheUser has joined #ruby
<burgestrand> troulouliou_dev: asking is never bad unless you are at an apple store in sweden where they charge you for it
<askTheUser> hey what's the addition method in ruby?
<shevy> sounds like all the pirates are in sweden
<burgestrand> askTheUser: addition
<troulouliou_dev> burgestrand, son't know the exact story but no i m not :)
<shevy> haha
<shevy> askTheUser, what do you wanna add
<burgestrand> troulouliou_dev: :)
<askTheUser> hey shevy. just like 3 + 4
<shevy> hmm I think it is def +(input) ... but I am not sure
ABK has joined #ruby
<shevy> I am never able to remember these things out of my head alone :(
<shevy> method(:+) NameError: undefined method `+' for class `Object'
<shevy> hmmmm
<shevy> I suppose I was wrong
dv310p3r has joined #ruby
<askTheUser> :(
adamn_yyc has joined #ruby
<davidd___> askTheUser: did you try plus sign (+)?
mcwise has joined #ruby
<davidd___> 2.+(2) works for me
<askTheUser> thanks
<askTheUser> !!
<burgestrand> Ah, it’s just syntax confusion
<burgestrand> askTheUser: usually you just write "2 + 2" in ruby too
robdodson has joined #ruby
<davidd___> personally I always write 2.+(2)
<davidd___> just to confuse people
<rippa> I can't submit that goddamd puzzle
<rippa> what does it expect
heeton has joined #ruby
<burgestrand> Trying to figure that out myself…
<heeton> Anyone one know of a tiny, single-user, fast file-based nosql database? Like sqlite, but mongodb or something :P
<rippa> oh, just one +
<davidd___> I guess I should make that more clear
zommi has joined #ruby
swittenkamp has joined #ruby
aj910martin has joined #ruby
<bawer> you just submit the __ - part
CannedCorn has joined #ruby
<bawer> which is +
workmad3 has joined #ruby
kevinbond has joined #ruby
adamn_yyc has joined #ruby
jlogsdon has joined #ruby
banisterfiend has joined #ruby
slonimsky has joined #ruby
otters has joined #ruby
__main__ has joined #ruby
<shevy> what
<shevy> __ is + ?
<rippa> yes
<shevy> you only want to confuse me!
tehgeekmeister has joined #ruby
askTheUser has joined #ruby
avalanche123 has joined #ruby
artOfWar_ has joined #ruby
askTheUser_ has joined #ruby
<avalanche123> I have a ruby ffi question about buffer allocation
yekta has joined #ruby
hippyphysicist has joined #ruby
<bounce> heeton, what sort of data are you planning to put in and what sort of queries are you planning to run over that data?
<burgestrand> avalanche123: don’t ask to ask, do ask, and you will not be asked to ask what it is you want to ask
<avalanche123> haha, ok
<avalanche123> I'm writing bindings for libuv using ruby ffi
cobragoat has joined #ruby
<heeton> bounce: I'm considering using it for a game, written in ruby. I don't need blazing fast write/reads (though would be nice for testing), I'm more looking for a nice data structure to work with during development
<avalanche123> it is using a buffer to for stream processing, that gets created with alocation function
<heeton> Something like mongoid's data structure is good, there will be lots of objects with varying attributes and nested collections, that kind of thing
<avalanche123> when I use it from c using malloc to allocate buffer base, it works fine
<avalanche123> from ruby however, I use attach function and malloc too, but it seems to allocate null terminated string
<burgestrand> My internet is a bit crappy at the moment, sitting on a cross-country train tethering via my phone :(
<avalanche123> here is buffer is allocated in both langs https://gist.github.com/1f1abaeb7be3b9e1ec91
kirun has joined #ruby
SeanLazer has joined #ruby
CodeFriar has joined #ruby
<SeanLazer> Is there a way to get a suggested file extension for a temporary file?
<avalanche123> I've also added the important part of UV module and hex dumps of allocated buffer from c and ruby
daniel_hinojosa has joined #ruby
<avalanche123> looks like ruby buffer is new-line separated while c buffer is continuous mamory
<avalanche123> *memory
chimkan_ has joined #ruby
<burgestrand> Still trying to load the gist :d
<avalanche123> it is not the full buffer just a part of it, but it displays the difference :)
<yekta> Using ruby 1.9 why can I require File.expand_path('../my_gem/version', __FILE__) but not File.expand_path('../my_gem/some_dir/base', __FILE__) -- that throws a load error.
<avalanche123> ok,let me know when you get it burgestrand
<burgestrand> yekta: print the result of FIle.expand_path, it show you your answer
<burgestrand> yekta: most likely the path is off
<yekta> burgestrand: well, I'm building a gem here, if I puts it it shows what I expect, but when I build the gem (using bundler) it doesn't get included into the package
stephenjudkins has joined #ruby
<yekta> My gemspec files list is here: gem.files = `git ls-files`.split("\n")
<burgestrand> yekta: for one, don’t use absolute paths to require files in your gems unless absolutely necessary
<burgestrand> yekta: rely on rubygems adding your lib/ folder to the load path, it should be enough to require 'your_gem/version' and require 'your_gem/other_file'
<burgestrand> (or even go down into subdirectories)
<burgestrand> yekta: as far as bundler goes, like that line says it only adds the files listed in git to the gemspec
<burgestrand> yekta: so if a file does not show up there, you probably need to git add path/to/your/file
<bounce> heeton, what's "lots of objects"?
aj910martin has quit [#ruby]
nlc has joined #ruby
<axl_> So I have an interesting question: Can I create an object and stub out a couple methods on it? What i want in host is an object that responds to .success ? with a false and .error_message with a string
<axl_> also is this bad coding?
Sailias has joined #ruby
<bounce> you're trying to use code testing tricks for production?
<shevy> I dont know what you are asking
<axl_> well, i guess, I haven't really explained the context, to it might come across as an outrageous thing to want to do, but in context it is not terrible
startling has joined #ruby
<axl_> bounce: sorta
<axl_> i get an object on an api call
<yekta> burgestrand: The sub directory files in lib are in the git list, but a relative require './dir/file' from within the main file in lib doens't work either, I've also tried require_relative './dir/file'
<shevy> I would not know if it is outrageous because I really have no idea what you want to do
<shevy> you want to change an object at runtime?
<bounce> drop a mixin on the object? (no idea if you can do that)
<axl_> shhevy
<yekta> burgestrand: I'm also not pushing this to rubygems (I'm just playing with trying to make a gem right now) -- how do you mean rely on ruby gems?
* bounce is still a ruby n00b
<shevy> I dont have so many h
<burgestrand> yekta: leave out the dot, it uses the current working directory, do just require 'your_gem/dir/file' assuming the file is placed in lib/dir/file.rb
<shevy> :P
<axl_> :)
<axl_> wel
<axl_> ,
<yekta> burgestrand: trying*
<bounce> ok, less hitting enter, more proofreading before hitting enter
<burgestrand> yekta: when you load your gem in irb, use -I to add the lib/ directory to the load path, it will be needed
<burgestrand> yekta: irb -Ilib -ryour_gem
<axl_> so, i want to create an object named result and have it respond to two methods: .success and .error_message
<shevy> axl_, you can create a new class, or not?
<shevy> if you can, just define those methods
<shevy> class Bla
<shevy> def success
<axl_> i can, but that just seems like an overkill
<shevy> what overkill :P
<shevy> you need to add the behaviour (of those two methods) anyway
<axl_> because i am going to use this object once in a particular situation
<axl_> a
<axl_> nd
<axl_> i want
<burgestrand> yekta: (your_gem is the name of your gem, and you should have a lib/your_gem.rb file)
<shevy> either you make a class, or you add the methods as singleton methods on your object
Vendethiel has joined #ruby
* bounce kicks axl_ for being obnoxious
<shevy> yes but even if you use it ONCE, you STILL have to modify its CURRENT behaviour
<burgestrand> avalanche123: still can’t load it, do you have the git url? might be able to clone it
<shevy> using a class is just the simplest way. you can singleton define the method, or you can bundle things into a module and mixin
<shevy> the *methods
<avalanche123> sec
<axl_> hmm.m...
<axl_> (my client is seemingly doing weird things with my keyboard)
fr0gprince_ has joined #ruby
<shevy> most people say it's the cat
seanstickle_ has joined #ruby
<shevy> like sometimes... things like...
<bounce> probably the ADHD
<shevy> die burgestrand !!!!!!
<shevy> happen
<shevy> and it's my cat
<burgestrand> D:
<shevy> because I only want to say
<shevy> hi burgestrand :)
<shevy> my cat is psycho
ceej has joined #ruby
<shevy> here is a catdoor downstairs... but she does not use it. instead she goes to the window and starts to make noise, and run up and down, until someone opens the window
<shevy> (but she could leave downstairs, then climb a tree, and end up on the roof too... stupid cat ...)
<avalanche123> burgestrand I made it a private gist, so git clone url wont help you, let me change that to public
<burgestrand> :p
<burgestrand> I’m surprised I manage to stay online even
ozymandius has joined #ruby
<avalanche123> ben225 git://gist.github.com/2313277.git
<avalanche123> err
<avalanche123> burgestrand git://gist.github.com/2313277.git
<yekta> burgestrand: OK, doing `irb -Ilib -rgit-to-pivotal` works! Howabout when I want to require my gem in a lets say git hook though, is there a way I can make it load the lib right away?
baroquebobcat has joined #ruby
havenn has joined #ruby
<burgestrand> yekta: hm, depends on how you require your gem in your git hook (absolute path to gem file or just require 'gemname')
brngardner has joined #ruby
<yekta> burgestrand: essentially what that must of done is add it to the loadpath yea? I would prefer to do a require 'gemname'
<burgestrand> yekta: if you install your gem to your system it would work that way for one
<yekta> burgestrand: *sigh, that's what originally did -- Using bundler again but I did rake build; rake install
<burgestrand> yekta: but if you don’t want to do that, and if you know which path your gem is in, you can do the same like you did with IRB, but perhaps from inside ruby by modifying the load path: $LOAD_PATH.unshift('/full/path/to/gem/lib'), and then require it like usual
<yekta> burgestrand: ah ha
<burgestrand> avalanche123: got it :d
<avalanche123> yay
<avalanche123> burgestrand as you can see the dump of buf from ruby is huge
<avalanche123> and I didn't even attach all of it
<axl_> shevy: so this is what I am thinking of doing: https://gist.github.com/2313316
<burgestrand> avalanche123: by the way, you should be able to just ffi_lib 'uv' instead of the full path to it (but full path to it works well as long as you know the full path to it :p)
<shevy> ewwwww
<avalanche123> yeah, this was a sample, I'm not using this, I have a list of paths much like ffi-rzmq
<shevy> axl_ I am glad that I will never touch something like this :)
<axl_> shevy: i am sure
<axl_> shevy: but i want to know what's bad
<shevy> funny idea though
<shevy> almost prototypical
<axl_> given that ruby considers everything as an object and follows duct typing
<axl_> err..
<axl_> duck typing
baroquebobcat has joined #ruby
<shevy> well, ruby kinda follows the "there is more than one way to do it" creativity line of thinking ... but it also gently suggests a better way. and for me, this is the classical class hierarchy that ruby prefers and insinuates to have people use
* bounce pokes heeton
<shevy> lol duct typing, nice pun :)
<axl_> anyways, thanks for your inputs
<shevy> that is like duck typing combined with monkey patching, isn't it? :D
<shevy> duct typing
<bounce> monkey business
<shevy> that sounds kinda cool
<shevy> none of your monkey business man!
antillas21 has joined #ruby
_main_ has joined #ruby
__main__ has joined #ruby
<heeton> bounce: sorry, afk. Not 'lots' , probably 50-500 :P
<burgestrand> avalanche123: talking to many people at the same time, sorry for being slow :p
<avalanche123> burgestrand sure, I'm sure it something silly that I don't understand about ruby ffi
<bounce> uhm. drop the whole thing in a file
<bounce> sounds like all you want is serialisation
<heeton> Yea, it probably is to be honest
jsnoob has joined #ruby
<heeton> Forget my question :)
<bounce> otherwise I'd have a couple suggestions :-)
<jsnoob> what's the goto book for learning ruby?
wyhaines has joined #ruby
<shevy> there is not one really, but learn to program by chris pine is good to work through once
<burgestrand> avalanche123: you don’t use uv_alloc_cb, is it something you’ve missed or is it intentional?
<shevy> ignore the title though, it really is more an introduction to ruby
<shevy> the pickaxe is also ok, the latest pickaxe is a bit boring though, but the pickaxe from ~5 years ago was nice
luxurymode has joined #ruby
<avalanche123> burgestrand yeah, this is used by libuv like so UV.read_start(stream, method(:on_alloc), method(:on_read))
<burgestrand> avalanche123: but it does look correct to me, UV.malloc returns a pointer to a memory region that fit 128 bytes and you pass that on to UV.buf_init
<avalanche123> right
<shevy> one good thing in the pickaxe is that it has the whole stdlib in its appendix with many comments and examples, this one I still regularly look at for new things jsnoob
<avalanche123> but when I hex dump it from c I get huge dump
<shevy> but the middle part of the latest pickaxe was just boring :(
<bounce> jsnoob, the poignant guide, wasn't it?
ghanima has joined #ruby
<burgestrand> avalanche123: keep in mind though that the memory allocated by malloc holds undefined data, it’s not zeroed out
<avalanche123> burgestrand that's fine, libuv overrides it and tells how much can be read
<avalanche123> but it seems weird that I would get such a long buffer allocated from Ruby compared to the one I allocate in C
<jsnoob> bounce: i do hear of why's poigniant guide quite often. just wish there was a version i could throw on my kindle
<burgestrand> avalanche123: I don’t get where the hex dumps come in though, how are they generated?
<shevy> hearing often about it doesn't mean it is any good
<avalanche123> burgestrand I added the loop that does the hex dump to the gist
<rippa> in mobi format
<avalanche123> but it is basically a loop I added inside one of libuv's internal functions
artOfWar has joined #ruby
<burgestrand> avalanche123: for both ruby and C the pointer allocated by malloc should hold no more than 128 bytes
<avalanche123> that uses allocated bufffer
<avalanche123> burgestrand exactly, but it is way more for ruby
<yekta> burgestrand: OK, I've tested this with $:unshift('/full/path/to/gem') and $LOAD_PATH.... I also puts the $LOAD_PATH right after I unshift it and it has the 'full/path/to/gem/lib' in there, but then after a rake build;rake install; irb and then `require 'my_gem/dir/file' fails to load :-/ I don't understand what I'm missing now
<burgestrand> avalanche123: you are still passing in the size, how do you know it is way more for ruby?
<avalanche123> burgestrand the hex dump is too long
<burgestrand> yekta: are you using ruby v1.8?
<yekta> burgestrand: no, this is 1.9.2.p290
qos has joined #ruby
<yekta> burgestrand: I just spoke incorrectly though -- in irb I `require 'gem_name' and it fails to require the file in the sub dir in lib
<shevy> hmm
<jsnoob> rippa: thanks mate
<burgestrand> yekta: and you require it with just 'my_gem/dir/fle', and the file is in lib/my_gem/dir/file.rb?
<yekta> burgestrand: correct
<Boohbah> $LOAD_PATH.unshift File.dirname(__FILE__)
<Boohbah> require 'file'
<burgestrand> avalanche123: but buf.len should not give you a bigger value than what you pass in to buf_init, should it?
<yekta> $LOAD_PATH.unshift( File.expand_path(File.dirname(__FILE__)) )
<Boohbah> yekta: hmm, what is the expand_path for?
<avalanche123> burgestrand yeah, exactly
<Synthead> is there some sort of inotify (or similar) gem for ruby? I want to watch a directory for new files and run a function every time it sees something. even better if it can fork multiple threads!
<avalanche123> I'm going to see what is there during execution
<yekta> Boohbah: It can be used to join files later, its probably not necessary for this test.
<burgestrand> avalanche123: but you pass in 128 as the second parameter to buf_init, so even if UV.malloc allocates too muc buf_init should always receive 128 as the size
<Boohbah> yekta: interesting
<avalanche123> burgestrand ok, here is what I got from C
<avalanche123> Got a buffer 128 bytes long
<avalanche123> ruby - Got a buffer 140735085305696 bytes long
<avalanche123> so the second parameter got it as too much
BonkersLaptop has joined #ruby
<axl_> shevy: so hey, i found what i was really looking for: http://www.ruby-doc.org/core-1.9.3/Struct.html
<avalanche123> burgestrand I'm gonna head out for a little bit, brb
<burgestrand> avalanche123: if I understand you correctly, buf_init gets a HUGE value for its size_t parameter?
<burgestrand> avalanche123: because that is *odd* :p
<burgestrand> I’ll probably be off soon, running out of battery and too lazy to get my power chord from the other side of the train
<yekta> burgestrand: The strange thing is -- the version inside of 'my_gem/version' loads fine.
<burgestrand> yekta: still, if you do "git ls-files lib" is your file in that list?
<burgestrand> no idea why I added still
<burgestrand> but I still did
<yekta> :)
<yekta> Well, that's interesitng...
<burgestrand> yekta: because the list of files you get from "git ls-files lib" is the list of files that get included in your gem
<yekta> burgestrand: right, that must be it then
<burgestrand> yekta: to have files on that list, you need to have added them in git, it’s possible you might need to even commit them
<shevy> axl_ yeah I call you Mr. Prototype from now on :P
<axl_> :)
<axl_> thanks.
<axl_> shevy: do you happen to be a cute gal by any chance
<yekta> burgestrand: face-palm
<yekta> burgestrand: thank you
<burgestrand> yekta: \o/
<axl_> shevy: ok, i am totally joking, please don't get offended, just thought that was funny
kpshek has joined #ruby
lurraca has joined #ruby
kpshek has joined #ruby
<Synthead> $ gem server -d ~/.gem/
<Synthead> ERROR: While executing gem ... (ArgumentError)
<Synthead> /home/max/.gem does not appear to be a gem repository
<Synthead> how can I view rdoc for user-installed gems?
wmoxam has joined #ruby
davidpk has joined #ruby
<Synthead> this did it: gem server -d ~/.gem/ruby/1.8/
Chryson has joined #ruby
dv310p3r has joined #ruby
looopy has joined #ruby
<heeton> bounce: So, I guess one of the reasons I had 'database' in my head: I want transactions for my game events
<heeton> But, there's bound to be a way to achieve that normally, and it's not going to be a big problem because it'll only be 1 person running the code
<heeton> So, I was really barking up the wrong tree :P ]
bananastalktome has joined #ruby
poorlilrichboy has joined #ruby
kuzushi has joined #ruby
<Synthead> will I experience a race condition if I use FSSM's "create" class to parse files in a directory where they are being written to? the writes won't be atomic
<bounce> heeton, you do know that asking for transactions isn't exactly what you'd ask of "nosql" systems, do you?
<heeton> Yep, I do now :)
<heeton> It was like a fever dream... I had a kernel of an idea in my head, in an area I've not tried before, and I just started asking dumb questions
<bounce> but yeah, you could drop the whole thing in a file and do the old unlink/rename trick
asteve has joined #ruby
deobald has joined #ruby
<asteve> what does self do in ruby? specifically def self.method_a vs def method_a?
hashpuppy has quit [#ruby]
kreantos has joined #ruby
<yxhuvud> def self.foo in a class context will define the method on the class instead of on instances of said class
<kreantos> hey, did anyone ever interacted with dbpedia?
<asteve> yxhuvud: so if I use def self.method_a I could not use the method with c = Class.new; c.method_a?
deryl-android has joined #ruby
<yxhuvud> asteve: uh. That question doesn't make sense.
thedonvaughn has joined #ruby
<shevy> hehehe
<shevy> it's still an awesome question :)
<asteve> yxhuvud: i believe you, I don't understand why self has any value
<shevy> self refers to something
<shevy> class Test; puts self.class; end # => Class
<yxhuvud> asteve: c = Class.new; class << c; def self.hello; puts 'hih'; end; end; c.hello
<yxhuvud> c.new.hello => undefined method hello
andrewhl has joined #ruby
jlogsdon_ has joined #ruby
<shevy> asteve with self.name, inside a class, you make a class method. if it is in class Foo, def self.test, you could call it like: Foo.test
<shevy> without using .new
<shevy> you see?
CannedCorn has joined #ruby
internet_user has joined #ruby
sacarlson has joined #ruby
seivan has joined #ruby
nik_-_ has joined #ruby
pastjean has joined #ruby
nacengineer has joined #ruby
Indian has joined #ruby
satrionics has joined #ruby
<satrionics> hi. does anyone know the status of gtk+3 bindings for ruby?
<satrionics> currently unsupported according to gtk.org
robacarp has joined #ruby
havenn has joined #ruby
zeroeth has joined #ruby
<zeroeth> Guys, what conditions would create a complex number?
<heeton> square root of -1
<heeton> (or any negative number)
<zeroeth> that returns invalid domain
zommi has joined #ruby
blueOxigen has joined #ruby
<apeiros_> zeroeth: because you didn't require 'complex'
<apeiros_> and then ruby performs it only regarding the domain of real numbers
<apeiros_> and as ruby tells you, the operation is invalid then
bluOxigen has joined #ruby
Guest____ has joined #ruby
bluOxigen has joined #ruby
MasterIdler has joined #ruby
samgranieri has joined #ruby
<zeroeth> apeiros_: ah thanks
<zeroeth> seems rails.. or something loads it
<zeroeth> vs irb
workmad3 has joined #ruby
nvez has joined #ruby
nvez has joined #ruby
pyreal has joined #ruby
arturaz has joined #ruby
dfamorato has joined #ruby
babinho has joined #ruby
brngardner has joined #ruby
banisterfiend has joined #ruby
bglusman has joined #ruby
asobrasil has quit [#ruby]
krz has joined #ruby
ryan__ has joined #ruby
fabiobik has joined #ruby
<ryan__> Could I please be given some advice on loading gems correctly.
_adeponte has joined #ruby
<davidcelis> require "rubygems"
<davidcelis> require "the gem"
<davidcelis> or use bundler
blacktulip has joined #ruby
<ryan__> Thanks. I was just missing the rubygems line. I'm not sure why I didn't think of that.
<apeiros_> only do the require 'rubygems' in your executable, not in your library.
sacarlson has joined #ruby
krz has joined #ruby
hooper has joined #ruby
dr_bob has joined #ruby
rexbutler has joined #ruby
CodeFriar has joined #ruby
Araq has joined #ruby
<Araq> hi, has anyone run ruby under valgrind?
<yxhuvud> haha have fun.
lorandi has joined #ruby
lorandi_ has joined #ruby
<Araq> I mean: has anyone found a solution to make it not moan about the conservative stack scanning?
<lectrick> If a File object goes out of scope and it didn't happen to be closed... Is it closed?
juiceman5000 has joined #ruby
jlogsdon has joined #ruby
triptec has joined #ruby
Araq has quit [#ruby]
<lectrick> I just did an irb test. The answer is: It stays open until the next garbage collect
<bawer> letrick: that sounds like a zen koan.. :)
<lectrick> lol
nlc has joined #ruby
KL-7 has joined #ruby
<lectrick> This job is such fucking magic. Ephemeral things existing only in my mind and then only represented in the physical world as a pattern of flipped bits in this machine are created and then destroyed nearly instantaneously
<lectrick> No wonder we scare people.
<bawer> all working because of magick currents of energy surging around the planet
<bawer> any technology advanced enough is indistinguishable from magic
stephenjudkins has joined #ruby
<bawer> as Arthur C. Clarke put it
tommyvyo has joined #ruby
mcwise has joined #ruby
<shevy> what a dumb man
iamjarvo has joined #ruby
ryker has joined #ruby
aroop has joined #ruby
<ryker> hi everyone
<ryker> I have an array, where each element contains a string like: key: value
<ryker> how can I parse this array and print out the keys and values?
<ryker> seriously, i have googled for the answer
<ryker> but I'm not having any luck finding what I want
<apeiros_> ryker: what did you try so far?
shruggar has joined #ruby
<gogiel> ryker: split ':'
<senthil> ryker: string.split(':')
askTheUser has joined #ruby
<ryker> ah, wait a sec. i think i was making this too complicated :)
<ryker> I was trying to use a regex in the slit
<ryker> *split
<ryker> :)
cap10morgan has joined #ruby
<apeiros_> I think you will want a regex
Jayvan has joined #ruby
supergiantrobot_ has joined #ruby
<apeiros_> at least if you want to avoid leading whitespace in the value
<ryker> apeiros_: lol, thank you very much.
<ryker> well, i just used k,v = string.split(":")
<ryker> and k.strip for printing the value
<apeiros_> (can always use strip too, of course)
<ryker> thank you. i was making it so complicated trying to use a regex instead of just a colon in split
<bawer> KISS
moshee has joined #ruby
moshee has joined #ruby
<apeiros_> o0
* apeiros_ thinks a single split with a regex is simpler than a split + a strip - but maybe that's just him…
<Zolrath> ryker: I assume none of your values can be strings containing colons?
thone has joined #ruby
<gogiel> ryker: arr.map {|x| Hash[*(x.split(':').map(&:strip))] }
<ryker> Zolrath: well…. I think so. I'm parsing the output from virsh dominfo
jhowarth has joined #ruby
<ryker> gogiel: that looks so complicated. :) what advantage is there to use your example?
sacarlson has joined #ruby
<gogiel> ryker: or Hash[array.map{|x| (x.split(':').map(&:strip)) }] to make big hash, not array of hashes
<gogiel> ryker: it's very simple, just one-liner
elake has joined #ruby
<Boohbah> gogiel: do you need to ampersand?
<Boohbah> to/the
<shadoi> Boohbah: that is a Symbol#to_proc short-form call
<Boohbah> shadoi: aye, i was reading about this today
<Boohbah> shadoi: seems it will work with no &, at least in newer rubies
<gogiel> it won't
<gogiel> you need &
hobbyist has joined #ruby
hobbyist has joined #ruby
dpollen has joined #ruby
<shadoi> Boohbah: maybe in 1.9.3? 1.9.2 requires it.
tommyvyo has joined #ruby
<apeiros_> no, 1.9.3 still needs it
hobbyist has joined #ruby
<shadoi> yeah, would be a strange change.
<Zolrath> You don't need the & for things like array.reduce(:+)
<canton7> Boohbah, inject() can accept straight symboles, and does its own fancy stuff on them. Other methods require Symbol#to_proc
h4mz1d has joined #ruby
jgrevich_ has joined #ruby
jgrevich_ has joined #ruby
satrionics has quit ["Konversation terminated!"]
<Zolrath> ryker: If the values CAN have colons /(?<key>.*):\s+(?<value>.*)/
<Boohbah> canton7: ahh it is only reduce/inject that can accept symbols
<Boohbah> interesting
<Boohbah> thank you
<shadoi> hmm.. inject/reduce/map/collect should be consistent, that's kinda ugly.
<ryker> Zolrath: cool. thank you
byronb has joined #ruby
<canton7> #inject(:+) et al are a bit of a special case anyway. With e.g. #map, a.map{ |c| c.to_s } == a.map(&:to_s). However, a.inject(:+) == a.inject(0){ |s,c| s + c }, which is a more involved mapping, and goes beyond simply calling a method on each element of a
dr_bob has quit [#ruby]
pu22l3r_ has joined #ruby
savage- has joined #ruby
ed_hz__ has joined #ruby
mengu_ has joined #ruby
mengu_ has joined #ruby
io_syl has joined #ruby
bozhidar has joined #ruby
nelson- has joined #ruby
looopy has joined #ruby
nelson- has joined #ruby
joaoh82 has joined #ruby
cpruitt has joined #ruby
jerg_phone has joined #ruby
mdw has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
buschhardt has joined #ruby
buschhardt has quit [#ruby]
andrewhl has joined #ruby
<rking> So, ruby -0777 -pe ... works on the whole stream, rather than the line, only. I don't quite understand, though what is special about character 0777 that it is an invalid char. Any ideas?
atmosx has joined #ruby
anykey has joined #ruby
wefawa has quit [#ruby]
macmartine has joined #ruby
iocor has joined #ruby
Synthpixel_ has joined #ruby
atmosx has joined #ruby
swittenkamp has joined #ruby
<swittenkamp> robert_: hola
CannedCorn has joined #ruby
bozhidar has joined #ruby
jerg_phone_ has joined #ruby
<swittenkamp> robert_: if you're around, got some more questions. PM me when you get a chance?
yoklov has joined #ruby
crodas has joined #ruby
<C0deMaver1ck> does anyone in the New Orleans area know of any Ruby meet-ups or conferences around besides RubyBayou which I've been told doesn't really exist
Progster has joined #ruby
x77686d has joined #ruby
x77686d has joined #ruby
gen0cide_ has joined #ruby
quest88 has joined #ruby
iamjarvo has joined #ruby
juiceman5000 has quit [#ruby]
jerg_phone has joined #ruby
quest88 has joined #ruby
Brainix has joined #ruby
mmercer has joined #ruby
Synthpixel has joined #ruby
gen0cide_ has joined #ruby
Banistergalaxy has joined #ruby
stephenjudkins has joined #ruby
krusty_ar has joined #ruby
lkba has joined #ruby
Banistertab has joined #ruby
yoklov has joined #ruby
jhowarth has joined #ruby
keymone_ has joined #ruby
rpgsimmaster has joined #ruby
josefig has joined #ruby
andrewhl has joined #ruby
mcwise has joined #ruby
charlenopires has joined #ruby
io_syl has joined #ruby
mdw has joined #ruby
crodas has joined #ruby
liluo has joined #ruby
bawerd has joined #ruby
lgbr has joined #ruby
<lgbr> path = !!path.match(%r{^/}) ? path : "/#{path}" <-- is there any reason for !! here?
steg132 has joined #ruby
<Banistertab> Igbr casts to bool
<lgbr> sure, but the ? operator doesn't require bool, right?
<canton7> just someone's habit when working with booles I guess
<canton7> *bools
robdodson has joined #ruby
charlenopires has joined #ruby
cinaski has joined #ruby
blueadept` has joined #ruby
kpshek has joined #ruby
<Sou|cutter> I'm trying to override an instance method with metaprogramming and failing.. I threw together a test case where I'd want the code in the module to be executed, but it isn't: https://gist.github.com/2314814
<Sou|cutter> note this is a contrived example, but I hope it shows what I want to do...
<shadoi> thank god, they seem to have somewhat unfucked ruby in ubuntu 12.04
atmosx_ has joined #ruby
Shagane has joined #ruby
<Veejay> Interesting article about what you're trying to achieve
<Veejay> Good read
Beoran_ has joined #ruby
netsmith2012 has joined #ruby
netsmith2012 has quit [#ruby]
levity_island has joined #ruby
nari has joined #ruby
tobym has joined #ruby
<Veejay> Sou|cutter: Why are you using super by the way?
g0bl1n has joined #ruby
<Sou|cutter> Veejay: this is an example.. I want to override a method with a method that refers back to the overridden method
Akuma0n3 has joined #ruby
iamjarvo has joined #ruby
poorlilrichboy has joined #ruby
<Sou|cutter> I'm not sure changing my code to omit the included will fix the problem.. trying, though
<Akuma0n3> hello, I,m having a really hard time installing mechanize on rub through the gems interface. I installed libxml2-devel and libxslt-devel, yet I keep getting am error message: checking for xsltParseStlesheetDoc() in -lxslt... no
<Sou|cutter> Veejay: it does not change the behavior
<Sou|cutter> module methods seem to override other module methods, but not methods defined in the class
<Sou|cutter> Veejay: https://gist.github.com/2314814 <-- is this what you had in mind?
Banistergalaxy has joined #ruby
blooberr has joined #ruby
<blooberr> anyone having trouble executing 'rvm install 1.9.3'?
<Sou|cutter> https://gist.github.com/2314814/2a983334df1d859fd95f137b26d32f788235c305 shows that overriding module methods work
<Sou|cutter> but as soon as you add a method defined in the class it doesn't work: https://gist.github.com/2314814/f3c084fbd4033aa530e37f1655149fc29b8af2e9
h4mz1d has joined #ruby
samgranieri has joined #ruby
nadirvardar has joined #ruby
shadoi has joined #ruby
mickn has joined #ruby
j3r0m3 has joined #ruby
eywu1 has joined #ruby
cobragoat_ has joined #ruby
<Sou|cutter> if I do a class_eval I lose access to any super method
<shevy> ewwwww
<shevy> eval
ZachBeta has joined #ruby
j3r0m3 has joined #ruby
cobragoat_ has joined #ruby
species has joined #ruby
<Sou|cutter> Oh, I know. I was trying to avoid doing any of that
<species> what would be a good program to write in ruby, to learn the language?
<species> ive been following some rails tutorials, but its clear my lack of ruby knowledge is a problem
<Sou|cutter> I am pretty sure there's a way to do it with alias_method_chain but I was not wanting to depend on ActiveSupport
<species> some things just look like magic
<species> for example, sometimes the files generated by various rails utils look slightly different and im not sure what the difference means (or how to work around it)
gen0cide_ has joined #ruby
<Sou|cutter> as far as I can tell this is something you just can't do in ruby. you'd either have to do an alias_method_chain sort of thing or use actual class inheritance
<Sou|cutter> but modifying an existing class to override a method and still have access to the overwritten method.. this you cannot do
<downtown> species: I find the pragprog stuff to be useful
<Sou|cutter> I'm just not sure I understand why you can do it if the method is mixed in from another module
artm has joined #ruby
<downtown> species: then again, I tend to prefer books
<species> ive long been fascinated by the idea of ruby as a game scripting language
mickn` has joined #ruby
netrealm has joined #ruby
igotnolegs has joined #ruby
katya^ has joined #ruby
fixl has joined #ruby
<Boohbah> species: http://www.rubyquiz.com/
<Boohbah> species: http://rubykoans.com/
<species> Boohbah: ive heard of the koans before actually
<species> yeah ill follow these, thanks
andrewhl has joined #ruby