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/
tommyvyo_ has joined #ruby
vraa has joined #ruby
<namidark> Is there anything in ruby (I've tried EM, Async Sinatra, and Sycnhronous sinatra) that would let me run blocking commands and continue to process other blocking commands ( such as another system command being run )? I've also looked at Tornado with python and no luck w that either :\
pu22l3r_ has joined #ruby
stephenjudkins has joined #ruby
bigkm has joined #ruby
knightMBP has joined #ruby
choffstein has joined #ruby
jergason has joined #ruby
cbuxton has joined #ruby
sacarlson has joined #ruby
trend_ has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
<gate> namidark: threads?
<RubyPanther> namidark: fork
<namidark> RubyPanther: how would a forked proc be able to respond?
<RubyPanther> IPC of some sort. I recommend dbus.
<RubyPanther> or some drb middleware
knightMBP has joined #ruby
<namidark> gate: thanks :) Found a simple TCP threaded socket example thats working how I want
idletom has joined #ruby
<gate> Cool :)
jgrevich has joined #ruby
<heftig> namidark: threads should work fine on 1.9
stephenjudkins has joined #ruby
MasterIdler has joined #ruby
knightMBP has joined #ruby
d34th4ck3r has joined #ruby
td123 has joined #ruby
Karmaon has joined #ruby
delinquentme has joined #ruby
<delinquentme> umm "sudo apt-get install ruby -1.9.3 " no bones
<delinquentme> what am i doing wrong here?
<delinquentme> this is for a production machine so I'm not running RVM
<heftig> it's probably called ruby1.9.1
red13 has joined #ruby
sacarlson has joined #ruby
munx has quit [#ruby]
<red13> I'm trying out Jekyll for the first time and getting a deprecation warning every time I start the server... is there any way to suppress this?
<red13> .rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
mdaisuke has joined #ruby
manizzle has joined #ruby
banisterfiend has joined #ruby
chaitanya has joined #ruby
<td123> is there a way to get a list of subclasses and submodules of a Module?
<banisterfiend> td123: using ObjectSpace
jbc has joined #ruby
<jbc> heyas :)
shtirlic has joined #ruby
<banisterfiend> jbc: heyyyy ya oh-oh, oh-oh..heyyyy yaa! oh-oh
sacarlson has joined #ruby
waxjar has joined #ruby
<jbc> I'm building a huffman compressor for fun and profit; is there an easy way to accumulate a stream of bits into a string of bytes?
tdelam has joined #ruby
<jbc> ie source.each_char {|c| output << codewords[c].to_bits} kinda thing
Mac_ has joined #ruby
<jbc> just for elegance, I don't want to store the whole output buffer as a big string of '1' and '0' chars...
<td123> jbc: "hi".each_byte ?
rook_flood has joined #ruby
phantasm66 has joined #ruby
havenn has joined #ruby
<jbc> ah, wrong end. Iterating over the source I can nut out - what's throwing me is concatenating variable-length bit sequences into a buffer
dhruvasagar has joined #ruby
kah has joined #ruby
<kah> hey, I'm working on something here.. http://pastie.org/3500679 -- it works fine except the files are copied no matter what, I would only like to copy it if there is a directory match! any idea?
themadcanudist has joined #ruby
themadcanudist has quit [#ruby]
Drewch has joined #ruby
al3xnull has joined #ruby
mxweas_ has joined #ruby
sawjig has joined #ruby
<kah> hey, I'm working on something here.. http://pastie.org/3500679 -- it works fine except the files are copied no matter what, I would only like to copy it if there is a directory match! any idea?
iamjarvo has joined #ruby
fayimora has joined #ruby
<SullX> i have an array [["1.99","2.34","3"],["2.11","4.56","1.98"]] how can i convert this to an array of floats, such as [[1.99,2.34,3],[2.11,4.56,1.98]]
<epochwolf> SullX: String#to_f should work
trend has joined #ruby
<mdaisuke> kah: what about add if Dir.exist? dir_name
albemuth has joined #ruby
<banisterfiend> SullX: [["1.99","2.34","3"],["2.11","4.56","1.98"]].map { |v| v.map(&:to_f) }
<SullX> epochwolf: banisterfiend: thank you!
<kah> mdaisuke, sorry i don't quite follow
Banistergalaxy has joined #ruby
dhruvasagar has joined #ruby
idletom has joined #ruby
tayy has joined #ruby
felipe has joined #ruby
ckrailo has joined #ruby
<kah> mdaisuke: hmm don't quite follow
<mdaisuke> kah: you can check if the directory exist by Dir.exist?
vraa has joined #ruby
<kah> mdaisuke: i still don't follow, all i want is it to only paste files where the directory matches.. right now it's just pasting a blank file in every folder for each my_dir file
rushed has joined #ruby
briankbuckley has joined #ruby
briankbuckley has joined #ruby
<CacheMoney> I have a Game class and Player class. In the Game class is an instance variable which holds an array of Player objects. How do I access an instance variable (ie 'name') of one of the Player objects within that array?
neohunter has joined #ruby
hadees has joined #ruby
td123 has quit [#ruby]
looopy has joined #ruby
Choobie has joined #ruby
liluo has joined #ruby
Indian_ has joined #ruby
td123 has joined #ruby
<CacheMoney> Heres the code http://pastie.org/3500839 And I know the Player class is a mess... I apologize
nari has joined #ruby
Sliker has joined #ruby
jordanstephens has joined #ruby
JJasonClark has joined #ruby
rohit has joined #ruby
JJasonClark has quit [#ruby]
undersc0re has joined #ruby
pu22l3r has joined #ruby
JJasonClark has joined #ruby
sawjig has joined #ruby
JJasonClark has joined #ruby
ilyam has joined #ruby
liluo has joined #ruby
macmartine has joined #ruby
snip_it has joined #ruby
ryanf has joined #ruby
tomzx has joined #ruby
crankyco_ has joined #ruby
baroquebobcat has joined #ruby
shtirlic_ has joined #ruby
<kah> mdaisuke, yeah I'll check that tomorrow, thanks!
jergason has joined #ruby
tar_ has joined #ruby
pongwon has joined #ruby
<mdaisuke> CacheMoney: you can get @name instance variable of Player object by @team[0].name
ipsifendus has joined #ruby
banisterfiend has joined #ruby
Evixion has joined #ruby
danishkhan has joined #ruby
sythe_ has joined #ruby
looopy has joined #ruby
Rishi_ has joined #ruby
cableray_ has joined #ruby
<delinquentme> how is it that I "sudo apt-get install rubygems1.8" and gem -version is "1.3.5" ??
tatsuya_o has joined #ruby
shtirlic has joined #ruby
tatsuya_o has joined #ruby
<CacheMoney> mdaisuke: Thanks. So I updated that... but I have a new problem. How do I make it so when I add points to a player object (ie player#twomake) it also adds points to the Game @@points total http://pastie.org/3501023
sdwrage has joined #ruby
<CacheMoney> Previous pastie cut off some of the code. Here is the entire code http://pastie.org/3501049
aers has joined #ruby
sacarlson has joined #ruby
fayimora_ has joined #ruby
Boohbah has joined #ruby
<hadees> any idea how you can calculate the md5 sum of a remote file with out storing the entire thing in memory?
<fowl> CacheMoney: set a method in player like points=(value), have it set @points and tell the game to increment its point count
baroquebobcat has joined #ruby
mxweas_ has joined #ruby
<fowl> CacheMoney: remember that if you want to use that function from player however just points += 2 won't work, that will try to set a local variable, you have to use explicit reciever self.points += 2
<Boohbah> hi, how can i get a useful value out of Process.times (Time.times) ? http://pastie.org/3500831
philcrissman has joined #ruby
<Boohbah> the values in Struct::Tms seem to have no relation to the timers i've setup
ribayr has joined #ruby
luxurymode has joined #ruby
<CacheMoney> fowl: How do I tell the Game to increment it's point count? What does the syntax look like?
bbttxu_ has joined #ruby
tdelam has joined #ruby
dv_ has joined #ruby
<CacheMoney> fowl: right now I have three Player methods that update a players' point total (ftmake, twomake, threemake). Can I add something to these three methods that will automatically update the @@points variable in Game?
dhruvasagar has joined #ruby
<fowl> CacheMoney: add a method to increment it?
ZeepZop has joined #ruby
<fowl> class game; def addpoints(p); @@points += p; end; end
fedalto has joined #ruby
<CacheMoney> fowl: I mean... Sorry I'm pretty new to Ruby (and programming in general). Can I call a method in the Player class and have it affect the @@points variable in Game class?
<CacheMoney> or our these two seperate things?
<lectrick> nobody uses @@variables pretty much
<fowl> CacheMoney: well, if you want the game instance to have access to the player's points, why not just get them from @player.points ?
<fowl> CacheMoney: how come you dont try to use Gosu, do a game with graphics
<CacheMoney> fowl: I plan on making this stat tracking app with graphics once I get a better understanding of how the classes and variables fit together
caveat- has joined #ruby
tatsuya_o has joined #ruby
<CacheMoney> fowl: So, should this method to update Game @@points search through each @player.points only when it's called? It'd be nice if it did it whenever one of the three methods was called that updates a players' point total
undersc0re has joined #ruby
<fowl> CacheMoney: well, each team would have a combined score of the players, right?
<CacheMoney> yeah
td123 has joined #ruby
<Boohbah> hi, how can i get a useful value out of Process.times? the values in Struct::Tms seem to have no relation to the timers i've setup. http://pastie.org/3500831
<CacheMoney> fowl: right now I'm taking the approach of tracking stats in real-time using the Command Line -- it's not ideal (graphics would be better and typing is a pain) -- but I want to be able to display up-to-date stats once called upon. So, say I'm halfway through the game and I want to know how player 'x' is doing, I can just type $ x.display
jordanstephens has quit [#ruby]
macmartine_ has joined #ruby
<CacheMoney> As a result, I'd like to have the Game @@points be updated immediately after a player scores a point
macmartine has joined #ruby
waxjar has joined #ruby
carlyle has joined #ruby
Seisatsu has joined #ruby
<fowl> CacheMoney: you have to somehow make your players aware of what game they are in. you could pass it in the args when you create it, then have a method in player called score_points(p) it would do @points += p and @the_var_you_save_the_game_instance_to.inc_points(p) then you'd have that inc_points() in Game to incrememnt its own counter
<fowl> brb in like 5, hope that helps, trying not to write code for people
<fowl> if that makes sense
<Boohbah> CacheMoney: it's a good idea to use private instance variables when you can
aroop has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
drbawb has joined #ruby
drbawb has joined #ruby
pac1 has joined #ruby
virtuoussin13 has joined #ruby
<virtuoussin13> I have a question about Rake, can I ask it here?
<Boohbah> don't ask to ask, just ask
i8igmac has joined #ruby
<virtuoussin13> well, it's not a strictly ruby language topic, some channels are very strict about their topics
<banisterfiend> virtuoussin13: hurry up and ask your question before the ice weasels come
<virtuoussin13> I'm trying to use the Gem::PackageTask for my project, but when I re-run the package task after the package is already built, I get a complaint about a circular dependency
<CacheMoney> fowl: Thanks for the advice. I'll keep looking on the internet for better examples of passing values across classes. If you know of any good resources send 'em my way
<fowl> CacheMoney: you dont want to pass values, thats not rubyish
philips has joined #ruby
philips has joined #ruby
adeponte has joined #ruby
senthil has joined #ruby
<senthil> what are contiguous arrays?
<senthil> the array has no nils?
<CacheMoney> fowl: What should I google to find help? "Passing arguments to objects"??
<fowl> basically the players should know about the game, and when they score a point they be able to be like "yo @game.increment_score(this_much)" code should flow like english, and when it runs you obfuscate it so nobody else can read it >:)
<CacheMoney> fowl: ahh that makes sense
<CacheMoney> okay, I think I know how to do that
<CacheMoney> fow: appreciate your help, and guidance
mikeycgto has joined #ruby
mikeycgto has joined #ruby
<virtuoussin13> it says: Circular dependency detected: TOP => gem => pkg/awesome_package-0.0.0.gem => pkg/awesome_package-0.0.0 => pkg/awesome_package-0.0.0
<virtuoussin13> I have no idea why that's happening
fayimora has joined #ruby
CheeToS has joined #ruby
adamkittelson has joined #ruby
<i8igmac> can i get some help adding a rescue error for my client... i cant get this in the right spot...
<i8igmac> line 15 i blocked the socket
manizzle has joined #ruby
fukushim_ has joined #ruby
emocakes has joined #ruby
mikepack has joined #ruby
ckrailo has joined #ruby
audy has quit ["Textual IRC Client: http://www.textualapp.com/"]
kevinbond has joined #ruby
sacarlson has joined #ruby
techhelp has joined #ruby
ryannielson has joined #ruby
<i8igmac> TCPSocket.open(ARGV[0],ARGV[1]) { rescue puts "#{$!}" else |sock|
sohocoke has joined #ruby
paissad has quit ["Leaving"]
jergason has joined #ruby
pantsman has joined #ruby
tdelam_ has joined #ruby
savage- has joined #ruby
Banistergalaxy has joined #ruby
Seppman has joined #ruby
munx has joined #ruby
akem has joined #ruby
akem has joined #ruby
cloudgeek has joined #ruby
<cloudgeek> best way to learn ruby from scarth for a newbie
<cloudgeek> ??
<cloudgeek> where to start if body can guide me
<cloudgeek> any book or website or any link ??
pu22l3r has joined #ruby
<sunaku> cloudgeek: http://tryruby.org
<cloudgeek> sunaku: okay
<i8igmac> cloudgeek, what are you looking to do
<cloudgeek> sunaku: any book , i can't have access to internet most of time , so if any there any book!
sroy2_ has joined #ruby
<i8igmac> i have learned alot from my own projects
<cloudgeek> i8igmac: I want learn ruby !
<sunaku> cloudgeek: click on the "poignant guide" book link on the bottom left
<i8igmac> sockets have been the most fun for me
<cloudgeek> i8igmac: okay nice ! learning by doing
<sunaku> cloudgeek: beware, poignant guide is not your *standard* book
<i8igmac> are you on linux?
<cloudgeek> i8igmac: how can i start , i use vim as ruby editor and ide
<cloudgeek> i8igmac: yep on linux
minijupe has joined #ruby
<cloudgeek> sunaku: okay
<i8igmac> maybe try scite editor... i like it... but anything will work
<i8igmac> have you tested irb?
<cloudgeek> i8igmac: nope , i just do all things with vim till now
<sunaku> cloudgeek: install vim-ruby https://github.com/vim-ruby/vim-ruby#readme
<i8igmac> have you testing any hello world examples?
gianlucadv has joined #ruby
<cloudgeek> i8igmac: no total a newbie
<cloudgeek> i8igmac: i am student , before this i do lot time for sysadmin work for university
<cloudgeek> i8igmac: now i just want to learn to code with ruby
<sunaku> in the old days, we all learned ruby from the "pickaxe" book. then came why's poignant guide. and more books followed
<cloudgeek> okay
<sunaku> hey the official ruby in 20 mins is pretty good: http://www.ruby-lang.org/en/documentation/quickstart/
rohit has joined #ruby
<cloudgeek> ruby is my first language beacsue i read about tdd and agile that attarcts me towards ruby
<sunaku> first ever programming language?
<sunaku> cloudgeek: have you programmed before?
FlyingFoXy has joined #ruby
leex has joined #ruby
Monofu has joined #ruby
drbawb has joined #ruby
drbawb has joined #ruby
macmartine has joined #ruby
<Monofu> How would I go about converting this to JSON in Ruby? http://pastie.org/3501596
robbyoconnor has joined #ruby
burlyscudd has joined #ruby
Monofu has quit [#ruby]
Monofu has joined #ruby
Know1edge has joined #ruby
banisterfiend has joined #ruby
undersc0re_ has joined #ruby
carlyle has joined #ruby
_undersc0re_ has joined #ruby
wyhaines has joined #ruby
albemuth has joined #ruby
fbernier has joined #ruby
rippa has joined #ruby
shadoi has joined #ruby
akem has joined #ruby
akem has joined #ruby
Monofu has quit [#ruby]
adamkitt_ has joined #ruby
wvdschel has joined #ruby
supergiantrobot has joined #ruby
Dreamer3 has joined #ruby
Monofu has joined #ruby
Targen has joined #ruby
akem has joined #ruby
red13 has quit [#ruby]
Monofu has quit [#ruby]
phantasm66 has joined #ruby
neurodrone has joined #ruby
neurodrone has joined #ruby
Karmaon has joined #ruby
fayimora_ has joined #ruby
<CacheMoney> How do I connect an instance of a Car class to an instance of a Person class http://pastie.org/3501730
sawjig has joined #ruby
fayimora_ has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
jsdrk has joined #ruby
delinquentme has quit ["Leaving"]
nikhil_ has joined #ruby
nikhil_ has quit ["http://gplus.to/nikhil"]
<rohit> CacheMoney: def car=(my_car); @car = my_car; end
<rohit> CacheMoney: that will let you do Person.new('CacheMoney').car = Car.new('make', 'model')
<rohit> CacheMoney: You'll also need a attr_accessor :car so that you can do @person.car i.e access the car you just stored
<fowl> rohit: attr_accessor would also set up car=()
<CacheMoney> rohit: What if I wanted the Person to have more than one car?
<rohit> CacheMoney: ^ yes attr_accessor :car will get you the same result
<rohit> CacheMoney: Then you have a @cars instance var in Person. Then have a method Person#add_car(car) which does @cars << car
<rohit> CacheMoney: Of course you'll need to initialize @cars = []
<CacheMoney> rohit: So I can set a @car instance variable in Person equal to a Car object?
<rohit> CacheMoney: Yup.
<CacheMoney> rohit: Should I initialize the @cars = [] in the def initialize; or outside a method as a class variable?
dankest has joined #ruby
<rohit> CacheMoney: initialize should be fine
akem has joined #ruby
ryanf has joined #ruby
blueadept has joined #ruby
wookiehangover has joined #ruby
<cloudgeek> i am able save data into log file
<cloudgeek> using logger
<cloudgeek> it just create the log file but data is not write inside the log file
<cloudgeek> my code is here http://pastie.org/3501875
friskd has joined #ruby
<CacheMoney> rohit: Is there a way so that when I initialize a new Car instance I can pass it along to a specific Person instance? http://pastie.org/3501885
<rohit> CacheMoney: It should be possible. But I'm only familiar with doing associations in Ruby on Rails. Ideally you should be able to do Car.new(model,make).person = some_person_object and that should update both the instances associations
jergason has joined #ruby
cantonic has joined #ruby
mephux has joined #ruby
<cantonic> does anyone know if there is a possibility to automate actions on java applets on a linux machine?
<CacheMoney> rohit: okay I'll give that a try.
etank has joined #ruby
banseljaj has joined #ruby
luckyruby has joined #ruby
<cloudgeek> i try to write ouput of my ruby script to a file , but it's now working my code is here http://pastie.org/3501912
hooper has joined #ruby
sungji has joined #ruby
sungji has joined #ruby
<cloudgeek> not now
<cloudgeek> it's not working
tonini has joined #ruby
chessguy has joined #ruby
<cloudgeek> i just dig into ruby and rails world with a dedicated vim user
sam113101 has joined #ruby
<sam113101> There’s no abstract classes or interfaces
<sam113101> wat
<sam113101> why is this
mxweas has joined #ruby
lkba has joined #ruby
machine1 has joined #ruby
knightMBP has joined #ruby
<rippa> sam113101: why do you need abstract class?
<sam113101> because they are not meant to be used directly
<ryanf> so don't use it directly
<ryanf> and interfaces are pointless in a dynamic language
<sam113101> RoR is the only reason why I want to learn ruby
<sam113101> maybe it will also be useful to prototype something
Shrink has joined #ruby
Karmaon has joined #ruby
imami has joined #ruby
x0F__ has joined #ruby
jsdrk has joined #ruby
andrewhl has joined #ruby
Jonah11_ has joined #ruby
Azure|dc has joined #ruby
Rorgo has quit [#ruby]
banisterfiend has joined #ruby
yxhuvud has joined #ruby
akem has joined #ruby
imami has joined #ruby
maletor has joined #ruby
QaDeS has joined #ruby
akem has joined #ruby
Morkel has joined #ruby
fayimora has joined #ruby
JohnBat26 has joined #ruby
jesly has joined #ruby
thomasfedb has joined #ruby
Tick-Tock has joined #ruby
undersc0re has joined #ruby
mikepack has joined #ruby
silky has joined #ruby
stoffus has joined #ruby
rohit has joined #ruby
dcvii has joined #ruby
SchalaZeal has joined #ruby
jwmann has joined #ruby
idletom has joined #ruby
<SchalaZeal> I've been looking on the web for some time for what to use in C/C++ code instead of ruby_run() now since 1.9 dropped it.
<SchalaZeal> What do I do instead?
<sunaku> it's like ruby_run_node() or something
csherin has joined #ruby
<luckyruby> is this a decent way of validating that a string is between 0000 and 2359? https://gist.github.com/1956339
xnm has joined #ruby
<SchalaZeal> oh wait, yeah I *just* came across a forum post on that
KL-7 has joined #ruby
<SchalaZeal> use the void* return value from rb_load_file as an argument for rb_run_node
<luckyruby> does it make sense to even check for time.length == 4 since time =~ /[0-2][0-9][0-5][0-9]/ enforces 4 characters
<sunaku> (0..2359).member? your_number_string.to_i
mxweas has joined #ruby
<luckyruby> sunaku: 'asdf'.to_i => 0
shin2012 has joined #ruby
<sunaku> alright, then Integer('asdf')
<luckyruby> sunaku: would I need to rescue that?
<shin2012> exit
shin2012 has quit [#ruby]
cloudgeek has joined #ruby
<sunaku> luckyruby: yes since your method seems to return boolean
<SchalaZeal> excellent, well I got it to compile... now for a test run
<sunaku> luckyruby: the length check is unnecessary; just add global anchors to your regexp (\A and \z)
shin2012 has joined #ruby
<SchalaZeal> woopsy...seg fault
<sunaku> SchalaZeal: run it in gdb
maletor has joined #ruby
rippa has joined #ruby
milky has joined #ruby
<luckyruby> sunaku: how about this? (0..2359).map{|i| i.to_s.rjust(4,'0')}.include? time
<SchalaZeal> well... I think I know why... the only header included is ruby.h and I loaded and ran a file with the contents `puts "hi there"`
zomgbie has joined #ruby
<sunaku> that #map is overkill. it'll be slow
<luckyruby> cool, I didn't know you could use rescue outside of begin/end
<sunaku> yes, only in a method def
<rippa> or in a one-liner
<sunaku> true, and you can't specify the exception class in a one-liner rescue
<sunaku> <expr> rescue <value>
<luckyruby> can I get away with just rescue without specifying ArgumentError?
<sunaku> yes, but that's bad practice
milky has joined #ruby
wallerdev has joined #ruby
<sunaku> you're essentially masking all StandardError
<sunaku> if you really insist on a one-liner: (0 .. 2359).include? Integer(time) if time =~ /\A\d+\z/
<sunaku> you could even revert to the #to_i since the regexp ensures only digits
<sunaku> (0 .. 2359).include? time.to_i if time =~ /\A\d+\z/
manizzle has joined #ruby
<luckyruby> which one performs better?
<sunaku> this one liner vs the rescue?
<luckyruby> I would think erroring out on invalid argument performs better than regex checking?
<luckyruby> sunaku: yea
<cloudgeek> how i can save my output of my ruby file
<cloudgeek> i tried basic file open
<sunaku> cloudgeek: ruby your_file.rb > your_output.txt
<cloudgeek> and later use logger
<luckyruby> cloudgeek: if you're using linux and you're outputting to stdout, then ruby myscript > somefile.txt
kevinbond has quit [#ruby]
<cloudgeek> luckyruby: sunaku hey when i run my script ruby logger.txt
<sunaku> luckyruby: not necessarily. depends on how Kernel#Integer() is implemented
<cloudgeek> then ouput shown by my script
<cloudgeek> i want to save my ouput let me paste my code , that help better to understand you
<sunaku> luckyruby: don't worry about these micro-optimizations. benchmark/profile your code and fry the big fish, so to speak
pdtpatr1ck has joined #ruby
<luckyruby> sunaku: yeah, i need to work on not prematurely optimizing
<luckyruby> thanks for the help. learned a lot
<cloudgeek> this is the script i write
<sunaku> luckyruby: np. IMHO readability trumps micro-optimizations, and program architecture (especially data structures you use) dictates performance in general
<shevy> cloudgeek at line 6 you should indent until that while loop is finished
<shevy> line 15 also wrong indent
<cloudgeek> sunaku: luckyruby my output of that script is this http://pastie.org/3502275
<shevy> log=Logger.new should be log = Logger.new
<cloudgeek> I want to save this output to my iploger.txt
<cloudgeek> shevy: okay
<cloudgeek> shevy: i making it clear of indentation
<shevy> cloudgeek I would use a method for saving a file
<sunaku> both line 10 and 11 open the same file for writing
<luckyruby> cloudgeek: think all u need to do is log.info(output)
<sunaku> cloudgeek: is this script meant to be a daemon (continuously logging this stuff) ?
pandora17 has joined #ruby
<SchalaZeal> I wonder... does Ruby have the ability to compile to platform-independent bytecode files?
<cloudgeek> sunaku: yep right
JohnBat26 has joined #ruby
<cloudgeek> luckyruby: i yep i need all output in log.info file
<luckyruby> yeah, just add log.info "your output goes here"
shruggar has joined #ruby
<luckyruby> and logger will take care of it
<shevy> in your example, the default of where would be 'iplog.txt'
<shevy> and then:
<shevy> save_file "output gonna to save in iplog.txt"
<cloudgeek> shevy: i done with identation http://pastie.org/3502291
<shevy> *indentation
<shevy> ;)
<shevy> argh
<cloudgeek> :) i miss n
<shevy> why are the numbers in the code?
<cloudgeek> shevy: i am using vim , using plugin i do pasting
<cloudgeek> that why numbers are there
<shevy> aha, well why are you doing that
<shevy> there are TWO times the numbers there now!
senny has joined #ruby
<shevy> lol :)
<sunaku> cloudgeek: auto-format your code in vim: ggVG=
<cloudgeek> shevy: one is pastie.org and other one my vim one it is auomatic process
jameshyde has joined #ruby
<cloudgeek> okay
<shevy> yeah, and now other people can not copy paste your code and have it work...
<luckyruby> sunaku: is there an advantage to use \A \Z vs ^ $?
<shevy> and you indented the lines, not your code...
<shevy> oh man ;<
<shevy> I gotta leave here for work, laters
<luckyruby> just curious cause I usually use ^ $
<cloudgeek> shevy: i done ggVG=
brjannc has joined #ruby
<sunaku> luckyruby: yes. with global anchors you're being more *specific* about the input. line anchors (^$) will match this: "foo\n123\nbar", global ones won't
Spockz has joined #ruby
<rippa> ^$ wouldn't match it too
<cloudgeek> now i look better
<cloudgeek> shevy: i think now proper indentation is there
<sunaku> rippa: /^\d+$/ =~ "foo\n123\nbar" #=> 4
<sunaku> rippa: /\A\d+\z/ =~ "foo\n123\nbar" #=> nil
<rippa> sunaku: well, that's not ^$
CheeToS has joined #ruby
<luckyruby> sunaku: I see
<sunaku> ah. i was speaking in context of luckyruby's earlier question
<cloudgeek> sunaku: now also it is not showing nothing inside iploger.xtx
<cloudgeek> txt
<cloudgeek> just it create this file and write date and time with username
<sunaku> luckyruby: the global anchors also increase your speed too (in theory) since they're more *specific*
<luckyruby> so basically if I went with line anchors, I'd hit an argumenterror on Integer if someone sent "foo\n123\nbar"
<sunaku> yes
<luckyruby> sunaku: is there a diff between \Z and \z?
<luckyruby> whoa.. must bookmark!
mafolz has joined #ruby
<cloudgeek> sunaku: how my scirpt works
<cloudgeek> i don't know
<sunaku> it doesn't :P
<cloudgeek> how it can write the output to that file
<cloudgeek> sunaku: i know that doesn't work
<cloudgeek> sunaku: i am newbie and it's my first program
<cloudgeek> sunaku: that's why it is not working
<cloudgeek> but it have to work
<sunaku> cloudgeek: it seems like all you're doing is this: netstat -n | sed 's/us_socket/REPLACEMENT/' >> iplog.txt
<sunaku> do you really need a ruby script?
<luckyruby> cloudgeek: i agree with sunaku. learn sed/awk
sungji has joined #ruby
sungji has joined #ruby
<cloudgeek> sunaku: i know to save with that , but i want perform same task with ruby
<cloudgeek> sunaku: i want to know read and write files using ruby it help me later in other things too
ph^ has joined #ruby
<sunaku> sorry amigo. you need to read/learn some more (see http://ruby-doc.org/docs/ProgrammingRuby/html/tut_io.html) before just solving task X. don't be in a hurry, and don't give up. cheers
shruggar1 has joined #ruby
<cloudgeek> yep sure , never give up your soul and faith if you wanna learn something
mikeycgto has joined #ruby
mikeycgto has joined #ruby
azbarcea____ has joined #ruby
maletor has joined #ruby
machine1 has joined #ruby
neutrino has joined #ruby
tyman has joined #ruby
Shrink has joined #ruby
Helius has joined #ruby
davidcelis has joined #ruby
shruggar has joined #ruby
<atmosx> hm
<atmosx> I wonder if there's a package to create easily create graphs (like bell curves) using ruby.
ephemerian has joined #ruby
<atmosx> and yes there is http://nubyonrails.com/pages/gruff
Sliker has joined #ruby
glosoli has joined #ruby
speggey has joined #ruby
odinswand has joined #ruby
cpruitt has joined #ruby
mea44 has joined #ruby
zakwilson has joined #ruby
stevecaney has joined #ruby
liluo has joined #ruby
shruggar has joined #ruby
TandemAdam has joined #ruby
<cloudgeek> i again edit my code , now also it now taking my output into new file
TandemAdam has quit [#ruby]
<cloudgeek> can tell me where is the error what i need to improve
<cloudgeek> in the code
bier has joined #ruby
joppe has joined #ruby
senthil has joined #ruby
PragCypher has joined #ruby
rippa has joined #ruby
nemesit has joined #ruby
InBar has joined #ruby
pi3r has joined #ruby
etehtsea has joined #ruby
minsa has joined #ruby
fortysixandtwo has joined #ruby
twelvechairs has joined #ruby
burns180 has joined #ruby
johndbritton has joined #ruby
liluo has joined #ruby
Emmanuel_Chanel has joined #ruby
neutrino has joined #ruby
jesly has joined #ruby
<jesly> hey which is the best ruby intro i can suggest to my friends?
<banisterfiend> jesly: rubymonks is good
<banisterfiend> rubymonk
<cloudgeek> file writing is not working afile
<jesly> <banisterfiend>: thank you
<cloudgeek> i trying to write progam in ruby that save ouput to file
<cloudgeek> but that is not working
alem0lars has joined #ruby
alesguzik has joined #ruby
Spockz has joined #ruby
mdw has joined #ruby
francisfish has joined #ruby
IPGlider has joined #ruby
berkes has joined #ruby
liluo_ has joined #ruby
burns180 has joined #ruby
Talvino has joined #ruby
iocor has joined #ruby
Guest63368 has joined #ruby
lurch_1 has joined #ruby
shtirlic_ has joined #ruby
DuoSRX has joined #ruby
shruggar has joined #ruby
timonv has joined #ruby
speggey has joined #ruby
adambeynon has joined #ruby
jergason has joined #ruby
zomgbie has joined #ruby
stenno has joined #ruby
davidpk has joined #ruby
burns180_ has joined #ruby
darthdeus has joined #ruby
arussel has joined #ruby
d34th4ck3r has joined #ruby
<arussel> I got a value extracted from the database id = tuple['id'], the value is 1. When I do (id % 2) it returns 1 (this what I expected)
<arussel> but when I do (id % 2 == 1), it returns false, then I don't understand why
davidpk has joined #ruby
<rippa> works here
shruggar has joined #ruby
BiHi has joined #ruby
arturaz has joined #ruby
<stenno> arussel,
<stenno> irb(main):001:0> "1" % 2
<stenno> => "1"
<stenno> migh this be the problem..?
<stenno> might*
<stenno> i.e. are you sure id is an int and not a string?
rohit has joined #ruby
sungji has joined #ruby
sungji has joined #ruby
<arussel> stenno: it is an int in the database. How can I check ?
<stenno> int.class
<stenno> should give Integer or Fixnum
<stenno> and not String
<arussel> String
<stenno> :D
<arussel> stenno: thanks
<stenno> np :)
stevecaney has joined #ruby
d3vic3 has joined #ruby
Spockz has joined #ruby
stoffus1 has joined #ruby
dr_bob has joined #ruby
arussel has quit ["ERC Version 5.3 (IRC client for Emacs)"]
n3m has joined #ruby
bootris has joined #ruby
sohocoke has joined #ruby
adeponte has joined #ruby
burns180 has joined #ruby
speggey_ has joined #ruby
jlebrech has joined #ruby
<cloudgeek> my code is working properly it not writing output into file
tatsuya_o has joined #ruby
tatsuya_o has joined #ruby
skim1776 has joined #ruby
<skim1776> hey there, is it possible to make same classes with the same number of arguments but different types?
<darthdeus> hey guys, is there any way to check if a method that's not supposed to get a block does get it? such as some flag that will at least raise a warning?
fayimora_ has joined #ruby
bootris has joined #ruby
nixmaniack has joined #ruby
tvw has joined #ruby
Ferdev has joined #ruby
<banisterfiend> skim1776: that doesnt really make sense
mdw has joined #ruby
nixmaniack has joined #ruby
<stenno> darthdeus, well you could check the class of the last argument
<skim1776> banisterfiend, method overloading
<stenno> if it is Proc (?), its a block
<stenno> skim1776, no need for that in ruby o-O"
<jesly> any ruby func to convert ascii value to corresponding character? 65=>'A' ??
<bootris> beerist has Quit (Ping timeout)..
<banisterfiend> darthdeus: check block_given?
<stenno> there are no 'types' in ruby in that sense
<stenno> jesly, 65.chr
<banisterfiend> darthdeus: def hello(); raise "dont want a block!" if block_given? end
<bootris> i worship little black people who live in caves.. !!!!. JESUS HAD THE SKIN OF BRONZE
<skim1776> I want to make two functions shift which would shift character to either another character or a number
<stenno> banisterfiend, oh thats convenient
iocor has joined #ruby
nixmaniack has quit [#ruby]
dv_ has joined #ruby
<skim1776> def shift(letter, letter) end def shift(letter, position) end
<stenno> so you would have to check if the second argument is either string or int
burns180_ has joined #ruby
<skim1776> stenno, okay, thanks
<stenno> i would make 2 methods though i think
<skim1776> stenno, with different names?
<stenno> yup
<stenno> to clear things
<skim1776> stenno, yeah, that's a good idea, thanks
trivol has joined #ruby
Spockz has joined #ruby
axl_ has joined #ruby
roolo has joined #ruby
g0bl1n has joined #ruby
workmad3 has joined #ruby
skim1776 has quit [#ruby]
jmeeuwen has joined #ruby
burns180_ has joined #ruby
ChampS666 has joined #ruby
adac has joined #ruby
<adac> how do we authenticate (basic auth) via open-uri?
<stenno> adac, specify :http_basic_authentication on uri.open
<stenno> oh wait that was OpenUri::OpenRead
<adac> stenno, is it better to use: Net::HTTP instead of open-uri?
<stenno> uh
canton7 has joined #ruby
davidpk has joined #ruby
BrianJ has joined #ruby
al3xnull has joined #ruby
<stenno> do you want to parse http headers? if yes, take Net::HTTP, otherwise, take OpenURI i'd say
<stenno> but i don't really know much about it i'd say
<stenno> net/http is more about sockets
tayy has joined #ruby
<adac> stenno, actually the page I fetch just gives me back a json string
<adac> so I just need that json string
parus has joined #ruby
<stenno> meh, just use open-uri
ccapndave has joined #ruby
<adac> stenno, thank you :)
<Guest63368> how do timeout a function in ruby
<Guest63368> like, if that function dont respond in 5sec
<rippa> Timeout
<eddie> yes
<eddie> my function call must expire in 5 sec
<Guest59400> and continue with the rest
<Guest59400> ok
<Guest59400> i will be back
<Guest59400> rippa: Thansk
<Guest59400> thanks*
jmeeuwen has joined #ruby
dazoakley has joined #ruby
gianlucadv has joined #ruby
nyuszika7h has joined #ruby
<stenno> adac, np
luoluoluo has joined #ruby
adambeynon has joined #ruby
burns180_ has joined #ruby
burns180 has joined #ruby
alcy has joined #ruby
speggey has joined #ruby
tayy_ has joined #ruby
<alcy> folks, in what situations would ruby -e '...' be different from ruby script.rb ?
Foxandxss has joined #ruby
<alcy> i mean in what situations would the expected behavior be different
<alcy> specifically, with normal ascii input both methods give the same result
chaitanya has joined #ruby
<alcy> but with non-ascii unicode ruby -e '..' barfs but ruby script.rb works
<stenno> maybe its a thing of your shell and not ruby ?
<stenno> anyway, ruby and unicode always was nasty
<stenno> might aswell be a bug
<alcy> hmm, let me check the behavior in irb
the_hack has joined #ruby
zomgbie has joined #ruby
simao has joined #ruby
<alcy> stenno: same as -e :(
IPGlider has joined #ruby
<stenno> hmm no idea then :| my guess would be (as i said) that your terminal does strange things to unicode escaping
<stenno> but thats just a blind guess
d34th4ck3r has joined #ruby
KJF has joined #ruby
francisfish has joined #ruby
sspiff has joined #ruby
berkes has joined #ruby
burns180 has joined #ruby
My_Hearing has joined #ruby
speggey has joined #ruby
Hanmac has joined #ruby
blacktulip has joined #ruby
<Hanmac> question about making time object in C ... i need time_t and millisconds or exist an other way
<stenno> are you talking about ruby C extensions?
<stenno> how to get the ruby Time object working in C code?
tvo has joined #ruby
tvo has joined #ruby
philcrissman has joined #ruby
Richmond has joined #ruby
Progster has joined #ruby
fr0gprince_mac has joined #ruby
<shevy> yeah cloudgeek you fixed the indentation. the extra-line numbers from vim are annoying though :)
<shevy> btw I would change:
<shevy> File.open("/home/py/iplog.txt","r+")do|file|
<shevy> to
<stenno> set nonumber
<shevy> File.open("/home/py/iplog.txt","r+") do |file|
<shevy> hmm your indent is still off http://pastie.org/3502929
AzizLight has joined #ruby
<stenno> :set nonumber, rather
<shevy> perhaps it is time to train with notepad first
<stenno> :D
<stenno> also vim autoindent is your friend
<shevy> stenno you are also using vim?
<stenno> yup
<stenno> but i try to convert to sublime_text vintage right now :)
<Hanmac> stenno "Time Object working in C" that is the question ... (i want an wxDateTime object wrapped in an RubyTime)
<shevy> hehe
<stenno> Hanmac, aah right i see
burns180 has joined #ruby
<shevy> Hanmac are you already building RubyOS
havenn has joined #ruby
speggey has joined #ruby
<stenno> i have to admit that i am not at all sure on how to require ruby libs into C code
<Hanmac> stenno i thought "rb_time_new(time_t, long);" is the right or?
<Hanmac> RubyOS: not today maybe later :P
<shevy> stenno yeah no idea either. last time I went into ruby-C i just tried to get basic things working
<stenno> Hanmac, that sounds good
<shevy> like adding to a ruby array in C or write a very simple class
<stenno> well that stuff is rather easy imho
Indian has joined #ruby
<Hanmac> adding to ruby array is rb_ary_push(array,element)
Helius has joined #ruby
hasrb has joined #ruby
<shevy> yeah those are the easy bits
speggey has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
shruggar has joined #ruby
burns180_ has joined #ruby
briankbuckley has joined #ruby
philcrissman has joined #ruby
pi3r has joined #ruby
<kivi> how to get encoding of a string at 1.8.7
Sliker has joined #ruby
<Hanmac> kivi 1.8 does not support realy encoding
akem has joined #ruby
neurodrone has joined #ruby
techhelp has joined #ruby
akem has joined #ruby
neurodrone has joined #ruby
rohit has joined #ruby
iocor has joined #ruby
Faris has joined #ruby
speggey has joined #ruby
zomgbie has joined #ruby
<Faris> Why does 'sleep' sleeps forever in a loop ?
<Faris> a loop block that is
burns180 has joined #ruby
<Faris> loop{print 'lol'; sleep1} for instance, never wakes up !
<JonnieCache> works fine for me
<Faris> you're using windows?
<zaargy> is there a nice ruby library for checking it processes are running on linux?
<Faris> what's wront with parsing ps ?
sacarlson has joined #ruby
<zaargy> er
<zaargy> lots?
<zaargy> proc at least
<zaargy> i mean you have to do something like that anyway
<zaargy> i just wondered if tehre some library already
<zaargy> so i don't need to reinvent the wheel
crankycoder has joined #ruby
<Faris> I don't know of such a lib sry ^^
<kivi> Hanmac: ok
<rippa> zaargy: Process
<Hanmac> kivi you should switch to 1.9.2+ if you can do this
zomgbie has joined #ruby
mrake has joined #ruby
<JonnieCache> just parse ps, its there to be parsed
<JonnieCache> nothing wrong with pushing strings around. unix has gotten by fine like that for decades
visof has joined #ruby
visof has joined #ruby
akem has joined #ruby
Rishi_ has joined #ruby
KL-7 has joined #ruby
tomzx has joined #ruby
zomgbie has joined #ruby
sacarlson has joined #ruby
burns180_ has joined #ruby
adamantas has joined #ruby
<Danielpk> With Middleman, any1 know how i can add other folders to Guard?
manizzle has joined #ruby
davidpk has joined #ruby
n1x has joined #ruby
iocor has joined #ruby
thone has joined #ruby
davidpk has joined #ruby
<cloudgeek> quiz.rb:3:in `require': no such file to load -- ui (LoadError) from quiz.rb:3
evilgeenius has joined #ruby
<Hanmac> cloudgeek your ruby version is >1.9 right?
ixti has joined #ruby
rohit has joined #ruby
<evilgeenius> How do I get the last 2 characters of a string?
sdwrage has joined #ruby
<banisterfiend> evilgeenius: string[-2..-1]
<evilgeenius> banisterfiend: thanks
burns180 has joined #ruby
robbyoconnor has joined #ruby
neurodrone has joined #ruby
neurodrone has joined #ruby
canton7 has joined #ruby
<dr_bob> oh, we have an evil genius in here. shudder
<Stefunel> What is the proper way of locking a file? f.flock File::LOCK_EX won
<Stefunel> won't work
<Stefunel> I mean I do that, sleep the script for ever and from outside the script I echo stuff into the locked file and it works
Barakas has joined #ruby
pu22l3r has joined #ruby
gianlucadv has joined #ruby
<dr_bob> That's not how it works. All processes must attempt to lock the shared file. See "ri File.flock'
<stenno> i wonder why in 1.8.7, string[index] gives the ASCII value, but string[start..end] gives a string and not an array of ascii values
<Stefunel> ah, so from a different script I should try to open the file and check if it is locked, right?
<matled> Stefunel: right
<Stefunel> thanks!
<adamantas>
ctp has joined #ruby
<matled> Stefunel: see also man 2 flock for details, it is a bit more detailed than the ruby documentation.
adambeynon has joined #ruby
fearoffish has joined #ruby
pangur has joined #ruby
<KJF> Is there a way to have more than one initialize method? One with a parameter and one without?
jesser has joined #ruby
<Hanmac> KJF no but you can use an default parameter
<KJF> Hanmac: something like def initialize(param = nil) ?
<jesser> Hello … I seem to have an issue with ruby 1.9.2p290 that I've built on OpenSolaris using gcc … Idle processes are consuming CPU.
barmston has joined #ruby
<Hanmac> yeah, and then you can check with "if param.nil?"
chaitanya has joined #ruby
<KJF> Hanmac: cool, thanks
<jesser> Would emailing the ruby-core mailing list be a good place to seek assistance?
j0bk has joined #ruby
<pangur> I am trying to create serveral instances of Person in http://fpaste.org/wZOr/ but while line 61 works fine for me, lines 64 only works if I do not have the [i]. I am not confident that it works even then. Any light on how I create an array of new Person would be helpful, thanks.
<Hanmac> jesser: you can try an newer ruby
<jesser> Hanmac: OK, is it a problem you've heard of?
mxweas has joined #ruby
* pangur looks as confused as an old newbie can be.
<Hanmac> currenlty no ... but maybe it was an error
BiHi has joined #ruby
<jesser> doing a truss on the processes they are doing this an awful lot: /8: lwp_park(0xFE9A0F1C, 0) Err#62 ETIME
<Stefunel> matled how do I just check if a file is locked?
ikaros has joined #ruby
alem0lars has joined #ruby
<canton7> pangur, firstly, try not to use for loops. There's almost always a better way. Here, "patrons.each do |patron|", then using "patron" instead of "patrons[i]", would be a lot cleaner. Also, if "attendee" isn't an array (it doesn't exist on line 64), you can't assign to an element of it
cool has joined #ruby
<pangur> Thanks, canton7, I appreciate that.
burns180 has joined #ruby
barmston has quit [#ruby]
* pangur starts editing his patrons
* shevy starts editing his pants
fdhsfdsgdsg has joined #ruby
<pangur> :)
speggey has joined #ruby
cloudgeek has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
Nathandim has joined #ruby
Seisatsu has joined #ruby
eka has joined #ruby
<matled> Stefunel: I don't kthink there is a way to check other than aquiring a lock and releasing it
fdhsfdsgdsg has joined #ruby
`brendan has joined #ruby
fdhsfdsgdsg has joined #ruby
vraa has joined #ruby
MrGando has joined #ruby
fdhsfdsgdsg has joined #ruby
n1x has joined #ruby
fdhsfdsgdsg has joined #ruby
the_hack has joined #ruby
erikstraub has joined #ruby
iocor has joined #ruby
darthdeus has joined #ruby
Redjack1964 has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
<shevy> I really want a RubyOS
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
<alcy> shevy: someone did write it, cant remember
InBar has joined #ruby
Barakas has joined #ruby
fdhsfdsgdsg has joined #ruby
erikstraub has quit [#ruby]
ecolitan_ has joined #ruby
addisaden has joined #ruby
rook_flood has joined #ruby
<addisaden> hi @all
<addisaden> i have a lil question
tatsuya_o has joined #ruby
<shevy> alcy yeah but I think it was discontinued :(
<shevy> perhaps it would work if many people come together to do just many many little tiny steps
ecolitan__ has joined #ruby
emocakes has joined #ruby
<addisaden> if you have an object and a function deals with a block, is the context of the block executed in the area, where its written (to deal with variables)
ecolitan has joined #ruby
<shevy> you mean variables within the block like |foo| ?
<addisaden> nope extern
<shevy> hmm do you have a short example
<addisaden> maybe i am in another object and want to use @foo
<shevy> well you have to get a reference to that @foo data
<shevy> for objects, they usually have their reader method, like object.foo
<banisterfiend> addisaden: yeah it's where the block is defined
<banisterfiend> addisaden: the block is a closure and captures its definition environment
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
<addisaden> also when i am working with &foo for the blog to save it as a proc?
<addisaden> -v 1.9.3 ;)
fdhsfdsgdsg has joined #ruby
<addisaden> because, that would be really really great
lkba has joined #ruby
dr_bob has joined #ruby
<banisterfiend> addisaden: yes it saves it as a proc
burns180_ has joined #ruby
<banisterfiend> addisaden: why would it be great though? :P
<addisaden> wow i love ruby. that would be so helpful
<addisaden> i am working on an interface for puredata
<addisaden> to make music
<addisaden> for a livesystem
<banisterfiend> addisaden: yeah, you'll discover most things in ruby are just what you want them to be :)
<banisterfiend> it's an exceptionally well designed language
<JonnieCache> addisaden: cool. like supercollider etc?
<addisaden> i am really happy :D - and the ruby language is really nice to write and to read
<addisaden> nope its more basic
<addisaden> i have a lil concept txt
<addisaden> http://mp3.adrianenns.de/pd/engine.txt - but its really the basic
alcy has quit [#ruby]
<addisaden> its just the interface ;)
<JonnieCache> check this out: http://dactyl.sourceforge.net/pentadactyl/
<JonnieCache> vim bindings for firefox
vraa_ has joined #ruby
<JonnieCache> well its more like a full vim mode really
<addisaden> @banisterfiend @shevy thank you for your help
<banisterfiend> np
mengu has joined #ruby
zenChild has joined #ruby
Targen has joined #ruby
gentz has joined #ruby
gentz has joined #ruby
mdw has joined #ruby
{ixti} has joined #ruby
dv310p3r has joined #ruby
fdhsfdsgdsg has joined #ruby
v0yager has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
neurodrone has joined #ruby
neurodrone has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
jlebrech has joined #ruby
namidark[w] has joined #ruby
cantonic has joined #ruby
Helius has joined #ruby
rippa has joined #ruby
sacarlson has joined #ruby
tommyvyo has joined #ruby
senny has joined #ruby
Indian has joined #ruby
namidark has joined #ruby
emmanuelux has joined #ruby
barraponto has joined #ruby
namidark_ has joined #ruby
<barraponto> the first line of my erb file is just a variable definition. yet it prints a blank line.
<barraponto> can i prevent it from printing anything?
SJr has joined #ruby
burns180 has joined #ruby
nanderoo has joined #ruby
tatsuya_o has joined #ruby
jgarvey has joined #ruby
geekbri has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
sbanwart has joined #ruby
fdhsfdsgdsg has joined #ruby
Seisatsu has joined #ruby
fdhsfdsgdsg has joined #ruby
d3vic3 has joined #ruby
iocor has joined #ruby
sacarlson has joined #ruby
vereteran has joined #ruby
<alesguzik> barraponto: iirc <% do_something -%>
<barraponto> alesguzik: that's what i'm using
<barraponto> alesguzik: it is the first line of the erb file, idk if it matters.
internet_user has joined #ruby
<JonnieCache> maybe you need a - on the opening tag as well
<JonnieCache> or instead of iirc
choffstein has joined #ruby
tdelam has joined #ruby
bagratte has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has quit [#ruby]
<barraponto> JonnieCache: this is a compass extension, i don't know where compass declares the trim mode.
<JonnieCache> im not a fan of compass, too heavy for me. if I were doing some massive site with loads of complex styling it might be useful, but it was overkill for the small project i tried it on
al3xnull has joined #ruby
zenChild has quit [#ruby]
jesly has joined #ruby
<darthdeus> anyone here familiar with VCR? I keep on getting WebMock::NetConnectNotAllowedError, even though the whole test is wrapped in VCR.use_cassette
drbawb has joined #ruby
drbawb has joined #ruby
virunga has joined #ruby
hien has joined #ruby
Sailias|work has joined #ruby
speggey has joined #ruby
philcrissman has joined #ruby
burns180_ has joined #ruby
bagratte has joined #ruby
pnh7 has joined #ruby
cantbecool has joined #ruby
vereteran has joined #ruby
<pnh7> Hi, I'm getting some problem with rhtml file . when I try to use require 'twitter' on apache , it gives some error . but it works with all internals gems (like erb) ... i'm getting same error with all the external gems. what might be the problem? error:http://pastebin.com/xRn8mqW1
bagratte has quit [#ruby]
glosoli has joined #ruby
havenn has joined #ruby
bagratte has joined #ruby
lorandi has joined #ruby
phantasm66 has joined #ruby
vereteran has joined #ruby
d34th4ck3r has joined #ruby
cantbecool has quit ["Textual IRC Client: http://www.textualapp.com/"]
crankycoder has joined #ruby
crankycoder has joined #ruby
kevinbond has joined #ruby
vraa has joined #ruby
phantasm66 has joined #ruby
IAD has joined #ruby
shruggar has joined #ruby
<barraponto> JonnieCache: i guess the tight integration it gets with rails and other ruby frameworks are to blame for the compass reputation. elsewhere (django, drupal) we just compile locally and put the css in the server.
<barraponto> JonnieCache: it can be done like that in rails as well, but the integration lures everyone into it.
shruggar has joined #ruby
<JonnieCache> yeah, its also that theres just *too much css.* obviously you can include only what you want but it meant everything took longer because i had to decide if it could be done in a compassy way or not
<barraponto> JonnieCache: hm, i usually use compass for css3, sprites and grid. but it suited my work, since i already used that before.
carlyle has joined #ruby
bagratte has quit [#ruby]
bagratte has joined #ruby
<JonnieCache> ive just climbed on the twitter bootstrap bandwagon and i must say i like it a lot
<JonnieCache> it has the things i want but its very simple
iocor has joined #ruby
<JonnieCache> i could quite happily delete it at some point, and my site wouldnt fall apart, id just have to patch up some gaps
bagratte has quit [#ruby]
bagratte has joined #ruby
Jackneill has joined #ruby
bagratte has joined #ruby
TaTonka has joined #ruby
mdw_ has joined #ruby
zomgbie has joined #ruby
Guest__ has joined #ruby
barraponto has quit [#ruby]
DRMacIver has joined #ruby
<roolo> #rufus-scheduler Is it possible to instruct rufus to ommit scheduled task if it's other instance running? Let's say this script
<roolo> Produce this weird intervals
bglusman has joined #ruby
<roolo> okey it's too weird :)
phantasm66 has joined #ruby
<roolo> This is correct :)
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
akemrir has joined #ruby
kartouch has joined #ruby
fdhsfdsgdsg has joined #ruby
burns180 has joined #ruby
PragCypher has joined #ruby
fdhsfdsgdsg has joined #ruby
mkscrg has joined #ruby
Seppman has joined #ruby
iocor has joined #ruby
speggey_ has joined #ruby
theRoUS has joined #ruby
theRoUS has joined #ruby
tayy has joined #ruby
v0yager has joined #ruby
sacarlson has joined #ruby
pnh7 has joined #ruby
fbernier has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
v0yager has joined #ruby
fdhsfdsgdsg has joined #ruby
fdhsfdsgdsg has joined #ruby
namidark has joined #ruby
Indian has joined #ruby
fdhsfdsgdsg has joined #ruby
coucher has joined #ruby
Drewch has joined #ruby
<ekaleido> 10.183.252.22 - - [02/Mar/2012:13:59:55 +0000] "GET /05-04-2011/bayly-iba-recibir-una-embajada/ HTTP/1.1" 200 1663 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
<ekaleido> 10.183.252.22 - - [02/Mar/2012:14:17:13 +0000] "GET /community/blog/owner/Adam HTTP/1.0" 301 0 "http://webbtrain.us/community/blog/owner/Adam" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"
<ekaleido> 10.183.252.22 - - [02/Mar/2012:14:17:16 +0000] "GET /community/blog/owner/Adam/ HTTP/1.0" 200 4267 "http://webbtrain.us/community/blog/owner/Adam/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"
<ekaleido> 10.183.252.22 - - [02/Mar/2012:14:40:27 +0000] "GET / HTTP/1.1" 200 4280 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"
<ekaleido> 10.183.252.22 - - [02/Mar/2012:14:47:41 +0000] "GET /?feed=rss2 HTTP/1.1" 404 853 "-" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.19; aggregator:Spinn3r (Spinn3r 3.1); http://spinn3r.com/robot) Gecko/2010040121 Firefox/3.0.19"
<ekaleido> agh, sorry
<glosoli> eka: pastie.org
fdhsfdsgdsg has joined #ruby
<glosoli> ekaleido: this was meant for you
lorandi has joined #ruby
DRMacIver has quit [#ruby]
pdtpatr1ck has joined #ruby
speggey has joined #ruby
<ekaleido> yeah i apparently have a trigger happy middle finger and logs in the buffer
aibo has joined #ruby
davidpk has joined #ruby
speggey has joined #ruby
bglusman has joined #ruby
langbiangplaza has joined #ruby
BrianJ has joined #ruby
axl_ has joined #ruby
tommyvyo has joined #ruby
dhruvasagar has joined #ruby
kpshek has joined #ruby
archaic has joined #ruby
Foxandxss has joined #ruby
<JonnieCache> e
burns180_ has joined #ruby
speggey has joined #ruby
mengu_ has joined #ruby
mengu_ has joined #ruby
denom has joined #ruby
<JonnieCache> hmm that vim mode extension was fun but i remembered why i stopped using firefox. cant believe its still such a resource hog
skim1776 has joined #ruby
jesly has joined #ruby
<skim1776> hey there
idletom has joined #ruby
gener1c has joined #ruby
gener1c has joined #ruby
d3vic3 has joined #ruby
srp_ has joined #ruby
tayy_ has joined #ruby
shruggar1 has joined #ruby
fayimora has joined #ruby
techhelp has joined #ruby
wallerdev has joined #ruby
danishkhan has joined #ruby
berserkr has joined #ruby
Sailias|work has joined #ruby
ghostlines has joined #ruby
machine1 has joined #ruby
albemuth has joined #ruby
namidark has joined #ruby
sacarlson has joined #ruby
burns180_ has joined #ruby
danishkhan has joined #ruby
machine1 has joined #ruby
iocor has joined #ruby
glosoli has joined #ruby
coucher has joined #ruby
fayimora_ has joined #ruby
dr_bob has joined #ruby
wyhaines has joined #ruby
snip_it has joined #ruby
mikepack has joined #ruby
havenn has joined #ruby
carlyle has joined #ruby
denom has joined #ruby
DrShoggoth has joined #ruby
zomgbie has joined #ruby
Kleggas has joined #ruby
ckrailo has joined #ruby
munx has joined #ruby
nachtwandler has joined #ruby
vraa_ has joined #ruby
ckrailo_ has joined #ruby
macmartine has joined #ruby
td123 has joined #ruby
CheeToS has joined #ruby
ceej has joined #ruby
baroquebobcat has joined #ruby
MasterIdler has joined #ruby
lkba has joined #ruby
coreydaley has joined #ruby
tayy has joined #ruby
danishkhan has joined #ruby
KL-7 has joined #ruby
fayimora has joined #ruby
sunaku has quit [#ruby]
carlyle has joined #ruby
sizz_ has joined #ruby
burns180 has joined #ruby
asdfdsfjnick has joined #ruby
g0bl1n has joined #ruby
johndbritton has joined #ruby
munx has joined #ruby
theRoUS has joined #ruby
Jake232 has joined #ruby
<Tasser> do we have a simple machine learning gem?
NotMyself has joined #ruby
ckrailo has joined #ruby
<asdfdsfjnick> I keep running out of memory with my multi-dimensional array. Can I use malloc() and free() to solve my problem? How to use them? Will this work with my pastebin code? http://pastebin.com/19ksR8eE int array=malloc(71*49*33); /*initialize array*/char array[71][49][33]=...; /*draw pixels*/ free(array); /* re assign array vars*/array[1][2][3]=...*/ /*draw pixels again*/
<Tasser> ouch
ckrailo has joined #ruby
adamjleonard has joined #ruby
lorandi has joined #ruby
speggey has joined #ruby
jgrevich has joined #ruby
ePirat has joined #ruby
<td123> Tasser: you're probably better off searching for a specific algorithm
<td123> Tasser: there is an ml gem
zen_ has joined #ruby
CodeZombie has joined #ruby
<ePirat> anyone can help me finding a weird ruby problem? I keep getting following error: "/home/MyUsername/.rvm/gems/ruby-1.9.2-p290/gems/dm-core-1.2.0/lib/dm-core/associations/relationship.rb:226:in `rescue in parent_model': Cannot find the parent_model Suggestion for Vote in suggestion (NameError)" and don't know why…
danishkhan has joined #ruby
<stenno50> ePirat, are Suggestion and Vote your own classes or are they provided by datamapper?
[-mX-] has joined #ruby
<stenno50> oh wait
<ePirat> stenno50, own classes
<stenno50> never mind
<stenno50> eh
<stenno50> so Vote inherits from Suggestion..?
<stenno50> or at least it looks like that for me
<ePirat> Vote is child of Suggestion
eywu has joined #ruby
tewecske has joined #ruby
<ePirat> but the code seems fine, it worked before, now after installing ubuntu 11.10 and rvm ruby/gem I keep getting this error :/
zen_ has joined #ruby
<stenno50> hmm
chrisrhoden has joined #ruby
<stenno50> so what is your ruby version now? maybe it was changed from 1.8 to 1.9 and something is different in the syntax
artOfWar has joined #ruby
<ePirat> ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
<stenno50> was it 1.9 before the update too..?
<ePirat> yes
<stenno50> hmm no idea then, sorry, i never saw stuff like that before
<stenno50> maybe you made a typo somewhere or something, best i can offer heh :)
enherit has joined #ruby
pandora17 has joined #ruby
<ePirat> stenno50, could you try if you are able to run the code? then i would know if it's an issue with my ruby/rvm/gem
rippa has joined #ruby
<hashpuppy> I want this module's search definition to behave differently for an array than for ActiveRecord. could i mixin in ActiveRecordSearchFunctions and then Search? and Search.search relies on ActiveRecordSearchFunctions.func1, func2, and func3. Same thing for ArraySearchFunctions.func1, func2, and func3
<hashpuppy> not sure if that makes sense
sacarlson1 has joined #ruby
<stenno50> ePirat, could you provide me a pastie..?
<ePirat> stenno50, it's on github: https://github.com/mutewinter/Showbot
startling has joined #ruby
<ePirat> stenno50 I am using the same code, just translated strings and adjusted url's. but already tried with "clean" git too without success
blueadept has joined #ruby
blueadept has joined #ruby
pandora17 has joined #ruby
<ePirat> trying to deal with the problem since a week now :/
crescendo has joined #ruby
<stenno50> ok lets see
akemrir has joined #ruby
<stenno50> props for using sinatra
speggey has joined #ruby
pencilcheck has joined #ruby
rippa has joined #ruby
namidark has joined #ruby
tyman has joined #ruby
philips has joined #ruby
Spockz has joined #ruby
scalebyte has joined #ruby
artOfWar has joined #ruby
Morkel has joined #ruby
cdabba_ has joined #ruby
medik has joined #ruby
Sphearion has joined #ruby
sacarlson has joined #ruby
<scalebyte> I have a class Profile in which I have serialized an attribute "detail" to pass values to it as hash. Now i do something like this to enter values to the attribute Profile.new.detail = { :Education => ["Degree", true] } it works fine but if i have something like this Profile.new.detail = { :My Education => ["Degree", true] }it throws error since my eduction isnt a single word
burns180_ has joined #ruby
hobodave has joined #ruby
<scalebyte> Si coul do something like this Profile.new.detail = { :"My Education" => ["Degree", true] } ie to pass it as a string
<scalebyte> but the issue is when i display the content wont the quotes also come along with it ?
apow has joined #ruby
<akemrir> did you tried %Q?
nemesit|osx has joined #ruby
<akemrir> for example %Q|{ :"My Education" => ["Degree", true] }|
<akemrir> bit it will be passed as string
TaTonka has joined #ruby
hooper has joined #ruby
<cdabba_> how can i use Find.find on a network director (ie: someip/SHARED)
<scalebyte> akemrir: yes it will be passed as string so while editing also i will have to do something like this profile.detail[:"My Hobby"]
<scalebyte> akemrir: so what is the alternative to get this implemented
<scalebyte> akemrir: so what is the alternative to get this implemented ?
PragCypher has joined #ruby
havenn has joined #ruby
<akemrir> scalebyte: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-c-serialize , and search for "Saving arrays, hashes, and other non-mappable objects in text columns" ;)
neurodrone has joined #ruby
neurodrone has joined #ruby
<scalebyte> akemrir: ok leme look at it
fayimora has joined #ruby
namidark has joined #ruby
mdw has joined #ruby
wmoxam has joined #ruby
speggey has joined #ruby
adamjleonard has joined #ruby
kpshek has joined #ruby
<scalebyte> akemrir: https://gist.github.com/1959254 this is my exact issue
<scalebyte> akemrir: and the api doesnt answer it as far as I know !!
<akemrir> scalebyte: I know where you have bug
<scalebyte> akemrir: where is it ?
<scalebyte> akemrir: it would be very helpful if u cud help me since I have been trying since the past 2 hours to fix this issue...
<akemrir> scalebyte: Profile.new.detail = { :"My Hobby" => ["Cook", false] } key of hash must be within quotation marks
headius has joined #ruby
Travis-42 has joined #ruby
<akemrir> scalebyte: of course when he have spaces within name
poolyco has joined #ruby
<scalebyte> akemrir: so how wud it be like ?
<poolyco> I keep running out of memory with my multi-dimensional array. Can I use malloc() and free() to solve my problem? How to use them? Will this work with my pastebin code? http://pastebin.com/19ksR8eE int array=malloc(71*49*33); /*initialize array*/char array[71][49][33]=...; /*draw pixels*/ free(array); /* re assign array vars*/array[1][2][3]=...*/ /*draw pixels again*/
<scalebyte> akemrir: i hope my migration and Profile class are correct and do I really need serialize :detail, Hash in Profile ? wont serialize :detail suffice ? I mean is that comma hash really required ?
banisterfiend has joined #ruby
<ePirat> stenno50, i did not made this, it was mutewinter
<stenno50> yeah i failed a bit installing
<stenno50> n/m i don't have an ide
<stenno50> a
<akemrir> scalebyte: do you wanna to have multiple hobbies shared across mutliple users?
<scalebyte> akemrir: actually user has_a profile and each users can create multiple details abt himself. so here Hobby will be the label and Cooking the value of it
<scalebyte> akemrir: so I am implementing it using hashes without having to affect the db schema and also users can have different less or more details abt themselves .
<akemrir> scalebyte: searching for users with same hobby may be tricky ;)
<ePirat> stenno50 Thanks a lot anyway, you tried at least to help me :)
<scalebyte> akemrir: that will not happen
<scalebyte> akemrir: this is just for displaying
<scalebyte> akemrir: but anyhow hw cud I get this done ?
<akemrir> scalebyte: Profile.new.detail = { :"My Hobby" => ["Cook", false] } and then Profile.find(1).detail[:"My Hobby"] or in view evaulate as like for normal hash
speggey_ has joined #ruby
iocor has joined #ruby
<akemrir> scalebyte: when users type in next attribute, put it in quotation marks automatically. You can erase quotation marks with gsub or special helper in view
<akemrir> scalebyte: use after_* to update details
kidoz has joined #ruby
Helius has joined #ruby
oscar has joined #ruby
cloke has joined #ruby
hasrb has joined #ruby
ascarter has joined #ruby
<scalebyte> akemrir: this seems to be terribly complex to implement
burns180 has joined #ruby
<scalebyte> akemrir: so u mean i need to automatically before saving put the has name inside quotes
<akemrir> scalebyte: maybe use redcloth or other markdown, then users could wrote their details without problems :)
sacarlson has joined #ruby
<scalebyte> akemrir: what is redcloth ?
<akemrir> Textile markup language
ed_hz_ has joined #ruby
bglusman has joined #ruby
<scalebyte> akemrir: bt again if a user enter a value like hobby" mistakenly then while saving it wud b saved as "hobby
pantsman has joined #ruby
pantsman has joined #ruby
<scalebyte> akemrir: saved as "hobby""
<akemrir> scalebyte: remove quotation marks before and then add own ;)
<scalebyte> akemrir: which can create problems :)
<scalebyte> akemrir: all the time... dude i freaking :)
<akemrir> scalebyte: gsub(/\"/, "") will be optional
<akemrir> scalebyte: this will search for quotation marks, and remove when found
<scalebyte> akemrir: hmm... but is there a better way i can implement the whole thing using serilization ?
<scalebyte> akemrir: yes gsub(/\"/, "") could be a nice option
andrewhl has joined #ruby
<akemrir> scalebyte: dou you use in form lot of javascript? :)
<scalebyte> akemrir: another doubt i had was if i already have Profile.new.detail = { :"My Hobby" => ["Cook", false] } and then wanna add a new detail after that hw wud I be able to do it ?
<scalebyte> akemrir: i havent started doing its view/// dont scare me :)
i8igmac has joined #ruby
<akemrir> scalebyte: first step, you read data from database and pass it to edit view
<scalebyte> yes
<akemrir> scalebyte: then add couple of form areas to put new data
<akemrir> scalebyte: before saving convert all data to new hash, with old and new
<scalebyte> akemrir: i just need the code.. hw cud I add new hash into Profile /
<scalebyte> akemrir: ok
<akemrir> scalebyte: user have one profile ? with association has_one?
chaitanya_ has joined #ruby
<scalebyte> akemrir: so u want me fto irst take a backup and then add new also to it and save
<scalebyte> akemrir: user has_one profile and profile belongs _to user
<akemrir> scalebyte: @user = User.find(1), in view @user.profile.detail will be this hash
<scalebyte> akemrir: in the view doing @user.profile.detail will fetch all hashes
chaitanya_ has joined #ruby
cbuxton has joined #ruby
<akemrir> scalebyte: yes, loop over them :) and you are in home
Marius has joined #ruby
<scalebyte> akemrir: but to update new hashes
ksinkar has joined #ruby
<scalebyte> akemrir: ^^ is wt i am confused abt
<akemrir> scalebyte: you can render form with pasted in values
<ksinkar> how do i include my fileutils library into my program? include FileUtils does not work
<akemrir> require 'filetutils' ;)
kenperkins has joined #ruby
davidcelis has joined #ruby
maletor has joined #ruby
<scalebyte> akemrir: ok after I render a form fetch the values till the controller and then wt i need to do is my doubt !! :_
<scalebyte> akemrir: to update/edit the new hashes
snip_it has joined #ruby
jergason has joined #ruby
<akemrir> scalebyte: if you have doubts, test it in console first
<any-key> when in doubt, REPL the shit out of it
<akemrir> yeah :)
<scalebyte> akemrir: i dnt know the code to update a new hash to the existing one thats the problem :)
<any-key> making a new hash from an existing one?
<any-key> sounds like deep copy...muahahaha
<akemrir> scalebyte: data passed from form is passed in params hash, debug it in controller in update action
apeiros_ has joined #ruby
sdwrage has joined #ruby
<any-key> also if you want debug output do logger.info("string") and it'll appear in the console
Araxia has joined #ruby
<scalebyte> akemrir: I know that what u saying is what I need to do... but programatically I think i will create a new hash each time deleting the existing one and push it to the db
<scalebyte> akemrir: that shud do I guess....
<akemrir> scalebyte: yes, rails will update database column removing old data
lkba has joined #ruby
<akemrir> scalebyte: when you pass data from form in update, old data will be there. Nothin will be lost :)
<any-key> just sit back and let rails do its thing...
<scalebyte> akemrir: hw cud i use gsub(/\"/, "") on a variable like on something like Profile.new.detail = { :"Education" => ["Deg"ree"", true], } ?
<akemrir> scalebyte: before_save :custom_def
<akemrir> scalebyte: you can modify data before saving to database
briankbuckley has joined #ruby
<scalebyte> akemrir: yes bt how to remove all the quotes from the data using gsub(/\"/, "")
<akemrir> scalebyte: I think detail column will be accesible in model
csherin has joined #ruby
<akemrir> scalebyte: loop thru detail in this custom definition, and modify only keys
<scalebyte> akemrir: yes like profile.attributes.[ :education]
amerine has joined #ruby
<akemrir> scalebyte: no
<scalebyte> sorry profile.attributes[ :education]
<akemrir> scalebyte: read the docs
<akemrir> scalebyte: you can use each_key
speggey has joined #ruby
<any-key> or any_key
<scalebyte> akemrir: ok
<stenno50> or just iterate over keys
<stenno50> hash.key
<stenno50> er
greenarrow has joined #ruby
<stenno50> hash,keys gives an array of the keys
<stenno50> hash.keys, gah
<akemrir> thats right :)
<scalebyte> akemrir: and hw to use gsub(/\"/, "") to remove quotes
<stenno50> o_O"
theRoUS has joined #ruby
<stenno50> just call it on the enumerator...
<akemrir> hash.keys.each { |key| key.gsub(/\"/, "") } : >
<apeiros_> meep, wrong
cloudgeek has joined #ruby
<apeiros_> .keys.each is *always* wrong. use .each_key.
<stenno50> oh
<stenno50> why is that?
<apeiros_> no need to generate temporary arrays.
s_dana has joined #ruby
<scalebyte> apeiros_: so hw wud it be like ?
<apeiros_> lots of useless work.
<stenno50> meh
<akemrir> thats good point
<stenno50> but you got a point
<stenno50> yeah
<scalebyte> and what is this : > at last ? :)
<apeiros_> scalebyte: is your keyboard broke or do you just utterly fail to articulate properly?
<stenno50> lol
<apeiros_> *broken
<stenno50> scalebyte, emoticon :)
<scalebyte> apeiros_: akemrir : could you correct this hash.keys.each { |key| key.gsub(/\"/, "") }
<scalebyte> hash.each_key { |key| key.gsub(/\"/, "") }
<akemrir> scalebyte: hash.each_key { |key| key.gsub(/\"/, "") }
<apeiros_> well, for starters, in your example it wasn't the key that needed gsubbing
<Hanmac> in 1.9 you can connect each & other functions like map or other without creating temporal arrays
<apeiros_> to continue, key.gsub in that loop won't do anything
<stenno50> would return a new hash
<apeiros_> you'd want gsub!
<apeiros_> but then your hash is broken
burns180 has joined #ruby
<stenno50> apeiros_, does gsub! work in each_key?
adamkittelson has joined #ruby
apok has joined #ruby
<scalebyte> apeiros_: i wanted the hash name probably to need gsub
<apeiros_> stenno50: yes, but you must rehash then.
deryldoucette has quit [#ruby]
deryldoucette has joined #ruby
deryldoucette has quit [#ruby]
deryldoucette has joined #ruby
<apeiros_> so to sum it up: hash.each_key do |key| key.gsub!(/\"/, "") end; hash.rehash
<apeiros_> also, to remove characters, we have String#delete!
<deryldoucette> damn. channel was locked up in my client for some reason. weird
gyre007 has joined #ruby
<akemrir> and of course, no spaces allowed in keys
<stenno50> or hash = hash.each_key {|key| key.gsub(/\"/, "")}
<apeiros_> so we get: hash.each_key do |key| key.delete!('"') end; hash.rehash
<apeiros_> stenno50: try that in irb
<apeiros_> it doesn't do what you think it does
<scalebyte> apeiros_: so for this example Profile.new.detail = { :"Education" => ["Deg"ree"", true], }
<scalebyte> apeiros_: what needs gsub
<apeiros_> scalebyte: the value
<akemrir> first element of value
<apeiros_> ^
<scalebyte> apeiros_: and what do u call :"Education" ?
<akemrir> :)
<apeiros_> key
<stenno50> scalebyte, correct spelling :)
<apeiros_> hash = {key => value}
bagratte has joined #ruby
<apeiros_> also that. u look liek n eediot if u speel lik dat
<scalebyte> apeiros_: ok so what i need is once i get the key from the users i need to remove all the existing quotes from the ends of the variable like education" or "education and then save it as "Education"
<scalebyte> apeiros_: hash.each_key do |key| key.gsub!(/\"/, "") end; hash.rehash should do that right !!
<apeiros_> actually, { :"Education" => ["Deg"ree"", true], } is a syntax error
<apeiros_> "Deg"ree"" <-- that ain't valid ruby.
BiHi has joined #ruby
<stenno50> either "Deg\"ree\"" or "Deg'ree'"
mrsolo has joined #ruby
<any-key> or 'Deg"ree'
i8igmac has joined #ruby
<any-key> single quote is like a honey badger
<stenno50> or %{Deg"ree}
<i8igmac> any one ever script with autoit and the scite editor
chaoslynx has joined #ruby
<apeiros_> i8igmac: yes
<scalebyte> apeiros_: aint value in a hash string so it shud accept all everything ryt ?
<apeiros_> someone at some time certainly did
luxurymo_ has joined #ruby
<i8igmac> the editor could guess your array or string almost like a tab compleation
jesly has joined #ruby
odinswand has joined #ruby
<scalebyte> apeiros_: %{Deg"ree} will do
<apeiros_> scalebyte: I can't read your question
<apeiros_> actually I don't want to
<chaoslynx> i am trying to install instiki, but i get /rails/activesupport/lib/active_support/d84:in `require': cannot load such file -- admin_helper (LoadError)
pdtpatr1ck has joined #ruby
<i8igmac> TCPS{tab} => TCPSocket.n{tab}
<scalebyte> apeiros_: see in Profile.new.detail = { :"Education" => ["Deg"ree"", true], } its the user who enters both education and degree.. and so if he enters my education.. it wudnt work sine its not a single word so i need to have it in string while saving it
<i8igmac> is there a editor that could do the same as scite did for autoit... tab compleation like plugin/function
<chaoslynx> does someone run instiki 1.9.3 on a linux machine here?
<chaoslynx> *19.3
robbyoconnor has joined #ruby
<akemrir> chaoslynx: what is instiki?
trivol has joined #ruby
<deryldoucette> wiki engine it seems
<scalebyte> apeiros_: akemrir :u know what I was just complicating it i just need to do key.to_string
<scalebyte> akemrir: u cud have given me that idea long back :)
<deryldoucette> current is 0.19.3 according to google
<chaoslynx> akemir: wiki engine
<deryldoucette> instiki.org for curiosity factor
<akemrir> chaoslynx: thanks, I was thinkin that was misstype -> install :P
<i8igmac> are there any fancy editors that you guys might recomend... useful tools for ruby
<deryldoucette> what are oyu on?
<deryldoucette> err you
<chaoslynx> what actually fails is Erubis 2.7.0
<akemrir> i8igmac: vim is very fancy ;)
<deryldoucette> vim+snipmate plugin (for your own custom TextMate-like snippets), TextMate with GetBundle, RubyMine if you need a full freakin IDE or something, or Aptana Studio
<deryldoucette> should give you a nice progression from simplistic to madly overly complex
zomgbie has joined #ruby
<akemrir> I`ve recently test ultisnips
<akemrir> for vim of course
<deryldoucette> been having some problems witht hat
<akemrir> syntax errors from python? :)
<scalebyte> apeiros_: akemrir : many many thanks for being patient enought to listen to me and suggest solutions.. u guys rock !!
<deryldoucette> yeah on startup of vim
<deryldoucette> not even working on python code (which i dont)
<akemrir> no, no... errors within ultisnips in python
chaoslynx has quit [#ruby]
<deryldoucette> kept telling my python wasn't installed (python) but python2.6 is installed
<deryldoucette> stuff like that
<deryldoucette> oh no not that
<akemrir> utlisnips have switch to python 3 ;)
<deryldoucette> yeah tried that too
<deryldoucette> actually ended up installing several pythons up and down the version chain trying to see which it was looking for since the error wasn't clear.
<deryldoucette> just said 'python' not a version
<deryldoucette> still didn't work
<akemrir> snipmate can generate list of snippets for current type of document?
<deryldoucette> said screw it and went back to snipmate
<deryldoucette> that i don't know. that would be nice. i handrolled my own
adeponte has joined #ruby
<akemrir> own function ? nice
rawbeef64 has joined #ruby
<deryldoucette> would rock if you could feed it say a directory of ruby code and have it go through each .rb file and generate skeletons and save to ruby.snippets :)
rawbeef64 has quit [#ruby]
<deryldoucette> no no manually wrote ruby.snippets additionals
vraa has joined #ruby
<geekbri> Is there a way to tell minitar not to follow symlinks and copy the files and to just copy the actual symlink itself?
<deryldoucette> though that might be a project worthwhile to do. write a ruby script to parse rb files and generate a ruby.snippets
<deryldoucette> akemrir: hey thanks! thats an idea!
<akemrir> deryldoucette: no problem ;)
sacarlson has joined #ruby
<deryldoucette> should help make my ruby-fu strong :) (its rather.. ehh right now I think)
<akemrir> deryldoucette: try <Ctrl>-R <Tab>
<deryldoucette> in?
<akemrir> deryldoucette: in ruby document
burns180_ has joined #ruby
<akemrir> deryldoucette: I does not have snipmate installed. Tell me if that works
<deryldoucette> yeah but what editor? vim? and with which? ulti or SM?
<akemrir> vim
<deryldoucette> oh sec
havenn has joined #ruby
speggey_ has joined #ruby
<deryldoucette> oh snap
<deryldoucette> gikves me a whole list of stuff
<akemrir> uuu :)
callenb has joined #ruby
<akemrir> works?
<deryldoucette> yeah
<deryldoucette> sweet. didn't know about that
<akemrir> I`am heading back to snipmate
<deryldoucette> but its not language specific
<deryldoucette> all it does is give a list and you have to scroll through it. not context sensitiev
<deryldoucette> s/ev/ve/
skipper has joined #ruby
<akemrir> I`ll try that anyway
robbyoconnor has joined #ruby
<deryldoucette> ahh i get it
Russell^^ has joined #ruby
MrGando has joined #ruby
<deryldoucette> do this. vim t.rb and then in it, do def<tab> and name the finc then tab again to get into the func, then start typing like say Array (Ar<tab>)
tdelam has joined #ruby
<deryldoucette> then it works sort of
ascarter has joined #ruby
<deryldoucette> and it screws up. if you type Ar<tab> it lowercases array but it DOES complete the word
<akemrir> this is omnicomplete, not snippet
<deryldoucette> i dont have that installed
<deryldoucette> oh you mean omnicomplete as in global complete nm
chrisrhoden has quit [#ruby]
Spockz has joined #ruby
<deryldoucette> do you use pathogen for loading your plugins?
<deryldoucette> well managing and loading of course
<akemrir> yes, It helps a lot
<deryldoucette> btw, another thing you might want to check out is NERDTree
<akemrir> but, don`t overload it with plugins
<deryldoucette> great with projects ruby or rails
<deryldoucette> yeah i don't have many i think i have like 6 or 8
jrist has joined #ruby
<akemrir> I use Command-T, and vim-rails
<akemrir> to move within project
robbyoconnor has joined #ruby
al3xnull has joined #ruby
gianlucadv has joined #ruby
<deryldoucette> what i want that i can't seem to get snippet to do or figure out how to get set up is matched closings. aka if I add { I want <space> } to be added
<deryldoucette> like { }
voodoofish430 has joined #ruby
<deryldoucette> forget what they call that. the act of doing that
<akemrir> I see from that list, all snippets are lowercase
munx has joined #ruby
<akemrir> It can be helpfull
<deryldoucette> ctl T for me just does the indentation. cmd t is mapped to opening a new iTerm2 tab for me
hadees has joined #ruby
dootdoot_ has joined #ruby
<deryldoucette> bbiaf. i want to google that again. see if i can figure out how to get it to auto-add closing matching braces and stuff
nfluxx has joined #ruby
<akemrir> deryl that shortcut creates list speficic to file type in my case
<akemrir> <c-r><tab>
ryannielson has joined #ruby
<deryldoucette> if i get vim to act completely like TextMate, I'll have less reason to use it and stick with vim :)
Targen has joined #ruby
<akemrir> wait moment
<deryldoucette> err? it gives me stuff like asm
<deryldoucette> what does asm have to do with ruby?
<deryldoucette> or dow
<apeiros_> inline_asm? :)
<deryldoucette> apeiros_: hehe. ruby does that? ;)
badabim has joined #ruby
<deryldoucette> akemrir: thanks
<apeiros_> yes
<apeiros_> zenspider wrote it
<deryldoucette> apeiros_: oh wow, seriously??
<deryldoucette> damn learn something new every day hanging out in here. love it!
<apeiros_> I guess after inline_c it wasn't that big of a leap anymore :)
<deryldoucette> i seriously didn't know ruby supported anything even close to that
francisfish has joined #ruby
<apeiros_> it's not ruby itself that supports it
<apeiros_> it's a gem that adds it
<deryldoucette> then agian there is tons of stuff about ruby i don't know
<deryldoucette> ahh
<akemrir> deryldoucette: btw, vim highlights pair of brackets. You will se something is missing.
<deryldoucette> sec. lemme open that url before it flows off my screen. i'm typing on another box
<deryldoucette> akemrir: only when your cursor is over one of the braces and you don't see it hilight the matching
<akemrir> deryldoucette: use % ;)
<akemrir> to jump to his pair
<any-key> wootwoot Vim
<any-key> I figured out * today...it searches for the word under the cursor :D
<deryldoucette> hahah i was going to say that page was blank, but i spelled charactors
<apeiros_> deryldoucette: haha, oogling through seattlerb's stuff, I even found inline fortran :D
<deryldoucette> apeiros_: hahaha
<deryldoucette> my ex-wife would have loved that. she programmed in fortran and COBOL
<any-key> inline fortran?!
<any-key> fuck yes
driki has joined #ruby
<apeiros_> deryldoucette: https://github.com/seattlerb/wilson
<deryldoucette> niiice
<akemrir> deryldoucette: use this ;) http://michael.peopleofhonoronly.com/vim/
driki has quit [#ruby]
<deryldoucette> whats that
<akemrir> cheat sheet for vim
<deryldoucette> sec let me attach to this tmux on the mac damn it
<shevy> cool
<shevy> fortran and COBOL
pangur has joined #ruby
<shevy> they sure were hipsters back in the day
<deryldoucette> there we go
<deryldoucette> and i wonder why my chrome process takes so much memory. you guys keep feeding my url addiction :)
<any-key> use something like instapaper to keep track of shit you want to read :P
<any-key> it's more efficient than leaving a million tabs open :P
<deryldoucette> instapaper?
<dootdoot_> i have so much crap in my instapaper
<deryldoucette> ooo
burns180 has joined #ruby
<dootdoot_> i need to get better at actually reading the stuff i put in it
<deryldoucette> any-key: damn, why am i only hearing about this now! I've been using delicious.com to store my stuff
<any-key> deryldoucette: if you're reading stuff that's in an article format, check out readability; their new (free) service is like instapaper but better
waxjar has joined #ruby
<deryldoucette> dootdoot_: hehe yeah i lose so many URLs and only read about 1/2 of what i save :)
<deryldoucette> there an android app for them? nm, i'll check market
<any-key> I believe so
wyhaines has joined #ruby
<colinwd> should be
<any-key> a lot of apps integrate with instapaper, and readability has a web app for mobile stuff that's pretty slick
<colinwd> the ios app is really nice
<colinwd> and yeah the app integration is the best part
<deryldoucette> hey they're even smart about the REad Later javascript bookmark thing they have.
<shevy> hmm
<deryldoucette> if you're on their site and click it it deoesn't save a copy of that page it says it works correctly
<shevy> you guys have way too much fun doing non ruby things!
<deryldoucette> they actually check. (though if you really DO want to save that might be an issue)
<deryldoucette> shevy: hehe this is all FOR ruby stuff for me
<any-key> readability has a chrome plugin that lets you save it for later or convert it to an easily read format without saving it
<deryldoucette> hell i even have an app on my tablet that downloads and stores the entire ruby docs :)
<deryldoucette> (for offline work)
<colinwd> yeah i just downloaded Ruby Doc and Rails Doc for my phone and it's pretty rad
<deryldoucette> yeah i wanted those 2 specifically but they don't have a droid version
<deryldoucette> thats what got me hunting actually
<colinwd> ah yeah
<colinwd> i just learned about them yesterday
<deryldoucette> me, only a week ago
<deryldoucette> i use my tablet a LOT, especially when I'm coding. I sit with ebooks on it while i work through stuff ect. started wondering if there were apps for the docs and stuff.
<deryldoucette> if you have a droid too, check out devcheats
<colinwd> yeah that's the one reason i'd really love a tablet
<colinwd> nah i've got an iphone
<colinwd> having docs open separately is great though
<deryldoucette> yep.
<colinwd> the less i have to move around and resize windows the better
<deryldoucette> exactly
<deryldoucette> and i don't always have the extra monitor attached to the mbp. the asus transformer is always next to me. just easier
thecreators has joined #ruby
lurch_1 has quit [#ruby]
flak has joined #ruby
<shevy> hmm
makkura has joined #ruby
<scalebyte> how can i print the value of a key alone from a hash ?
akem has joined #ruby
akem has joined #ruby
<deryldoucette> puts "#{my_hash[:key]}" you mean?
<deryldoucette> or ['key']
startling has quit [#ruby]
<scalebyte> user.profile.detail.each do |profile| puts profile end ---- will return the key value pair hw can I get all the names of key alone?
<stenno50> each_pair
<deryldoucette> .keys
<stenno50> for example
<deryldoucette> oh you want the combo
virtuoussin13 has joined #ruby
<akemrir> maybe user.profile.details.each do |key,value| ??
<scalebyte> i have something like this
<scalebyte> <Profile id: 6, user_id: 2, detail: {:Education=>["", true], :College=>["", true]}, created_at: "2012-03-02 18:07:07", updated_at: "2012-03-02 18:07:07">
<stenno50> or profile[0]
<scalebyte> i need to print out just education and college
<scalebyte> and then the value pair
<virtuoussin13> When can weakreferences be garbage collected? Are they like SoftReferences in java where they may be garbage collected when memory runs low, or may they be garbage collected only when there are no other outstanding "hard" references to the object?
<stenno50> try with each_pair instead of each
<scalebyte> stenno50: ok
<stenno50> each_pair{|key, value| to be exact
kirun has joined #ruby
<scalebyte> stenno50: user.profile.detail.each_pair do |profile|
GiambalaGiambala has joined #ruby
<deryldoucette> stenno50: thanks. didn't know .each_pair
<stenno50> no
<scalebyte> stenno50: hw wud be the second line ?
<stenno50> oh
<stenno50> scalebyte, what
<stenno50> english please o_O"
<scalebyte> stenno50: user has_a profile so user.profile
<stenno50> ok
<scalebyte> stenno50: and detail is an attribute inside profile to store hashes
<stenno50> roght
<stenno50> right*
trivol has joined #ruby
<scalebyte> stenno50: so how can I ierate over the existing hashes ?
<virtuoussin13> oh it looks like WeakRef's requires finalizers, which don't work with frozen objects anyway
<stenno50> user.profile.detail.each_pair{|key, value puts "key: #{key} value: #{value}"}
<stenno50> oops
<stenno50> user.profile.detail.each_pair{|key, value| puts "key: #{key} value: #{value}"}
<stenno50> try that one
theRoUS has joined #ruby
<shevy> lol stenno50 "english please o_O" <-- hilarious!
<scalebyte> shevy: lol
<scalebyte> stenno50: thanks
<stenno50> no prob :)
burns180_ has joined #ruby
mk1 has joined #ruby
sarmiena_ has joined #ruby
CacheMoney has joined #ruby
PragCypher has joined #ruby
d34th4ck3r has joined #ruby
Norrin has joined #ruby
driki has joined #ruby
oooPaul has joined #ruby
akem has joined #ruby
Norrin_ has joined #ruby
<scalebyte> stenno50: http://stackoverflow.com/questions/9533383/how-can-i-implement-this-association/9534109#comment12080044_9534109 this is what I wannt get done. The first answer marked correct is what I am following but I am stuck up with the view part
bluOxigen has joined #ruby
bluOxigen has joined #ruby
pu22l3r has joined #ruby
davidpk has joined #ruby
n3m has joined #ruby
<stenno50> sorry, i didn't do rails in quite some time now
<stenno50> maybe just ask in #rubyonrails ?
bashdy has joined #ruby
shruggar has joined #ruby
kaneda_ has joined #ruby
gener1c has joined #ruby
gener1c has joined #ruby
<scalebyte> stenno50: ok thanks !!
hasrb has joined #ruby
speggey_ has joined #ruby
eldariof has joined #ruby
mxweas_ has joined #ruby
johndbritton has joined #ruby
jergason has joined #ruby
Indian_ has joined #ruby
v0yager has joined #ruby
trend has joined #ruby
akem has joined #ruby
sako has joined #ruby
speggey_ has joined #ruby
trend has joined #ruby
sonkei has joined #ruby
burns180 has joined #ruby
Alantas has joined #ruby
shruggar1 has joined #ruby
workmad3 has joined #ruby
idletom has joined #ruby
ilyam has joined #ruby
berserkr has joined #ruby
trkemist has joined #ruby
jergason has joined #ruby
davidpk has joined #ruby
iocor has joined #ruby
luckyruby has joined #ruby
mikewintermute has joined #ruby
tayy has joined #ruby
res0nat0r has joined #ruby
<mikewintermute> Any ideas why this list test doesn't work? http://pastebin.com/SWgdVtkQ
qdoom has joined #ruby
qdoom has quit [#ruby]
<oooPaul> mikewintermute, What's it doing, and what's it supposed to be doing? :)
<oooPaul> Oh, I know.
<oooPaul> x[1] == ("R"||"S")...
<Alantas> mikewintermute: "R"||"S" tries to evaluate them logically; if the string "R" or string "S" are true...
<oooPaul> ("R"||"S") is going to return "R" (because it's true.
<mikewintermute> updated the paste. Expect it to not print anything if the 2nd element in "list" is "R" or "S"
<Alantas> You probably want something like: x[1] == "R" or x[1] == "S"
<oooPaul> Change x[1]... to ["R", "S"].include?(x[1])
<oooPaul> On a performance note, consider changing your logic, too...
<mikewintermute> hmm - having a play now..
<oooPaul> print "not valid" if list.find{|x| !["R", "S"].include?(x[1])}
<Alantas> oooPaul: "all?" should fail as soon as one fails.
<oooPaul> Oh yeah.
<Alantas> (I had that thought too, but then I realized that.)
<oooPaul> It's Friday. :)
<Alantas> I blame the Leap Day, myself.
robbyoconnor has joined #ruby
iamjarvo has joined #ruby
cloke_ has joined #ruby
SeanLazer has joined #ruby
cloke has joined #ruby
tvo has joined #ruby
tvo has joined #ruby
badabim_ has joined #ruby
Eiam has joined #ruby
<mikewintermute> aah. makes sense now. thanks
robbyoconnor has joined #ruby
<gener1c> "R" || "D" always thought it would return true for some reason
<gener1c> but returning R is way cooler
<Alantas> gener1c: I thought so too at first. But that's C-style thinking. In Ruby, it'd evaluate to "R".
fr0gprince_mac has joined #ruby
<Alantas> Neat little trick: herp ||= derp
<gener1c> yeah
<gener1c> i love it
<Alantas> Sets it to 'derp' if it's false/nil. Neat way to initialize things.
<gener1c> initialize if not initialized already
<Alantas> (If 'herp' is false/nil)
<oooPaul> Ayup.
<oooPaul> Just watch out if herp is false and derp is nil.
<gener1c> oi
<oooPaul> That's bit me a few times.
<gener1c> then
burns180_ has joined #ruby
S1kx has joined #ruby
<gener1c> herp ||= derp unless !derp
<Alantas> or "... if derp"
<gener1c> yeah
<gener1c> herp ||= derp if derp
<gener1c> but i think it needs end
<Alantas> herp ||= derp || "hurr"
<Alantas> (Maybe...)
<gener1c> that could work
<oooPaul> gener1c, That fails if herp is nil and derp is false. :)
<Alantas> Yeah, it works.
<Alantas> Changes herp, but not derp.
<Alantas> (Just as planned.)
<oooPaul> herp = derp if herp.nil?
<gener1c> ur right paul
<gener1c> which is exactly my initial variant
<oooPaul> herp ||= derp # is great if you're never dealing with 'false' :)
<gener1c> herp ||= derp unless !derp
stephenjudkins has joined #ruby
<oooPaul> If derp is false, and herp is nil, that won't set herp to false.
<gener1c> yeah ur right
<Alantas> "unless !derp" and "if derp" should be completely equivalent.
<oooPaul> No logic really works if you're trying to deal with 'nil' and 'false'. In that case, you need to just explicitly check for 'nil'.
<Alantas> (Unless you can overload the unary bang operator? But I don't think you can.)
<gener1c> herp ||= derp || "hurr durr"
<oooPaul> HODOR.
<oooPaul> Sorry, GoT fever.
<Alantas> I don't recall any code offhand where nil and false were distinguished in the same context.
<Alantas> (That I've done.)
<gener1c> i mean
<oooPaul> I've had a few cases where I wanted/needed a variable to track a true/false value, but if it was nil, wanted it to be set based on some costly function.
<Alantas> Generally, "false" in opposition only to "true", and "nil" in opposition to anything else. (Is the principle I'd follow when deciding what should be assigned what.)
<oooPaul> So the whole foo ||= bar trick seemed like it was great, until I realized when bar returned 'false' I wouldn't get the caching effect I wanted.
undersc0re has joined #ruby
<Alantas> Ah. Yeah, in that case: herp ||= derp if herp.nil?
<oooPaul> At that point, you don't need the ||.
<oooPaul> herp = derp if herp.nil?
<Alantas> Oh. Yeah.
<Alantas> Leap day.
<oooPaul> :D
<gener1c> which means ||= is useless again :(
<Alantas> gener1c: Only in that particular case.
munx has joined #ruby
<gener1c> and this whole conversation didnt happen
<oooPaul> It's definitely a shorter way to write the logic, but only if you're never dealing with false.
<Alantas> Or never dealing with nil. One of the two.
<Alantas> Or generally, if you don't need to distinguish them.
<oooPaul> Rarely would I expect a variable to ACTUALLY maintain a true/false value. Usually it's just nil or "something".
<gener1c> the problem with duck typing is that you may never know
<gener1c> :P
odinswand has joined #ruby
<oooPaul> One time where I'm so glad that 0 (zero) is NOT considered 'false' in an evaluation.
<Alantas> String indexing?
robbyoconnor has joined #ruby
adambeynon has joined #ruby
<pangur> http://fpaste.org/JZvz/ is my latest attempt at creating Person instances from data.csv
<pangur> I get this error
<Alantas> Suggestion: @herp, @derp, @hurr = herp, derp, hurr
<pangur> undefined local variable or method `surname' for #<Sinatra::Application:0x84f934c> file: index.rb location: block (2 levels) in <main> line: 28
<Alantas> (Little shortcut. Doesn't change/fix anything.)
<oooPaul> pangur: You're not assigning the results of the split to anything.
<oooPaul> You never define what the parameters you're passing into Person.new are.
<oooPaul> (ie. surname, etc.)
<pangur> c = contents.split()
<Alantas> patron = Person.new(*c)
<Alantas> Try that, assuming the arguments line up. c[0] is the surname, etc
<oooPaul> Also, you probably want to do "readlines" on the CSV file, and then split *each line* -- what you have there is going to read the whole file and split on every comma...
<Alantas> And yes, that too.
<Alantas> Also, what's line 24 supposed to do? You're passing a block to "to_a"?
<pangur> wrong number of arguments (366 for 6) .....file: index.rb location: initialize line: 8
<Alantas> Yeah, see. You're slurping up the whole file.
<Alantas> Oh, try this: patron = Person.new(*patron)
<Alantas> In line 28.
<davidpk> that or use the CSV thing in the standard library...
<Alantas> patrons = File.new("data.csv").map{|line| line.strip.split(",")}.sort.map{|data| Person.new(*data)}
<pangur> NoMethodError at /undefined method `bytesize' for ["surname", "name", "4", "883", "X", ""]:Array file: utils.rb location: bytesize line: 281
<Alantas> Er, will need to close the file too. But yay one-liners.
<pangur> That was from Person.new(*patron)
<davidpk> which will properly handle commas inside field values, etc.
<davidpk> ^-- will make your life easier
<apeiros_> Alantas: I doubt that sort there is a good idea…
<apeiros_> unless you want the attributes to be in randomized order :-)
<apeiros_> oh, sorry
<Alantas> It's sorting arrays against each other, not sorting within the arrays.
<apeiros_> misread it to be after the .split
<oooPaul> Lunching. BBL.
<pangur> Thanks very much for the ideas oooPaulAFK
<pangur> Thanks to all
* pangur is reading davidpk's link
albemuth has joined #ruby
<Alantas> Throw in a <=> method in the Person class and you could sort it later.
<Alantas> patrons = Array.new; IO.foreach("data.csv") { |line| patrons << Person.new(*line.strip.split(",")) }; patrons.sort!
<pangur> The csv file is just one line of data.
<Alantas> They're all on one line? Ew.
odinswand has joined #ruby
<pangur> Is there an easy way to put them into 61 lines?
<davidpk> pangur: are you sure? how are you viewing it?
<pangur> eclipse
<pangur> I can see it in the eclipse text editor
<pangur> it 366 items
<apeiros_> p *person
<pangur> it is
<apeiros_> p *patrons
<Alantas> out = File.new("data2.csv", "w"); File.read("data.csv").split(",").each_slice(6) { |fields| out.puts(fields.map(&:strip).join(",")) }; out.close
<davidpk> Try looking for CRs or LFs or CRLFs. You could have some weird line-endings
<davidpk> otherwise
<Alantas> Or I guess just strip the File.read result and drop it from the inner loop. Heh.
<Alantas> File.open("data2.csv", "w") { |out| File.read("data.csv").strip.split(",").each_slice(6){|fields| out.puts(fields.join(",")) } }
kenichi has joined #ruby
<pangur> Thanks Alantas - that's it in 61 lines now
<davidpk> CSV.read('data.csv').first.each_slice(6) {|patron| … do stuff ... }
burns180 has joined #ruby
dv_ has joined #ruby
thecreators has joined #ruby
mxweas_ has joined #ruby
albemuth has joined #ruby
Dreamer3 has joined #ruby
ceej has joined #ruby
<jesly> i am working on ruby 1.9.2, and i tried loading another file via require , but shows an error no file to load, but the file does exist.
the_hack has joined #ruby
judd7 has joined #ruby
jsdrk has joined #ruby
<Alantas> I think that might be relative to the directory the script was run from, not the directory the script itself is in.
<judd7> Ruby syntax help, PLEASE! I need a push a whole bunch of strings that might or might not be set onto an array. response << thing.set? ? thing.string : otherthing.string
<Alantas> At least, it would explain this thing: require File.join(File.dirname(__FILE__), "lib", "sigfree_proxy.rb")
<judd7> something like that?
<Alantas> judd7: Looks okay, from that line alone.
<judd7> no way.
<judd7> Atlantas, I was totally just guessing.
<Alantas> Maybe use parentheses just in case: response << (thing.set? ? thing.string : otherthing.string) # or call push() instead of <<
<davidpk> use ./lib/sigfree_proxy.rb
heftig has joined #ruby
<Alantas> davidpk: That should be just the same as "lib/sigfree_proxy.rb". Redundant.
kenichi has joined #ruby
tatsuya_o has joined #ruby
<Alantas> jesly: Try the File.join thing I suggested: require File.join(File.dirname(__FILE__), "lib/sigfree_proxy.rb")
axl_ has joined #ruby
callenb has quit [#ruby]
Asher has joined #ruby
<jesly> Alantas: yea, u were r8, require loads from where script is running, fixed it with require_relative
darthdeus has joined #ruby
<Alantas> Or, yeah, there's that. Kids and their >1.8 these days.
coucher has joined #ruby
mxweas_ has joined #ruby
fixl has joined #ruby
fayimora has joined #ruby
<jesly> Alantas: hehe.. which ver are u on??
<Alantas> 1.8.7. I tried 1.9 but it doesn't have Ruby/Gtk.
<jesly> Alantas: never dreamed of gtk stuff yet, n00b :)
coreydaley has joined #ruby
<heftig> Alantas: there's also gir_ffi, new gobject bindings in development.
shruggar has joined #ruby
bgupta has joined #ruby
ph^ has joined #ruby
chimkan has joined #ruby
Choobie has joined #ruby
shruggar has joined #ruby
<judd7> Atantas: here's the code I'm hacking: response << "<node name=" + node.attribute?('fqdn') ? node[:fqdn] : node[:name] + "\n"
<judd7> Seems to be treating the ternary operator as a simple "true/false" and not returning the values of node[:fqnd] on true and node[:name] on false.
amerine_ has joined #ruby
<judd7> Hmm.. Hard to get your name right. :) Alantas
<Alantas> judd7: Could be precedence going haywire, hence what I said about parentheses. Also: response.push("<node name=\"#{node[node.attribute?('fqdn') ? :fqdn : :name]}\">")
<heftig> judd7: ternary has rather low precedence
<Alantas> And \n at the end before the last "
<heftig> lower than <<
zomgbie has joined #ruby
<heftig> so this is probably getting interpreted as: ( response << ("<node name=" + node.attribute?('fqdn')) ) ? node[:fqdn] : (node[:name] + "\n")
macabre has joined #ruby
<judd7> getting the "cant convert nil to string"
<Alantas> In other words, "herp << derp ? hurr : durr" being "(herp << derp) ? hurr : durr", rather than the intended "herp << (derp ? hurr : durr)"
<judd7> lol
burns180_ has joined #ruby
TaTonka has joined #ruby
davidcelis has joined #ruby
<i8igmac> with vim editor, can you auto orginize a sloppy script
<shevy> by using something called brain
<Alantas> i8igmac: I googled up "ruby lint". Looks like there's something there. Try it.
sgmac has joined #ruby
fbernier has joined #ruby
SQLDarkly has joined #ruby
<Eiam> yep there is a ruby linter
<Eiam> i use it for sublime text 2
<SQLDarkly> Hey Room I have hosts = %x{ls -w1 /sys/class/fc_host}.split(/\n/) hosts.each {|x| %x{cat /sys/class/fc_host/x/port_name}.chomp } Im obviously not using "x" correctly. How can I get that to interpolate "x"?
philcrissman has joined #ruby
<Alantas> SQLDarkly: Try #{x}
<Alantas> As in, %x{cat /sys/class/fc_host/#{x}/port_name}
TaTonka has joined #ruby
<SQLDarkly> I tried that, and I get no output. when removing the #{} I get cat: /sys/class/fc_host/x/port_name: No such file or directory I know the files exist, but im curious why no output is given when #{x} is used?
<SQLDarkly> im testing in irb btw. there are no other lines :)
<Alantas> Try "p hosts" first. Maybe it's not getting anything.
<Alantas> (Such as, maybe the "ls" is failing for some reason, or there's nothing to list.)
<SQLDarkly> its there
<SQLDarkly> hosts = %x{ls -w1 /sys/class/fc_host}.split(/\n/) => ["host0", "host1"]
chimkan has joined #ruby
<SQLDarkly> when manually adding the host also I get expected results : %x{cat /sys/class/fc_host/host0/port_name}.chomp => "0x10000000c98693212"
<Alantas> Oh. %x{cat herp derp} is returning a string, but you're not doing anything with it (other than "chomp").
<Alantas> hosts.each {|x| puts %x{cat /sys/class/fc_host/#{x}/port_name}.chomp}
<Alantas> Try that.
<SQLDarkly> AHHH like puts.... thus empty output
<SQLDarkly> uno moment
<SQLDarkly> o
<SQLDarkly> yep that worked.
<deryldoucette> Alantas: umm isn't that %x[] not %x{}
<deryldoucette> or just so long as they match?
<SQLDarkly> bah no wonder no output. it was stored but not shown :P
<SQLDarkly> thanks
<Alantas> deryldoucette: It can be anything that matches.
machine1 has joined #ruby
<deryldoucette> ahh ok makes sense. like sed
<Alantas> Even %x%echo herp derp% works, giving "herp derp\n".
<deryldoucette> s.derp.herp. gotcha
<Alantas> Well, it makes me think "like Perl". No idea about sed, never used it.
MrGando has joined #ruby
<deryldoucette> yeah same thing. sed changes things s/change_this/to_this/ (close with g to make it global rather than single line)
<deryldoucette> thats like the 5th thing today i've learned new in this channel. <g>
<Alantas> You'll pick up tricks as you go along, and soon you'll be the one dispensing wisdom!
<deryldoucette> works for me :) been in here awhile and always picking up new stuff.
<deryldoucette> amazing some of the things you pick up just lurking
<oooPaul> Like syphilis.
TaTonka has joined #ruby
<deryldoucette> hahaha
<deryldoucette> that was rough
<oooPaul> What? What? Who was that?
* oooPaul looks innocent.
Azure has joined #ruby
TaTonka has joined #ruby
nonotza has joined #ruby
hooper has joined #ruby
hashpuppy has joined #ruby
hydrozen has joined #ruby
burns180 has joined #ruby
badabim has joined #ruby
robbyoconnor has joined #ruby
kpshek has joined #ruby
mdw has joined #ruby
albemuth has joined #ruby
dlam has joined #ruby
amerine has joined #ruby
speggey has joined #ruby
punkrawkR has joined #ruby
<CacheMoney> Can someone tell me why when I use the add_player method it creates an array containing a Player object instead of just a Player object http://pastie.org/3506871
shadoi has joined #ruby
<Mon_Ouie> Because that's what Array#push returns
the_lord has joined #ruby
<Alantas> It's being added to the array. But the push() call returns the array, not what was pushed. The idea is that you could chain the calls: array.push(herp).push(derp)
ReTFEF has joined #ruby
<Mon_Ouie> That's intended so you can chain calls to it. You can explicitly return @player if you want
<Mon_Ouie> I also doubt you meant @player
<Alantas> You can simply have "@player" as the next line, to return it.
<Mon_Ouie> I'd think you most likely want to use a local variable (just player) instead
<Alantas> Or, yeah. If you don't intend to use the 'player' object outside of the add_player method (as opposed to using @team), you don't need @player, just player.
<CacheMoney> Mon_ouie: is there a way to set player1 = Player#object but still push that object into the @team array?
<Alantas> CacheMoney: uh, just do: @team.push(Player.new(name,num))
<Mon_Ouie> I'm not sure what you mean
<oooPaul> Could also tap it.
<oooPaul> Player.new(name, num).tap{|player| @team.push(player)}
<Alantas> Er, actually: player = Player.new(name,num); return player
<Alantas> Er^2, actually: player = Player.new(name, num); @team.push(player); return player
<Alantas> Or: @team.push(Player.new(name,num)); return @team.last
snearch has joined #ruby
<oooPaul> I like mine better. :)
<oooPaul> I have a saying -- "There's more than one way to skin a cat, and none of them are good for the cat."
<Alantas> Yeah, but yours has syphilis.
Asher has joined #ruby
<CacheMoney> Alantas: Thanks for advice...
<Mon_Ouie> I prefer Alantas penultimate version
<oooPaul> Still think the syphilitic cat would prefer to have skin. :)
<Boohbah> i also have an array of players in my application :)
<Alantas> Also: require "player" # The "./" is superfluous.
<Mon_Ouie> Using tap feels kind of silly, and doesn't make the code any clearer
<Alantas> (It won't hurt, but it isn't needed.)
<Hanmac> Alantas: no you are VERY wrong
<Mon_Ouie> The . *does* hurt
<Boohbah> Alantas: actually, it is
TheTFEF has joined #ruby
<Boohbah> needed
<Mon_Ouie> Nope
<gate> "./" is required for relative requires in 1.9.3
<oooPaul> Mon_Ouie, if "returning" was still around, it would be cleaner... But alas.
<Alantas> Well, that's silly. And unintuitive, as you just saw.
<Alantas> Doesn't 1.9 have require_relative?
<Mon_Ouie> returning and tap both look silly to me. I only liked tap to insert debugging puts in the middle of an expression.
<Mon_Ouie> With ./, you require relatively to the current working directory
<Mon_Ouie> Which is *not* what you should rely on
<oooPaul> I liked returning. It read pretty well.. "returning Player.new(foo, bar) do | player |; @team.push(player); end"
<Boohbah> Mon_Ouie: what is the right way?
<Mon_Ouie> Instead, you should set up your $LOAD_PATH properly and just do require "player"
<Boohbah> so, add the pwd to $LOAD_PATH ?
<Alantas> Or just use require_relative to pick it up relative to the script itself, not where it's called from.
<Mon_Ouie> Like pushing File.dirname(__FILE__) to the load path
<Mon_Ouie> No, not pwd — that's just the same as using ./
<Mon_Ouie> It breaks if you run the script from a different directory than the one where it is located
<Alantas> require File.join(File.dirname(__FILE__), "player.rb") # uphill, both ways...
paissad has joined #ruby
<Hanmac> Mon_Ouie, arent you that guy that makes an possible dynamic shader for ruby?
<Mon_Ouie> Not sure what you mean, but I did play with OpenGL shaders in Ruby.
<Boohbah> Mon_Ouie: so how do we setup the $LOAD_PATH properly, then?
mikepack has joined #ruby
<Mon_Ouie> $LOAD_PATH.unshift File.dirname(__FILE__)
glosoli has joined #ruby
<Alantas> Or require_relative.
<Hanmac> i had nice ideas for shaders, or maybe an programable one, for gosu ... but my exp are to low
<Boohbah> Mon_Ouie: thanks for showing me the right way :)
mengu has joined #ruby
robbyoconnor has joined #ruby
jergason has joined #ruby
robbyoconnor has joined #ruby
MrGando has joined #ruby
machine1 has joined #ruby
minijupe has joined #ruby
Targen_ has joined #ruby
Zanacross has joined #ruby
jbw_ has joined #ruby
burns180 has joined #ruby
jamw has joined #ruby
sgmac has joined #ruby
ekaleido has joined #ruby
tridentino has joined #ruby
enoch_ has joined #ruby
sgmac has quit [#ruby]
enoch_ has quit [#ruby]
robbyoconnor has joined #ruby
headius has joined #ruby
tridentino has quit [#ruby]
tridentino has joined #ruby
PragCypher has joined #ruby
stephenjudkins has joined #ruby
S1kx has joined #ruby
robbyoconnor has joined #ruby
glosoli has joined #ruby
s0ber_ has joined #ruby
y3llow_ has joined #ruby
havenn has joined #ruby
enoch_ has joined #ruby
choffstein has joined #ruby
y3llow has joined #ruby
r0bby has joined #ruby
heretoday has joined #ruby
akem has joined #ruby
akem has joined #ruby
speggey has joined #ruby
jsdrk has joined #ruby
y3llow has joined #ruby
tvw has joined #ruby
burns180_ has joined #ruby
cloke_ has joined #ruby
Tearan has joined #ruby
alek_b has joined #ruby
enoch_ has quit [#ruby]
cloke has joined #ruby
y3llow has joined #ruby
briankbuckley has joined #ruby
tazrover has joined #ruby
enoch_ has joined #ruby
y3llow has joined #ruby
sdwrage has joined #ruby
i8igmac has joined #ruby
the_hack has joined #ruby
Vert has joined #ruby
ryanlabouve has joined #ruby
altamic has joined #ruby
denom has joined #ruby
cook1es has joined #ruby
psino has quit [#ruby]
stringoO has joined #ruby
GiambalaGiambala has joined #ruby
Foxandxss has joined #ruby
Guest__ has joined #ruby
HenryTrollins has joined #ruby
<HenryTrollins> hey guis, how long it take to compile rubinius-git?
<Eiam> is there a handy way to say 'the thing i just said' , for example
<Boohbah> Eiam: define a method
<Eiam> a = Model.fetch_something(:key =>value) unless "the result of tha thing is nil"
<Mon_Ouie> The result of what is nil?
<Eiam> i feel silly saying a = Model.fetch_something(:key =>value) unless Model.fetch_something(:key =>value).empty?
<Mon_Ouie> empty? and nil? are two different thing
<Eiam> yes, well its going to be .blank? but
<Eiam> the question is more about 'not repeating myself'
<Alantas> Eiam: Perhaps fetch_something should throw an exception if it's not there.
<apeiros_> that's what local variables are there for
<Mon_Ouie> Well, you're right about that — especially since it's not just a matter of repitition
<Mon_Ouie> You're calling the method twice, doing the work twice
<Eiam> Mon_Ouie: oh gosh i'd hope it was smart enough to cache that result..
<HenryTrollins> it's been compiling for a week now.. and i really need to leave my house for groceries hence why i need to know whether it's almost done or not
<Eiam> especially since it appears in the same statement..
<apeiros_> Eiam: caching ain't smart
<Alantas> Unless you want to keep the old value of "a", you can just assign it unconditionally, *then* check it.
ed_hz_ has joined #ruby
<Mon_Ouie> It doesn't know that method didn't have any side effect and will return the same thing in both cases
burns180 has joined #ruby
<Alantas> The "just do it and see if it worked" approach, rather than "see if it'll work first, then do it".
<Eiam> yeah, i guess ill do that
<Boohbah> design by accident, that's my approach :)
<Alantas> a = Model.fetch_somethin(:key=>value); if a then herp() else derp() end
<Alantas> (Assuming it returns nil (or false) if there's nothing to fetch.)
<macmartine> I have a rake task run by cron. If that rake has 'puts' in it, it returns an error. HOw can I write to the cron log from that rake then?
macabre has joined #ruby
nyuszika7h has joined #ruby
<Eiam> Alantas: yeah, i mean obviously i could do it like that
<Eiam> i was just trying to be less.. wordy
<Alantas> HenryTrollins: Is it compiling in a window that shows progress, such as the compiling commands? If it's still cooking, then it's still cooking, I guess. If it's been a week, missing it by an hour or so isn't gonna hurt anything.
<Alantas> HenryTrollins: Otherwise, I'd be wondering if it's gotten stuck in a loop or something. Nothing should take that long to compile!
<Alantas> Eiam: Or, more succinctly: if a = Model.fetch_something(:key=>value) then herp else derp end
<Boohbah> kdelibs on a celeron 333 takes about that long :)
<Alantas> (Using "=" and not "==" in a conditional. Best practice! /sarcasm)
<macmartine> Boohbah: But do I want 'Logger.new(STDOUT)' ? or do i have to specify the file again?
<Eiam> you can do an assign in a conditional?
<Eiam> that seems like bad form
<macmartine> Boohbah: I specify the log file in the cronjob, so i expected that to just work
<Alantas> Eiam: You can. An assignment evaluates to whatever was assigned. So "if herp = derp then ..." is a shortcut for "herp = derp; if herp then ..."
<Alantas> (Might be good to put a comment next to it to make it clear it's not a typo'd "==".)
<Boohbah> file = File.open('foo.log', File::WRONLY | File::APPEND)
<Boohbah> logger = Logger.new(file)
<macmartine> So the log I specify in the cron has no effect?
<Eiam> ah. interesting oay tanks
<Eiam> +k +h
<Boohbah> macmartine: i can't see your code...
<HenryTrollins> atmosx: i know right, hence why i'm here
<HenryTrollins> i mean Alantas sorry
ascarter has joined #ruby
tommyvyo has joined #ruby
<macmartine> Boohbah: https://gist.github.com/1961757
<macmartine> Boohbah: I thought any 'puts' would just be output to that log
<Boohbah> macmartine: nope, because puts is hooked to STDOUT by default
<Alantas> Isn't there a $defout or something?
<Boohbah> Alantas: yeah there is
Ferdev has joined #ruby
<macmartine> Boohbah: ok, so no need to specify the log in the crontab for this at all?
<Alantas> If so, you might be able to reassign that.
<Boohbah> $stdout global, p.399
<Alantas> Or play nice and just redirect stdout to the file at the shell.
<Boohbah> you could do it either way
al3xnull has joined #ruby
<Alantas> Or, in the script, assign a "cron file" variable (perhaps global?) and always use that. $cronout = File.new("herp.log", "a")
<Alantas> Maybe with a def cron(what); $cronout.puts(what); end for flavor. cron("what madness is this?")
<Boohbah> Alantas: nice :)
<macmartine> thanks
<Alantas> Then go and search-and-destroy cron-destined "puts" to use $cronout or that cron().
<apeiros_> Boohbah: actually Kernel#puts uses $stdout
<apeiros_> and $stdout can be reassigned
psino has joined #ruby
<Boohbah> you are correct
<apeiros_> $stdout = File.open('some.log')
<apeiros_> $stdout = File.open('some.log', 'ab:binary')
<apeiros_> second one is better :)
<apeiros_> puts "foo" # will now be written to that log
<Alantas> Why binary, if it's text?
thebastl has joined #ruby
alanp has joined #ruby
<apeiros_> Alantas: you know all encodings that will go into it?
<macmartine> apeiros_: will it be set back when the script is done?
<Alantas> If you depend on the line endings, I think there's a $/ or something.
<apeiros_> Alantas: for example, I had issues with rails' logger in 3.1 as it used the default, which was utf-8
<apeiros_> and suddenly a bit of sql had byte sequences in it that weren't valid utf-8
<apeiros_> -> boom
Kleggas has joined #ruby
<apeiros_> you do usually not want to deal with such issues when logging.
<Alantas> apeiros_: Isn't that all the more reason to use text mode? Let it do conversions or something.
<apeiros_> Alantas: you don't understand
sbanwart has joined #ruby
<Alantas> If you use binary, you're taking the cards as dealt, invalid UTF-8 and all.
stenno50 has quit ["Leaving"]
<apeiros_> …
<apeiros_> not in the mood to argue
<apeiros_> if you want to shoot your foot, that's your foot.
<yxhuvud> and that is why god invented c++
Boohbah has joined #ruby
CacheMoney1 has joined #ruby
<Alantas> Well, it might be a problem if you non-interactively read them back in and try to pass them to SQL which expects the non-UTF-8 text.
davidpk has joined #ruby
odinswand has joined #ruby
<yxhuvud> do you think that will be handled automatically?
<apeiros_> it might be a problem when it explodes in your face when it tries to write it…
<Alantas> Why you'd do that with a log file is beyond me.
<apeiros_> I mean to the log
SegFaultAX|work has joined #ruby
Boohbah_ has joined #ruby
<gate> Invalid UTF8 chars in your logfile will bork reading the logfile, whether being done by hand or in automation
<apeiros_> gate: worse, it'll explode WHEN YOU WRITE
<apeiros_> dammit, how hard is it to get that point?
<yxhuvud> not hard at all since all it takes is a client
<Alantas> If you know SQL's returning non-UTF8, run it through a filter/converter before writing to a file expecting UTF8.
baroquebobcat has joined #ruby
burns180_ has joined #ruby
<apeiros_> and all hope is lost…
<apeiros_> poor feet
<pangur> My ruby proggy is frustrating me. http://fpaste.org/MS1k/ In eclipse, if I run the script from console, it will run sinatra. I go to the sinatra page - blank apart from error message - and then go back to the console - it shows me the patrons' names.
sabooky has joined #ruby
<Alantas> Don't blame my feet just because you're not doing your job sanitizing your output. Maybe that cron() I suggested earlier could do some UTF8-sanitizing automatically so you don't have to in the calls themselves, or something.
<pangur> Somehow, it seems to know that I want forename followed by surname, even though I do not think that I have told it that. It does not display the other fields. Is that a built-in default?
<sabooky> What's the preferred way of wrapering a function so it's memoized? Do people just roll their own?
<apeiros_> Alantas: so at what point do you sanitize the output when you reroute Kernel#puts, hm?
<apeiros_> do you redefine puts in order to sanitize?
<apeiros_> or do you control all points where something is being written to $stdout?
<apeiros_> hint: no, you don't. you shot your feet.
luisjose has joined #ruby
<Alantas> You don't write just any old thing in the middle of, say, a JPEG file, there's a binary format it expects to be followed. Text is the same way: it's not just a blob of arbitrary binary data, it's a format that expects to be interpreted a given way.
thecreators has joined #ruby
<apeiros_> additionally: in many cases you don't want to sanitize if it means you lose information. not all information can be converted to unicode.
idletom has joined #ruby
<Alantas> If it barfs when you try to write invalid data to it, that's the symptom, not the problem.
<apeiros_> -.-
<CacheMoney1> I'm having trouble breaking out of a method. When I use break; I'm returned a message that says "Invalid Break" http://pastie.org/3507535
<yxhuvud> alantas: the problem is that there is no automated way of doing that at the moment
ged has joined #ruby
<Alantas> def cron(what); $cronout.puts(sanitize(what)); end # And use this when you want to write to cron.
artOfWar has joined #ruby
<Alantas> I suggested it earlier before this sanitization thing came up, as a syntactic convenience, but here is shown another benefit of it.
<pangur> The error is undefined method `bytesize' for ["MacLeod", "Calum", "8", "0759", "X", "X"]:Array
adit has joined #ruby
<Alantas> CacheMoney1: Maybe just "return", in that case?
<Alantas> CacheMoney1: Assuming you're trying to get out of game_details().
<CacheMoney1> i'll try that...
<Alantas> pangur: The fact it wants surname before forename is defined by *you* in your code: the order of arguments to Patron#initialize.
burns180 has joined #ruby
<pangur> Is it my def to_s that determines it?
<Alantas> pangur: Your to_s is what makes the output "Jane Smith" rather than "Smith,Jane" or whatever.
<pangur> ah,
regedarek has joined #ruby
<Alantas> If you want it to print surname first, you'd change it there.
<CacheMoney1> Alantas: Good call, that worked. What about Q2: When I create multiple players during the initialization of a Game instance, can I store the Player#objects so I can access them from the command line?
<pangur> It is not printing on the internal browser at all :(
<pangur> Only in the console
<pangur> And then only once I have run the browser.
robertjpayne has joined #ruby
<pangur> I am happy enough to know how it was managing to do what I wanted. It was so long ago since I drew up my class :)
<pangur> I thought it would be cinch to turn a csv file into attributes.
<Alantas> CacheMoney1: Well, you could put "attr_reader :team" in the Game class, and get it as "game.team".
<Alantas> CacheMoney1: If that's what you meant.
stringoO has joined #ruby
<HenryTrollins> good news everyone, rubinius compiled
snip_it has joined #ruby
<adit> lol
<pangur> Why does it not print in the browser what it puts into the console?
<adit> congratulations
<Alantas> HenryTrollins: Surely you took advantage of it? http://xkcd.com/303/
<pangur> Is it my eclipse installation that is at fault?
<HenryTrollins> Alantas: lol
<Boohbah> an eclipse installation is always a fault :P
<pangur> hmph
<pangur> Guess you are going to say vim next :)
chimkan_ has joined #ruby
<CacheMoney1> Alantas: I was hoping to do it all in one-fell-swoop. But I guess once I initialize the Game and add all the players, I'll have to iterate through the @team array and set variables equal to each Player#object.
wyhaines has joined #ruby
Quirrell has joined #ruby
eignerchris has joined #ruby
<Quirrell> If I wanted to document methods and use the documentation as printable strings in the same program, how would I accomplish this?
v0n has joined #ruby
<Alantas> CacheMoney1: Ew, you've defined it as a recursive function. You should have it be something like: def game_details; loop do; puts "Add player?"; prompt; if action.upcase == 'Y' then herp derp; else break; end; end; end
<pangur> NoMethodError at /undefined method `bytesize' for ["MacLeod", "Calum", "59", "070345", "X", "X"]:Array
<Alantas> pangur: What's this "bytesize"? What are you trying to do?
<pangur> I have no idea where it is coming from. I do not want it.
<pangur> I am just trying to print out names like Calum MacLeod.
friskd has joined #ruby
<Alantas> Well, it should be printing a big call chain or something. That's what happens when one of my scripts barfs. Annoying, but handy.
<pangur> a series of 61 names
<CacheMoney1> Alantas: I'll change my game_details method. Thanks for the warming
<Alantas> pangur: Well, the only time you have ["MacLeod", "Calum", etc] in array form like that is during the CSV read/parse loop: such as the 'patron' given in line 25.
<CacheMoney1> *warning
<pangur> http://fpaste.org/qNZf/ is the traceback
<Alantas> pangur: The error's occuring when something's trying to call "bytesize" on that. The only other thing that handles those arrays is the CSV code.
<pangur> I want the patron to appear on browser page as a regular Calum MacLeod.
<shevy> Calcium MacLeod?
<pangur> I feel just as brittle atm, shevy :)
<Alantas> pangur: Hmm. What I meant was something like "No method 'herp' in derp.rb:123; from this/that.rb:19 in `twiddle'; from here/there.rb:33 in `tweak'; and so on.
<pangur> Alantas: that means absolute nothing to me - sounds vaguel venereal.
<pangur> vaguely even
<Alantas> pangur: Well, it'd help figure out what's trying to call "bytesize" on your array, and where it's calling it from.
LowKey has joined #ruby
cantonic has joined #ruby
<Alantas> pangur: My point being that it should already be doing that. Or maybe it *is*, but it's going into stderr or something.
<pangur> This is what's in my console at the moment
<Alantas> Yeah, that's what I meant. *Looks*
Kyle__ has joined #ruby
<Alantas> Though that has nothing to say about the bytesize thing.
robertjpayne has joined #ruby
<pangur> NoMethodError at / undefined method `bytesize' for ["MacLeod", "Calum", "59", "0709", "X", "X"]:Array file: utils.rb location: bytesize line: 281
<Alantas> Oh, utils.rb. Is that one of your scripts? If not, then it might be in a library somewhere.
<pangur> Is that any better?
<pangur> It is not one of my scripts that I know of.
<pangur> It was not generated by me.
<Alantas> If it was one of yours, you'd know it. So it's probably in the CSV gem or whatever.
burns180_ has joined #ruby
<pangur> Would it be part of Sinatra?
emmanuelux has joined #ruby
<Alantas> Maybe look in /home/calum/.rvm/gem/sruby-1.9.3-p0gems/ for a "csv" directory.
<CacheMoney1> Alantas: I updated the game_details method http://pastie.org/3507689 But it doesn't exit the method very well. Any ideas?
<Alantas> (I'm guessing. I don't use gems, so I'm just going by what I'm seeing here.)
sbanwart has joined #ruby
havenn has joined #ruby
<Alantas> CacheMoney1: Delete lines 20 and 22. They're not needed: you're already looping.
<Alantas> And line 2 can be "loop do" rather than "while true". Same effect, but a little cleaner.
<CacheMoney1> Atlantas: Nice catch. I'll change line 2 as well
<CacheMoney1> thanks
<pangur> It is in the rack library
<Alantas> Yeah. The nested calls (lines 20/22) were starting the loop all over again, so I'm guessing you had to "N" out as many times as you had players you entered?
<Alantas> Or something like that.
<Alantas> Nested loop, I might add. Break out of the inner loop and you merely wind up back in the outer loop.
<Alantas> When there should Be Only One loop.
<CacheMoney1> Alantas: After I'm done adding players from the command line during the game_details method it prints out all the details for this Game instance. Is there a way to stop this from happening?
<robert_> shevy: hai :D
<pangur> "/home/calum/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/utils.rb
<Alantas> CacheMoney1: Define an "inspect" method that returns a string you want it to show.
<Quirrell> If I wanted to document methods and use the documentation as printable strings in the same program, how would I accomplish this?
<Alantas> def inspect; "#{@team.length} players on this team"; end # Just for example. You can have it return any string you want.
<Alantas> irb calls inspect() on the resulting object after each top-level command.
<Alantas> + and shows it
<CacheMoney1> Alantas: Where do I put this in the game_details method... Ahh, so i need to overwrite the inspect method
<shevy> yo robert_
<robert_> how's it going?
<shevy> robert_ this was the last time I tried to do a rewrite-from-scratch
<Alantas> Not as part of the game_details method, but its own method. class Game; def inspect; "Yeah, I'm game."; end
<shevy> from now on I will soft-replace old code slowly
<robert_> aha.
<Alantas> (Alas, there are no nested functions in Ruby that I'm aware of. And it wouldn't be appropriate in this case anyway.)
<CacheMoney1> Alantas: sounds good. Thanks again!
<shevy> robert_ but now I am doing something more productive rather than fixing code I broke
<shevy> I am trying to learn sinatra!
<robert_> use Padrino instead.
<robert_> :D
<Alantas> class Player; def inspect; "#{@name}, ##{@num}"; end
ryannielson has joined #ruby
pu22l3r has joined #ruby
ixti has joined #ruby
drbawb has joined #ruby
drbawb has joined #ruby
pu22l3r has joined #ruby
<pangur> line 281 refers to bytesize
<shevy> nono I must take things slowly
<Alantas> pangur: It says it broke the site?
startling has joined #ruby
startling has quit [#ruby]
explody has joined #ruby
<pangur> NoMethodError at / undefined method `bytesize' for ["MacLeod", "Calum", "59", "0709", "X", "X"]:Array file: utils.rb location: bytesize line: 281
<shevy> Array does not have bytesize method
<Alantas> pangur: That link isn't working, it says it's over 512 KB or something.
burgestrand has joined #ruby
sirdeiu has joined #ruby
<Alantas> That worked.
burgestrand has joined #ruby
xissburg_ has joined #ruby
<Alantas> Hmm, I think the problem is that an Array is being passed where it expects a String.
etank has joined #ruby
<Alantas> Line 280 checks if String has a bytesize() method, and if so, def's up a shortcut for it. But if you pass an Array to that def...
<Alantas> Well, "you", or whoever.
<Alantas> This is all coming from your little three-line CSV.read loop? You'd think it'd be prepared to handle plain old arrays, especially since it's generating the things.
<pangur> yep
<pangur> I thought that the thing looked so neat and cute and straight forward - once I had help from you folks :) - that it would just work out of the box.
RichGuk has joined #ruby
<pangur> 29 lines of code
j0bk has joined #ruby
j0bk has joined #ruby
<shevy> work out of the box
<shevy> you are an optimist
<Alantas> I have half a mind to suggest class Array; def bytesize; 0; end; end just to see what happens.
<pangur> Well, most things will work for me eventually but maybe too late :)
<Alantas> Or have it raise "This is blasphemy. This is madness!" to get a proper backtrace.
<pangur> You want me to put that in my little script?
<Quirrell> So nobody knows?
<shevy> Alantas lol
<shevy> Quirrell did you have a look at rdoc formatting
<Quirrell> I took a brief glance
<pangur> No, it still gives me the bytesize No method error
kevinbond has joined #ruby
<shevy> I dont use rdoc as it messes up my docu when I use "# ============ #" to start my comments, but other folks us it a lot
shadoi has joined #ruby
<Alantas> pangur: Put the class Array etc stuff above the loop.
Vsg21 has joined #ruby
<shevy> *use it a lot
<pangur> I put immediately after my Patron class.
<pangur> When I put it immediately above the Patron class, it gives me a blank browser page and ...
<pangur> prints the names in the console after I return from the browser.
Sailias|work has joined #ruby
<pangur> I am beginning to think that my setup must be broken.
<Quirrell> shevy: How would I print the documentation from within the program?
<pangur> Anyway, it is bedtime for me.
<shevy> Quirrell hmmmm I am not sure that is possible. you want to access the documentation like a doc string in python?
<pangur> Thanks for your help in abbreviating the script, Alantas.
<shevy> I think ruby does not support that
<Quirrell> shevy: Yes, exactly
<shevy> it is more "dead" documentation where you generate static files via rdoc :\
<Quirrell> Bleh
<shevy> with .source_location or something like that you can print the method body
sbanwart has joined #ruby
<shevy> perhaps you can put # following the "def foo" to start with a docu header
<shevy> I have not tested this though, probably won't work
<shevy> but it would be nice if you could then suggest to the core team to provide an additional method, to also show comments hehehe "Ruby Docstring proposal"
<Quirrell> I might just do that, thanks for the help
<shevy> Quirrell good luck :-) perhaps there exists another way, people here can suggest it!
<burgestrand> pry does it
<Alantas> What's this, like for on-line (in-irb) reference or something? You could put up class methods that print/return explanation. Spidey.how_do_i_shot(:web) for reference on Spidey#web() for example.
<Quirrell> Alantas: What I'm trying to do is have a help function for other methods (think IRC bot) that prints how to use the method
<Quirrell> And I'd like to tie it into the methods instead of writing everything in the help function
vraa has joined #ruby
Vsg21 has quit [#ruby]
burns180_ has joined #ruby
axl_ has joined #ruby
sizz has joined #ruby
<Quirrell> Nice, killed the channel
<Alantas> No, it made its saving throw and has stabilized.
pu22l3r_ has joined #ruby
ascarter has joined #ruby
crankycoder has joined #ruby
manizzle has joined #ruby
<burgestrand> Quirrell: I know one gem that has that functionality and it’s pry; the idea is simple: you find the source for the method and the line with object.method(methodname).source_location, and then read the file at that location. You then walk the lines upwards as long as there is documentation and save that. You could then possibly use YARD to parse that documentation into a more meaningful data structure (for example).
<burgestrand> banister`sleep: I suppose that’s still built into pry and has not made it into its’ own gem yet?
<banister`sleep> burgestrand: method_source
<burgestrand> banister`sleep: even method_documentation?
<burgestrand> :p
<banister`sleep> burgestrand: yeah, method_ousrce supports: method(:blah).doc
<burgestrand> Ah, sweet!
<banister`sleep> as well as method(:blah).source
<burgestrand> Quirrell: ^
pantsman has quit ["Leaving"]
<burgestrand> Ah, #comment and #source
<Quirrell> Fantastic, thanks
<fayimora> I am using Dir.glob('./**/*.java') do |file_name| to loop through all the java files in a directory.. How do i get the filename? file_name there returns the path to the file but i just want its name
<Alantas> File.basename(file_name) I think
<shevy> fayimora File.bas... argh
<shevy> he was faster
<fayimora> lol thanks guys
* shevy silently breaks some of Alantas's fingers ...
ysiad has joined #ruby
* Alantas shoves an Array down shevy's throat and asks for its bytesize.
_obiJuan has quit [#ruby]
tazrover has joined #ruby
stephenjudkins has joined #ruby
<ReinH> Alantas: flawless victory
<tazrover> trying to use $.post() with jquery to send JSON to my server, but my ruby controller doesn't seem to be "seeing" my JSON. it creates a new object but all data fields are null. would really appreciate any help.
<mvangala> No sort method in ruby string class??
<mvangala> that is surprising!
burns180 has joined #ruby
davidcelis has joined #ruby