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
<gurugeek_>
Axsuul: many thanks you rock :P
<gurugeek_>
shadoi: thank you too
<rking>
Naming question here. If you have like a thingeroo that is the signal to skip a computation and use the cached results, what is it called? Like the timestamp of a .c file for a Makefile, or the status bar of my IRC client (when it is unchanged, I don't switch to IRC. When it is changed, I do switch).
<rking>
There has to be a good name for this, it's surely a common pattern. A real-life example may be a kitchen timer: if timer.status == previous_status; return end
PragCypher has joined #ruby
Araq has joined #ruby
MasterIdler_ has joined #ruby
<rking>
That might be a better way to describe it, in code: It's of the form: previous = obj.property; ... loop do if obj.property == previous; puts "Time to wake up!" end end
<rking>
I guess I can call it previous_status. =\
<gurugeek_>
dumb question if In bash I have dscl . -create /Users/$USER
<gurugeek_>
how do I put the variable that is user in ruby ?
<rking>
gurugeek_: You mean like ENV['USER'] ?
<gurugeek_>
just /Users/user ?
<gurugeek_>
rking: no the variable user
<gurugeek_>
user = ARGV[0]
<rking>
Oh, so your script is the "dscl"?
<gurugeek_>
no that is the command line command
<gurugeek_>
like useradd on linux/bsd
<rking>
I am lost in the apple sauce.
<gurugeek_>
ah I guess is #{user}
tommyvyo has joined #ruby
<rking>
Ok. =)
<Axsuul>
rking: hmm i still don't understand your scenario lol
pokui has joined #ruby
<rking>
Axsuul: OK, the reason I'm having a hard time naming it is probably exactly the same as why I'm having a hard time describing it.
<rking>
Axsuul: The issue is that I have an expensive operation that I don't want to perform unless a certain indicator tells me it's time to.
<rking>
Axsuul: I'll tell you the exact scenario, maybe that will help. =)
<Axsuul>
denysonique: sweet, when will it be ready? I really like Shoes DSL ツ
dalkor has joined #ruby
luckyruby has joined #ruby
ZachBeta has joined #ruby
<rking>
I'm writing a bit of code for a 3D editing program, and only when the topology changes (that is, when there are new faces, edges or verts) is it time for me to run a big function that analyzes the topology for mistakes. I am in a situation where my code is hooking into a busy-loop, so I don't want to do the full analysis on each iteration, I only want to compare the vert/edge/face count to see if it's time to run the checks or not.
<Vert>
Aww, I thought I had a highlight then. =(
<rking>
Vert: LOL
<rking>
Oops.
<Vert>
:p
<Axsuul>
rking: hmm, how about.. topology_changed
<rking>
Vert: If it is any consolation, when I IRC from my cell phone (using AndroIRC), it makes an audible chime every time somebody says "it's not working".
<banisterfiend>
rking: use AndChat instead, much better than AndroIRC IMO
<Vert>
rking: Oh wow. :D
<rking>
Axsuul: But that's the thing - it's not storing the changedness. It's storing the counts of the elements and some other stuff.
williamcotton_ has joined #ruby
<rking>
banisterfiend: Wonderful to know. I did a simplistic search. Thank you.
<Vert>
Yeah AndChat is pretty good.
<banisterfiend>
rking: maybe you can use an observer pattern?
Guedes has joined #ruby
Guedes has joined #ruby
<shadoi>
gurugeek_: if you just want a ruby version here's one: ruby -e 'puts %x(dscl . -list /Users UniqueID).lines.map(&:split).sort_by{|u|u[1]}.last[1].to_i + 1'
<rking>
banisterfiend: Let me dust off my GoF knowledge.
<banisterfiend>
or some kind of notification center system
CCCPSpy has joined #ruby
<rking>
Wow. WTG Wikipedia, using crufty Java code for the example.
<rking>
banisterfiend: Even within such a system I would still have to name this thingeroo.
<scientes>
rking, then change it, it IS wikipedia after all
<rking>
It's almost a status_hash
<gurugeek_>
in ruby command line you would do add_user << "-s #{shell} " to pass a command right? so how would you pass a raw command line command from a ruby script
<gurugeek_>
I did dscl . -create << "/Users/#{user}" and got like undefined local variable or method `dscl' :(
<rking>
scientes: I seriously might. What part of this helps you understand the Observer pattern?: if (arg instanceof String) { resp = (String) arg; System.out.println("\nReceived Response: "+ resp ); }
<rking>
As far as I can tell that is only this: def foo arg; puts arg end
<shadoi>
gurugeek_: in ruby you'd do %x(dscl . -create /Users/#{user})
<juul>
I've seen code like this around: name: 'value'
<juul>
what does that mean? is it equivalent to: :name => 'value' ?
<seanstickle>
It's the new style of :name => 'value'
<juul>
oh, from which version and up?
<seanstickle>
1.9
<juul>
is the old style deprecated?
<seanstickle>
Nope.
CodeFriar has joined #ruby
<juul>
so I should be able to do {foo: 'bar'} in any 1.9 ruby?
nari has joined #ruby
<seanstickle>
Yup
<juul>
because tryruby.org reports "1.9.2" when i type RUBY_VERSION
<antillas21>
juul: {foo: 'bar'} works the same as {:foo => 'bar'}
<juul>
and if I type {foo: 'bar'} then it says "the code you submitted is not valid ruby"
<seanstickle>
juul: I dunno what to tell you
<seanstickle>
juul: I don't know how tryruby works
<juul>
ok
<juul>
thanks for the help :)
<denysonique>
banisterfiend: Thank you
<denysonique>
hmm
<denysonique>
How do I find the last method in a chain?
<denysonique>
e.g. Method.foo.bar
<denysonique>
err
<denysonique>
Class.foo.bar
<denysonique>
bar is the last method
<denysonique>
How can I detect that bar is last?
<denysonique>
In the definition of bar
<banisterfiend>
denysonique: u dont, u just check whether it's been passed a block
<denysonique>
hmm
<banisterfiend>
denysonique: what are oyu trying to do
<denysonique>
But somtimes I would like to do User.find(1)
<denysonique>
and have it displayed in irb
<denysonique>
Rails can do this
<denysonique>
ActiveRecord
<denysonique>
I do not need pass a block
<denysonique>
banisterfiend: I am writing a scraper and developing a nice API for it
<denysonique>
So for example users can be found by their id
<denysonique>
ids*
<denysonique>
etc
<twelvechairs>
can anyone recommend a decent widget toolkit for ruby that I can run opengl inside????
<denysonique>
twelvechairs: Qt
<denysonique>
QtRuby
<philcrissman>
denysonique: I don't think I understand your actual question. What does activerecord have to do with the question about "the last method in a chain"?
<denysonique>
twelvechairs: also RubyGame maybe will be someting of your interet
Clordio has joined #ruby
<banisterfiend>
denysonique: i have a feeling your mental model is slightly wrong
<denysonique>
philcrissman: ActiveRecord is an example of this
<denysonique>
well
<philcrissman>
denysonique: in Class.foo.bar, bar can't "know" that it is the last method. It just returns whatever it returns...
fmcgeough has joined #ruby
<philcrissman>
denysonique: how is AR an example of this?
<twelvechairs>
denysonique: Thanks for the suggestion. Have you tried others to be able to compare? I've been using GTK but its giving me problems
<denysonique>
twelvechairs: yes
<denysonique>
Qt is the best so far
<denysonique>
which is also cross platform
Divinite has joined #ruby
<denysonique>
twelvechairs: I can help you with QtRuby if you have any probems
<denysonique>
problems*
<philcrissman>
denysonique: a method has a return value. If you chain methods, each successive method is being called on whatever object the previous method returned. None of the methods "know" that they are even in a "chain". As far as the method is concerned, it is called on an object, and it returns something.
<denysonique>
yep
<denysonique>
ok
<denysonique>
hmm
<philcrissman>
denysonique: I'm just not getting your question, I guess. :/
<denysonique>
I will ask again (;
<philcrissman>
lol
<twelvechairs>
denysonique, : thanks. will give it a look
KnowTheLedge has joined #ruby
kpshek has joined #ruby
Ontolog has joined #ruby
adeponte has joined #ruby
flaccid has joined #ruby
<flaccid>
is it possible for irb to accept a script by stdin? i have a basic multiline
<twelvechairs>
denysonique: have you ever used qt with opengl inside?
dbgster has joined #ruby
<denysonique>
twelvechairs: nope, but give it a try, it shouldn't take you longer than 10 minutes to test opengl in QtRuby
<denysonique>
philcrissman: The quesiton: How is this accomplished?
<denysonique>
AR lazy evaluates methods. e.g.
<denysonique>
User.where(age: 21).where(gender: 'female') -- the first 'where' adds only an age condition to the underlying SQL query, it does not return an object executing the query. Only the last where actually executes the SQL query.
<seanstickle>
The last where doesn't execute the query either
<seanstickle>
Until you move into all or each or some other processing
<denysonique>
seanstickle: if you run it in Rails console it does
<denysonique>
or in irb
<philcrissman>
denysonique: look at the code; where returns a relation. The method can't "know" whether or not another method will be called on whatever it returns. It can't "know" it's the "last" method in the chain...
<seanstickle>
denysonique: console runs an explicit to_s
<denysonique>
seanstickle: unlike, IRB right?
<seanstickle>
Both do
<seanstickle>
Console is just a spiced-up irb
<seanstickle>
Same with pry
ringotwo has joined #ruby
shadoi has joined #ruby
<denysonique>
hmm
<denysonique>
I probably have made a mistake when checking in irb whether to_s is called on class methods
<banisterfiend>
as a lot of people are really confused about the top level
<denysonique>
this is a very interesting article
maletor has joined #ruby
d2dchat has joined #ruby
<denysonique>
Is there any programming language comparably awesome as Ruby?
<banisterfiend>
denysonique: lots
<seanstickle>
Yes. Many.
<denysonique>
what are they?
<banisterfiend>
smalltalk, lisp, maybe scala
<denysonique>
hmm
<seanstickle>
Lisp. SmallTalk. APL. Forth.
<banisterfiend>
self
<denysonique>
yep, heard of scala and lisp
<banisterfiend>
IO
<monokrome>
Haskell :D
<seanstickle>
Haskell, yes.
<seanstickle>
SML.
<denysonique>
hmm
<seanstickle>
Fortress.
<Sou|cutter>
erlang
<denysonique>
Why is Ruby the mot popular/used of them?
<seanstickle>
More languages than you can shake a stick at.
<seanstickle>
Who says it is?
<denysonique>
ok
<denysonique>
But they are not as awesome, right?
<seanstickle>
What is this, troll hour?
<denysonique>
;>
<denysonique>
no, I am serious
<Sou|cutter>
people in a ruby channel are probably going to enjoy ruby.
Guest71832 has joined #ruby
<seanstickle>
I enjoy Ruby plenty well. But I love APL.
<banisterfiend>
denysonique: i guess ruby is more popular than some of those because rubys syntax is more approachable, but also because it has a decent web framework (rails), so it attracts the enormous retarded clusterfuck of ex-PHP programmers. That isn't a good thing, btw, and is probably the reason so many rails programmers are retards
<denysonique>
banisterfiend: The entry of level is now getting higher and higher
<denysonique>
entry level of Rails*
<denysonique>
hmm
<banisterfiend>
denysonique: popularity != quality btw, remember the spicegirls were once popular :)
<denysonique>
I think that Ruby has the greatest community of most langs. great support + awesome gems
<banisterfiend>
denysonique: so it doesn't make ruby better than lisp/smalltalk just because more people use it
<denysonique>
I can say that Ruby is definitely way better than Python in most cases
<denysonique>
I had programmed in Python before
<banisterfiend>
denysonique: you talk like a noob :)
<seanstickle>
banfoy
wilmoore has joined #ruby
<denysonique>
banisterfiend: well, Python does not have awesome gems/libs. I have used both languages for a while and noticed that Ruby libs are simple and straightforward to use, whereas Python libs are not 'cool'/developer friendly.
<banisterfiend>
denysonique: python has much better libs in some areas
<banisterfiend>
shadoi: i didnt write it and it looks retarded
<shadoi>
okey then :)
<banisterfiend>
shadoi: it looks like one of those sites that mirror stack overflow, but pretend like they're their own site providing a unique service
<banisterfiend>
blergh
<shadoi>
yeah, strange
<banisterfiend>
shadoi: how did u find it
<shadoi>
gem q -rn pry
<shadoi>
:)
<banisterfiend>
shadoi: check out pry-git btw
<shadoi>
will do
<banisterfiend>
i just fixed it up for recent releases
<banisterfiend>
shadoi: u can do shit like: git blame Class#method
<banisterfiend>
you can also do: git diff Class#method
<banisterfiend>
and even, git add Class#method
<Quadlex>
Wow
<Quadlex>
This web service is fucking stupid
<shadoi>
nice, that's a great way to do isolated commits
sbanwart has joined #ruby
darmousseh has joined #ruby
<Quadlex>
The Booking object contains a Location object which contains an Address object which contains several properties each of which are objects, each of which only have an ID and a Value property
<darmousseh>
i have an arel question
<shadoi>
banisterfiend: I'm considering putting pry into all my apps by default and just have it enabled with $DEBUG
<darmousseh>
how do i do a where or clause
<darmousseh>
using arel
<banisterfiend>
shadoi: cool, which plugins do you use?
brngardn_ has joined #ruby
<shadoi>
banisterfiend: none, but I'll use the remote explorer when I do that I think
sm4sh has joined #ruby
<banisterfiend>
shadoi: pry-remote-em ?
<banisterfiend>
that thing is cool
<shadoi>
And I'll be making use of Celluloid and DCell soon so I can toggle debugging in live processes
<shadoi>
banisterfiend: yeah
Synthead has joined #ruby
adamkittelson has joined #ruby
<shadoi>
It'll make tracking issues in production so much nicer.
<banisterfiend>
shadoi: yeah im thinking of rewriting pry-remote-em in celluloid, what are the immediate advantages in celluloid over EM anyway?
<shadoi>
banisterfiend: it just doesn't look like Node.js :)
<banisterfiend>
shadoi: is it all fiber based?
<shadoi>
yeah
<banisterfiend>
shadoi: well that means it cant run on jruby or rbx
<shadoi>
threads with fibers for concurrency
<shadoi>
it can actually
<banisterfiend>
not sure that's good for people who are aiming for broad compatibility in their libraries
<shadoi>
he's done a LOT of work to make it work nicely on both
<banisterfiend>
oh
<shadoi>
pry-remote-em integrated in DCell would be fucking hot shit
<banisterfiend>
shadoi: what is DCELL ?
<banisterfiend>
shadoi: btw 'em' means eventmachine, so maybe they wouldnt be compatible?
<shadoi>
it's the distributed (over zeromq) Celluloid actors
<shadoi>
right, you'd have to rewrite it to use Celluloid::IO
<banisterfiend>
shadoi: it wont be hard to rewrite it for celluloid though
blueadept has joined #ruby
<banisterfiend>
yeah
<shadoi>
definitely not
<shadoi>
it'd probably clean up the code even
<shadoi>
lol
<banisterfiend>
yeah
davidcelis has joined #ruby
<shadoi>
I'm super excited about DCell
<shadoi>
Going to try to work on Paxos leader election and a DNS service registry for it soon.
PragCypher has joined #ruby
Brainix has joined #ruby
<banisterfiend>
shadoi: can u show me some simple celluloid code for a multiplexing echo server/echo client system
<banisterfiend>
shadoi: are people starting to use it yet? also how does performance compare to EM?
<banisterfiend>
not that i imagine there'd be much difference
<shadoi>
Not a huge difference, it's fractionally slower
<shadoi>
But you get a lot more out of it.
<shadoi>
with less effort
<shadoi>
I think quite a few people are getting into it
<banisterfiend>
nice
<banisterfiend>
shadoi: so cool.io is dead now?
<shadoi>
yeah this definitely supersedes it
<banisterfiend>
he should probably announce that on the readme ;) since i didnt know that celluloid::io replaced it
<banisterfiend>
and was considering using it
kvirani has joined #ruby
<shadoi>
he produced it all so quickly… I don't think it's made it out there.
<shadoi>
In fact he published all this stuff while I was rewriting some shit to use cool.io, I was pissed!
<shadoi>
lol
<shadoi>
But it's MUCH more of what I wanted anyway.
<banisterfiend>
shadoi: yeah he seems super productive
__main__ has joined #ruby
Hunner has quit [" "]
stefanp_ has joined #ruby
thiagopnts has joined #ruby
Karmaon has joined #ruby
looopy has joined #ruby
strife25 has joined #ruby
nikhgupta has joined #ruby
LBRapid has joined #ruby
Banistergalaxy has joined #ruby
Brandon1 has joined #ruby
<Brandon1>
test
jergason has joined #ruby
dumptruckass has joined #ruby
dumptruckass has quit ["Leaving"]
PsiliPharm has joined #ruby
thiagopnts has joined #ruby
looopy has joined #ruby
blueadept has joined #ruby
Axsuul has joined #ruby
Paradox2000 has joined #ruby
aj910martin has joined #ruby
stephenjudkins has joined #ruby
sdeobald has joined #ruby
Ontolog has joined #ruby
nlc has joined #ruby
libertyprime has joined #ruby
tbenst has joined #ruby
mikeric has joined #ruby
Brandon1 has quit [#ruby]
knightMBP has joined #ruby
rohit has joined #ruby
thinkswan has joined #ruby
thinkswan has quit [#ruby]
iamjarvo1 has joined #ruby
<iamjarvo1>
has anyone used mailchimp? they have a way that if you add a class to an element it automatically does inline styles on the html element. Does anyone have any clever ways of reproducing this?
<neurotech>
One question right off the bat. Is there a better alternative to PowerShell on windows?
Mon_Ouie has joined #ruby
<neurotech>
This thing is so uglyyy
<Quadlex>
You could install Cygwin
<Quadlex>
But it's kinda aesthetically unpleasing also
<Quadlex>
I do Ruby dev on a MacBook dualbooting
<Quadlex>
And I'm considering just switching to OSX wholesale
<ajayror>
on
<neurotech>
I don't have a mac unfortunately
<neurotech>
I have Lion running in a VM though, on a SSD
<neurotech>
But it's not perfect
<neurotech>
it'd just be nice to have some more colour/font choice
<ajayror>
need help on ruby on rails engine application
rippa has joined #ruby
<TTilus>
mac and linux go way better with ruby than win
<neurotech>
Yeah. :{}
<ajayror>
ror help ?
<Quadlex>
I got a pull request accepted a few week
<Quadlex>
s ago
<Quadlex>
Based on switching an install script from bash to pure Ruby so it'd work on Windwos
stevegozie has joined #ruby
adeponte has joined #ruby
ringotwo has joined #ruby
blueadept has joined #ruby
<banisterfiend>
neurotech: you'll save yourself trouble if you switch to linux/osx for ruby dev now
<banisterfiend>
neurotech: ruby on windows is kind of weird
<neurotech>
banisterfiend: Don't tell me this
<neurotech>
:(
<neurotech>
My PC at work is Windows
<neurotech>
so is my home machine
<neurotech>
Maybe a VM is the answer?
<banisterfiend>
neurotech: you can use ruby on windows, it's just not a nice experience
<banisterfiend>
Yeah use a linux VM
<neurotech>
What distro would you recommend?
senthil has joined #ruby
<neurotech>
ubuntu 11.10?
<banisterfiend>
neurotech: i just use linux mint
<banisterfiend>
which is pretty much ubuntu i think
<neurotech>
I'll check it out
advorak has joined #ruby
<neurotech>
banisterfiend: Is there something like GitHub for mac, for Linux?
<banisterfiend>
neurotech: i think there's a few git guis
<banisterfiend>
but i just use the command line
<banisterfiend>
command line is fine
<neurotech>
mm
<neurotech>
mint looks great
<neurotech>
nice and neat
<neurotech>
ok back to a ruby question
<neurotech>
Is this the best formula to work out "How many seconds in a decade?" puts 60 * 60 * 24 * 365 * 10
<banisterfiend>
neurotech: that's a math question :) not a ruby question
<neurotech>
That's a great point
<wefawa>
neurotech: do you take into account leap years? and a lot of other minors adjustments?
<neurotech>
I have no idea how I would do that
banjara has joined #ruby
<neurotech>
I'm going through the "Other Things to Try" section on here wefawa :http://pine.fm/LearnToProgram/?Chapter=01
<Quadlex>
Woudln't it be better to do something like "Some Date" - "Some Date - 10 years".to_seconds?
sacarlson has joined #ruby
<neurotech>
probably
<neurotech>
I want to get the basics down first
mikeric has joined #ruby
<neurotech>
never coded before, outside of html/css/js
kah_ has joined #ruby
thiagopnts has joined #ruby
thiagopnts has joined #ruby
vermutt has joined #ruby
<denysonique>
hmm
<denysonique>
ActiveSupport should have someting like 10.years.in_seconds
<wefawa>
enysonique: I really dislike that "convention", but yes...
<Gekz>
wefawa: putting methods on integer literals?
<Gekz>
it has always erked me a little
<Gekz>
it feels a bit satanic.
<wefawa>
Gekz: it's not satanic... It's just an awfull design practise...
<Gekz>
of course it's satanic, it reads well, but you know you shouldn't do it
moshee has joined #ruby
moshee has joined #ruby
kah_ has joined #ruby
ninor has joined #ruby
sacarlson has joined #ruby
jergason has joined #ruby
banjara has quit [#ruby]
jrhorn424 has joined #ruby
vermutt has quit [#ruby]
<jrhorn424>
any reason irb should choke on reading a 90meg json file? ruby had virtual mem up to 10G and real memory up to 6G before I quit. `f = File.read('foo.json')`
savr has joined #ruby
<savr>
hi
<savr>
bundle install is asking me for my password
<savr>
which password is this?
<savr>
because my user password is saying try again
<savr>
:O
Morkel has joined #ruby
<savr>
hmm
kah_ has joined #ruby
<savr>
it is meant to be my password as I can see from the sudo attempt
Banistergalaxy has joined #ruby
nat2610 has joined #ruby
<savr>
okay
yxhuvud has joined #ruby
savage- has joined #ruby
<savr>
problem with the sudoers file
<savr>
sorry!
savr has quit [#ruby]
banjara has joined #ruby
sonkei has joined #ruby
banjara has quit [#ruby]
arturaz has joined #ruby
fayimora has joined #ruby
gen0cide_ has joined #ruby
nikhgupta has joined #ruby
hooper has joined #ruby
JohnBat26 has joined #ruby
seivan has joined #ruby
raincole__ has joined #ruby
alvesjnr has joined #ruby
a_a_g has joined #ruby
dzhulk has joined #ruby
blast_hardcheese has joined #ruby
Banistergalaxy has joined #ruby
nerdy_ has joined #ruby
GoBin has joined #ruby
Synthead has joined #ruby
ringotwo has joined #ruby
Boohbah has joined #ruby
savr has joined #ruby
<savr>
You cannot specify the same gem twice with different version requirements. You specified: mysql2 (~> 0.3.6) and mysql2 (>= 0)
<savr>
I have mysql and sql in the gemfile
<savr>
never mind
<savr>
grep knows better than my eyes!
arturaz has joined #ruby
gurugeek_ has joined #ruby
<neurotech>
How can I make line 3 of this add an integer to the input received in line 2? http://pastie.org/3725133
sacarlson has joined #ruby
zommi has joined #ruby
voodoofish has joined #ruby
savr has quit [#ruby]
x0F_ has joined #ruby
heftig has joined #ruby
wefawa has quit [#ruby]
djdb has joined #ruby
artm has joined #ruby
arturaz_ has joined #ruby
CheeToS has joined #ruby
Hsparks has joined #ruby
wolgo has joined #ruby
<wolgo>
is there a ruby synonym for Perl's print blah if =~ /something/
ozymandius has joined #ruby
a_meba has joined #ruby
<a_a_g>
wolgo: print blah if str =~ /something/ should work
<Mon_Ouie>
print blah if /something/, though that's not really recommended outside of an one-liner
Tearan has joined #ruby
<wolgo>
ahh
<wolgo>
there is no $_
<Mon_Ouie>
There is
<a_a_g>
there is actually
<Boohbah>
there is $_
<a_a_g>
but it is not as universal as perl
<a_a_g>
only a few function from the Kernel module use and set $_
<banisterfiend>
wolgo: also too convenient for regex captures
daniel_hinojosa has joined #ruby
<banisterfiend>
$1 $2 $3 etc
<banisterfiend>
they're just too tempting, whether they're perlish or not ;)
<banisterfiend>
i think everyone uses them
<Boohbah>
awk-ish
mxweas_ has joined #ruby
provideal has joined #ruby
<provideal>
hey Folks, is there a reasonably recent gem to handle tar archives? We tried tarruby, but that segfaults all the time.
gokul has joined #ruby
<wolgo>
thanks guys
<wolgo>
I figured it out
<wolgo>
I have to be a little less Perly
<wolgo>
but
<wolgo>
ruby kicks ass
<wolgo>
(like every other programming language I just start using)
<wolgo>
lol
<banisterfiend>
wolgo: what other langs ?
shruggar has joined #ruby
workmad3 has joined #ruby
Eartz has joined #ruby
sspiff has joined #ruby
sspiff has joined #ruby
Houdini has joined #ruby
Divinite has joined #ruby
djabbour has joined #ruby
<djabbour>
If i have a method name I want to call in a symbol, how can I evoke it? I know send allows me to send to an object, but what about just calling a method?
<djabbour>
(without knowing the specific object I want to send to)
<arturaz>
obj.send :method_name
<arturaz>
or do you mean a global method, like puts?
<arturaz>
jruby-1.6.6 :001 > send :puts, 3
<arturaz>
3
<arturaz>
=> nil
schovi has joined #ruby
<arturaz>
global methods are defined on Kernel, which in turn is included in Object
<arturaz>
so they are available on every object
<djabbour>
arturaz, ah, what if I don't know the context of the method though- like it can be on any object, but I know it's in scope
<arturaz>
so how are you planning to call it on? :)
nim_ has joined #ruby
<arturaz>
i mean you actually still are going to call that method on some object
<arturaz>
right?
<djabbour>
arturaz, argah, damn rails magic going on. Not sure if it's a class or instance method
<arturaz>
doesn't matter :)
<djabbour>
arturaz, maybe I should bug the rails guys- but I am in a helper trying to metaprogram calling other helper methods
<djabbour>
but they can be on any helper
<arturaz>
helpers are modules, IIRC
<arturaz>
and they're mixed into view class
<arturaz>
so send(:your_method) should work just fine
<djabbour>
ah I tried that but it gave me an undefined method (hence asking the question) on my object
<djabbour>
I've actually got a helper initializing an object
<djabbour>
inside that object I'm making this send
<djabbour>
i'm confident the call works without using send/metaprogramming
<djabbour>
hence scratching my head
<djabbour>
i mean I suppose I could eval it but that'd be a lot slower
<djabbour>
arturaz, am I explaining my situation well enough? like my_helper() do Foo.new end and inside Foo#initialize I've got this send going on
<arturaz>
that send is being called on Foo, not your view class
<arturaz>
pass self to Foo.new
<arturaz>
and do send on it
xastion has joined #ruby
<djabbour>
but then how does making the call without using send work?
<arturaz>
from inside Foo?
<djabbour>
Yup
robbyoconnor has joined #ruby
<arturaz>
try Kernel.send(:yourm)
<arturaz>
but that shouldn't work too
<arturaz>
:]
LMolr has joined #ruby
<djabbour>
yeah it gives me undefined method `link_to' for Kernel:Module
aj910martin has joined #ruby
<djabbour>
(i'm trying to call link_to in this case)
<shevy>
now we know that Kernel does not have a method called link_to
<djabbour>
lol indeed
<arturaz>
it shouldn't really work inside Foo too
<arturaz>
are you sure it works?
<djabbour>
arturaz, yeah lol
<djabbour>
arturaz, I can access all the rails helpers in there- content_tag, etc, use them all over my class
<arturaz>
I have no idea how that might be happening :)
<arturaz>
try __send__
<shevy>
rails loves to remain mysterious
<djabbour>
arturaz, alright thanks for the help anyhow. I'll do some playing
<arturaz>
perhaps send is overriden
<djabbour>
shevy, that it does
<arturaz>
thats why I started disliking rails :)
<arturaz>
it was quite simple in the begining
<djabbour>
I can understand that argument
a_a_g has joined #ruby
<arturaz>
now its full of magic
<shevy>
my theory is that good projects are able to remain sufficiently small BUT also easy all the time, even on internals
<arturaz>
I even have a file named ar_monkey_squad that monkeypatches activerecord to do my bidding :D
<arturaz>
djabbour, just pass self :)
<arturaz>
this magic is not good for your code readability anyway
<djabbour>
arturaz, if I can avoid passing self I'll try- if not I will resort to that heh
<arturaz>
its good design to pass that explicitly
<arturaz>
imagine if other coder comes
<arturaz>
and wonders - how these methods are called
<arturaz>
where are they defined?
<arturaz>
with dynamic typing you have no way of finding that out
<shevy>
other coders are already screwed
<shevy>
the best is to document your own things properly
<shevy>
also don't shy away from cursing at rails in the comments
<shevy>
:>
gregorg has joined #ruby
gregorg has joined #ruby
<arturaz>
hehe
<arturaz>
its ironic: rails brought my to ruby, now I sort of loathe it
<arturaz>
its load time is abysimal
<arturaz>
no tdd without spork for you!
<arturaz>
oh, wait, no spork on jruby? well, screw you.
<arturaz>
bah.
<shevy>
hmm
akemrir has joined #ruby
<djabbour>
oh weird, it works with send() with content_tag but not link_to
<djabbour>
wtf, they're both ActionView::Helpers
InBar has joined #ruby
<shevy>
you are slowly digging deeper into the real magic at hand
<arturaz>
djabbour, let me explain this
<arturaz>
the only ways for method to appear in object are
<shevy>
magic
<arturaz>
1) you define it, either via def/define_method
<arturaz>
2) you include a module into it
<shevy>
hmm
<arturaz>
3) you define your methods in Kernel (or main scope, which is Kernel). Because every Object includes Kernel, see point 2)
<arturaz>
4) method_missing
<arturaz>
thats it
<shevy>
could you do a proc, that acts like a module, and send that proc to your object, and eval it?
<arturaz>
shevy, you probably could :)
<arturaz>
at least with define_method and instance_eval
<shevy>
subclassing via procs, multiple inheritance via procs! perhaps even using the -> operator
<arturaz>
why use modules when you can reinvent them!
<shevy>
not "reinvent", that is a positive word
<shevy>
I want to BYPASS them :)
<shevy>
I'd also never want to use that, if it works... via procs
<shevy>
somehow I dont like magic
<djabbour>
Ahha! I got it. And it's because i'm slightly retarded.
<djabbour>
I forgot I wrote a base class that included TagHelper
<shevy>
you finally entered the required state of mind to understand magic
<arturaz>
heh
etehtsea has joined #ruby
<shevy>
but I am also losing track sometimes
<shevy>
I think my largest project has around 50 classes and 120 .rb files... and about 20 yaml files ... and some more docu files
<shevy>
I am not even sure anymore that classes are the way to go :(
<w400z>
rubyists, whenever you are scraping for images, make sure you use "wb" for binary mode. That is all….
dalkor has quit [#ruby]
Banistergalaxy has joined #ruby
KL-7 has joined #ruby
<arturaz>
helpful tip is being helpful
PragCypher has joined #ruby
jenglish has joined #ruby
_null has joined #ruby
moshee has joined #ruby
moshee has joined #ruby
ukwiz has joined #ruby
shruggar has joined #ruby
eka has joined #ruby
ephemerian has joined #ruby
rcs has joined #ruby
BiHi has joined #ruby
aj910martin has quit [#ruby]
tvw has joined #ruby
akemrir has joined #ruby
<shevy>
lol
<shevy>
crappy tip is being crappy
<shevy>
I dont think I ever had to scrape for images in my 7 years of ruby. unlikely I will ever have to do that either
akemrir has joined #ruby
moshef has joined #ruby
jlebrech has joined #ruby
akemrir has joined #ruby
emmanuelux has joined #ruby
gyre007 has joined #ruby
blacktulip has joined #ruby
davidpk has joined #ruby
zunnyohn1 has joined #ruby
simao has joined #ruby
alem0lars has joined #ruby
tatsuya_o has joined #ruby
robbyoconnor has joined #ruby
trivol has joined #ruby
mdw has joined #ruby
<JohnBat26>
hello all
<JohnBat26>
How can I see memory leak in ruby C gem ?
<JohnBat26>
I have six resque jobs and see memory leaks in system memory
<JohnBat26>
If I kill resque jobs memory leak keep
<alem0lars>
I'm using sinatra and dm-redis-adapter. When I try to connect to a remote redis instance, I get a Timeout::Error, but connecting via redis-cli works. What could be the issue?
<shevy>
especially when you compare this to how he looked 5 years ago!
<vectorshelve>
shevy: awww that scared me off
alem0lars_ has joined #ruby
nyuszika7h has joined #ruby
<shevy>
or in athletics, when you see women with dental braces suddenly... it is because the roids cause the jaw to become more massive. like Marion Jones did during her time
<shevy>
doping killed sports a long time ago :(
<shevy>
vectorshelve when will you start to learn ruby?
<vectorshelve>
shevy: the day you start teaching me dear ;)
<shevy>
nah it won't work like that, because you would lack INNER motivation for the task
<shevy>
it's like why I can't learn C ...
<shevy>
I blame ruby
<shevy>
vectorshelve, good that you don't learn ruby, it would just spoil you
<vectorshelve>
shevy: then I should blame my girlfriend for my over obsession with her
<shevy>
yes
<shevy>
there goes your time
<shevy>
:D
<vectorshelve>
I just dont feel like doing anything else than being with her.. she is to me more than what ruby is to you :)
<shevy>
hey banisterfiend ... would you like me more if my jaw would be twice as massive as it is right now?
<shevy>
vectorshelve yeah, the thing is, I am a doer. Things must be done. Just as Alan Kay said ... "The best way to predict the future is to invent it."
<shevy>
I am just picky at what has to be invented
<shevy>
a new programming language would be neat
<jlebrech>
yield if block_given?
<vectorshelve>
shevy: I always wanna develop something be part of something construtice.. I hate testing job and I want hard cash :) love my girl and be happy
<shevy>
jlebrech that will trigger optionally (and only) if a block is given
<shevy>
jlebrech I usually use the "yield if block_given?" rather than just "yield" alone
<jlebrech>
shevy that what i want :)
<shevy>
vectorshelve I think you are a happy person :)
<shevy>
I am not. I am not content with how things are anywhere. Progress depends on the unreasonable man.
<shevy>
90% of everything sucks. 9% is ok. The remaining 1% is however really awesome.
<shevy>
90% of my code sucks too :(
<shevy>
I am unconvinced that I reach the 1% of total awesomeness in my code so far
<vectorshelve>
shevy: but u got to understand that things arent always in your control and a single soul cannot change the fortunes of a million ones until they feel that themseleves
<shevy>
even something as simple as reporting issues is nice and easy, compared to i.e. sourceforge
<Divinite>
Well, in most cases, 99% of stuff sucks, and 0.9% of stuff is alright. Only 0.1% of stuff is good.
<shevy>
I think I reported... about 12 times at sourceforge. I could not tell you how much of that was ignored... perhaps 80%. On github... I reported about ~15 things so far. In 90% I got feedback
<shevy>
yeah Divinite
<shevy>
I just squeeze in some things I think are cool. like Biology!
<shevy>
vectorshelve I cant read that
<vectorshelve>
shevy: why ?
<shevy>
vectorshelve I am too surprised why people in Pakistan even accept their "government"
<shevy>
well
<shevy>
you could replace the names of any individual and things would be pretty much the same
<vectorshelve>
shevy: I am not from pakistan
<vectorshelve>
shevy: they dont accept they atre too fragile for a revolution
<shevy>
hmm
twinturbo has joined #ruby
<shevy>
perhaps they are too reasonable, I'd be angry all the time
<vectorshelve>
shevy: they are oppressed suppresed and depressed
<shevy>
I wake up, I read news, and I get angry.
<vectorshelve>
shevy: the afghanistan condition is terrible.. even somalia.. two most volatile nations of the world today
<shevy>
yeah the afghans have it bad too
<shevy>
they go from wartime to wartime to wartime
Houdini1 has joined #ruby
jenglish_ has joined #ruby
sacarlson has joined #ruby
johndbritton has joined #ruby
heftig has joined #ruby
waxjar has joined #ruby
jenglish has joined #ruby
<vectorshelve>
shevy: afghan girls are beautiful... infact arab girls ;)
kp666 has joined #ruby
<shevy>
hard to see under all that veil
<shevy>
hmm I have to leave here... should be back in an hour
rohit has joined #ruby
Banistergalaxy has joined #ruby
buschhardt has joined #ruby
gokul has joined #ruby
gomix has joined #ruby
Whoop has joined #ruby
mcero has joined #ruby
beilabs has joined #ruby
artm has joined #ruby
r0bby has joined #ruby
norm_ has joined #ruby
ddoucette has joined #ruby
axl__ has joined #ruby
irration_ has joined #ruby
bluenemo has joined #ruby
y3llow_ has joined #ruby
jenglish_ has joined #ruby
sectionme has joined #ruby
Sigma00_ has joined #ruby
elliot_ has joined #ruby
Danielpk|rdlBNC has joined #ruby
ewag_ has joined #ruby
mtkd_ has joined #ruby
Nanuq_ has joined #ruby
kp666_ has joined #ruby
alienven1m has joined #ruby
banisterfiend has joined #ruby
alvesjnr_ has joined #ruby
Corey_ has joined #ruby
Freijo has joined #ruby
wolgo_ has joined #ruby
csamuelson has joined #ruby
akhkharu_ has joined #ruby
mlue_ has joined #ruby
beha has joined #ruby
methodfree has joined #ruby
falena has joined #ruby
djdb_ has joined #ruby
fjfish has joined #ruby
Yappo____ has joined #ruby
tomku|two has joined #ruby
zigidias_ has joined #ruby
zigidias has joined #ruby
Axsuul has joined #ruby
artm has joined #ruby
kuzushi has joined #ruby
sohocoke has joined #ruby
buschhardt has quit [#ruby]
savr has joined #ruby
<savr>
hi
<savr>
#capistrano seems dead but maybe someone here can help
<savr>
before I added/committed my deploy.rb and Capfile
<frontendloader>
Is there a self-contained alternative to amqp+rabbitmq? I'm only running one process with 10 threads tops and just need to message between those threads.
jenglish has joined #ruby
s1n4 has joined #ruby
<frontendloader>
I suppose EventMachine::Queue satisfies what I'm asking for at a basic level
visof_ has joined #ruby
niku4i has joined #ruby
sectionme has joined #ruby
stoor has joined #ruby
mengu has joined #ruby
s1n4 has joined #ruby
<banisterfiend>
frontendloader: look at celluloid too
dbgster has joined #ruby
<banisterfiend>
frontendloader: it seems pretty featureful
Indian has joined #ruby
stoor has quit [#ruby]
<vectorshelve>
savr: ask this question in #rubyonrails room
<savr>
ok
<vectorshelve>
Indian: are you an indian ?
irrationalfab has joined #ruby
banisterfiend has joined #ruby
heftig has joined #ruby
josephwilk has joined #ruby
alem0lars has joined #ruby
<Spaceghostc2c>
Indian: Are you a native of some place that isn't India?
<linduxed>
now i understand what it does, but even with that explanation i have no understanding of how it works
<linduxed>
:-)
<linduxed>
as in, now i can use it, but the entire proc thing is beyond me
<philcrissman>
linduxed: it's converting the symbol to a Proc which it will pass in a block (directly paraphrasing Dave)... so array.map(&:value) is the same as array.map{|a| a.value}
<philcrissman>
linduxed: if it helps, nevermind the Proc aspect, for now. :) Think of it as translating to a block, as above. Think of the symbol as becoming a method.
<linduxed>
haha, sounds fair
bananastalktome has joined #ruby
iamjarvo has joined #ruby
<philcrissman>
linduxed: and the .reduce(&:+) in the example you started with, would be equivalent to reduce{|sum, n| sum + n} (see the inject/reduce docs if that's still unclear. :)...
nari has joined #ruby
jenglish has joined #ruby
<linduxed>
i know what inject does (and that reduce is an alias), but i'm a bit confused as to how it manages to skip the start value for inject
ickmund has joined #ruby
<linduxed>
i'm just assuming that there's magic going on adding a zero as start value there somewhere
Morkel has joined #ruby
nanderoo has joined #ruby
torpor has joined #ruby
<torpor>
hi
chrassidy has joined #ruby
<torpor>
how do I do this: somestring = result_of_funct() or ""
<torpor>
so that if result_of_func() = nill, an empty string is assigned instead?
<chrassidy>
Is ruby a good language for a modular, game server backend?
<chrassidy>
I plan on writing an API that will allow a java (android app) client to connect to the server
<torpor>
chrassidy: yes
<chrassidy>
alright
<beeneto>
you ask that in the ruby channel? :p
<rippa>
torpor: yes, you do it like that
<chrassidy>
what database software do you suggest?
<torpor>
rippa: doesn't seem to work, i get a nil object
<rippa>
try || then
<torpor>
ok
<torpor>
nope, still get "can't convert nil into String", damn.
strife25 has joined #ruby
<torpor>
oh wait it works.
<torpor>
:)
<philcrissman>
linduxed: in the inject case, it's implicitly summing from zero.
sohocoke has joined #ruby
<torpor>
another dumb question: how do i force something to string?
<torpor>
is it just string(something)?
<philcrissman>
linduxed: just like if you call it with the block and no start value. If you needed a non-zero start value, afaik you'd need to use the block format: eg, [1,2,3].inject(5){|s,n| s+n} => 11
<philcrissman>
torpor: usually whatever.to_s
<torpor>
ok thanks
Synthead has joined #ruby
troessner has joined #ruby
<_ack>
Can a class method change his implementation once executed?
<apeiros_>
(at work, though, so not very responsive)
<banisterfiend>
apeiros_: do u have yard installed?
<banisterfiend>
np
<troessner>
neohunter, your question wasn't smart, see the SO answer so far
mengu_ has joined #ruby
<apeiros_>
sure
theishi has joined #ruby
<troessner>
-> blablub # ERROR
<canton7>
neurotech, what's the answer to the question which Simon Woker posted?
<troessner>
that's not helpfull
linoj has joined #ruby
Nathandim has joined #ruby
<theishi>
I have a method that I want to call, that I didn't write, and I want to find out how many arguements it will take, and what the names of these arguments are... how can i do this?
<troessner>
you can look up the api docs for Method, i am pretty sure there is more usefull stuff in there
<troessner>
:-)
<theishi>
Yeah i guess. It isn't well documented though
<canton7>
neohunter, looks like the t.user.to_hash hash contains an id field, which you're not allowed to assign
<neohunter>
canton7: yeah, i know that, but how i can do that? i need to create a hash with each field? {:description => t.user.description, :screen_name => t.user.screen_name ....and so on?
shaggy2dope has joined #ruby
kvirani has joined #ruby
<canton7>
neohunter, you can unset the :id key
thiagopnts has joined #ruby
netrealm has joined #ruby
<canton7>
neohunter, or, better, you could just select the keys you want
thiagopnts has quit [#ruby]
banisterfiend has joined #ruby
<neohunter>
canton7: so manually create the hash. ok i will do that
<neohunter>
cause now im receiving this error: ActiveRecord::UnknownAttributeError: unknown attribute: id_str
<neohunter>
they are keys that i dont have on model..
<neohunter>
i though if key doesnt exist it just got ignored but dont works that way
jitesh_shetty has joined #ruby
<philcrissman>
neohunter: where is id_str coming from?
<canton7>
neohunter, I was thinking more along the lines of Hash#reject or Hash#select
<banisterfiend>
apeiros_: do you have yard installed?
<neohunter>
philcrissman: id_str is one key from Twitter::User from twitter gem
<neohunter>
canton7 mmmm hash select, interesting, let me read aboutit
t0mmyvyo has joined #ruby
<philcrissman>
neohunter: ok. But if it's not an attribute in your model, you can't just pass it to the model... But I guess you've seen that. :)
<canton7>
neohunter, t.user.to_hash.select{ |k,v| [:field, :another_field.include?(k) } or so
<apeiros_>
banisterfiend: yes, "sure" I said before already ;-)
<canton7>
ahem, with an added ] in the right place
<banisterfiend>
apeiros_: sorry bad internet
<apeiros_>
beat it!
mrwalker has joined #ruby
<apeiros_>
canton7: yay! :-S
<apeiros_>
canton7: there's no Symbol#include? :-p
nuby has joined #ruby
<banisterfiend>
apeiros_: try this in irb: YARD::Parser::Ruby::Legacy.constants(false)
<any-key>
it wants you to wrap it in a function or something
<any-key>
I dunno
<any-key>
they provide absolutely no clues as to what you're supposed to actually type in
CannedCorn has joined #ruby
<philcrissman>
askTheUser: you're just supposed to type in the method from the blank.
<philcrissman>
in that one, upcase
<askTheUser>
oh
<askTheUser>
thanks
<philcrissman>
askTheUser: there is a "help" link right up top. ;)
<any-key>
that's stupid
<askTheUser>
hahah
<askTheUser>
:P
asobrasil has joined #ruby
<philcrissman>
any-key: it didn't seem intuitive to me either... but it is pretty clear in the "help" page.
jgarvey has joined #ruby
<philcrissman>
so, maybe it's good to read the help page. ;)
<any-key>
it's against my personal policy to click "help" links
strife25 has joined #ruby
<philcrissman>
any-key: yeah, I hate learning things too
<any-key>
it's the worst
<philcrissman>
:/
nu7hatch has joined #ruby
Aristata has joined #ruby
uris has joined #ruby
yoklov has joined #ruby
phantasm66 has joined #ruby
kevinbond has joined #ruby
brngardner has joined #ruby
nlc has joined #ruby
LBRapid has joined #ruby
blueOxigen has joined #ruby
fearoffish has joined #ruby
bbttxu has joined #ruby
__main__ has joined #ruby
stevegozie has joined #ruby
crankycoder has joined #ruby
td123 has joined #ruby
bluOxigen has joined #ruby
* shevy
presses the any-key
EzeQL has joined #ruby
EvanR has joined #ruby
jlogsdon has joined #ruby
IrishGringo has joined #ruby
shift_ has joined #ruby
EvanR has joined #ruby
Aristata has quit [#ruby]
waxjar has joined #ruby
Bofu2U has joined #ruby
gurugeek_ has quit [#ruby]
luxurymode has joined #ruby
kpshek has joined #ruby
<Spaceghostc2c>
shevy: where u hied mai eny-kee?
KL-7 has joined #ruby
<shevy>
I dunno, I cant find it myself!
Ryougi_Shiki has joined #ruby
tobago has joined #ruby
roolo has joined #ruby
bawer has joined #ruby
fr0gprince_mac has joined #ruby
axl_ has joined #ruby
<robert_>
hai shevy :D
lkba has joined #ruby
dfibre has joined #ruby
lorandi has joined #ruby
snip_it has joined #ruby
eka has joined #ruby
cezar_ has joined #ruby
red5 has joined #ruby
<red5>
what's the last version of ruby ? 1.9.3-p125 ?
PragCypher has joined #ruby
<banister_>
red5: ya
ckrailo has joined #ruby
lateau has joined #ruby
<red5>
banister_: awsm !
red5 has quit [#ruby]
cachoimechi has joined #ruby
rndm has joined #ruby
dql has joined #ruby
bbttxu_ has joined #ruby
<rndm>
so i put some stuff in app/bin and some other stuff in app/lib. what's the best way for something in app/bin to require a file in app/lib?
yoklov has joined #ruby
liluo has joined #ruby
PaciFisT has joined #ruby
alek_b has joined #ruby
zunnyohn1 has joined #ruby
maximumgeek has joined #ruby
jcromartie has joined #ruby
Gushings1 has joined #ruby
<Gushings1>
Hello
fayimora has joined #ruby
<Gushings1>
I have a couple questions.
rippa has joined #ruby
Poapfel has joined #ruby
<Gushings1>
I commonly see the format .each{|somevalue| somecommand()} used in place of a for loop in ruby
BiHi has joined #ruby
<Gushings1>
Is there any sort of general style guideline for when to use for vs each?
<maximumgeek>
I don't know.
atnight has joined #ruby
<maximumgeek>
I tend to go with 'for' x in 'bleh'
<maximumgeek>
but that is just me
<Gushings1>
yeah, that's what I felt like doing naturally as well
CheeToS has joined #ruby
<bawer>
I think that people new to ruy tend to use the for..in construct
dcolebatch2 has joined #ruby
n1x has joined #ruby
<Gushings1>
My other issue, which is more important, is that I have a TCPServer which I am using select() on to get the sockets that are available for reading.
<geekbri>
if there is an object, with a member who is a hash. Is there a way to extract just that hash into a new object? myobject.myhash.clone ?
andrewhl has joined #ruby
<Gushings1>
However, when I use descriptor.gets(), I can get blocked by sockets that have not terminated their input with a newline.
<Gushings1>
I've looked at timeouts but I don't like the solution.
<maximumgeek>
Gushings1, what language are you coming from?
<Gushings1>
C, Java, Scheme, Python
davidpk has joined #ruby
<Gushings1>
I'm wondering if getsc inside a while loop could work.
IrishGringo has joined #ruby
[-mX-] has joined #ruby
<Gushings1>
or read_nonblock loops promising.
iocor has joined #ruby
looopy has joined #ruby
<Synthead>
if I were to open an ssh forward within a ruby script, is there some weird gem or something I could use, or should that be done as an `external command` ?
DrShoggoth has joined #ruby
elhu has joined #ruby
ales has joined #ruby
<canton7>
Synthead, I believe Net::SSH can do that
<fearoffish>
Gushings1: personally I use each all the time, it's more of a ruby-ism than a for loop
<fearoffish>
as for read_nonblock, no idea, never used it :)
MasterIdler has joined #ruby
porco has joined #ruby
<canton7>
Gushings1, gets can take an argument saying what the delimeter is
<Gushings1>
Is it acceptable to have 5-10 lines of code inside an each block?
<canton7>
Gushings1, and the advice is never to use for unless you have to. for doesn't have the scoping that #each has, and it wraps #each underneath anyway
<Gushings1>
canton7 - my issue is that I am reading from a socket. I don't know when or if it will ever successfully send me the delimeter.
<Gushings1>
Right now it's newline.. their socket could have input ready for read but then never send me a newline and I hang waiting for that.
<Gushings1>
If it was a space, the same situation could occur.
<Gushings1>
Is there some delimeter you have in mind?
<canton7>
Gushings1, you can also pass in nil, apparently, which reads everything
<Gushings1>
hm
g0bl1n has joined #ruby
g0bl1n has joined #ruby
<Gushings1>
I'll give it a shot.
<canton7>
Gushings1, or you could use getc to grab the input one character at a time
MasterIdler has joined #ruby
<Gushings1>
I don't understand how it would ever know it received everything.
<Gushings1>
but perhaps there is magic hidden away.
<canton7>
as in, passing nil means that gets will give you everything that's available
<canton7>
*that's currently available
mashed has joined #ruby
synk has joined #ruby
<Gushings1>
interesting
<Gushings1>
Well I hope that works
<Gushings1>
I'll give it a shot
<Gushings1>
thank you.
n1x has joined #ruby
g0bl1n has joined #ruby
schovi has joined #ruby
brianpWins has joined #ruby
johnmilton has joined #ruby
artm has joined #ruby
apeiros_ has joined #ruby
vipaca has joined #ruby
vipaca has joined #ruby
hooper has joined #ruby
KL-7 has joined #ruby
looopy has joined #ruby
<lectrick>
I work at a startup and something on our local network is syn flooding the router. Anyone a network person or know how to track this down? (maybe another channel for sysadmins?)
wizbdoy has joined #ruby
blacktulip has joined #ruby
<Gushings1>
There is probably a simpler way
<Gushings1>
but I would use wireshark to examine what is traveling to your router and find their internal IP address.
Guest65986 has joined #ruby
<Gushings1>
Whoever set up the system may have a wiring diagram that can tell you exactly where he/she is connected.
<Gushings1>
Otherwise, if it is wireless , it's a bit harder.
<Gushings1>
The source can be spoofed as well.
<lectrick>
It's wireless.
<Gushings1>
It depends on how technically skilled he is or what software he is using.
<Gushings1>
How large is your startup, may I ask?
<Gushings1>
By number of people you expect to be using the router.
wmoxam has joined #ruby
<lectrick>
like 15 people? There are 50+ clients on the router tho, apparently
<Gushings1>
Well, iphones and other devices will connect.
jgrevich has joined #ruby
jgrevich has joined #ruby
d3vic3 has joined #ruby
mdhopkins has joined #ruby
<Gushings1>
Someone who is a security expert may be able to help you better.
<Gushings1>
I just play around with it.
<uris>
your router should be able to list all users connected to it
<uris>
most routers can do that once you login
<uris>
that will give you an idea of who and what is connected
adambeynon has joined #ruby
<Gushings1>
I'm interested in how that would help.
<uris>
it can give you an idea if people who are not supposed to be connected are indeed connected
<uris>
like was mentioned earlier, people on their phones or tablets
<Gushings1>
MAC addresses can be changed, the assigned IP addresses are dynamically allocated, and SYN floods can spoof the IP address anyways.
<uris>
sometimes it is simpler than that, maybe someone just connected and is using a large amounts of bandwidth
sectionme has joined #ruby
<Gushings1>
True, but he specified that he was being syn flooded.
<Gushings1>
I'd just lock up the router for now, is it password protected lectrick
<lectrick>
Gushings1: Of course. WPA2.
<uris>
then it could be one of your machines that is compromised
blueadept has joined #ruby
<uris>
install wireshark and ntop to monitor some traffic
<Gushings1>
yep
<uris>
there is not easy solution, for cases like this you have to roll up your sleeves and get lots of coffee
<uris>
it takes some time
<shevy>
coffee
<shevy>
I HATE IT
williamcotton has joined #ruby
<Gushings1>
Do you have a log of the network connections?
<matti>
Noess.
<matti>
shevy: How can you have coffee?
<matti>
;/
<Gushings1>
Modafinil
<shevy>
I am the chocolate type
<matti>
shevy: OUT ->
LMolr has joined #ruby
<matti>
;/
<matti>
shevy: :)
<shevy>
hot chocolate + donut (but not too many donuts)
<matti>
Callories...
<shevy>
:(
<Gushings1>
At least the WPA2 narrows it down.
<Gushings1>
It's probably someone that has the key.
<Gushings1>
That you or someone else provided to them.
headius has joined #ruby
td123 has joined #ruby
renanoronfle has joined #ruby
riginding has joined #ruby
hobodave has joined #ruby
baroquebobcat has joined #ruby
maletor has joined #ruby
aantix has joined #ruby
<bounce>
*looks at backscroll* uhm not really the right place to look
<bounce>
s/look/ask/
cloke has joined #ruby
<bounce>
but fire up tcpdump, check the macs, that sort of thing. there's things like... from vague memory wifi-spy that work even without the fancy expensive dongle (that gives moar powr) to help pinpoint physical location
davidpk has joined #ruby
cloke_ has joined #ruby
LiquidInsect has joined #ruby
<lectrick>
Is there any way to have an instance of a number? Something that is passed by-ref instead of by-val, but otherwise acts like a number?
<bounce>
there is a way to make cheap router boxes hand over the wpa key with 11000 tries max unless the box blocks the attack, and without key you can still mount a disassoc attack
cloke has joined #ruby
minver has joined #ruby
<minver>
Since matz strongly discourage autoload (http://is.gd/Ik3zfm) should I simply use require then?
<shevy>
sure
<bounce>
if your switches aren't cheap crap they can point to a port where it's coming from (and possibly turn off the port; a bit of snmp-scripting does the trick)
<TTilus>
lectrick: 1 is an instance, what you are talking about?
<shevy>
otherwise extending class Fixnum would work
<TTilus>
lectrick: without knowing what you are actually trying to put together, id say you might want to use proxy or delegator
<lectrick>
shevy: yeah
* apeiros_
repeats: lectrick, make a proxy object.
<apeiros_>
Numeric classes in ruby are all immutable. so no chance of doing that with a core numeric.
<TTilus>
lectrick: ...but i emphasize the "without knowing" part
<lectrick>
apeiros_: yeah that's what I thought
eywu has joined #ruby
<TTilus>
lectrick: how about elaborating on what you are doing
<apeiros_>
by the use of coerce you can have it easily work like a normal number
<apeiros_>
also define to_int to return the value.
<lectrick>
TTilus: Nothing specific. I was just thinking of a way to somehow add extra information to return values.
<TTilus>
lectrick: you _were_ thinking that for a reason =D
<TTilus>
lectrick: and thats something id like to know
SegFaultAX|work has joined #ruby
<shevy>
I am only curious why it had to be a singleton method
<lectrick>
TTilus: I often want to return extra information from a method, but not have the users of that method notice a difference or have to change the API.
<TTilus>
shevy: thats pretty much why im asking whats the dude doing =D
<TTilus>
lectrick: such as
<lectrick>
So my idea was a variable that looks and acts like a number (or perhaps a string) but has extra attributes or methods on it
<TTilus>
lectrick: come on! you _do_ have a case or few in your mind
<shevy>
hmm
<TTilus>
lectrick: "i often want" is not a reason ;)
<td123>
cap10morgan: some ppl seemed to have switched to pry + pry-nav and other solutions which might be good
joaoh82 has joined #ruby
tewecske has joined #ruby
thecreators has joined #ruby
jarred has joined #ruby
<cap10morgan>
td123: yeah, looks interesting. though I'm a bit worried about answering a newcomer to Ruby's question: How do I get a debugger? (Well, first you install pry and these other gems, then you use that instead of irb everywhere...)
<joaoh82>
hey guys
<joaoh82>
I am new to ruby
<joaoh82>
so I have kind of a newbie quesiton
zakwilson has joined #ruby
zakwilson has joined #ruby
h4mz1d has joined #ruby
jankly has joined #ruby
<any-key>
we don't allow those
<any-key>
:P
<apeiros_>
joaoh82: skip the boilerplate. ask.
<apeiros_>
there's only a few genuinely stupid questions (e.g. "may I ask a question?" :-p)
buschhardt has joined #ruby
buschhardt has quit [#ruby]
workmad3 has joined #ruby
moted has joined #ruby
<any-key>
too late
kenichi has joined #ruby
arturaz has joined #ruby
t0mmyvy0 has joined #ruby
ed_hz_ has joined #ruby
pythogorian has joined #ruby
nfluxx has joined #ruby
<pythogorian>
hello ruby guys
<pythogorian>
:)
brngardner has joined #ruby
<any-key>
we prefer to be called "ruby persons"
<pythogorian>
sorry :)
adamkittelson has joined #ruby
<pythogorian>
i need help
<any-key>
just ask
<pythogorian>
today i started writing some ruby code
<pythogorian>
came from python land
<any-key>
off to a good start
<bawer>
ruby is pretty
<pythogorian>
i like it
<any-key>
I much prefer the block syntax over the way python does lambdas
<any-key>
but anyways, what's your issue?
<pythogorian>
how can i create hash inside hash by referencing
<pythogorian>
example:
banisterfiend has joined #ruby
ales has joined #ruby
<pythogorian>
n = {1 => 'one, 2 => 'two'}
<pythogorian>
great
<any-key>
yo dawg, I heard you like hashes
<pythogorian>
now
<pythogorian>
m = {1=>n}
<pythogorian>
says
<pythogorian>
m = {1=>nil}
<pythogorian>
why nil?
<Mon_Ouie>
Because n is nil
<apeiros_>
you must have reassigned nil to n in between
moos3 has joined #ruby
<apeiros_>
you have a typo in your first hash btw.
<Gushings1>
Anyone knowledgable with ruby reading ruby sockets
<Gushings1>
?
<any-key>
the immature part of me just laughed at that command
<any-key>
Gushings1: I know a little bit, just wrote something that uses them with select
<Gushings1>
Nice, I'm doing something similar
<Gushings1>
I used select to get the sockets ready for read
<Gushings1>
now I'm trying to use gets to read the line from the socket...
csprite has joined #ruby
<Gushings1>
It worked, but I ran into an issue where the line isn't terminated properly (no newline or other ending character) and it tries to read forever.
<Gushings1>
as gets is never sure that the socket is finished sending.
<apeiros_>
Gushings1: you'll have to do your own buffering in that case
PragCypher has joined #ruby
<apeiros_>
sounds like the other side neither sends an EOF
<any-key>
are you the one writing to the other socket?
<apeiros_>
Gushings1: so how will you recognize that the message is complete?
krz has joined #ruby
<apeiros_>
I mean… no EOF, no line terminator…
<Gushings1>
No, people can connect with any client they want.
<apeiros_>
sounds like a fucked up client…
<any-key>
aah
<Gushings1>
I'm trying to make the server software robust.
<any-key>
I don't know what the Proper Way™ is, but I'd surround the read with a timeout
<Gushings1>
I can't be certain the client will do anything properly.
<apeiros_>
Gushings1: I'd time-out the connection and disconnect the client
<Gushings1>
I looked into timeouts.. potential for lots of lag?
<Gushings1>
or should it not be an issue.
<apeiros_>
why should it lag?
<any-key>
you'll lag, since it blocks
<apeiros_>
but you should use non-blocking read on a server
<any-key>
yes
<apeiros_>
otherwise with a single-threaded select based server, a single client can DOS you
<Gushings1>
right, I agree
<Gushings1>
I want to keep it single threaded for now
<Gushings1>
I found read_nonblock
<Gushings1>
I have never used it before.
<Gushings1>
any insight?
pokui has joined #ruby
pokui has joined #ruby
kvirani has joined #ruby
stkowski has joined #ruby
shruggar has joined #ruby
<any-key>
can't say I've used it
<Gushings1>
hm
<Gushings1>
It's my intuition that getc() to read chars until there were none left would still block?
daniel_hinojosa has joined #ruby
<any-key>
it looks like read_nonblock is what you want though
shift_ has joined #ruby
<any-key>
it's like a timeout for the maximum number of characters if I'm understanding it correctly
arturaz has joined #ruby
cousine has joined #ruby
<Gushings1>
I think it's just read up to N bytes.
<any-key>
yep
arturaz has joined #ruby
<any-key>
it should help, although it won't completely fix the problem
mxweas_ has joined #ruby
<any-key>
assuming you can set a sane limit for this specific application without screwing other clients over
arturaz has joined #ruby
<Gushings1>
I'll just make it very large.
<Gushings1>
to test it.
<Gushings1>
I can adjust it later.
<any-key>
play with it and get a number that doesn't cause too much lag
<apeiros_>
any-key: read_nonblock simply returns everything that is in the buffer
<any-key>
apeiros_: up to the maxlength
arturaz has joined #ruby
<apeiros_>
yes, you can additionally limit it
askTheUser_ has joined #ruby
<Gushings1>
Have you used it apeiros
<apeiros_>
beware, some versions of 1.9.2 had a bug with the implementation using a buf arg
<apeiros_>
Gushings1: sure
arturaz has joined #ruby
gift has joined #ruby
ben225 has joined #ruby
<Gushings1>
All I have to do is read some number of bytes that should cover any message received, and catch the EOF, then process the bytes however I want?
<apeiros_>
no
<apeiros_>
you have to buffer
berserkr has joined #ruby
<apeiros_>
until your message is complete
<apeiros_>
it reads *up to* maxlength bytes
<apeiros_>
which means it can be less, it can be an incomplete message
<Gushings1>
I see, I see.
rdegraci has joined #ruby
<apeiros_>
and you have to handle the timeout
<Gushings1>
So add the bytes to the buffer for the connection, then check if a full message exists yet.
<apeiros_>
correct
ballpointcarrot has joined #ruby
<apeiros_>
don't forget to rescue the exceptions
<Gushings1>
Yeah, I still have to figure out what some of them mean.
nev3rkill has joined #ruby
<any-key>
also, do "if select(.....)" so that if select times out and returns nil you don't have an exception
<any-key>
I haven't updated it...the sensor support is currently being developed as my senior design project progresses :P
<any-key>
yep
<Gushings1>
That's pretty cool
shruggar has joined #ruby
<any-key>
Ruby is good for everything ever
<Gushings1>
We have an anybot at my school that roams the halls.
<Gushings1>
The software for it is a bit lacking.
<Gushings1>
Maybe someday I'll try to follow in your footsteps.
<apeiros_>
Gushings1: hu? no, socket being ready for read means something is ready to be read. if you use read_nonblock on it, it will return "immediatly" (it won't block)
<apeiros_>
but you have to handle when you want to time out your clients
<any-key>
right now I have a "roomba server" set up in my project (not in the library) that listens for clients...there's a separate ClientRoomba class that inherits from the main Roomba class and tells it to write to a socket instead of the serial port
<apeiros_>
unless you want to keep bad clients connected indefinitely
<any-key>
so I can have multiple processes all talking to the same roomba :D
<shevy>
style question http://pastie.org/3728324 what do you prefer? the terse variant without the newlines or the more verbose one with the newlines
<any-key>
shevy: the second one, I don't like the whitespace on line two
<any-key>
if you got rid of that I'd prefer the first one
delinquentme has joined #ruby
<apeiros_>
shevy: terse. I'd write it even terser: some_variable << 'bla' if look_for_more_things
<delinquentme>
ok sooo im having some ruby brain melt....
<any-key>
uh oh
<Gushings1>
I am taking care of checking the clients and removing their connections somewhere else.
mxweas_ has joined #ruby
<shevy>
cool thanks
<delinquentme>
can I get like a 1 liner on what "base" does?
<Gushings1>
Related to the read_nonblock though, I do not need to check for timeouts - Is this correct?
<shevy>
base?
<apeiros_>
Gushings1: no. only for error conditions.
<any-key>
delinquentme: we need some more context as to what "base" is
<shevy>
All Your Base Are Belong To Us!!!
<apeiros_>
any-key: you still can't read minds? shame on you! OUT!!!
<Gushings1>
delinquentme it raises the pH of the program you are writing
<delinquentme>
apeiros_, im already on a bit of a wild goose chase here while yes ideally i should have read everything im trying to sort out whats going on within *this* instance
<superjoe>
shevy, increment a possibly nill array or hash value
<delinquentme>
as its all chinese to me as it is
<shevy>
still not getting it quite :)
<shevy>
your code seems to just make this array [1, 1, 1, 1, 1, 1]
<any-key>
llaskin: you aren't in a loop
<llaskin>
...i am
<superjoe>
shevy, obviously this is a simplified example.
<delinquentme>
nm
<superjoe>
apeiros_, nope. sorry. the name is just a random made up nonsense from when I was 12 years old.
<delinquentme>
"yes" is the answer i was after
<llaskin>
it stopped working right wen I upgraded from 1.8.7 to 1.9.3
<superjoe>
I was hoping I could do something like this:
nikhgupta has joined #ruby
cousine has joined #ruby
<superjoe>
(foo[i] ||= 0) += 1
<shevy>
this boggles my mind, I hope apeiros_ can make sense of it
<superjoe>
e.g. not access foo[i] twice
eka has joined #ruby
<delinquentme>
which is 138 chars shorter than what you needed to type :D
<shevy>
hehehe
<rippa>
apeiros_: I liked all bionic commando
<Gushings1>
How large are chars in ruby?
<rippa>
old, new and rearmed
<shevy>
about -> ' ' <- this size
<apeiros_>
rippa: I only played the first. no save-game was terrible back then, though (parents didn't allow playing for long continued periods)
brngardner has joined #ruby
<rippa>
apeiros_: I played spectrum version
<apeiros_>
shevy: with immutables, you can even use the 2-arg form: foo = Array.new(5,1)
<shevy>
cool
<apeiros_>
rippa: oh? NES one for me
<shevy>
I like that more
<llaskin>
any-key: any thoughts on it breaking due to a shift from 1.8.7 to 1.9.3?
<shevy>
see superjoe, if you wanted to mak an array like that, you can use Array.new :D
<shevy>
*make
<superjoe>
the goal is to not access foo[i] twice
<superjoe>
because in real code, i is more complicated
<rippa>
cache i
<rippa>
i = complicated
<rippa>
foo[i] twice
<any-key>
llaskin: no clue
shruggar has joined #ruby
<llaskin>
when i run the same script with 1.8.7 its ok
<llaskin>
1.9.3 borks
<apeiros_>
llaskin: proc/lambda behavior changed from 1.8 to 1.9. your next is obviously in a place where it's no longer valid.
<Gushings1>
read_nonblock(somenumberofbytes) is going to give me a string containing the ascii (?) representations for those bytes. If I'm trying to calculate how much I want to read (lets assume 500 characters) then should I just read 500 bytes and assume they are being represented by 8 bits?
<apeiros_>
Gushings1: then it'd probably use Encoding.default_external
sohocoke has joined #ruby
askTheUser has joined #ruby
<Gushings1>
Ah, I see.
<Gushings1>
Interesting.
<apeiros_>
Gushings1: just to be clear - String can handle any binary data
<Gushings1>
Yes, it just won't make sense if the encoding is wrong.
<apeiros_>
but a couple of operations require the data to be valid according to the encoding it states to have
<apeiros_>
e.g. gsub will raise if your strings says it was utf-8, but the data contains illegal sequences
<superjoe>
bawer, no error, I just think it looks ugly
askTheUser has joined #ruby
<superjoe>
wondering if there is a better way to write that
llaskin has quit [#ruby]
<Gushings1>
Wait what.
<delinquentme>
apeiros_, there is no Module#include
<delinquentme>
#included?
<delinquentme>
nope
Sailias has joined #ruby
<apeiros_>
delinquentme: srsly? want me to put you with the nose into it? :-)
<Gushings1>
Given any arbitrary binary string divisible by 8, wouldn't it just be interpreted in sets of 8? It would result in garbage, but it would have some representation, no?
<Gushings1>
How would you ever know it was not the intended message?
<apeiros_>
though this documentation is *horrible*. my god… such an important method, such sucky documentation :(
cbuxton has joined #ruby
<rippa>
Gushings1: because not every byte sequence is valid utf-8
kirun has joined #ruby
<delinquentme>
whats messing me up is Klass.send(:include, FooModule) .. this says "include"
<delinquentme>
whereas the method being called is .included
<apeiros_>
delinquentme: if you'd properly read…
<apeiros_>
19:58 apeiros_: i.e., Foo.include Bar will invoke Bar.included(Foo)
<Gushings1>
Ah, okay.
<Gushings1>
I never knew that.
<Gushings1>
I thought there was some default representation that filled all spare slots.
<Gushings1>
:)
sectionme has joined #ruby
<Gushings1>
Alright, I have to go to robotics.
<delinquentme>
apeiros_, so there is some magic ruby linking going on between include and included
<apeiros_>
Gushings1: there's a couple of byte-sequences that are just not allowed in utf-8
<Gushings1>
Thanks for the help everyone
<Gushings1>
I'll be around.
<delinquentme>
Gushings1, what robots are you building
<apeiros_>
Gushings1: in a single byte encoding, that'll never be the case, of course
linoj has joined #ruby
<apeiros_>
delinquentme: nothing magic. it's just a callback.
<apeiros_>
hook.
<Gushings1>
We are building robots from scratch with a brainstem microcontroller.
<Gushings1>
three 180 degree servos for locomotion
<delinquentme>
Gushings1, ima track u down later we need to talk
<delinquentme>
<< open source robotics
<apeiros_>
bah, that's ancient technology… brainstem micros… pfffff
<apeiros_>
:)
strife25 has joined #ruby
<Gushings1>
Working with robot vision, SLAM, etc.
<Gushings1>
:)
<Gushings1>
see you all!
<apeiros_>
cya
tommyvyo has joined #ruby
carlyle has joined #ruby
phantomfakeBNC has joined #ruby
JohnBat26|2 has joined #ruby
workmad3 has joined #ruby
b26 has joined #ruby
smoak has quit ["WeeChat 0.3.7"]
phantomfakeBNC has joined #ruby
gomix has quit [#ruby]
williamcotton has joined #ruby
alaska has joined #ruby
<cap10morgan>
anyone know how to eval a variable in pry whose name conflicts with a command? so, for example, if I have a local var named "step", how do I ask pry for its value?
eldariof has joined #ruby
<cap10morgan>
in ruby-debug, I would use "eval step"
<Gushings1>
blah nevermind
<Gushings1>
My favorite class was canceled. ;(
askTheUser has joined #ruby
<Gushings1>
Is there any issue with using read_nonblock with a byte size of say 500?
<Gushings1>
I don't think there should be
tatsuya_o has joined #ruby
artm has joined #ruby
nikhgupta has quit [#ruby]
jcromartie has joined #ruby
<rippa>
cap10morgan: put a space before it
Liothen_ has joined #ruby
looopy has joined #ruby
<cap10morgan>
rippa: *forehead slap* thanks for suggesting the simple and obvious thing I didn't try. :)
codezombie has joined #ruby
xybre has joined #ruby
ben_m has joined #ruby
s has joined #ruby
williamcotton_ has joined #ruby
<shevy>
cap10morgan banisterfiend should know
<cap10morgan>
shevy: rippa was all over it. putting a space before it work beautifully.
wallerdev has joined #ruby
cousine has joined #ruby
bawer has quit ["Leaving"]
bawer has joined #ruby
<shevy>
I see
KL-7 has joined #ruby
<ben_m>
Hey everyone. I just installed Ruby 1.9.3 via the windows installer, then installed ruby-processing via gem, but I get "file not found" errors when trying to run the samples.
schovi has joined #ruby
williamcotton_ has joined #ruby
bbttxu_ has joined #ruby
strife25 has joined #ruby
hzlocky has joined #ruby
<hzlocky>
Guys, is there anyway to define method with name [][](first_arg, second_arg) in my class?
axeman- has joined #ruby
<Gushings>
def [][](first_arg, second_arg)
<Gushings>
#code
<Gushings>
end
<Gushings>
?
<Gushings>
Does that not work?
askTheUser has joined #ruby
yoklov has joined #ruby
<hzlocky>
obviously nope
buschhardt_ has joined #ruby
buschhardt_ has quit [#ruby]
<Gushings>
What is the error?
jbw has joined #ruby
<hzlocky>
syntax error, unexpected '[', expecting '\n' or ';'
axeman- has quit ["Leaving"]
nlc has joined #ruby
<jlogsdon>
hzlocky: exactly what it says. look at the line it references, make sure aren't missing something (maybe a closing paren or bracket)
<jlogsdon>
oph wait
<jlogsdon>
sorry, i didn't see your message at 15:19.
davidpk has joined #ruby
<hzlocky>
yep
neersighted has joined #ruby
shadoi has joined #ruby
williamcotton_ has joined #ruby
<Gushings>
hzlocky , check out this stackoverflow page
<n1x>
canton7, yeah it happened with me, when i was trying that url with wget
<canton7>
n1x, also, that looks like jsonp, not json, so you'll have to do a bit of parsing before you can json-decode it
wilmoore has joined #ruby
shadoi has joined #ruby
<n1x>
canton7, oh. okay i'll look into that.. thanks for your valuable suggestions
kpshek has joined #ruby
<becom33>
shevy Im sure thats only file I have in my compuer
<becom33>
computer*
headius has joined #ruby
savage-_ has joined #ruby
<becom33>
I was scripiting on linux before, wanted to check on windows
<shevy>
that is cool becom33 but
<shevy>
the pastie you showed contains no "res = fi...d)"
netrealm has joined #ruby
<lectrick>
apeiros_: I took a stab at doing this myself without a Delegate and got it to work. https://gist.github.com/2305169 Do you know how I could use Delegate to do that better? (feel free to edit gist)
Teddy2steper has joined #ruby
punkrawkR has joined #ruby
<n1x>
canton7, it doesn't fail, if you add User-Agent. :)
sarpanch1 has joined #ruby
<canton7>
n1x, hrm, I did have a user-agent in there
Eldariof-ru has joined #ruby
greenarrow has joined #ruby
apeiros_ has joined #ruby
<apeiros_>
lectrick: you're doing way too much IMO
johndbritton has joined #ruby
<Gushings>
I am not well versed in catching ruby exceptions
<apeiros_>
*rescuing
<apeiros_>
catch has a different meaning
<Gushings>
*rescuing.
<Gushings>
Let's suppose I had a group of exceptions that all had the same parent class.
<Gushings>
Could I rescue the parent to cover all of them?
<lectrick>
apeiros_: I know :( I want to do it better
<apeiros_>
Gushings: yes
<Gushings>
EX: Errno::EWOULDBLOCK, Errno::EINTR
<apeiros_>
rescues work hierarchically
<Gushings>
can I rescue Errno
<Gushings>
okay, great.
<apeiros_>
you can also use rescue a,b,c => exc
<apeiros_>
i.e., rescue many in a single rescue clause
<apeiros_>
lectrick: minute
<Gushings>
Yeah, I figured that one out :)
wilmoore has joined #ruby
nerdy_ has joined #ruby
ringotwo_ has joined #ruby
<rking>
Is there a doc that helps you transition from PCRE to "R"CRE? Somebody has probably made a doc that highlights 100% of the differences.
<becom33>
test.rb:1: syntax error, unexpected keyword_def, expecting '<' or ';' or '\n'
<becom33>
... end print "hello"
c0rn has joined #ruby
<rking>
lectrick: Hrm, that has some stuff, yep. Maybe the document I'm looking for doesn't exist (in which case I'll write it if I end up finding it something that is needed).
<becom33>
sorrry wrong error
<becom33>
c:\>ruby test.rb
<becom33>
test.rb:1: syntax error, unexpected keyword_def, expecting '<' or ';' or '\n'
<becom33>
e... end puts "hello"
<becom33>
^
<becom33>
thats the right one
<becom33>
sorry if im flooding :/
<rking>
becom33: You could've put it in the pastie, sure.
Teddy2steper has joined #ruby
<apeiros_>
becom33: I think the code you pasted and the syntax error don't belong together
<apeiros_>
you sure you edit the right file?
<becom33>
apeiros_ yes Im sure
<rking>
I agree. That code works fine.
<rking>
I wonder if there is an \r\n issue somehow? Does Ruby handle mixed \n and \r\n's?
netrealm has joined #ruby
<becom33>
rking Im sure it will work fine in linux , Im on windows , maby I have to setup the path for ruby execute ? in the 1st line
<apeiros_>
becom33: I'd double check. that code is fine.
<becom33>
coz it gives a 1st line error right ?
<apeiros_>
becom33: no, your error is coming from the ruby interpreter
<apeiros_>
so windows finds your executable
<becom33>
:/
<apeiros_>
remove everything from the file and run it again
<apeiros_>
if the syntax error still persists, you're definitively editing the wrong file.
<lectrick>
apeiros_: I will study it. Is there any way (or even any advantage) to have it use BasicObject instead of Object?
<becom33>
apeiros_ no Im editing the right file , i changed puts in prints . still Im getting a error
<apeiros_>
there is a way. just replace Object with BasicObject
<becom33>
print *
<rking>
becom33: That's not doing what he said.
<apeiros_>
lectrick: I don't like BasicObject as it kills off all introspection
<apeiros_>
becom33: that's pointless.
<apeiros_>
anyway, bottom line is: that code is syntactically correct, for both, 1.8 and 1.9. \n vs. \r\n should not be an issue.
<becom33>
apeiros_ bur that mean Im editing right file
<apeiros_>
your problem lies elsewhere.
<rking>
becom33: How in the world does it demonstrate that? If anything, it's evidence to the contrary.
<becom33>
apeiros_ thats the problem . I tried same thing on Interarctive ruby prompt , it works fine in it
<becom33>
but on the script I dnno :/
greenarrow has joined #ruby
* apeiros_
will wait how long it takes becom33 to figure out how he got the wrong file
<becom33>
rking Im sorry I dnt undertand your question
badabim has joined #ruby
<rking>
Is there a paste server that lets you upload text files directly?
<becom33>
apeiros_ help me find the right file
<apeiros_>
anyway, if you don't want to follow suggestions, I don't see a reason to waste my time.
<apeiros_>
what for? you ignore what I say.
<becom33>
no I didnt . explain me
* apeiros_
goes back reading his book
<rking>
becom33: He said to blank out the file then re-run.
<becom33>
aghh
<becom33>
wait wait
<shevy>
we always wait
<becom33>
so I ran a blank file it doesnt give me anything
simao has joined #ruby
<shevy>
write:
<rking>
becom33: OK, so you have the right file. =)
<becom33>
but on that empty class I get a error . btw whats a bogus parser ?
<shevy>
and it prints out hello world
<shevy>
rking, the parser he invokes is not running that file
<shevy>
some magic is happening
<shevy>
<becom33> endss Test <--- what is this by the way
<shevy>
endss Test?
<shevy>
is that your typo? :)
<becom33>
shevy thats error I got on the empty class
<shevy>
that is odd
<becom33>
no pasted you the exact thing what I had in my script
<becom33>
btw shevy your script gives me a error too
<lectrick>
apeiros_: good points on introspection. this is a lot cleaner but i'm not 100% sure why it needed 2 levels of class hierarchy to implement this way...
<shevy>
yeah, something is going on somewhere
<canton7>
becom33, what's the output of ruby --version ?
<shevy>
becom33 what error?
<rking>
My suspense/excitement is dropping as I start to expect there is no solution in sight.
<canton7>
man it's been years since I was on bash.org
<rking>
canton7: I don't fully understand it. What was the exact byte string coming out, before?
<canton7>
rking, the lines were ending with \n instead of \r\n. That particular windoes ruby version wasn't liking this, and was ignoring the line endings, and tripping up as a result
<canton7>
on my box, p125 handles \r line endings on a windows machine just fine, so it must be one of the things they patched up pretty quickly
<becom33>
in windows ir is deffernt that linux the way its requires ? when I require a file it gives me
<becom33>
canton7 what is that gits ruby paste link ? it give a optons to add two separate pastes ?
<shevy>
no it is not different
<shevy>
it works on linux, it works on windows
<canton7>
becom33, what?
<rking>
By the way, for the record: [14:27] <rking> I wonder if there is an \r\n issue somehow? Does Ruby handle mixed \n and \r\n's?
<shevy>
hahaha :)
<canton7>
rking, well spotted!
<rking>
There is a record, right? And so far my score is 1 for 1, right?
williamcotton_ has joined #ruby
<shevy>
you got lost in the amount of line noise rking
<canton7>
rking, can we buy you a megaphone and shouting rights?
<rking>
canton7: Oh, I need neither to be a loud person.
<canton7>
rking, for becom33's sake, please be as noisy as you can in similar situations in the future haha :P
<becom33>
canton7 now I checked on that windows things . its selected on the script
Indian has joined #ruby
<canton7>
becom33, by default, LOAD_PATH doesn't include the current directory. You've got the option of using require_relative or adding the current dir to $LOAD_PATH
<becom33>
aww how can I do that
williamcotton_ has joined #ruby
<canton7>
becom33, option 1 is to use require_relative 'core' instead of require 'core'
<becom33>
aghh ok
<becom33>
hay that works
<becom33>
btw canton7 even in liunux does require_relative works ?
<becom33>
insted of require ?
<canton7>
becom33, yup. It's a 1.9-thing only, though, I believe
<becom33>
canton7 i see . it someone is using older version than 1.9 ?
<rexbutler>
canton7: I'll have to look at that also
<senthil>
shadoi: how so?
<burgestrand>
Actually, I don’t know if there’s a way to make them ungreedy. The PCRE method of ?’ing or +’ing the quantifiers certainly don’t make an effect for me.
<shadoi>
senthil: so you know ahead of time what classes you're going to create and you can define an API for them before runtime.
shruggar has joined #ruby
<burgestrand>
… never mind, I’m full of it. They work well.
<burgestrand>
Or rather, ?’ing the quantifiers work well.
jitesh_shetty has joined #ruby
<senthil>
shadoi: if i stick to just google api wrappers, then yea. i was hoping it could be useful for any RESTful api
shruggar has quit [#ruby]
macroevolve has joined #ruby
<lectrick>
Can someone explain the reasoning behind methods that end in ! returning nil or false (instead of the receiver) if the receiver is unchanged by the call? (not criticizing just wondering)
maletor has joined #ruby
<senthil>
lectrick: maybe so you can do "if changed!"
<shadoi>
senthil: that's defnitely a hard problem to solve cleanly. I gave up and put HATEOAS indexes on all my REST APIs.
<wefawa>
lectrick: ! methods intend to modify the receiver... not to query it...
<shadoi>
senthil: makes generating a client API very simple.
<canton7>
or if (new_object = changed!)
<canton7>
(for those that happen to like that sort of thing)
<lectrick>
senthil: wefawa: all decent points
askTheUser has joined #ruby
atmosx has joined #ruby
<senthil>
shadoi: doesn't HATEOAS just define where/how to get resource/action?
<rexbutler>
BTW, is there a minification library for Ruby, or even better also a source formatting library? My sinatra apps 'view source' is so full of whitespace it's a disaster
<shadoi>
senthil: so there's using it in each resource, and then there's having an INDEX resource that lists ALL available resources and actions.
<shadoi>
theoretically if you design it properly you can discover the whole API by walking resource links.
<shadoi>
I prefer an index
<senthil>
shadoi: and it has all the info? request verbs, params? etcs.
<shadoi>
yeah
Squarepy has joined #ruby
<shadoi>
I basically used something similar to the "rake routes" tool in Rails to generate mine.
<shadoi>
for Sinatra
Squarepy has joined #ruby
<senthil>
shadoi: interesting...you could essentially have the api create a wrapper for itself
<shadoi>
yup
<senthil>
thats freaking awesome!
<shadoi>
senthil: I went down the path you were taking and realized it was HAIRY :)
<senthil>
shadoi: i bet!
<senthil>
shadoi: i've never seen a "big" api use it? do you know of any that does?
<senthil>
by big i mean fb, twitter, google, 4square etc.
<shadoi>
senthil: none of the big ones sadly
<shadoi>
senthil: well, actually I haven't checked in a while
artm has joined #ruby
askTheUser has joined #ruby
supergiantrobot has joined #ruby
carloshpf has joined #ruby
<senthil>
shadoi: bummer; thx for the info!
<senthil>
back to work
supergiantrobot_ has joined #ruby
<rking>
Wow. I looked at every one of http://en.wikipedia.org/wiki/Comparison_of_pastebins ... and there really is a need for a file-upload version of a paste site. One because it's inconvenient sometimes to do the open/copy/paste step, and two so we could solve problems like the \r one before.
<rking>
And also someone needs to spend 30mins and scrub that list for dead links. I might do it at some point.
<shadoi>
rking: there are TONS of tools to automate posting to various paste sites
<shadoi>
pry being my favorite.
<rking>
shadoi: Is there a web page that I can say, "Go here, then click the file picker widget, then click Upload"?
<rking>
shadoi: Pry's gist feature is hot, yes.
brngardner has joined #ruby
<shadoi>
I think a file browser upload feature is overkill, but … *shrug* I'm sure some would prefer it.
mxweas_ has joined #ruby
TNTechnoHermet has joined #ruby
<shadoi>
it'd probably result in people uploading a shitload of stuff they didn't mean to though
<shevy>
p0rn
TNTechnoHermet has joined #ruby
ghvandoorn has joined #ruby
Guedes has joined #ruby
Deele has joined #ruby
artm has joined #ruby
<rking>
shadoi: I don't think so. People on #blender use http://pasteall.org/blend all the time. Like every 5 mins.
mengu_ has joined #ruby
mengu_ has joined #ruby
<shadoi>
rking: so.. why not just use that?
<rking>
shadoi: Because it only allows .blend and .py at that URL, then only .png and .jpg at the image URL.
<shadoi>
oh.. weird
TNTechnoHermet has quit [#ruby]
<rking>
shadoi: I guess I could tell the user to rename their .rb to .blend and use that. =D
<rking>
Actually, that's the best solution I have at the moment.
<shadoi>
you'd think it'd allow any file type they support
saster has joined #ruby
savage- has joined #ruby
apok has joined #ruby
Jake232 has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
niku4i has joined #ruby
_adeponte has joined #ruby
askTheUser has joined #ruby
askTheUser has joined #ruby
askTheUser has joined #ruby
leynos has joined #ruby
alex__c2022 has joined #ruby
askTheUser has joined #ruby
entrenador has joined #ruby
apok has joined #ruby
apok has joined #ruby
mxweas_ has joined #ruby
<shevy>
dumdedum
leprosys has joined #ruby
<shevy>
hmm
<shevy>
an INI file is basically a file with:
<shevy>
[foo]
<shevy>
blabl
<shevy>
ble
<shevy>
[bar]
<shevy>
ble
<shevy>
blue
<shevy>
?
<shevy>
because that would be very trivial to parse
raz has quit ["Leaving..."]
dbgster has joined #ruby
ttm has joined #ruby
<bounce>
there's also =, spaces in tags (for some parsers), and values trickery
mattyoho has joined #ruby
keymone_ has joined #ruby
<shadoi>
shevy: there are plenty of example INI parsers out there.
<ReinH>
puppet makes me so sad for having to maintain an ini parser >:(
tatsuya_o has joined #ruby
d2dchat has joined #ruby
<apeiros_>
ReinH: hu? an ini parser should be like… 20 lines in ruby?
<frontendloader>
anyone use celluloid? How do you gracefully terminate a supervised actor?
<ReinH>
apeiros_: you would think
<apeiros_>
I wrote one, so yes, that's what I think :)
<apeiros_>
(and that's even like 6y ago…)
<monokrome>
What does the [] operator do in an example such as: "some string here"[/^A([a-z])+/, 1]
<monokrome>
specifically the 1 part
<shevy>
monokrome not sure it looks like a regex
<shevy>
perhaps it captures the first match
<shevy>
in between the ()
<monokrome>
oooh
<monokrome>
I understand the regex, but I think you are correct on the 1 part
<monokrome>
Thanks
andrewhl has joined #ruby
<monokrome>
Yep! Testing agrees. Thanks, shevy,
wallerdev has joined #ruby
tommyvyo has joined #ruby
<apeiros_>
monokrome: you are aware, that there's API documentation for ruby?
phinfonet has joined #ruby
<phinfonet>
hi
<apeiros_>
e.g. `ri 'String#[]'` in your shell
<monokrome>
Yes, of course. However, I am unaware of if that would be a "string" thing or a language feature
<apeiros_>
or rdoc.info, or ruby-doc.org
<monokrome>
operator overloading ftl
<phinfonet>
in here have persons that utilize bowline?
<apeiros_>
monokrome: almost everything in ruby is a method
<apeiros_>
in that regard
<apeiros_>
i.e., +, -, *, ** are all methods
<monokrome>
Right
cousine has joined #ruby
<monokrome>
Operator overloading just makes things confusing for newcomers :)
<apeiros_>
there's only very few true operators/syntax elements (and, or, &&, ||, defined?, ?:)
<monokrome>
Thanks for your help
<apeiros_>
monokrome: it's not operator overloading.
<monokrome>
Oh?
<apeiros_>
ruby is not capable of overloading
<monokrome>
Oh, you mean that they aren't operators
<monokrome>
Interesting.
<phinfonet>
i have a problem with bowline-bundler
<phinfonet>
yours shoulde help-me?
alup_ has joined #ruby
<apeiros_>
no, I mean that the term "overloading" describes a concept where you can have multiple definitions of the same method, only distinguished by the type of arguments they take
<apeiros_>
ruby can't do that
<monokrome>
apeiros_: That seems confusing. Does that imply that you can use the name of any method in the same way that you use +?
<phinfonet>
i'm have a error
<apeiros_>
monokrome: no, syntax for "symbol" methods is special
<apeiros_>
monokrome: the reverse is true however, you can do 5.+(6)
<banisterfiend>
apeiros_: afaik the term 'operator overloading' just means 'defining the behavior of an operator', the word 'overloading' doesnt mean the same in that context as it does in the sense of 'overloaded' functions/methods
<phinfonet>
in this link its pasted my error
<banisterfiend>
at least that was my experience of the way that term is used in C++
<apeiros_>
banisterfiend: yes and no. no matter, the term doesn't apply.
<apeiros_>
(at least not to my understanding of it)
<phinfonet>
apeiros_: you uses bowline?
<apeiros_>
phinfonet: no, and I go to sleep now anyway
<phinfonet>
ok
<phinfonet>
who uses bowline in here?
<phinfonet>
apeiros_: what gui you uses in yous applications?
sectionme has joined #ruby
heeton has joined #ruby
cachoimechi has joined #ruby
klip has joined #ruby
liluo has joined #ruby
eywu has joined #ruby
<phinfonet>
have a bowline users in here?
CoderCR|work has joined #ruby
vjacob has joined #ruby
<rexbutler>
Is there a good place that hosts sinatra apps for free?
iocor has joined #ruby
<phinfonet>
rexbutler: you use gui frameworks for ruby?
pdtpatrick has joined #ruby
Boohbah has joined #ruby
sepp2k has joined #ruby
<rexbutler>
phinfonet: No
<rexbutler>
phinfonet: Sinatra is a lightweight web framework
<phinfonet>
who know persons that utilize this?
porco has joined #ruby
<phinfonet>
rexbutler: i'm use rails
<phinfonet>
rexbutler: has many diferrences?
<rexbutler>
phinfonet: Well, which is better is (as usual) based on what you want to do
<rexbutler>
phinfonet: I think github uses Sinatra
<phinfonet>
hmm
yoklov has joined #ruby
<phinfonet>
i'm have a tested padrino
<phinfonet>
is a good framework too
<rexbutler>
It's a very lightweight framework
<rexbutler>
(sinatra is)
<phinfonet>
after i'm finalize my rails projs i'm go test it
<shevy>
hmm what is a good way to get rid of all \n in a string? perhaps one without .gsub ?
<phinfonet>
who uses bowline in here?
<rexbutler>
shevy: using gsub would be a good way
<rexbutler>
phinfonet: What is bowline?
<bawer>
String#chomp
<phinfonet>
rexbutler: is a desktop ruby framework
SolarisBoy has joined #ruby
<bawer>
shevy: in all of the string or just end of lines?
<shevy>
all of it
<bawer>
shevy: why not gsub?
<shevy>
I think gsub pulls the regex engine in
<bawer>
what about String#delete! ?
ende has joined #ruby
<shevy>
hmm yeah... time to try some benchmarks :)
<ende>
I'm not a ruby guy, just installing it as part of a dependency. gem is giving me the following error: http://pastebin.com/kWX9fWUJ
<ende>
does that look familiar to anyone?
<shevy>
openssl should be part of ruby itself ende
<shevy>
it resides in ext/openssl
<shevy>
do you happen to be on debian perhaps? :)
Banistergalaxy has joined #ruby
<ende>
hm
<ende>
yes I do
<shevy>
no idea how to make it work on debian. but here on my system, I compile openssl, then go into ext/openssl and run the extconf.rb (or setup.rb) file there, then openssl works
<shevy>
the ruby bindings to openssl are in ext/openssl
elake has joined #ruby
<phinfonet>
have a rugui users in here?
<ende>
thanks shevy ill try that
aroop has joined #ruby
SolarisBoy has quit [#ruby]
jitesh_shetty has joined #ruby
mxweas_ has joined #ruby
_ack has joined #ruby
mattyoho has joined #ruby
<monokrome>
Is there a reason against using spaces for functions? IE, if something.includes? 24
<heftig>
huh?
<heftig>
you can't omit parentheses if the resulting code would be ambiguous