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
pdtpatr1ck_ has joined #ruby
nari has joined #ruby
<CannedCorn>
hey guys, whats the best way to let users store choose a local time for something to run, would you store their timezone
<CannedCorn>
?
mmokrysz1 has joined #ruby
sixteneighty has joined #ruby
caiges has joined #ruby
mmokrysz1 has quit [#ruby]
fr0gprince_ has joined #ruby
M- has joined #ruby
tomzx has joined #ruby
trend has joined #ruby
dv310p3r has joined #ruby
linoj_ has joined #ruby
Jay_Levitt has joined #ruby
nik_-_ has joined #ruby
Pheen has joined #ruby
CannedCorn has joined #ruby
deryldoucete has joined #ruby
Hydroxide has joined #ruby
deryldoucete has joined #ruby
red13 has joined #ruby
deryldoucete has joined #ruby
deryldoucete has joined #ruby
ZachBeta has joined #ruby
deryldoucete has joined #ruby
mmokrysz has joined #ruby
deryldoucete has joined #ruby
pastjean has joined #ruby
deryldoucete has joined #ruby
deryldoucete has joined #ruby
deryldoucete has joined #ruby
deryldoucete has joined #ruby
<fowl>
the fuck ^
pgpkeys has joined #ruby
pgpkeys has joined #ruby
lkba has joined #ruby
mmokrysz has quit [#ruby]
bwlang has joined #ruby
bwlang has joined #ruby
artOfWar has joined #ruby
vitoravelino has joined #ruby
vitoravelino has joined #ruby
libertyprime has joined #ruby
libertyprime has joined #ruby
<red13>
Hmmm... I'm contemplating deleting my Twitter account... on account of the fact that I waste too much time following people and not creating anything of value in the world.
<red13>
I deleted my Facebook account 4 years ago and never looked back.
<red13>
But I absolutely adore Twitter and find it fascinating to follow certain interesting people.
<arubin>
red13: Replace those addictions with IRC.
<red13>
That might just work.
deryldoucette has joined #ruby
trend_ has joined #ruby
<red13>
I've heard that nature abhors a vacuum. And my life is definitely a vacuum. In that it sucks shit. I wish I could be one of those fancy Dyson vacuums.
artOfWar has joined #ruby
mrbrdo has joined #ruby
thone has joined #ruby
Rishi_ has joined #ruby
pu22l3r has joined #ruby
badabim has joined #ruby
mmokrysz has joined #ruby
waxjar has joined #ruby
superguenter has joined #ruby
BRMatt has joined #ruby
tds has joined #ruby
cableray has joined #ruby
superguenter1 has joined #ruby
dwon has joined #ruby
lkba has joined #ruby
caiges has joined #ruby
waxjar has joined #ruby
nfluxx has joined #ruby
polarist has joined #ruby
sj26 has joined #ruby
tommyvyo has joined #ruby
neohunter has joined #ruby
nfluxx_ has joined #ruby
liluo has joined #ruby
mikepack has joined #ruby
Targen has joined #ruby
deryldoucette has joined #ruby
emanu has joined #ruby
S2kx has joined #ruby
td123 has joined #ruby
_|christian|_ has joined #ruby
luxurymode has joined #ruby
Anastasiya has joined #ruby
Anastasiya has quit [#ruby]
Fari has joined #ruby
duard has joined #ruby
looopy has joined #ruby
eywu has joined #ruby
headius has joined #ruby
robbyoconnor has joined #ruby
cook1es has joined #ruby
jetblack has joined #ruby
jetblack has joined #ruby
nari has joined #ruby
hydrozen has joined #ruby
sekretskwerl has joined #ruby
crescendo has joined #ruby
pu22l3r has joined #ruby
pdtpatr1ck has joined #ruby
shtirlic_ has joined #ruby
cableray has joined #ruby
iamjarvo has joined #ruby
CannedCorn has joined #ruby
pastjean has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
caiges has joined #ruby
robbyoconnor has joined #ruby
carlyle has joined #ruby
sacarlson has joined #ruby
dbgster has joined #ruby
looopy has joined #ruby
neurodrone has joined #ruby
neurodrone has joined #ruby
nopolitica has joined #ruby
dhruvasagar has joined #ruby
badabim_ has joined #ruby
shadoi has joined #ruby
r0bby has joined #ruby
liluo has joined #ruby
ed_hz_ has joined #ruby
QKO has joined #ruby
fbernier has joined #ruby
phantasm66 has joined #ruby
drake10 has joined #ruby
nfluxx has joined #ruby
nikhgupta has joined #ruby
nikhgupta has quit [#ruby]
Avanine has joined #ruby
havenn has joined #ruby
nfluxx_ has joined #ruby
sbanwart has joined #ruby
igotnolegs has joined #ruby
CheeToS has joined #ruby
pu22l3r has joined #ruby
__main__ has joined #ruby
snip_it has joined #ruby
kah has joined #ruby
SegFaultAX has joined #ruby
c0rn has joined #ruby
eignerchris has joined #ruby
headius has joined #ruby
Evixion` has joined #ruby
apok_ has joined #ruby
Drewch has joined #ruby
Fou_DRA has joined #ruby
albemuth has joined #ruby
acekiller has joined #ruby
sarguru__ has joined #ruby
maxximith has joined #ruby
Evixion has joined #ruby
n8ji has joined #ruby
<maxximith>
hi eveyrone - over the past few months I've been finishing up a prototype for a website i'm trying to develop.. so far i've created a prototype/skin for each page based on user role and how each page interacts - i had been planning to offset what i've done to a developer to help me program it. I haven't prototyped the admin panel yet.. and was hoping to get your guys' opinion on whether it would
<maxximith>
be good for me to try to create what i believe to be what i want on the admin panel - or would this be counterproductive and my work probably scrapped as the developer starts developing?
baroquebobcat has joined #ruby
zodiak has joined #ruby
cmasseraf has joined #ruby
badabim has joined #ruby
pu22l3r has joined #ruby
Zac_o_O has joined #ruby
frishi has joined #ruby
<banistergalaxy>
maxximith: or you're going to pay a developer to build it for u?
<fragmachine>
Hey how can I search for 'something' or 'something else' With grep? Eg something like 'cats dogs kangaroos'.split.grep(/(cats)||(dogs)/) - retruns cats and dogs but not kangaroos?
danishkhan has joined #ruby
Teddy2st_ has joined #ruby
<sarguru__>
Sorry for posting again but please let me know if there is away to write to fd1 of the process or is dup2 possible with ruby?
The_Tick has quit [#ruby]
csherin has joined #ruby
<heftig>
sarguru__: IO.new(1)
<heftig>
though STDOUT should already be FD 1
j0bk has joined #ruby
j0bk has joined #ruby
Gesh has joined #ruby
<sarguru__>
heftig, I want to write to it and not read from it
<sarguru__>
This is exactly what I want but I cannot see any continuation of it heftig
<heftig>
IO.new(1, "r")
<sarguru__>
and pass it on to popen4
<sarguru__>
I want to pass it to a sub process
rohit has joined #ruby
<heftig>
hmm
tomato64 has joined #ruby
stefanp_ has joined #ruby
caiges has joined #ruby
liluo has joined #ruby
<sarguru__>
heftig, for example I use open(STDOUT,<&pipeout) in perl
<sarguru__>
is there any similar thing in ruby
adeponte has joined #ruby
tomato16 has quit ["Leaving"]
pu22l3r has joined #ruby
stefanp has joined #ruby
stefanp has joined #ruby
bbttxu has joined #ruby
baroquebobcat has joined #ruby
CannedCorn has joined #ruby
<heftig>
sarguru__: test.rb:11:in `reopen': <STDOUT> can't change access mode from "w" to "r" (ArgumentError)
<heftig>
that just gets you an error
btfriar has joined #ruby
fowl has joined #ruby
<sarguru__>
mmm
stkowski has joined #ruby
zulax has joined #ruby
<sarguru__>
I know reopen wont work, What I wanted was to create a dup entry to a pipeout. Close stdout and write to it from pipe in in the parent process
<sarguru__>
but cant figure the way heftig
sefiu has joined #ruby
<fowl>
you gotta check those pipes, kids
<fowl>
clean em out
<fowl>
now think about your dad
<fowl>
i wanna meet that dad
shevy has joined #ruby
<sarguru__>
fowl, :)
<cout>
sarguru__: iirc it's something like r,w = IO.pipe; STDOUT.reopen(w)
<cout>
then write to r
<sarguru__>
reopen. will try with it cout
<sarguru__>
i was doing stdout=r.dup
banistergalaxy has joined #ruby
n8ji has joined #ruby
<sarguru__>
btw has anybody seen a qmail-queue replacement in ruby
<fowl>
sarguru__: did you dream about it or something? does such a thing exist?
<sarguru__>
Im trying to write one
<sarguru__>
The qmail-scanner in perl is very difficult to modify easily
<sarguru__>
I thought ruby should give more clarity
bbttxu has joined #ruby
cha1tanya has joined #ruby
Vadim2 has joined #ruby
<sarguru__>
fowl, thats what made me endup in trying to write to fd1 of the qmail-queue binary when I want to queue it back
rippa has joined #ruby
<shevy>
ruby is definitely nicer than perl
cmasseraf has joined #ruby
<fowl>
sarguru__: i recommend just thinking about how your going to handle the data, then write some concise ruby around that thought
<sarguru__>
but I am stuck with the initial prototyping itself due to this problem
<sarguru__>
fowl, true
gokul has joined #ruby
kawa_xxx has joined #ruby
EddieS has joined #ruby
Jay_Levitt has joined #ruby
Vadim has joined #ruby
nate_h has joined #ruby
Zac_o_O has joined #ruby
baroquebobcat has joined #ruby
mneorr_ has joined #ruby
confounds has joined #ruby
radmacd has joined #ruby
<radmacd>
Hey, silly question. What would you think is the most elegant way to grab a directory listing of a directory and put the list of tiles [not directories] with full absolute path into a string for further processing?
<shevy>
it must be a string?
<radmacd>
naw
<radmacd>
hash, array...
<shevy>
then I would make it an array
<sarguru__>
array any day
<shevy>
with full absolute path
<shevy>
to its members
<radmacd>
Yes
<sarguru__>
one more silly question from my side. kern#exece will take the input from STDIN and print the output to STDOUT replacing the present process. Correct?
pdtpatr1ck has joined #ruby
max_ has joined #ruby
<shevy>
radmacd: problem solved? :)
<shevy>
array = Dir['/some/location/*']
<radmacd>
shevy: nope… still not sure how to nail it
<shevy>
sarguru__: not sure if it will replace the current process at all
<shevy>
doesnt it start something like a subshell or subthread instead?
<seoaqua>
im suddenly confuzed about the class params of ruby
<seoaqua>
oops, typo.... sorry guys
moshee has joined #ruby
moshee has joined #ruby
LMolr has joined #ruby
pastjean has joined #ruby
<t-mart>
so, in ruby, you don't make binaries--its an interpreted language. how should i install my application on a system then if it requires many files? i don't want to just throw it all in usr/bin. im suspecting something like "require usr/lib/myapp/andsoforth"? anyone have an example project that installs to the system that might provide some insight?
PsiliPharm has joined #ruby
emmanuelux has joined #ruby
<scientes>
t-mart, rubygems is really popular, and is part of the core library with ruby 1.9
twqla has joined #ruby
<scientes>
but yeah t-mart, put it in /usr/lib/$PACKAGE/
<scientes>
if you are not going to use rubygems
<scientes>
or rather /usr/local/lib/$PACKAGE if it is not packaged and distributed by/with the OS
Shrink has joined #ruby
<t-mart>
my goal is command line execution. rubygems is really only a solution for development, right? not really end-use?
<scientes>
t-mart, rubygems can install executables which lie in the path
<scientes>
and you can use gem2rpm to package for rpm-based OS's
<t-mart>
mmm. nifty
<scientes>
and maybe even alien that to a .deb
<scientes>
but that is a streach
<scientes>
there was alot of opposition AFAIK to rubygems at one point
<scientes>
but it kinda won
<t-mart>
how long ago was this?
<t-mart>
the debate
<scientes>
not sure
undersc0re has joined #ruby
Azure_ has joined #ruby
<t-mart>
ah, but anyway, i found the docs relating to making command line utilities with ruby gems. thanks a lot! im actually glad to here there's a standardized solution built right in
undersc0re has joined #ruby
undersc0re has joined #ruby
<t-mart>
hear*
alem0lars has joined #ruby
<scientes>
e.g. rubygems put's its cache files in /var/lib/ instead of /var/cache
lobak_ has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
nemesit has joined #ruby
flippingbits has joined #ruby
<scientes>
wait /usr/lib on this box
luoluoluo has joined #ruby
<scientes>
t-mart, now, native c extentions as distributed as source, and require a compiler on the target machine
<shevy>
^^^ I did show you precisely where to start. I cant link you into chapter 11 if you dont understand the things before
durre has joined #ruby
<defV>
I have to agree with shevy
<WhereIsMySpoon>
im gonna stop this conversation before i say something bad
<defV>
and anything you already know & understand, just skip it
<shevy>
The only real way to learn ruby is to start writing ruby scripts
senthil has joined #ruby
<shevy>
and I also meant it that you don't *need* to understand blocks. You can really use just a subset of ruby and still be productive
<durre>
is RVM the recommended way of handling ruby & it's gems?
<shevy>
durre I would say the most natural one would be to compile ruby from source into /usr. I think when rubygems was started, RVM did not even exist
<shevy>
(into /usr prefix that is)
<banistergalaxy>
durre: yes use rvm
<defV>
shevy: you still do that?
<defV>
<3 rvm
<WhereIsMySpoon>
so you cant pass functions as method parameters in ruby?
tatsuya__ has joined #ruby
<shevy>
defV well actually no, I compile into /Programs/Name/Version, which expands to /Programs/Ruby/1.8.7something and /Programs/Ruby/1.9.3something
<WhereIsMySpoon>
if you want to do that you do it with procs?
<defV>
WhereIsMySpoon: you can, either as a block or with Class.method(:method_name)
<WhereIsMySpoon>
oh ok..this tutorial says you can't pass methods into other methods (but you can pass procs into methods), and methods can't return other methods (but they can return procs).
<WhereIsMySpoon>
soo
<defV>
well, for anything you need to know in that tutorial, it's not possible
<defV>
in fact, it's not very customary to pass methods to other methods
<defV>
but it is possible
<shevy>
you can do pretty much everything by using
<shevy>
eval
<shevy>
:)
<senthil>
does the term 'composition' refer to combining objects or combining methods/modules into a single object?
<shevy>
I'd assume it refers to behaviour and traits of objects
<WhereIsMySpoon>
what is an object_id of a integer useful for
<workmad3>
WhereIsMySpoon: you can also gain some insight by looking at the object_id... if it's an odd number, then you have a Fixnum
<rippa>
also, it's different each time
<rippa>
tbh, I never used object_id at all
<workmad3>
the object_id for a Fixnum is static
<workmad3>
it's not exactly 'useful' info... but it's kinda interesting IMO :)
<rippa>
for Bignum*
<WhereIsMySpoon>
rippa, no it isnt
<WhereIsMySpoon>
3.object_id is alwasy 7
<rippa>
for Fixnum it's static
<WhereIsMySpoon>
oh ok
<TTilus>
WhereIsMySpoon: ruby interpreter (kind of) instantiates bunch of objects every time it starts, the same way every time, nil, true, false and 0 belong to them, 1234.29348756 does not
<WhereIsMySpoon>
heh so it is
<WhereIsMySpoon>
so object_id for Bignum is useless
<rippa>
10.times.map {(10**12).object_id}
<WhereIsMySpoon>
unless you want to use it for a random number generator algorithm
<TTilus>
WhereIsMySpoon: definitely not useless
<WhereIsMySpoon>
if it is rando
<WhereIsMySpoon>
m
<workmad3>
WhereIsMySpoon: it isn't random
<TTilus>
WhereIsMySpoon: no
<WhereIsMySpoon>
oh ok
<rippa>
you can check if it's the same object
<WhereIsMySpoon>
whats it useful for
<TTilus>
WhereIsMySpoon: you identify the object
<rippa>
a = b = 10**80
<rippa>
a.object_id == b.object_id
<workmad3>
WhereIsMySpoon: it's essentially the memory reference (sort of)
<rippa>
a.object_id != (10**80).object_id
<TTilus>
WhereIsMySpoon: if you ever want to identify particular object, you use object_id
<WhereIsMySpoon>
i mean object_id specifically for bignums
<WhereIsMySpoon>
doesnt seem useful
<workmad3>
WhereIsMySpoon: it's as useful as for any object
<WhereIsMySpoon>
but its different every time you ask for it
<workmad3>
WhereIsMySpoon: which tells you?
<WhereIsMySpoon>
i guess you could infer that its a bignum
<WhereIsMySpoon>
but that would be a bit risky
<rippa>
it means it's different object each time
<workmad3>
WhereIsMySpoon: and is it different *every* time you ask for it? if I did 'a = 1111111111' and then '1000.times {a.object_id}' would I get a different number each time?
<WhereIsMySpoon>
no idea
<WhereIsMySpoon>
from the small test i did with 10 different executions of object_id it was different
<workmad3>
WhereIsMySpoon: would there be a difference if I did '1000.times { 1111111111.object_id }' ?
<workmad3>
WhereIsMySpoon: what does your intuition tell you happens? and can you test that intuition? ;)
<WhereIsMySpoon>
hm
<workmad3>
rippa: I'm trying to not just give the answer ;)
<WhereIsMySpoon>
yea im thinking
scalebyte has joined #ruby
<WhereIsMySpoon>
if you assign 1111111111111 to a
<WhereIsMySpoon>
a is now a bignum
schovi has joined #ruby
<WhereIsMySpoon>
but its in a different memory location than 111111111111
<WhereIsMySpoon>
which is i assume just on the stack
<WhereIsMySpoon>
stack
<scalebyte>
what exactly is store..the essential difference between a hash and a store.. ??
<WhereIsMySpoon>
i meant heap
<workmad3>
WhereIsMySpoon: is it?
<WhereIsMySpoon>
workmad3, id say yes
<WhereIsMySpoon>
but i dont know
<WhereIsMySpoon>
for sure
<WhereIsMySpoon>
yes to your original question that is
<workmad3>
WhereIsMySpoon: maybe you can test your answer? :)
<WhereIsMySpoon>
about there being a difference
<rippa>
if you assign object to a variable
<rippa>
it's the same object each time
<WhereIsMySpoon>
oh
<WhereIsMySpoon>
yea so
<WhereIsMySpoon>
i was right
<WhereIsMySpoon>
:)
<WhereIsMySpoon>
but not in the way i thought iw as
<WhereIsMySpoon>
AHHH
<WhereIsMySpoon>
i se
<WhereIsMySpoon>
e
<WhereIsMySpoon>
why it changes
<workmad3>
WhereIsMySpoon: there we go :)
<WhereIsMySpoon>
the bignum objhect is being recreated each time
<WhereIsMySpoon>
so it has different id each time
<workmad3>
bingo
<WhereIsMySpoon>
but why
<rippa>
bignum is arbitrarily big
<scalebyte>
== scalebyte is waiting for a response
<rippa>
you can't have them all precomputed
<rippa>
unlike fixnum
<WhereIsMySpoon>
ah yes
<WhereIsMySpoon>
yep
<WhereIsMySpoon>
ok
<WhereIsMySpoon>
makes sense :p
<WhereIsMySpoon>
you cant store infinity in a finite memory storage
<WhereIsMySpoon>
:D
<workmad3>
WhereIsMySpoon: yeah... and you can figure out that behaviour just by looking at the object_id ;)
frishi has joined #ruby
<workmad3>
WhereIsMySpoon: bear in mind that the koans are as much about giving you insight into the language as they are about learning the syntax :)
<WhereIsMySpoon>
well
<WhereIsMySpoon>
that was certainly interesting
<WhereIsMySpoon>
it is very strange to me
<WhereIsMySpoon>
that ints are not primitive
<WhereIsMySpoon>
and are objects
<WhereIsMySpoon>
^^
<scalebyte>
WhereIsMySpoon: Please clean up your spoon :)
<workmad3>
WhereIsMySpoon: yeah... but they're still different from other objects, as can be evidenced by their object id not following 'normal' rules ;)
<WhereIsMySpoon>
;)
<WhereIsMySpoon>
i think scale needs help
<WhereIsMySpoon>
:)
<workmad3>
scalebyte: I don't know what you mean by a 'store'
<scalebyte>
WhereIsMySpoon: yep.. I thought if you werent busy searching for the lost spoon of yours :) probably you can help me out a lil in understand what exatly is store and its difference with hash
<workmad3>
scalebyte: it's a backend for an ActiveSupport cache
<scalebyte>
workmad3: Yes... could u explain a lil.. the doc seems very implicit
<workmad3>
scalebyte: basically, you can implement a cache in different ways. The Cache store gives you an abstract interface to interact with the cache independent of the exact implementation
<workmad3>
scalebyte: and then you could swap out implementations... e.g. you could start with just a big Hash stored in your process memory, but you could swap it out for an implementation that uses memcached, or one that uses redis, and they fit the same interface so you don't need to alter how you use the cache
<scalebyte>
workmad3: so if I use a store over a hash I can cache it.. ryt ? apart from that I hope it doesnt get any better from there !!
<WhereIsMySpoon>
ooh
<workmad3>
scalebyte: you wouldn't create a Store normally... if you want to cache a value, you can grab the configured cache store from within your application, but you shouldn't just create one on the fly
<WhereIsMySpoon>
i quite like this
<WhereIsMySpoon>
array = Array.new
<WhereIsMySpoon>
array << 1
<WhereIsMySpoon>
thats nice
pastjean has joined #ruby
<workmad3>
scalebyte: and if you're just looking for storing some values, you probably don't want to get into the mess that can be caching :)
<WhereIsMySpoon>
instead of needing an add() function
<workmad3>
WhereIsMySpoon: are you coming to us from java by any chance? :)
<WhereIsMySpoon>
or push function rather
<WhereIsMySpoon>
yes i know java, also python
<WhereIsMySpoon>
i tried c++ for 2 months
<scalebyte>
workmad3: ok now the matter is i have a user.rb and inside that http://pastie.org/3593007 i do this so that for each user inside Profile object (profile belongs to user ) the serialized attribute detail gets initialized with some values
LMolr has joined #ruby
<WhereIsMySpoon>
i know how to use pointers somewhat but c++ was like one long slog
<WhereIsMySpoon>
so i gave it up
<workmad3>
scalebyte: in all honesty, you're likely to get better answers from the #rubyonrails channel
tenderloaf has joined #ruby
<scalebyte>
workmad3: I cant get into that channel since my office IP is blocked in that channel..
<workmad3>
(or at least, more discussion... I'm pretty active in there too, but I have to admit I'm going purely on intuition with these answers)
<workmad3>
scalebyte: oh, is someone in your office a #rubyonrails troll?
dql has joined #ruby
nanderoo has joined #ruby
<workmad3>
WhereIsMySpoon: C++ can be fun... but only once you get into templates really :)
<WhereIsMySpoon>
workmad3, it was extremely difficult
<WhereIsMySpoon>
and i got into language related issues almost immediately
<WhereIsMySpoon>
which is just stupid
<scalebyte>
workmad3: I think so :P its a big one so hard to find the culprit !!
<scalebyte>
workmad3: could you please help me with this.?
<workmad3>
scalebyte: in all honesty... I don't think you want a cache store
<workmad3>
scalebyte: if you don't know the reasons for caching, and the pitfalls, you don't want to go down that route
<workmad3>
WhereIsMySpoon: yeah, it can be annoying like that
<WhereIsMySpoon>
if i have array = [ :stuff, :stuff1, :stuff2 ] why is array[0, 1] only [:stuff] instead of [:stuff, :stuff1]
mmokrysz has joined #ruby
mmokrysz has quit [#ruby]
<workmad3>
WhereIsMySpoon: what would array[1,1] be?
<WhereIsMySpoon>
[:stuff1] in my head
<workmad3>
WhereIsMySpoon: first a guess based on intuition, then test it ;)
<WhereIsMySpoon>
i know it will be []
<WhereIsMySpoon>
because of what i now kno
<workmad3>
WhereIsMySpoon: and what about array[2,1] ?
<WhereIsMySpoon>
know*
<workmad3>
WhereIsMySpoon: and test your answers ;)
<WhereIsMySpoon>
[:stuff2]
<WhereIsMySpoon>
ohhh
<WhereIsMySpoon>
its from 0, 1 time
<WhereIsMySpoon>
not from 0th to 1st element
<workmad3>
WhereIsMySpoon: yup :)
<WhereIsMySpoon>
k
tommyvyo has joined #ruby
<workmad3>
WhereIsMySpoon: any ideas why ruby would have that syntax instead of the one you were thinking?
<WhereIsMySpoon>
why is array [4,0] not an out of bounds exception
monban has joined #ruby
<WhereIsMySpoon>
and instead just reutnrs nill
<WhereIsMySpoon>
returns
<WhereIsMySpoon>
if i have an array of less than length 4
<WhereIsMySpoon>
that is
doublethink has joined #ruby
<WhereIsMySpoon>
er, length 5
<WhereIsMySpoon>
you get what i mean
<workmad3>
WhereIsMySpoon: ok... that one I've never been convinced by :)
<workmad3>
WhereIsMySpoon: yeah, I know it does it
<WhereIsMySpoon>
array [4,0]
<WhereIsMySpoon>
its just nil
<workmad3>
WhereIsMySpoon: I've just never convinced myself it's 'correct'
catphish has joined #ruby
<WhereIsMySpoon>
ah
sawgij has joined #ruby
<WhereIsMySpoon>
eh
<WhereIsMySpoon>
workmad3, if i do array = [:a, :b, :c]
<WhereIsMySpoon>
then array[3,0]
<WhereIsMySpoon>
it returns []
<WhereIsMySpoon>
but if i do
<WhereIsMySpoon>
array [4,0]
<WhereIsMySpoon>
it returns nil
<WhereIsMySpoon>
wtf is this
<WhereIsMySpoon>
o.o
<WhereIsMySpoon>
index 3 isnt even in the array
<WhereIsMySpoon>
how can it not return nil
altivec_ has joined #ruby
<rippa>
just accept it
<scalebyte>
workmad3: where do you think using store (cache) are beneficial ?
<WhereIsMySpoon>
D:
<rippa>
not like you will use it or something
<WhereIsMySpoon>
rippa, but array[3,0] isnt even IN the array
<rippa>
it's just a weird corner case
<WhereIsMySpoon>
if i do array[2,0] it also returns []
<WhereIsMySpoon>
which is fine
<WhereIsMySpoon>
because i am getting 0 elements
<rippa>
think of indexes a places between elements
<rippa>
1 | :a | 2 | :b | 3 | :c | 4
<rippa>
I mean
<rippa>
0..3
<WhereIsMySpoon>
yea
<WhereIsMySpoon>
its still frickin weird
<rippa>
yes it is
<rippa>
also, array[0..1] returns first two elements
<WhereIsMySpoon>
it really looks to me like a bug :S
`brendan has joined #ruby
shevy has joined #ruby
anderse_ has joined #ruby
<banistergalaxy>
WhereIsMySpoon: google 'weird ruby array slice behaviour'
<banistergalaxy>
WhereIsMySpoon: ad you'll find a tonne of explanatins
gianlucadv has joined #ruby
anderse_ has quit [#ruby]
beha has joined #ruby
tingo has joined #ruby
mcwise has joined #ruby
nemesit has joined #ruby
gregorg_taf has joined #ruby
<apeiros_>
if anybody knows a useable image pastebin, I can upload a pic explaining WhereIsMySpoon's issue
yalue has joined #ruby
<banisterfiend>
apeiros_: imgur.com :P
<catphish>
i'm having trouble with zombie processes, can someone check over my code and tell me how i might be able to more reliably kill and dispose of child precess trees? http://paste.codebasehq.com/pastes/ir57q7dvt3880puw75
<allaire>
reverse, and = operator does not modify my initial object that was passed as an argument, but [] do.
sbanwart has joined #ruby
zandt has joined #ruby
havenn has joined #ruby
tatsuya_o has joined #ruby
<WhereIsMySpoon>
zandt, i only started last week with ruby :)
chson has joined #ruby
<zandt>
WhereIsMySpoon, started monday. so far, so good
<WhereIsMySpoon>
:D
<zandt>
trying to be productive during spring break
<WhereIsMySpoon>
good stuff
<WhereIsMySpoon>
im a little bit
<WhereIsMySpoon>
kinda
<WhereIsMySpoon>
nervous
<WhereIsMySpoon>
at the fact that if i do
<WhereIsMySpoon>
a, = [a, b, c]
<WhereIsMySpoon>
it doesnt blurt out an error
<WhereIsMySpoon>
it just continues
<zandt>
spoiler alert, I'm not that far
<WhereIsMySpoon>
it wasnt for you :)
<zandt>
haha
<zandt>
let me ask you
<zandt>
what is the comma for ?
<WhereIsMySpoon>
its like if i had
<WhereIsMySpoon>
a, b = [a, b, c]
<zandt>
ahh
<WhereIsMySpoon>
a = a
<WhereIsMySpoon>
b = b
<zandt>
I see
<WhereIsMySpoon>
its just that
<WhereIsMySpoon>
if i do that a, =[a, b, c]
<WhereIsMySpoon>
it doesnt say YOU HAVE A COMMA WITH NOTHING AFTER IT
<zandt>
haha
<WhereIsMySpoon>
its a little worrying
<canton7>
bit like python then :P
internet_user has joined #ruby
<zandt>
you can have open parentheses @ the end of chain, as well
<zandt>
er
<zandt>
not open
<zandt>
empty
<WhereIsMySpoon>
nope CannedCorn
<zandt>
sorry :P
<WhereIsMySpoon>
oops
<WhereIsMySpoon>
nope canton7
<WhereIsMySpoon>
i just did that in python
<WhereIsMySpoon>
python complains
<zandt>
brb
moshee has joined #ruby
moshee has joined #ruby
<canton7>
WhereIsMySpoon, ah, so it does. Python is rather fond of its trailing commas in general though
* WhereIsMySpoon
pokes heftig
<heftig>
aaaaah!
<WhereIsMySpoon>
how come ruby doesnt churn out an error
<WhereIsMySpoon>
when i do
<WhereIsMySpoon>
a, = ['a', 'b', 'c']
<WhereIsMySpoon>
and just carries on
<zandt>
back
<WhereIsMySpoon>
front
<zandt>
left
<heftig>
because.
<WhereIsMySpoon>
*shiv*
<heftig>
weird quirk of multiple assignment
<WhereIsMySpoon>
thats the 2nd "weird quirk" today
<WhereIsMySpoon>
:p
aibo has joined #ruby
kpshek has joined #ruby
arturaz has joined #ruby
<arturaz>
Hey. Is there a way to regain STDOUT if I get Errno::EBADF: Bad file descriptor - Bad file descriptor when writing to it?
<canton7>
WhereIsMySpoon, quote from o'reilly: "If you want to prevent the multiple rvalues from being combined into a single array, follow the lvalue with a comma. Even with no lvalue after that comma, this makes Ruby behave as if there were multiple lvalues"
<canton7>
so, I'm guessing feature
<WhereIsMySpoon>
ahhhhh
<WhereIsMySpoon>
yea its so you can assign only the first part fo the array
<WhereIsMySpoon>
without having to do x = array[0]
<WhereIsMySpoon>
surely you'd need some sort of compare method
<WhereIsMySpoon>
and then they could be the same
<canton7>
WhereIsMySpoon, hash comparisons are done value-by-value iirxc
<WhereIsMySpoon>
but they are different objects
<canton7>
*iirc
<WhereIsMySpoon>
oh
<canton7>
like strings, and arrays
<WhereIsMySpoon>
wah ;_;
<WhereIsMySpoon>
its like
<WhereIsMySpoon>
the opposite
<WhereIsMySpoon>
of java
<WhereIsMySpoon>
D:
<canton7>
almost all scripting languages do this sort of stuff for you
MasterIdler has joined #ruby
<WhereIsMySpoon>
hm
<WhereIsMySpoon>
ok
vipaca has joined #ruby
vipaca has joined #ruby
lockweel has joined #ruby
<canton7>
WhereIsMySpoon, .equal? exists to determine object identity, if that's what you mean
<lockweel>
hello, I'm wondering if someone knows any script or gem for data mining written in ruby...
<canton7>
"Equality
<canton7>
Unlike ==, the equal? method should never be overridden by subclasses: it is used to determine object identity (that is, a.equal?(b) iff a is the same object as b)."
<zandt>
WhereIsMySpoon, head explode from trying to understand what everyone is saying here :P
<zandt>
I'm not that far along
<WhereIsMySpoon>
haha
<WhereIsMySpoon>
ok :)
<WhereIsMySpoon>
zandt, you new to programming in general?
<zandt>
yeah
yoklov has joined #ruby
<WhereIsMySpoon>
you tried the lrthw (learn ruby the hard way) tutorial?
<zandt>
nope, I have some books
<WhereIsMySpoon>
ah
<zandt>
and I'm using them to compliment each other
<WhereIsMySpoon>
that tutorial is for newbies to programming
<zandt>
pickaxe + well-grounded rubyist + poignant guide + learn to program (chris pine)
<WhereIsMySpoon>
i see
<WhereIsMySpoon>
oki :)
<zandt>
learn to program is very, very basic so I start learning about a concept there
<WhereIsMySpoon>
cool
<zandt>
then shift to the pickaxe
<zandt>
and when I feel like I can't read anymore, why's guide
iocor has joined #ruby
<zandt>
I dunno, reward system I guess
<WhereIsMySpoon>
haha
<WhereIsMySpoon>
:)
<zandt>
:)
<zandt>
I'll check out learn ruby the hard way though
<WhereIsMySpoon>
its quite intensive
<WhereIsMySpoon>
but seems to go over all the basics in a really solid way
<WhereIsMySpoon>
its just a bit basic for me ;P
<WhereIsMySpoon>
*:P
<zandt>
do you have previous prog exp?
ethicalhack3r has joined #ruby
axl_ has joined #ruby
<WhereIsMySpoon>
yes
<ethicalhack3r>
Hi, how do I return an array of matches from this? "open_ports = nmap_output[%r{<port protocol="tcp" portid="(.+)">.+</port>}]"
polarist has joined #ruby
pastjean has joined #ruby
<ethicalhack3r>
open_ports returns a string
<WhereIsMySpoon>
zandt, id say if you learnt ruby as a first language, you might struggle with learning a strict language like java, or a pointer-oriented language like c++ or C, but you need to start somewhere :)
<WhereIsMySpoon>
by strict i mean type strict
<canton7>
ethicalhack3r, you probably want #scan
<zandt>
:D well, I think I would struggle with java or C++ without learning ruby, too
<WhereIsMySpoon>
but java isnt all that complicated anyway
<WhereIsMySpoon>
c++ is hard D:
<scalebyte>
does anybody know a lil bit of rails out here ?
<WhereIsMySpoon>
scalebyte, #rubyonrails
<ethicalhack3r>
canton7, thanks, I'll have a look
<scalebyte>
WhereIsMySpoon: I told you the reason in afternoon
rippa has joined #ruby
<WhereIsMySpoon>
oh sorry that was you
<WhereIsMySpoon>
scalebyte, try a different server and #rubyonrails?
<WhereIsMySpoon>
maybe there'll be one on one of the other big ones
<scalebyte>
WhereIsMySpoon: IP is shared.. or else I will have to go home :(
<scalebyte>
WhereIsMySpoon: you found your spoon ?
<WhereIsMySpoon>
scalebyte, imean try a different irc server
<WhereIsMySpoon>
like coldfront
<WhereIsMySpoon>
or whatever
<WhereIsMySpoon>
and no
<WhereIsMySpoon>
D:
<scalebyte>
WhereIsMySpoon: how do i do that ?
<WhereIsMySpoon>
./server irc.coldfront.net
Gesh has joined #ruby
<scalebyte>
./server irc.coldfront.net
<WhereIsMySpoon>
or whatever you wnat
<WhereIsMySpoon>
without the dot
<WhereIsMySpoon>
:p
<scalebyte>
WhereIsMySpoon: :)
<scalebyte>
WhereIsMySpoon: i ran the command
<scalebyte>
nothing happened
<WhereIsMySpoon>
o.o
<zandt>
fortunately scalebyte wasn't asking how to identify their nick
<WhereIsMySpoon>
rofl
<zandt>
scalebyte, do it without the dot
<zandt>
/server irc.coldfront.net
<scalebyte>
zandt: ya i ran it
<zandt>
what irc client are you using ?
WhereIsMySpoon has joined #ruby
<zandt>
or are you using a browser ?
<scalebyte>
zandt: I am via web
<zandt>
ahh
<scalebyte>
zandt: yes
<zandt>
there's your problem
<WhereIsMySpoon>
ah
<WhereIsMySpoon>
use a client
<zandt>
freenode web chat doesn't let you switch servers
<WhereIsMySpoon>
like everyone else :P
<WhereIsMySpoon>
xchat or mirc are good
<scalebyte>
WhereIsMySpoon: a good client for ubuntu
<WhereIsMySpoon>
xchat
<zandt>
xchat for ubuntu
<WhereIsMySpoon>
is what im using
<scalebyte>
WhereIsMySpoon: ok
<WhereIsMySpoon>
irssi is what some people will tell you
<WhereIsMySpoon>
dont listen to them
<zandt>
very simple to use
<scalebyte>
sudo apt-get install xchat will do ?
<WhereIsMySpoon>
er
<canton7>
I used weechat-curses when I'm on linux
<WhereIsMySpoon>
yes scalebyte
<scalebyte>
WhereIsMySpoon: thanks spoon
<zandt>
irssi is simple to use, after you learn to use it.... xchat is probably going to be easier to navigate out the box
<WhereIsMySpoon>
ye
<zandt>
canton7, never heard of that
<scalebyte>
WhereIsMySpoon: i got it installed spoon and in the UI i have networks to choose from which one to chose ?
<WhereIsMySpoon>
freenode is this network
mikepack has joined #ruby
<WhereIsMySpoon>
the one you're on right now
CannedCorn has joined #ruby
<zandt>
scalebyte, where are you trying to go ?
<scalebyte>
zandt: #rubyonrails
axl_ has joined #ruby
<WhereIsMySpoon>
he wants a ror channel he isnt banned on
<WhereIsMySpoon>
:P
abstrakt has joined #ruby
wmoxam has joined #ruby
<scalebyte>
WhereIsMySpoon: not me the ip isnt banned on :)
<WhereIsMySpoon>
well, not him, but his work's ip
<zandt>
ah
<WhereIsMySpoon>
so scalebyte, press the xchat menu option a tthe top
<WhereIsMySpoon>
new
<WhereIsMySpoon>
server window
<WhereIsMySpoon>
click the new one and type ./server irc.coldfront.net
<WhereIsMySpoon>
without the dot
<WhereIsMySpoon>
otherwise you'll disconnect from here
<WhereIsMySpoon>
like i did
Rezwan has joined #ruby
<WhereIsMySpoon>
er scalebyte sorry
<WhereIsMySpoon>
there isnt a #rubyonrails channel there
<WhereIsMySpoon>
D:
<WhereIsMySpoon>
er
Indian has joined #ruby
<scalebyte>
WhereIsMySpoon: i chose the freenode network
<WhereIsMySpoon>
freenode is this one
<scalebyte>
WhereIsMySpoon: now its showing the message
polarist has joined #ruby
<scalebyte>
WhereIsMySpoon: * Looking up irc.freenode.net * Connecting to chat.freenode.net (213.179.58.83) port 8001...
<scalebyte>
WhereIsMySpoon: but not connecting
iocor has joined #ruby
<WhereIsMySpoon>
it should take a few seconds
cha1tanya has joined #ruby
<scalebyte>
WhereIsMySpoon: then which network to choose spoon ?
<WhereIsMySpoon>
scalebyte, whatever one you want to try
<WhereIsMySpoon>
scalebyte, try googling for #rubyonrails channels
<WhereIsMySpoon>
that arent on freenode
<scalebyte>
WhereIsMySpoon: my system is through proxy.. is that a concern ?
<zandt>
yeah, you need to set up the connection options to connect
<zandt>
however, I am not the man to help with that
<zandt>
as I've never done it
<scalebyte>
zandt: hmmm... it better asking it on SO till I get home
<WhereIsMySpoon>
scalebyte, SO is a good place to ask
<lockweel>
hello, I'm searching for any starting script or gem to do data mining. Does anyone knows?
allaire has quit [#ruby]
crankycoder has joined #ruby
<WhereIsMySpoon>
scalebyte, because
<WhereIsMySpoon>
canton7, if i say a="asd" and then b=a, if i then do b << "dsa" why does a become "asddsa"?
<heftig>
because it doesn't make a copy
<WhereIsMySpoon>
><
<heftig>
if you want a copy, do b = a.dup
<WhereIsMySpoon>
ruby is like
<WhereIsMySpoon>
if there was ever an opposite to java
<WhereIsMySpoon>
in everything
<WhereIsMySpoon>
ruby would be it
<WhereIsMySpoon>
thanks hef
<heftig>
no, java is the same way
<heftig>
you just don't notice it with strings because you can't mutate strings in java
<WhereIsMySpoon>
so if i did in java
<spox>
you could just use += in place of the << to get an implicit dup
<WhereIsMySpoon>
char[] a = ['a', 'b', 'c']
<canton7>
WhereIsMySpoon, also, bear in mind that << (on strings) mutates the original string. If you want to create a new copy, try b += "dsa"
ohdae has joined #ruby
<WhereIsMySpoon>
then char[] b = a
<WhereIsMySpoon>
and did b[3] = 'd'
sarguru__ has joined #ruby
<ohdae>
Whats up guys, got a quick question (hopefully quick :p )
<WhereIsMySpoon>
a[3] == 'd'?
caiges has joined #ruby
<ohdae>
How do I add a string as an item in an array?
<WhereIsMySpoon>
im sure that isnt right
<WhereIsMySpoon>
ohdae, array << mystring
<ohdae>
I have an array and I iterate through the array and perform a function on each item. I want to take the output of that function and add it to a new array
<scalebyte>
WhereIsMySpoon: I am confused spooon :p
<ohdae>
WhereIsMySpoon: great, ty
<ohdae>
i tried array += output
<ohdae>
but no go heh
Barakas has joined #ruby
<rippa>
you can sum arrays
<spox>
array += [string]
<rippa>
array += other_array
<ohdae>
I am just learning Ruby now, i'm a python guy so its alittle tricky for some things
<ohdae>
hmm
Barakas has joined #ruby
<ohdae>
and could I add each item from the new array to correspond with the original arrays position?
ckrailo has joined #ruby
<heftig>
WhereIsMySpoon: indeed that happens in java.
<WhereIsMySpoon>
hm
pdtpatr1ck has joined #ruby
<WhereIsMySpoon>
im obviously an idiot :p
<ohdae>
like array1 = [ "a", "b", c"] array2 = [ "yes","maybe",no"] array1 += array2 output being something like a : yes b: maybe c: no
Barakas has joined #ruby
<WhereIsMySpoon>
you want a hash
<WhereIsMySpoon>
if you want to link keys and values
<canton7>
ohdae, are you after #zip ?
<ohdae>
yeah exactly
<ohdae>
but only after i get the output from my iteration of the first array
<ohdae>
#zip?
<canton7>
Hash[arr1.zip(arr2)]
<WhereIsMySpoon>
ooh
Ammar01 has joined #ruby
<WhereIsMySpoon>
thats awesome
<ohdae>
damn ruby confuses the hell out of me sometimes lol
<WhereIsMySpoon>
er except
<ohdae>
all the 'end's drive me crazy :p
<WhereIsMySpoon>
no thats fine
<WhereIsMySpoon>
thats a pretty cool function
yeggeps has joined #ruby
<ekaleido>
sh mac address-table | i 0025.b544.012f
<canton7>
ohdae, zip works exactly as it does in python
<WhereIsMySpoon>
ohdae, that will do exactly what you want
<ekaleido>
oops
<WhereIsMySpoon>
:p
<ohdae>
WhereIsMySpoon: canton7: great thank you :D
<ohdae>
i wrote my first ever succesful ruby script yesterday..well two of them actually
<ohdae>
and now im on a roll heh
<canton7>
good feeling, huh? :)
<WhereIsMySpoon>
im bored of writing games
<ohdae>
There are so many functions I want to convert from a project I have in python but i just dont know how heh
<ohdae>
im getting there
<WhereIsMySpoon>
anyone got a good idea for a ruby script or two to write?
<canton7>
WhereIsMySpoon, IRC bots are immensely popular
<lockweel>
yes data mining one :P
<WhereIsMySpoon>
canton7, thats a little advanced
<WhereIsMySpoon>
id have to do network stuff
<canton7>
WhereIsMySpoon, not really. The basics are trivial
<WhereIsMySpoon>
canton7, i only started ruby last week
<WhereIsMySpoon>
o.o
<WhereIsMySpoon>
and network stuff is never trivial
<WhereIsMySpoon>
:L
<lockweel>
the world is full of
<lockweel>
data
<lockweel>
out there
<WhereIsMySpoon>
look mr lockweel
krz has joined #ruby
<WhereIsMySpoon>
*shiv*
<WhereIsMySpoon>
stop your data nonsense :p
<lockweel>
data - information - knowledge sir MySpoon
<lockweel>
bs Business Admin
<WhereIsMySpoon>
im not writing a datamining program for you
<asteve>
i want to use options for a ruby script but i don't want to require an argv; example: "jump.rb --how-high 20" but "jump.rb" will automatically jump 10
<deryl>
ok so rvm is correctly set up. now remove ANY rvm use x.x.x lines from your .bashrc and .bash_profile. leave the rvm source lines that actually load rvm as per instructions page
<deryl>
then log out then back in then rvm use 1.9.3 --default
<WhereIsMySpoon>
why would i need to log out
<deryl>
also try switching to a diff ruby with the --default, close the sessions ALL OF THEM
<deryl>
because you need to reinitialize the environment
<deryl>
close the terminal session
<WhereIsMySpoon>
logout != close the terminal
<WhereIsMySpoon>
o.o
<WhereIsMySpoon>
but ok
wyhaines has joined #ruby
<deryl>
WhereIsMySpoon: you wanna get pedantic with me? how do *I* know if you're running a terminal or a console session?
<WhereIsMySpoon>
user:~$ rvm use 1.9.3 --default
<WhereIsMySpoon>
Using /usr/share/ruby-rvm/gems/ruby-1.9.3-p125
<WhereIsMySpoon>
sorry :)
<WhereIsMySpoon>
ok so
<WhereIsMySpoon>
now i just open a new console session and it should work?
<deryl>
did you close ALL the terminal sessions?
<deryl>
terminal console whatever you're using
ringotwo has joined #ruby
<deryl>
reinit everything totally
<WhereIsMySpoon>
all the ones that i'd put ruby commadns in
<lockweel>
where on earth you found p125
<deryl>
dude, just play along. close all your terminals. every one that you've launched since starting this
<oooPaul>
p290 is for 1.9.2; not sure what patchlevel 1.9.3 is at
<WhereIsMySpoon>
so again
<deryl>
i don't have the time nor the patience to play 20 20 with environments. reinit the whole stack - its just a simple terminal (gnome-terminal, konsole whathaveyour, right?)
<deryl>
not that hard
<WhereIsMySpoon>
yes ive done that
<deryl>
oooPaul: i wa just throwing out an example
<WhereIsMySpoon>
and run the rvm use command
<deryl>
p125 is latest 1.9.3 to be exact
<oooPaul>
deryl, was talking to lockweel
<deryl>
ah
<deryl>
WhereIsMySpoon: ok, you did rvm use 1.9.3 --default right?
<deryl>
open a new term
<WhereIsMySpoon>
yes
<WhereIsMySpoon>
k
<deryl>
rvm info
<WhereIsMySpoon>
ok
<WhereIsMySpoon>
do you want a copy of it?
<deryl>
is it still defaulting elsewhere?
<lockweel>
rvm list know shows -p0 to me
<WhereIsMySpoon>
rvm info doesnt say anything about the ruby version
<deryl>
umm yes it does
<deryl>
or it should
<WhereIsMySpoon>
nope
<deryl>
3rd section down
<deryl>
gist it
<deryl>
is this a per user or a multi-tenency install? (homedir vs /usr/local)
<deryl>
the closing of all the terminals ensures that the entire environment is completely reset. you should actually get an error about not being able to find the rvm file for sourcing after that because you haven't reinstalled
<deryl>
and please tell me you're not using that blasted ruby-rvm package for debian and ubuntu
<deryl>
if you are RIP IT OUT
nikhgupta has joined #ruby
<deryl>
completely and utterly NOT supported by us
<WhereIsMySpoon>
er
<WhereIsMySpoon>
i did do a sudo apt-get install ruby
<WhereIsMySpoon>
at some point
<deryl>
thats just the system ruby.
<deryl>
dpkg -l | grep ruby-rvm
mengu has joined #ruby
<deryl>
if that is in, apt-get --purge remove ruby-rvm
<WhereIsMySpoon>
rc ruby-rvm 1.6.9-0ubuntu2 easily install, manage and work with multiple ruby environments
<deryl>
ok whew
<deryl>
such an utter peice of shit
pu22l3r has joined #ruby
<WhereIsMySpoon>
lol
<WhereIsMySpoon>
ok so
<deryl>
they screw up the packaging so bad and it breaks other rvm installs for users.
bwlang_ has joined #ruby
<WhereIsMySpoon>
shall we start over?
<WhereIsMySpoon>
deryl? :)
pu22l3r__ has joined #ruby
<deryl>
yes, run that script i pointed you at, close ALL terminals, reopen one, run the PER-USER install from the rvm install page (the one without the sudo), close the terminal *again* and reopen it and now the rvm sourcing line should work again
<deryl>
then rvm --intall --create use 1.9.3-p125 --default
<deryl>
s/intall/install/
<deryl>
then close the terminal and reopen it so that it reinits fresh, and ruby --version
<WhereIsMySpoon>
deryl, is the per-user install the one thats under the header "ruby-debug and ruby 1.9" on the beginrescueend page?
<deryl>
and GIST me the details of rvm info when thats done. I hate pastebin and refuse to use it
schovi has joined #ruby
waxjar has joined #ruby
<deryl>
no its the one under rvm.beginrescueend.com/rvm/install and is the first one listed
alx- has joined #ruby
waxjar has joined #ruby
waxjar has joined #ruby
<WhereIsMySpoon>
er
<WhereIsMySpoon>
why do i no longer have a .bash_profile
badabim has joined #ruby
Teddy2steper has joined #ruby
<deryl>
idk, as you can see we don't delete that
<deryl>
we do /usr/bin/sudo rm -rf $HOME/.rvm $HOME/.rvmrc /etc/rvmrc /etc/profile.d/rvm.sh /usr/local/rvm /usr/local/bin/rvm
fowl has joined #ruby
<deryl>
the only physical words for the bash stuff are in an echo: /bin/echo "RVM is removed. Please check all .bashrc|.bash_profile|.profile|.zshrc for RVM source lines and delete or comment out if this was a Per-User installation."
<deryl>
and you can even not run that becaue we want the .bash_profile
<deryl>
i want it to actually error because its proof that rvm isn't found (thus why you get the error about not being able to load)
kng has quit [#ruby]
<WhereIsMySpoon>
right well im installing 1.9.3
<WhereIsMySpoon>
on #configuring atm
<WhereIsMySpoon>
and now compiling
bigkm has joined #ruby
flak has joined #ruby
ethd has joined #ruby
ethd has joined #ruby
rramsden has joined #ruby
waxjar_ has joined #ruby
<deryl>
also i tell people to use the patchlevel when they set their default ruby so that you don't potentially break other projects if you rvm upgrade the major version
<deryl>
so make sure to use the patchlevel when you set your default
<WhereIsMySpoon>
thats the -p<blah>
<deryl>
yep
<WhereIsMySpoon>
kk
Spaceghostc2c has joined #ruby
<WhereIsMySpoon>
compiled fine, just retreiving default gemsets
<deryl>
*I* dont because its SUPPOSED to break for me, I'm one of the RVM developers. *I* need to know when that upgrade process breaks :)
<Spaceghostc2c>
oooPaul: lol
<deryl>
but general users .. not so much
<WhereIsMySpoon>
ok done
rmaceissoft has joined #ruby
<deryl>
give me the commandline you ran for the 1.9.3 install
<deryl>
so i know exactly what you did
<WhereIsMySpoon>
rvm install 1.9.3
rippa has joined #ruby
<Spaceghostc2c>
deryl: When I upgraded my system to Windows 7, rvm broke. Plz fix soon.
<WhereIsMySpoon>
deryl, rvm info shows nothing about the ruby version
<deryl>
ok, now do this. rvm --install --create 1.9.3-p125@user --default
<WhereIsMySpoon>
only the rvm version
<WhereIsMySpoon>
ah was it too early for an rvm info ^^
<deryl>
(I want it to make the gemseet so i can test that and so i can seee that it set the default TO using a gemset as well so i know the whole chain is working)
<deryl>
yeah way too early
<WhereIsMySpoon>
ok done
<deryl>
none was selected so it will be empty
<deryl>
ok so are you showing you in ruby-1.9.3-p125@user then?
<WhereIsMySpoon>
what
<WhereIsMySpoon>
am i showing me?
<deryl>
are you showing that yoou are in that?
<deryl>
come on, grey matter man, grey matter
<WhereIsMySpoon>
i dont actually understand your sentence, am i showing that i am in that? is it a folder?
<WhereIsMySpoon>
is it a package?
<deryl>
did you do the rvm --install --create 1.9.3-p125@user --default
<WhereIsMySpoon>
yes
<deryl>
ook, rvm info
<WhereIsMySpoon>
i changed user for my username
<deryl>
thats fine
<WhereIsMySpoon>
new console?
<deryl>
same
bwlang_ has joined #ruby
<WhereIsMySpoon>
ok
<deryl>
new con is nect
<deryl>
err next
<WhereIsMySpoon>
all of these things at the bottom have been set
<WhereIsMySpoon>
like GEM_HOME
<WhereIsMySpoon>
MY_RUBY_HOME
<deryl>
just making sure that the current session actually changed
<WhereIsMySpoon>
gemset
<deryl>
ok and they show the right ruby in them right?
<WhereIsMySpoon>
etc
<WhereIsMySpoon>
yes
<WhereIsMySpoon>
ruby-1.9.3-p125
<WhereIsMySpoon>
ah and now it has some ruby info at the top
<deryl>
ok, and you have the rvm load line in your $HOME/.bash_profile correct?
<WhereIsMySpoon>
i still dont actually have a .bash_profile
<WhereIsMySpoon>
i have a .bashrc
<deryl>
per users need that to load. we handle it in /etc/profile.d/rvm.sh for multi
<WhereIsMySpoon>
For rvm to work properly, you have to set 'Run command as login shell' checkbox on Title and Command tab inside of gnome-terminal settings.
<WhereIsMySpoon>
i need to find where these settings are
<deryl>
ahhh
<deryl>
i dont use it myself as I'm on a Mac, but it should be under the preferences somewhere
<deryl>
think mpapis said the last tab
<deryl>
thats totally from memory so if i'm wrong i apologize
<robacarp>
deryl: osx uses .bashrc_profile I think...checking
<robacarp>
.bash_profile
<deryl>
no no
<deryl>
i meant for where the gnome-terminal settings are
<deryl>
and yeah it uses .bash_profile by default
<WhereIsMySpoon>
dsakldsadlkasdksada;
<WhereIsMySpoon>
sigh
danishkhan has joined #ruby
<WhereIsMySpoon>
11.10
<WhereIsMySpoon>
so #$*(
<deryl>
some of these linux distros use .profile but .profile is for sh-compat mode. bash defaults to using .bash_profile and using .profile disables some features of bash as a result
<deryl>
and that breaks some of what we do too because we use some of bash's extended capabilities not available when it switches to compat mode
<deryl>
which is fine. the future is forwards, not back ;)
ringotwo has joined #ruby
<WhereIsMySpoon>
oh here it is
<deryl>
anyways, go through doing all that. I gotta disappear for awhile. IRL stuff that HAS to be done now
<geekbri>
Can you use #{} in ruby regular expressions?
<oooPaul>
Actually, I think you can.
cmasseraf has joined #ruby
v0n has joined #ruby
<oooPaul>
x = "foo"; "foobar" =~ /#{x}/ => 0
n1x has joined #ruby
<oooPaul>
"biff" =~ /#{x}/ => nil
pzol has joined #ruby
<oooPaul>
It's even interpreted -- x = "[abc]", "foobar" =~ /#{x}/ => 3
pzol has quit ["Sayonara!"]
yrrep has joined #ruby
<geekbri>
hrm, excellent!
cbuxton has joined #ruby
ivanoats has joined #ruby
crankycoder has joined #ruby
bwlang_ has joined #ruby
ivanoats has joined #ruby
nemesit has joined #ruby
mikespokefire has joined #ruby
moemen has joined #ruby
Vert has joined #ruby
workmad3 has joined #ruby
mneorr has joined #ruby
atmosx has joined #ruby
mneorr has joined #ruby
kf8a has joined #ruby
drake10 has joined #ruby
polarist has joined #ruby
jason_rad has joined #ruby
Avanine has joined #ruby
havenn has joined #ruby
bwlang_ has joined #ruby
<jason_rad>
I'm trying to use ActiveSupport::SecureRandom.base64(10) in my app.. I did require 'active_support/secure_random' and I get this upon running the app
<jason_rad>
require': cannot load such file -- active_support/secure_random (LoadError)
<jason_rad>
any ideas
ascarter has joined #ruby
cal has joined #ruby
<jason_rad>
active support 3.2.1 is also installed as a gem
alienvenom has joined #ruby
<drake10>
If I have a string like "123-apple-dog-cat" and want to split as "123" , "apple-dog-cat". How would I do that? I tried split('-'), but it would split as "123", "apple", "dog" "cat"
iamjarvo has joined #ruby
albemuth has joined #ruby
<fowl>
be lazy
<canton7>
drake10, I managed with positive lookahead and lookbehind: "123-apple-dog-cat".split(/(?<=\d)-(?=\D)/) Not sure if there's a cleaner way
<Eiam>
split it, pop the first item
<Eiam>
rejoin with -
<fowl>
^
A_D has joined #ruby
<Eiam>
glad I wasn't alone in that response haha
<shevy>
drake10: indeed, if it is that simple use .split and rejoin. if you however want to use a regex, make it match via two ()
<Eiam>
to me, what canton7 is less readable
<Eiam>
it takes me longer to parse & understand what he wants
<shevy>
yeah
<drake10>
canton7: Thanks, was wondering if there was a function
<Eiam>
but I recognize that I'm terrible with regex.
<canton7>
yeah, mine's very much unreadable and emrely an exercise in regex :P
<shevy>
regexes are harder to understand at a first glance
<canton7>
*merely
<shevy>
they are always harder Eiam
pzol has joined #ruby
pzol has quit ["Sayonara!"]
<epitron>
drake10: what are you doing? are you extacting the ID from an URL slug?
dekroning has joined #ruby
<epitron>
or is that a customer's address?
iamjarvo1 has joined #ruby
<ccapndave>
drake10: How about "123-apple-dog-cat".partition("-").delete_if { |b| b == "-" }
<Eiam>
I need to do a bunch of shell commands through rake, stuff like making directories if they don't already exist, copying files, archving files, and loading stuff into launchctl. is rake + fileutils the most suited tool for that job, or should I just shell out directly from rake?
pastjean has joined #ruby
mikepack has joined #ruby
<drake10>
epitron: I need to pass, object id along with object name via files and later split id and names
<epitron>
via filenames?
jason_rad has quit [#ruby]
Helius has joined #ruby
KL-7_ has joined #ruby
<epitron>
because there are better ways to encode ids and names inside files :)
<epitron>
also, better ways to encode an id via a filename
<drake10>
ccapndave: that is neat, thanks
<epitron>
"10. Apple Cat Dog.dat"
bwlang_ has joined #ruby
<epitron>
or, ideally, zero-padded, so they sort properly
<ccapndave>
drake10: There might be a more elegant way still
<epitron>
"0010. Apple Cat Dog.dat"
<drake10>
epitron: not via file names. Its each record within a file
<epitron>
ah
<epitron>
if you want to store records, there are lots of things out there for that
<epitron>
yaml for example :)
<epitron>
or json
<epitron>
or a small database
<epitron>
(eg: tokyo cabinet)
<drake10>
epitron: I know, trying to fix a bug in an existing system, cant change a whole lot
<epitron>
ah
<epitron>
migration :\
<drake10>
epitron: what is tokyo cabinet?
bean_dharma has joined #ruby
<epitron>
it's like mysql without the sql
<epitron>
you can store data in little hashtables or btrees on disk
<drake10>
something like key-value? mongodb?
<epitron>
it's not like mongodb
<epitron>
it's just a little library
<epitron>
there's no server
<epitron>
it just lets you open/read/write cabinet files
<Pwdrkeg>
Hello, I'm interested in writing a program in ruby that will be sort of a command line menu driven interface for running various Windows commands/scripts. I've never written in Ruby before though, could anyone suggest a place to start? Specifically, with interfacing with Windows.
<bean_dharma>
I'm trying to subtract two DateTime objects by "DateTime.now - DateTime.parse('2012-03-10 21:29:46 UTC')", but this returns (55659343181/14400000000). How do I make this readable?
mneorr has joined #ruby
<Pwdrkeg>
thanks rippa, does that include win 7?
<rippa>
Pwdrkeg: seems so
<rippa>
bean_dharma: it's a rational
<rippa>
you can call to_f on it
beha has joined #ruby
<matled>
bean_dharma: I found Date and DateTime most of the time quite confusing and found Time much more convenient to use.
<rippa>
though I'm not sure why it would return a rational
Hydroxide has quit [#ruby]
<bean_dharma>
call to_f on the end result? That returns 3.8694378109953704 =\
evilgeenius has joined #ruby
releod has joined #ruby
<evilgeenius>
Does anyone know the file name format of photos taken on the iPad? is the timestamp in the filename?
jwang has joined #ruby
<matled>
bean_dharma: it seems to return the number of days between two DateTime objects
<shadoi>
bean_dharma: try chronic.
ephemerian has quit [#ruby]
<bean_dharma>
ohhh okay thatnks, I'll try formatting it from there
mneorr has joined #ruby
yoklov has joined #ruby
jameshyde has joined #ruby
<shevy>
Eiam why shell out? Plain ruby can do all of that. I myself dont use rake though, it annoys me too much
<shevy>
Pwdrkeg: writing ruby on and for windows is not that different than writing ruby on and for linux
<Pwdrkeg>
shevy: I see. For me, one example might be, a menu option to run a powershell script.
stephenjudkins has joined #ruby
ruby_fun has joined #ruby
<ruby_fun>
I am creating a new browser session using Watir::Browser.new :firefox and am trying to use a variable instead of ":firefox" anyone know if this is possible?
<oooPaul>
mocker, I think our sysadmin here did. :)
<oooPaul>
ruby_fun, of course.
<mocker>
oooPaul: Just picked up the ebook, gonna check it out tonight.
<oooPaul>
:firefox is just a symbol. Put a variable there instead, and set the variable to :firefox. :)
<ruby_fun>
that doesn't work
<oooPaul>
mocker, I haven't often been disappointed by PragProg books (except for that first book on git, what a useless pile of words that was)
<oooPaul>
foo = :firefox; Watir::Browser.new(foo)
luke--_ has joined #ruby
hobodave has joined #ruby
hukl has joined #ruby
Progster has joined #ruby
<shevy>
I dunno. the pickaxe before the current one was very good, but other than that I have been too disappointed by the prag prog books
<shevy>
metaprogramming ruby was a waste of time and resources for me
<oooPaul>
Really? That's one of my faves.
<oooPaul>
There was a lot in there I already knew, for sure, but there was a lot of good description of some nuances that had passed me by.
<ruby_fun>
whats the ( ) do
<oooPaul>
Seven Languages in Seven Weeks was good.
<oooPaul>
ruby_fun, it bounds your parameter list.
schovi has joined #ruby
zul has joined #ruby
kremiak has joined #ruby
williamcotton has joined #ruby
<oooPaul>
Parens on function arguments are optional in Ruby. Foo.new "biff" is the same as Foo.new("biff").
<shevy>
yeah oooPaul 80% I knew what was in that book, and the rest does not seem to be overly useful to me either. there is too much metaprogramming magic in ruby, it is becoming cargo cult building when in ancient times, the kool aid was simple solid and concise design, without any magic in it
chendry has joined #ruby
_bob has joined #ruby
<oooPaul>
shevy, the big win for me in that book was the concise explanation of the whole Eigenclass inheritance thing... Which doesn't come up often, but when it does, I'm glad it let me figure it out. :)
<oooPaul>
But yeah, magic is a double-edged sword.
<chendry>
hi everybody! This has been bugging me. I want a method on Enumerable that takes a block, iterates through the Enumerable's objects, and calls the block passing the object. The first time the block returns a "true" value, I want that value to be returned by the method. Does such a method exist?
<oooPaul>
I do like the magic in some cases, though. I had to put together code to interface with a SOAP API, and used a lot of the tricks in that book so that the code actually builds ActiveRecord-like objects from the WSDL, rather than me having to build all those objects manually.
<oooPaul>
chendry: "find".
<Eiam>
shevy: plain ruby can do all of that?
<Eiam>
shevy: howso?
<Eiam>
I'm not familiar with this portion of ruby I suppose
<chendry>
ooPaul: find is _close_ to what I need -- except I want it to return what my block returns. (instead of returning the object that was passed to my block when my block returned true)
<shevy>
first, you can use include FileUtils and then omit all FileUtils. prefixes
<chendry>
ooPaul: like this: %w[a b c].find { |x| x == "b" ? "Found it!" : nil }.should == "Found it!"
<shevy>
second, when you have something like mv, omit the ()
<shevy>
third and most importantly, I write methods that do the task at hand
<shevy>
for instance, I tend to do:
<shevy>
def move_file(from, to)
<shevy>
and inside there do some checking
<shevy>
and usualliy also do: alias mv move_file
simao has joined #ruby
<shevy>
*usually
panpainter has joined #ruby
<axl_>
heres a question: I have a class that uses an instance variable, that does not have a setter. can i force set it from console?
<shevy>
it then becomes much closer to how you do it in shell scripts too
birkoff has joined #ruby
<shevy>
(minus the '')
<oooPaul>
chendry: In that case I don't think so.
<shevy>
I'd love to be able to omit the '' though :(
sgmac has joined #ruby
sgmac has quit [#ruby]
Magik_n has joined #ruby
<Magik_n>
hi all :)
c0rn has joined #ruby
<chendry>
oooPaul: well crap. I've needed it twice in the past two days :) Which book were you talking about, btw?
_bob has joined #ruby
<oooPaul>
chendry: Metaprogramming Ruby from PragProg. I liked it. shevy didn't.
simao has joined #ruby
shevy_ has joined #ruby
mrsolo has joined #ruby
Jay_Levitt has joined #ruby
havenn has joined #ruby
<shevy_>
hmm question
<shevy_>
I often do:
<chendry>
oooPaul: aye, yes, I recall liking that one. I think my favorite by far until now has been _The Ruby Programming Language_ -- that's super concise
<shevy_>
begin
<shevy_>
code_that_may_fail_here
<shevy_>
rescue Exception => error
<shevy_>
pp error
<shevy_>
end
trivol has joined #ruby
senj has joined #ruby
<shevy_>
is there any way to cut down on the amount of lines here? Especially the rescue part is redundant when I use that like 20 times in a project
<shevy_>
I'd like to have something like...
<shevy_>
rescue_everything
<shevy_>
end
<shevy_>
instead of:
<shevy_>
rescue Exception => error
<shevy_>
pp error
<shevy_>
hmmmmm
<oooPaul>
shevy: you can toss rescue on the end of a single line...
_bob_ has joined #ruby
<oooPaul>
my_call rescue puts "error"
<oooPaul>
Although I think you'd still have to put Exception => e there to capture it...
<shevy_>
hmm
cal has joined #ruby
<shevy_>
do you know what "rescue" is? is that a method somewhere like in Kernel ?
<shevy_>
or is it a keyword
<shevy_>
:(
<oooPaul>
I've seen, for example: foo = something_that_might_fail rescue nil
<shevy_>
I guess it is ...
<oooPaul>
Which sets foo to nil if that something failed.
kenichi has joined #ruby
<oooPaul>
Keyword, almost positive.
bwlang_ has joined #ruby
<rippa>
keyword
<oooPaul>
Has to be -- how would you rescue the rescue method? ;)
<shevy_>
yeah hmmm
<shevy_>
I just dont like the rescue Exception => error; pp error part all over my code :(
bbttxu has joined #ruby
<A124>
Um.. I got a "little" problem parsing ULRs. Can anyone gime a hint please? URI.parse('http://sss.some.com/h[je]') URI::InvalidURIError: bad URI(is not URI?): http://sss.some.com/h[je]
<shevy_>
I am sure that could be done better somehow...
<oooPaul>
Put the handler way at the top.
<oooPaul>
Unless you're planning on continuing code execution after it.
arvidkahl has joined #ruby
Vert has joined #ruby
<oooPaul>
A124: The square brackets are illegal characters in the URI.
looopy has joined #ruby
<shevy_>
ah no, they just should show some error messages. for instance, some of my yaml files can sometimes be invalid, and it is often easier to continue just showing the error
<oooPaul>
shevy_, Ah, gotcha. Yeah, just kinda need to litter them. :
<oooPaul>
:P
pastjean has joined #ruby
<A124>
oooPaul: Interesting. Someone said exact oposite of that today. .. URI.escape does not escape that.
<shevy_>
hehe
Foxandxss has joined #ruby
<oooPaul>
You can put a rescue in a method, though, without a begin/end -- def foo; blah; rescue Exception => e; pp e; end
francisfish has joined #ruby
<oooPaul>
A124: Escaping is for parameters; those square brackets are in the URI path.
virunga has joined #ruby
<A124>
oooPaul: Ah. ok. How can I fix that please?
<A124>
nobitanobi: or Date._strptime('2001-02-03', '%Y-%m-%d')
<A124>
nobitanobi: No. that one not. That was my fail. *facepalm* sorry
<nobitanobi>
mmm ok
<A124>
nobitanobi: You want this I guess: Time.now.strftime('%F')
n3m has joined #ruby
<A124>
nobitanobi: Am I right?
bbttxu has joined #ruby
bwlang_ has joined #ruby
khammett has joined #ruby
greenarrow has joined #ruby
<nobitanobi>
I have a Date object
<khammett>
hey
<nobitanobi>
not a Time object
<khammett>
strange thing
<khammett>
why in Ruby
<khammett>
3 * 0.8 = 2.4000000000000004
<khammett>
strangeeeee
zul has joined #ruby
<Synthead>
I'm looking to read an XML-based template (open to ideas), add a few elements based on some variables, and write it to a file. how can I do this?
<shevy_>
khammett: not with syntax like that
<khammett>
shevy_: ???
<shevy_>
3 * 0.8 surely does not return 2.40004 for you right?
<rippa>
shevy_: returns for me
yoklov has joined #ruby
<rippa>
khammett: because it's a float
zommi has joined #ruby
<shevy_>
oh
<shevy_>
that changed in 1.9.x?
<rippa>
maybe
<khammett>
shevy_: please try to do so in IRB
<nobitanobi>
How can I get a Date object like this: YYYY-MM-01 --> Where YYYY is actual year, and MM is actual month?
<shevy_>
I see it does in 1.9.x
<shevy_>
another example how ruby evolves :(
<khammett>
rippa: i wonder why there is a '4' at the end
ghanima has joined #ruby
<rippa>
khammett: because 0.8 != 8/10
<rippa>
it's only an approximation
<rippa>
because floats are binary
<shevy_>
hmm but in 1.8.x it works without requiring anything else
yekta has joined #ruby
<ekaleido>
nobi: strftime?
fjfish has joined #ruby
<Synthead>
can I read an .rhtml file into a var as if I ran eruby on it?
<khammett>
rippa: so, what's the rule here? the result is too long for me
<shevy_>
rippa I think he wants the rounded result
<khammett>
rippa: i pass the amount of $ to paypal, and the amount = 3 * 0.8, which causes paypal error (The link you have used to enter the PayPal system contains an incorrectly formatted item amount - from Paypal)
<rippa>
khammett: format it then
<rippa>
also, don't use floats for money
<khammett>
rippa: what do you recommend how to format it? As this is money, so I don't want to round it
<nobitanobi>
shevy_: but how would you get the actual year? using Time?
<canton7>
"%.2f" % (3 * 0.8). This is why you don't use floats for currency
<rippa>
you could use BigDecimal
<nobitanobi>
same for month
<Synthead>
nobody has any ideas? :s
<shevy_>
nobitanobi: dunno, there are surely methods on date
<deluminathor>
-e:1: unterminated string meets end of file
<deluminathor>
does someone know how to solve it?
colinwd has joined #ruby
bwlang_ has joined #ruby
<A124>
nobitanobi: Um.. sorry, it not my name in chat I don't see. It's coincidence I saw it "now".
poincare101 has joined #ruby
sroy2 has joined #ruby
S1kx has joined #ruby
S1kx has joined #ruby
deluminathor has joined #ruby
poincare101 has quit [#ruby]
DrShoggoth has joined #ruby
bwlang_ has joined #ruby
davidcelis has joined #ruby
deluminathor has quit [#ruby]
<A124>
Solved that mine uri barackets '[]' problem with module, class << self, monkey patch, if anyone curious.
eko has joined #ruby
eko has joined #ruby
cal has joined #ruby
shruggar has joined #ruby
c0rn has joined #ruby
darthdeus has joined #ruby
kpshek has joined #ruby
bwlang_ has joined #ruby
christopherl has quit [#ruby]
apok_ has joined #ruby
Indian has joined #ruby
jamescotterill has joined #ruby
trivol has joined #ruby
mythmon has joined #ruby
dekroning has joined #ruby
dubios has joined #ruby
axl_ has joined #ruby
doublethink has joined #ruby
Mac_ has joined #ruby
banisterfiend has joined #ruby
stephenjudkins has joined #ruby
Helius has joined #ruby
dekroning has joined #ruby
friskd has joined #ruby
havenn has joined #ruby
<shevy_>
hmmm
<shevy_>
I really need to write a RubyOS
<shevy_>
even linux is going on my nerves lately
shyam has joined #ruby
CombatWombat has joined #ruby
CombatWombat has joined #ruby
CombatWombat has joined #ruby
<A124>
LoL
superguenter has joined #ruby
cbuxton has joined #ruby
c0rn has joined #ruby
yellow5 has joined #ruby
asobrasil has joined #ruby
etehtsea has joined #ruby
samuelkadolph has joined #ruby
yairgo has joined #ruby
cbuxton has joined #ruby
superguenter has joined #ruby
c0rn has joined #ruby
<yairgo>
what's the best way to create standalone ruby applications?
kstephens has joined #ruby
samuelkadolph has joined #ruby
cbuxton has joined #ruby
superguenter has joined #ruby
<shevy_>
yairgo: depends on what requirements you have, what target platform you aim for etc..
etehtsea has joined #ruby
c0rn has joined #ruby
nobitanobi has joined #ruby
asobrasil has joined #ruby
<yairgo>
shevy_ some form of debian
superguenter has joined #ruby
cbuxton has joined #ruby
<shevy_>
best ways are to: write everything in classes. if it belongs to one project, let them reside in the same namespace for that project
yellow5 has joined #ruby
<shevy_>
ok so you target linux only (debian)?
samuelkadolph has joined #ruby
kstephens has joined #ruby
etehtsea has joined #ruby
c0rn has joined #ruby
superguenter has joined #ruby
cbuxton has joined #ruby
msch has joined #ruby
asobrasil has joined #ruby
samuelkadolph has joined #ruby
kstephens has joined #ruby
superguenter has joined #ruby
cbuxton has joined #ruby
<yairgo>
shevy_ yes we will be only targeting debian, I meant how do I turn it into a standalone app that I can give to someone without ruby installed and they can run it
c0rn has joined #ruby
<A124>
Excess flood? Really? or it's just a white lie?
<shadoi>
shevy_: It's a very simple, clean way to do meta-programming without resorting to method_missing magic.
<shevy_>
shadoi: and that is no different than to use normal methods too. .send is not normally called when a message sends a message
<shadoi>
shevy_: yes, but you need to check if the object responds to those methods before executing them. how do you propose to do that without using send?
CombatWombat has joined #ruby
<mklappstuhl>
shevy_: I know that it's wierd but I have no explantation at hand thats why I am asking
<shevy_>
mklappstuhl: that is no useful at all
<brianosborne>
Hey all, I'm trying to write some code that will keep track of instances of a class using Class Instance Variables, but I'm getting a NoMethodError on << when trying to push an instance… http://pastebin.com/fzzhG5hN
CombatWombat has joined #ruby
CombatWombat has joined #ruby
<brianosborne>
Not sure what I'm missing here
<shevy_>
I mean, that is like two lines there you show mklappstuhl, how should anyone make sense of that
<shevy_>
shadoi: I dont reason *for* using .send, I am reasoning to not use it
<devinus>
yairgo: i'm trying to take an object's instance variables and turn some of the ones i want off the object into a hash, e.g.; class Foo; @a = 1; @b = 2; @c = 3; end; obj = Foo.new; @w(a b c).map { |k| obj.send(k) }
<shadoi>
mklappstuhl: what is self?
<devinus>
er
<shadoi>
shevy_: I'm asking how you solve the problem without using send.
<devinus>
or something like that
<shevy_>
method_missing is a giant pile of hack
<shevy_>
shadoi: use the method that exists on the object of course. that is the only proper way to use objects and messages
<robert_>
blah.. I'm trying to regex match a file extension in a .each{} block. :/
<shadoi>
shevy_: and how do you check if the method exists before calling it?
<robert_>
haiii shevy_ :D
<shevy_>
you can, if you must to, via .respond_to?
<shevy_>
but really if I were in charge of such projects, I'd not rely on method_missing and send. they are hacks to me
msch has joined #ruby
<shevy_>
hai robert_ :D
<shadoi>
shevy_: and how do you pass a method name to respond_to, and then call it? write some code to show how you'd do it.
<robert_>
couldn't you just do, self.member = memberUid.collect{|uid| User.find(uid).dn }, yairgo? :p
<kenneth>
not quite sure why i'm getting \\0 in the output
<yairgo>
robert_ of course,
<robert_>
why the extra assignment, then?
<kenneth>
when what i'm expecting is \'
<nobitanobi>
I am doing this: d = Date.new(2012,12,1) -- But I would like to change 2012 for the actual year and 12 for the actual month. I want to keep the 1 though. What-s the best way of doing so?
<yairgo>
mklappstuhl yeah, ldap attributes are goofy, sometimes clearing them sets them to nil, did you try what I typed out, self.member = memberUid.collect{|x| User.find(x).dn}
<robert_>
yairgo: ah. :D
jbw_ has joined #ruby
dbgster has joined #ruby
<mklappstuhl>
yairgo: no not yet, seeing it for the first time right now
<mklappstuhl>
(ah I see.. missed it above...
<yairgo>
robert_ that was better than what I first though, @new_member = []; memberUid.each{|uid| @new_member << User.find(uid).dn}; self.member = @new_member; lol
<yairgo>
*thought
<robert_>
yeah. :D
<A124>
kenneth: Tell me what you want to do.. you did not provided the desired output
<kenneth>
trying to properly escape a string which might contain all kinds of random crap, to put it in a SQL query
<robert_>
aha.
<kenneth>
can't use prepared statements because that feature is broken :p
luke--_ has joined #ruby
<yairgo>
mklappstuhl good luck, ActiveLdap wasn't in the best shape last time I tried to use it.
<yairgo>
exit
<A124>
kenneth: Ok. Give me what should escape to what and I can write you the regexp
cal has joined #ruby
ephemerian has joined #ruby
<havenn>
nobitanobi: One way to do it: require 'date'; Date.strptime('01', '%d') ##<Date: 2012-03-01 ...
<nobitanobi>
I did it like this.. : a = Date.new(Time.now.year,Time.now.month,1)
<robacarp>
shadoi: you shouldn't be doing that in libraries. It leaves you open to vulnerabilities akin to mass_assignment attacks
<A124>
I'd like to make it happen the "best" way possible. Substitute best for your personal preference.
shaatar has joined #ruby
<robacarp>
A124: scraping is a finicky thing...whatever works for you is good enough.
dotemacs has joined #ruby
<robacarp>
A124: I used http://mechanize.rubyforge.org/ and got along just fine with it...scrubyt wasn't doing what I wanted. In other cases I've found the opposite to be true.
<shadoi>
robacarp: I do input validation on all attributes, I'm fairly confident you can't inject malicious data.
moeSeth has joined #ruby
<A124>
shadoi: Thank you. robacarp: I'm not talking about scraping. But the donwloading mostly. When it comes to millions, numbers does matter.
<shadoi>
robacarp: the reason I do it, is all objects are serialized JSON, so I can deserialize, validate the JSON against a schema, and count on it being valid when I pull it back in.
<robacarp>
shadoi: sure, okay. But when you add a method to your class it can be called implicitly via the hash on the init function. surely you don't want that.
bigkm has joined #ruby
arnihermann has joined #ruby
<robacarp>
A124: yea, okay, I see what you mean. if you have a list of all the urls then just use Net::HTTP or something
skipper has joined #ruby
avandendorpe has joined #ruby
<A124>
robacarp: Too slow. And also there is the storage, reliability, etc. part. That why I was asking.
Squarepy has joined #ruby
<shadoi>
robacarp: right, I actually use "public_send" in my code, and all my non-accessible methods are private.
<robacarp>
well, what do you mean storage?
<A124>
robacarp: Where the pages / scraped data goes.
<A124>
robacarp: I'm not only in scraping. So storing whole pages is relevant.
<shadoi>
robacarp: and only accessors have setters anyway.
<robacarp>
shadoi: if thats what you want to do, then do it...when it comes back to bite you in the ass later because you forgot to privatize a method or something
pkondzior has joined #ruby
TheDeadSerious has joined #ruby
pvh has joined #ruby
relix has joined #ruby
<robacarp>
A124: okay, if you're just going to download a crap ton of pages it doesn't matter how you do it, its going to take the same amount of space.
fcoury has joined #ruby
<robacarp>
if you're going to scrape some data out of it you'll probably want to store it in a database and the data is the size of the data
<shadoi>
robacarp: what's a more secure way to do it for data that can contain arbitrary keys?
<robacarp>
about speed though, parallelism is your friend here, because your process is network bound.
VictorMartins has joined #ruby
si14 has joined #ruby
<A124>
robacarp: The thing is. I would like to do both. The storage for one entry is about 12-25kB + tenst to hunder kbB of raw.
kaichanvong has joined #ruby
<robacarp>
well, you can gzip it I suppose, too.
technel has joined #ruby
<robacarp>
shadoi: well. I sppose there really isn't, but I would be really curious as to why you need to write generic meta-code that must work across all possible values of keys.
bwlang has joined #ruby
<robacarp>
that said, if its what you need to do, its what you need to do.
ethicalhack3r has quit ["Leaving"]
<shadoi>
robacarp: I've implemented a base class for all my models, it uses this, and they are all subclasses.
<robacarp>
and if it comes back to bite you, thats just teh consequences of life.
<shadoi>
I guess I'll just be super anal about security in my base class. :)
<shadoi>
like always.
srid has joined #ruby
srid has joined #ruby
srid has joined #ruby
<robacarp>
yea, I think you're seeing the juxtaposition of security and convenience here
<shadoi>
For sure.
moemen has joined #ruby
<A124>
robacarp: The statement about size is not true.
<robacarp>
...okay...
<A124>
robacarp: Yes. Thanks for gzip tip. It saves space. Though not optimal in all cases :)
<A124>
robacarp: (about the sizes againg) To be exact, not as with storing the data in non-raw format. Nor even classic compression methods.
MoMo has joined #ruby
patricksroberts has joined #ruby
SeanTAllen has joined #ruby
jrgifford has joined #ruby
<workmad3>
shadoi: and I think robacarp's original point about sending {'blah=' => 'foo'} to the method breaking things is valid tbh... your code would test if the object responded to 'blah=' (which it would) and would then attempt to send 'blah==' which would raise a NoMethodError
<robacarp>
workmad3: yea, the odd thing is that it doesn't raise an error
<robacarp>
it doesn't set the attribute either...but it doesn't raise an error
<workmad3>
robacarp: hmm... interesting
<robacarp>
oh, wait, my test case was different from the example
<workmad3>
robacarp: heh :) I just tried in irb and got a NoMethodError
<A124>
workmad3: Hey. Just reading again your advices :)
<workmad3>
A124: still having fun with your distributed crawler? :)
dkannan has joined #ruby
<robacarp>
now you've made me want to make a crawler.
<A124>
workmad3: Yeah. I had to overcome some nasty things like transition to 1.9, URI parsing problems and such
<workmad3>
robacarp: a sandcrawler? :D
randym has joined #ruby
<workmad3>
robacarp: oh crap, thinking about that made me think about a crawler filled with java jawas...
<workmad3>
that's an image that's gonna hang around for a while
polarist has joined #ruby
xrl has joined #ruby
<nobitanobi>
what would be the best way of doing this: Given an array [1,2,3,4], just get [1,4] -- so, first and last element.
<A124>
workmad3: java jawas? Coffee?
<robacarp>
nobitanobi: [array.first, array.last]
ziyadb has joined #ruby
<robacarp>
okay, my coworkers are flying helicopters around the office now.
Dr4g_ has joined #ruby
shruggar has joined #ruby
<nobitanobi>
robacarp: thanks
saidin has joined #ruby
<robacarp>
nobitanobi: np
<shadoi>
robacarp: sure it does, it raises a NoMethodError for 'blah=='
svnlto has joined #ruby
DrShoggoth has joined #ruby
<robacarp>
I wonder how many website url's I could catalog in a sqlite database < 1G
kf8a has joined #ruby
<shadoi>
oh, nm, didn't read far enough
<shadoi>
workmad3: having something like 'blah=' in my case it would never surface because it wouldn't pass the JSON schema validation, so it would never get to instantiation.
havenn has joined #ruby
trend has joined #ruby
jleitgeb has joined #ruby
kenneth has joined #ruby
ZenoArrow has joined #ruby
zulax has joined #ruby
denysonique__ has joined #ruby
stringoO has joined #ruby
<workmad3>
shadoi: ah, fair enough :)
<ZenoArrow>
Hi, I'm doing my nut in trying to understand access control in Ruby. Hope someone here can help me. I think I'm most confused about 'protected'.
<workmad3>
ZenoArrow: basically, private means you can't have an explicit receiver for the method (so it's an error if you do obj.private_method, even if obj is 'self')
BrianE has joined #ruby
<workmad3>
ZenoArrow: protected, you can call the method with an explicit receiver, but only from within an instance of the class (or an instance of a subclass)
<ZenoArrow>
My own understanding of protected is that instances of a class are allowed to call protected methods, so why does the call 'ca.m2' in the code I linked to fail, as ca is an instance of the ClassAccess class?
<workmad3>
ZenoArrow: because you're doing it from outside the class
<ZenoArrow>
robacarp, thanks I'll have a look at that.
<workmad3>
ZenoArrow: if you could do it like that, protected would be identical to public ;)
<ZenoArrow>
workmad3, so protected methods are only available in the class they're defined in, and sub-classes of that class?
<workmad3>
ZenoArrow: and only from within the class, yes
<ZenoArrow>
So only public methods are accessible outside a class?
hukl has joined #ruby
kapowaz has joined #ruby
<ZenoArrow>
I think it's this wording that is confusing me: 'only from within an instance of the class'. To me, an instance of a class is an object defined using the class as a blueprint.
<ZenoArrow>
I understand in Ruby that 'Class' is a type of object as well, but instance of a class seems rather vague to me now!
pastjean has joined #ruby
<ZenoArrow>
Thanks workmad3, I'll look at that now. BRB.
__main__ has joined #ruby
robcthegeek has joined #ruby
<nobitanobi>
Is there a ruby way to get the middle element of an array?
<workmad3>
nobitanobi: define 'middle'
<nobitanobi>
yes.. if the array size is odd [1,2,3] --> middle would be 2
<nobitanobi>
if array size is even [1,2,3,4] , I would choose between 2 or 3, rounding up or down.
<A124>
nobitanobi: The thing is if array is [1,2,3,4], what is middle?
<workmad3>
nobitanobi: which one would you pick in the even case though?
<ZenoArrow>
nobitanobi, you could divide array length by 2, and if you got a remainder from the division, either round up or round down (depending on your own preference).
<workmad3>
nobitanobi: because chances are, whichever you pick, plenty of people will disagree ;)
<nobitanobi>
I was just wondering if there was any ruby magic way of doing so
<workmad3>
nobitanobi: (which is an explanation as to why ruby doesn't have a .middle method)
<nobitanobi>
correct, makes sense
<A124>
nobitanobi: No, there is not. As workmad said. It's a thing to dispute and not oftenly use anyway.
<workmad3>
nobitanobi: you could just do ary[ary.size/2] though
<ZenoArrow>
nobitanobi, it logically can't be done, it's not Ruby's fault!
<gogiel>
nobitanobi: class Array; def middle; [size/2+1]; end; end
<ZenoArrow>
The closest you can get is an approximation.
<nobitanobi>
heeeey I am not blaming Ruby!
<nobitanobi>
I love Ruby!
<workmad3>
ZenoArrow: at least until ruby defines what ary[2.5] means, anyway :)
<nobitanobi>
but thanks for the suggestions
kstephens has joined #ruby
<workmad3>
gogiel: your middle method would be incorrect in the case of an array of size 1 btw...
<workmad3>
hmm, and of size 2...
<gogiel>
workmad3: no, it will work
<workmad3>
gogiel: 2/2 + 1 = 2, which is the third element... I know ruby would probably let it pass, but it's still wrong ;)
<gogiel>
oops, i made a mistke
<gogiel>
workmad3: becasue i was testing it quickly on [1,2,3] arrya ;)
<workmad3>
gogiel: wouldn't it have returned '3' in that case too?
nobitanobi has joined #ruby
<gogiel>
class Array; def middle; self[size/2]; end; end
<ZenoArrow>
workmad3, thank you so much for that gist, I understand most of it now! The only line I don't quite grok yet is this one, I understand what you're doing (calling a protected method from within the class), but I'm not familiar with all the syntax...
<ZenoArrow>
other ? other.protected_foo : self.protected_foo
<workmad3>
ZenoArrow: oh, sorry, that's just the ternary operator
<ZenoArrow>
What do the ? and : symbols do in this example?
<ZenoArrow>
The ternary operator?
<workmad3>
ZenoArrow: it's equivalent to if other; other.protected_foo; else; self.protected_foo
shadykhan has joined #ruby
n3m has joined #ruby
<shadykhan>
best ruby online learning source?
<ZenoArrow>
Ah, I'm starting to see. Thanks workmad3.
<A124>
I love ternary.. saves a ton of code.
tobym has joined #ruby
<workmad3>
A124: as long as you don't abuse it ;)
nobitanobi1 has joined #ruby
<ZenoArrow>
shadykhan, I've been using rubylearning.com. It's been pretty good to me so far, sometimes I'll get stuck but that just forces me to broaden my knowledge about the language.
colinwd has joined #ruby
<A124>
workmad3: Yeah. Sometimes I do it on purpose though xD
<shadykhan>
thanks ZenoArrow ill look into it
<ZenoArrow>
You're welcome shadykhan.
martinciu has joined #ruby
<ZenoArrow>
workmad3, two final questions about that gist. What happens when other is set to nil (i.e. the default behaviour) and self.protected_foo is called? How does other.protected_foo differ from self.protected_foo in terms of the program output?
stephenjudkins has joined #ruby
nari has joined #ruby
<workmad3>
ZenoArrow: other.protected_foo calls protected_foo on the object you pass in (which in the example is a different instance of the same class)
<A124>
I wonder.. if I shouldgo through some tutorial also, if I started earlier, when there was no known tutorial?
<workmad3>
ZenoArrow: basically, it demonstrates that you can call protected_foo on other instances of the same class inside an instance method
<workmad3>
ZenoArrow: however, because protected_foo just prints out the same line, no visible difference occurs ;)
<workmad3>
ZenoArrow: however, if other is nil, then the method falls back on calling protected_foo on itself
<workmad3>
ZenoArrow: so if you did 'a.call_protected_foo' it would call protected_foo on a, but when you do 'a.protected_foo(b)' it calls b.protected_foo
bwlang has joined #ruby
<ZenoArrow>
Ah, so because you're passing in the object 'b' which is an object of the same class as 'a' then the call is made to b.protected_foo, rather than a.protected_foo?
cloke_ has joined #ruby
<workmad3>
ZenoArrow: yeah
<ZenoArrow>
Sorry, it seems I had another 'final question', must feel like an episode of Columbo to you! ; )
<workmad3>
ZenoArrow: if you tried the same thing with a private method, you'd get an error ;)
<ZenoArrow>
Thanks workmad3, you're a diamond, I understand it now!
<workmad3>
lmi2
<workmad3>
oops, that wasn't right :/
mneorr has joined #ruby
ChampS666 has joined #ruby
<ZenoArrow>
You should really put that gist out there for more people to learn from, if you haven't already, as it really helps!
<ZenoArrow>
As did your explanation of course!
<A124>
workmad3: Just to clarify. You can call proteted methods only on other instances of self.class, right?
fr0gprince_ has joined #ruby
<workmad3>
A124: pretty sure you can call protected methods on instances of subclasses too
phantasm66 has joined #ruby
<workmad3>
ZenoArrow: I wrote that gist from scratch for you just now ;)
<ZenoArrow>
That's freaking amazing dude, you're the bomb, seriously. I just copied the whole of this chat transcript and saved it in a text file called 'Understanding Ruby Access Control', I'm sure it'll come in handy should I ever need a refresher! :-)
artOfWar_ has joined #ruby
<workmad3>
ZenoArrow: do you want to know the kicker? I don't think I've ever actually used 'protected' in ruby ;)
<workmad3>
other than when learning the language
<A124>
workmad3: Ah. And subclasses too, thanks.
polarist has quit [#ruby]
<ZenoArrow>
Ha! Well you clearly understand it good enough to teach it, which is a very good indicator that you've absorbed the knowledge needed to use it, if you ever choose to. :-)
<ZenoArrow>
Okay, I'm off. Cheerio peeps!
<workmad3>
ZenoArrow: I was more indicating how 'useful' the knowledge is likely to be :)
swarley has joined #ruby
samsonjs has joined #ruby
<ZenoArrow>
workmad3; I understand, but I like to learn as much as I can about programming, even if I'll probably not use it. :-)