Topic for #ruby is now Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/
davidd` has quit ["Leaving..."]
<any-key>
they used some form of cross platform toolkit
techhelp has joined #ruby
igotnolegs has joined #ruby
ephemerian has joined #ruby
<glosoli>
any-key: I find that Ruby is quite popular for Mac OS X apps?
frishi has joined #ruby
<glosoli>
or am I thinking wrong
<any-key>
not sure
<any-key>
I'd imagine ObjectiveC would be more popular :P
<glosoli>
well yes ;D
burns180 has joined #ruby
<Tasser>
sarmiena_, I'd use sequel or DM without rails
<banisterfiend>
glosoli: where did u hear that
emmanuelux has joined #ruby
<glosoli>
banisterfiend: dunno, just thought that, seen some of them in a few days
<banisterfiend>
glosoli: cn u name one
zulax has joined #ruby
<glosoli>
banisterfiend: thought that wunderlist is it hmm, but I might be completely wrong
<fowl>
wunderlist, sounds naughty
<banisterfiend>
fowl: bbs
zakwilson has joined #ruby
<sarmiena_>
banisterfiend: any idea why i'd be getting a malloc error with this: http://pastie.org/3514915
shevy has joined #ruby
<sarmiena_>
part of the httpclient-2.2.4 gem
<banisterfiend>
sarmiena_: run it in gdb
burns180_ has joined #ruby
<sarmiena_>
banisterfiend: oh man. that looks like a lot of fun :/
<fowl>
sarmiena_: try an older version
<sarmiena_>
hmm yeah. think that's worth a shot
<banisterfiend>
sarmiena_: learning some gdb is a major productivity helper if you're writing/debugging C extensions
<banisterfiend>
without it, you're just guessing
<sarmiena_>
banisterfiend: yeah. it'll be weeks before I can get a firm grasp on C and the ruby source code haah
<banisterfiend>
sarmiena_: C is a very easy language to read, it's just writing it is hard ;)
<sarmiena_>
hehe ok. i'll keep that in mind when i'm neck deep in the stuff
cableray has joined #ruby
A124 has joined #ruby
davidpk_ has joined #ruby
macabre has joined #ruby
emocakes has joined #ruby
ymasory has joined #ruby
<frontendloader>
right-affixed colons for hash symbol keys is 1.9 right?
wadkar has joined #ruby
<wadkar>
what is the var_dump equivalent of PHP in ruby ?
nonotza_ has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
i8igmac has joined #ruby
<wadkar>
inspect?
<any-key>
yeah, I suppose
<frontendloader>
inspect isn't magic like a dump function might be
Seisatsu has joined #ruby
<frontendloader>
it just invokes the inspect method on an object, and if the object doesn't define inspect for itself you're out of luck
burns180 has joined #ruby
stephenjudkins has joined #ruby
nfluxx has joined #ruby
wmoxam has joined #ruby
wmoxam has joined #ruby
johndbritton has joined #ruby
A124 has quit [#ruby]
ZachBeta has joined #ruby
indstry has joined #ruby
banisterfiend has joined #ruby
<wadkar>
frontendloader: hmm, I just want to print out an array/hash/string ; simple objects ; who's value is what I want to see; var_dump is poor man's debugger
pen has joined #ruby
travisjeffery has joined #ruby
thecreators has joined #ruby
mmokrysz has joined #ruby
LBRapid has joined #ruby
mmokrysz has quit [#ruby]
zehrizzatti has joined #ruby
<frontendloader>
oh yep, inspect
tatsuya_o has joined #ruby
<Veejay>
Is there an operation that is the opposite of .to_s for a Hash
wmoxam has joined #ruby
<Veejay>
That would turn "{foo: 40, goo: "bang"}" into the appropriate Hash
Rishi_ has joined #ruby
fowl has joined #ruby
LBRapid has joined #ruby
<Veejay>
Forget that question, it's as stupid as my face
bsdbandit has joined #ruby
<frontendloader>
eval what you were looking for?
burns180_ has joined #ruby
banisterfiend has joined #ruby
ryanf has joined #ruby
<zehrizzatti>
Veejay, it appears to me that Hash#to_s is more of a convenience method for inspection...
<banisterfiend>
Veejay: anyone ever called you vajayjay?
<banisterfiend>
:D
<zehrizzatti>
you could use an appropriate marshalling mechanism like json, I guess
centr0 has joined #ruby
QaDeS_ has joined #ruby
havenn has joined #ruby
ryanf has joined #ruby
wroathe has joined #ruby
badabim has joined #ruby
etank has joined #ruby
mikeycgto has joined #ruby
mikeycgto has joined #ruby
ryanf_ has joined #ruby
seanstickle has joined #ruby
cableray has joined #ruby
burns180 has joined #ruby
<wadkar>
errm , there are no public/private modifiers in ruby, right ? so how do I tell if a method on a class is public or private ?
<cantonic>
guys, i have to do something tricky. i have a main.rb and sub.rb … sub.rb has to be run by main.rb for every incoming request and i need the possibility to run sub.rb multiple times and pass arguments to it… how could i do that?
shtirlic has joined #ruby
sonkei has joined #ruby
tomzx_ has joined #ruby
yoklov has joined #ruby
sarmiena_ has joined #ruby
machine1 has joined #ruby
stephenjudkins has joined #ruby
cobragoat has joined #ruby
burns180_ has joined #ruby
Hanmac1 has joined #ruby
wmoxam has joined #ruby
Companion_ has joined #ruby
ZachBeta has joined #ruby
wmoxam has joined #ruby
gmas has joined #ruby
dbgster has joined #ruby
yefim323 has joined #ruby
yefim323 has quit ["Leaving"]
pu22l3r has joined #ruby
wmoxam has joined #ruby
thecreators has joined #ruby
machine1 has joined #ruby
i8igmac has joined #ruby
<sudhi>
err, what am I doing wrong? foo1 = [ 'bar', 'baz' ] ; foo2 = foo1 ; foo2[1].upcase! ; puts foo1.inspect #=> shows me BAZ ?!
wmoxam has joined #ruby
<sudhi>
ruby assignment is by reference only? how do I do a deep copy?
etank has joined #ruby
adeponte has joined #ruby
epochwolf|2 has joined #ruby
burns180 has joined #ruby
ChampS666 has joined #ruby
<sudhi>
and this is even more puzzling ; foo3 = foo2[0]; foo3.upcase! ; puts foo1.inspect; #=> shows me BAR !!??
senthil has joined #ruby
neohunter has joined #ruby
uabn93 has joined #ruby
<seanstickle>
sudhi: why should this puzzle you?
<sudhi>
seanstickle: aren't foo3, foo2, foo1 different variables ? or are they same ?
wmoxam has joined #ruby
<seanstickle>
Different variables pointing to the same object.
<sudhi>
how come changing one affects the other?
<sudhi>
seanstickle: then how do I _deep-copy_ an object ?
<seanstickle>
foo.dup
<fowl>
sudhi: at that point foo3 is pointing to the same object in foo1
<sudhi>
seanstickle: so foo2 = foo1.dup ; # change foo2 ; #foo1 still same ?
<heftig>
sudhi: foo2 = foo1.map(&:dup)
<heftig>
will do a two-level copy
<sudhi>
heftig: so foo1.dup won't copy the entire hash/array as a deep copy ?
<heftig>
nope. just the array itself
<heftig>
so you get two different arrays holding the same objects
<sudhi>
heftig: this is going way over me, isn't array an object whose elements are 'bar', 'baz' ; how can then foo2 and foo1 contain same element after deep_copy?
<heftig>
dup is not a deep copy, just a shallow copy
<heftig>
and foo2 = foo1 isn't a copy at all
<sudhi>
heftig: ohhk, got it, so whats the method to do deep_copy ? surely ; you do want to deep copy stuff sometimes
<heftig>
there's none
<heftig>
you could serialize and unserialize via Marshal
<sudhi>
heftig: yeah, (un)serializing will give me a deep copy for sure (I hope)
wmoxam has joined #ruby
<sudhi>
heftig: just wondering , foo2 = foo1.map(&:dup) #=> two-level copy ; what happens if the array/hash has more dimensions , say 4 levels ?
Emmanuel_Chanel has joined #ruby
<heftig>
not deep enough
<sudhi>
heftig: meaning there's still a chance that 3rd of 4th level modification can propagate back to source?
Jragon has joined #ruby
pantsman has joined #ruby
pantsman has joined #ruby
uabn93 has quit ["Leaving"]
<sudhi>
(I mean they are still pointing to same object)
<heftig>
yes
sacarlson has joined #ruby
<sudhi>
heftig: phew ! thats errm, strange ; was puzzled for past 1 hour , but I hope to get hang of it soon :) thanks !
burns180_ has joined #ruby
<centr0>
why is my .to_yaml method outputting binary on a hash?!
timonv has joined #ruby
sako has joined #ruby
startling has joined #ruby
startling has quit [#ruby]
sroy2_ has joined #ruby
techhelp has joined #ruby
<sudhi>
winning_turn = turn1[strategy] == is_beaten_by(turn2[strategy]) ? turn2 : turn1 #=> is this the right usage of ternary operator ; or should I stick with if/unless ?
<bsdbandit>
anyone installed ruby on rails on mac osx lion using macports ?
<seanstickle>
bsdbandit: yup
<seanstickle>
bsdbandit: although I ended up using rvm instead
banisterfiend has joined #ruby
omahajoe has joined #ruby
gener1c has joined #ruby
gener1c has joined #ruby
<gener1c>
ok i tried and i tried and i googled and i tried again , its 530 am and i still can figure out thie readline problem
albemuth has joined #ruby
<gener1c>
does anyone have any idea how to fix the readline issue that irb shouts at me about?
<sudhi>
I have game = [ turn1, turn2] and get_winner(game) function ; given a (sane)tournament_list of 2^n game, i need to recursively determine the winner ; I am confused how to use reduce in combination with recursion
<avalarion>
Hey there, I need help with using regex in Ruby. http://pastebin.com/NVTUc5gL content should only be (.*) but is the full RegEx...
goodieboy has joined #ruby
wmoxam has joined #ruby
gener1c has joined #ruby
gener1c has joined #ruby
briankbuckley has joined #ruby
radic_ has joined #ruby
<gener1c>
well i did: apt-get install ruby-libs then i did rvm install readline then rvm install zlib then rvm install 1.9.2 -C --with-zlib-dir=~/.rvm/usr/lib --with-readline-dir=~/.rvm/usr/lib
<sudhi>
how to split an array of 2^n length into two parts , first containing 0 to 2^n/2 - 1 and the rest ?
<sudhi>
and the second* part* containing* the rest ?
randym_zzz has joined #ruby
<fowl>
sudhi: how about like huge_array[0..(huge_array.size*0.5)] and huge_array[(huge_array.size*0.5)..-1] ?
<fowl>
:P
<fowl>
that would just split it in half
<sudhi>
fowl: ohh, the double dots (..) work like enumeration list or something like that ?
<sudhi>
fowl: so .. includes the end point, ... doesn't include the end point, but in either case the start point is included (makes sense as we give it as input)
delsea_ has joined #ruby
<fowl>
sudhi: you can also pass x, y like [0,1,2,3,4,5,6][1,5] #=> [1,2,3,4,5] (start at index 1, get 5 items)
prtksxna has joined #ruby
hatorade has joined #ruby
<fowl>
sudhi: you can even define your own behavior for [] by defining a [] method :)
<sudhi>
fowl: thats nice , I think the solution should be recursive_list = [ list[0...(list.size/2)], list[(list.size/2)..-1] ]
<sudhi>
s/should/would/
<sudhi>
triple dots for the first part and double dots for the second
<sudhi>
now if only I could do the function call via list.reduce() it would be great !
hatorade has quit [#ruby]
wmoxam has joined #ruby
chaitanya_ has joined #ruby
<avalarion>
How to solve TypeError (can't convert MatchData into String) ?
<sudhi>
(core doc doesn't list size as a method for array, so I thought I will stick with length)
<fowl>
sudhi: honestly i just recommend pry to people
<sudhi>
and when should I use return statement , like in the middle of a method where I realize I got the return value and no need to come out of the loop/conditionals ?
<sudhi>
fowl: pry ?
wmoxam has joined #ruby
wmoxam has joined #ruby
<fowl>
its like irb on steroids: http://pry.github.com/ you'll be prototyping in no time
<fowl>
yeah if you need to break out early thats when you'd use it
poindontcare has joined #ruby
<sudhi>
fowl: something like ipython as opposed to normal python interpreter ? cool, I will give it a shot
igotnolegs has joined #ruby
albemuth has joined #ruby
burns180 has joined #ruby
rohit has joined #ruby
blueadept has joined #ruby
justinmcp has joined #ruby
ProLoser|Mac has joined #ruby
<ProLoser|Mac>
where should i go for help with compass/sass?
cloudgeek has joined #ruby
<ProLoser|Mac>
i want to pass the sass and return the css in cli
<ProLoser|Mac>
so that i can execute it in my fw on a variable/blob
<cloudgeek>
looking to follow a zen ruby master for learning by doing
<cloudgeek>
in ruby
<cloudgeek>
is anybody can help
<banisterfiend>
cloudgeek: $100 an hour and you're sorted ;)
burns180_ has joined #ruby
avalarion has quit [#ruby]
waxjar has joined #ruby
SegFaultAX has joined #ruby
undersc0re has joined #ruby
maletor has joined #ruby
wmoxam_ has joined #ruby
manojhans has joined #ruby
baroquebobcat has joined #ruby
langbiangplaza has joined #ruby
mvangala_ has quit [#ruby]
langbiangplaza has joined #ruby
kawa_xxx has joined #ruby
langbiangplaza has joined #ruby
<sudhi>
how do I know if an element of an array is of type string ? and not one more nested level of array?
langbiangplaza has joined #ruby
<fowl>
something.is_a? String
radmacd has joined #ruby
radmacd has quit [#ruby]
Andromeda has joined #ruby
<td123>
is there a way to tell bundle to remove any gems that don't appear in your Gemfile?
<sudhi>
fowl: ohhk, so I assume there is similarly .is_instance_of?
odinswand has joined #ruby
FortKnox has joined #ruby
emid_ has joined #ruby
sdwrage has joined #ruby
<sudhi>
fowl: if I do myHash = {} ; myHash[variable] = value ; puts myHash.inspect #=> {["what"]=>3, ["the"]=>2}
cook1es_ has joined #ruby
<sudhi>
why is it taking that extra square brackets as if the key is an array element ?
ysiad has joined #ruby
robacarp has joined #ruby
s0ber has joined #ruby
<sudhi>
I am basically doing : words = sentence.scan(/(\b\w+\b)/) ; words.each { |word| result[word] = words.count(word) }
<sudhi>
where result = {} #initialize to empty hash
burns180 has joined #ruby
srp_ has joined #ruby
abstrusenick has joined #ruby
CodeZombie has joined #ruby
robertjpayne has joined #ruby
Natch| has joined #ruby
A124 has joined #ruby
<heftig>
sudhi: remove the parentheses in the regex
porco has joined #ruby
<heftig>
with the parentheses, scan will return an array of arrays of strings, not an array of strings.
emid_ has quit ["quit"]
Quirrell has joined #ruby
<sudhi>
heftig: hmm, ohhk, so the scan itself creates an array, and the parentheses create one more, got it, thanks !
<sudhi>
though I may need to use parentheses if I _actually_ need an array of 'group of strings' as array
tommyvyo has joined #ruby
srp_ has joined #ruby
torto has joined #ruby
<sudhi>
when I have array = [1,2,3,4,5] ; array.each do |num| #..some code ; do I necessarily travel the array in order ? or is it random ? as in if I want to do some search based on the index of num , can I do it?
undersc0re has joined #ruby
<heftig>
sudhi: it's in order
undersc0re has joined #ruby
stephenjudkins has joined #ruby
<robertjpayne>
Is there a way to set the UTC offset on a DateTime object? DateTime.new doesn't seem to use the machines local time zone
kuzushi has joined #ruby
stephenjudkins has joined #ruby
<Drewch>
When can u use require instead of require_relative
<Drewch>
I see programs of people using require 'path/to/file'
TinhTienMau has joined #ruby
rippa has joined #ruby
<sudhi>
heftig: thanks, I am just not sure how do I iterate over an array by poping out one element at a time, while also removing some elements from the array while inside the loop
TinhTienMau has joined #ruby
<heftig>
there are special iterators for deleting
<sudhi>
maybe I should create a deep copy first and then pop from original, and pop+remove matching from the copy
seanstickle has joined #ruby
burns180_ has joined #ruby
<sudhi>
heftig: those ending with a bang ! right ? but I want to remove element based on a condition, while inside the loop
<sudhi>
which doesn't look right to me when I think about it; I mean, who modifies the array while iterating over it ?
<rippa>
sudhi: Array#reject!
<heftig>
sudhi: delete_if
cobragoat has joined #ruby
<rippa>
that's almost the same thing
<rippa>
but delete_if is better
<rippa>
because it can't return nil
TinhTienMau has joined #ruby
banisterfiend has joined #ruby
<sudhi>
heftig: rippa : ohhk, so reject! sounds good, I think I will reject 0th element, and those matching the conditional too; that way after iterating the array, it should become empty
x0F__ has joined #ruby
TinhTienMau has quit [#ruby]
TinhTienMau has joined #ruby
esotericalgo has joined #ruby
TinhTienMau has joined #ruby
yoklov has joined #ruby
al3xnull has joined #ruby
TinhTienMau has quit [#ruby]
TinhTienMau has joined #ruby
Morkel has joined #ruby
TinhTienMau has quit [#ruby]
poindontcare has joined #ruby
macmartine has joined #ruby
<sudhi>
strings have no sort method ? hmm, interesting, I think I get my first chance to sort ASCII strings :)
<bgupta>
Is there anyway to make a thor cli utility that takes global options? e.g. - myscommand --debug subcommand.
<esotericalgo>
sudhi: you can sort a string by using the enumerable chars iirc
<bgupta>
I am finding references to global options in the commit log, but the wiki/docs mention nothing about it
<robertjpayne>
The last paramter in DateTime.new takes the UTC offset in fraction form right? I'm having no luck creating a DateTime with a proper UTC offset
<heftig>
robertjpayne: takes a string
<heftig>
can identify a timezone or an offset
sako has joined #ruby
<robertjpayne>
heftig: right, ok I think I noticed the second to last is offset fraction.. I was looking at some bad sample code I think
<heftig>
"+4", "-4", "CET", "CEST", "EDT" all work
sizz has joined #ruby
dubellz has joined #ruby
rramsden has joined #ruby
burns180_ has joined #ruby
<bgupta>
Is there a better IRC channel for getting help writing CLI commands in Ruby? (I am not set on THor it just seems the most popular)
<seanstickle>
You can try #ruby-lang
<bgupta>
seanstickle: thanks
dbruns has joined #ruby
tk___ has joined #ruby
stephenjudkins has joined #ruby
<dbruns>
Since when can you shorten :label => 'test' to label: 'test' ?? where can I find documentation on this?
<seanstickle>
dbruns: welcome to Ruby 1.9
<dbruns>
so where can I find documentation on this? is it simply a shortcut for symbol => '' in a hash?
<sudhi>
rippa : of course, use return in combination with super ! thats neat :)
blueadept has quit ["Leaving"]
sarmiena_ has joined #ruby
abcsdgad has joined #ruby
davidcelis has joined #ruby
i8igmac_ has joined #ruby
vraa_ has joined #ruby
thecreators has joined #ruby
abcsdgad has joined #ruby
abcsdgad has joined #ruby
minijupe has joined #ruby
Asher has joined #ruby
cableray has joined #ruby
senthil has joined #ruby
abcsdgad has joined #ruby
burns180_ has joined #ruby
LMolr has joined #ruby
abstrusenick has joined #ruby
sako has joined #ruby
abcsdgad has joined #ruby
robertjpayne has joined #ruby
<senthil>
what do you guys use for code stats? can't get metrical or metric_fu working properly
cloudgeek has joined #ruby
i8igmac__ has joined #ruby
yxhuvud has joined #ruby
Zolrath has joined #ruby
akemrir has joined #ruby
Jackneill has joined #ruby
tewecske has joined #ruby
A1241 has joined #ruby
dlam has joined #ruby
mdw has joined #ruby
rippa has joined #ruby
rippa has joined #ruby
<robertjpayne>
Is it more ruby like to use self. or @ to access instance variables? (Regardless of read/write etc.. )
<ekaleidox>
do it however its easiest for you to debug later. but if youre asking for opinions, i prefer @
<rippa>
self is implied
<epitron>
rippa: i wonder if you could do that with short-circuited logic :)
<epitron>
def foo; @bar == 'baz' || super; end
mdw has joined #ruby
bier has joined #ruby
<epitron>
(re: what you posted to sudhi 45 mins ago)
<epitron>
(little late)
burns180 has joined #ruby
<sudhi>
epitron: nah, I have to return false if @bar == 'baz' ; wont work with short-circuit-logic
<epitron>
ah
<epitron>
i think if/else looks cleaner
nachtwandler has joined #ruby
<epitron>
or just: def foo; @bar == 'baz' ? super : false; end
<sudhi>
thats what I did, but ternary are hard to read
<epitron>
nahh
<epitron>
that's a perfect use of a ternary operator
<sudhi>
(for others :P)
<epitron>
a == b ? thing1 : thing2
<epitron>
very clean and clear
<epitron>
it's only bad if the expressions start to get complicated
<epitron>
then you can't see the ? and : anymore :)
<epitron>
they get lost in the fog of complexity
<rippa>
include? ? :derp : :herp
<rippa>
include? ? ? : :b
<rippa>
even better
<rippa>
damn
<rippa>
include? ? ?? : :b
bluOxigen has joined #ruby
<epitron>
hahah
<epitron>
that's my new favorite ruby expression
<epitron>
include ? ? ?? : ?!
<epitron>
-\
<epitron>
actuallyyy
<epitron>
include? ?? ? ?! : ??
<epitron>
hah! it works
<ekaleidox>
or does it?
<ekaleidox>
</greek-style-mind-fuck>
<sudhi>
epitron: thinking about the short circuiting, I can make it work like this : def foo; ( @bar != 'baz' || false ) && super ; end
<epitron>
hahah
<epitron>
gj
<rippa>
['"'].include?(% ' ) ? % " : % ?
burns180_ has joined #ruby
<sudhi>
(and I was wondering I should write more readable code :P )
<epitron>
rippa: that doesn't work for me
<rippa>
in repl?
<epitron>
newp
<rippa>
eval %q<['"'].include?(% ' ) ? % " : % ? > does work for me
<epitron>
ah, okay
<epitron>
the repl isn't advanced enough to parse such a crazy structure :)
<epitron>
ohhh, are you using % X as a space-delimited string? :)
<epitron>
that is sneaky
<epitron>
that could make some pretty awesome obfuscated ruby
<ekaleidox>
you know what else is sneaky? ninjas
<epitron>
i did not know that!
<epitron>
probably because they're so sneaky
nemesit has joined #ruby
<epitron>
they managed to totally avoid being learned about
<ekaleidox>
truth
burns180 has joined #ruby
burns180_ has joined #ruby
ghanima has joined #ruby
Nss has joined #ruby
blacktulip has joined #ruby
burns180 has joined #ruby
glosoli has joined #ruby
ZeepZop has joined #ruby
ZeepZop has joined #ruby
lkba has joined #ruby
A124 has joined #ruby
ph^ has joined #ruby
flippingbits has joined #ruby
ZeepZop has joined #ruby
sizz has joined #ruby
<ZeepZop>
<irc://moz-net>
eldariof has joined #ruby
ZeepZop has joined #ruby
sudhi has joined #ruby
LMolr has joined #ruby
KL-7 has joined #ruby
burns180_ has joined #ruby
Synthead has joined #ruby
sabooky has joined #ruby
CheeToS has joined #ruby
cantonic has joined #ruby
robbyoconnor has joined #ruby
SiliconDon has joined #ruby
_john has joined #ruby
machine1 has joined #ruby
havenn has joined #ruby
visof has joined #ruby
visof has joined #ruby
pen has joined #ruby
francisfish has joined #ruby
burns180 has joined #ruby
fayimora_ has joined #ruby
d3vic3 has joined #ruby
john___ has joined #ruby
stephenjudkins has joined #ruby
machine1 has joined #ruby
_john has joined #ruby
looopy has joined #ruby
vaneda has joined #ruby
banisterfiend has joined #ruby
glosoli has joined #ruby
LowKey has joined #ruby
brjannc has joined #ruby
sgmac has joined #ruby
apeiros_ has joined #ruby
mohsin^ has joined #ruby
<mohsin^>
hi there
<mohsin^>
is there a way to find out of an array is nest array ?
<mohsin^>
one way i could think of was to check the type of element at a[0] ..
<mohsin^>
and if type is array .. I am still not at the data elements level
<mohsin^>
i thought i should ask experts
niko has joined #ruby
SiliconDon has joined #ruby
al3xnull has joined #ruby
burns180_ has joined #ruby
sayem has joined #ruby
<banisterfiend>
mohsin^: Yeah
<banisterfiend>
mohsin^: you want ot know if all elements are arrays?
<banisterfiend>
or just that one of the elemtns is an array?
<mohsin^>
yes .. exactly
<banisterfiend>
all or one?
<mohsin^>
since at one level all elements are uniform (safe assumption) .. one would do
fyolnish has joined #ruby
<banisterfiend>
moshee: then use one? or all?
<mohsin^>
one
<banisterfiend>
array.one? { |v| v.is_a?(Array) }
<banisterfiend>
or if u want all
<banisterfiend>
array.all? { |v| v.is_a?(Array) }
<mohsin^>
thanks a lot
<banisterfiend>
np
<A124>
Or..
<mohsin^>
listening
<A124>
Compare flatten array
<A124>
arry.flatten == arry
<mohsin^>
I will look up flatten as well .. thanks A124
<Hanmac1>
A124 nope, one? and all? are VERY MUCH faster
<A124>
Welcome ;)
<A124>
Hanmac1: Depends on your situation
<A124>
Iterating in ruby is slower than doing one C# call
<A124>
So, istead of big iterating, you have two routines which runs in optimized binaries.
<A124>
*one
<Hanmac>
nope, because one? & all? break up the iteration if only ONE element is not what they want
davidpk has joined #ruby
wadkar has quit ["Leaving"]
greenarrow has joined #ruby
nicoulaj has joined #ruby
randym_ has joined #ruby
briankbuckley has joined #ruby
<apeiros_>
Hanmac, banisterfiend, you guys know the diffference between one? and any?, right? (exactly one vs. at least one) - I didn't read the whole backlog, so I don't know which one is really needed…
<Hanmac>
i knew the difference, it depends what moksin wants if he can grand that all elements on one level are the same, one? is good enough
<apeiros_>
Hanmac: as said, one? will test if exactly *one* fits the test, if it is two fitting the test, it will return false
<Hanmac>
fu you are right, i replaced this with any?
<apeiros_>
that's why I asked :)
<fyolnish>
anyone know about a good audio synthesis gem?
<fyolnish>
preferably oriented towards live coding
<Hanmac>
mohsin^ sorry for confusing you ... i think you can use "any?" instead of "all?"
sarmiena_ has quit [#ruby]
<mohsin^>
thanks Hanmac
sako has joined #ruby
<banisterfiend>
Hanmac: aren't one? and any? the same
<banisterfiend>
oh shit
<banisterfiend>
no
<Hanmac>
nope. like apeiros said. one? returns false if more then one element match
<banisterfiend>
one? is only wanted if there's only one element
<banisterfiend>
Yeah
<banisterfiend>
i notice now
ex0a has joined #ruby
cableray has joined #ruby
<banisterfiend>
for some reason i thought it meant >= 1, Hanmac
tvo has joined #ruby
tvo has joined #ruby
porco has joined #ruby
<Hanmac>
its not your fault .. we are all mostly human :P
pantsman has quit ["Leaving"]
<banisterfiend>
Hanmac: except Mon_Ouie, he's some kind of merciless programming teenage programming robot from belgium
<banisterfiend>
s/programming//
<Hanmac>
no i think he is a AI that learned to program
<Hanmac>
banisterfiend: sorry if i ask again ... if i have Flag constants, with are combinable with | ..but i dont like that constants ... exist an nicer way for that? (maybe replace them with symbols?)
Squarism has joined #ruby
<banisterfiend>
Hanmac: hmm i've never had to do that kind of thing in ruby before (but i do it in C). Maybe in ruby i would just have a flags array and #push symbols onto it :P
<banisterfiend>
and check for existence using any?
<banisterfiend>
hehe
<banisterfiend>
Hanmac: but i dont think it's so bad just using Flag constants either
<matled>
Hanmac: I'd use what banisterfiend suggested or an hash with true or false/nil
Foxandxss has joined #ruby
<matled>
a hash should be easier to use than an array
<Mon_Ouie>
Or a Set
srp_ has joined #ruby
<A124>
Back. What you are talking about? .. still the 'nested' issue?
<Mon_Ouie>
Other ways than bitflags to describe a set of options
ysiad has joined #ruby
berserkr has joined #ruby
burns180 has joined #ruby
demian`___ has joined #ruby
mrake has joined #ruby
wmoxam_ has joined #ruby
wmoxam has joined #ruby
rushed_ has joined #ruby
rushed_ has quit [#ruby]
Richmond has joined #ruby
Vendethiel has joined #ruby
SiliconDon has joined #ruby
TaTonka has joined #ruby
Spockz` has joined #ruby
Seisatsu has joined #ruby
TaTonka_ has joined #ruby
davidpk has joined #ruby
dbgster has joined #ruby
burns180_ has joined #ruby
mohsin^ has joined #ruby
mohsin^ has joined #ruby
francisfish has joined #ruby
havenn has joined #ruby
ephemerian has joined #ruby
iocor has joined #ruby
aim-On has joined #ruby
DuoSRX has joined #ruby
luxurymode has joined #ruby
odinswand has joined #ruby
Corey has joined #ruby
tayy has joined #ruby
canton7 has joined #ruby
vraa_ has joined #ruby
odinswand has joined #ruby
srp_ has joined #ruby
niko has joined #ruby
trivol has joined #ruby
emocakes has joined #ruby
fr0gprince_ has joined #ruby
joobn72 has joined #ruby
<trivol>
Is there any quick and easy way to launch a ruby script on an ec2 instance ? I looked at capistrano but I don't need that much awesomeness. I just need to scp my ruby script + some data, set the correct rubies, run bundle install and start my software.
burns180 has joined #ruby
Ch4rAss has joined #ruby
<Ch4rAss>
can I use rails migrations in standalone ruby application?
thone has joined #ruby
mikewintermute has joined #ruby
cantonic has joined #ruby
LMolr has joined #ruby
kidoz has joined #ruby
A124 has joined #ruby
sgmac has quit [#ruby]
<mohsin^>
ok guys .. get ready for a very very basic question .. what the variables that start with @
<mohsin^>
pardon me .. I am working with few tutorials to learn ruby and has not reached where it is explained
<rippa>
instance variables
davidpk has joined #ruby
Russell^^ has joined #ruby
<mohsin^>
thanks .. I will look that up
conor_ireland has joined #ruby
<mikewintermute>
Anyone know why this (wordhash is a hash; word is a string): wordhash[word.split('').sort!.join('')] += [word]
<mikewintermute>
gives me this in irb: NoMethodError: undefined method `+' for nil:NilClass
<rippa>
maybe it's aready sorted?
<rippa>
or more likely
kW has joined #ruby
<rippa>
that key does not exist
<rippa>
and you are doing nil += [word]
ziyadb has joined #ruby
<mikewintermute>
rippa: thanks - yes, that seems to be the problem.
<Hanmac>
mohsin^ @ are instance variables, @@ are class variables, $ are global variables, |v| are block variables ... and without maybe local variables
<mohsin^>
so @@ like static variables ?
<ziyadb>
Hello, I want to strip all non-alphanumeric characters from a phrase.
<ziyadb>
how do I do that?
<canton7>
ziyadb, mystring.gsub(/\W/, '')
<rippa>
or
<rippa>
string.gsub /[^[[:alnum:]]]/, ""
<ziyadb>
gsub it is. Thank you Rubyists.
burns180_ has joined #ruby
briankbuckley has joined #ruby
<canton7>
or you could use tr, if you were that way inclined
<Hanmac>
mohsin^ yeah a little bit ... but becare full ... @@ variables are also inherited ... so if you change them in the child class you change them also in the parent ...
<Hanmac>
/me wispers: an little secret is ... classes can have instance variables too
<ziyadb>
canton7: tr?
<banisterfiend>
Hanmac: can u whisper me a secret too
<Hanmac>
randym_ what i wish and what maybe come with 2.0 is multiarch :P
SiliconDon has joined #ruby
banisterfiend has joined #ruby
sbanwart has joined #ruby
glosoli has joined #ruby
Xerife has joined #ruby
berkes has joined #ruby
<banisterfiend>
Hanmac: named parameters, refinements, multiple vms, traits
macan has joined #ruby
<Hanmac>
ok named parameters are nice ... (if there are also nice to use in C-ext)
<Hanmac>
but i dont have an idea that traits are for ...
<banisterfiend>
Hanmac: basically better mixins
<shevy>
Hanmac ah
<Hanmac>
hu ... maybe i like that ... but first i must see how they are usefull for ...
<Hanmac>
PS: maybe 2.0 will be multiarch ... with that you can use an lib32-ruby on an lib64 system :P
bnhymn has joined #ruby
<shevy>
sometime in
<shevy>
2020
<shevy>
:)
<shevy>
ruby should replace smalltalk and squeak in spirit
<randym_>
and all projects should be running on travis-ci
<randym_>
but then, the world rarely is perfect ;)
philcrissman has joined #ruby
fayimora has joined #ruby
cantonic has joined #ruby
interlocutor has joined #ruby
al3xnull has joined #ruby
PragCypher has joined #ruby
nyuszika7h has joined #ruby
<mikewintermute>
wordkey = word.split('').sort!.join('') # am i right in saying sort and sort! are equally valid here?
sbanwart has joined #ruby
<Hanmac>
no, use sort without the !
<mikewintermute>
Hanmac: why?
chaitanya_ has joined #ruby
<Hanmac>
because sort! can return nil ... and nil does not have an join method ... and if that happens ... your application will crash
neurodrone has joined #ruby
<mikewintermute>
Hanmac: yes, good point.
Andromeda has joined #ruby
kexibq has joined #ruby
`brendan has joined #ruby
<mikewintermute>
Hanmac: just had a play - both sort and sort! can return nil (e.g. on "a = nil") so are there other cases?
<shevy>
mikewintermute it's a bad idea to chain more methods after using a method with !
<shevy>
x = %w( ghi abc ); x.sort; x # => ["ghi", "abc"]
burns180_ has joined #ruby
<shevy>
x = %w(ghi abc); x.sort!; x # => ["abc", "ghi"]
<mikewintermute>
shevy: ok - that's interesting - what's going on there?
<shevy>
mikewintermute ! modifies self
<shevy>
well, the method does
<shevy>
but it is also a convention in ruby
<canton7>
mikewintermute, in this case, sort! will always return an array when called on an array (at least according to the man page), so it's not much of an issue here. Other bang methods can return nil or something unrelated, though, hence it being bad practice
<shevy>
def foo vs def foo!
sbanwart has joined #ruby
jlebrech has joined #ruby
jagga has joined #ruby
<jagga>
hello, im newbie in ruby, can anyone help me with one thing regarding array, need to grep some data from array... thanks a lot in advance
<canton7>
jagga, just ask. Someone might chip in
<shevy>
array.grep
<jagga>
k
<shevy>
[1,2,"cat"].grep /c/ # => ["cat"]
<jagga>
so i have the following array ("the update date: 11 march 2011", "the update date: 12 march 2011")
<jagga>
i need to receive at final only dates
<jagga>
11 march 2011, 12 march 2011
<canton7>
do they all start with "the update date: " ?
<jagga>
yap
n1x has joined #ruby
<canton7>
tharray.map{ |a| a[17..-1] } is the hackiest and quickest way :P
<shevy>
hehe
<jagga>
hm
<shevy>
it's a good way, it solves the problem at hand
<jagga>
take a sec
ikaros has joined #ruby
<shevy>
canton7, I think he is wanting to change his conditions :(
andrenkov has joined #ruby
<andrenkov>
anyone use rhodes ? what version of ruby does it require ?
<jagga>
the second step is to convert strings (11 march 2011, 12 march 2011) in dates
<jagga>
=)
<canton7>
jagga, thearray.map{ |a| a.sub(/^the update date: /, '') } will also work, as will thearray.map{ |a| a[/^the update date: (.*)/, 1] }
<jagga>
thanks a lot canton7
<jagga>
i will try this, wait a second
adambeynon has joined #ruby
seanstickle has joined #ruby
sungji has joined #ruby
sungji has joined #ruby
cha1tanya has joined #ruby
<canton7>
jagga, also Date.parse("11 march 2011") for your second question
<jagga>
k
<canton7>
jagga, thearray.map{ |a| a[/^the update date: (.*)/, 1] } will produce unexpected results if the string doesn't start with "the update date", so best avoid it actually
td123 has joined #ruby
Seisatsu has joined #ruby
<Hanmac>
jagga: i would use match to try to find the dates in the sting ...
blacktulip has joined #ruby
Muon has joined #ruby
<canton7>
Hanmac, that's what my last example was doing
emocakes has joined #ruby
Sailias has joined #ruby
<Muon>
should methods that take a Hash for optional arguments clone or dup it if they wish to modify it?
<Muon>
there's this annoying bit where some options get #delete'd so I can't reuse the options hash
<jagga>
damn
<Hanmac>
Muon i think i your usecase clone and dup works the same
<canton7>
jagga, you're replacing everything which matches /^закрытое \(резюме не видно никому\) · Последнее изменение: (.*)/ with ''. What were you expecting?
<Muon>
that's why I'm trying to fix it
emocakes has joined #ruby
<Muon>
just checking the recommended way to fix it
<canton7>
jagga, try clear = dates.map { |a| a.sub(/^закрытое \(резюме не видно никому\) · Последнее изменение: /, '')
<jagga>
sec
<jagga>
canton7, as result of my actions - I need to receive only dates in my array
eldariof has joined #ruby
<jagga>
damn(
<jagga>
didn't work)
<canton7>
jagga, define "didn't work". What did you try, and what did you get?
<jagga>
our try to delete part of array - failed =)
<canton7>
jagga, is there a space at the beginning of each element?
<jagga>
wait a sec
iocor has joined #ruby
briankbuckley has joined #ruby
<jagga>
nope I have doubchecked that this array has the following structure: ["закрытое (резюме не видно никому) · Последнее изменение: 4 марта 2012, 18:41", "закрытое (резюме не видно никому) · Последнее изменение: 4 марта 2012, 18:41"]
<jagga>
so we need to delete each part of all items stored in array before each date
<canton7>
jagga, hmm, I don't know whether this is a matter of ruby falling over on the character encoding? Try making an array "dates" out of ascii-only characters, just to see if that works
luxurymode has joined #ruby
iocor has joined #ruby
<jagga>
oh...
macan has joined #ruby
chimkan has joined #ruby
_dark has joined #ruby
emocakes has joined #ruby
kW has joined #ruby
<jagga>
canton7 I think you was right)
<jagga>
hot to convert array to UTF-8? from ascii
<jagga>
.encode('UTF-8') ?
Andromeda has joined #ruby
frishi has joined #ruby
caiges_ has joined #ruby
stoffus has joined #ruby
jm has joined #ruby
nvez has joined #ruby
burns180_ has joined #ruby
SiliconDon has joined #ruby
kf8a has joined #ruby
iamjarvo has joined #ruby
ceej has joined #ruby
mikewintermute has joined #ruby
gokul has joined #ruby
chimkan___ has joined #ruby
<jagga>
canton7 ?)
QaDeS has joined #ruby
srp_ has joined #ruby
Squarepy has joined #ruby
Squarepy has joined #ruby
francisfish has joined #ruby
bragh has joined #ruby
Drewch has joined #ruby
bragh has quit [#ruby]
BrianJ has joined #ruby
jamw has joined #ruby
abstrusenick has joined #ruby
mrake has joined #ruby
mattonrails has joined #ruby
LMolr has joined #ruby
al3xnull has joined #ruby
glosoli has joined #ruby
johndbritton has joined #ruby
burns180 has joined #ruby
n1x has joined #ruby
philcrissman has joined #ruby
any-key has joined #ruby
glosoli has joined #ruby
minijupe has joined #ruby
catphish has joined #ruby
Kaell has joined #ruby
<catphish>
what would be the best way to create a hash where the values expire (preferably being automatically removed when memory is needed)
<apeiros_>
alternatively: don't use class variables.
minijupe has joined #ruby
<greenarrow>
<apeiros_>
most ruby coders don't really know how class variables work.
<catphish>
what's not to know :|
nemesit has joined #ruby
<apeiros_>
for starters, that they aren't just shared between a class and its instances
<catphish>
i use them as global variables with a good home
<Hanmac>
class instance variables in 99% better
<apeiros_>
they're shared across the whole inheritance tree
<greenarrow>
<catphish>
Hanmac: instance variables serve a totally different purpose
<catphish>
how can you compare them
blischalk has joined #ruby
<catphish>
apeiros_: that makes sense
<apeiros_>
catphish: classes are objects
<apeiros_>
being objects means they can have instance variables
<catphish>
oh i see
<apeiros_>
that's what Hanmac means by class instance variables. and he's right, in most cases they're the better choice.
<apeiros_>
it's really sad, though, as you need to go through an accessor.
<catphish>
i suspect in my case a global variable might be an easier choice
<apeiros_>
I'd totally love class variables if they were only shared across class + instances
<catphish>
is that what cattr_accessor does?
<apeiros_>
never really looked int cattr
Azure|netbook has joined #ruby
<shevy>
is that a railism
<catphish>
i think it might be
<shevy>
:(
<apeiros_>
yes
<catphish>
i think it creates a class instance variable with accessors
<shevy>
wonder what matz had to say about cattr
<catphish>
never used it though as i didn't understand it fully
<catphish>
i'll use a $ to prevent any confusion
<catphish>
and because they dont need to be initialized
<apeiros_>
ew
deryldoucette has joined #ruby
burns180 has joined #ruby
<apeiros_>
a) global variables = instafail, b) constants are the better globals, c) not knowing whether thing X is initialized = a bad thing - normalize. make sure it *is* initialized
<apeiros_>
just my 3x0.02$
<catphish>
constants better than globals? i find constants are only useful when they're constant, pointing them to a changing object would upset me
<Hanmac>
i use classes as holder for ther Children ... so r = Recipe.new(:name); Recipe[:name] == a is true
crescendo has joined #ruby
<Hanmac>
i mean == r
<shevy>
Hanmac is always doing some crazy shit
albemuth has joined #ruby
<catphish>
global variables seem safe enough, at least you know where you are with them, as long as ruby doesn't throw me any nasty threading problems
<shevy>
they just look ugly
<Hanmac>
shevy iDo because iCan
<shevy>
iGlobal
<shevy>
well
<shevy>
@@foo looks even uglier
<shevy>
so $foo is an improve
<shevy>
but foo is better
<shevy>
perhaps CONSTANTS should have become globals, and real constants be solved differently, and also be really constant
<shevy>
hey robert_
<apeiros_>
catphish: a constant will constantly reference the same object
<apeiros_>
the object itself can be mutated
tomzx has joined #ruby
<apeiros_>
shevy: if you want to protect your object from mutation, use Object#freeze
<catphish>
apeiros_: i know that, i just don't like doing it, i prefer the object to stay the same if its referenced by a constant
<apeiros_>
catphish: you shouldn't write any classes then…
<apeiros_>
or modules…
<catphish>
how so? i don't expect them to change
<apeiros_>
catphish: you think so?
nelson- has joined #ruby
<apeiros_>
try: class Foo; freeze; def bar; end; end
<apeiros_>
as you'll see, you're very much changing the class…
<shevy>
TypeError: can't modify frozen class
<apeiros_>
anyway, it's your code. I have a different opinion, that's all.
<catphish>
apeiros_: works for me, as long as its frozen after you're done defining it
<shevy>
hmm
<shevy>
apeiros_, are you using freeze in one of your projects?
<apeiros_>
catphish: the very act of "defining" it is *changing* it throughout
<catphish>
this was more of a hypothetical discussion
<apeiros_>
shevy: no. I see no point in babysitting developers.
zakwilson_ has joined #ruby
<apeiros_>
shevy: I've used freeze only to detect bugs. accidental changes of objects.
CheeToS has joined #ruby
<catphish>
apeiros_: you are of course correct by in my mind once a constant is done being defined, i don't like it to change at what i'd call runtime
<catphish>
just a personal thing i guess
<catphish>
s/by/but/
adamjleonard has joined #ruby
<catphish>
so to me a constant and a global variable are the same except that one is there to be modified and the other is err what's the word ;)
<catphish>
i guess that's just a matter of personal taste though
sako has joined #ruby
Knodi has joined #ruby
<catphish>
on a totally unrelated note, why doesn't this work? puts text while text = "hello"
<apeiros_>
globals are a failure as you must be in control of the global namespace
<apeiros_>
otherwise you're prone to collisions
Knodi has joined #ruby
<apeiros_>
and your line doesn't work due to the way the parser works
<catphish>
that makes sense, i forget constants have a home and globals done
<catphish>
*don't
Knodi has quit [#ruby]
<catphish>
it works in a block, just not using the reversed syntax
srp_ has joined #ruby
<catphish>
i guess the parser doesn't reverse that line into a normal block before running it
<catphish>
shame, i thought my line was rather elegant
<apeiros_>
yeah, stumbled over that too
<apeiros_>
I don't see either why ruby handles it that way.
<apeiros_>
given the actual execution order, it should work
<catphish>
thats what i thought
<catphish>
works if you reorder it
<catphish>
i have to resort to: while (f = $permissions.first and f[1][:expiry] < Time.now); $permissions.delete(f[0]); end
macmartine has joined #ruby
<apeiros_>
I don't like that one. otoh, the parsers oddities enable things like: foo = proc { foo[] }
<apeiros_>
I better don't comment :-p
<akem>
hey, how can i break or return early in a {} block, i tried "return" but i got "unexpected return error" and "break" i got "break from proc-closure
<akem>
" ?
undersc0re has joined #ruby
<akem>
this is inside a QT widget callback button.connect() {}, might be a bit special...
mdw has joined #ruby
iocor has joined #ruby
dbgster has joined #ruby
<Hanmac>
akem maybe you want "next"?
TaTonka has joined #ruby
<akem>
Hanmac, yay awesome, that 's what i'm looking for, thanks!
Azure has joined #ruby
<akem>
Hanmac, are you the guy working on Ogre Ruby binding?
<Hanmac>
yep ... but currently i work on new wxRuby
neohunter has joined #ruby
burns180_ has joined #ruby
<akem>
Hanmac, ok, just wondering how it is comming, i guess it's a bit on standby then.
wallerdev has joined #ruby
<Hanmac>
it is not very productive if you are the only guy for > 5 projects ;P
flingbob has joined #ruby
cuit has joined #ruby
yeggeps has joined #ruby
adeponte has joined #ruby
flingbob has quit [#ruby]
etank has joined #ruby
k_89 has joined #ruby
<k_89>
so .. i have had ruby lying around on system for a long time, deided to learn it .. everything works fine, but i get this error whenever i try to open irb, or use gem Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/activemodel-3.2.0.rc1.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0xb9082dc> 3.2.0.rc1"]
Redjack1964 has joined #ruby
<k_89>
sorry, i should have separated the error, here it is
<k_89>
:
<k_89>
Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/activemodel-3.2.0.rc1.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0xb9082dc> 3.2.0.rc1"]
Pheen has joined #ruby
<k_89>
tried googling the error, didn't find anything, anyone got any idea
<akem>
hehe right, gotta focus on a single one untill completition, then moving along!
<k_89>
akem, you talking to me?
<akem>
that's what i try to do...
<akem>
k_89, to Hanmac
<k_89>
k
timonv has joined #ruby
<akem>
k_89, i have no idea about your issue sorry...maybe version mismatch?
<k_89>
yeah i think so too ... i installed 1.9.3 before starting a tut on ruby
<k_89>
hmm i'll try removing all gems
havenn has joined #ruby
mdw has joined #ruby
omahajoe has joined #ruby
yoklov_ has joined #ruby
gener1c has joined #ruby
io_syl has joined #ruby
drbawb has joined #ruby
sungji has joined #ruby
drbawb has joined #ruby
LLama has joined #ruby
axisys has joined #ruby
<Pheen>
Hi! I'm trying to pass multiple files through a file upload form to local storage, I have it working with one file perfectly, but I can't figure out how to access more than one file at a time through params[:fieldID]. <%= params[:mp3file].class %> returns ActionDispatch::Http::UploadedFile. There doesn't seem to be very many methods available for ActionDispatch::Http::UploadedFile, the main
<Pheen>
one is .read to which works great for one file, but I need to do something like <%= params[:mp3file].each do |f|; f.read; end %>, but .each is not available for ActionDispatch::Http::UploadedFile, any help would be greatly appreciated :D
stringoO has joined #ruby
burns180 has joined #ruby
sgmac has joined #ruby
adambeynon has joined #ruby
rippa has joined #ruby
jacktrick has joined #ruby
dr_bob has joined #ruby
Foxandxss has joined #ruby
kenperkins has joined #ruby
spoike_ has joined #ruby
machine1 has joined #ruby
tvo has quit ["Leaving"]
<spoike_>
does anyone else have trouble installing gems? middleman doesn't seem to install properly
<spoike_>
at least I can't seem to run the app. it is in gem list
sohocoke has joined #ruby
zakwilson has joined #ruby
McGo has joined #ruby
srp_ has joined #ruby
tayy has joined #ruby
voodoofish has joined #ruby
Xerife has joined #ruby
friskd has joined #ruby
mxweas_ has joined #ruby
jgrevich has joined #ruby
virunga has joined #ruby
bluOxigen has joined #ruby
chimkan has joined #ruby
francisfish has joined #ruby
chimkan_ has joined #ruby
havenn has joined #ruby
timonv has joined #ruby
Faris has joined #ruby
Faris has quit [#ruby]
Redjack1964_ has joined #ruby
danishman has joined #ruby
thecreators has joined #ruby
havenn_ has joined #ruby
sgmac has joined #ruby
Foxandxss has joined #ruby
Drewch has joined #ruby
burns180_ has joined #ruby
ribayr has joined #ruby
tayy_ has joined #ruby
csprite has joined #ruby
n3m has joined #ruby
<shevy>
spoike_ I have no problems installing gems
<shevy>
but some gems dont run. bundler for one never worked for me so far
Tuplario has joined #ruby
mdw has joined #ruby
<Tuplario>
hi, could anyone kindly point me to an example of how to traverse an array of arrays recursively? thanks
looopy has joined #ruby
gmas has joined #ruby
td123 has joined #ruby
mohits has joined #ruby
<mohits>
Hi, can anyone suggest any pointers to write CLI tools in ruby, such as pyCLI for python
<shevy>
mohits I dont know what pyCLI does. can you say what requirements you need? the arguments given to a script are available in ARGV. to check if the program is run standalone, do: if __FILE__ == $PROGRAM_NAME
<Tuplario>
shevy: I need to group the inner arrays in pairs and call the same function on each of them
<Tuplario>
I don't really see how to do it with each
<shevy>
yeah, for that use .map
albemuth has joined #ruby
<Tuplario>
nice, thanks shevy
<mohits>
shevy: requirement is simple , intended to be a *nix cli tool which is would query an webservice and return results
<shevy>
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
<shevy>
this equals to:
<shevy>
your_script.rb --verbose
<shevy>
your_script.rb --no-verbose
<shevy>
I think the last entry is what is displayed on the commandline for this option
KL-7 has joined #ruby
<audrius>
hallo! how to print two items with p without line break?
<shevy>
what
<mohits>
thanks shevy
<shevy>
you use it like ... p a, b ?
<audrius>
yes
<audrius>
but it prints it in separate lines
<shevy>
hmm
<shevy>
a = "abc\n"; b = "def\n"; p a.chomp + b # => "abcdef\n"
<shevy>
I think p appends a newline
glosoli has joined #ruby
<apeiros_>
no, p doesn't append a newline. p inspects objects.
<audrius>
cannot comp arrays :(
<audrius>
cannot chomp arrays :(
shruggar has joined #ruby
<shevy>
audrius how do your arrays look?
<audrius>
["Armando","P"]
<shevy>
well
<shevy>
you have two arrays there
<audrius>
i need it printed in one line along with aditional text
<shevy>
use +
mikepack has joined #ruby
<shevy>
p ["Armando","P"]+["Armando","P"] # => ["Armando", "P", "Armando", "P"]
<shevy>
or you .join your arrays
<Drewch>
Are there static classes in Ruby? Like can I just use a class and it's methods without going myvar = MyClass.new
kidoz has joined #ruby
<shevy>
Drewch yeah... class Foo; def self.bla
<audrius>
p ["Armando","P"] , "then line"
<shevy>
some_return_value == Foo.bla
<shevy>
oops
<shevy>
some_return_value = Foo.bla
<apeiros_>
Drewch: technically there are no static methods, practically there's something that looks similar
Redjack1964 has joined #ruby
<apeiros_>
(shevy already showed that)
<shevy>
audrius that looks very odd
<Drewch>
cool :) Thanks shevy apeiros_
<shevy>
you want to output an array but in string form or?
<Drewch>
What if it is a variable
<Drewch>
like I have attr_accessor :foo
<shevy>
at this rate I'd think it is easier if you use pastie.org to show what exactly you need as output, and what you have as input audrius ;)
<audrius>
i need print that array with all those brackets + string in same line
<Drewch>
I want to do Foo.foo = 5
<shevy>
yeah you need your array in string form. why didn't you say that earlier :P
flingbob has joined #ruby
<Drewch>
Is it @@foo?
<Hanmac>
no
<apeiros_>
Drewch: attr_accessor :foo just defines two methods
<shevy>
audrius '["'+%w( cat dog pig ).join('","')+'"]' # => "["cat","dog","pig"]"
<Hanmac>
Drewch: class << Foo; attr_accessor :foo; end
<Hanmac>
important is the <<
<apeiros_>
foo and foo=, which are equivalent to (if you'd write them manually): def foo; return @foo; end; def foo=(value); @foo = value; return @foo; end
mattonrails has joined #ruby
<yxhuvud>
apeiros_: well, equivalent except in performance
<shevy>
Drewch I think the << is the same in a way but I usually use def self.bla
<shevy>
and isn't it something like class << self usually?
<shevy>
you are torturing ruby man ;)
<Hanmac>
Drewch this is currect ... i prefer use class Foo; class << self; classmethods; end; instancemethods; end;
seanstickle has joined #ruby
<Hanmac>
you can also use def Foo.foo outside of the class but i dont prefer that
bounce has joined #ruby
<audrius>
shevy, i don't have to use p. any output allowed . how to convert to string without losing brakes of array.
blischalk has joined #ruby
tayy has joined #ruby
<mikewintermute>
grr - struggling with dynamic accessors: anyone know how I avoid syntax errors here: http://pastebin.com/nxNpNXT7
<shevy>
audrius '["'+%w( cat dog pig ).join('","')+'"]' # => "["cat","dog","pig"]"
<shevy>
well write a method that does this
<shevy>
x = '["'+["Armando","P"].join('","')+'","'+"ddd"+'"]'
<shevy>
x # => "["Armando","P","ddd"]"
undersc0re has joined #ruby
<Drewch>
shevy - so is there anyway to make the two functions that attr_accessor creates implicitly, class methods by default, instead of instance methods
<Hanmac>
mikewintermute, because they are totaly diffrent ... you need define_method
<Blaster>
We're trying to remove all non-letter characters from the string
<matti>
Ah.
<matti>
LOL
<shevy>
ah right again the REVERSE
<shevy>
:\
<matti>
Blaster: You mean non-printable?
<Blaster>
I mean if you give "A B C ! %," you'll only be left with "ABC"
<apeiros_>
remove all non-letter characters: str.delete('^a-zA-Z')
<matti>
shevy: Its like with customers -- they want A but think X>
gmas has joined #ruby
<shevy>
and describe B
<shevy>
:)
<apeiros_>
delete! if you want in-place
<apeiros_>
@ Blaster
<shevy>
@ Fire!!!
<Blaster>
yeah, that worked. thanks
baroquebobcat has joined #ruby
glosoli has joined #ruby
<apeiros_>
@ matti, tr with '' as second argument means you want delete ;-)
<Blaster>
I don't really get what the difference between string.gsub! vs string.gsub does
<apeiros_>
Blaster: the former mutates the receiver
johndbritton has joined #ruby
<apeiros_>
the latter returns a new string with the substitution applied
<apeiros_>
beware, gsub! will return nil if nothing changed
<Blaster>
ah
<apeiros_>
most people are unaware of that and happily chain ! methods
<Blaster>
that is the problem I ran into when I tried a non-letter replacement example from Google
<apeiros_>
reading the documentation is a very good idea…
<apeiros_>
especially when something happens that you didn't expect.
amerine has joined #ruby
<apeiros_>
I'd even recommend reading the docs of all methods in ruby-core. and if only to have it seen at least once.
berserkr has joined #ruby
<Blaster>
ok
<Blaster>
thanks for the tip
hoipolloi has joined #ruby
<hoipolloi>
where can I find ruby's test suite, specifically the tests for the Date package?
fr0gprince_mac has joined #ruby
<apeiros_>
hoipolloi: in the directory named 'test'?
philcrissman has joined #ruby
cpruitt has joined #ruby
g0bl1n has joined #ruby
g0bl1n has joined #ruby
<shevy>
hmm when I have a class ... hero.rb ... which has attributes like strength... xp ... hitpoints... right now I save this into a yaml file, and on startup, load this yaml file and set the values anew (enabled load and save), but is there another way to store data that can change?
<hoipolloi>
apeiros_: that's what I would have expected however I've installed with brew and there doesn't seem to be a test directory
<hoipolloi>
apeiros_: other than the one in lib that has unit.rb in ;)
<apeiros_>
hoipolloi: I have no idea where brew puts the sources
visof has joined #ruby
visof has joined #ruby
<apeiros_>
hoipolloi: errr, nonono, you get that wrong
<apeiros_>
it's in the *sources*, not in the *installed product*
<hoipolloi>
ahh, I see, I just assumed it got installed with it, cool, I'll download the sources for the same version and look there
<hoipolloi>
thanks apeiros_
Beoran has joined #ruby
burns180_ has joined #ruby
virunga has joined #ruby
<Blaster>
is there an easy way to access the first argument given when a script is run from the CLI?
<hoipolloi>
Blaster: ARGV[0]
<apeiros_>
shevy: marshal, databases, json…
KarlFreeman has joined #ruby
<apeiros_>
there's billions of ways to store data…
<hoipolloi>
shevy: how would you like it to happen differently? Is there something in the way that it's happening at the moment that you're not happy with?
<shevy>
hoipolloi yeah, it seems like manual work for me
SunNoise has joined #ruby
bnhymn has joined #ruby
<shevy>
for instance, i have different instance variables right now
<shevy>
and when loading the yaml file, I have to restore the state
<apeiros_>
you can do it without manual work
<apeiros_>
YAML.load(your_hero.to_yaml)
<apeiros_>
yaml has no problems with custom classes
<shevy>
hmm ok
jcjh has joined #ruby
odinswand has joined #ruby
ephemerian has joined #ruby
stephenjudkins has joined #ruby
TaTonka has joined #ruby
timonv has joined #ruby
aim-On has joined #ruby
timonv_ has joined #ruby
Vert has joined #ruby
philcrissman has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
ekaleidox has joined #ruby
davidpk has joined #ruby
conor_ireland has joined #ruby
TaTonka has joined #ruby
burns180 has joined #ruby
jacktrik has joined #ruby
ekaleidox has joined #ruby
mdw has joined #ruby
k_89 has quit ["Leaving"]
al3xnull has joined #ruby
McGo2 has joined #ruby
SunNoise has quit [#ruby]
dbgster has joined #ruby
<CannedCorn>
hey guys, how would you go about setting the size of a terminal in ruby
havenn has joined #ruby
<CannedCorn>
i'm trying winsize gem but it doesn't seem to work
mmercer has joined #ruby
burns180_ has joined #ruby
kW has joined #ruby
moshee has joined #ruby
jbw_ has joined #ruby
BrianJ has joined #ruby
<RubyPanther>
CannedCorn: usually I use something like curses and I don't set the size I only ask the size... if I really was setting the size I would execute the terminal program with command line options: xterm -geometry 1000x2000+0+0
<CannedCorn>
right but there should be a way to do it with ioctl
<RubyPanther>
if it is *nix you can use the x11 libs fairly easily
robertjpayne has joined #ruby
vaneda has joined #ruby
<RubyPanther>
if you use sawfish window manager you can talk to the window manager in LISP to do it. (easy to generate)
Keva161 has joined #ruby
<Mon_Ouie>
require 'io/console'; $stdout.winsize
<Mon_Ouie>
Assuming you want the size in characters, and don't care about the window size in pixels
<Mon_Ouie>
(Especially considering the user of your app can be using a terminal multiplexer or whatever)
mrake has joined #ruby
trivol has joined #ruby
fr0gprince_ has joined #ruby
<CannedCorn>
Mon_Ouie i want to set instead of read though
kenperkins has joined #ruby
<CannedCorn>
it lets me set the winsize there but the terminal never resizes
Squarism has joined #ruby
<CannedCorn>
Mon_Ouie any ideas?
Seisatsu has joined #ruby
seo_ has joined #ruby
Keva161 has joined #ruby
emptyflask has joined #ruby
flingbob has joined #ruby
burns180 has joined #ruby
baroquebobcat has joined #ruby
glosoli has joined #ruby
<CannedCorn>
where can i learn more about console/io
emocakes has joined #ruby
shruggar has joined #ruby
mdw has joined #ruby
conor_ireland has joined #ruby
<CannedCorn>
Mon_Ouie i think i need to send sigwinch
<CannedCorn>
so that it is aware that it was sent
<CannedCorn>
or changed, rather
timonv has joined #ruby
drbawb has joined #ruby
io_syl has joined #ruby
fbernier has joined #ruby
kah has joined #ruby
McGo has joined #ruby
burns180_ has joined #ruby
Gesh has joined #ruby
seanstickle has joined #ruby
pac1 has joined #ruby
Andromeda has joined #ruby
<pen>
hey
<Gesh>
hi. could someone explain me why this regexp works: /\d*(?:\.|,|_)\d*/.match("wr4.578ge") but this one doesn't /\d*(?:\.|,|_)?\d*/.match("wr4.578ge"). the difference is only in '? ' after round brackets
<pen>
are there any ruby libraries available for cipher?
<pen>
such as aes256/ctr
drbawb has joined #ruby
wmoxam_ has joined #ruby
ephemerian has joined #ruby
stephenjudkins has joined #ruby
<CannedCorn>
guys?
<seanstickle>
What up dog!?
flingbob has joined #ruby
tatsuya_o has joined #ruby
<Blaster>
can you use string.delete to delete everything but alpha characters and spaces? I tried string.delete('^a-z\s')
wmoxam has joined #ruby
machine1 has joined #ruby
liluo has joined #ruby
fr0gprince_ has joined #ruby
dankest has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
burns180 has joined #ruby
indstry has joined #ruby
indstry has joined #ruby
indstry has quit [#ruby]
mxweas_ has joined #ruby
Xerife has joined #ruby
dankest has quit [#ruby]
S2kx has joined #ruby
<CannedCorn>
how would you reset terminal size programatically
artOfWar has joined #ruby
<CannedCorn>
i realize you can use io/console to set $stdout.winsize
<CannedCorn>
which definitely adjusts the window size parameters
drbawb has joined #ruby
Jamie has joined #ruby
<CannedCorn>
but then i think you need to send a sigwinch singal
<CannedCorn>
so that your terminal figures out that the dimensions have changed
shadoi has joined #ruby
michaelh has joined #ruby
Jamie has quit [#ruby]
michaelh has quit [#ruby]
tommyvyo has joined #ruby
wmoxam has joined #ruby
<pielgrzym>
would someone be so kind and explain me why this => http://pastebin.com/r6NweZ1E doesn't work? And how do I need to correct it to work?
<Hanmac>
pielgrzym: when you use yield, you need a block
wmoxam has joined #ruby
<pielgrzym>
is it because function fz expects a block as a param?
<pielgrzym>
Hanmac: as a param, right?
<Hanmac>
yes
<pen>
how do I encrypt using AES256/CTR in ruby?
<pielgrzym>
Hanmac: thanks!
<Hanmac>
i hope you does close the File objects later
<pielgrzym>
Hanmac: it's only a irb playground :) although File.open 'xxx', 'r' do |file| ... end would close the file, right?
<Hanmac>
yeah
wmoxam_ has joined #ruby
waxjar has joined #ruby
<davidpk>
pen: the OpenSSL library. hold on, will gist an example
<pen>
davidpk: you sure? CTR mode?
<davidpk>
pen: err. probably not, actually
<pen>
I wonder why OpenSSL does not support CTR
<pen>
and only CTR
<pen>
for AES
<pen>
and I wonder if there are other cipher libraries for ruby that supports AES CTR
<pielgrzym>
Hanmac: http://pastebin.com/nRLDEXs5 - I just fell in love with ruby :)))) it's by default much more functional than python :) amazing :)
<pielgrzym>
Hanmac: will it close all files automatically in this scenario?
<davidpk>
pielgrzym: no, but there's a trivial fix. hold on
<A124>
Both python and ruby are great. Depends on purpose.
wmoxam has joined #ruby
flingbob has joined #ruby
<pielgrzym>
davidpk: thanks!
<atmosx>
no python is great
<atmosx>
ruby superb
<pielgrzym>
A124: agree :) though I love the blocks concept :) this (at first glance at least) makes programming ultra-fluid :)
<A124>
pielgrzym: Agreed.
blueadept has joined #ruby
<A124>
atmosx: Agreed also. But for system utilities, python is more suited.
<atmosx>
in what respect A124 ?
Sigma00 has joined #ruby
<atmosx>
give me a specific example
burns180 has joined #ruby
randym_ has joined #ruby
emmanuelux has joined #ruby
nfluxx has joined #ruby
flingbob has joined #ruby
snearch has joined #ruby
<A124>
Libraries, current support, plugins, interfaces, but that is pretty dependend and not tied to language.
<Hanmac>
IMO everything you can write in pyton can be writen in ruby
<bounce>
both are turing complete, no
wmoxam has joined #ruby
adamjleonard has joined #ruby
<A124>
Hanmac: If you haven't notices, I have just said that.
<A124>
*noticed
<Hanmac>
but ruby looks more nice :P
<pielgrzym>
atmosx, A124: as a bystander (that is sometimes using various ruby utils) python seems usually to load (eg. start working) faster - just an impression. have to check capistrano (python fabric seems ok, apart from some bad programming practices)
kW has joined #ruby
<banisterfiend>
pielgrzym: try with ruby 1.9.3 :)
<A124>
Hanmac: Yes, it does. I'm not backing up python. I'm objective
<seanstickle>
Also, try Perl
<pielgrzym>
banisterfiend: sure will :) is there something like virtualenv in python for ruby (that is a separate ruby install per app, with it's own gems etc)?
<seanstickle>
Or APL
<pielgrzym>
seanstickle: perl scares me ;)
<A124>
pielgrzym: Yes, you should try Ruby 1.9.3, if you have older. There is a huge difference and no problem if you are writing new scripts.
<seanstickle>
pielgrzym: rvm is the recommended multi-ruby installation technique
<pielgrzym>
seanstickle: thanks!
<A124>
If not, check changes. Like "a"[0] = Integer, and not char
<A124>
seanstickle: Agreed. +1
<bounce>
heh, 'objective'. for "system utilities", I'd pick, oh, anything that doesn't require the sysadmin to install and maintain another framework
fr0gprince_ has joined #ruby
<bounce>
meaning C, C++ maybe, shell (no bash, just bourne shell), awk, that sort of thing
<A124>
bounce: Yes, that's why python. In most distributions a lot of utilities use it anyway.
<bounce>
beyond that it's pick whatever you like, whatever fits the task best.
<bounce>
no, python does not count. not even now that Xorg b0rked up their tree and reversed the dependencies
<pielgrzym>
bounce: c/c++ for sysutils? risky thing :) I mean as an automating/scripting. For some cmd-line utils, sure - if you have time that is :)
stephenjudkins has joined #ruby
<bounce>
what is a script but a collection of CLI utils tied together?
wmoxam has joined #ruby
<pielgrzym>
bounce: right, but you have to agree that a bug in c/c++ util may lead to a disasterous danger - while ruby/python/etc but usually leads to some sort of trouble (I meant security disasters with c/c++)
igotnolegs has joined #ruby
<bounce>
er. if you mean scripting languages have far more safety nets, yes, that's true. it's not exactly difficult to write safe code in C or C++, but you do have to know what you're doing.
* Hanmac
is the king of segmentation faults :P
<pielgrzym>
bounce: yup - and one need to know much better low level stuff to use gdb (etc.) to debug properly, since you sometimes have to disasemble stuff to fish a bug
<bounce>
had a foss consulting job for a while; just about the first thing I had to do was dig through several levels of damage to find some stupid segfault. fun fun fun.
<pielgrzym>
:)
<Hanmac>
i managed to write code that is compiled in both MSVC and g++ ...but then crash only on msvc :P
<pielgrzym>
Hanmac: submit to metasploit ;)
jbhewitt has joined #ruby
<pielgrzym>
gotta go :) thanks for help :)
<bounce>
but then again, really good sysadmins are apt to be even better at debugging than random programmers tend to be
<bounce>
they have to find faults in /other/ people's code, deal with broken hardware, the wildest user inputs, and so on, and so forth