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
chimkan_ has joined #ruby
Imapickle has joined #ruby
<Imapickle> could someone tell me how to make these if statements look nicer http://pastebin.com/z7t9kvZm
<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?
wmoxam has joined #ruby
<gener1c> i tried this solution
<gener1c> but alas, it didnt work...
namidark_ has quit ["Linkinus - http://linkinus.com"]
<gener1c> sorry for linebreaking on you...
wmoxam has joined #ruby
CacheMoney has joined #ruby
<gener1c> brb
neohunter has joined #ruby
burns180 has joined #ruby
centr0 has quit [#ruby]
v4n_ has joined #ruby
<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 ?
<fowl> no
<fowl> .. is a range
<fowl> [0,1,2,3,4,5,6,7,8,9,10][0..3] #=> [0,1,2,3]
<sudhi> fowl: ohhk, but I can still use it inside the code, and not write a for loop for something right ?
<fowl> start at 0, include 3
<sudhi> fowl: ohh, thats sweet !
<fowl> [0,1,2,3,4,5,6,7,8,9,10][0...3] #=> [0,1,2]
<fowl> thats another kind of range
sparta300 has joined #ruby
<sparta300> Genuine method to crack any passwords free!!!: http://leakyneuron.blogspot.in/
kW has joined #ruby
sparta300 has quit [#ruby]
<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) ?
burns180_ has joined #ruby
nfluxx has joined #ruby
<sudhi> fowl: how does this look ? http://pastie.org/3515912
rexbutler has joined #ruby
<fowl> looks ok except for the explicit returns
Squarism has joined #ruby
rushed has joined #ruby
<sudhi> fowl: ruby doesn't like explicit returns ? (BTW I missed the list.length in it, updating the code)
<fowl> you dont need them in ruby
<fowl> unless you need them
BrianJ has joined #ruby
<sudhi> fowl: ohhk, how about now http://pastie.org/3515912 (updated)
timonv has joined #ruby
<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
manojhans has joined #ruby
burns180 has joined #ruby
<banisterfiend> sudhi: "hello".chars.sort
<sudhi> banisterfiend: esotericalgo : thanks, thats simple !
adeponte has joined #ruby
<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?
Morkel has quit [#ruby]
<seanstickle> dbruns: or various other places
<sudhi> can I define a method inside an inherited class like : def foo { super unless @bar == 'baz' ; false }
<sudhi> basically, I want to call up super method with all args/stuff , if the condition is *NOT* true ; if its true ; I will return false
<sudhi> I could do basic if <cond> {expression} else {expression} ; but I was wondering if it can be done via unless
emmanuelux has joined #ruby
azbarcea__ has joined #ruby
burns180 has joined #ruby
i8igmac has joined #ruby
dotnull has joined #ruby
sizz_ has joined #ruby
sdouglas has joined #ruby
<rippa> sudhi: def foo {return super unless @bar == 'baz' ; false }
<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
<mohsin^> i am learning to let go the previous learning and starting fresh .. and I am enjoying it !
<ziyadb> canton7: ah, nice.
<mohsin^> thanks a bunch Hanmac
* Hanmac wispers: ruby gems does make more fun when you write them in C++
johndbritton has joined #ruby
<banisterfiend> thx
snakeleg has joined #ruby
<rippa> canton7: though #delete would work better here
<canton7> rippa, that's very true
kirun has joined #ruby
telling has joined #ruby
telling has joined #ruby
sbanwart has joined #ruby
sungji has joined #ruby
mikespokefire has joined #ruby
davidpk has joined #ruby
porco has joined #ruby
jesly has joined #ruby
tayy has joined #ruby
luxurymode has joined #ruby
ph^ has joined #ruby
tatsuya_o has joined #ruby
sohocoke has joined #ruby
burns180 has joined #ruby
ephemerian has joined #ruby
Vendethiel has joined #ruby
<conor_ireland> does anyone have any good resources on learning FP in ruby?
<conor_ireland> ...using ruby
tatsuya_o has joined #ruby
<msch> anyone know how far off ruby 2.0 is? and why is rubysoc.org still in the topic? isn't that 2 years old by now?
dbgster_ has joined #ruby
<randym_> msch: scheduled for Feb/March of next year iirc
<msch> randym_: thanks. let's hope it's faster than 1.9
<randym_> lol it will be
<msch> randym_: seriously? i thought they didn't change the VM for 2.0?
<randym_> but If you think 1.9 is slow - go code on 1.8!
<msch> randym_: well yeah i'm happy that almost everyone has migrated to 1.9 by now
wmoxam_ has joined #ruby
<Hanmac> currently i have no idea what BIG changes they have planed for 2.0 ... i mean changes which are for the normal users ...
<randym_> the thing that sticks out the most to me is possible gemification of stdlib
<randym_> but you should talk to a MRI committer, I am sure they have far more in store for us!
<Hanmac> shevy ready for a BIG suprise? :P
<Hanmac> http://bugs.ruby-lang.org/issues/6111 << it is tagged with "2.0" so maybe someone think it is usefull
tayy_ has joined #ruby
<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
<jagga> trying to check in http://rubular.com/ created regex
<jagga> with success!
<jagga> but puts dates didnt work
<jagga> I will post pastebin
<Muon> Hanmac: okay
<Muon> but
pielgrzym has joined #ruby
<Muon> Hanmac: (should (methods that (take a Hash for optional arguments) (clone or dup it) if (they wish to modify it?))
<pielgrzym> hi, is there a way to make irb display docs about given method?
<Muon> i.e. I'm not asking whether to use *clone* OR *dup*, I'm asking whether I should clone or dup it
<Hanmac> they should dup it ...
<jagga> Canton7, please check http://pastebin.com/Pa5GQ4ex
<seanstickle> To whit: https://github.com/dadooda/ori
<seanstickle> RI within IRB
<Hanmac> but removing options is bad
<pielgrzym> seanstickle: thanks you
<jagga> I have post my source of rb file
nachtwandler has joined #ruby
<Muon> Hanmac: I know it's bad
<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?
fr0gprince_mac has joined #ruby
<jagga> k
iocor has joined #ruby
kexibq has quit [#ruby]
burns180 has joined #ruby
<jagga> canton7, link http://pastebin.com/2DgqfsMW
<jagga> didnt work
<canton7> jagga, what does it output?
<jagga> the same result
<jagga> as array "dates"
<jagga> puts dates == puts clear
gogiel has joined #ruby
<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
jamw has joined #ruby
<jagga> maybe we should use regex?
<jagga> please check it
<canton7> jagga, we are using regex
<jagga> but it doesn't work)
yoklov has joined #ruby
<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)
<Kaell> Ruby newb here... any help with basic method definition and usage? http://pastebin.com/k0iZejyt
<catphish> Kaell: your method is called count_words?
<catphish> you called count_words
<Kaell> oh, doh
<Kaell> thanks
mattonrails has joined #ruby
briankbuckley has joined #ruby
TaTonka has joined #ruby
Nathandim has joined #ruby
havenn has joined #ruby
<catphish> Kaell: words.split(\W+)
<catphish> is a better split, that splits on any non-word characters
<catphish> your version will actually match part of each word
<Kaell> yeah... probably... i changed it to "\b\W*" right now...
<mikewintermute> re this message: "warning: modifying $= is deprecated" - are there any alternatives to modifying "$=" for case-insensitive matching?
<Kaell> yeah, it didnt work ;P
fbernier has joined #ruby
<catphish> sorry i meant .split(/\W+/)
<catphish> i forgot the //
philcrissman has joined #ruby
<apeiros_> mikewintermute: with regexen? use the i flag
<mikewintermute> apeiros_: it was for statements using include?
<apeiros_> mikewintermute: you mean == then?
srp_ has joined #ruby
waxjar has joined #ruby
lolsuper_ has joined #ruby
lolsuper_ has joined #ruby
<mikewintermute> this is the line of code: h[wordkey] += [word] unless h.values.flatten.include?word
<apeiros_> seems like. at least with 1.8 & `$= = true`, "hello" == "HELLO" # => true
<catphish> there is a way to modify how comparisons are done
<catphish> on a class
Talvino has joined #ruby
<catphish> not sure which method include? calls though
<apeiros_> mikewintermute: well, you could do class CaseInsensitiveString; def ==(other); downcase == other.downcase; end; end
<apeiros_> f.ex.
<apeiros_> but I'd probably just change your code
<catphish> looks like it uses ==, so apeiros_ is right :)
Keva161 has joined #ruby
<mikewintermute> apeiros_: hmm - ok, thanks.
<apeiros_> doesn't look like the best code anyway…
<apeiros_> it looks to me like you should make the h.values.flatten a lookup table itself too
<catphish> nothing wrong with making caseinsensitivestring, as long as you're not changing string itself
<apeiros_> catphish: it feels dirty :)
ericklan has joined #ruby
<catphish> i was upset to discover that you can inherit from NilClass, but you can't make an instance
medik has joined #ruby
<apeiros_> hehe
<catphish> i'm trying to think of the best way to make a key-value store with expiry
<mikewintermute> apeiros_: yeah - lookup table is a good idea
<apeiros_> catphish: hash + linked list
<Hanmac> like: true.untrust :P
burns180_ has joined #ruby
<apeiros_> catphish: at least if all expires have the same duration
ukwiz has joined #ruby
Targen has joined #ruby
<apeiros_> actually with ordered hashes of 1.9, all you need is a hash :)
<catphish> how so?
trivol has joined #ruby
<apeiros_> they're ordered, push new key-value pairs at the end, check first key-value pair for being expired, if so, shift it off
<apeiros_> as said, only works if all have the same expiration duration
<catphish> apeiros_: not a bad idea
<catphish> can just loop off the top deleting
Vert has joined #ruby
_dark has joined #ruby
<catphish> as long as checking the expiry of the first item in the list on every access isn't too slow
<catphish> but i wouldn't have thought it will be
startling has joined #ruby
<catphish> in 1.9 is Hash already ordered?
<catphish> so i just need to do hash.first[:expiry] on any hash?
<catphish> it *appears* to work
<catphish> thanks :)
yoklov has joined #ruby
Vert has joined #ruby
flak has joined #ruby
rippa has joined #ruby
<catphish> @@cache.delete(f[0]) while f = @@cache.first and f[:expiry] < Time.now
startling has quit [#ruby]
CannedCorn has joined #ruby
<CannedCorn> hey guys, does httparty support ssl? like connecting to https:// not sure if it just *does the right thing if you do*
neohunter has joined #ruby
TaTonka_ has joined #ruby
drbawb has joined #ruby
drbawb has joined #ruby
TaTonka_ has joined #ruby
<apeiros_> catphish: yes, in 1.9, hashes are ordered. it retains insertion order
<catphish> cool - this seems to be working
drbawb has quit [#ruby]
<catphish> with the expiry code i pasted running before each get
drbawb has joined #ruby
kah has joined #ruby
rickmasta has joined #ruby
<catphish> uninitialized class variable :(
<catphish> what a sucky error
Guest__ has joined #ruby
<catphish> how do i check if a class variable is set?
gokulnath has joined #ruby
hukl has joined #ruby
<catphish> self.class.class_variable_defined?('@@test')
<apeiros_> just ensure it's always set
<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> Tuplario just use .each
<shevy> [ [1,2,3], [4,5,6] ].each {|x| print x.join(',')+"\n"}
<shevy> 1,2,3
<shevy> 4,5,6
mxweas_ has joined #ruby
<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> a = [ [1,2,3], [4,5,6] ].each {|x| x.map! {|y| y=y+5} }
<shevy> a # => [[6, 7, 8], [9, 10, 11]]
* mohits is new to ruby universe
etehtsea has joined #ruby
<shevy> yeah mohits well
tommyvyo has joined #ruby
audrius has joined #ruby
burns180 has joined #ruby
<shevy> I suppose it is basically the same as in python, you surely have ARGV in python too
<shevy> then for commandline option parsing, you could use ...
<shevy> look at "minimal example" on that page
<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
libertyprime has joined #ruby
<apeiros_> yxhuvud: correct. functionally equivalent.
tommyvyo has joined #ruby
<shevy> Drewch Foo.foo= is a method call. def foo=(your_input_here)
libertyp1ime has joined #ruby
<Hanmac> shevy: you mean def self.foo=(val)
<Drewch> Hanmac shevy, so class << Foo automatically makes all methods within become self.(eachMethod)
<shevy> audrius look at the code above here
<Drewch> without me having to write self
<Drewch> is that correct?
scalebyte has joined #ruby
<shevy> audrius though I dont know why you need to use p
sgmac1 has joined #ruby
<shevy> just convert the stuff you want to output into a string
<scalebyte> need a cancel button for my simple form that will redirect to previous page
<scalebyte> = commit_button(f, {:class => "btn btn-primary btn-large", :value => _("simple_form.buttons.save")})
sgmac1 has quit [#ruby]
<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
<shevy> array_converter(*your_messy_input_comes_in_here)
<shevy> Drewch, I dont think in default ruby. there is cattr or something in rails
<audrius> i'll try, thanks!
<shevy> the attr* only work for instance variables
berserkr has joined #ruby
<shevy> attr_accessor :foo is the same as def foo; return @foo; def foo=(i); @foo = i
<Drewch> shevy right, thanks
<shevy> dont know if you can turn these into class methods
<Drewch> shevy was kind of hoping there was something like cattr_accessor in ruby, as you said
<shevy> :)
<Hanmac> if you want class methods, do this in class << self
banisterfiend has joined #ruby
libertyprime has joined #ruby
<mikewintermute> Henmac: sorry - being a bit dense here. do you mean like this? http://pastebin.com/m426sEx2
libertyp1ime has joined #ruby
cobragoat has joined #ruby
burns180_ has joined #ruby
thecreators has joined #ruby
_adeponte has joined #ruby
adeponte has joined #ruby
<Hanmac> nope
krisfremen has joined #ruby
mystique has joined #ruby
Muon has quit ["PLANE SHIFT!"]
<Drewch> Why does #{varname} print a new line everytime
<Drewch> in puts
Squarism has joined #ruby
<mystique> I just installed ruby using rvm install 1.9.3 but when I type ruby -v, I get 1.8.7. Can anyone help me out?
pen has joined #ruby
sungji has joined #ruby
<Hanmac> mystique: my first thought is that rvm is not configured right
<catphish> Drewch: that's what puts does
<Hanmac> if you want without newline you need print
<catphish> Drewch: if you want to print raw data instead of lines, use "print"
<Drewch> cool, thanks
tommyvyo has joined #ruby
<catphish> mystique: you need to select which ruby you want, run "rvm 1.9.3"
<mystique> Hanmac, do you have any hints on what I could do? I tried installing everything that was suggested
remink_ has joined #ruby
<mystique> catphish, I get this, "RVM is not a function, selecting rubies with 'rvm use ...' will not work"
<catphish> now that's weird
<catphish> maybe you set up the login script wrong
Rishi- has joined #ruby
rramsden has joined #ruby
<catphish> maybe you tried to run rvm manually by its path?
<catphish> instead of setting up your login script/
<mystique> do you mind telling me what the login script is? I followed the instructions on rvm's site, step by step
<catphish> did you add some lines to your bachrc?
<catphish> something like this: $ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
<catphish> you should have done that
<catphish> then logged out and back in
<mystique> should I uninstall and do that or just copy and paste the command?
CannedCorn has joined #ruby
nvez_ has joined #ruby
<catphish> well the installation should have walked you through it
<catphish> but you could try running that and see if it fixes it
<catphish> everyone says that will fix it
TaTonka has joined #ruby
<catphish> you need to lo out and in after running it
<mystique> catphish, can I just run rvm uninstall and try to redo everything?
<catphish> i think the command is rvm implode
<catphish> so yeah, you can do that
<catphish> or just try my command first
<mystique> implode or uninstall?
yeggeps has joined #ruby
vraa has joined #ruby
<catphish> rvm implode *is* the uninstall command
themadcanudist has joined #ruby
themadcanudist has quit [#ruby]
<catphish> do that, then reinstall and make sure you read all the instructions it gives you carefully
<mystique> ok
<catphish> it should tell you to run that command to add rvm to your bash_profile
<Drewch> catphish: when I use print, printf, or puts they all put a new line after the variable
<catphish> no they don't
<Drewch> catphish: i'm printing with a class method
<catphish> run this: print "hello"; print "world"
<catphish> they should end up on the same line
<Drewch> the newline only happens when I'm doing something like
enoch_ has quit [#ruby]
elec2 has joined #ruby
philips has joined #ruby
<Drewch> print "There are ", myclass.attackers," and ", myclass.defenders, "\n"
philips has joined #ruby
KarlFreeman has joined #ruby
nvez has joined #ruby
nvez has joined #ruby
<Drewch> printf works fine though, so no worries i'll just use printf, it's what I'm used to anyways
gen0cide_ has joined #ruby
blischalk has joined #ruby
dubellz has joined #ruby
<shevy> Drewch well you give print a newline, so it prints it out
<shevy> I would assume that your instance variable contain a \n
burns180 has joined #ruby
audrius has joined #ruby
<shevy> x = " World"; print "Hello",x # => Hello World# => nil
<shevy> see, no newline as x does not contain a newline
<shevy> x = " World\n"; print "Hello",x
<shevy> Hello World
<shevy> # => nil
<shevy> there the newline comes!
<shevy> almost pure magic :D
<catphish> print "There are ", myclass.attackers," and ", myclass.defenders, "\n" prints a newline because you told it to :|
<shevy> :)
<shevy> he'll never believe us
DrShoggoth has joined #ruby
<catphish> lol
caiges_ has joined #ruby
cobragoat has joined #ruby
<Drewch> catphish, shevy , i told it to print a new line at the end
<shevy> lol
<catphish> yes you did
<shevy> :-)
<shevy> there is a lot of magic in this world
<Drewch> What it prints is: There are 5 <break> and 10 <break> <break>
<shevy> just look at Java
<Drewch> where break is a newline
<shevy> that is cool
<Drewch> it prints a new line after each variable
<shevy> it is magic man
<shevy> of course
<shevy> for you it does, for everyone else it does not?
<shevy> ;-)
<Drewch> That's why am asking if you are sticking in a variable as a method, whether it does some funky stuff
<Drewch> such as add a new line
<shevy> you are still believing in magic
al3xnull has joined #ruby
<shevy> if you have a method like
<shevy> def foo(i)
<shevy> return @foo = i+"\n"
<shevy> then there comes a newline in this method!
jacktrick has joined #ruby
<Drewch> Can I send u my file and you can tell me what it prints for you
<shevy> hmm
<shevy> Drewch, do you use IRB or pry?
Blaster has joined #ruby
<Drewch> rib, it's working in irb
<Drewch> it's only not working when I'm doing it a bit more complicated
<shevy> in IRB when you do:
<Drewch> so I suspect I have some error, or its because it's coming from a get
<shevy> x = " World"; y = " without"; z = " pain"; print "Hello",x,y,z
<Blaster> hey how would you remove all non-letter characters from a string?
<shevy> you will recieve:
<shevy> Hello World without pain# => nil
<Drewch> if I get the variable from a get, is it putting a new line
<shevy> you see that Drewch? that there is no newline? that you can reproduce this in irb too?
<shevy> aaaaah
<Drewch> shevy: I understand lol, this is clearly a ruby implicit thing
<shevy> you use get :)
<shevy> no
kaneda_ has joined #ruby
<shevy> if you use gets that is
<shevy> $stdin.gets.chomp
<shevy> with .chomp you remove newline
<Drewch> ok, so yes I do believe in magic
<shevy> if you use gets then the input has a \n
kW has joined #ruby
<Drewch> thats why it's happening
<shevy> yeah
<shevy> Blaster I would beat them with a stick
<shevy> until they surrender
brjannc has joined #ruby
sohocoke has joined #ruby
<Blaster> I just read gsub(/[^0-9a-z]/i,'')
<shevy> .gsub(/\d/,'')
<shevy> oh
<shevy> right
<Blaster> isn't \d digit?
<shevy> non-letter chars
<shevy> got confused
<shevy> hmmm
<bounce> there's \W too
<Blaster> unfortunately my attempt didnt work for removing non letters from a string. string.gsub(/^a-z0-9/i,'')
<shevy> yeah
catphish has quit ["Leaving"]
<shevy> I am a bit stumped ...
<shevy> I can apparently remove letters, buw how to keep them and remove the rest?
<shevy> :\
<shevy> *but
<Blaster> I know of this solution, but it doesnt work if non-letter characters DON'T exist... gsub!(/\W+/,'')
<shevy> x.gsub(/[a-z]/i,'')
<shevy> "123abc".gsub(/[a-z]/i,'') # => "123"
<bounce> and [^a-z] ?
<shevy> what is that
<Blaster> heres what works
<Blaster> gsub(/[^a-z]/i,'');
<shevy> ah
<shevy> nice
<Blaster> that removes numbers too though
<shevy> one just has to toggle the ^ on and off
tatsuya_o has joined #ruby
<shevy> "123abc".gsub(/[^a-z]/i,'') # => "abc"
<shevy> "123abc".gsub(/[a-z]/i,'') # => "123"
<Blaster> Guess it's time to go read some more http://regular-expressions.info
<Blaster> for me anyway
<bounce> might play with http://rubular.com/
odinswand has joined #ruby
<Blaster> nice. thanks
<matti> "123abcDEF".tr('a-zA-Z', '')
<shevy> here comes the rescue
sdwrage has joined #ruby
<matti> Works for "zzz123abcDEF" etc.
<Blaster> didn't work as expected for me.
<matti> (main):007:0> "zzz123abcDEF".tr('a-zA-Z', '')
<matti> => "123"
<shevy> perhaps your expectation is wrong
<matti> shevy: Haha
RichGuk has joined #ruby
<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
Sou|cutter has joined #ruby
<davidpk> pielgrzym: http://pastebin.com/NkaaJhDA <-- that should work (notice lines 1 and 4)
<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
macmartine has joined #ruby
Ian_ has joined #ruby
<kah> Quick question, why isn't my File.rename working? http://pastie.org/3522177
<kah> and I know, windows isn't the best.. ;)
<bounce> I was thinking that '#!usrbinenv' thing looked rotten
k_89 has joined #ruby
ascarter has joined #ruby
<kah> bounce, haha =(
maletor has joined #ruby
<kah> if it helps, i'm on linux right now
<kah> hah
ascarter has quit [#ruby]
ascarter has joined #ruby
<bounce> well, then I guess the paths wouldn't match, right?
<bounce> anyway I'm much too much of a ruby beginner to know why the rename won't work
<bounce> have you tried with just one file first, though?
<kah> bounce, yeah
<kah> that worked
tatsuya_o has joined #ruby
senthil has joined #ruby
<banisterfiend> pielgrzym: bundler i guess / rvm
aim-On has joined #ruby
burns180_ has joined #ruby
xlogic has joined #ruby
mdw has joined #ruby
zakwilson has joined #ruby
fr0gprince_ has joined #ruby
alaska has joined #ruby
coucher has joined #ruby
delinquentme has joined #ruby
ascarter has joined #ruby
adeponte has joined #ruby
bigkm has joined #ruby
adeponte has joined #ruby
badabim has joined #ruby
dlam has joined #ruby