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
dbgster has joined #ruby
neurodrone has joined #ruby
liluo has joined #ruby
thisisme11 has joined #ruby
<thisisme11> ...
luckyruby has joined #ruby
vanmik has joined #ruby
ByteCrunch has joined #ruby
Paradox2000 has joined #ruby
evilgeenius has joined #ruby
<evilgeenius> Is there an accessor class function, such as attr_accessor, that can create a variable that can only be accessed from within the object?
<fowl> attr_accessor :x ; private :x, :x=
<fowl> you could write a method to do that and call it i_love_fowl
<dbgster> when you have 2 models that have has_and_belongs_to_many (both referencing each other), this means you can add to either models proxy class?
<evilgeenius> or :fowl_is_stalking_me_please_help
<fowl> ;)
Bardosity has joined #ruby
<fowl> dbgster: models and proxies are the worry of the proletariat. #rubyonrails
<dbgster> fowl: ?
<fowl> /join
<shevy> dbgster he says that the channel here is about ruby, not a specific framework like yuor question.
plato has joined #ruby
plato has joined #ruby
Rishi_ has joined #ruby
burns180 has joined #ruby
Eiam has joined #ruby
sbanwart has joined #ruby
kevinbond has joined #ruby
pu22l3r has joined #ruby
<evilgeenius> fowl: What's the best way of doing that? or just using instance variables?
<evilgeenius> scrap the "or"
<fowl> evilgeenius: I have a small test for you to pass first. class Person; attr_writer :name; private :name=; end how would you call the name= method?
<evilgeenius> fowl: self.name =
<shevy> how would that even work man
ScottNYC has joined #ruby
Sailias has joined #ruby
Zolrath has joined #ruby
<evilgeenius> shevy: ?
<shevy> evilgeenius go show code that works
<shevy> "self.name =" does not work
banisterfiend has joined #ruby
<evilgeenius> shevy: it does if there is a attr_writer
<shevy> did you test it at all?
<evilgeenius> shevy: yes, just now.
<shevy> k could you show me your code please?
<evilgeenius> it worked fine
<evilgeenius> run this : class Person; attr_writer :name; private :name=; def hi ; self.name="shit" ; end ; end ; p = Person.new ; p.hi
<banisterfiend> shevy: hey shevegen
<banisterfiend> evilgeenius: Yeah self.name= works even if it's private
<banisterfiend> evilgeenius: it's an exceptino to the rule
<banisterfiend> exception
<evilgeenius> banisterfiend: It doesn't matter if it's private because I'm using it inside the object.
<banisterfiend> evilgeenius: it does matter because you're accessing it through an explicit receiver
waxjar has joined #ruby
mickn has joined #ruby
<banisterfiend> evilgeenius: the access rules apply to explicit receivers :)
<banisterfiend> evilgeenius: try this: class Hello; attr_reader :name; private :name; def hi; self.name; end; end; Hello.new.hi
thone_ has joined #ruby
<banisterfiend> [1] (pry) main: 0> class Hello; attr_reader :name; private :name; def hi; self.name; end; end; Hello.new.hi
<banisterfiend> NoMethodError: private method `name' called for #<Hello:0x0000010105f8a0>
<evilgeenius> banisterfiend: that's unexpected.
<banisterfiend> evilgeenius: no, it's expected when you understand that the access rules apply to explicit/implicit receivers
sedai has joined #ruby
<banisterfiend> evilgeenius: anyway what was your question
<evilgeenius> banisterfiend: Being able to access a method only from the outside is unusual.
rkinyon has joined #ruby
<fowl> sorry i stepped away
<evilgeenius> banisterfiend: it doesn't seem to go along with OO ideas
<banisterfiend> fowl: smoking to keep thin?
<banisterfiend> evilgeenius: what was your question anyway?
lkba has joined #ruby
nesoi has joined #ruby
<banisterfiend> evilgeenius: ping
<evilgeenius> banisterfiend: Whats the best way to access an instance variable from within a class that you don't want to be pubkic.
<evilgeenius> Just use @? or just create private accessors?
<banisterfiend> evilgeenius: it depends, do you always want just direct access to the ivar? or might you want more sophisticated access in the future?
<banisterfiend> evilgeenius: if all you want is direct access then use the @ivar
looopy has joined #ruby
zandt has joined #ruby
<banisterfiend> evilgeenius: but the advantage in using a method instead is that if you later choose to extract another class out of your current one, it's trivial to make that accessor method delegate to the other class instance instead of the ivar in your class
<evilgeenius> yes good point
cameron_ has joined #ruby
<nesoi> hello, I have something like: start_time = Time.utc(2003); puts start_time; That prints out the date as expected. Then I have a database column called last_order_entered defined as type datetime. If I do Last_orders.create(:last_order_entered => start_time) and then retrieve it with start_time = Last_orders.first (there's only one record), and do puts start_time, I get #<Last_orders:0x1da02d0>. What am I doing wrong?
<evilgeenius> banisterfiend: so is it best to use attr_accessor :x and private :x, :x= or create the methods manually? whats normal?
<banisterfiend> evilgeenius: either is fine, they're equivalent actually. However, many people dont even bother to make things 'private' :)
<nesoi> any hints?
pu22l3r has joined #ruby
<evilgeenius> nesoi: do puts start_time.last_order_entered
<evilgeenius> nesoi: start_time is a Last object, so you need to call the last_order_entered method on it
[[thufir]] has joined #ruby
<evilgeenius> nesoi: sorry, start_time is a Last_orders object.
ed_hz_ has joined #ruby
nikhil_ has joined #ruby
<evilgeenius> nesoi: sorted it?
<nesoi> evilgeenius : thanks, that worked!
Drewch has joined #ruby
<nesoi> evilgeenius : so my next question is, any idea how to create a datetime in this format? 2009-04-01T23:48:34.000Z
<evilgeenius> nesoi: if you're using rails with ActiveRecord then it's quite strange that you have a Last_orders object.
mickn has joined #ruby
<evilgeenius> nesoi: you want to output to the screen in that format?
<nesoi> evilgeenius: I'm processing input data and want to be able to resume from where I let off
cameron_ has joined #ruby
<nesoi> no, that's how the data comes to me, so I need to either convert the Time.utc to that format, or convert that to Time
<nesoi> or can I do a string compare on dates in that format?
<evilgeenius> nesoi: You can use the strftime Time function to convert a Time to that output format. http://www.ruby-doc.org/core-1.9.3/Time.html#method-i-strftime
banister_ has joined #ruby
<evilgeenius> nesoi: You could try using the Time.parse("2009-04-01T23:48:34.000Z") method to try converting the string into a Time object. Time.parse is in rails. Are you using rails?
<nesoi> no, but I could include that if I know what to require
<nesoi> or I could just store the string as a string and compare strings
<nesoi> could I compare them as strings? they should stort so that the later date is always greater no?
banister_ has joined #ruby
<evilgeenius> nesoi: that method is in the activesupport gem
<nesoi> oh I included that
<nesoi> that worked!
cameron_ has joined #ruby
pu22l3r has joined #ruby
<evilgeenius> an alternative is to use regular expressions to extract the bits you need from the string and then pass it into Time.mktime(year, month, day, hour, minutes)
<evilgeenius> nesoi: Time.parse can give you unexpected results though. You should test it in edge cases if you're gona use it.
Abhinav1 has joined #ruby
magic_hat has joined #ruby
<evilgeenius> nesoi: check that it's getting the month and days field the right way round
<nesoi> it is ATM... what if it wasn't?
Teddy2steper has joined #ruby
<magic_hat> Hi all. Can anyone think of how to write a regex that identifies a target phrase only if it's not enclosed by an anchor tag? this is killin' me!
Abhinav1 has joined #ruby
<evilgeenius> nesoi: then don't use it
<nesoi> :)
<evilgeenius> nesoi: I use regular expressions to extract fields from the time string. e.g. "2009-04-01T23:48:34.000Z".match(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/)
<nesoi> yeah, I have to learn regex. I never really got it
<evilgeenius> run this : match = "2009-04-01T23:48:34.000Z".match(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/) ; p match[1], match[2], match[3], match[4], match[5]
PragCypher has joined #ruby
<evilgeenius> nesoi: it's definately worth investing some time to learn them
Paradox2000 has joined #ruby
<nesoi> yeah, I know... but I'm trying to learn a bit of ruby first... :)
CheeToS has joined #ruby
<nesoi> nice
waxjar has joined #ruby
<evilgeenius> nesoi: One key to appearing a better programmer than you really are is to know your libraries. Or even better, know how to find decent libraries. I always look here to find the best tools : https://www.ruby-toolbox.com/
Paradox2000 has joined #ruby
nari has joined #ruby
S2kx has joined #ruby
nikhgupta1 has joined #ruby
jhowarth has joined #ruby
dbgster has joined #ruby
BHensley has joined #ruby
h4mz1d has joined #ruby
nesoi has joined #ruby
dv310p3r has joined #ruby
CannedCorn has joined #ruby
shtirlic_ has joined #ruby
davidcelis has joined #ruby
albemuth has joined #ruby
mikepack has joined #ruby
wyhaines has joined #ruby
marknyc has joined #ruby
pastjean has joined #ruby
TESTKEYz has joined #ruby
pastjean has joined #ruby
adeponte has joined #ruby
liluo has joined #ruby
td123 has joined #ruby
thisisme12 has joined #ruby
mikeric has joined #ruby
andrewhl has joined #ruby
looopy has joined #ruby
banisterfiend has joined #ruby
pac1 has joined #ruby
theRoUS has joined #ruby
machine2 has joined #ruby
luxurymode has joined #ruby
raluxgaza has joined #ruby
FACEFOX has joined #ruby
looopy has joined #ruby
sedai has joined #ruby
shtirli__ has joined #ruby
CannedCorn has joined #ruby
williamcotton has joined #ruby
TESTKEYz has joined #ruby
<arphen> anyone good with webdev?
<arphen> i'm having an issue with my own code and i'm too stupid to find it on google:
<arphen> does the occurence of "$(this).serialize();" imply that i'm using jquery code?
looopy has joined #ruby
shtirlic has joined #ruby
<evilgeenius> arphen: Check http://lmgtfy.com/?q=Web+dav
<evilgeenius> Whats the best way to check if the class of an object has included a specific module?
shtirlic has joined #ruby
<evilgeenius> e.g. similar to : car.is_a? FourWheeler , but not quite..
<evilgeenius> Update... is_a? works fine
<banisterfiend> evilgeenius: yeah
<evilgeenius> arphen: yes
lukeholder has joined #ruby
<lukeholder> Anyone have a good resource on packaging a ruby app in a java stack?
luisfelipea has joined #ruby
luisfelipea has quit [#ruby]
luisfelipea has joined #ruby
felipe_s has joined #ruby
h4mz1d has joined #ruby
<evilgeenius> lukeholder: You know abuot jruby right?
<evilgeenius> about
<lukeholder> evilgeenius: Yes. Im looking for packaging it into a war or something
libertyprime has joined #ruby
<evilgeenius> i was about to suggest warbler
senthil has joined #ruby
<evilgeenius> There is also a glassfish gem that you might find useful
adamkittelson has joined #ruby
<lukeholder> What's the diff?
<evilgeenius> lukeholder: I can't remember
zandt has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
simpleharmonicmo has joined #ruby
<evilgeenius> lukeholder: They are distinct in the way they work though
<lukeholder> Ok
adamkitt_ has joined #ruby
ghosTM55 has joined #ruby
<arphen> evilgeenius, thing is i am not including jquery... is there any other context $(this).serialize() could work?
<evilgeenius> arphen: ask in the #jquery irc room
<arphen> also: do you feel cool using "lmgtf
<evilgeenius> arphen: no, i regretted it instantly
<arphen> you might as well have said nothing thank you
<evilgeenius> arphen: do you feel cool telling us you are too lazy to search google?
c0rn has joined #ruby
yoklov has joined #ruby
<arphen> evilgeenius, i said i am too stupid to formulate a question
<arphen> how the hell do you google for "$(this)" without a billion irrelevant results
kevinbond has joined #ruby
<banisterfiend> evilgeenius: how come a genius cant spell 'genius' correctly
<banisterfiend> or are you an iconoclastic genius and play by your own rules? :P
lukeholder has joined #ruby
<evilgeenius> banisterfiend: You don't need rules where im going, and am.
jwang has joined #ruby
havenn has joined #ruby
<banisterfiend> evilgeenius: mexico?
apucacao has joined #ruby
h4mz1d has joined #ruby
chimkan has joined #ruby
<evilgeenius> banisterfiend: le'ts just say... I am the moon.
<evilgeenius> *let's
<banisterfiend> ah right
<banisterfiend> mental asylum ;)
<evilgeenius> Is it ok for a private method to call a public method?
<banisterfiend> evilgeenius: Yeah
banisterfiend has joined #ruby
whh has joined #ruby
drake10 has joined #ruby
gen0cide_ has joined #ruby
zandt has joined #ruby
yoklov has joined #ruby
krz has joined #ruby
CannedCorn has joined #ruby
_ack has joined #ruby
<_ack> Hello. sending mails using gmail's smtp servers can be done on ruby 1.9.3?
robbyoconnor has joined #ruby
SegFaultAX has joined #ruby
<td123> smtp is a protocol independent of any language
banisterfiend has joined #ruby
lukeholder has joined #ruby
jphpsf has joined #ruby
Fezzler has joined #ruby
adeponte has joined #ruby
<_ack> td123, I know. The thing is ruby is throwing some errors with I try to send mails with Net::SMTP, complaining about STARTTLS. But when I do .enable_starttls It segfault.
<_ack> when*
gabeh has joined #ruby
<td123> it segfaults? you need to file a bug
<_ack> yes. I will do that
Sailias has joined #ruby
<banisterfiend> _ack: run it in gdb to find the place it's segfaulting
andrewhl has joined #ruby
csprite has joined #ruby
banisterfiend has joined #ruby
csprite has joined #ruby
froy has joined #ruby
csprite has joined #ruby
seanstickle has joined #ruby
caiges has joined #ruby
mikeric has joined #ruby
csprite has joined #ruby
Azure has joined #ruby
td123 has joined #ruby
radic_ has joined #ruby
yoklov has joined #ruby
<senthil> I'm getting TypeError:nil is not a symbol, no clue why https://gist.github.com/2144058
Abhinav1 has joined #ruby
<senthil> I don't think its rspec syntax, have used expect before with no error
ghosTM55 has joined #ruby
<maahes> I'm using rvm, and I'd like to not have to add each gem I use individually to my rc, for each different version of ruby. Is there a catchall command I can use?
wilmoore has joined #ruby
<senthil> Its not what's inside expect block either, same error for diff. body also
ghosTM55 has joined #ruby
<maahes> also, how do I add my system ruby into rvm as it's default? So I can switch back to it.
<senthil> rvm use system --default
ringotwo has joined #ruby
burns180_ has joined #ruby
burns180 has joined #ruby
Apocalypse has joined #ruby
khannz has joined #ruby
burns180_ has joined #ruby
_|christian|_ has joined #ruby
kstephens has joined #ruby
stephenjudkins has joined #ruby
NotreDev has joined #ruby
burns180 has joined #ruby
<NotreDev> is there a flag i can set to not return the result of my most recent command on irb? it's about to return a hell of a lot of data
Drewch has joined #ruby
wenbert has joined #ruby
DarthGandalf has joined #ruby
<banisterfiend> NotreDev: not in irb, but you can in pry
<banisterfiend> NotreDev: http://pry.github.com
<NotreDev> :(
<NotreDev> thanks
<banisterfiend> NotreDev: ok in irb you can do: expr ; nil
aantix has joined #ruby
<NotreDev> good call!
<NotreDev> cheers
<banisterfiend> np
hygsan has joined #ruby
viaov has joined #ruby
luckyruby has joined #ruby
bl3k has joined #ruby
<shevy> irb should die
<banisterfiend> shevy: you still use it chevrolet
arphen has joined #ruby
<shevy> yeah
<shevy> it comes bundled with ruby after all :)
<shevy> save for debian
froy has joined #ruby
looopy has joined #ruby
havenn has joined #ruby
<shevy> it's domination of the inferior
bl3k has joined #ruby
sedai_ has joined #ruby
jmfcool has joined #ruby
bl3k has joined #ruby
Yappo__ has joined #ruby
Abhinav1 has joined #ruby
burns180 has joined #ruby
tommyvyo has joined #ruby
cha1tanya has joined #ruby
rippa has joined #ruby
shadoi has joined #ruby
Abhinav11 has joined #ruby
Abhinav11 has joined #ruby
tommyvyo has joined #ruby
kah has joined #ruby
<kah> does anyone have some suggestions for learning regular expressions??
<seanstickle> kah: the O'Reilly book on the subect
<seanstickle> *subject
<HINS> kah: The aho and ullman book, or something like that
ghosTM55 has joined #ruby
chimkan_ has joined #ruby
<kah> ok i'll look into those
<kah> thanks
<seanstickle> The classic
<HINS> kah: You'll need to learn automatons if you really want to understand regular expressions...
<kah> also, quick question, this isn't really the place but i don't know where else to go, when i go to log into IRC it mistakes my identify for kahuna and not kah, suggestions??
<seanstickle> And if you really want to understand automatons, you'll need to understand logic
<seanstickle> So read up on Aristotle too
<kah> i can do that
<seanstickle> Or, you could just take it one step at a time
<kah> what book would outline automatons?
<seanstickle> And read the Regex book
<kah> the mastering reg ex?
<seanstickle> Yeah
<kah> i just picked up a book called reg expressions in 10 mins
<kah> ill start with that
<kah> and then hit up your book
<kah> that you suggested
<seanstickle> Sounds like a plan
<seanstickle> Also, check out #regex, where all us regex folks hang out
<kah> ah nice
<kah> i will for sure
<kah> any idea how to solve my other problem w my irc identity?
<kah> maybe i'll just create a new one..
c0rn has joined #ruby
<seanstickle> My knowledge of IRC extends to knowing how to type in stuff and hit enter
<seanstickle> You could try the #help channel
<kah> kk cool thanks
ilyam has joined #ruby
ipoval has joined #ruby
ipoval has quit [#ruby]
psylinse has joined #ruby
io_syl has joined #ruby
<maahes> to include a gem dir in my source do I just have to do something like export PATH=$PATH:$HOME/rvm/path/to/particular/ruby/gem/dir/* for all subdirs?
<maahes> er, to include all subdirs
Banistergalaxy has joined #ruby
shtirlic has joined #ruby
wedgeV has joined #ruby
seitensei has joined #ruby
<maahes> this: [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
<maahes> causes my shell to spit out: "string not in pwd: ../
sandGorgon has joined #ruby
<maahes> "
* maahes watches the crickets.
lampe2 has joined #ruby
wenbert_ has joined #ruby
<lampe2> hey i generated a gem with bundler and now i wanne test the script how i do it?
<sandGorgon> lampe2: set your GEM_PATH and GEM_HOME to the path of the local gem and you can use your scripts
bier has joined #ruby
kah1 has joined #ruby
kah has joined #ruby
kah_ has joined #ruby
maletor has joined #ruby
khannz has joined #ruby
artm has joined #ruby
c0rn has joined #ruby
ipoval has joined #ruby
khannz has quit [#ruby]
ben225 has joined #ruby
ipoval has quit [#ruby]
wenbert_ has joined #ruby
Karmaon has joined #ruby
MrGando has joined #ruby
wolflee has joined #ruby
burns180 has joined #ruby
advorak has joined #ruby
greenarrow has joined #ruby
nfluxx has joined #ruby
Guest53287 has joined #ruby
a_a_g has joined #ruby
cameron_ has joined #ruby
bounce has joined #ruby
robacarp_ has joined #ruby
wolflee has quit [#ruby]
JohnBat26 has joined #ruby
nikhil_ has joined #ruby
DiseaseHF has joined #ruby
DiseaseHF has quit [#ruby]
Morkel has joined #ruby
x0F_ has joined #ruby
wilmoore has joined #ruby
Eric_HOU has joined #ruby
banisterfiend has joined #ruby
TESTKEYz has joined #ruby
cameron_ has joined #ruby
Divinite has joined #ruby
MrGando has joined #ruby
nemesit has joined #ruby
moshee has joined #ruby
nemesit|osx has joined #ruby
yxhuvud has joined #ruby
nikhil___ has joined #ruby
lan has joined #ruby
wedgeV has joined #ruby
CheeToS has joined #ruby
mdw has joined #ruby
aknewhope has joined #ruby
lan has quit ["Leaving"]
hooper has joined #ruby
wedgeV has joined #ruby
mneorr has joined #ruby
maletor has joined #ruby
zakwilson has joined #ruby
jmfcool has joined #ruby
zakwilson has joined #ruby
Banistergalaxy has joined #ruby
Banistergalaxy has joined #ruby
regedarek has joined #ruby
Indian has joined #ruby
kremiak has joined #ruby
looopy has joined #ruby
banisterfiend has joined #ruby
senthil has joined #ruby
shruggar has joined #ruby
zommi has joined #ruby
dzhulk has joined #ruby
ph^ has joined #ruby
danishkhan has joined #ruby
n1x has joined #ruby
nikhgupta has joined #ruby
cha1tanya has joined #ruby
ephemerian has joined #ruby
artm has joined #ruby
jrwesolo has joined #ruby
sleetdrop has joined #ruby
luoluoluo has joined #ruby
dekroning has joined #ruby
cHarNe2 has quit [#ruby]
shruggar has joined #ruby
pi3r has joined #ruby
LMolr has joined #ruby
simao has joined #ruby
shruggar has joined #ruby
headius has joined #ruby
jrwesolo has joined #ruby
jrwesolo has quit [#ruby]
lobolars has joined #ruby
mafolz has joined #ruby
trivol has joined #ruby
johndbritton has joined #ruby
giurik has joined #ruby
<giurik> CiaO a TuTtO iL CHaN......... AVE Lux. 666
<giurik> ciao
<giurik> !list
blacktulip has joined #ruby
ukwiz has joined #ruby
francisfish has joined #ruby
schaerli has joined #ruby
mfridh has joined #ruby
acd has joined #ruby
<acd> /mames
<acd> /names
wookiehangover has joined #ruby
pithagora has quit [#ruby]
mdw has joined #ruby
BiHi has joined #ruby
simao has joined #ruby
Divinite has joined #ruby
<acd> /names
elhu has joined #ruby
cha1tanya has joined #ruby
d3vic3 has joined #ruby
karbonick has joined #ruby
pp01bit has joined #ruby
banisterfiend has joined #ruby
TaTonka has joined #ruby
workmad3 has joined #ruby
apeiros_ has joined #ruby
raluxgaza has joined #ruby
nemesit has joined #ruby
maasha has joined #ruby
nikhgupta1 has joined #ruby
batmanian has joined #ruby
<maasha> Hello. I am playing with RubyInline. How can I raise my own errors and not ruby's? -> rb_raise(rb_eRuntimeError, "row out of range: %d >= %d\\n", row, rows);
nesoi has joined #ruby
iocor has joined #ruby
<nesoi> so if I have a hash where I need to sort at the 2nd level, what's the correct way? It's like response.orders and I want to sort each order by one of the many keys at that level. I tried response.orders.sort_by{ |orders| orders[:purchase_date] }; it doesn't complain but it also doesn't work
<apeiros_> nesoi: you know that sort_by does not do in-place sorting, but returns a new array, which is sorted?
<apeiros_> i.e., you must assign the result and use that
<maasha> sort_by!
<elhu> use sort_by! if you want to sort in place
<banisterfiend> maasha: get the constant
regedarek has joined #ruby
<fowl> nesoi: hash.sort_by { |key, value| value[:purchase_data] } the
karbonick has quit [#ruby]
<elhu> nesoi: as a general rule, methods aren't' performed in place but return a new instance, and methods finishing by ! are 'destructive', since they change the object the method is called on
<fowl> if it is |orders| I think they get sent as [key, value] so you'd use orders[1][:key]
<fowl> (i think)
<nesoi> elhu : so I need to do response.orders = response.orders.sort_by{ |orders| orders[:purchase_date] } ? (assuming that would be the right sort)
<nesoi> fowl I don't understand the value. I want to sort each record by that key descending
<maasha> banisterfiend: something like rb_const_get(MyError, "ID")
Ammar01 has joined #ruby
banister_ has joined #ruby
<elhu> nesoi: yes, or simply response.orders.sort_by!{ |orders| orders[:purchase_date] }
<banister_> maasha: rb_raise(rb_eval_string("YourConst"), "baby")
<banister_> or rb_const_get if it's easy to access
<elhu> but, by any chance, is that an active record relationship ?
<nesoi> cool, thanks
<nesoi> no it's some structure returned by a library routine
<fowl> nesoi: {a: 10, b: 5, c: 2}.sort_by { |key, value| puts "#{key}: #{value}"; value }
<elhu> nesoi: ok, I would have told you to go check out scopes otherwise
<nesoi> fowl: there are lots of keys though, like 30
<nesoi> for each record
<maasha> banister_: I have a class MyError < StandardError; end - so I can use rb_const_get(MyError, "ID") - though I don't really know what to do with the "ID" part.
<fowl> nesoi: i'm just saying
<fowl> try that in irb, see the output
<fowl> then run {a: 10, b: 5, c: 2}.sort_by { |key| puts "#{key}"; key[1] }
visof has joined #ruby
visof has joined #ruby
d3vic3 has joined #ruby
<banister_> maasha: rb_intern("YourConst")
jonteru has joined #ruby
Shrink has joined #ruby
<nesoi> fowl : I don't understand the 1st one. what's the extra value at the end doing?
Shrink has joined #ruby
<maasha> banister_: hm, not quite there -> rb_raise(rb_intern("MyError"), "raising my own error");
<fowl> nesoi: the value is what you're sorting by, silly
<banister_> maasha: bitch
<fowl> puts returns nil, it was just there to show you how the vars come in
<banister_> maasha: just use rb_eval_string
<banister_> maasha: rb_raise(rb_eval_string("YourConst"), "blegh")
<nesoi> oic
<fowl> nesoi: the sort only cares about the return value from the block so you could have other logic in there if you want, or rand(1000) or anything really
<maasha> banister_: right. that will do nicely. ty
roolo has joined #ruby
jakebaek has joined #ruby
srnty has joined #ruby
<fowl> banister_: you ever seen someone raise an exception like `raise SomeException.new("stupid reason")`
ephemerian has joined #ruby
<banister_> fowl: better to do: SomeException.exception("stupid reason") iirc
zeninfinity has joined #ruby
TaTonka has quit [#ruby]
<fowl> why not raise SomeException, 'blah'
<banister_> fowl: that works too, but #exception works with both classes and objects and it has the advantage in copying other exceptoin attributes (if it's an instance)
<banister_> iirc
<nesoi> fowl I'm still not quite getting it. those 2 sorts you posted didn't change the order, but if I do a = {a: 10, b: 5, c: 2}; a.sort_by {|a| a[1]} it does print it out in order by increasing value
stefanp has joined #ruby
stefanp has joined #ruby
<fowl> nesoi: those two sorts i posted werent to fix your problem it was to explain how when you give th block 1 var you get [key, value] pairs ie [:a, 10], [:b, 5] which is why you use a[1] and not just a
<workmad3> fowl: I prefer hsh.sort_by {|k,v| v} personally
<fowl> workmad3: i pasted that too and he ignored it
<fowl> why try?
<workmad3> oh, didn't notice that :/
flou has joined #ruby
iocor has joined #ruby
<nesoi> hmm.. well response.orders.sort_by!{ |orders| orders[:purchase_date] } still isn't sorting it properly for some reason
regedare_ has joined #ruby
<nesoi> fowl what am I doing wrong?
fearoffish has joined #ruby
eddie has joined #ruby
DarkFoxDK has joined #ruby
jlebrech has joined #ruby
trivol has joined #ruby
tatsuya_o has joined #ruby
tvw has joined #ruby
lampe2 has joined #ruby
banisterfiend has joined #ruby
<lampe2> hey i created a gem with bundler and i added a new file into the projekt named sub folder of the lib folder. now i wanne require it into the app named rb in the lib folder but ruby says that he cant find it
<workmad3> lampe2: gist your code please
<eddie_> lampe2: did you mention the new file in gemspec ?
<lampe2> eddie_, no must i?
<eddie_> yes
<lampe2> is there a easy way or must i do it manual ?
shruggar has joined #ruby
waxjar has joined #ruby
<luoluoluo> hi there, how to print multi stars on the screen. for example: print '*' * 50 will print a line with 50 stars
<lampe2> eddie_, if got this gem.files = `git ls-files`.split($\)
<eddie_> you want to print from left to right
<eddie_> ?
<eddie_> luoluolu: you want to print from left to right?
oposomme has joined #ruby
<luoluoluo> eddie_: yes. I got it. I just made a mistake. thanks
arturaz has joined #ruby
fjfish has joined #ruby
<lampe2> luoluoluo, just say after 10 stars /n for new line
<eddie_> luoluoluo: ok
<oposomme> hi I would like to know how do I mount a volume in ruby?
<luoluoluo> lampe2: thanks. I already got it.
cbm has joined #ruby
<eddie_> lampe2: try mentioning the straight away
<eddie_> :)
<eddie_> lampe2: Your gem?
nikhgupta1 has quit [#ruby]
darthdeus has joined #ruby
<lampe2> eddie_, "gem.files = `git ls-files`.split($\)" i thought that this will add everything from the git repo what i add to git but it dont work :(
<eddie_> lampe2: "gem.files = `git ls-files`.split($\)" . You checked what it gives
<eddie_> ?
<workmad3> lampe2: can you give the require line that's failing please?
etehtsea has joined #ruby
<lampe2> workmad3, require "lommongo/mdbConnect"
<lampe2> eddie_, this gives me all files what i added with "git add ."
<lampe2> okay i got it now it works :)
<eddie_> luoluoluo: was this your solution? http://pastie.org/private/p05tyaqdetqk2gxwqnpyag
<eddie_> lampe2: What was wrong?
fuffi has joined #ruby
<lampe2> eddie_, i need to reinstall the gem properly on my locale maschine
etehtsea has joined #ruby
<eddie_> ok
<eddie_> i will tell you the steps
KL-7 has joined #ruby
banisterfiend has joined #ruby
<banisterfiend> k
<eddie_> lampe2: First make your final gem version
<Divinite> Sigh... Why is my Ruby using the wrong encoding?
<Divinite> It's using UTF-8
<eddie_> lampe2: after step 4 your gem will be insdtalled properly
<lampe2> thx eddie_
<eddie_> Divinite: UTF-8 must be the default one
<Divinite> But it says all my .gemspec's contain invalid characters...
<Divinite> Why?
<luoluoluo> eddie_: thanks. not what I want. I just want what "p '*' * 50" does.... I made a stupid mistake myself and figure it out right after I post the problem here.... Thanks for your kindness :D
regedarek has joined #ruby
<eddie_> Divinite: gist of your gemspec
adman65 has joined #ruby
<eddie_> lampe2: would like to see your gem. at rubygems.org
<Divinite> eddie_: Can't, I'm on iOS.
Shrink has joined #ruby
Shrink has joined #ruby
mklepsch has joined #ruby
mklappstuhl has joined #ruby
railsbros_dirk has joined #ruby
<eddie_> Divinite: Does your spec look like this. It should. http://pastie.org/private/sfmid0vbuymnqul9emu2a
<Divinite> Something like that eddie_ ..
<eddie_> Divinite: Your ruby version?
<Divinite> 1.9.3
<Divinite> Unknown with -p
<eddie_> Divinite: Mine is the same i have no issues yet
jenglish has joined #ruby
<lampe2> eddie_, one day it will be up there but not today i just started the development. this will be a implementation of the LOM standard from the IEEE to save the meta data in a mongodb :)
Prezioso has joined #ruby
knirhs has joined #ruby
waxjar has joined #ruby
drewmacq has joined #ruby
<artm> anyone familiar with guard? is there some best practice for combining multiple change events into one? like when I "Save All" in the editor, I'd like make to be called only once
sgupta has joined #ruby
Richmond has joined #ruby
drewmacq has quit [#ruby]
_class_ has joined #ruby
raluxgaza has joined #ruby
<maasha> how are ruby arrays implemented? C arrays or list of lists sturcture?
<banisterfiend> maasha: C arrays
<maasha> banisterfiend: nice.
<eddie_> lampe2: great. Share your github if you dont mind
<Divinite> *sigh* Why is ruby so hard on iOS?
nikhil_ has joined #ruby
gavinmcnair has joined #ruby
araujo has joined #ruby
Foxandxss has joined #ruby
MrGando has joined #ruby
aibo has joined #ruby
frontendloader has joined #ruby
eldariof has joined #ruby
<shevy> wat
<shevy> not harder than ur mom
Rishi_ has joined #ruby
<Divinite> shevy: Was that necessary?
<shevy> for iOS sure
<banisterfiend> Divinite: was it necessary to call him up on it? #ruby is not a nun's convent
<Divinite> I know, but there was no need.
<Divinite> "Ur mum" jokes only work when it's funny banisterfiend. Otherwise its just rubbish.
<Mon_Ouie> jokes only work when it's funny too
fmcgeough has joined #ruby
<banisterfiend> Divinite: it was harmless all the same
<Mon_Ouie> shevy: They changed their rules since then
<banisterfiend> Divinite: he's not obliged to be funny, and he wasn't offensive, he was just silly at best. No reason to call him up on it
<Divinite> I know, I know.
<Divinite> I wasn't biting, just wondering.
<Divinite> shevy: I'm jailbroken.
<shevy> hmm
<dominikh> all he contributes are bad and repeated urmom jokes and useless comments, so yeah, it starts to be pretty offensive
<shevy> "The Agreement about Apple not accepting any coding language layer has been removed not too long ago. I guess we will have to wait a little to see complex language like Python and Ruby interpreter. Since LUA is a scripting language, it is easier to port it."
<shevy> dominikh I like Divinite and his mom is actually nice, but you suck
<banisterfiend> dominikh: he's our poppavic ;)
<shevy> dominikh I wonder why you are obsessed with me though :>
<Divinite> I have Ruby, Python, Perl, Lua...
<Divinite> shevy: I'm a she, not a he.
<Divinite> Or a shehe.
<shevy> awww ok then indeed my joke was bad :(
<shevy> sorry
<Divinite> Don't worry shevy, I get that all the time on irc!
fuffi has joined #ruby
dbgster has joined #ruby
Indian has joined #ruby
FND has joined #ruby
r3dskade has joined #ruby
francisfish has joined #ruby
zeninfinity has joined #ruby
gianlucadv has joined #ruby
nikhgupta has joined #ruby
FND has quit [#ruby]
berserkr has joined #ruby
tk_ has joined #ruby
Prezioso has joined #ruby
sgupta has joined #ruby
catphish has joined #ruby
bl3k has joined #ruby
<catphish> what's the class that makes a simple enum from a block?
banisterfiend has joined #ruby
batmanian has joined #ruby
<Divinite> No idea.
schaerli has joined #ruby
<artm> "scripting language" vs what?
DMKE has joined #ruby
<Divinite> Nothing.
<Divinite> Binary.
<catphish> ah - Enumerator.new
<Divinite> catphish: What?
<catphish> it makes an enum instance from a block
falena has joined #ruby
<catphish> eg: enum = Enumerator.new(&block); enum.each do |b|
etehtsea has joined #ruby
<banisterfiend> catphish: why do u want to do that, out of interest
<catphish> i can't remember now
<catphish> i did it ages ago
<banisterfiend> catphish: Enumerator.new is normally used for creating generators
<banisterfiend> so it's a bit weird to see you iterate over it with #each IMO
Maxou56800 has joined #ruby
scalebyte has joined #ruby
KL-7_ has joined #ruby
MrGando has joined #ruby
<scalebyte> I have a serialized ruby hash which has array of hashes inside. I want to sanitize the values of these hashes.. any possible solutions ?
raluxgaza has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
<catphish> banisterfiend: my use case is hard to explain, basically i have a method that iterates over incoming data live, so it needs to be passed what looks like a generator so that code can be processed as it arrives
sandstrom has joined #ruby
<catphish> so my method calls .each, then the caller pushes data into it progressively
nikhil_ has joined #ruby
<banisterfiend> catphish: ah ok
mcwise has joined #ruby
mengu has joined #ruby
Helius has joined #ruby
`brendan has joined #ruby
<`brendan> morning folks
<artm> good midday
sacarlson has joined #ruby
<artm> internet English should evolve some longitude-agnostic greetings
tatsuya_o has joined #ruby
tatsuya_o has joined #ruby
headius has joined #ruby
<workmad3> artm: you mean like 'hello' or 'hi'? :)
becom33 has joined #ruby
bl3k_ has joined #ruby
<becom33> http://pastebin.com/R9n2zZJr why Base.name("para") doesn't work >
<becom33> ?
<artm> workmad3: yes, but starting with good
<artm> becom33: Base.name = "para"
ryannielson has joined #ruby
<artm> no, without Base
<artm> it's an instance method
<artm> ^ becom33
<becom33> why attr_reader insted of attr_accessor ?
<artm> why accessor if you declare the writer manually?
<Mon_Ouie> name = "foo" does not do what you think
<Mon_Ouie> It always sets a local variable name to "foo"
<Mon_Ouie> You need an explicit receiver if you want to call the method
<artm> Mon_Ouie: id does what becom33 programmed it to do
<Mon_Ouie> No, it does not call the Base#name= method
<Mon_Ouie> self.name = "foo" does
<Mon_Ouie> Otherwise it'd be impossible to create local variables at all
raluxgaza has joined #ruby
<becom33> btw what I just wanna call a varibale which is in a another class ?
<artm> that's right
<artm> this one works
<Mon_Ouie> Instance variables don't depend on the class, they only depend on self
bluenemo has joined #ruby
martman has joined #ruby
nikhil_ has joined #ruby
radic has joined #ruby
pu22l3r has joined #ruby
LMolr has joined #ruby
iamjarvo has joined #ruby
iocor has joined #ruby
Beakr has joined #ruby
visof has joined #ruby
senthil has joined #ruby
Sailias has joined #ruby
jimmyy111 has joined #ruby
yoklov has joined #ruby
nanderoo has joined #ruby
<roolo> Does anybody have simple, no in-script solution for making https requests on 1.9.2 ?
<roolo> (homebrew as packaging system)
mklappst_ has joined #ruby
nanderoo has joined #ruby
<Mon_Ouie> Just Net::HTTP? (I'm not sure what you mean by "no in-script solution")
tatsuya_o has joined #ruby
bl3k has joined #ruby
<roolo> Everytime i make https request i get SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
pu22l3r has joined #ruby
<roolo> I discovered it's some issue with how ruby is finding certificates, but all tutorials i found presume macports
<roolo> or recommend turning certificate verification off
iocor has joined #ruby
HINS has quit [#ruby]
luoluoluo has joined #ruby
<Mon_Ouie> Doesn't that defeat the point of using SSL?
<senthil> roolo: Hitting Facebook Api by any chance?
<roolo> Mon_Ouie: Yes ;)
gyre007 has joined #ruby
tbrock has joined #ruby
<roolo> senthil: You mean if i am trying Facebook API?
<senthil> roolo: yes
<senthil> roolo: I run into SSL errors all the time with Fb
bl3k_ has joined #ruby
<roolo> senthil: No, but you were close ;) I am trying Google Calendar api — https://developers.google.com/google-apps/calendar/setup
tommyvyo has joined #ruby
simpleharmonicmo has joined #ruby
<roolo> senthil: How did you solve that? Maybe the solution is similar
pzol has joined #ruby
<senthil> roolo: For Fb I think it was the 'www' endpoint causing the trouble
TaTonka has joined #ruby
<senthil> roolo: just a week back I was thinking about writing a wrapper for gcal
drake10 has joined #ruby
nikhgupta has joined #ruby
schovi has joined #ruby
ap0gee has joined #ruby
crankycoder has joined #ruby
rTypo has joined #ruby
BiHi has joined #ruby
lorandi has joined #ruby
KL-7 has joined #ruby
Drewch has joined #ruby
Progster has joined #ruby
moshee has joined #ruby
moshee has joined #ruby
bl3k has joined #ruby
evilgeenius has joined #ruby
kf8a has joined #ruby
ph^ has joined #ruby
geekbri has joined #ruby
bl3k_ has joined #ruby
ipoval has joined #ruby
ipoval has quit [#ruby]
fermion has joined #ruby
td123 has joined #ruby
nari has joined #ruby
robkinyon has quit [#ruby]
jonteru has joined #ruby
iocor has joined #ruby
Abhinav1 has joined #ruby
bl3k has joined #ruby
robkinyon has joined #ruby
Abhinav1 has joined #ruby
roolo has joined #ruby
dv310p3r has joined #ruby
dql has joined #ruby
fr0gprince_mac has joined #ruby
bluenemo has joined #ruby
headius has joined #ruby
astrostl has joined #ruby
<astrostl> non-ruby/rails dev debugging a rails setup. if i strace a Rack process (passenger) and it's returning literally nothing while chewing up cpu resources, is it dead? is this a common thing? (xpost from #rubyonrails, don't know if this is straight ruby-related or not)
sbanwart has joined #ruby
jgarvey has joined #ruby
Sailias has joined #ruby
kidoz has joined #ruby
bglusman has joined #ruby
dql has joined #ruby
IrishGringo has joined #ruby
zeninfinity has joined #ruby
bluenemo_ has joined #ruby
cpruitt has joined #ruby
bbttxu has joined #ruby
bluenemo__ has joined #ruby
mdiedric has joined #ruby
jenglish has joined #ruby
bl3k_ has joined #ruby
a_a_g has quit [#ruby]
LBRapid has joined #ruby
jcromartie has joined #ruby
Jackneill has joined #ruby
chico has joined #ruby
jankud has joined #ruby
Guest53287 has joined #ruby
kpshek has joined #ruby
vandemar has joined #ruby
<jankud> Hi, I am trying to find (without any luck so far) if there is a mechanism in Ruby similar to writev() and readv() i.e. read/write from vector of buffers
y3di has joined #ruby
zaydana has joined #ruby
maasha has joined #ruby
nikhil_ has joined #ruby
<maasha> I am building a bitarray with 3 rows and 21 columns encoded in a 8 byte string. Every new row starts at every 7 bits. How to get the sum of each row using a single pass iteration of the byte string?
<y3di> I know there are multiple resources for sending email with ruby, but does anyone have a suggestion of one, that they feel is the easiest to work with
phantasm66 has joined #ruby
PragCypher has joined #ruby
carlyle has joined #ruby
<canton7> y3di, Pony is recommended, and I've personally found it works well
<robkinyon> maasha: a quick googling returns http://www.freshports.org/math/ruby-bitvector
zeninfinity has joined #ruby
senthil has quit [#ruby]
kevinbond has joined #ruby
<maasha> bitvector is 1D bitarrays. I want a 2D one... And how hard can it be! :o)
<robkinyon> a bit array is a bit vector
Aristata has joined #ruby
<robkinyon> just add the column math yourself.
<robkinyon> bitarray[x][y] === bitvector[x*row_size+y]
<maasha> robkinyon: that is sort of what I am trying to do. I am just stuck where I want to count set bits 1 byte at a time instead of 1 bit at a time.
<robkinyon> "count set bits" means what in English?
<maasha> so for all rows, how many bits are set to 1.
bonhoeffer has joined #ruby
<robkinyon> so, you have a bitvector (or bit array, whatever) and you want to know how many of the 63 bits (3 rows x 21 columns) are 1 vs. 0 ?
<bonhoeffer> in a functional language like ruby -- objects still have persistent state -- how does this reconcile?
<bonhoeffer> or is ruby a mix of imperative and functional?
<robkinyon> bonhoeffer: ruby isn't a functional language, it's an OO language
<robkinyon> functional languages are things like scala, haskell, lisp, etc
<maasha> robkinyon: for each of the 3 rows, I want to know how many bits are set.
<roolo> How clean do you think is this(for dealing with https)? http://git.io/NwwcZA
<bonhoeffer> ok -- got it -- so how should i understand: Ruby supports multiple programming paradigms, including functional, object oriented, imperative and reflective.
<robkinyon> ruby is much close to eiffel or smalltalk
astrostl has quit [#ruby]
<jcromartie> "a functional language like Ruby…" O_o
<robkinyon> bonhoeffer: because it does?
<bonhoeffer> so ruby can do a functional paradigm -- but you are really working objects
<jcromartie> I mean sure, as long as the only criteria is the ability to pass a closure
<jcromartie> mutability is every-frickin-where
<bonhoeffer> is the message receiver terminology unique to ruby?
<robkinyon> maasha: loop over the bits and count ?
<maasha> robkinyon: here is the code that does the sum of set bits for the entire bitarray: http://pastie.org/3641596
<robkinyon> bonhoeffer: Umm … no. that's standard OO terminology
<robkinyon> i believe it was coined that in the 1970's (1960's?) when Ada was created
<bonhoeffer> sorry, i'm an engineer, not a CS guy, but i'm writing the contracting request for some software
<workmad3> bonhoeffer: it's the original model for OO
<robkinyon> bonhoeffer: write requirements, not implementation details
<bonhoeffer> i code ruby by night, but i want the software to be developed to be flexible, and modular like a ruby app
<workmad3> bonhoeffer: there's also the C++/java style that I call 'method calling OO'
<robkinyon> make that a requiremen,t not the language
etehtsea has joined #ruby
<bonhoeffer> robkinyon: i'm trying to do that -- but want to understand flexibility as a requirement
<robkinyon> maasha: does that code work?
<bonhoeffer> i'm not specifying the language
<workmad3> bonhoeffer: define 'flexibility' ;)
<robkinyon> bonhoeffer: What does flexibility mean to you?
<maasha> robkinyon: it does actually
<robkinyon> maasha: so . . . why are you trying to change code that actually works?
io_syl has joined #ruby
<bonhoeffer> robkinyon: it means that we can make the code do what we want -- in this case traverse multiple scales to answer questions at various levels of fidelity
<bonhoeffer> so we have multi-million lines of code now in big models that only a few people can run -- at one scale
<robkinyon> bonhoeffer: in other words, you want the unix toolchain
<bonhoeffer> they are run by hundreds of flat-text files -- in FORTRAN, etc
<maasha> robkinyon: I can loop over one bit at a time, but that takes 8 times as long
badelat has joined #ruby
<workmad3> maasha: so the code doesn't work because it fails your performance requirements
<robkinyon> maasha: there are some things that are appropriate to write in C and other things that are appropriate to write in Ruby.
<maasha> robkinyon: ah, that code bit makes a sum of the entirve bit array. I am trying to get it per row now.
<robkinyon> maasha: bit-twiddling is appropriate to write in C
<bonhoeffer> the flexibility i want is to maybe look at a few -on - few context -- then move to global objects
KL-7 has joined #ruby
<bonhoeffer> it is desiging the application (or collection of objects) for a scientist/coder, not a mechanic
<bonhoeffer> if that makes sense
<maasha> workmad3: I want the evil speed. Not evil speed / 8 :o)
<robkinyon> bonhoeffer: "flexibility" and "global objects" are archenemies. Think Joker and the Batman
<bonhoeffer> please explain
Aristata has quit [#ruby]
<robkinyon> well, you still have defined flexibility
<robkinyon> haven't*
abstrakt has joined #ruby
<robkinyon> not in a way that's actionable
<workmad3> bonhoeffer: the larger the scope of something, the less amenable it is to change
<banisterfiend> bonhoeffer: the langage you're developing in is fortran?
<bonhoeffer> banisterfiend: trying to move away from fortran
<bonhoeffer> i'm the young guy around . . . secretly coding ruby by night
<robkinyon> bonhoeffer: you want the unix toolchain
<bonhoeffer> and now tasked with spending a million bucks to develop the future tool we should use
<robkinyon> go study why the unix toolchain is so successful and you will understand what flexibility means
<bonhoeffer> robkinyon: any links?
<workmad3> robkinyon: a.k.a. filters and pipes :)
<banisterfiend> bonhoeffer: you should probably be using python if you're doing scientific computing
<workmad3> (that's to bonhoeffer too btw)
<bonhoeffer> you mean bash?
<robkinyon> if you're confused, go read up on Netflix and the Chaos Monkey
<banisterfiend> bonhoeffer: if u want to replace python that is
<robkinyon> bonhoeffer: no … "the unix toolchain"
<banisterfiend> replace fortran*
<bonhoeffer> i think python might have a lot to leverage, SAGE, etc
<workmad3> robkinyon: or are you meaning the tools that you tend to get in unix?
sirecote has joined #ruby
<robkinyon> bonhoeffer: i just gave you two google-able terms. Go forth and cogitate.
<robkinyon> workmad3: no. I said "the unix toolchain". it's a very specific term with a very specific meaning
* workmad3 googles
<robkinyon> "Each piece in the chain should do one thing, only one thing, and do it superlatively."
<robkinyon> "Each piece in the chain should be able to read STDIN for input and write to STDOUT for output"
<robkinyon> "Each piece must be hookable to each other piece"
<workmad3> robkinyon: ah, the filters and pipes approach, that was what I originally thought :)
<bonhoeffer> robkinyon: now i'm on to something
punkrawkR has joined #ruby
EvanR has joined #ruby
<robkinyon> workmad3: it's much more than that. filters and pipes just covers "hookability"
BeLucid has joined #ruby
edogawaconan has joined #ruby
EvanR has joined #ruby
<robkinyon> the key for bonhoeffer is "one and only one thing done superlatively"
akemrir has joined #ruby
<workmad3> robkinyon: true... and I know what you mean, I'm just in a brain-dead state today when it comes to expressing things... I should probably shut up :)
A124 has joined #ruby
<robkinyon> eh. that's why there's many of us - to work through exactly how to express something
<robkinyon> tomorrow, i will be braindead and you will be on your game
dql has joined #ruby
theRoUS has joined #ruby
theRoUS has joined #ruby
jcromartie has joined #ruby
<EvanR> its wednesday, its supposed to be the intersection of recovering from the weekend and winding in preparation for the weekend ! ;)
<EvanR> winding down
oposomme has joined #ruby
<theRoUS> meh
<theRoUS> ruby 1.8.7.. is there any way to find out what action is the current handler for a specific signal *without* doing an 'x = Signal.trap(sig,'DEFAULT');Signal.trap(sig,x)' ?
immigrantX has joined #ruby
<bonhoeffer> robkinyon: so does abstraction provide flexibility
<bonhoeffer> we need to look over millions of scenarios and understand the flexbility and robustness of a collection of assets we invest in
<robkinyon> bonhoeffer: the *right* abstraction provides flexibility
<theRoUS> i want to know because SIGVTALRM can only have a trap set in a threaded environment; doing the trap/retrap throws an exception else
<robkinyon> the wrong abstractions . . . well, those we don't talk about
<bonhoeffer> ok -- I see what you are saying
kinderman has joined #ruby
<robkinyon> bonhoeffer: often, too, we need multple layers of abstractions in order to get to the right point
<robkinyon> so, we write abstractions on top of abstractions
DMKE has joined #ruby
<robkinyon> and that's okay
<bonhoeffer> so we are trying to write requirements that a contractor tells us their framework for solving this
<bonhoeffer> but we don't want another monster that you have to develop a career in to run
snip_it has joined #ruby
bitrot has joined #ruby
<bonhoeffer> and in my line of work -- onerous code means you focus on running on the model, not the insight you get from it
bl3k has joined #ruby
<robkinyon> bonhoeffer: let's take this to /msg - this isn't ruby-related
mdw has joined #ruby
cha1tanya has joined #ruby
y3di has joined #ruby
oposomme has joined #ruby
PragCypher has joined #ruby
alem0lars has joined #ruby
Ryougi_Shiki has joined #ruby
headius has joined #ruby
<theRoUS> $ ruby -e 'Signal.trap("VTALRM", "IGNORE")'
<theRoUS> -e:1:in `trap': SIGVTALRM reserved for Thread; can't set handler (ArgumentError)
<theRoUS> from -e:1
guillaum has joined #ruby
John_P has joined #ruby
alx- has joined #ruby
moshee has joined #ruby
moshee has joined #ruby
minver has joined #ruby
<minver> Can anyone refactor my code? http://is.gd/IhG5iT
wedgeV has joined #ruby
zeninfinity has joined #ruby
iocor has joined #ruby
<alem0lars> I'm using YARD. I want to document my classes and methods using Textile. I tried both the command line argument --markup textile and including # @markup textile in the top of each file. However, it won't use Textile, but instead RDoc. How can I use Textile with YARD?
<alem0lars> Is it possible to change the markup format for the documentation (YARD) in source files?
<abstrakt> so I installed ruby 1.9.3-p0 from rvm, so I have the src folder, I just ran rdoc inside said folder because there don't appear to be any available downloads for the 1.9.3 documentation
<abstrakt> the documentation is split in to core and stdlib
Maxou56800 has joined #ruby
<abstrakt> after running rdoc in the 1.9.3-p0 source folder
<abstrakt> will that have generated all the docs for stdlib as well
<abstrakt> or will/does stdlib live in a different folder
<abstrakt> my guess would be that it does generate docs for stdlib, I just wanna double check here
drknus has joined #ruby
alx- has joined #ruby
John_P has joined #ruby
d3vic3 has joined #ruby
tess has joined #ruby
mdw has joined #ruby
<shevy> I guess the guys on #rvm may know, as far as I understood it though they keep everything that belongs to a specific version of ruby in the same directory specific to that version
wicchan_ has joined #ruby
adambeynon has joined #ruby
InBar has joined #ruby
andrewhl has joined #ruby
cjlicata has joined #ruby
bl3k_ has joined #ruby
wmoxam has joined #ruby
vandemar has joined #ruby
waxjar has joined #ruby
vipaca has joined #ruby
vipaca has joined #ruby
pu22l3r_ has joined #ruby
yoklov has joined #ruby
bbttxu_ has joined #ruby
shruggar1 has joined #ruby
rippa has joined #ruby
mickn has joined #ruby
havenn has joined #ruby
shtirlic has joined #ruby
igaiga has joined #ruby
CheeToS has joined #ruby
pu22l3r has joined #ruby
pdtpatr1ck has joined #ruby
AxonetBE has joined #ruby
<AxonetBE> Is it a good idea to use a json for a radio button value?
pu22l3r has joined #ruby
rushed has joined #ruby
headius has joined #ruby
<fmcgeough> is there a good writeup that someone can recommend on the available GUI Ruby frameworks for a straight app? (Windows, OS X, Linux). I'd like to bundle some things that I've written up for some support folks.
Indian_ has joined #ruby
albemuth has joined #ruby
TNTechnoHermet has joined #ruby
y3di has joined #ruby
bl3k has joined #ruby
<shevy> fmcgeough ruby-gtk
codespectator has joined #ruby
<shevy> fmcgeough, http://ruby-gnome2.sourceforge.jp/?News_20120115_1 it is easy, but still quite a lot of work
<shevy> unless all you want to do is make simple hello world buttons
<fmcgeough> the last time I wrote a desktop app I used Eclipse RCP… so anything is going to be an adventure.
adamkittelson has joined #ruby
Richmond has joined #ruby
_kinderman has joined #ruby
<shevy> if you know ruby fairly well then all the toolkits will be quite similar anyway
nemesit has joined #ruby
ckrailo has joined #ruby
araujo has joined #ruby
araujo has joined #ruby
Shrink has joined #ruby
Jay_Levitt has joined #ruby
<dbgster> does the Ruby hash have something similar to array#collect/map?
parsifal_ has joined #ruby
<parsifal_> I realize this is the wrong place to ask this, but I can't figure this out and can't find it online. Does anyone know which markup syntax this is? http://cl.ly/3w0R152W2a2s461C2c0I
<shevy> dbgster .map works on every member of an array. what would the .map version for a hash (with its key->value pairs) do?
flou has joined #ruby
iocor has joined #ruby
bl3k_ has joined #ruby
<shevy> hmm
<dbgster> it works on every member of an array, and returns a new array. so with a hash I guess it would work on the values of each key no?
flagg0204 has joined #ruby
<shevy> why not the keys?
<shevy> I am a bit confused right now though
devinus has joined #ruby
<shevy> in my irb, hash seems to have a .map method
devinus has joined #ruby
<arturaz> it works on |key, value|
<arturaz> and returns an array
devinus has joined #ruby
<shevy> ah yes
<robacarp> parsifal_: to me it looks to be a markdown syntax with some custom addon
<shevy> {"i"=>7, "j"=>7, "d"=>4, "e"=>5, "c"=>3, "a"=>1, "b"=>2, "FgH"=>6}.map {|key, value| value * 2}
<parsifal_> robacarp: rats. Fucking Doctrine. thanks
Bardosity has joined #ruby
<shevy> # => [14, 14, 8, 10, 6, 2, 4, 12]
devinus has joined #ruby
<robacarp> o-o
devinus has joined #ruby
devinus has joined #ruby
Walenrod has joined #ruby
bl3k has joined #ruby
devinus has joined #ruby
MasterIdler has joined #ruby
devinus has joined #ruby
parsifal_ has quit ["Linkinus - http://linkinus.com"]
araujo has joined #ruby
andrewhl has joined #ruby
Morkel has joined #ruby
ipoval has joined #ruby
bl3k_ has joined #ruby
tatsuya_o has joined #ruby
axl_ has joined #ruby
ipoval has quit [#ruby]
Teddy2steper has joined #ruby
choffstein has joined #ruby
DrShoggoth has joined #ruby
looopy has joined #ruby
kf8a has joined #ruby
kinderman has joined #ruby
Norrin_ has joined #ruby
jmfcool has joined #ruby
ph^ has joined #ruby
flagg0204 has joined #ruby
sandstrom_ has joined #ruby
sandstrom_ has joined #ruby
cbuxton has joined #ruby
Pip has joined #ruby
wilmoore has joined #ruby
kremiak has joined #ruby
<dbgster> if I have a module that has a class, I normally refer to it by: MYMODULE::MyClass.new
<dbgster> is there a way to import a namespace?
bl3k has joined #ruby
<robkinyon> import or alias?
<Mon_Ouie> You can include modules and get access to their constants
<matti> :>
Walenrod has quit ["Konversation terminated!"]
<dbgster> so just: include MYMODULE
pdtpatr1ck has joined #ruby
oooPaul has joined #ruby
gen0cide_ has joined #ruby
oposomme has joined #ruby
wallerdev has joined #ruby
bl3k_ has joined #ruby
shruggar has joined #ruby
trivol_ has joined #ruby
williamcotton has joined #ruby
PragCypher has joined #ruby
zeninfinity has joined #ruby
alex__c2022 has joined #ruby
bricker88 has joined #ruby
a_a_g has joined #ruby
<Jay_Levitt> Any Sublime Text 2 users? I just updated from 2189 to 2190 on Mac and now ST crashes at startup when the Ruby package is installed.. and the sublime forum is down :/
bl3k has joined #ruby
hydrozen has joined #ruby
rTypo has joined #ruby
apucacao has joined #ruby
ed_hz_ has joined #ruby
<Beakr> Ruby package? Doesn't Ruby come built-in?
darthdeus has joined #ruby
<Beakr> Jay_Levitt: I use Vim but I'm pretty sure ST should start normally if Ruby comes built-in like it did when I got it. You might want to find a ST channel if there is one more than the Ruby channel.
mafolz has joined #ruby
<Jay_Levitt> Beakr: Nah, looked for a channel and no luck.. actually seems to be a package that updated, not ST itself - I just downrevved to 2189 and it still happens
<Beakr> Jay_Levitt: Could be a bug with the package update itself.
<Jay_Levitt> Beakr: Also true
<Beakr> Jay_Levitt: If you can uninstall the package maybe it would work.
antonishen has joined #ruby
<Jay_Levitt> Beakr: Yeah, unfortunately I just pulled the two packages that Package Control mentioned updating and it's still crashing, might be something else tho
bl3k_ has joined #ruby
jgrevich has joined #ruby
<Beakr> Jay_Levitt: If it doesn't get patched or uninstalled you could consider reporting it.
shyam has joined #ruby
<Jay_Levitt> Beakr: Right - the hard part is figuring out what's crashing!
<Jay_Levitt> Beakr: Never have I been so happy that ST starts up quickly, tho :)
<frontendloader> http://bpaste.net/show/n7d4hePWN4BjgjM9FTmW/ having a build fail when I try to install ruby_debug
shyam has quit [#ruby]
<Beakr> Jay_Levitt: Yeah, it could be something different than just the package.
<workmad3> frontendloader: the error tells you the problem
<frontendloader> most of the time they do.
<Beakr> Jay_Levitt: Sadly I only have the 30 day trial. :P
cloke has joined #ruby
artOfWar_ has joined #ruby
<frontendloader> I'm not sure how to fix this one, shouldn't gcc know about libpq-fe.h in /usr/include/postgresql?
<workmad3> frontendloader: that's not the problem
<workmad3> frontendloader: the error message says 'Can't handle 1.9.x yet'
scalebyte has joined #ruby
<frontendloader> oh, hell.
<frontendloader> are there any debuggers that can?
<workmad3> ruby-debug1.9 can handle 1.9.2 I believe
<workmad3> not sure about any 1.9.3 debuggers though I'm afraid
<Jay_Levitt> I've heard that pry can substitute as a debugger as well, hopefully it doesn't rely on ruby-debug for that tho
<Jay_Levitt> There are workarounds to get ruby-debug working on 1.9.3 but I haven't got it working with bundler yet, only manual gem instlals
<Beakr> Anyone know a gem or library that helps you write Vim plugins in Ruby?
<frontendloader> I just need to set a breakpoint in this rails app :/
pu22l3r_ has joined #ruby
zandt has joined #ruby
<workmad3> frontendloader: do you need a breakpoint, or do you just need to look at what's happening at that point?
<frontendloader> I don't feel like spamming logger() a bunch
<frontendloader> but it'll suffice if I can't get a debugger to work
<workmad3> frontendloader: you don't need to ... 'raise interesting_variable.inspect' at the point you want ;)
baroquebobcat has joined #ruby
eywu has joined #ruby
<frontendloader> that works too, but I don't want it to die on the raise,
<workmad3> frontendloader: hmm... you're stuck with logging of putting 'debug var' statements in your view then
<workmad3> frontendloader: I quite like the stop-the-world of raising though, lets me focus on one variable at a time while tracking things down :)
<workmad3> frontendloader: and limits my view of the app to exactly the point I identified as currently of interest
maletor has joined #ruby
pu22l3r has joined #ruby
SegFaultAX|work has joined #ruby
startling has joined #ruby
startling has quit [#ruby]
Indian has joined #ruby
nachtwandler has joined #ruby
PragCypher has joined #ruby
<frontendloader> I enjoy writing throw <expletive> to check if I'm hitting a block of code.
adeponte has joined #ruby
pu22l3r has joined #ruby
zeninfinity has joined #ruby
tewecske has joined #ruby
Teddy2steper has joined #ruby
pu22l3r has joined #ruby
nonotza has joined #ruby
hooper has joined #ruby
msuszczy has joined #ruby
antonishen has joined #ruby
nadirvardar has joined #ruby
pu22l3r has joined #ruby
havenn has joined #ruby
io_syl has joined #ruby
Vert has joined #ruby
araujo has joined #ruby
araujo has joined #ruby
apok has joined #ruby
arturaz has joined #ruby
seivan has joined #ruby
cpasmoi has joined #ruby
<cpasmoi> Hi !
<oooPaul> 'lo.
<cpasmoi> I think two links from http://www.ruby-lang.org/fr/documentation/ruby-from-other-languages/to-ruby-from-perl/ are deads because of rubygarden.org
<cpasmoi> URL to the wiki and FAQ of the website
<zandt> you should try emailing from the website.... not sure who handles that, but I noticed that, too. (it's been dead a while)
trivol_ has joined #ruby
PragCypher has joined #ruby
<cpasmoi> well I'm new to ruby, have to practice it in order to get a job but ok, i'll mail the webmaster
td123 has joined #ruby
araujo has joined #ruby
araujo has joined #ruby
wicchan_ has joined #ruby
pastjean has joined #ruby
fr0gprince_mac has joined #ruby
williamcotton_ has joined #ruby
jcromartie has joined #ruby
Araxia has joined #ruby
<dbgster> so when I do: attr_accessor :some_att
blacktulip has joined #ruby
<dbgster> if I want this to be a hash, can I add: def some_att; self.some_att ||= []; end
y3di has joined #ruby
<dbgster> is that correct?
ballpointcarrot has joined #ruby
<workmad3> dbgster: no... that would be infinite recursion
<workmad3> dbgster: also, [] is an array literal, not a hash literal
<dbgster> yes sorry {}
<workmad3> dbgster: doesn't stop the infinite recursion ;)
<dbgster> hehe…yes I was hoping you were going to correct me
<dbgster> removing the self?
<workmad3> dbgster: if I just correct you, you don't learn anything ;)
<workmad3> dbgster: especially in a language like ruby, where you can just open irb and play with code
<dbgster> uhm…how's that?
<dbgster> k
ghanima has joined #ruby
pu22l3r has joined #ruby
<workmad3> dbgster: I'm a believer that an answer you work out for yourself is a better learning experience than one handed to you
iocor has joined #ruby
<dbgster> well I can just create a attr_writer
<shevy> dbgster but not when you want self.foo
<dbgster> then I need @foo
apeiros_ has joined #ruby
<shevy> but really, the attr* aren't doing anything magical
<shevy> you can write ruby code without using them
<rippa> or you can write them yourself
<cpasmoi> Is there a way with Time Class to convert a time format "2012-01-12" to "12/Jan/2012" (the slash separator can be handled with regexp I guess) ? I only see the contrary (Time.utc (2012,"jan",12) => 2012-01-12
ascarter has joined #ruby
cloke has joined #ruby
ed_hz_ has joined #ruby
<rippa> cpasmoi: Time#strftime
luxurymode has joined #ruby
<cpasmoi> thanks ! I'll look forward
adamkittelson has joined #ruby
MrGando has joined #ruby
madhatter has joined #ruby
deryl has joined #ruby
kpshek has joined #ruby
asobrasil has joined #ruby
ringotwo has joined #ruby
frontendloader has joined #ruby
SeanLazer has joined #ruby
CannedCorn has joined #ruby
carlyle has joined #ruby
<SeanLazer> hey guys, i seem to remember that there's a way to have an instance of a class return something other than itself, like if you call @instance_of_class it would actually give you @intstance_of_class.to_s
<SeanLazer> did i dream that up or is that a thing?
<apeiros_> you have been dreaming
carlyle has joined #ruby
<apeiros_> @ivar is an instance variable, as a variable, all it can ever do is reference an object.
mmokrysz has joined #ruby
<apeiros_> so it will always evaluate to the object that has last been assigned to it
<SeanLazer> alright maybe i need help with an implementation strategy
sungji has joined #ruby
<SeanLazer> I have a simple settings class, similar to Settingsclass, but checks three sources (database, yml file, env vars) for the setting
<SeanLazer> i want to be able to call something like Settings.api_key and get the value of api_key
<SeanLazer> but also be able to call Settings.api_key.source and find out what the source is
<SeanLazer> (settings is a singleton)
<cpasmoi> thank you rippa that's exactly what I was looking for :)
carlyle has joined #ruby
ringotwo has joined #ruby
<apeiros_> SeanLazer: um, note that what you now just asked has nothing to do with your initial question. ivars and methods are largely unrelated (and Settings.api_key is a method)
<SeanLazer> oops, when i said similar to Settingsclass i meant similar to Settingslogic
mrsolo_ has joined #ruby
havenn has joined #ruby
<apeiros_> if you want it to be that way, api_key must return an object that responds to .source, what's your problem with doing that?
<rippa> Settings.source.api_key
<rippa> would work for that porpoise without trickery
<SeanLazer> apeiros_: i know, i've jumbled this up in my head. i just used @ivar to represent something which had been set to an instance of a class. also in my first implementation i had .api_key returning an object
lkba has joined #ruby
mmokrysz has quit [#ruby]
<apeiros_> SeanLazer: you are being fuzzy - every value in ruby is an object.
<apeiros_> you can't return anything *but* an object
<SeanLazer> apeiros_: so i guess my question is this, how do i structure it so that Settings.api_key returns a string but Settings.api_key.source is also available? just dynamically add those methods to the string itself?
<SeanLazer> and yes i know i'm explaining this really poorly, imagine that i was a guy who understood ruby fairly well but hadn't eaten lunch yet ;)
AxonetBE has joined #ruby
<apeiros_> SeanLazer: again, everything is an object, a string is an object too
<apeiros_> you can define additional methods on any object just fine
<SeanLazer> apeiros_: so that would be your approach if i wanted that interface?
<apeiros_> SeanLazer: *my* approach would probably be what rippa suggested
<apeiros_> but if you want *your* approach, then just extend the string you return with all the necessary methods & data
<apeiros_> see Object#extend, or alternatively, def obj.some_meth; …; end
stephenjudkins has joined #ruby
<apeiros_> also Object#define_singleton_method
<SeanLazer> apeiros_: i'm designing around a specific interface that i had in mind based on how i think other devs might use this code, i think it's more clear this way but maybe i'm wrong
<SeanLazer> i'll check out the documentation on that stuff, thanks
maasha has joined #ruby
kinderman has joined #ruby
mikepack has joined #ruby
<phantasm66> is there a class or core method that can tell me if a another process has a file "open"?
<maasha> How do convert a ruby array, passed to a C function as VALUE rb_ary, to a C array?
wallerdev has joined #ruby
<apeiros_> maasha: read README.EXT
<apeiros_> iirc it's a macro
<maasha> apeiros_: yeah, I am staring at this but cant quite locate it:http://www.eqqon.com/index.php/Ruby/Ruby_V1.9_C_Extension
<apeiros_> phantasm66: I don't think so. there might be gems that do that. probably not in a platform-agnostic way, though.
<apeiros_> maasha: that's not README.EXT.
<maasha> apeiros_: nope, but thats what I have been reading :o)
<phantasm66> ok.. thanks
nemesit has joined #ruby
a_a_g has joined #ruby
pdtpatr1ck_ has joined #ruby
voodoofish430 has joined #ruby
ByteCrunch has joined #ruby
delinquentme has joined #ruby
<delinquentme> what does a & do when attached to an argument?
<delinquentme> def merge_sort(&predicate) < example
dross_ has joined #ruby
nfluxx has joined #ruby
<rippa> delinquentme: passes argument as bock
<rippa> *block
<apeiros_> and calls .to_proc on it if necessary
pdtpatr1ck has joined #ruby
kf8a has joined #ruby
cloke has joined #ruby
iocor has joined #ruby
__Grabarz__ has joined #ruby
<norm> can i specify a gem source for a dependency in a .gemspec file?
seivan has joined #ruby
cbuxton has joined #ruby
badabim has joined #ruby
__Grabarz__ has quit [#ruby]
havenn has joined #ruby
Nss has joined #ruby
<apeiros_> norm: afaik, no
<apeiros_> it wouldn't make sense anyway
sako has joined #ruby
francisfish has joined #ruby
<sako> hey guys, has anyone figured out the gcc issues with ruby and osx lion yet?
<apeiros_> sako: I think you can just install the gcc from kenneth reitz on github
stringoO has joined #ruby
<sako> apeiros_: i see, i was reading kenneth's blog and was under the assumption that xcode command line tools does exactly what his packages did?
<sako> already have xcode command line tools installed
<apeiros_> ah, right, apple now provides gcc separately
<apeiros_> then I'd guess all you have to do is use the right gcc…
davidcelis has joined #ruby
<norm> apeiros_: i'm still differentiating gemspecs and gemfiles. i'm developing a home-grown gem that depends on another home-grown gem. in production, these come from an internal gem server. for development, should i just manually install the dependencies?
<apeiros_> norm: configure your rubygems for your custom source, not the gem
<apeiros_> alternatively, specify it in the gemfile
flou has quit ["Leaving..."]
stkowski has joined #ruby
c0rn has joined #ruby
schovi has joined #ruby
n1x has joined #ruby
dross has joined #ruby
mikepack has joined #ruby
cbuxton has joined #ruby
Indian has joined #ruby
cjlicata has joined #ruby
csprite has joined #ruby
snip_it_ has joined #ruby
Divinite has joined #ruby
csprite has joined #ruby
ringotwo has joined #ruby
advorak has joined #ruby
cbuxton has joined #ruby
ringotwo has joined #ruby
kpshek has joined #ruby
alup_ has joined #ruby
HektoR has joined #ruby
waxjar has joined #ruby
<HektoR> hello guys... is there any ruby full text search engine like Lucene for java ?
<apeiros_> HektoR: afaik, there's ruby bindings for lucene
<apeiros_> and of course, with jruby you can use whatever exists for java
pdtpatr1ck_ has joined #ruby
<apeiros_> I think solr was the name of the ruby binding
<apeiros_> ah, no, it was ferret. but solr is relevant too in this context.
<HektoR> apeiros_: is jruby effecient ?
shell0x_ has joined #ruby
<apeiros_> define efficient
cameron_ has joined #ruby
mcwise has joined #ruby
<apeiros_> it runs on the jvm and is well suited for server tasks
Gekz has joined #ruby
Gekz has joined #ruby
CannedCorn has joined #ruby
robkinyon has joined #ruby
ByteCrunch has joined #ruby
badelat has joined #ruby
litejk has joined #ruby
litejk has quit ["696 programming language || ruby-lang.org || Paste >3 lines of text in http://pastie.org || Rails is in #rubyonrails"]
choffstein has joined #ruby
bhunt has joined #ruby
ByteCrunch has joined #ruby
Nisstyre has joined #ruby
thecreators has joined #ruby
sacarlson has joined #ruby
greenarrow has joined #ruby
gianlucadv has joined #ruby
Gekz has joined #ruby
sandstrom has joined #ruby
sandstrom has joined #ruby
interopcop has joined #ruby
pdtpatr1ck has joined #ruby
<interopcop> can anyone suggest an Array funciton for removing an item from a sorted array (which is actually a set). here's my code: https://gist.github.com/2150809
<interopcop> I have assembled an Array of SoftwareRelease id's. I need to trim off id's which refer to SoftwareReleases which are before current
lorandi has joined #ruby
<yxhuvud> interopcop: I suppose you are aware that there are already a set implementation you could use? require 'set'
codespectator has joined #ruby
stefanp has joined #ruby
stefanp has joined #ruby
stefanp has joined #ruby
<interopcop> yxhuvud: so essentially if I make the Array a set, then I can still sort it and group it as I do, but at the end I can just return it as an array if the client expects an array in the interface?
<maasha> I want to define a slice method that takes arrays/ranges as arguments like slice([1], [2 ... 5]), but the range is not turned into an array?
<robkinyon> interopcop: why do you need it sorted while working on it?
<robkinyon> sorting seems to be a display requirement in your code
<interopcop> I sort and group it to get the last which is the release marker
<yxhuvud> interopcop: if it is a set, then it isn't sorted. (as far as the users of the set are concerned. implementation may differ).
williamcotton_ has joined #ruby
<interopcop> are you saying a set can't be sorted?
mikepack has joined #ruby
<interopcop> sorry I'm new
<yxhuvud> intercop: I reacted to your claim that it was a set you were implementing. If you require it sorted then it probably isn't
baroquebobcat has joined #ruby
<interopcop> it's a set only in the sense that it doesn't contain duplicates
<interopcop> it contains the last SoftwareRelease in each major/minor group
jlebrech has joined #ruby
blueadept has joined #ruby
ephemerian has joined #ruby
shruggar has joined #ruby
bashdy has joined #ruby
eywu has joined #ruby
<robert_> shevy: lmao, Facebook wants me to be friends.. with myself! o.o
fukushim_ has joined #ruby
EF has joined #ruby
<ddv> #facebook
Russell^^ has joined #ruby
mdw has joined #ruby
<robert_> ddv: I was just saying that. </end-of-offtopic>
jjore_ has joined #ruby
mfridh_ has joined #ruby
wookiehangover has joined #ruby
PaciFisT has joined #ruby
mdw has joined #ruby
carlyle has joined #ruby
carlyle has joined #ruby
<nate_h> how would i require a gem with fqdn
<nate_h> instead of using the LOAD_PATH ?
<apeiros_> should I be pedantic and point out that the 'dn' in 'fqdn' stands for 'domain name'?
Kiall has joined #ruby
<sandstrom> Is it possible to use rake-pipeline with 'asset pipeline'-style index.js files defining the load order (instead of using say minispades)?
Beakr has joined #ruby
nikhgupta has joined #ruby
libertyprime has joined #ruby
russfrank has joined #ruby
artm has joined #ruby
kirun has joined #ruby
artm_ has joined #ruby
mickn has joined #ruby
<nate_h> does anyone know how to provided the path to a gem in the require?
<nate_h> like require '/foo/bar/foo' ?
<apeiros_> rubygems uses Gem.path
yoklov has joined #ruby
<apeiros_> not sure whether you can just manipulate it like $LOAD_PATH, but you can always just try and see what happens…
<nate_h> apeiros the problem i'm having is that within an app i'm extending its not allowing me to require gems
<nate_h> yet it works in irb
<apeiros_> (don't forget that you can't require a .gem file anyway)
<nate_h> and the Gem.path is correct
<apeiros_> not allowing you? how?
<nate_h> saying file not found
CannedCorn has joined #ruby
<nate_h> sec, i'll pastie some stuff
<apeiros_> that's not quite the same as 'not allow'
kenichi has joined #ruby
kirun_ has joined #ruby
<nate_h> so the top is the output from my application
bwlang has joined #ruby
<nate_h> in this case puppet
<nate_h> you see three notice statements
<nate_h> those are the Puppet.notice calls in the code
<nate_h> to print the Gem.path, $LOAD_PATH, and Gem.ruby
<nate_h> so the gem path looks fine because i can see the gems in that location
<nate_h> root@oZone1:/etc/puppet/modules# ls /var/lib/gems/1.8/gems/
<nate_h> builder-3.0.0 deep_merge-1.0.0 diff-lcs-1.1.3 hiera-0.2.1 hiera-puppet-0.2.1 metaclass-0.0.1 mocha-0.10.0 rspec-2.8.0 rspec-core-2.8.0 rspec-expectations-2.8.0 rspec-mocks-2.8.0
<nate_h> i had to append "gems" to the end
shruggar has joined #ruby
<apeiros_> nate_h: wow, why does it not print the actual error message but only the backtrace?
<apeiros_> that's like superstupid and evil at the same time…
<nate_h> well err: no such file to load -- rspec
<nate_h> thats the error
<nate_h> i figured?
<nate_h> i ran my puppet in debug/trace mode to see that other stuff
<apeiros_> aaay, they… seriously write the backtrace first and THEN the error message?
<apeiros_> how stupid is that…
<apeiros_> thanks for pointing it out, I didn't see it
<nate_h> ya that's just the format they use I guess
<nate_h> anyways, this function works totally fine in another puppet server
<nate_h> diff os
<nate_h> so it has to be some kind of ruby pathing issue
<apeiros_> nate_h: please make a paste of the output of `gem env` and check, whether rspec is listed in `gem list`
CannedCorn has joined #ruby
bwlang_ has joined #ruby
<apeiros_> nate_h: or permissions issue…
CannedCorn has joined #ruby
tbrock has joined #ruby
<nate_h> apeiros_, if it were a permission issue what would I check? THis is running as root
otters has joined #ruby
<apeiros_> well if you run as root, permissions issues are unlikely I'd say… what you'd check: whether you have read rights on the rspec.rb file in the lib dir of the rspec gem
ballpointcarrot has quit ["Exit, Stage Left."]
williamcotton_ has joined #ruby
artm has joined #ruby
schovi has joined #ruby
<nate_h> um
<apeiros_> ok, so that gem command matches up with the output of your other pastie, and rspec is listed in `gem list`?
<apeiros_> does `ruby -rrubygems -rrspec -e 'puts "hi"'` work?
<nate_h> that's a little odd
<nate_h> it didn't work as you pasted it, but it worked in irb
<apeiros_> nate_h: ah, I forgot, in 1.8 that wouldn't work
ipoval has joined #ruby
<apeiros_> you'd have to do `ruby -rrubygems -e 'require "rspec"; puts "hi"'`
ipoval has quit [#ruby]
<apeiros_> at least I think you had to… been a while since 1.8…
<nate_h> that worked
hooper has joined #ruby
<apeiros_> ok, odd then…
justinmcp has joined #ruby
<nate_h> indeed
<apeiros_> it's the same gem, the same paths, once it can load it, and once it can't…
<apeiros_> in irb, do $".grep(/rspec.rb/)
<nate_h> makes me want do punch something
<apeiros_> it should give you the full path to the required file, you can test there whether it is indeed a permissions issue
<apeiros_> I don't have any other ideas to offer atm…
<nate_h> irb(main):003:0> $".grep(/rspec.rb/)
<nate_h> => []
<nate_h> did i mess up syntax?
<apeiros_> hurr?
<apeiros_> no
<apeiros_> and $".last ?
<nate_h> irb(main):004:0> $".last
<nate_h> => "irb.rb"
<apeiros_> hu? you did require rubygems & rspec before you did that, yes?
<nate_h> oh no sorry
<nate_h> sec
<nate_h> haha
<apeiros_> ^^
<nate_h> irb(main):007:0> $".grep(/rspec.rb/)
<nate_h> => ["rspec/monkey/spork/test_framework/rspec.rb", "rspec.rb"]
<apeiros_> ah fuck, 1.8 didn't expand the paths in $"
<apeiros_> $:.grep(/rspec/)
CannedCorn has joined #ruby
<nate_h> => ["/var/lib/gems/1.8/gems/rspec-core-2.8.0/lib", "/var/lib/gems/1.8/gems/rspec-expectations-2.8.0/lib", "/var/lib/gems/1.8/gems/rspec-mocks-2.8.0/lib", "/var/lib/gems/1.8/gems/rspec-2.8.0/lib"]
<apeiros_> nate_h: ok, /var/lib/gems/1.8/gems/rspec-2.8.0/lib/rspec.rb is the file I'd say
<nate_h> btw this happens for ANY gem i require
<apeiros_> nate_h: did you try the ruby -rrubygems -e with root?
Divinite has joined #ruby
<nate_h> i am root
<nate_h> it all works fine via the command line
<apeiros_> ok, just to rule out a difference with different users
<nate_h> cause the app is running as root too
<apeiros_> does the app fork under a different user?
<nate_h> checking
Indian has joined #ruby
<nate_h> holy shit
<nate_h> i run it as root and it runs at puppet
<nate_h> second, i may have found the issue
<nate_h> fucking ubuntu
n3m has joined #ruby
SphericalCow has joined #ruby
<apeiros_> ok, I guess you've found a likely cause :)
<nate_h> hmm first fix didn't work, trying next one
<nate_h> hmm nope
<nate_h> trying next fix
beakerma_ has joined #ruby
<nate_h> ok i 755 all the gems and dirs
<nate_h> and no luck
<apeiros_> :-/
<apeiros_> does the ruby -r work when you run it as puppet?
tewecske has joined #ruby
dbgster has joined #ruby
Indian_ has joined #ruby
bwlang has joined #ruby
kgraham has joined #ruby
<kgraham> is this the right channel for ruby mysql2 library
Russell^^ has joined #ruby
pyreal has joined #ruby
<kgraham> hello, I'd like to run this query using a ruby gem, i've tried mysql2, but it doesn't return what i get from mysql cli client
<kgraham> the CONCAT's don't run
<kgraham> what is the best mysql client library i guess is what I'm asking
<Spaceghostc2c> mysql2
<kgraham> tried that, i must be using the result object incorrectly
<kgraham> i have to xform the result into a csv,
ePirat|off has joined #ruby
y3di has joined #ruby
zandt has joined #ruby
beakerman has joined #ruby
geekbri has joined #ruby
bricker88 has joined #ruby
nachtwandler has joined #ruby
SphericalCow has joined #ruby
ridders24 has joined #ruby
williamcotton_ has joined #ruby
stephenjudkins has joined #ruby
<ridders24> can anyone help me with how to write a script to seach for part of a file name in directories
NotAzure has joined #ruby
mrsolo_ has joined #ruby
mrsolo_ has joined #ruby
mcwise has joined #ruby
geekbri has joined #ruby
williamcotton_ has joined #ruby
ScottNYC has joined #ruby
drknus has joined #ruby
c0rn has joined #ruby
<ScottNYC> any ideas? I ran $rbenv install 1.9.3-p125 ..then getting error : "checking whether the C compiler works... no
<ScottNYC> configure: error: C compiler cannot create executables. See `config.log' for more details"
<Spaceghostc2c> Install a working compiler.
<ScottNYC> and I hace excode installed with CLI tools
antonishen has joined #ruby
<ScottNYC> gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
r3dskade has joined #ruby
twixmix has quit [#ruby]
ChampS666 has joined #ruby
kevinbond has joined #ruby
fowl has joined #ruby
tayy has joined #ruby
wefawa has joined #ruby
zandt has joined #ruby
jwang has joined #ruby
mikepack has joined #ruby
<y3di> hi guys, im getting an error at line 15 and I have no idea why: https://gist.github.com/2152502
<y3di> am i doing the slim templating wrong?
<y3di> the error is at the second = sign
skavez has joined #ruby
<oooPaul> What's the error?
<y3di> oh did i forget the require....
<fowl> y3di: dont you need to __END__ so that's not processed by ruby
* oooPaul doesn't do Sinatra, so anything I suggest is just guessing.
<fowl> looks like that's the problem
<y3di> idk, I'm new to ruby, ill try that fowl
<y3di> it was an 'unexpected tIDENTIFIER' btw
v0n has joined #ruby
Mrono has joined #ruby
<y3di> thanks that worked fowl
<fowl> y3di: __END__ tells ruby to stop reading the script there, anything below that is available as __DATA__
<fowl> no problem y3di
SphericalCow_ has joined #ruby
johndbritton has joined #ruby
SphericalCow_ has quit [#ruby]
SphericalCow has joined #ruby
chimkan_ has joined #ruby
dzhulk has joined #ruby
ablemike has joined #ruby
Nathandim has joined #ruby
<y3di> NoMethodError at / undefined method `slim' for <app>
<y3di> I have the slim gem installed and I require slim so idk why im getting that error during runtime
Ontolog has joined #ruby
ablemike has joined #ruby
trivol has joined #ruby
Divinite has joined #ruby
chson has joined #ruby
banistergalaxy has joined #ruby
canton7 has joined #ruby
triptec has joined #ruby
mcwise has joined #ruby
manizzle has joined #ruby
<y3di> anyone know why I might be getting a NoMethodError for slim at line 5? : https://gist.github.com/2152669
yoklov has joined #ruby
jgrevich has joined #ruby
shadoi has joined #ruby
s0ber_ has joined #ruby
y3llow_ has joined #ruby
<TTilus> ridders24: find -name '*partofafilename*'
<TTilus> ridders24: no?
swarley has joined #ruby
<swarley> i see String#tr in the rdoc, (assuming it behaves like perl's tr/A-Z/Z-A/) but I do not seem to have the method available to use. Trying in pry using ruby 1.9.3
<apeiros_> swarley: how did you try?
<swarley> i tried show-doc String.tr
<burgestrand> swarley: show-doc String#tr
<apeiros_> I mean how did you try to *use* it
<epochwolf> does ruby use the quicksort algorithm for Enumerable#sort_by ?
<swarley> ah
<swarley> i feel silly now
<apeiros_> epochwolf: I think so
<epochwolf> fuck fuck fuck fuck
<swarley> it seems to produce different results
<swarley> at first it was a no method error, i thought
<apeiros_> epochwolf: why's that fuckfuckfuck?
<TTilus> epochwolf: come down...
<apeiros_> even quadruplefuck
<burgestrand> epochwolf: yes it does
<epochwolf> apeiros_: quicksort isn't stable
<burgestrand> epochwolf: just attach the index before sorting
cespare has joined #ruby
<apeiros_> epochwolf: ah
<apeiros_> yeah, sort makes no promises about stability
<apeiros_> neither does sort_by
<epochwolf> burgestrand: yeah, I'll have to sort_by with a hash.
<epochwolf> errr array
<apeiros_> so even if it was stable, you should not rely on it
<epochwolf> apeiros_: this application is locked on 1.8.6 and will be until the end of time.
<apeiros_> ary.with_index.sort_by { |v,i| [criterion(v), i] }
<burgestrand> ^
<epochwolf> apeiros_: yes, yes, yes, I know :)
<apeiros_> oh, then no .with_index, but you can zip
<apeiros_> epochwolf: you should reduce the energy drinks, you're hypering :-p
<y3di> anyone know why I might be getting a NoMethodError for slim at line 5? : https://gist.github.com/2152669
<burgestrand> y3di: you have slim required?
<burgestrand> nvm
<burgestrand> I fail at reading
<burgestrand> :d
<epochwolf> apeiros_: forms.sort_by(&:name).sort_by(&:sequence) should be form.sort_by{|f| [f.sequence, f.name]}
<burgestrand> y3di: post your error
<y3di> NoMethodError at / undefined method `slim' for <app>
<apeiros_> epochwolf: um, no
<epochwolf> no?
<apeiros_> that's different, even with stable sort
<burgestrand> y3di: *shrugs* did you try requiring slim before sinatra?
schovi has joined #ruby
<burgestrand> I mean, hopefully makes no difference, but it might
<epochwolf> apeiros_: how so?
<apeiros_> ["a",1], ["b",0]
<y3di> ill tyr that
<apeiros_> with sort_by chained, that'll be b first, then a
<apeiros_> ah
<apeiros_> oh, you inverted… wait
<apeiros_> but still, it's not the same
<apeiros_> I just need to adapt my example
<epochwolf> apeiros_: I need my forms sorted by sequence, and then alpha by name if the sequence is the same.
<apeiros_> well, why don't you just use the latter form anyway?
<epochwolf> apeiros_: I am
<apeiros_> no, you're right, with stable sort it's the same
<apeiros_> *it'd be
<y3di> burgestrand: yea didn't help
<epochwolf> apeiros_: see, I'm not an idiot. :)
<apeiros_> epochwolf: there was a 95% chance…
<epochwolf> that I was?
<apeiros_> with a tendency of becoming a 98% chance…
<apeiros_> yes :)
<epochwolf> apeiros_: thank you :D
<apeiros_> oh, that's related to general demographics and probability ;-p
<y3di> apeiros_ & epochwolf: do you guys have any suggestions for me?
jangell has joined #ruby
Gesh has joined #ruby
<apeiros_> y3di: given that I use neither slim nor sinatra - no
<epochwolf> y3di: non-sarcastic ones only I assume?
vikingly has joined #ruby
<y3di> epochwolf: yea =/
<epochwolf> rather, I only have sarcastic ones
<jangell> I'm trying to find a gem for forking workers with a pool of jobs….and I need some way for them to send data back to the parent…any tips?
<y3di> epochwolf: actually go for it anyways
<epochwolf> y3di: use rails :P
maletor has joined #ruby
}0 has joined #ruby
<Spaceghostc2c> It's easy to refactor after rails, just replace it with padrino on jruby.
<y3di> epochwolf: bah, i think i'll stick with python. If only I didn't have to TA this webware class that uses ruby =/
<epochwolf> Spaceghostc2c: you are evil. I like you.
tatsuya_o has joined #ruby
<Spaceghostc2c> :D
<vikingly> Hi! I have some methods that return a value hash of the same format. Is there a best practice better than just returning a hash? Ex. of hash returned from methods: { :quantity => 0, :price_per => 0, :subtotal => 0, :service_fee => 0, :trans_fee => 0, :total => 0, :currency => 'USD' }
<Spaceghostc2c> y3di: Yeah, sometimes having only one way to do things is fun.
<Spaceghostc2c> Notreally, but I'm trying ot be nice here.
<epochwolf> vikingly: use a class?
shtirli__ has joined #ruby
<vikingly> epochwolf: I am considering that. Should I just use a plain class or is there a best practice on an API in the class (e.g operators implemented)?
<y3di> Spaceghostc2c: i use clojure and php too =p
<epochwolf> vikingly: there is an OpenStruct in the standard library if you just want to wrap a hash
<Spaceghostc2c> y3di: You poor mortal.
<y3di> Spaceghostc2c: xD
* Spaceghostc2c is a ginger. :(
<epochwolf> y3di: you are dead to me.
<y3di> Spaceghostc2c: used php*
* epochwolf makes out with Spaceghostc2c instantly.
* Spaceghostc2c gets brolested and likes it
tatsuya_o has joined #ruby
}0 has joined #ruby
jgrevich has joined #ruby
<y3di> anyone know why I might be getting a NoMethodError for slim at line 5? : https://gist.github.com/2152669
<shadoi> y3di: never used it, but do you need to enable it in the sinatra settings?
<vikingly> epochwolf: thanks
luke--_ has joined #ruby
<shadoi> y3di: or maybe you have an old version of sinatra, has to be >= 12
<shadoi> 1.2*
asobrasil has quit [#ruby]
<y3di> shadoi: omg, that might be it
<any-key> hex stuff in ruby is driving me mad
<any-key> say I have the number -200, which as a 16 bit signed integer is 0x38FF
<epochwolf> vikingly: you're welcome
<shadoi> any-key: I recommend PacketFu::StructFu for handling that shit, made my life a lot easier.
arphen has joined #ruby
<any-key> [-200].pack('s') is supposed to convert this to a 16 bit signed int, but it gives me "8\xFF"
<any-key> shadoi: I'll check it out
arixx has joined #ruby
<any-key> pack is lying to me, though
<shadoi> pack is weird
<any-key> no kidding
<apeiros_> any-key: and guess what "8" is
<apeiros_> hint: "8" == "\x38"
<any-key> bah!
<any-key> no...ascii 8 is \x08
Nisstyre has joined #ruby
<apeiros_> but you don't *have* ascii 8
<apeiros_> you have "8", which is ascii 56, which is 0x38
<shadoi> hehe
<any-key> 8 is 8 in ascii
<apeiros_> omg, get a clue
<apeiros_> any-key: yes, now take a really close look at that table
<apeiros_> it says exactly what I just said.
<any-key> aghhh
<any-key> thanks...I should stop skimming things
<any-key> >.<
<apeiros_> great, you stopped fighting the evidence :-p
<any-key> I looked into it before asking here, saw that first 8 and was like "wtf"
<apeiros_> but yes, of course dec 8 is hex 8 :-p
<arphen> can d=file.open("/etc/.vimrc") ; d.puts("blabla");d.close();d=file.open("/etc/.vimrc/");s=d.gets() ever fail?
<arphen> i.e: writing something to a file and immediately reading it?
<arphen> because i think that's happening to me
<apeiros_> arphen: a) use block form of open
<apeiros_> b) really, if you paste code, CASING MATTERS, don't short-cut it, you just confuse everybody
<arphen> i just typed it out...
<arphen> does the block form do anything else than "close"?
<apeiros_> it ensures the close, which you don't
<arphen> you mean in case of an exception?
<apeiros_> for example
<arphen> meh... my basic question stands. if i call file.close() and it succeeds, will the write be carried out before any sequential reads?
<apeiros_> it should
<apeiros_> ruby builds on the OS' API, so it really depends on that
<arphen> :(
<arphen> i hate these bugs
<apeiros_> I only hate bugs I don't get paid to fix :-p
<shadoi> arphen: you're still at the mercy of the OS filesystem buffering, etc.
<Spaceghostc2c> apeiros_: I actually enjoyed that working with unix books.
y3di has joined #ruby
<Spaceghostc2c> s/s//
adman65 has joined #ruby
<arphen> yeah you may go ahead and laugh at me now shadoi
<arphen> :D
<arphen> but i think i found the course
<arphen> s/course/cause
<shadoi> arphen: I'm not laughing, but I did tell you so. ;)
<arphen> s_s/course/cause_s/course/cause/_
<apeiros_> of course you found the cursed cause
jgrevich has joined #ruby
<arphen> i was just using old data instead of properly refreshing it
cbuxton has joined #ruby
kgraham has quit [#ruby]
<arphen> i am pleased by the amount of stuff im learning right now
fowl has joined #ruby
<arphen> this internship was a splendid idea
<arphen> i can work whenever i want, wherever i want
<shadoi> arphen: maybe this is the pain your manager was trying to get you to learn by forcing you to use files. Or maybe he's just dumb. :)
<arphen> i have my own project, lots of time and i already got paid
cbuxton has joined #ruby
<arphen> plus it's the last missing piece for my degree :)
<arphen> next week i'll be looking into jQuery
<arphen> i enjoy web dev since there is no such thing as "overly paranoid" in web dev
jgrevich has joined #ruby
sjhuang has joined #ruby
AxonetBE has joined #ruby
<Spaceghostc2c> paranoid in what fashion?
<Spaceghostc2c> This sounds like a very slick slope.
<any-key> as long as you're paranoid in the right way it's good
jgrevich has joined #ruby
<arphen> it's not paranoid if they are out there
<arphen> just kidding, i mean the whole security stuff, man in the middle etc, having to think before you store passwords and how you store passwords
<arphen> i'm doing most stuff by hand so i'm implementing challenge response salt codes etc
<any-key> doing stuff by hand can be dangerous :P
<arphen> i also know that... im not re implementing sha or rsa
nikhgupta has joined #ruby
<any-key> haha
havenn has joined #ruby
<any-key> is there some cool syntax for a single line function definition?
<any-key> I have a bunch of lines that just do @serial.write(asdfasdf)
<any-key> and I know about semicolons :P
<apeiros_> no. there's just the ordinary "use ; instead of newline"
<apeiros_> or "use unambiguous syntax"
<apeiros_> e.g. `def foo() "bar" end` is valid
<any-key> maybe there's a way cooler way of doing this: I have a bunch of constants that define opcodes, and the class I'm writing has a function that sends each opcode
Ontolog_ has joined #ruby
<any-key> so it gets kind of tedious, but I want the end result to be class.opcode rather than something like class.mode(opcode)
axl__ has joined #ruby
dnyy has joined #ruby
<any-key> well, nah, I'll just use that second method for it
<apeiros_> you can use metaprogramming to let ruby create your methods for you
<arphen> it is higher level wizardry
<any-key> yeah...I suppose I could do that
Russell^^_ has joined #ruby
<any-key> that involves a metaclass, doesn't it?
<any-key> I never understood those
<TTilus> doesnt have to
<any-key> what would be the cool way of going about this?
<any-key> I have an array of opcodes, and I want to iterate through and add a method for each based on a proc
<vikingly> I am using a class to return values (Ex. https://gist.github.com/9bfd99af5ad76f81c0d5 ). How do I redefine the += operator on this class? For A+=B I'd like += to add attributes in all attributes in AMOUNT_CALC_ATTRIBUTES from B to A, and fail if an attribute is not defined in A or B.
<TTilus> share your non-cool way so we'll what you are up to
<TTilus> any-key: "based on a proc"?
<any-key> TTilus: I just have a bunch of constants, like "START" which each have a function in the class such as Roomba::start
<any-key> TTilus: ignore that
<vikingly> epochwolf: what do you think about https://gist.github.com/9bfd99af5ad76f81c0d5?
trivol has joined #ruby
<TTilus> any-key: def method_missing(method); Roomba.send method; end
<TTilus> any-key: ?
<epochwolf> vikingly: you recreated OpenStruct?
<any-key> method missing is a bit slow, though
<TTilus> any-key: why not just have the methods?
<any-key> TTilus: there's quite a few opcodes
<vikingly> epochwolf: I'd like to add a += operator and I'd like to fail if all attributes in AMOUNT_CALC_ATTRIBUTES are not defined, which is why I choose class instead.
<any-key> TTilus: define_method should do the trick
<epochwolf> vikingly: that work
<epochwolf> s
<TTilus> any-key: but you'll have the opcodes as methods, it really doesnt make any difference if they are hardcoded or define_method-generater
<Mon_Ouie> There's no += operator in Ruby. a += b expands to a = a + b
<shadoi> vikingly: assignment operators are not user-definable unfortunately.
<Mon_Ouie> So you just have to define the + method
<TTilus> any-key: or is there something you arent stating
<any-key> TTilus: I'm too lazy to type out all of these methods, it'll make my code look cleaner
<TTilus> any-key: good argument
<TTilus> any-key: just all_opcodes.each { |opcode| define_method(opcode) { ...whatever you do... } }
<any-key> yeah, that's the idea
<vikingly> shadoi: Mon_Quie: epochwolf: any suggestions on best practices to defining += equivalent semantics between two objects?
<TTilus> vikingly: define +
<vikingly> TTilus: the idea was to avoid object creation. Should I not worry about that?
<shadoi> vikingly: I usually just define +, and << for set/array-like things.
<TTilus> vikingly: i dont know if your objects are particularily heavy to create, u tell me
jgrevich has joined #ruby
<Mon_Ouie> You can create another method like merge or << if it's a problem
io_syl has joined #ruby
<vikingly> TTilus: I usually error on the side of allocating very few temporary objects as I don't want to be too reliant on the garbage collector. In this case I'll sum over an array of objects. However, the array will usually be less than 100 in size.
<TTilus> how would one be "too reliant on the gc"?
ph^ has joined #ruby
<TTilus> you mean "need to gc too much"?
<TTilus> or do you expect gc to fail somehow?
<vikingly> yes, need to gc more objects than strictly necessary.
<TTilus> just profile your memory usage and see if the solution you use "needs gc more objects than strictly necessary"
<TTilus> whatever that is
jgrevich has joined #ruby
<RubyPanther> vikingly: as said += doesn't mean that in Ruby, but << is usually the equiv. mutator
<vikingly> RubyPanther: TTilus: I am programming up two solutions now, and I'll test them both up. '<<' with the equiv semantics to +=, and overloading of the '+' operator.
mikepack has joined #ruby
mikepack_ has joined #ruby
mikepac__ has joined #ruby
mikepack has joined #ruby
punkrawkR has joined #ruby
jgrevich has joined #ruby
jcromartie has joined #ruby
emmanuelux has joined #ruby
luke--_ has joined #ruby
<CannedCorn> what is the best way to have a default and a minimum value for an opt
<CannedCorn> @var = opt.fetch(:var, default)
<CannedCorn> @var = min if @var < min?
jgrevich has joined #ruby
<CannedCorn> or is there a cleaner way to write that code
Tearan has joined #ruby
<apeiros_> looks fine
igaiga has joined #ruby
<apeiros_> if you want to do an arguments check on opt, you can use delete with a block instead of fetch
<apeiros_> but don't forget to dup opt before you start deleting stuff (mutating arguments is rude)
<CannedCorn> apeiros_: could you explain a bit more
<CannedCorn> why is that rude?
<apeiros_> because a user doesn't expect a method to modify something you pass to it
<apeiros_> a method should generally only modify the receiver
<apeiros_> (i.e., self)
<CannedCorn> got it
<CannedCorn> hrm so why not simply pass a block to fetch?
luckyruby has joined #ruby
<apeiros_> as for args checking, it'd go like: def foo(opts={}); opts=opts.dup; some_opt = opts.delete(:some_opt) { default }; raise "Invalid options: #{opts.keys.inspect}" unless opts.empty? …
landfall has joined #ruby
<apeiros_> because if you delete the option, you can check in the end whether there's unknown keys left, as seen above
<CannedCorn> yep
zakwilson has joined #ruby
<CannedCorn> ah because and passes in the key
<apeiros_> alternatively you can of course just do: unknown_keys = opts.keys-known_keys; raise … unless unknown_keys.empty?
<shadoi> I usually don't modify opts at all, I do something like: opts.each {|k,v| self.send("#{k}=", v) if valid_opts.include?(k)
<shadoi> and then for assignment defaults: @opt1 ||= "default"
<shadoi> missed my last } on that iterator
<CannedCorn> oh wait, but i want to implement a minimum if fetch/delete do return something
blacktulip has joined #ruby
<apeiros_> CannedCorn: that part doesn't change ;-)
<apeiros_> yours is fine there already
snearch has joined #ruby
<vikingly> TTilus: RubyPanther: I benchmarked both solutions (https://gist.github.com/9f853b237d0207996d92#comments), and overloading '+' is way faster.
KL-7 has joined #ruby
<davidcelis> CannedCorn: back when I had a radio show in college, I had a listener that would come into chat as "tastytastycorn" and make trollish phone calls
<CannedCorn> right, but there is no way to do it on one line
<CannedCorn> that wasn't me davidcelis
<CannedCorn> sorry
<davidcelis> I know
swarley has joined #ruby
<davidcelis> I just wanted to tell you that story
<CannedCorn> haha or was it?
<davidcelis> It wasn't
mikeg has joined #ruby
norex has joined #ruby
<CannedCorn> ok ok
<davidcelis> lol
<CannedCorn> it just sems like i should be able to do some fancy logic
<CannedCorn> in one line that says
<CannedCorn> try to get the value of this key, default is this, min is this
<CannedCorn> or maybe the way i wrote it was optimal
<CannedCorn> just seemed janky
<vikingly> TTilus: RubyPanther: shadoi: Thank you for the pointers.
<RubyPanther> vikingly: your benchmark is badly broken and doesn't tell you anything
<RubyPanther> in one case you throw away the result, and in the other, you concatenate the results
NotAzure has joined #ruby
<RubyPanther> well, or whatever happens to it
<RubyPanther> and << isn't supposed to just call foo= it is normally supposed to be able to change the object data directly, where that is possible
Ontolog has joined #ruby
RangerMauve has joined #ruby
<RangerMauve> Hey, can somebody tell me what part of the page in the WebForm redirects to /save? http://www.igvita.com/2007/02/13/building-dynamic-webrick-servers-in-ruby/
<RangerMauve> I mean /submit
<RangerMauve> No wait, it is /save. >.<
<vikingly> RubyPanther: Thanks. I did some changes to address those concerns: https://gist.github.com/9f853b237d0207996d92
<vikingly> RubyPanther: But I don't know how to make << change object data directly
<swarley> what are you trying to do
<swarley> okay so
<swarley> why
<swarley> attr_accessor *AMOUNT_CALC_ATTRIBUTES
<swarley> what am i missing there
<swarley> shouldnt that be a symbol?
<apeiros_> no
<swarley> oh
<swarley> i see
<swarley> i feel stupid
<apeiros_> AMOUNT_CALC_ATTRIBUTES should be an array of symbols (or strings)
<swarley> yeah
<swarley> i saw it after i said it
}0 has joined #ruby
darthdeus has joined #ruby
<apeiros_> also, variables vs. objects
<apeiros_> a symbol is an object, a constant is a variable
<vikingly> swarley: I am returning the same set of numbers from multiple methods. I am defining a class that holds those return values and overloads the + operator.
<apeiros_> (even if it sounds contradicting)
<swarley> i see
MasterIdler_ has joined #ruby
<apeiros_> iow, everything you can assign to is a variable. you can't assign to a symbol. :foo = 1 # not possible
PragCypher has joined #ruby
kreiggers has joined #ruby
<swarley> no
<vikingly> also, + will fail if one or more of the AMOUNT_CALC_ATTRIBUTES are not defined. I liek failing early.
<swarley> apeiros_, im not confused about that
<swarley> i just over looked the contents of the constant
nari has joined #ruby
landfall has joined #ruby
MasterIdler_ has joined #ruby
<vikingly> RubyPanther: another flaw of my benchmark is that it does not really measure the cost of gc as it is a short-running program, and it does not measure peak memory usage.
pu22l3r has joined #ruby
<arphen> i still couldnt figure out
<arphen> how do i view a file's size on the command line in human readable format?
<arphen> on gnu/linux
<apeiros_> arphen: du -shx path
<arphen> thanks
<arphen> you're a genius!
Jay_Levitt has joined #ruby
tommyvyo has joined #ruby
Dreamer3 has joined #ruby
manizzle_ has joined #ruby
<RubyPanther> vikingly: https://gist.github.com/39d1ac550acf4e6380f1 This is normally what the difference is, here using array which does have a proper << mutator
KL-7 has joined #ruby
knightMBP has joined #ruby
andrewhl has joined #ruby
<vikingly> RubyPanther: thanks. That is the same result I got in my improved gist. With strings '+' is faster in this particular benchmark, and '<<' is faster with numbers.
johnduhart has joined #ruby
<RubyPanther> vikingly: In the one I gave with << used correctly (on arrays) it should be quite a bit faster than +
<MauvePussy> RubyPanther: http://pastie.org/3644578 it should work, no?
<RubyPanther> Note that on numbers... 3 << 4 gives 48 and 3 + 4 gives 7 :)
<swarley> [59] pry(main)> k = Fabulous.new("Hello world")
<swarley> => "HELLO WORLD"
eshi has joined #ruby
<swarley> this seems useless to have made
<swarley> but it makes me happy
nonotza has joined #ruby
chson has joined #ruby
<RubyPanther> swarley: does it play nice with Term::ANSIColor ??? Fabulous.new("Hello World").red.blink
<swarley> RubyPanther, idk i made my own colorizer, so i dontt have that installed
<swarley> but i can see
rdesfo has joined #ruby
<rdesfo> hello
<rdesfo> I keep getting an error with guard and rspec git://gist.github.com/2154113.git
<davidcelis> Can you paste the actual gist link, and not the one to clone it?
nonotza_ has joined #ruby
Evixion has joined #ruby
Beakr has quit [#ruby]
liluo has joined #ruby
<mikeliss> Is there a trick to make gsub not treat its arguments as regexes?
<oooPaul> Don't put them in /'s?
yoklov has joined #ruby
mrsolo_ has joined #ruby
<oooPaul> "foobar".gsub("oo", "i") => "fibar"
<RangerMauve> SO, how would I make a simple form that sends a POST to a WEBrick servlet?
bglusman has joined #ruby
<davidcelis> "blah \d".gsup(" \d", "") # => "blah"
<davidcelis> gsub*
<oooPaul> "mr.rum".gsub("r.", "x") => "mxrum"
rushed has joined #ruby
<mikeliss> OK, so just using double paren? Wait, I'm not sure I follow.
<mikeliss> grr, and by parens, I mean quotes.
<mikeliss> This is what I currently have: text.gsub(from.to_s, to.to_s)
<RangerMauve> What he's doing there is specifying a string instead of a regex, and it looks for that combination of characters, and subs it with the second argument
<oooPaul> Compare: "mr.rum".gsub("r.", "x") => "mxrum" "mr.rum".gsub(/r./, "x") => "mxxm"
<oooPaul> What makes you think "from.to_s" is being evaluated as a regular expression?
<mikeliss> oooPaul: It didn't seem to be matching when I thought it should. It has a value that includes dots, so I figure that might be the cause.
<mikeliss> Sounds like that ain't it.
<oooPaul> Dump "from.to_s" to a console and see what you're *actually* getting?
gregorg_taf has joined #ruby
<mikeliss> oooPaul: Not a bad idea...this helps, thanks.
<oooPaul> Is from a Regexp object to begin with?
<oooPaul> A regex object converted to a string is not likely to give you what you want.
<oooPaul> Example: /foo/.to_s => "(?-mix:foo)"
<swarley> RubyPanther,
<swarley> [3] pry(main)> String.color_set :IRC; nil; puts Fabulous.new("Hello world!").red
<swarley> HELLO WORLD!
<mikeliss> oooPaul: Naw, it's coming from an XML file, not a regex.
<shadoi> buhleted.
<oooPaul> mikeliss, Ah. You may have some escaped characters or something in there that you're not expecting.
carloshpf has joined #ruby
<mikeliss> oooPaul: Yeah, about to find out.
<oooPaul> If the first parameter to gsub isn't a Regexp object, it should just be doing a straight-up text replace.
<mikeliss> oooPaul: Crap - it's a misconfiguration. Code was fine, but your tip was the one that counted.
CannedCorn has joined #ruby
tomzx has joined #ruby
<arphen> suppose i have many instances of a script running which each need to manipulate a file, possibly simultaneously. what's the general solution?
<oooPaul> :D
<oooPaul> When in doubt... puts debugging FTW. :)
<oooPaul> arphen, file locking.
<oooPaul> ri File#flock
<arphen> ok thanks
<swarley> this class feels dumber by the second
<arphen> whyu?
<swarley> because
nonotza has joined #ruby
<swarley> [10] pry(main)> puts Fabulous.new(Lolcat.translate("Hello world"))
<swarley> OH HAI, WORLD
<swarley> i also made an lolcat translator
<otters> pretty sure it's "ohai"
<zandt> swarley, lol
<CombatWombat> swarley: Wat :D
disappearedng has joined #ruby
<otters> might be a dialectic thing
<disappearedng> I have a = { "foo" =>"cat" } how can I assign it to a variable so that a.foo = cat?
<zandt> gonna try to compile ruby 1.9.3 in ubuntu 10.04 again tonight.... out of curiosity, has anyone been successful ?
<otters> sounds like an openstruct problem
<CombatWombat> disappearedng: define_method in ruby.
<swarley> IT DOESNT MATTR MUCH T ME, ITS JUS IMPORTANT IT LOOKS LIEK LOLCAT SPEKK TBH
<oooPaul> disappearedng, require 'ostruct'; foo = OpenStruct.new(a); foo.foo => cat
<swarley> you can use my module :D
<CombatWombat> ^That works too
<oooPaul> otters gets the credit. I just went verbose. ;)
<arphen> yes just use the lolcat module
<CombatWombat> I'd possibly use a lambda maybe.
<arphen> for everything
<fowl> swarley: link?
<CombatWombat> I don't always code, but when I do, I make sure it's in lolcat.
<swarley> require 'rubyserif'; k = JavaScript::Object.new({"foo" => "cat"}); k.foo
<swarley> oh
<arphen> get forth
<swarley> for lolcat?
<arphen> write program in lolcat
<swarley> i need to fix i bug i think
<fowl> write a lolcat in ruby
<arphen> puts "a lolcat"
<arphen> done
S1kx has joined #ruby
S1kx has joined #ruby
<arphen> on the serious side, i like ruby better every day
<swarley> fowl, the gem for the lolcat i made is lulzcatz
<swarley> because lolcat is taken by that program that makes rainbow text..
<swarley> i dont see the relationship really.. but whatever
<Gekz> cat, the concatenation program
<Gekz> in a lol way.
<Gekz> that's the relationship.
<fowl> lol
<fowl> cool
<davidcelis> fowl: gem install lolcat
<swarley> no
<swarley> gem install lulzcatz
<swarley> #1
<swarley> lol
<davidcelis> $ ls -al | lolcat
<davidcelis> profit
<swarley> no
<swarley> my lolcat actually makes lol cat text :[
<swarley> not rainbow text
<davidcelis> sux
<Ontolog> any way to get a stacktrace when ruby itself crashes?
Kichael has joined #ruby
<swarley> uhh
<swarley> yeah it prints it all
<swarley> lol
shadoi has joined #ruby