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
<yekta>
So I made a gem and released it to my internal gem server using geminabox, however when I install the gem from my gem-server it doesn't seem to install the dependencies, shoudln't the dependencies automatically be installed? (I have them in my gemspec.)
<davidcelis>
geminabox
<davidcelis>
lawl
<yekta>
:)
<davidcelis>
won't it look for the dependencies on your internal gem server?
<yekta>
Oops, I see I made them development dependencies
<yekta>
I guess I gotta switch that to add_runtime_dependency
<davidcelis>
ah
<yekta>
Do I need separate declarations for development too?
<yekta>
or will runtime suffice
hzlocky has joined #ruby
<hzlocky>
Guys, I want to mix into true, false, nil method [], is it sounds rational?
<fowl_>
no
<fowl_>
dont do it just because you can
<hzlocky>
but why?
<hzlocky>
I am curious why it is bad idea?
BigFatFatty has quit ["Leaving"]
<shadoi>
yekta: development dependencies are for things like rdoc and debugging tools
<shadoi>
documentation, testing, coverage, debugging, etc.
<shadoi>
hzlocky: Monkey patching is generally bad if you modify core language behavior.
wmoxam has joined #ruby
<shadoi>
hzlocky: you can't predict how other libraries have used those things and what you'll break by changing it.
andrewhl has joined #ruby
SolarisBoy has joined #ruby
andrewhl has joined #ruby
dfamorato has joined #ruby
nif has joined #ruby
Bartzy has joined #ruby
<rking>
An algorithm that checks every element against every other element (like people shaking hands in a meeting) is... O(N*log(N))?
<Chaazd>
Im getting an unexpected ':' expecting keyword_end and unexpected keyword_end expecting ':' on lines 8 and 10 respectively no idea why. http://pastie.org/3771569
<hackingoff>
Space out your usage of the ternary operator's ?.
TomJ has joined #ruby
shevy has joined #ruby
* hackingoff
doesn't understand why the function is being repeatedly defined inside of the loop.
mfridh has joined #ruby
banisterfiend has joined #ruby
<shadoi>
macmartine: if you look at the examples in the docs it includes a time including the GMT offset.
* hackingoff
bleaches his eyes.
carlyle has joined #ruby
<shadoi>
holy christ crackers that's some hideous code.
<hackingoff>
Yeah.
<Chaazd>
My first attempt at tinycode
<Chaazd>
Prety horrible
<hackingoff>
May want to have things spread across multiple lines and ensure they work BEFORE obfuscating it.
<shadoi>
why tiny?
<shadoi>
ruby's entire purpose for existing is expressive, easy to understand code.
<Chaazd>
r/tinycode
dbgster has joined #ruby
<Chaazd>
I wanted to try
<shadoi>
You do need the spaces for the ternary operator
<hackingoff>
It says minimalistic, not obfuscated, right?
<hackingoff>
I'm looking at the sidebar, even though I didn't know of that subreddit's existence.
<hackingoff>
It's also idiomatic to use {} instead of do-end for one-line blocks, though that's not really the root of any problems.
philcrissman has joined #ruby
<shadoi>
it would help shrink and obfuscate it. :)
<shadoi>
hackingoff: yeah, I always expect * to match more than I wanted though
<Chaazd>
The {} actually added a tIdentifier problem. And they are based off of booleans. (I think) http://pastie.org/3771611
<shadoi>
Chaazd: you're not ending some of your blocks
<hackingoff>
Sometimes ruby complains at me if I don't ()-wrap the boolean expression, so that may eventually be something you run into as well.
<hackingoff>
s/ruby/MRI/
<shadoi>
Chaazd: and you'd be much better off using a case statement on a
Chryson has joined #ruby
<hackingoff>
shadoi: Is "+?" somehow less greedy than "*"?
davidcelis has joined #ruby
* hackingoff
has been working with finite automata, so is habituated to thinking of those two expressions as interchangeable.
<shadoi>
hackingoff: no I think it's equivalent like you said, just some mental block I have :)
<shadoi>
too many shell expansion woes I think
<hackingoff>
Chaazd: I think the thing you really want to do is write a version that doesn't attempt to compact everything, and then work on compacting it one step at a time, because there're probably more problems lurking there than you suspect.
<shadoi>
Chaazd: the way you have it, all of those ternary expressions are nested.
<hackingoff>
Your else's block needs to be on a separate line.
<hackingoff>
(I have no idea why.)
nerdy_ has joined #ruby
apok has joined #ruby
<macmartine>
oh! it's updatedMin in this case. sheesh.
<Chaazd>
Now over the 'when's -_-
<macmartine>
actually, no, still doesn't work
<macmartine>
updatedMin returns 0 result even if I set the year to 1800
<shadoi>
Chaazd: what error?
<hackingoff>
macmartine: I'm not sure who was initially helping you with that, but I don't think it was me.
<Chaazd>
Unexpected, expecting end
<macmartine>
hackingoff: oh, sorry
<hackingoff>
No problem. :-)
<macmartine>
shadoi: adding the offset makes no difference
<shadoi>
macmartine: you should construct the URL from what you've put in there and see what it returns.
<shadoi>
with just curl
havenn has joined #ruby
blueadept has joined #ruby
Vert has joined #ruby
Husel has joined #ruby
<hackingoff>
Neither here nor there, but the current nightmare of web maint is having to consolidate old HTML/CSS into templates and/or extract all the info. I feel the nightmare of "tomorrow" will be trying to track down all of the fucking libraries, frameworks, etc., and maybe some part of that will be having to install all sorts of stuff like npm/lessc to build it all.
<bikcmp>
i've been 'gem install'ing stuff and it doesn't seem to go into my path
<bikcmp>
or something's up
<bikcmp>
WARNING: You don't have /home/jason/.gem/ruby/1.8/bin in your PATH, gem executables will not run.
<bikcmp>
fair enough
nari has joined #ruby
<bikcmp>
nope, still won't work when i gem install something
adamkittelson has joined #ruby
sacarlson has joined #ruby
malcolmva has joined #ruby
d2dchat has joined #ruby
vaxinate has joined #ruby
robdodson has joined #ruby
frogstarr78 has joined #ruby
ZachBeta has joined #ruby
Paradox2000 has joined #ruby
<td123>
you need to put that folder into your path
Paradox2000 has joined #ruby
Paradox2000 has joined #ruby
hackingoff has joined #ruby
abra has joined #ruby
micah has quit [#ruby]
apok_ has joined #ruby
prometheus has joined #ruby
RubyRedGirl has quit [#ruby]
kah_ has joined #ruby
<kah_>
hey, what's are the most common languages to use with ical
<kah_>
xml?
<kah_>
javascript?
<any-key>
you can use javascript and ical?
<kah_>
any-key: are you asking a question or saying, yes you can use javascript and ical
<kah_>
?
<any-key>
I don't understand the question
<any-key>
what are you trying to do with ical?
<kah_>
ideally I would like to take my ical file and import in onto my bar website
<any-key>
ah okay that makes a lot more sense
<any-key>
the .ics format that ical exports is XML
<any-key>
if you wanted to display that on a website I'd use a parser in whatever language you're using on the website to grab all the data and display it
dhruvasagar has joined #ruby
<any-key>
or you can use something like google calendar and embed that
<kah_>
any-key: so i'm using ruby
<kah_>
any-key: that's always an option too, lets say i was to do it with ruby, how would you do that
maletor has joined #ruby
thesirdanny has joined #ruby
thesirdanny has quit [#ruby]
<any-key>
I'd use Nokogiri
<kah_>
hmm haven't heard of that
<any-key>
parse the .ics file, pull out the information you want
<any-key>
then just display it however you feel like
<havenn>
kah_: Use the gem nokogiri (nokogiri.org) to parse the xml or use RiCal gem or another ical gem.
<kah_>
hmm ok, cool guys thanks! I'll look into those
dhruvasagar has joined #ruby
stefanp_ has joined #ruby
jitesh_shetty has joined #ruby
zakwilson has joined #ruby
fukushima has joined #ruby
pjn_oz_ has joined #ruby
williamcotton has joined #ruby
looopy has joined #ruby
beckettsfool_ has joined #ruby
pjn_oz has joined #ruby
pac1 has joined #ruby
Asher has joined #ruby
freeayu_ has joined #ruby
c0rn has joined #ruby
cha1tanya has joined #ruby
mxweas_ has joined #ruby
ctp_ has joined #ruby
jedir0x has joined #ruby
<jedir0x>
hi, is ruby 1.9 debuggable in eclipse with DLTK?
ElderFain has joined #ruby
Guest71832 has joined #ruby
ZeBordoada has joined #ruby
mxweas_ has joined #ruby
Hsparks has joined #ruby
headius has joined #ruby
sacarlson has quit [#ruby]
adeponte has joined #ruby
surfprimal has joined #ruby
tommyvyo has joined #ruby
keymone has joined #ruby
zz_skinny_much has joined #ruby
RORgasm has joined #ruby
dfamorato_ has joined #ruby
liluo has joined #ruby
Mohan has joined #ruby
Lyrics has joined #ruby
<Lyrics>
Anyone in the room?
Zac_o_O has joined #ruby
delinquentme has joined #ruby
<delinquentme>
OOOO OOOO!
<delinquentme>
I found a bug in ruby !
<delinquentme>
OOOOO!
<shadoi>
lol
<shadoi>
show and tell time
<delinquentme>
or at least .. an inconsistency !
<mrtheshadow>
lies
<Lyrics>
first time on the webchat client - to join rubyonrails it says i needto be identified with services - anyone know what i can do?
<joener>
@arturaz just shut up if you can help OK!!!!!!
macmartine has joined #ruby
<arturaz>
Ok, i'm going to sacrifice a kitty then
daniel_hinojosa has joined #ruby
<joener>
funny dude
wefawa has quit [#ruby]
<joener>
just shut up dude
cezar-b has joined #ruby
<joener>
i know you cant help me
<joener>
cause your pretending that you know Ruby
<joener>
ok
dhruvasagar has joined #ruby
<davidcelis>
And thus spake joener, the man who was no longer able to receive help
pygmael has joined #ruby
ChampS666 has joined #ruby
<joener>
??????
<delinquentme>
"
<davidcelis>
Please do not query me.
<joener>
ok
<davidcelis>
delinquentme: Hahha what
<arturaz>
Tab instead of space in front?
<davidcelis>
that's my guess as well
<delinquentme>
phsyics
<joener>
i think no one can help me to this room
<delinquentme>
damn.
<davidcelis>
OH
<davidcelis>
typo
<davidcelis>
lolol
<davidcelis>
Hey cool, joener left
<davidcelis>
what a dick
<arturaz>
Heh
x0F_ has joined #ruby
dshdsgdfdf has joined #ruby
nu7hatch has joined #ruby
ryanf has joined #ruby
<any-key>
wait, was he that same annoying guy that was annoying a few days ago?
iocor has joined #ruby
<delinquentme>
whats the most idiomatic ruby way to remove beginning and ending spaces on a string?
startling has quit [#ruby]
sako has joined #ruby
Kireji has joined #ruby
jgrevich has joined #ruby
jgrevich has joined #ruby
workmad3 has joined #ruby
ringotwo has joined #ruby
<davidcelis>
.strip
<davidcelis>
oh he left
<davidcelis>
oh well, he should read the docs anyway. it's not that hard
c0rn has joined #ruby
alem0lars has joined #ruby
GoBin has joined #ruby
ph^ has joined #ruby
maletor has joined #ruby
nfluxx has joined #ruby
ben225 has joined #ruby
KL-7 has joined #ruby
wilmoore has joined #ruby
jamesbrink has quit [#ruby]
IPGlider has joined #ruby
sako has joined #ruby
savage- has joined #ruby
bigkevmcd has joined #ruby
maasha has joined #ruby
Bauer1 has joined #ruby
<maasha>
Hello. I want a packed string of a specifed size with zeroed unsigned integers. What is the elegant way?
<maasha>
I guess a subquestion is how to create an array of a given size with only 0s?
<maasha>
In Perl you can do (0) x size
<maasha>
IIRC
io_syl has joined #ruby
CheeToS has joined #ruby
MasterIdler_ has joined #ruby
<maasha>
Array.new(size, "\0")
drKreso has quit [#ruby]
<maasha>
testing
ElderFain has joined #ruby
<maasha>
Array.new(20, 0).pack("I*")
arturaz has joined #ruby
<maasha>
thanks :o)
schovi has joined #ruby
ephemerian has joined #ruby
tewecske has joined #ruby
KL-7 has joined #ruby
zakwilson has joined #ruby
Eldariof-ru has joined #ruby
polysics has joined #ruby
trivol has joined #ruby
dfamorato has joined #ruby
mdw has joined #ruby
MrBar has joined #ruby
xnm has joined #ruby
ctp has joined #ruby
robert_ has joined #ruby
dfamorato_ has joined #ruby
dfamorat_ has joined #ruby
banjara has joined #ruby
luckyruby has joined #ruby
<luckyruby>
for nokogiri, is it generally better to use xpath or css for searching?
maletor has joined #ruby
<luckyruby>
in terms of performance
LMolr has joined #ruby
peterhil` has joined #ruby
blacktulip has joined #ruby
williamcotton has joined #ruby
dfamorato has joined #ruby
ken_barber has joined #ruby
<bounce>
now I know nothing about nokogiri, but that question makes no sense whatsoever to me
eka has joined #ruby
tommg has joined #ruby
lillybing has joined #ruby
t0lkman has joined #ruby
eeadc has joined #ruby
apeiros_ has joined #ruby
jenglish has joined #ruby
abra has joined #ruby
RORgasm has joined #ruby
lobolars has joined #ruby
shruggar has joined #ruby
Mon_Ouie has joined #ruby
ben225 has joined #ruby
tyman has joined #ruby
tyman has joined #ruby
jlebrech has joined #ruby
francisfish has joined #ruby
ukwiz has joined #ruby
BiHi has joined #ruby
DuoSRX has joined #ruby
alanp_ has joined #ruby
jeznet has joined #ruby
Mohan has joined #ruby
Mohan has joined #ruby
KL-7 has joined #ruby
roolo has joined #ruby
robotmay has joined #ruby
robert_ has joined #ruby
sspiff has joined #ruby
adac has joined #ruby
bluOxigen has joined #ruby
<tyman>
has anyone using the active_directory gem with 1.9?
<tyman>
s/using/used/
<maasha>
what do we use to output high resolution run time for e.g. number of records processed (every 10000).
<maasha>
Perl has TimeHiRes
<maasha>
what about Ruby?
d3c has joined #ruby
jmcphers has joined #ruby
<arturaz>
miliseconds?
<arturaz>
Time.now.to_f
<arturaz>
Lower than that? JRuby has Java::java.lang.System.nano_time
<Mon_Ouie>
Time.now.usec
<maasha>
excellent
<maasha>
usec it is
<Mon_Ouie>
Actually you can even go as far as Time#nsec
<maasha>
enuf :o)
waxjar has joined #ruby
<lillybing>
Mon_Ouie: have oyu just been away on holiday?
<Mon_Ouie>
Nope, Internet connection stopped to work here for a couple of days
pietr0 has joined #ruby
<lillybing>
Mon_Ouie: ouch, what did u do instead?
<lillybing>
Mon_Ouie: or did u just spent the entire time refreshing the google home page and staring blankly at the screen
lobolars has joined #ruby
kmurph79 has joined #ruby
tatsuya_o has joined #ruby
__main__ has joined #ruby
berkes has joined #ruby
RubyPanther has joined #ruby
sohocoke has joined #ruby
trivol has joined #ruby
workmad3 has joined #ruby
Mchl has joined #ruby
dhruvasagar has joined #ruby
ickmund has joined #ruby
Advocation has joined #ruby
dzhulk has joined #ruby
<shevy>
he did what every french without internet does
<shevy>
he danced on the streets!!!
fivetwentysix has joined #ruby
<fivetwentysix>
whats the correct way to test that a class includes a module
sohocoke has joined #ruby
<apeiros_>
fivetwentysix: SomeClass < SomeModule
<fivetwentysix>
apeiros_: example with assertion/shoulda?
williamcotton has joined #ruby
<apeiros_>
nocando
mengu_ has joined #ruby
bier has joined #ruby
<workmad3>
fivetwentysix: do you really need to test that?
<fivetwentysix>
workmad3: not really, it's covered by my integration tests, but i want a unit test for all production code lol
<workmad3>
fivetwentysix: ... you want to create useless tests that add no value?
<workmad3>
fivetwentysix: nice to see you have money to burn ;)
<fivetwentysix>
workmad3: nice insult
<workmad3>
:)
<workmad3>
fivetwentysix: seriously though... think about how long it will take to write that test (obviously that's already reaching 15 mins) compared to how much utility it actually gives you
<workmad3>
fivetwentysix: and add to that the fact that if this changes in the future, you will then need to change both your integration tests and your unit tests
<workmad3>
(and if it isn't going to change and already works... why add extra tests to it? :) )
<fivetwentysix>
workmad3: good point
<fivetwentysix>
workmad3: its just weird looking at a spec
<fivetwentysix>
and it not completely covering the file it's testing
Mohan has joined #ruby
Mohan has joined #ruby
<Advocation>
hey guys, I have a weird issue with Git after installing rbenv.
<Advocation>
if I type 'git' into terminal, it comes up with -bash: git: command not found
<Advocation>
it was working before installing rbenv, but I'm just wondering what I've messed up!
<Advocation>
fairly new to this stuff..
<Advocation>
anyone got any ideas?
twinturbo has joined #ruby
SPYGAME has joined #ruby
berserkr has joined #ruby
banisterfiend has joined #ruby
dfamorato_ has joined #ruby
jesly has joined #ruby
<jesly>
any good gem via which i can manage external processes??
<shevy>
even @@class variables, and it is complicated anc convoluted
<shevy>
when you have a problem, it is best to bring it down to the most simplest form
ken_barber has joined #ruby
<shevy>
like a few lines where you can reproduce the problem, and also say what you expected or want to have instead
bluenemo has joined #ruby
arturaz has joined #ruby
<Mon_Ouie>
shevy: Check #ruby-lang
<Mon_Ouie>
radoen: do not cross post like that
fr0gprince_mac has joined #ruby
Mohan has joined #ruby
Mohan has joined #ruby
richardlxc has joined #ruby
<shevy>
ah I see
nari has joined #ruby
arnihermann has quit [#ruby]
t0lkman has quit [#ruby]
williamcotton has joined #ruby
pibako has joined #ruby
falena has joined #ruby
pibako has joined #ruby
ukd1 has joined #ruby
clockwize has joined #ruby
<TTilus>
fivetwentysix: you need to think what you are up to with testing
<TTilus>
fivetwentysix: is it complete line coverage, branch coverage, path coverage or just plain you being sure that what you do works?
pibako has joined #ruby
freenetw has joined #ruby
pibako has joined #ruby
Squarepy has joined #ruby
akemrir has joined #ruby
dbgster has joined #ruby
LMolr has joined #ruby
banjara has joined #ruby
LMolr has joined #ruby
freenetw has quit ["Bye"]
pibako has joined #ruby
davidpk has joined #ruby
pibako has joined #ruby
bluelf has joined #ruby
pibako has joined #ruby
emmanuelux has joined #ruby
dhruvasagar has joined #ruby
sheldonh has joined #ruby
sheldonh has quit [#ruby]
davidcelis has joined #ruby
frishi has joined #ruby
ph^_ has joined #ruby
williamcotton_ has joined #ruby
iamjarvo has joined #ruby
krusty_ar has joined #ruby
eam has joined #ruby
Kireji has joined #ruby
nu7hatch has joined #ruby
radic has joined #ruby
_AlbireoX has joined #ruby
nanderoo has joined #ruby
iocor has joined #ruby
Ammar01 has joined #ruby
mcwise has joined #ruby
cha1tanya has joined #ruby
davidpk has joined #ruby
fayimora has joined #ruby
ph^ has joined #ruby
xcvd has joined #ruby
JCBK has joined #ruby
<JCBK>
is there some way to get wildcards to work with dir.foreach?
JohnBat26 has joined #ruby
kmurph79 has joined #ruby
mdw has joined #ruby
riginding has joined #ruby
wvdschel has joined #ruby
RORgasm has joined #ruby
sectionme has joined #ruby
fermion has joined #ruby
ph^ has joined #ruby
`brendan has joined #ruby
dshdsgdfdf has joined #ruby
<Mon_Ouie>
Use Dir.glob instead?
tijmencc has joined #ruby
mcwise has joined #ruby
BiHi has joined #ruby
<JCBK>
Mon_Ouie yeah did that now, works well. but then I want to write the whole bunch to a single string, how do I do that?
<Mon_Ouie>
I don't know what you mean by that. #join?
<JCBK>
well the whole process I'm trying to accomplish is this
apok has joined #ruby
<JCBK>
scan a directory for html files, omit the directory and the extension (so /foo.html and /foo/bar.html become foo and /foo/bar) and then write it all to all json file
ken_barber1 has joined #ruby
jbw has joined #ruby
lorandi has joined #ruby
ken_barber1 has joined #ruby
n1x has joined #ruby
<canton7>
JCBK something like Dir.glob('**/*.html').map{ |f| f.chomp('.html') } (there might be a neater way to get the extension off)
n1x has quit [#ruby]
<apeiros_>
canton7: I doubt it. it's a very nice way IMO.
<canton7>
sweet!
<JCBK>
cheers
jenglish has joined #ruby
<canton7>
I always feel like I should be using strip/lstrip/rstrip to get arbitrary characters off the ends of a string, and chomp to get whitespace off the end
<JCBK>
I've got this right now: Dir.glob('../_site/**/*.html') {|x| puts "#{x}, "}
<JCBK>
how would I implement chomp into that?
fbernier has joined #ruby
rking has joined #ruby
Kireji has joined #ruby
Advocation has joined #ruby
<JCBK>
because I need to omit both "../_site" and ".html"
fr0gprince_ has joined #ruby
<apeiros_>
to omit the "../_site", use Dir.chdir
<apeiros_>
Dir.chdir("../_site") { …glob stuff… }
eam has joined #ruby
<canton7>
pastie.org/3773895 for one way of doing it
iocor has joined #ruby
* apeiros_
prefers {} for return-value (and do/end for side-effect)
chico has joined #ruby
<JCBK>
brilliant, thanks so much!
fmcgeough has joined #ruby
<JCBK>
managed to write the it all to json as well, perfect
vrinek1 has joined #ruby
tommyvyo has joined #ruby
mattyoho has joined #ruby
philcrissman has joined #ruby
mattyoho has joined #ruby
glosoli has joined #ruby
dql has joined #ruby
dshdsgdfdf has joined #ruby
Sailias has joined #ruby
hirotoshi has joined #ruby
pu22l3r has joined #ruby
pu22l3r has joined #ruby
jesly has joined #ruby
<revon>
any one familiar with ffi??
jrist has joined #ruby
delinquentme has joined #ruby
<delinquentme>
hey all I'm wondering whats the best way to run a cron job and if it gets any errors ... id like it to email me
iamjarvo has joined #ruby
<workmad3>
delinquentme: err... that sounds like a normal cronjob
<delinquentme>
oh?
<workmad3>
delinquentme: you just need to set up your crontab appropriately
<delinquentme>
i've never run one
<delinquentme>
but after some googling .. rake tasks are better?
<workmad3>
rake tasks don't have the scheduling built in... but a popular thing to do is to write a rake task to do what you want and then schedule it with cron
<delinquentme>
yeahhh
<delinquentme>
thats what they're suggesting
<workmad3>
and make sure your task writes to stdout and stderr appropriately
cjs226 has joined #ruby
<workmad3>
a crontab with an email set up will email the output :)
pangur has joined #ruby
<delinquentme>
does capistrano run rake tasks?
<workmad3>
no
<workmad3>
you can get capistrano to run a rake task, but cap tasks aren't rake tasks
<delinquentme>
can a crontab be run from a ruby script?
<delinquentme>
erm.
<delinquentme>
cancel that
_ack_ has joined #ruby
<pangur>
undefined method `surname' for nil:NilClass in line: 38 of http://pastie.org/3774046. I have a nil data item in my first and various other rows. How do I cope with that?
Radium_ has joined #ruby
<pangur>
line 38 should be line 21 (only showing an excerpt).
mcwise has joined #ruby
<pangur>
I guess that would be obvious to anyone able to help though :)
<shevy>
pangur you should not have nil objects
<delinquentme>
ok so the heroku application runs on debian ... so the cron code should be exactly the same right?
<shevy>
also why do you use .strip.to_s()
<shevy>
I mean, if you'd be consistent, you'd at least use .strip().to_s()
<pangur>
the to_s() I need because otherwise I get a bytesize error :(
Synthead has joined #ruby
<shevy>
do you have the example "finreg.csv"
<shevy>
even if only a small part of it where the error is established
<pangur>
just a mo
dhruvasagar has joined #ruby
<shevy>
moooooooooooh
<shevy>
like a cooooooooooooow
<pangur>
MacLeod,John,4,X, triggers the error, I believe, because of the lack of a fifth data item
td123 has joined #ruby
<pangur>
What I imagine happens is that an object is not generated because there is a data item missing?
d3vic3 has joined #ruby
<pangur>
Or else the data item being supplied is a nil
<shevy>
ok so you require 5 entries but you have a line with only four
<pangur>
That's it
<shevy>
now you must decide what to do in this case
polysics_ has joined #ruby
<shevy>
your five entries are:
<pangur>
surname, forename, age, pup, sci
<shevy>
surname, forename, age, pup, sci
<shevy>
yeah
kvirani has joined #ruby
<shevy>
the first thing is - do you allow nil entries, yes or no.
<shevy>
if not, you should specify default values in case a nil occurs
<shevy>
OR
<pangur>
yes
<pangur>
ah
<shevy>
"finreg.csv" needs to have the correct input
<shevy>
I dont know how many more entries can be faulty or not, but if it is always the last entry, then you could do a simple check
<pangur>
so I should have pup="blank", sci="blank" because these are the ones likely to return a nil.
<shevy>
p.sci = 'MISSING ENTRY!'
<shevy>
end
<shevy>
yeah, you can safeguard after that
<shevy>
and check whether they are nil or not
ecolitan has joined #ruby
<pangur>
Thanks shevy :)
<shevy>
yeah
v0n has joined #ruby
<shevy>
I think I myself would prefer the assumption that the input data is always correct :)
<shevy>
I always try to assume that thinks early in the chain should not fail... and only then in the event that they really fail, do I want to write code that handles that failure
<shevy>
*things early in the chain
<shevy>
sadly reallife often is messy and faulty and crappy
<shevy>
so my code tends to (must) handle all those things that fail anyway
<shevy>
I want to live in a perfect world instead :(
<relix>
hey guys
<pangur>
If the form of the original data is such that the fifth item is a nil, how would I change the original csv file to make that nil into something acceptable?
<relix>
unfortunately the guys in #ror arent' responding, so maybe you know a good answer for this
<apeiros_>
shevy: tr(…, '') --> delete(…)
fbernier has joined #ruby
<shevy>
apeiros_ eh I dont touch other people's code ;P
<relix>
I have a ruby application and a ruby on rails application, I'd like the ruby app to consume the REST API of the ruby on rails app (they're both mine)
<relix>
what's the best way/library to use for this?
<relix>
thanks davidcelis to point me in this direction by the way
<shevy>
pangur I am not sure, just add an entry there?
<pangur>
like the word "nil"?
<shevy>
"nil" would be a string
<pangur>
or "blank" or something?
<shevy>
but, you already have a nil there, dont you? :P
<shevy>
fields[4]
<shevy>
if it does not exist it is nil
<pangur>
fields[4]=nil but I want that to be an acceptable value.
<shevy>
what value should it be when it would be assigned nil?
<pangur>
Basically, it is a list of who is registering for a kids event: puppets or science :)
mstratman has joined #ruby
<shevy>
you have [0] [1] [2] [3] [4], 5 entries if you count that
<pangur>
correct
<shevy>
"MacLeod,John,4,X, "
<shevy>
perhaps the CSV parser in ruby assumes that after the , comes something
<shevy>
just check if fields[4] is nil, then assign to some other value instead.
<pangur>
ah, ok, thanks.
A124 has joined #ruby
<shevy>
btw
<shevy>
you could write a second small class
A124 has quit [#ruby]
<shevy>
class AllMyPeople
<shevy>
hehehe
<ezkl>
shevy: Is pangur using CSV from stdlib or just the File/IO handler?
<shevy>
oh, vice versa... extending class People would be easier
wallerdev has joined #ruby
cha1tanya has joined #ruby
<pangur>
I have require 'csv'
<shevy>
p = Person.new
<shevy>
p.assign_data line
<shevy>
and the rest of it could be moved into this method, including sanity checking on your entries
<shevy>
oops
<shevy>
should be:
<pangur>
ezkl, standard library, I believe.
<shevy>
p.assign_data fields
* pangur
feels that AllMyPeople has an imperious sound to it :)
<delinquentme>
im waaaaay tired and basically " Did I send my password to anyone with that code ? "
[-mX-] has joined #ruby
abra has joined #ruby
Sailias has joined #ruby
thone_ has joined #ruby
io_syl has joined #ruby
abstrusenick has joined #ruby
yekta has joined #ruby
jrist has joined #ruby
wallerdev has joined #ruby
mikepack has joined #ruby
bbttxu_ has joined #ruby
<Boohbah>
delinquentme: hwæt
<delinquentme>
??
carlyle has joined #ruby
jenglish has joined #ruby
vipaca has joined #ruby
vipaca has joined #ruby
snip_it has joined #ruby
zonetti has joined #ruby
Ammar01 has joined #ruby
manohara has joined #ruby
danielpunt has joined #ruby
Kireji has joined #ruby
josefig has joined #ruby
jaywastaken has joined #ruby
Radium has joined #ruby
eam has joined #ruby
nlc has joined #ruby
bbttxu_ has joined #ruby
wallerdev has joined #ruby
kevinbond has joined #ruby
albemuth has joined #ruby
ceej_ has joined #ruby
ysiad has joined #ruby
<td123>
delinquentme: check your logs
<chico>
any tips for generating an TAGS file for ruby?
bean has joined #ruby
vaxinate has joined #ruby
ghanima has joined #ruby
__main__ has joined #ruby
netzapper has joined #ruby
vectorshelve has joined #ruby
joaoh82 has joined #ruby
<netzapper>
how can I compose one regex into another one? Is it just /outer_regex_stuff#{inner_regex}more_outer_stuff/?
ukd1 has joined #ruby
<Mon_Ouie>
Yep
sleetdrop has joined #ruby
<netzapper>
Mon_Ouie: was that to me?
<Mon_Ouie>
Even works if your inner_regex has different options than the outer one
<netzapper>
woah! for serious? Neat!
<Mon_Ouie>
(e.g. case insensitive)
__main__ has joined #ruby
<apeiros_>
netzapper: irb ftw :-p
<apeiros_>
it's great for "can I do X?" type questions
16SAA0QJD has joined #ruby
<netzapper>
what about capture groups? If my LABEL_RE has a capture group, and I want to do "INDIRECT_LABEL = /\[(#{LABEL_RE})\]/", which capture group gets used?
<netzapper>
apeiros_: it is good, except that the input pre-processing is kind of a bitch and makes it hard for me to just play with it in irb.
<netzapper>
apeiros_: yeah, the data I'm using goes through a normalization pass... although, I suppose a test case would be easy enough to make
<Mon_Ouie>
vectorshelve: second one could possibly silence a bug
<apeiros_>
um, no, there's no input-preprocessing in irb, netzapper.
<apeiros_>
all it does is accumulate until you have a complete statement
rye_ has joined #ruby
<netzapper>
apeiros_: no, no. I just mean that the data I'm regex'ing requires preprocessing. But, test case, I know...
<vectorshelve>
Mon_Ouie: yeah thanks but do you think it could be slower the first ?
CheeToS has joined #ruby
<apeiros_>
netzapper: um, yeah… :)
<Mon_Ouie>
netzapper: You could use any data you want to test if you can nest two regexps using the syntax you mentionned
<netzapper>
I know, I'm working on that.
PragCypher has joined #ruby
<shevy>
what do you guys use when you want fancy colours in your project? (commandline based, linux primarily)
<canton7>
vectorshelve, the speed difference is going to be minimal. focus on what's more readable and better behaved
<vectorshelve>
canton7: ok thanks mate
mikepack has joined #ruby
<canton7>
vectorshelve, I might be tempted to do this: http://pastie.org/3774640 . It makes the assumption that @current_user will always be nil if session[:user_id] is nil, which might or might not be right
<vectorshelve>
canton7: right mate thanks
<Mon_Ouie>
shevy: I usually use the term-ansicolor gem
<vectorshelve>
canton7: makes sense.. with concise code :) looks beautiful as ruby
<vectorshelve>
canton7: ruby <3
EzeQL has joined #ruby
ckrailo has joined #ruby
<canton7>
vectorshelve, hehe, yup :D You start to wonder how other languages manage to be so verbose :P
<vectorshelve>
canton7: but I think it's pretty much wrong to begin with, if the user in the session is nil or doesn't exist in the database, you are not logged in, please go see the login screen right ?
rippa has joined #ruby
IrishGringo has joined #ruby
<canton7>
vectorshelve, hrm? I don't know how your site works. If this is only going to be used on pages you have to be logged in to see, then it's pretty safe to assume that the session[:user_id] must be set by the time that current_user is called
<vectorshelve>
canton7: thanks mate :(
francisfish has joined #ruby
<vectorshelve>
canton7: :)
paxcoder has joined #ruby
<canton7>
vectorshelve, on the other hand, if this function might be used on a page where the user could or could not be logged in, it's worth making it behave nicely if session[:user_id] doesn't exist
<paxcoder>
i need to match $var, is the correct regex $var or \$var?
<vectorshelve>
canton7: right
iocor has joined #ruby
<canton7>
paxcoder, the latter
<paxcoder>
thx
<canton7>
paxcoder, rubular.com is pretty good btw
<vectorshelve>
It's getting too too hot in India now :(
slonimsky has joined #ruby
lkba has joined #ruby
flagg0204 has joined #ruby
<canton7>
it keeps hailing in england... opposite problem
Vert has joined #ruby
hydrozen has joined #ruby
<paxcoder>
canton7: thanks
JCBK has quit [#ruby]
artm has joined #ruby
krusty_ar_ has joined #ruby
* artm
is implementing custom YAMLisation for an object (implementing 'encode_with(codec)'). Is it possible to force inline format for lists for this class?
bglusman has joined #ruby
dql has joined #ruby
davidpk has joined #ruby
workmad3 has joined #ruby
InBar has joined #ruby
jeebster has joined #ruby
sterNiX has joined #ruby
kenperkins has joined #ruby
jeebster has quit [#ruby]
jeebster has joined #ruby
cbuxton has joined #ruby
qos has joined #ruby
stefanp has joined #ruby
stefanp has joined #ruby
davidcelis has joined #ruby
<paxcoder>
this line returns a Matchdata object, why: "anna".match(/a/) {|a| puts a}
dfamorato has joined #ruby
<paxcoder>
(nothing is printed)
<any-key>
try changing puts to p
<paxcoder>
no effect
<paxcoder>
guess it doesn't call the block
<paxcoder>
no matches? how?
<any-key>
"anna".match(/a/)[0] # => "a"
andrewhl has joined #ruby
arkiver has joined #ruby
<paxcoder>
any-key: i remember trying .each, failing, then reading that match takes a block... *shrug*
<any-key>
paxcoder: "anna".match(/a/) { |a| puts a } # => a
<any-key>
paxcoder: what version of ruby?
<paxcoder>
any-key: old one? :-)
<arkiver>
Hi, I'm trying to create a database in rails and I need to use enums. How to do this in rails ?
<any-key>
paxcoder: yeah I'm not sure how match behaves pre-1.9
baroquebobcat has joined #ruby
<shevy>
arkiver the rails people fled to #rubyonrails
<shevy>
we here know only general ruby things
<any-key>
we chased them out with torches and pitchforks
<shevy>
yeah
<shevy>
I also told them to press the any-key
<arkiver>
shevy: Thanks.
<shevy>
these turned mad
<any-key>
arkiver: ruby doesn't have enums, symbols are the closest thing
<shevy>
he probably meant symbols
<shevy>
wonder where he got the word enum ...
JohnBat26 has joined #ruby
<any-key>
every other programming language?
<canton7>
databases often support enums
<davidcelis>
no, he means enum
<any-key>
it really depends on the DB he's using
<shevy>
!!!
<davidcelis>
it's a database string-like field that only allows a specific set of values
<paxcoder>
any-key: alright, using 1.9.2 now. i get a single "a". shouldn't it match globally?
<shevy>
a database that has enums???
<canton7>
mysql, for starters
<shevy>
whoa
<any-key>
paxcoder: nope, match just finds the first occurrence iirc
bluOxigen has joined #ruby
<davidcelis>
shevy: it's a database string-like field that only allows a specific set of values
<apeiros_>
that's why I rectified my statement, from unpack to pack :)
maletor has joined #ruby
pygmael has joined #ruby
luckyruby has joined #ruby
<rodd>
Hi, I'm new to ruby and would like some help. Been trying to setup rvm + passenger + apache2, followed a few tutorials including this one http://beginrescueend.com/integration/passenger/ The setup went fine, apparently. However when running the app i get the following msg: "Could not find rake-0.9.2 in any of the sources (Bundler::GemNotFound)" Any idea on how I could get that sorted out? thanks in advance
<apeiros_>
rodd: run `gem install rake`
<rodd>
I have rake installed
cwang has joined #ruby
<canton7>
rodd, is your Gemfile right? Does it have the correct source at the top?
<rodd>
there were a few dep, managed them and re ran it
<workmad3>
rodd: how did you do your bundle install? for a deployment, it's normally safest to do 'bundle install --deployment'
Cyrus has joined #ruby
<rodd>
workmad3, I just entered 'bundle install'
<rodd>
can I reset a bundle install?
<workmad3>
rodd: just run the command I just gave again, it'll change the bundle config and reinstall ;)
<rodd>
sweet let me tr
<rodd>
y
<workmad3>
and it will do a full reinstall with that one... it'll install all your gems into vendor/bundle
mxweas_ has joined #ruby
PragCypher has joined #ruby
adamkittelson has joined #ruby
<rodd>
bundle complete
jhunter has joined #ruby
<rodd>
awesome, it worked!
hadees has joined #ruby
<rodd>
thanks a lot, I've been hitting my head on this one for hours
sako has joined #ruby
kenperkins has joined #ruby
<workmad3>
rodd: the issue was probably then that your passenger wrapper wasn't seeing the same gemset as you'd installed into... but that's why the --deployment flag is good :)
<rodd>
great, thanks workmad3 !
radic has joined #ruby
_adeponte has joined #ruby
<paxcoder>
"two".scan(/(one)|(two)/) returns [[nil, "two"]], i want *either* group to be matched. in other words, how do i get it to return ["two"]?
brianpWins has joined #ruby
<paxcoder>
oh, and note that i need those groups.
<apeiros_>
(one|two)
<paxcoder>
apeiros_: the above.
<apeiros_>
that makes no sense
<apeiros_>
you either have two groups or one group
<paxcoder>
apeiros_: ok, how do i flatten each array in an array (to remove nil)?
<apeiros_>
maybe you're explaining your problem badly, and you're looking for non-capturing groups…
<apeiros_>
yeah, now it sounds like that…
<paxcoder>
apeiros_: i can give you the real regex
<apeiros_>
(?:one)|(?:two)
yxhuvud has joined #ruby
<paxcoder>
apeiros_: you mean ((?:one)|(?:two)) ?
savage- has joined #ruby
<apeiros_>
no outer parens required, no
<apeiros_>
just /(?:one)|(?:two)/
<apeiros_>
unless your explanation is still laking…
<apeiros_>
*lacking
<paxcoder>
actually, that's not it. you're going to need the full regex
<apeiros_>
you don't need grouping for that at all
<apeiros_>
got an example line?
<paxcoder>
apeiros_: for string "'$one' 'two' 'three' '$four'", it should return ["$one", "'two'", "'three'", "$four"] #notice the quotes around two and three
shtirlic has joined #ruby
hrs has joined #ruby
schovi has joined #ruby
pluerna has joined #ruby
<pluerna>
hi guys
<apeiros_>
paxcoder: yeah, then as said, you don't need no grouping. just drop the parens.
eywu has joined #ruby
<paxcoder>
apeiros_: i'm actually making a script to turn bad SQL-injection prone statements into nice, prepared ones.
<apeiros_>
paxcoder: wrong solution.
<apeiros_>
paxcoder: trying to sanitize sql is doomed to fail. use bind variables.
<pluerna>
what is the reverse of the next methods (string) ?
<paxcoder>
apeiros_: i'm not sanitizing it manually
<canton7>
pluerna, it's not really possible
<paxcoder>
apeiros_: anyway, the key there is not to have quotes around $vars
ed_hz_ has joined #ruby
shtirlic_ has joined #ruby
<apeiros_>
paxcoder: it doesn't matter whether you do it manually or automatically. trying to sanitize sql is the wrong approach.
<pluerna>
canton7: why ?
<apeiros_>
paxcoder: seriously, read up on bind variables.
<paxcoder>
apeiros_: if i leave the groups out, i'm going to have them, or otherwise match a variable that's not quoted
<paxcoder>
apeiros_: you don't understand, i'm separating strings ad variables into an array, and then I have those "?"'s in their place in the SQL string.
<paxcoder>
apeiros_: eg. for $query="SELECT * from $table"; $db->query($query) i'm going to get $query="SELECT * from ?"; $db->query($query, array($table))
Sailias has joined #ruby
Araxia_ has joined #ruby
<arturaz>
i thought this is #ruby, not #php :)
<apeiros_>
paxcoder: you mean your db is crappy and doesn't know keyword bind-variables, so you do that manually?
<paxcoder>
apeiros_: no, it can keyword-bind. it's just easier to do this, and the end result is pretty much the same
<apeiros_>
…
* apeiros_
is stunned
maskact has joined #ruby
* paxcoder
rolls eyes
Mohan has joined #ruby
<apeiros_>
well, I told you how to do the scan
<paxcoder>
apeiros_: your way would match quotes. i don't want quotes.
<paxcoder>
or rather, i do, but not around php variable identifiers
<apeiros_>
then do a 2nd step and strip them
bluenemo has joined #ruby
bluenemo has joined #ruby
<paxcoder>
sigh
<apeiros_>
or use look-arounds
<paxcoder>
how?
<apeiros_>
you either get a nested array or you get the quotes. that's how scan works.
<apeiros_>
scan will either contain the complete match or all capturing groups
<Synthead>
can I store a function's name as a string, then execute it from the string?
<td123>
Kovensky: ruby 1.9.3 p125 is alright
<td123>
not sure what 1.8.7 is doing :P
<Kovensky>
me neither
<Kovensky>
my guess would be that (1 < 0) returns nil instead of false
<Mon_Ouie>
puts ((1 < 0) == (0 < 1)) ? "WTF" : "all is right" works just fine here
<apeiros_>
Kovensky: can't reproduce
<apeiros_>
even with 1.8.7
<Synthead>
eval! eval(string)
<Kovensky>
hmm
<sam113101>
Synthead: method('string').call(args)
<Mon_Ouie>
Synthead: No, you most likely want to use Object#send
<apeiros_>
Synthead: given that ruby has no functions, no. but you can store the name of a method as a string.
<Kovensky>
I don't have a ruby on this computer so I couldn't verify myself
<apeiros_>
Synthead: and then send, as Mon_Ouie already said. damn. too fast he is! :(
ctp has joined #ruby
<apeiros_>
also you can store a Method instance and call it later (unlike just having the method name, a Method instance also encompasses the receiver)
<Kovensky>
also, that screenshot has a p. high linecount on irb
<Kovensky>
nothing prevents the guy from having monkeypatched ==
cha1tanya has joined #ruby
<apeiros_>
Kovensky: so that's not your irb session?
<Kovensky>
nah, someone linked that on another channel
<apeiros_>
even low line count means nothing. can use irb -r to load stuff.
<Kovensky>
probably got linked from somewhere else too
<Kovensky>
heh
TheIronWolf has joined #ruby
<sam113101>
how do I use the send method
<td123>
Kovensky: somebody's probably just screwing around :P
<Mon_Ouie>
object.send(method_name, *arguments)
<Kovensky>
<<instance>>.send(symbol, *args) => does the same as <<instance>>.symbol(*args)
two- has joined #ruby
<sam113101>
is it better send or method(method_name).call(*args)
mdhopkins has joined #ruby
kenichi has joined #ruby
<Kovensky>
method(method_name) will return method_name on *your* object, not on the object you want to call
<Kovensky>
just use send; method().call() ends up just being boilerplate
<Kovensky>
(in that case)
Vert has joined #ruby
<hashpuppy>
in irb, i'll get stuck where my evaluations don't get processed. is there a way i can break out of this w/o quitting
<hashpuppy>
for example, when i forget a }
<apeiros_>
ctrl-c
strife25 has joined #ruby
<hashpuppy>
for some reason, that doesn't seem to work sometimes
<hashpuppy>
maybe i'm imagining things
jacktrick has joined #ruby
Ontolog has joined #ruby
voodoofish430 has joined #ruby
fr0gprince_ has joined #ruby
tatsuya_o has joined #ruby
mcwise has joined #ruby
tatsuya_o has joined #ruby
stephenjudkins has joined #ruby
mxweas_ has joined #ruby
musl has joined #ruby
shadoi has joined #ruby
kmurph79 has joined #ruby
looopy has joined #ruby
nikhgupta has joined #ruby
senthil has joined #ruby
f0ster has quit [#ruby]
johnn has joined #ruby
Advocation has joined #ruby
crankyco_ has joined #ruby
srnty has joined #ruby
d34th4ck3r has joined #ruby
vaxinate has joined #ruby
strife25 has joined #ruby
mrtheshadow has joined #ruby
workmad3 has joined #ruby
crankycoder has joined #ruby
nightlycoder has joined #ruby
PragCypher has joined #ruby
thecreators has joined #ruby
srnty has joined #ruby
PaciFisT has joined #ruby
kirun has joined #ruby
krzkrzkrz has joined #ruby
Araxia_ has joined #ruby
brngardner has joined #ruby
snearch has joined #ruby
imsplitbit has joined #ruby
mikeycgto has joined #ruby
mikeycgto has joined #ruby
maskact has joined #ruby
axl___ has joined #ruby
macroevolve has joined #ruby
<macroevolve>
join #rails
adac has joined #ruby
n3m has joined #ruby
francisfish has joined #ruby
<apeiros_>
macroevolve: you're aware that #rails is a dead thing, the channel you want is #rubyonrails (#ror forwards to it)
KL-7 has joined #ruby
linoj_ has joined #ruby
d3c has joined #ruby
benoit___ has joined #ruby
workmad3 has joined #ruby
startling has joined #ruby
williamcotton has joined #ruby
ceej_ has joined #ruby
nobitanobi has joined #ruby
savage- has joined #ruby
<nobitanobi>
I have a question... Given that I don't know if a variable is declared or not, how do I assign the variable value to another variable if it exists, and assign nil, if it doesn't? So something like: my_new_var = my_old_var
<nobitanobi>
but if my_old_var doesn't exist, assign nil to my_new_var
shruggar has joined #ruby
<apeiros_>
nobitanobi: if you do not know whether a local variable has been defined at a given point, then you've done something very very wrong
<apeiros_>
local scopes should be quite short (<50 lines, preferably in the 5-15 lines range)
_numbers has joined #ruby
<nobitanobi>
actually, I can defined to nil and then it can be overwritten
<_numbers>
in a Capfile with capistrano 2.x you can provide command-line configuration variable overrides using the -s var=new_value argument
<Mon_Ouie>
nobitanobi: I think you're confusing "references nil" and "doesn't exist"
ed_hz_ has joined #ruby
<_numbers>
but how do you reference it from within the capfile?
<nobitanobi>
Mon_Ouie: no. I know the difference. But I am just wondering what's the correct way of doing this in Ruby.
<nobitanobi>
It comes from here my doubt: raw_date = auth.fetch('extra', {}).fetch('raw_info', {})['birthday'] if auth.fetch('extra', {}).fetch('raw_info', {})['birthday']
<nobitanobi>
I would like raw_date to be nil, if the conditional is false.
<Mon_Ouie>
That's already the case as it is
berkes has joined #ruby
<Mon_Ouie>
if's and loops don't create a new local variable scope
<nobitanobi>
oh, ok..
<Mon_Ouie>
Also, I wouldn't repeat the auth.fetch('extra', {}).fetch('raw_info', {})['birthday'] twice
<Mon_Ouie>
Plus if that expression can't evaluate to nil, all you have to do is drop the condition
<canton7>
in fact, if the if statement is checking to see whether ...['birthday'] is nil (not false) you can skip the if cnodition altogether
<Mon_Ouie>
I meant to false*
<_numbers>
whats the shortest way i could search ARGV for a value "-s" and then delete it and the next array index after it?
tommyvyo has joined #ruby
<canton7>
or, if auth...['birthday'] *can* be false, you could do raw_date = auth...['birthday'] || nil
<nobitanobi>
Mon_Ouie: you wouldn-t repeat that? Then how yould you know if is fetchable?
<canton7>
nobitanobi, you're fetching it and seeing if it exists, then fetching it *again* if it does
Araxia_ has joined #ruby
<hashpuppy>
I'm working on an old rails 2 app and the only way I can get it running is if I add "require 'thread'" above require boot in my Rakefile, environment file, and script/server file. what's the impact of this if I deploy to production running nginx like this?
<hashpuppy>
wrong channel... meant #rails
ctp has joined #ruby
<nobitanobi>
canton7: I thought by doing the condition I was ensuring to try to fetch it, to avoid getting undefined index.
ceej has joined #ruby
<canton7>
nobitanobi, to simplify your statement, you're doing raw_data = a['key'] if a['key']
<nobitanobi>
canton7: what worries me is the index 'birthday' if is not there, and I don't do the conditional, I will get an undefined index.
<canton7>
I mean, if you were doing raw_data = a['key'] if a.include?(:key) I would understand where you were coming from
<canton7>
anyway, accessing an undefined hash index in ruby results in nil, not an error
<nobitanobi>
ok.
<nobitanobi>
thanks canton7
<canton7>
_numbers, something like parts = ARVG.slice!(ARGV.index('-s'), 2) if ARGV.include?('-s') ?
<canton7>
_numbers, use something like OptionParser or trollop, anyway
<nobitanobi>
canton7: the problem is when doing chaining in access a has. If the first index doesn't exist, you will try to access a key within a nil object.
<nobitanobi>
right?
<canton7>
nobitanobi, sure. You weren't checking that, though
<nobitanobi>
*in access a hash.
<nobitanobi>
canton7: so what's the correct way of checking that, in a one liner version? Checking let's say a three dimension hash.
<nobitanobi>
so I am expecting my_hash['extra']['raw_info']['birthday']
<canton7>
nobitanobi, I haven't come across a neat way to do that... I'd do var = ... if my_hash['extra'] && my_hash['exta']['raw_info#
<canton7>
but maybe someone on here has a nicer way
<canton7>
hashpuppy, I tihnk #rubyonrails is more activ
krzkrzkrz has joined #ruby
<hashpuppy>
thanks
Akuma has joined #ruby
<nobitanobi>
canton7: ok...
<nobitanobi>
thanks
<any-key>
wow that's a lot of hashes
<any-key>
"yo dawg, I heard you like hashes..."
<canton7>
I've seen stuff that size crop up when parsing config files and the like
<canton7>
where the user might or might not have deleted a particular key...
lkb has joined #ruby
<canton7>
though I guess you *could* monkey-patch NilClass to respond to [], and return nil
<canton7>
actually that works quite well. It's probably got some hidden dangers and potential pitfalls though
<any-key>
I dunno if this helps, but you can initialize a hash's default value with a proc
stkowski has joined #ruby
<canton7>
heh, I guess you could set the default value to an empty hash. Not as easy to test for, though, and someway disposed towards creating confusion in the future
<any-key>
changing default hash values is kind of frowned upon :\
<any-key>
but if it makes life much easier I say go for it
<canton7>
easier for whom? You or the guy maintaining your code? :P
<nobitanobi>
any-key: that has comes from Facebook API
<nobitanobi>
so FB loves hashes >_>
<any-key>
"has comes from" broke my English parser
<andantino>
i am kind of looking for something to keep me busier a bit longer
td123 has joined #ruby
brngardner has joined #ruby
<shevy>
well
<shevy>
I dunno really
<shevy>
the pickaxe is ok
<shevy>
but to be honest
<shevy>
I think for 95% of the problems where it gets much more complicated than in the chris pine tutorial... something is wrong
<shevy>
best thing is to start a project, with several .rb files and classes and modules on your own
_class_ has joined #ruby
<shevy>
that'll teach you how to install things, how to require things properly, how to all turn it into a gem
<shevy>
ideally host the project at github
Guest5330 has joined #ruby
davorb has joined #ruby
<shevy>
ah yes, and slowly let your project grow
Guest5330 has quit [#ruby]
<andantino>
what if it wilts?
<shevy>
simply add things slowly
h4mz1d has joined #ruby
<shevy>
eventually you'll come at a point where you will rewrite parts of it anyway
<shevy>
ideally you'll do that in a way as to keep the project still working at any given time
<shevy>
and you can use tests to ensure that, too
<atmosx>
andantino: I'm very satisfied by… "Beginning Ruby: From Novice to Professional" by Peter Cooper
<atmosx>
andantino: Chris Pine's book is kinda limited .. it's like for kids
<andantino>
yeah i was looking at that one
<andantino>
or learning ruby
<oooPaul>
Isn't Chris Pine the guy who's playing the new Kirk?
<andantino>
like i have done some programming....ive basically done language hopping for about a year
<atmosx>
While this one is at least as comprehensive and has a huge variety of topics on it… I mean I stopped at the 6th chapter, because I was able (with some help from the ml and here) to crate my own projects easily.
<atmosx>
at least the ones I wanted to mess with so far.
<andantino>
im almost done a perl in 24hours book here but the grass looks greener on the ruby side
<atmosx>
andantino: the one I mention is really good. You can start with no knowledge of programming and (if you read the entire thing) end with a good grasp of ruby. You can do practically everything. You don't become an *expert* with one book though and… above all imho the best thing is to write programs as much as possible.. it's the only way of learning fast.
vaxinate has joined #ruby
<atmosx>
perl? omg
senthil has joined #ruby
<atmosx>
that's a cryptic language lost in time
<atmosx>
do people still do that? I mean, for things other than regexp?
<andantino>
perl is kinda fun
<atmosx>
for is like Chinese
<senthil>
do you guys remember that one rubyist personal website which has a cmd line interface?
<atmosx>
for *me*
<atmosx>
senthil: I know that are you talking about but I don't remember the URL
<atmosx>
s/that/what … shit it's late, I have to go to bed (apparently)
<senthil>
atmosx: was it peter cooper?
EvanR has joined #ruby
<atmosx>
senthil: hmm might be, yes
<atmosx>
or the other guy, that I follow on twitter maybe
<atmosx>
it was a geek of that statue though
<andantino>
well i might go with beginning ruby then...
<jlebrech>
Mon_Ouie that's not a problem in my instance
s0ber_ has joined #ruby
y3llow_ has joined #ruby
ghanima has joined #ruby
<shevy>
"Rasputin impersonator"
<shevy>
man
<shevy>
I wanna be a Rasputing impersonator
<shevy>
but I can never get such a great beard :(
pangur has joined #ruby
krusty_ar has joined #ruby
y3llow has joined #ruby
<senthil>
we can't have growl notifications sent from a browser right?
sebastorama has joined #ruby
<apeiros_>
partially wrong
<apeiros_>
you can have the browser send a request to a server running on your computer and have that server translate it to a growl message
ezkl has joined #ruby
ezkl has joined #ruby
<senthil>
apeiros_: seems complex for something so simple
<apeiros_>
you have an odd idea about simple…
xcvd has joined #ruby
ezkl has joined #ruby
y3llow has joined #ruby
<pangur>
http://pastie.org/3776686 gives me the error on line 20. Otherwise it tells me that surname is not the attribute of a nil class. Are my data not getting to my instance attributes? What do I need to do to fix my error, please?
ezkl has joined #ruby
ezkl has joined #ruby
<apeiros_>
pangur: yay, you're creating a new class on every request there!
<apeiros_>
don't put class definitions inside blocks/methods
ezkl has joined #ruby
<apeiros_>
pangur: paste the error you get
<pangur>
Is my class definition not within my struct, apeiros_? All I am doing in 10..14 is mapping my data to the attributes? No?
<pangur>
ok
<apeiros_>
pangur: you define your class within the `get '/fun' do` block
<apeiros_>
don't
<apeiros_>
put it above it
<pangur>
ah
<apeiros_>
also, use [] instead of Array.new
<apeiros_>
ah, I didn't spot the problem because you indent badly
<pangur>
sorry
<apeiros_>
.each { … } introduces a new scope for local variables. p is not defined outside of it. do `p = nil` before the each.
<shadoi>
pangur: a good general rule is use { .. } when it's a one-liner and do … end when it's multi-line
<apeiros_>
shadoi: I disagree :-p
<shadoi>
apeiros_: but you're wrong! :)
<apeiros_>
a good general rule is use { … } if you care about the return value, use do … end when you care about the side-effect
<apeiros_>
single- vs. multiline is easy to see without using {} vs do/end
mengu_ has joined #ruby
mengu_ has joined #ruby
<apeiros_>
using do/end for side-effect works nicely with DSLs too, where you usually don't want to use parens.
<shadoi>
apeiros_: I guess I almost always only do multi-line blocks for things that I care about the side-effect for.
waxjar has joined #ruby
<apeiros_>
and using {} for return values works well because do/end looks stupid when you chain
<shadoi>
yup
VegetableSpoon has quit ["Leaving"]
<shadoi>
same result, different rule I guess
<apeiros_>
not for me. I've a couple of multi-line {}'s
<apeiros_>
I rarely ever have single line do/end's, though.
<pangur>
Should people.each do |p| return p.surname not give me every surname in the array?
looopy has joined #ruby
<d34th4ck3r>
pangur: no.
<oooPaul>
Return jumps the code block.
<apeiros_>
pangur: people.map { |p| p.surname }
<oooPaul>
Yes -- try that.
<oooPaul>
(beat me to it)
<pangur>
thanks apeiros_
<pangur>
and oooPaul :)
<pangur>
and d34th4ck3r :)
hcumberdale has joined #ruby
cHarNe2 has quit [#ruby]
mxweas_ has joined #ruby
looopy has joined #ruby
<d34th4ck3r>
pangur: you can return a value just one time. you can't return something from within loop. you can return something from function. the funtion terminates after return and the lines in the funtion below are not executed.
_class_ has joined #ruby
<pangur>
Thanks d34th4ck3r. Where do I put my return for the people.map { |p| p.surname }
dwon has joined #ruby
<pangur>
I have tried it after that line and I have tried it within the {} but only one surname each time.
<inemion>
Any good resources out there for doing a rails at that would be real time monitoring system? Not sure where to start on this one
<d34th4ck3r>
pangur: no where. I'd suggest pack the values into an array and then return the array.
<pangur>
Is that not what people.map does?
<pangur>
I have the values in people.
jacob1 has joined #ruby
Squarepy has joined #ruby
tommyvyo has joined #ruby
<pangur>
When I do return people.to_s - there is only one surname
<d34th4ck3r>
pangur: u can user people[index][surname]
emmanuelux has joined #ruby
<d34th4ck3r>
*u can use people[index][surname]
<d34th4ck3r>
to get the value of specific person's sername.
Squarepy has joined #ruby
<d34th4ck3r>
like people[1][surname]
<d34th4ck3r>
or people[0][surname]
<d34th4ck3r>
basically people is a 2D array from what I could get.
<pangur>
It is an array of rows - each row being a person's data.
<pangur>
I want each row in the array returned
<pangur>
Is that a nested array?
<d34th4ck3r>
pangur: yea.
<pangur>
So, what I want is for each row to be returned.
<d34th4ck3r>
pangur: you can get each row from people using people[index]
<d34th4ck3r>
example: people[0] will return first row.
keymone_ has joined #ruby
ken_barber has joined #ruby
<pangur>
OK, I can get each person like but I want it to run off the entire contents of the array without my input, as it were.
williamcotton_ has joined #ruby
<pangur>
OK, I can get each person like return people[12] but I want it to run off the entire contents of the array without my input, as it were.
_class_ has joined #ruby
looopy has joined #ruby
<pangur>
Like a kind of while array loop?
<Squarepy>
pangur use an iterator
* pangur
looks hopefully at Squarepy :)
* pangur
needs a bit more clues
mxweas_ has joined #ruby
* pangur
looks clueless
<pangur>
The conundrum is how to return all the values in an array but using return after which nothing else will execute.
<Squarepy>
a.each{|element| puts element}, or am I being silly
<d34th4ck3r>
pangur: create a callback, in which you pass the value and it would return people[value_passed] , not in the main body create a loop calling callback. :P
wbc3 has joined #ruby
<pangur>
puts will output to the console but only return will output to the screen.
<d34th4ck3r>
pangur: I can return only one value , so, to overcome this problem we use arrays.
<d34th4ck3r>
in arrays we pack the value to be returned, and then we access these value using array_name[index_of_value_needed]
<pangur>
So, I need to fetch the names from my people array and then join them into a single string and then return them?
<pangur>
return the one string
kpshek has joined #ruby
<Squarepy>
return an array if you want
<Spaceghostc2c>
I'd prefer it if you'd return with a sandwich for me.
<pangur>
people.each { |p| return p.surname } only gives me one surname
<apeiros_>
pangur: I already told you to use map
<Spaceghostc2c>
^
<d34th4ck3r>
pangur: yea, that would just give u first surname
<pangur>
people.map { |p| return p.surname } only gives me one surname
<apeiros_>
people.map { |person| person.surname } # <-- this will return an array of all surnames
<apeiros_>
pangur: no, NOT return
<pangur>
It does not matter whether I use map or each - the result is the same
<apeiros_>
this isn't java/javascript/php
<apeiros_>
pangur: yes, because you put a return in there. don't.
<apeiros_>
just as I wrote it.
<pangur>
Yeehah :)
<d34th4ck3r>
pangur: map is completely different thing from looping, dont get confused there. (If thats what confuses you)
<pangur>
It is working for me now :) Thanks again, apeiros_ :)
<pangur>
d34th4ck3r, the fact that there was not an explicit mention of return made me think that I had to add a return.
ceej_ has joined #ruby
<pangur>
I think that I have gotten the hang of it now :)
* pangur
realises that he is kidding himself
* pangur
goes away feeling pleased that he has learned a few new things - especially about map.
looopy has joined #ruby
d34th4ck3r has joined #ruby
nightlycoder has quit ["Ухожу я от вас (xchat 2.4.5 или старше)"]
Jortuny has joined #ruby
<Jortuny>
howdy - how is the seed for Array.sample decided on? (aka, how can I see sample...?)
ZachBeta has joined #ruby
Chryson has joined #ruby
mikepack has joined #ruby
mxweas_ has joined #ruby
<d34th4ck3r>
Jortuny: seed ?? random variable's seed?
<Jortuny>
d34th4ck3r: the rng's seed
<Jortuny>
the docs say sample should take a Random argument, but maybe my ruby isn't new enough :'(
elalande has joined #ruby
gregorg has joined #ruby
gregorg has joined #ruby
startling has quit [#ruby]
<Squarepy>
it probably takes the current time, like rand
asobrasil has quit [#ruby]
ben225 has joined #ruby
dshdsgdfdf has joined #ruby
seraph787 has joined #ruby
cinnamon has joined #ruby
guns has joined #ruby
Guedes has joined #ruby
nari has joined #ruby
My_Hearing has joined #ruby
ben_alman has joined #ruby
fbernier has joined #ruby
tewecske has joined #ruby
joaoh82 has joined #ruby
dfamorato has joined #ruby
Asebolka has joined #ruby
dfamorato_ has joined #ruby
iamjarvo has joined #ruby
jcrossley3 has joined #ruby
_null has joined #ruby
bwlang has joined #ruby
pu22l3r_ has joined #ruby
jcrossley3 has quit ["ERC Version 5.3 (IRC client for Emacs)"]
KL-7 has joined #ruby
fayimora has joined #ruby
sspiff has joined #ruby
chico has joined #ruby
sspiff has joined #ruby
inemion has joined #ruby
slonimsky has joined #ruby
<Shamgar>
Question for you guys. I'm working on a client that speaks a protocol that requires sending messages that are the length of the message + msg
<Shamgar>
i.e. msg = "cmd blah blah"
<Shamgar>
length = [msg.length].pack(n)
<Shamgar>
newmsg = length << msg
<Shamgar>
I then need to send that to the remote tcp socket
<shadoi>
hmm, I think you want to pack after combining.
<Shamgar>
Some of these can be quite long, and I need to do them by increments
<Shamgar>
only the length should be packed
<shadoi>
… odd
<Shamgar>
it reads those bytes, then reads <x> bytes based on unpacking that
<Shamgar>
on the remote end
<Shamgar>
So, I have a socket open
<Shamgar>
and I'm trying to send the message
<Shamgar>
I created a socket with Net::InternetMessageIO.new(s)
<Shamgar>
where s is the result of a Socket.connect call
<Shamgar>
but when I call @socket.send(msg, 0) I get an exception
<Shamgar>
It complains about the 'NUL' in the message (because some of the packed data comes out as \0)
<Shamgar>
and claims there's "no such method"
<Shamgar>
I thought "send" was the right method to use, so I would get back the length of bytes written and I could loop until all of the message was sent
<Shamgar>
the others all seem to be line oriented, which isn't what i want.