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/
<Tachyon> shadoi: thx very much :)
<shadoi> np
pantsman- joined #ruby
nerded joined #ruby
looopy joined #ruby
Brozilla_ joined #ruby
Ankhers joined #ruby
austinbv joined #ruby
anachronistic left #ruby
Guest2452 joined #ruby
Guest2452 left #ruby
mksm joined #ruby
Nisstyre joined #ruby
cassarani left #ruby
esparkman joined #ruby
Adept` joined #ruby
rpowell joined #ruby
looopy joined #ruby
Tachyon left #ruby
esparkman joined #ruby
looopy joined #ruby
replore_ joined #ruby
io_syl joined #ruby
io_syl joined #ruby
notbrent joined #ruby
babinho joined #ruby
jwmann joined #ruby
esparkman joined #ruby
eignerchris joined #ruby
esparkman joined #ruby
republican_devil joined #ruby
<republican_devil> :)
bwlang joined #ruby
esparkman joined #ruby
brownies joined #ruby
esparkman joined #ruby
kevinbond joined #ruby
LittleBill902 joined #ruby
h4mz1d joined #ruby
cableray joined #ruby
LittleBill902 joined #ruby
mytec joined #ruby
esparkman joined #ruby
esparkman joined #ruby
crankycoder joined #ruby
SolarisBoy joined #ruby
bwlang joined #ruby
esparkman joined #ruby
esparkman joined #ruby
esparkman joined #ruby
jonathan_ joined #ruby
pen joined #ruby
sdwrage joined #ruby
marcuspat joined #ruby
esparkman joined #ruby
jonathan_ joined #ruby
jonathan_ left #ruby
Seisatsu joined #ruby
esparkman joined #ruby
esparkman joined #ruby
esparkman joined #ruby
looopy joined #ruby
sdwrage joined #ruby
esparkman joined #ruby
esparkman joined #ruby
dotnull joined #ruby
SolarisBoy joined #ruby
esparkman joined #ruby
esparkman joined #ruby
esparkman joined #ruby
dotnull joined #ruby
radmacd joined #ruby
esparkman joined #ruby
dotnull joined #ruby
zedUNDginger joined #ruby
bigkm_ joined #ruby
dotnull joined #ruby
esparkman joined #ruby
dasfugufish joined #ruby
esparkman joined #ruby
esparkman joined #ruby
mxweas_ joined #ruby
un1x01d- joined #ruby
esparkman joined #ruby
<brownies> can we rap about admin panels?
<brownies> i have observed that many RoR gems for this are shitty and slow down my app. i am contemplating just rolling my own.
<brownies> thoughts? links to gems that don't suck? suggestions for how to roll my own?
<shadoi> padrino
esparkman joined #ruby
<brownies> that's not... a solution. >.>
esparkman joined #ruby
<brownies> i already have a RoR app, and i'd like to add admin-panel functionality to it for myself.
esparkman joined #ruby
spyvsspy joined #ruby
esparkman joined #ruby
esparkman joined #ruby
Asher joined #ruby
esparkman joined #ruby
babinho joined #ruby
Ankhers joined #ruby
<shadoi> All the gems will have limitations and you'll probably wish you'd written your own. I felt that way every time I used it for anything but the simplest case.
cbuxton1 joined #ruby
<shadoi> I haven't tried any since ajax/activescaffold
<brownies> that's true.
voodoofish430 joined #ruby
<shadoi> I'd recommend going with something like SproutCore or ExtJS to be honest. Completely separate the app from the API.
<shadoi> But that's just from past painful experiences I've had.
<shadoi> Even just something like Backbone.js + Jquery is good.
<brownies> hm, so expose an "admin API" via Rails and then connect to it via a separate JS app?
<brownies> that's a nice idea. rather a lot of work though.
<shadoi> yeah
<shadoi> Something like ExtJS gives you a tabular view to JSON data with very little work.
<brownies> tbh i just want a "special magic account" where i can log in and it shows me a special page with the results of some db-level analysis calls -- like Users.count, Users.all.sort_by(last_login_date)[:10]
<brownies> stuff like that
<shadoi> SSH + scripts/console ;)
<shadoi> Hirb can make that a fairly nice UI as well.
<brownies> haha, yea, that's what i've been doing. but it's a bit clunky ;)
<shadoi> Check out hirb
<shadoi> pagination, menus, etc.
<shadoi> pretty cool
<brownies> hey that's actually pretty sweet. thanks.
<shadoi> np
<brownies> honestly i just don't want to have console-level power available when i log in to check stats. you know?
<shadoi> yup
<brownies> User.all.count is one drunken typo away from User.all.each { |x| x.destroy }
<shadoi> export stats as with collectd, and use the data for many purposes (alerts, trends, stats reports, etc.)
<shadoi> then you get a free simple web ui too :)
<brownies> "export stats as with collectd" <== sorry, what do you mean by that?
Adman65 joined #ruby
<brownies> free simple web ui is exactly what i want
<shadoi> write a little collectd script that loads up activerecord, does the stats queries you want and sends it to a server
<shadoi> Of course, this assumes you use collectd or something like it already to gather stats for other stuff.
<republican_devil> ruby handle lists easily? and unix files?
<shadoi> republican_devil: absolutely
<brownies> i don't, let me google wtf "collectd" is
<brownies> hmm interesting interesting
austinbv joined #ruby
nari joined #ruby
babinho joined #ruby
looopy joined #ruby
<brownies> hmmmm
<brownies> but now it'd be a snapshot that's decoupled from the current state of my system, which is sub-optimal
roberto_bob joined #ruby
<brownies> and does not cater well to my desire to sit here and refresh constantly
<zedUNDginger> i have an interesting puzzle for someone if they wanna try it
<zedUNDginger> not really a puzzle, just trying to figure out how to do smething that may be impossible
<zedUNDginger> anyone interested?
Tachyon joined #ruby
Tachyon left #ruby
<republican_devil> heres a puzzle
<republican_devil> why doesnt everyone vote for ron paul?
<dominikh> I'll answer with a puzzle: why is this called #ruby and not ##politics
<zedUNDginger> dominikh: i have a binding from inside a deleted method, is it possible to get a method object for that method?
<dominikh> no idea
sdwrage joined #ruby
<zedUNDginger> my usual strategy is: binding.eval "method(:#{__method__})"
<zedUNDginger> but of course that wont work in the case the method is deleted
<dominikh> I doubt there's a way
<zedUNDginger> Yeah
techhelp joined #ruby
<dominikh> nn
dchelimsky joined #ruby
wyhaines joined #ruby
marcuspat joined #ruby
roaminghorse joined #ruby
swarley joined #ruby
<swarley> so, in reading why's poignant guide i see
<swarley> class << self
<swarley> not quite sure how that works. Anyone care to explain?
raincole joined #ruby
<brownies> << is list append, isn't it?
<swarley> yes
<swarley> apparently its metaprogramming thing
<swarley> But im not sure
<swarley> its a*
shadoi1 joined #ruby
Sailias joined #ruby
sdwrage joined #ruby
<apeiros_> class << self is syntax and opens the singleton_class of self
<apeiros_> works the same with class << anyobj
<apeiros_> it's not a meta programming thing, it isn't "list" append either
<apeiros_> the singleton class allows you to define methods for a single object
<swarley> Oh
linoj joined #ruby
skrewler joined #ruby
p0y joined #ruby
Targen joined #ruby
roaminghorse joined #ruby
_kinderman joined #ruby
ben_alman joined #ruby
badabim joined #ruby
austinbv joined #ruby
p0y_ joined #ruby
p0y_ joined #ruby
p0y joined #ruby
adeponte joined #ruby
jonathanrwallace joined #ruby
ghosTM55 joined #ruby
igotnolegs joined #ruby
cdepue joined #ruby
dagnachewa joined #ruby
thone_ joined #ruby
kevinbond joined #ruby
satyavvd joined #ruby
dv310p3r joined #ruby
beseku joined #ruby
beseku left #ruby
eignerchris joined #ruby
Ankhers joined #ruby
rpowell joined #ruby
rclark joined #ruby
p0y_ joined #ruby
<shevy> hehe
tobyo joined #ruby
austinbv joined #ruby
ghosTM55 joined #ruby
casidiablo joined #ruby
<casidiablo> Hello there!
<casidiablo> First time here...
<casidiablo> I am basically trying to create an object from this class: Builder::XmlMarkup; however, I am doing it from a model (whose extends ActiveRecord). The problem is that, inside ActiveRecord there seems to be another module called Builder and get this error:
<casidiablo> uninitialized constant ActiveRecord::Associations::Builder::XmlMarkup
mxweas_ joined #ruby
wiz joined #ruby
<wiz> Enter text here...anyone there
<wiz> you there
<wiz> i have a question
mxweas_ joined #ruby
<wiz> anyone reply please
<mksm> YOU reply :(
TheNoob joined #ruby
<wiz> hi
<wiz> i have a question
<wiz> ready
<wiz> it's c++
<wiz> hello
<mksm> ahoy ther
<wiz> yes you there
<mksm> no ... i'm over here
<any-key> and I'm over here
<mksm> oh
<TheNoob> I have a question... if I wanted to quickly build a website in Ruby, but wasn't familiar with RoR, what framework woud you guys recommend? If this was something I had to learn and build quickly...
<mksm> i forgot irc has private msg
<mksm> :(
<mksm> TheNoob, what's the site about?
<any-key> TheNoob: Sinatra
<ryanf> haha
<ryanf> misread that as TheNoob saying the site would be about Sinatra
<ryanf> that was a fun couple seconds
<ryanf> anyway, what he said. use sinatra.
<TheNoob> For those who asked... its a site for a club... only people with accounts would be club members. Would be primarily database driven
<any-key> my websites are awesome-driven
<TheNoob> We could edit public pages, and maybe have a small message board like system
wiz left #ruby
<TheNoob> Sinatra still?
<any-key> not sure if sinatra is good for that
<mksm> certainly won't be quick
<any-key> that sounds like something that would be better-suited to RoR or using some pre-built stuff
<mksm> but that's not sinatra's fault
<TheNoob> Would it be better to use a language like PHP? Just to quickly write it?
<any-key> there's all kinds of forum software things around, no clue which ones are good
<any-key> TheNoob: no, it's going to be work in any language
<mksm> TheNoob, try something like joomla
<TheNoob> ok thanks
TheNoob left #ruby
<any-key> you want a CMS,
<any-key> as much as I hate Joomla, this is kind of what it was meant for :P
<mksm> yeah
<mksm> that's one website i shall not enter :P
<mksm> capistrano is still being used or did someone come up with somethings awesome-rerer
<any-key> not the most secure thing ever
<any-key> joomla, that is
pen joined #ruby
<shevy> Joomla - isn't that PHP
<any-key> it is
<any-key> he just wants something that works...no need to reinvent the wheel honestly
sdwrage joined #ruby
pencilcheck joined #ruby
kuadrosx joined #ruby
skrewler joined #ruby
badabim joined #ruby
<shevy> you sent another poor soul down to PHP hell :(
<any-key> heh he's not developing for it, just using it
sdwrage joined #ruby
<any-key> there are worse things, what it's written in doesn't make a huge difference
<any-key> although joomla has some serious faults it'll be fine for him
randym joined #ruby
<mksm> shevy, YES I DID
<shevy> :(
<shevy> hmmm
<shevy> I should make it my task to kill PHP
<shevy> well one day
<any-key> meh
<any-key> I'm not a fan but it has some things going for it
<any-key> namely the fact that it's so fucking easy to deploy
<mksm> any-key: and to take it down buwahaha
<shevy> yeah ease of deployment is a big plus
sakamal1 joined #ruby
flock joined #ruby
austinbv joined #ruby
jonathanrwallace joined #ruby
x0F__ joined #ruby
mxweas__ joined #ruby
Banistergalaxy joined #ruby
skrewler_ joined #ruby
Ruthenium joined #ruby
sakamal2 joined #ruby
raythecat joined #ruby
vauban joined #ruby
Ankhers left #ruby
booginga joined #ruby
keymone joined #ruby
stephenjudkins joined #ruby
poorlilrichboy joined #ruby
silky joined #ruby
kuadrosx joined #ruby
radic_ joined #ruby
Pip joined #ruby
Pip_ joined #ruby
Pip_ joined #ruby
mxweas joined #ruby
xol joined #ruby
zodiak joined #ruby
jrist-bb joined #ruby
chsonnu joined #ruby
pen joined #ruby
Bardosity joined #ruby
nerdy joined #ruby
h4mz1d joined #ruby
poisonar1s joined #ruby
TomJ joined #ruby
nari joined #ruby
jonathan_ joined #ruby
apok joined #ruby
randym joined #ruby
jonathanrwallace joined #ruby
keymone joined #ruby
stephenjudkins joined #ruby
sakamal2 joined #ruby
Bardosity joined #ruby
skim1776 joined #ruby
dfamorato_ joined #ruby
v4n_ joined #ruby
sakamal1 joined #ruby
<v4n_> hi
<skim1776> hey
gregorz joined #ruby
CannedCorn joined #ruby
<v4n_> it seems like doing a STDIN.gets after a STDIN.read doesn't work
<v4n_> maybe STDIN needs to be reopened or something
<v4n_> example: http://fpaste.org/V0V1/ doesn't work as expected
<v4n_> any idea?
<skim1776> what do you want to do? read from console?
<v4n_> skim1776, yep, see the example
kuadrosx joined #ruby
emptyflask joined #ruby
v4n__ joined #ruby
<v4n_> skim1776, wow, getting tired... the last variable name is not the good one in the script... >< But anyway, that's not the problem. The script's working by calling directly ruby script.rb, but not when using a pipe like cat something.txt | ruby script.rb
sdwrage joined #ruby
Beoran__ joined #ruby
benja-M- joined #ruby
JumpMast3r joined #ruby
Sunil01 joined #ruby
kuadrosx joined #ruby
vauban_ joined #ruby
nlew joined #ruby
pabloh joined #ruby
TheMoonMaster joined #ruby
MUILTFN joined #ruby
xol joined #ruby
p0y joined #ruby
yxhuvud joined #ruby
jarjar_prime joined #ruby
<sdwrage> how do I store a file reference into a variable?
<sdwrage> I need to use it for rails send_data
<sdwrage> this question, I thought, is more of a ruby question than a rails one
ethndbst joined #ruby
ethndbst joined #ruby
Banistergalaxy joined #ruby
<sdwrage> guessing this: file = File.open("temp.txt", "r")
AlecTaylor joined #ruby
<AlecTaylor> Is there a Ruby ORM gem which integrates with MS Access?
mxweas_ joined #ruby
ph00l1sh joined #ruby
adelcampo joined #ruby
luckyruby joined #ruby
macmartine joined #ruby
jredville joined #ruby
<mksm> sdwrage, yes
<sdwrage> hrm… I need the binary data
<sdwrage> mksm: how would I store binary data?
<sdwrage> need to push it to send_data
<mksm> File.open("temp.txt", "rb")
<mksm> i do not know send_data
tobyo left #ruby
austinbv joined #ruby
moshef_ joined #ruby
tyler_ joined #ruby
bluOxigen joined #ruby
tyman joined #ruby
wilmoore joined #ruby
moshef_ joined #ruby
moshef_ joined #ruby
xol joined #ruby
smgt joined #ruby
fixl joined #ruby
maletor joined #ruby
xol joined #ruby
Cervajz_ joined #ruby
Asher joined #ruby
cantonic joined #ruby
kassien joined #ruby
kassien joined #ruby
kassien joined #ruby
stephenjudkins joined #ruby
ilyam joined #ruby
raythecat joined #ruby
kassien joined #ruby
kassien joined #ruby
jr00n joined #ruby
kassien joined #ruby
skrewler joined #ruby
kassien joined #ruby
skipper joined #ruby
kassien joined #ruby
kassien joined #ruby
xol joined #ruby
kassien joined #ruby
burgestrand joined #ruby
kassien joined #ruby
kassien joined #ruby
Nate75Sanders joined #ruby
kassien joined #ruby
kassien joined #ruby
kassien joined #ruby
kassien joined #ruby
senny joined #ruby
michael_mbp joined #ruby
dnjaramba joined #ruby
JohnBat26 joined #ruby
xpot joined #ruby
fridim_ joined #ruby
heftig joined #ruby
marcuspat joined #ruby
nachtwandler joined #ruby
hukl joined #ruby
xol joined #ruby
crodas joined #ruby
zommi joined #ruby
hinogi joined #ruby
keymone joined #ruby
hinogi joined #ruby
nlew joined #ruby
moshef left #ruby
TheMoonMaster_ joined #ruby
stephenjudkins joined #ruby
moshef_ joined #ruby
robotmay joined #ruby
mafolz joined #ruby
stoffus joined #ruby
omp joined #ruby
Russell^^ joined #ruby
ph^ joined #ruby
bosphorus joined #ruby
stephenjudkins joined #ruby
ph^_ joined #ruby
ph^ joined #ruby
burgestrand joined #ruby
sdwrage left #ruby
ph^_ joined #ruby
batlock666 joined #ruby
zenergi joined #ruby
michael_mbp joined #ruby
pencilcheck joined #ruby
Manhose_ joined #ruby
ttvd joined #ruby
<ttvd> is there a way to convert number to a words? like "8" to "eight"
<ttvd> ?
Cervajz_ joined #ruby
xol joined #ruby
jarjar_prime joined #ruby
flippingbits joined #ruby
<kke> is Restrack any good?
ttvd left #ruby
ryanf joined #ruby
<kke> and is anyone using it anywhere
<kke> wouldn't want to end up with an abandoned framework
Mchl joined #ruby
roaminghorse joined #ruby
danielpunt joined #ruby
<shevy> never heard of Restrack
gayasentinel joined #ruby
rpowell joined #ruby
Know1edge joined #ruby
ChampS_ joined #ruby
Manhose_ joined #ruby
<kke> it looks suitable for what i'm doing
<kke> which is serving a rest api
<kke> without a browser interface
Seisatsu joined #ruby
akem_ joined #ruby
akem_ joined #ruby
ioannis joined #ruby
_debo joined #ruby
akem joined #ruby
mksm joined #ruby
<shellox> hi
Adman65 joined #ruby
<shellox> i have a hash table and i want to change a value there
pen joined #ruby
<shellox> but im not sure how to do it
<shellox> if i do puts @x[:address][:city]
stepnem joined #ruby
<shellox> it prints the name of the city, but if i do @x[:address][:city] = "foo" i get an error :/
<shellox> TypeError: can't convert Symbol into String
<shellox> how to fix this?
jbpros joined #ruby
cyri_ joined #ruby
<shevy> shellox how dows the array look
<shevy> I think @x[:address] already fails
<shevy> ah a hash it is
Samoi joined #ruby
<shellox> shevy: i store xpath data in it
<shevy> hash[key] = new_value # would always work
<shevy> so I think @x[:address] is odd for you, probably it has no [] method
<shevy> whatever is returned there, that is
<shevy> oh, xpath. sounds like XML.
* shevy runs away in panic.
<shellox> shevy: @x[:address] works
zedUNDginger joined #ruby
<shevy> hmmmm
<shellox> shevy: it print the xml with it's attributes
<shevy> aha
<shellox> so one of them is city
<shellox> and @x[:address][:city] print the city name
<shellox> and @x[:address][:city].class prints string
opameier joined #ruby
<shellox> but @x[:address][:city] = "foo" still fails
<shellox> with the error: TypeError: can't convert Symbol into String
geoffw8_ joined #ruby
tatsuya_o joined #ruby
<shevy> well your hash must somehow be wrong
bdiallo joined #ruby
<shellox> shevy: nah
<shellox> shevy: it is correct, im sure
<shellox> shevy: solved it o.O
<shellox> but wtf!
<shevy> returns {:address=>{:city=>"london"}} for me
smgt joined #ruby
<shellox> @x[:address]["city"] = "foo" works
<shevy> I thought it did not :\
<shevy> ah
<shellox> but @x[:address][:city] = "foo" doesnt
<kke> ruby-1.9.2-p290 :003 > hash[:address][:city] = "Helsinki" => "Helsinki"
<shevy> yeah I noticed now
<kke> ruby-1.9.2-p290 :004 > hash.inspect => "{:address=>{:city=>\"Helsinki\"}}"
<shevy> Helsinki!!!
<shellox> kke: too cold in helsinki :P
<kke> not yet
<shevy> hehe
<kke> last winter it was so cold at times that i couldn't light up a cigarette because my thumb was too frozen to push the button
<shevy> shellox but you see that it would normally work, right?
<Samoi> can anyone tell me what I'm doing wrong? this snippet http://pastie.org/2943041 gives me a type error on line two: can't convert Fixnum into String (TypeError)
<shevy> kke that's terrible! I think suomi is a hilarious country with lots of crazy people, but I can't stand coldness :(
bastilian joined #ruby
<yanniskolovos> hello everyone .. I am using textmate and i want to ask if someome manage to make it work autocomplete dropdown like in eclipse?
<shellox> shevy: i know that it normally work, so i was confused
<shellox> shevy: i guess its an nokogiri thing then
<kke> Samoi: i think you want to do str.insert "1", str[str.size - 1]
<shellox> shevy: access it with [:bla] and change it with ["bla"] now ;)
<ryanf> i think the args are just backwards
<kke> perhaps
<ryanf> that sounds like a bug shellox
mengu joined #ruby
<shellox> ryanf: more like a feature ;)
<Samoi> hmm
<Samoi> works with ruby 1.9.2
hurikhan|Work joined #ruby
robotmay joined #ruby
akem joined #ruby
akem joined #ruby
zetesha joined #ruby
clockwize joined #ruby
moshef joined #ruby
<Samoi> the args are not backwards
mklappstuhl joined #ruby
Deiu joined #ruby
Deiu joined #ruby
ephemerian joined #ruby
iocor joined #ruby
<shevy> Samoi you did not give a range
<shevy> str.insert 1, str[str.size - 1, 1] works
<shevy> I think in 1.9.x too
<shevy> I prefer to use []= though
<shevy> str[4,1] = 'hi there'
cakepie joined #ruby
hukl joined #ruby
<cakepie> Has anyone compiled ruby on Lion with clang here?
maletor joined #ruby
pen joined #ruby
Deiu left #ruby
Spockz joined #ruby
dazoakley joined #ruby
ikaros joined #ruby
dazoakley joined #ruby
dazoakley joined #ruby
Indian joined #ruby
<Samoi> thanks
Telling joined #ruby
james_cotterill joined #ruby
manizzle joined #ruby
<ryanf> Samoi: the problem is
<ryanf> in 1.8 indexing a string gives you the character value as a number
<ryanf> you can use .chr to turn it back into a string
BiHi joined #ruby
adambeynon joined #ruby
<shevy> cakepie I have not. sounds like fun though
flippingbits joined #ruby
Telling joined #ruby
<cakepie> Well, there's no gcc on lion, so clang it is.
beseku joined #ruby
beseku left #ruby
havenn joined #ruby
clockwize joined #ruby
Manhose joined #ruby
Shrink joined #ruby
sepp2k joined #ruby
<shevy> hehe
heftig_ joined #ruby
Manhose joined #ruby
probst joined #ruby
mikewintermute joined #ruby
Manhose_ joined #ruby
<cakepie> The NEWS document says to use clang on Lion, so that's what I'm trying to do.
Manhose__ joined #ruby
randym_ joined #ruby
iocor joined #ruby
xol joined #ruby
pen joined #ruby
clockwize joined #ruby
fixl joined #ruby
luke joined #ruby
heftig joined #ruby
<dagobah_> So, I'm trying to write something that will show the 'diff ' in a ruby scripts output from the previous run, any ideas?
vmatiyko joined #ruby
otakutomo joined #ruby
BrianE joined #ruby
<heftig> touch run.old; ruby script.rb >run 2>&1; diff -u run.old run; mv run run.old
<heftig> er, well
<heftig> mv -f run run.old
<dagobah_> Very nice, thanks.
<dagobah_> Can I have that be a hook that is called by including a module in the script.rb?
_debo joined #ruby
pi3r joined #ruby
vmatiyko left #ruby
_debo joined #ruby
Nowaker joined #ruby
<heftig> BEGIN { FileUtils.touch("run.old"); io = open("run","w"); $stdout.reopen(io); $stderr.reopen(io) }; END { system("diff -u run.old run"); FileUtils.mv("run", "run.old", :force => true) }
<heftig> dagobah_: totally untested. but something like this, I guess.
jbpros joined #ruby
Drakx joined #ruby
RomD`` joined #ruby
p1d joined #ruby
heftig joined #ruby
JonnieCache joined #ruby
pen joined #ruby
Manhose joined #ruby
Zsadan joined #ruby
pantsman joined #ruby
pantsman joined #ruby
thone joined #ruby
yann2 joined #ruby
<yann2> Hello! I've got a hash like myhash["key1" => "value1", "key2"=> "value", .... is there a way to convert that to an array with the keys, ["key1", "key2"...] ?
brauliobo joined #ruby
<brauliobo> how to make rake tasks description (with -T) longer?
<sepp2k> yann2: Unless that's a typo, you have an array containing a hash, not just a hash.
<sepp2k> Anyway: to get the keys from a hash, just call the_hash.keys
closedbracket joined #ruby
<yann2> .. that might be what I was looking for , thanks :)
<zedUNDginger> sepp2k: long time no see seppx0r
<zedUNDginger> sepp2k: i guess you've been lost in the world of skyrim
<dagobah_> heftig: It appears ruby isn't happy with using FileUtils in a BEGIN block
<zedUNDginger> dagobah_: did u require it first
<dagobah_> Yeah, perhaps my system is a little screwed.
<dagobah_> It's fine without the BEGIN {} END
<zedUNDginger> dagobah_: or you could just be an epsilon semi-moron
<heftig> dagobah_: needs to be required inside the BEGIN
<dagobah_> That's it.
jeedey joined #ruby
ph00l1sh joined #ruby
robotmay_ joined #ruby
speggey joined #ruby
bwright joined #ruby
fermion joined #ruby
moshef joined #ruby
bsnyder joined #ruby
<bsnyder> i'm having trouble installing passenger: http://pastie.org/2943416
<bsnyder> this happens while i am scripting the install of rvm, ruby, rails and passenger
<bsnyder> i'm running the following commands: rvm install 1.8.7; rvm use 1.8.7 --default; rvm gemset create my-gemset; rvm gemset use my-gemset --default; gem install rails; gem install passenger; echo -en "\n\n\n\n" | /usr/local/rvm/gems/ruby-1.8.7-p352/bin/passenger-install-apache2-module
manizzle_ joined #ruby
<bsnyder> this is all running from a bash script and it fails with the error upon the last command
<bsnyder> any suggestions?
<JonnieCache> environment variables. are you running it through SSH? the env variables like $PATH might not be getting set
<JonnieCache> also rvm does lots of weird things to environment variables
<JonnieCache> maybe also ask in #rvm
<bsnyder> no, it's not running thru ssh but i was already suspecting rvm
vitoravelino joined #ruby
vitoravelino joined #ruby
gianlucadv joined #ruby
iocor joined #ruby
p0y joined #ruby
_debo joined #ruby
jarjar_prime joined #ruby
Shrink joined #ruby
jbpros joined #ruby
<shevy> everything gets more complicated
<shevy> nothing ever works
<shevy> hmmmm
knoopx joined #ruby
<shevy> is there really a use for BEGIN and END? I am thinking hard of a place where those two are really useful
jbpros_ joined #ruby
knoopx left #ruby
tk_ joined #ruby
flippingbits joined #ruby
trivol joined #ruby
preller joined #ruby
Sliker joined #ruby
fayimora joined #ruby
<fayimora> hey guys how do i make a ruby program executable
<fayimora> so i can save it in my local/bin and call it from anywhere
<JonnieCache> put this as the first line: #!/usr/bin/env ruby
<JonnieCache> then obviously make sure it has the executable permission set
moshef_ joined #ruby
moshef joined #ruby
<shevy> hmm who is interpreting the shebang?
clockwize joined #ruby
heldopslippers joined #ruby
Krebs joined #ruby
fermo joined #ruby
clockwize joined #ruby
<Krebs> I dont know ruby much. So any help would be much appreciated..my problem is this: i'm on freebsd shellaccount and most scripts i try to run gets a loaderror for iconv...but iconv is already installed
brauliobo joined #ruby
cantonic joined #ruby
<Krebs> Is ther anyway to change the path for the iconv binary?
zedUNDginger joined #ruby
burgestrand joined #ruby
<JonnieCache> shevy: the shell itself, ie. probably bash on most systems
<shevy> ah
<JonnieCache> Krebs: maybe you need to rebuild ruby after you installed iconv? also do you have the iconv dev packages as well as the actual iconv itself?
<shevy> JonnieCache hmm ... but isn't is that the shebang is honoured even in GTK apps? they probably don't spawn a bash shell ... hmm hmm hmm
<Krebs> Its a shell account so i dont have root access
<shevy> Krebs where is the iconv binary and can you copy it into your PATH
<Krebs> About the dev package...i'll check
<Krebs> Binary is in usr/local/bin
<Krebs> If there's a 'require 'iconv'' in th script where does ruby search for it?
<fayimora> JonnieCache: thanks would look at that
nari joined #ruby
iocor joined #ruby
Lord-Harlot joined #ruby
dlitvak joined #ruby
BrenoPerucchi joined #ruby
QaDeS joined #ruby
alup_ joined #ruby
xec joined #ruby
kaydara joined #ruby
FND joined #ruby
adeponte joined #ruby
moshef joined #ruby
<FND> say I want to create a block purely to limit variable scope*, is there a more elegant alternative to `1.times do ... end`
<FND> * I know that sounds like a stupid idea
<yfeldblum> `proc do ... end.call`
<FND> I guess that is more elegant - thanks
<yfeldblum> `def immediately(&block) ; block.call end ; ... immediately do ... end`
<FND> heh that's cute :)
kaspernj joined #ruby
Shrink joined #ruby
iocor joined #ruby
<zedUNDginger> FND: i like to call it let: def let() yield end
<FND> zedUNDginger: that seems sensible - if a bit confusing perhaps because it might look like a keyword (which, I guess, is kind of the point)
<FND> but from that I gather I'm not being crazy wanting to do this in the first place?
gayasentinel joined #ruby
<zedUNDginger> FND: i kinda like it: let do |x=10, y=(x*2)| puts x + y ;end x #=> NameError
ChampS_ joined #ruby
raincole joined #ruby
<FND> zedUNDginger: I don't disagree - what context do you use this in, for example?
<zedUNDginger> FND: i dont think i've ever actually used it (as my methods are very small i dont have a need for it really) but i just like it ;)
<zedUNDginger> FND: another cool thing about it is you can use the block control keywords with it ;)
<FND> gotcha
<FND> like?
<zedUNDginger> FND: so: let do | case x; when 20; x= 40; redo; when 40; puts "hey baby"; end; end
cdepue joined #ruby
<FND> GOTO? ;)
<zedUNDginger> FND: hehe in a way
<zedUNDginger> FND: other things like break too
<zedUNDginger> FND: case/if statements in ruby dont allow a 'break' (early exit) but if you wrap the case/if in a let you can use break
<zedUNDginger> to break out of a nested if or nested case
<FND> yeah, that's an interesting possibility - although I'd rather I never get the urge to use it ;)
<JonnieCache> if i find myself wanting to break out of a case or something like that i usually decide its time to try a different idea
<JonnieCache> its generally a sign im going the wrong way
<zedUNDginger> Yeah, i've never used that either
<zedUNDginger> but it's interesting nonetheless
<JonnieCache> case statements are generally tricky, the pass-through behaviour is a huge source of bugs
<zedUNDginger> JonnieCache: ruby case dont have fall through
<JonnieCache> ah. shows how little i use them
<zedUNDginger> hehe
akem joined #ruby
sandstrom joined #ruby
sandstrom joined #ruby
axilla joined #ruby
geoffw8__ joined #ruby
<FND> JonnieCache: Crockford has a nice story on fallthroughs, which always comes up in his talks about JSLint
<JonnieCache> yeah thats probably what im remembering. someone did a study of C code showing that 99% of the time the fallthrough represented a bug or something
<FND> JonnieCache: FWIW, http://youtu.be/prAwkQt3ARg?t=20m55s
ph^ joined #ruby
fayimora joined #ruby
apeiros_ joined #ruby
Guedes joined #ruby
Guedes joined #ruby
iocor joined #ruby
probst joined #ruby
wyhaines_ joined #ruby
burgestrand joined #ruby
wyhaine__ joined #ruby
fayimora joined #ruby
airstrike joined #ruby
<JonnieCache> FND: love that bit about "we spend most of our time staring at the screen, thinking 'what the hell have I done?!'"
<FND> JonnieCache: yeah, Crockford is full of such things - his talk are well worth watching
<JonnieCache> ive seen the classic "javascript: the good parts" one but i should probably watch more
<FND> to be honest, it gets repetitive after a while, but I guess that's invevitable for professional speakers
jcromartie joined #ruby
jbpros joined #ruby
<JonnieCache> i love watching hacker conference vids
<JonnieCache> really want to go to CCC in berlin this new years
<FND> I rarely have the patience for videos, too sequential
<FND> so when I do watch some, I try to make it count
preller joined #ruby
preller joined #ruby
ikaros joined #ruby
<JonnieCache> i like the wacky/dangerous ones. remotely destroying hard drives, rooting sattelites and so on
cantonic_ joined #ruby
cdepue_ joined #ruby
sbanwart joined #ruby
gregorg_taf joined #ruby
cemerick joined #ruby
<cemerick> Hi: is there a corollary of Python's `with` in Ruby?
rkk joined #ruby
shevy joined #ruby
<heftig> not as a language feature, no.
<heftig> e.g. File.open { |f| ... } will close the file after the block exits
<cemerick> OK; so each "closeable" resource manages its own scope?
<shevy> blocks do that
<shevy> END { cemerick.dance }
<JonnieCache> When you pass a block to file.open
<shevy> there. at the end of the script, cemerick dances
<JonnieCache> it opens the file, yields the file to the block, then closes the file
tvw joined #ruby
<cemerick> thanks :-)
<rkk> I get a LoadError when requiring a .rb
<rkk> but the file is really there
<rkk> don't know why
<JonnieCache> if you're using ruby 1.9, you need to manage your own load path. thats probably the issue
<rkk> i am a newbie
<rkk> howto?
cemerick left #ruby
<rkk> im using 1.9.2p290
BiHi joined #ruby
<apeiros_> rkk: require/load look for the file in every directory listed in $LOAD_PATH
<apeiros_> $LOAD_PATH is just an ordinary array of strings
<apeiros_> you can add e.g. your working directory when starting ruby using the -I (capital i) flag
<apeiros_> ruby -I. yourscript.rb
<rkk> i figuire out current directory has been moved away in 1.9
<apeiros_> yes. you should NOT relay on the working directory when requiring
<apeiros_> your script isn't always started as ./yourscript
sbanwart joined #ruby
<apeiros_> *rely
<JonnieCache> the thing to do is to put your code into a lib directory and add that to the load path. then require as normal
<rkk> i've put it in a lib directory
<JonnieCache> now put $: << "lib" at the top of your main file. i think thats the best way to do it
moshef joined #ruby
<JonnieCache> $: is shorthand for $LOAD_PATH
larry joined #ruby
<rkk> it works
<shevy> hmm
<shevy> $:
<rkk> thanks
<apeiros_> I disagree
<apeiros_> "lib" depends on working directory again
<JonnieCache> i was under the impression thats what youre supposed to do. what alternative is there, apart from using absolute paths which is obviosuly unworkable?
<shevy> $: << "lib"
<shevy> vs
<shevy> $LOAD_PATH << "lib"
<shevy> :(
<shevy> The longer version isn't really that much better...
<apeiros_> JonnieCache: there's 2 situations where you don't have to do anything: a) your library was installed by setup.rb, b) your library way installed by rubygems
<shevy> long live setup.rb!
<rkk> *_*
<apeiros_> JonnieCache: the one case where you have to handle $LOAD_PATH is when you explicitly do not want to install the library. e.g. because you're working on it and installing it for every testrun is tiresome
<shevy> I am the perfect cheerleader
moshef joined #ruby
<JonnieCache> or when youre just throwing together a little script. which is what im doing when im not making a gem or a rails app
<rkk> if i am making a gem, what's the best way?
<apeiros_> for that one case, there's IMO 2 ways to deal with it: a) use -I, b) manage the load path from your test helper, c) add to load path relative from your script (code follows)
<apeiros_> JonnieCache: the moment you put stuff into a lib dir it stops qualifying as little, IMO :-p
<JonnieCache> fair point
<shevy> what if it is just one file under a lib/ dir!
<apeiros_> rkk: if you're making a gem, just put your files into the 'lib' dir
<apeiros_> everything there can be required just fine
<apeiros_> (only once you've installed the gem, that is)
<JonnieCache> jesus this is giving me flashbacks to life before bundler. i may need to go and have a lie down
<shevy> the weak lie down and the strong walk on them
<JonnieCache> hah
<apeiros_> code for c), assuming your script is PROJ/bin/script and your require stuff is in PROJ/lib: lib_dir = File.expand_path("../../lib", __FILE__); $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
<rkk> now i put my main.rb file in lib/, and a config.rb in lib/config/, but it still report the LoadError.
benja-M-_ joined #ruby
ikaros joined #ruby
<rkk> is it because i haven't create the .gemspec file?
Synthead joined #ruby
mr_the_shadow joined #ruby
ramusara joined #ruby
sbanwart joined #ruby
<apeiros_> rkk: as said, you have to actually install the gem. the installed gem's stuff in lib can be required.
p0y joined #ruby
bwlang joined #ruby
<rkk> emm, confused...
<apeiros_> but if you don't even have a gemspec, you're probably still working on the gem. use the -I flag. ruby -Ilib bin/yourscript
FND left #ruby
<shevy> hmm what is File.expand_path("../../lib", __FILE__) doing?
<shevy> get's the absolute path?
<apeiros_> shevy: yes
<apeiros_> relative to __FILE__
<rkk> apeiros_: but i haven't finish the gem, how can i install it..
<apeiros_> and since __FILE__ contains the filename, we have to do .. twice
<apeiros_> rkk: I repeat, for the third time now, use -I
<apeiros_> ruby -Ilib bin/yourscript
<apeiros_> I really have to get my FAQ up and running…
jtrudeau joined #ruby
<shevy> will it be in Schweizerdeutsch!
<rkk> got it
macabre joined #ruby
<apeiros_> shevy: of course, in order to reach the maximum audience, I'll keep it in schwizerdütsch…
<shevy> YEAH
<rkk> i am really a slow thinking :-(
<shevy> nah
<shevy> you solved it today
<shevy> if you would be slow, you'd need 5 more days
enikar joined #ruby
<apeiros_> listen to shevy, he's an experienced slow thinker ;-)
<shevy> I am just easily distracted :(
tommyvy__ joined #ruby
<zedUNDginger> apeiros_: does this look reasonable? https://github.com/sinatra/sinatra/pull/421
<rkk> haa, i will :-)
nari joined #ruby
<apeiros_> zedUNDginger: I wonder whether arity check is really necessary
<zedUNDginger> apeiros_: yeah me too, but it's in the tests so i added it in
<apeiros_> I don't know the implications for sinatra, I'd guess if the tests still pass, sure
<zedUNDginger> without it i got 4 failures
nanderoo joined #ruby
fermion joined #ruby
danishman joined #ruby
<zedUNDginger> anyway i think it's better than the approach they had which was creating a method with a weird name (it had spaces in it) getting an unbound method object to it, then removing the method, and later calling the method by rebinding it to an object...
<zedUNDginger> seems like a classic case for instance_exec
<apeiros_> that for sure
<apeiros_> if they used that, they could have gone with instance_exec from day one
michael_mbp joined #ruby
<apeiros_> and use one of the backports which does a silly method generation trick anyway
<zedUNDginger> Yeah
<apeiros_> sometimes I dislike the backwards thinking of some devs…
austinbv joined #ruby
Telling joined #ruby
<apeiros_> but then again, I'm sick today, so maybe I'm more misanthropic than other days…
Azure joined #ruby
Azure joined #ruby
linoj joined #ruby
emmanuelux joined #ruby
yfeldblum joined #ruby
vauban joined #ruby
renanoronfle joined #ruby
Shrink joined #ruby
<apeiros_> is it really slower?
EddieS joined #ruby
<zedUNDginger> how is it slower? the other approach requires rebinding on each call too
nerded joined #ruby
<zedUNDginger> it's an unbound method object that is being rebound and called
<apeiros_> where's generate_method defined?
<zedUNDginger> base.rb
<apeiros_> maybe make a benchmark and prove him wrong :)
<apeiros_> thx
<apeiros_> so he thinks UnboundMethod.bind(obj).call was faster than instance_exec?
* apeiros_ got serious doubts…
<zedUNDginger> Yeah
<apeiros_> especially if you kick out arity check…
pen joined #ruby
kf8a joined #ruby
<zedUNDginger> apeiros_: in my test instance_exec is faster
catphish joined #ruby
<catphish> if i create an application-specific ruby installation ie --prefix=/opt/myruby will gems be self-contained also, or is there a way i can make that the case?
<zedUNDginger> apeiros_: also the backtraces seem more or less the same
<apeiros_> zedUNDginger: 2.5 times here
nerded joined #ruby
<apeiros_> claim chowder…
<zedUNDginger> apeiros_: also i dont see that much difference in teh backtrace
booginga left #ruby
<zedUNDginger> apeiros_: the backtrace for define_method() methods dont even include teh method name in my tests, it just says 'block in blah'
<zedUNDginger> which isn't much nicer tha 'instance_exec in blah'
<apeiros_> I'd link the comparison and ask him for his numbers…
Sailias joined #ruby
<zedUNDginger> done
<zedUNDginger> thanks
pjeide joined #ruby
ABK joined #ruby
kriskropd left #ruby
AutoMan joined #ruby
<AutoMan> I need help getting results back from an Oracle Stored procedure... the simple examples on the web are not working
<AutoMan> If anyone has a snippet to share that would be great!
ikaros joined #ruby
muzzle-fuzzle joined #ruby
sbanwart_ joined #ruby
dv310p3r joined #ruby
devdazed joined #ruby
strife25 joined #ruby
devdazed left #ruby
sj26 joined #ruby
arpegius joined #ruby
<shevy> never used oracle
iamjarvo joined #ruby
pjeide joined #ruby
Pip joined #ruby
gu_ joined #ruby
<AutoMan> Yeah I am surprised there is not more info on it out there
theRoUS joined #ruby
theRoUS joined #ruby
<gu_> is there in ruby something like "self" that does not refer to the class but to the current intance?
<AutoMan> I know it has had to be done (simply...)
<gu_> and i don't need @PROPERTY, i need the instance itself, not its properties
cdepue joined #ruby
<ccooke> gu_: in ruby, 'self' refers to the current instance.
<ccooke> gu_: the current class is self.class
<sj26> Anybody know why ruby-debug19 has releases ready for 1.9.3 not yet pushed to rubygems?
<catphish> there is something *very much* like self ;)
beaknit joined #ruby
<apeiros_> ccooke: only if you're in a class method or in the class body, self will refer to the class - simply because that IS the current instance there
<ccooke> (or rather, the class of the current instance is "self.class")
gregorg_taf joined #ruby
<apeiros_> argh, not @ ccooke, but @ gu_
<ccooke> apeiros_: heh
<apeiros_> tab-completion failure :)
<ccooke> apeiros_: the point is, inside a class body the current instance *is* the class you're defining
<apeiros_> (limechat can tab-complete starting from an empty string - I think it uses last talking nick for that, no idea)
<apeiros_> ccooke: which is what I said ;-)
<ccooke> apeiros_: aye
<apeiros_> >> simply because that IS the current instance there
<apeiros_> ;-)
<ccooke> :-)
<ccooke> apeiros_: let's violently agree some more!
<apeiros_> I AGREE!!!!!!
<shevy> I DISAGREE!
<catphish> i think you're all wrong!
<shevy> I agree with catphish!
* apeiros_ 's agreement CRUSHES ccooke's agreement!
<catphish> lol
<ccooke> I disagree with disagreement!
<ccooke> I disagree with having to go do work, too :-/
<apeiros_> be sick, like I!
<apeiros_> wanna trade?
<AutoMan> calling all Ruby/Oracle folks...
<apeiros_> I'd rather work than be sick :( sick sucks…
nkbuff joined #ruby
radmacd joined #ruby
<apeiros_> AutoMan: oracle enhanced adapter mailing list is often useful, also ruby-oci8 ML
<apeiros_> fact is, oracle is too low topic to have good chances getting answers in irc :-/
<AutoMan> Well you guys have helped in the past when I got stuck so why not...?
<apeiros_> sure, worth a try
<apeiros_> just saying chances are low
<catphish> i'm amazed there's a market for oracle with its pricing
<apeiros_> and that I'd expect better chances on the MLs
<AutoMan> MLs?
<apeiros_> catphish: if it was only the price
<apeiros_> AutoMan: ML = MailingList
<AutoMan> Mailing list?
<apeiros_> catphish: oracle SUCKS
<apeiros_> hard, even
<AutoMan> I agree!!!!
<catphish> really? i thought it was actually very good
<AutoMan> But I got to use it unfortunately
<catphish> i used to use 10g in passing, the reporting tools look cool
<apeiros_> 30 chars limit on identifiers, can't correctly convert unicode, happened to be slower than sqlite in a couple of cases for me, its error messages are a craptard…
<catphish> but overall seems like a waste of time when mysql and postgres exist
<apeiros_> I mean, seriously, if you have like 50 cols in a select, saying "unknown identifier" is SHTOOPID. tell me *which* is unknown.
<AutoMan> Oracle = Microsoft they tend to make things too complicated...
rbanffy joined #ruby
<AutoMan> But they are big and powerful
poorlilrichboy joined #ruby
<apeiros_> AutoMan: and lots of companies started using it when it was indeed a good choice, and now they're locked in
<apeiros_> we've got so much legacy crap deeply vested with oracle…
<apeiros_> at least it seems we've got everybody in line to let us use postgres for new projects.
<shevy> hehe
<AutoMan> I am just trying to get the results back from a stored procedure... not build a rocket... but building a rocket seems easier
<shevy> chasing the stick strategy
<apeiros_> oh, yeah, right, did I mention you can have only one character set per *database*? (no, not per column, not per table, not per tablespace, PER DATABASE)
<apeiros_> AutoMan: I'd expect a select to work with a stored procedure
<apeiros_> but no oracle at home, can't try
<apeiros_> so can't help much
<AutoMan> For some reason the select works differently... I can get it to work just fine . SPs send back a Fixnum object that I cannot parse
macmartine joined #ruby
<AutoMan> thanx folks I'll keep lokking
<AutoMan> looking...
catphish left #ruby
akem joined #ruby
akem joined #ruby
austinbv joined #ruby
mkscrg joined #ruby
krz joined #ruby
jonathanrwallace joined #ruby
jwill joined #ruby
linoj joined #ruby
lutinwood joined #ruby
<lutinwood> Hi all
<lutinwood> i ther anyone who know the official website of thin
pjeide left #ruby
pjeide joined #ruby
burgestrand joined #ruby
<lutinwood> pjeide have you been there
<pjeide> lutinwood, yes, what is the problem?
jensn joined #ruby
<lutinwood> because i tied firrst and i was redirect to some wired page for pharmacie
Ch4rAzZz joined #ruby
<Ch4rAzZz> hi, how to convert float to string with following format: '3.00'
iocor joined #ruby
sena joined #ruby
<pjeide> lutinwood, that is not what I see at all :) I get the thin site.
<sena> i have just build new project with 1.9.3-p0, i use haml but i got an error message about encoding when i try to display the page :( Error during failsafe response: incompatible character encodings: UTF-8 and ASCII-8BIT
<shevy> ENCODING FUN!
<lutinwood> pjeide : even with the link i gave on the channel ?
<shevy> love it! don't hate!
dcarper joined #ruby
<pjeide> lutinwood, correct
<apeiros_> Ch4rAzZz: sprintf/String#%
io_syl joined #ruby
io_syl joined #ruby
dch4pm4n joined #ruby
probst joined #ruby
Ankhers joined #ruby
becom33 joined #ruby
<becom33> how can I read filenames in a dir and get them into array ?
<sj26> markit: `rake db:migrate:up/down VERSION=blah` should only migrate that particular migration, but it takes your migrations into account.
<sj26> frak, wrong window
<apeiros_> becom33: take a look at the Dir class
<apeiros_> especially its class methods.
preller joined #ruby
rippa joined #ruby
<shevy> take a look at my
bier joined #ruby
<lutinwood> wired my machin might be hacked o
<lutinwood> I start to get confused with ruby
<shevy> why
<lutinwood> I am using ubuntu 10.4
bier|tp joined #ruby
becom33 joined #ruby
<lutinwood> and I would like to run redmine with thin
Dangr_ joined #ruby
<lutinwood> I'have half of my package installed with apt-get and the other half with gem
<lutinwood> I might have some installed with both
<lutinwood> then I get lost on the config file
<lutinwood> I don't have the same information from gem '-list
<lutinwood> and gem serve
<lutinwood> gem list show me 13 items installed
<lutinwood> gem serve 4
heftig joined #ruby
axl_ joined #ruby
arpegius joined #ruby
RomD`` joined #ruby
LBRapid joined #ruby
xissburg joined #ruby
KenSentMe joined #ruby
dotnull joined #ruby
yekta joined #ruby
blischalk joined #ruby
SaneWarning joined #ruby
mksm joined #ruby
philcrissman joined #ruby
<lutinwood> just a question
<lutinwood> If i use gem install rail sould i use apt-get install rail as well ?
<pjeide> lutinwood, no
<pjeide> gem install rails
<pjeide> but not apt-get
notbrent joined #ruby
<lutinwood> i should only use gem to install ruby code ?
<JonnieCache> yeah
<JonnieCache> the ruby/gem packages in apt-get shouldnt really be used, they just cause problems
csavola joined #ruby
<JonnieCache> it stems from a disagreement between the ruby community and the debian community, and its really boring
excelsio1 joined #ruby
<JonnieCache> just uninstall all the ones from apt-get and use gem instead, and dont worry about it
<lutinwood> but to use gem I have to start somewhere like rubygems itsefl
<lutinwood> should I installed it from the source
<mr_the_shadow> it's almost funny that package managers try to keep up with the ruby community
<JonnieCache> lutinwood: use rvm to install ruby and rubygems
<JonnieCache> its an automatic way of building it from source
<lutinwood> another one
<lutinwood> ok thanks
<JonnieCache> you can just build ruby directly if you want
<JonnieCache> but most people use rvm
KenSentMe_ joined #ruby
fayimora joined #ruby
<lutinwood> thanks bye
LiquidInsect joined #ruby
evantravers joined #ruby
tomhsx joined #ruby
xec joined #ruby
ethndbst joined #ruby
closedbracket joined #ruby
Ok4mi joined #ruby
jensn joined #ruby
iamjarvo joined #ruby
kingCrawler joined #ruby
burgestrand joined #ruby
wilmoore joined #ruby
vipaca joined #ruby
vipaca joined #ruby
<JonnieCache> rippa: LOL
<JonnieCache> unfortunatrely they did some A/B testing and found that jimbo's starey face resulted in something like 400% more donations versus just the text
albemuth joined #ruby
<zedUNDginger> JonnieCache: mani need to put his pic on my website
gayasentinel joined #ruby
luxurymode joined #ruby
<JonnieCache> i dont think it was jimmys face in particular, people just respond strongly to human faces
<JonnieCache> but i encourage you to try it and report back
<axl_> Hey guys, I am using each_with_index to iterate through items in my array. Is there an elegant way inside the iteration to check if the item is last
<axl_> ?
jwmann1 joined #ruby
<JonnieCache> axl_: index == array.size
<JonnieCache> but i agree its not very elegant
ckrailo joined #ruby
<axl_> JonnieCache: k. thanks!
<zedUNDginger> size - 1?
<JonnieCache> yeah that
<JonnieCache> or just `object == array.last` that would be clearer
alek_b joined #ruby
gregorg joined #ruby
<axl_> yeah, ill do that
<axl_> i was hoping i could do something like index.last?
Adman65 joined #ruby
<axl_> anyways, thanks guys
nachtwandler joined #ruby
<shevy> axl_ you could always add a "def last?" method to class Array or module Enumerable
<axl_> shevy: thats a good suggestion
apok joined #ruby
<JonnieCache> rippa: that's kinda funny, but i'm more intriguied by the XDCC link on the right there
<JonnieCache> rippa: the fansub scene is still partying like it's 1999 huh?
<axl_> shevy: i am not a big coder, and haven't changed much internals, but won't it be tricky because i do not want to call the method on the array object
crankycoder joined #ruby
<axl_> shevy: I want it to call it on the object, but more so, the index...
<rippa> JonnieCache: XDCC is still a very popular method
<JonnieCache> axl_: that doesnt make sense, the index is just an integer, it doesnt know anything about your array
randym joined #ruby
<axl_> JonnieCache: yeah, but the same thing would be true for the object, wont it?
<axl_> or lets call the object an item in this context
<axl_> wonder if i can define a 'last?' method at all
<JonnieCache> not on the item or the index, no, unless you have that method take the array as a parameter, but that would be backwards
<JonnieCache> it makes more sense to have a last?(item) method on Enumerable that checks if the item passed in is its last item
<JonnieCache> like shevy said
maletor joined #ruby
<shevy> hmm
<shevy> I think he wants to have "index.last?"
<shevy> which would work on Integer no?
<shevy> he kinda confuses me
burgestrand joined #ruby
<shevy> "index.last?" alone seems to miss the proper context
<shevy> axl_ do you have example data/code?
<axl_> May be it can be done by defining the method on the Enumerable... I know too little
tshauck joined #ruby
Hellojer_ joined #ruby
Brozilla joined #ruby
emptyflask joined #ruby
<burgestrand> !
p0y joined #ruby
atmosx joined #ruby
fayimora joined #ruby
<JonnieCache> axl_: tbh id just do it like this and get on with my life: https://gist.github.com/1409621
<JonnieCache> its fun to extend the core classes but its usually a distraction
<axl_> JonnieCache: yeah, makes sense
<burgestrand> There’s an elegant solution to this problem but I always forget it
<shevy> hehe
<shevy> can't have had a lasting impact on ya now then can it
<burgestrand> Ah, yeah, (array + [nil]).each_cons(2) { |item, next_item| … }
Ankhers joined #ruby
<burgestrand> At the last iteration, next_item will be nil
sbanwart_ joined #ruby
<JonnieCache> what
<shevy> hmmmmmm
<shevy> what is that [nil]
<shevy> it makes me want to kill kittens
<burgestrand> It’s an array containing a nil
<shevy> hehehe
<JonnieCache> you must have a different definition of elegant than me haha. that looks like something a desperate java programmer might do
poisonar1s joined #ruby
<JonnieCache> (obviously you cant do that in java but you get the idea)
<burgestrand> ;)
<burgestrand> I should have said clever, not elegant
<JonnieCache> i was gonna say array[0..array.length-1].each {|item| …}
<JonnieCache> then handle the last item outside the loop
<JonnieCache> or maybe it'd be -2. i always get that wrong
<shevy> burgestrand, when you said "It's an array containing a nil" it did so remind me of http://www.youtube.com/watch?v=SEz70ClCetM
raincole joined #ruby
vitoravelino joined #ruby
<JonnieCache> burgestrand: actually ive embarrased myself havent I. thats actually a LISPy or PROLOGy construct isn't it, the very opposite of java
grimeton left #ruby
<JonnieCache> head-tail list processing and all that.
<burgestrand> JonnieCache: obviously you should feel ashamed of the disgrace you’ve drawn upon yourself by this error, seppuku is the only option
RomD joined #ruby
<JonnieCache> yeah or I could just actually learn lisp
<burgestrand> I have to say I have no idea, I don’t do much lisp nor prolog, Haskell I play with a bit on the other hand
<JonnieCache> its the same deal when it comes to list processing i believe
QKO joined #ruby
dch4pm4n joined #ruby
youdonotexist joined #ruby
paraglade joined #ruby
kedare joined #ruby
amacgregor_osx_ joined #ruby
amacgregor_ joined #ruby
Hellojere joined #ruby
dfr|work joined #ruby
akem joined #ruby
akem joined #ruby
havenn joined #ruby
benlangfeld joined #ruby
benlangfeld joined #ruby
sopheak joined #ruby
lkba joined #ruby
<shevy> (lisp(rocks(the(boat
<rippa> ))))
tomzx joined #ruby
<csavola> module Ruby; class Has; def a_different_boat; end; end; end
smgt joined #ruby
<csavola> you can write unclear anything
Cervajz joined #ruby
artOfWar_ joined #ruby
v4n_ joined #ruby
quest88 joined #ruby
Sunil01 joined #ruby
<Tasser> rippa, some lisp dialects had meta-parenthesises, so you could write {lisp(rocks(the(boat}
<rippa> kewl
<v4n_> hi guys
noImagination joined #ruby
<v4n_> does anyone use the mini_magick gem? The README example about create a new image doesn't work, as Image.create { } yields on a Tempfile and not the Image
possibilities joined #ruby
<possibilities> deep in a library i'm using a request is being made using Net::HTTP, in development everything is fine but in production it fails silently, any tips on how to debug this?
ctp joined #ruby
<ctp> hi folks. after mystring.split sometimes a get an array which contains whitespace e.g. [" ", "my", "splitted", "passphrase"]. how to remove the whitespace from this array?
bosphorus joined #ruby
io_syl joined #ruby
io_syl joined #ruby
<csavola> ctp: if you have activesupport #select(&:present?) or #reject(&:blank?)
<csavola> ctp: or #strip the string before splitting
<ctp> hm: [" ", "foo", " ", "bar"].reject(&:blank?)
<csavola> possibilities: if the library doesn't allow you to have hooks you may have to resort to monkey patching it to get the data you need
<ctp> NoMethodError: undefined method `blank?' for " ":String
<csavola> ctp: you don't have active support :)
thepix joined #ruby
<ctp> hm, ok
<ctp> should embed it into my rails code
<csavola> ctp: blank serves as both a nil check and a whitespace only check...
<ccooke> probably nicer to patch Regexp with a to_proc, though...
<possibilities> ctp, thanks, i switched to using the tcpflow util so i can see what's really going on
kaspernj joined #ruby
<JonnieCache> possibilities: thanks for the tip on tcpflow. its a less invasive pcap
<JonnieCache> actually no its based on libpcap. so it still needs root presumably?
musl joined #ruby
mafolz joined #ruby
h4mz1d joined #ruby
cdepue joined #ruby
<JonnieCache> ooooh, OS X ships with tcpdump included! didnt know that.
<noImagination> Hello, I'm attempting to move a file from one directory to a network drive (macintosh network). Wondering if anyone had guidance on how I could do that (maybe FTP?). I've made an alias directory but FileUtils throws an error that the alias directory is not a directory
<possibilities> now that i can see the results i'm not much better off, only difference is in one environment there's a couple pages of info i can't understand and in production there's half a screen
<JonnieCache> possibilities: maybe dump the traffic into a file with tcpdump, then open the dump in wireshark so you can analyse it better
<JonnieCache> wireshark is awesome
<possibilities> cool, i'll try n' figure that out, thank you
<JonnieCache> possibilities: time learning to use wireshark is time well spent
elliottcable joined #ruby
paraglade joined #ruby
linoj joined #ruby
daniel_hinojosa joined #ruby
anachronistic joined #ruby
badabim joined #ruby
mr_the_s_ joined #ruby
clockwize joined #ruby
iocor joined #ruby
<pjeide> JonnieCache, possibilities, agreed
<possibilities> JonnieCache, pjeide, just trying to figure out tcpdump at the moment. at the moment i can only see that i'm making a connection to the ip in question... is wireshark going to help me make sense of it?
<possibilities> or do i need to understand tcpdumps output for wireshark to be helpful
<JonnieCache> use `tcpdump -s 1514 port 80 -w capture_file` on your server
<JonnieCache> then download capture_file
Revernd joined #ruby
<JonnieCache> open it in wireshark, and it has a big fancy graphical interface which lets you inspect the contents of each packet, see all the http requests and everything
<JonnieCache> its a little bit like the network panel in firebug, but much much lower level
ikaros joined #ruby
<possibilities> awesome
fgro joined #ruby
Ammar01 joined #ruby
crankycoder joined #ruby
nonotza joined #ruby
moted joined #ruby
alfism joined #ruby
centipedefarmer joined #ruby
hukl_ joined #ruby
pdswan joined #ruby
<possibilities> without really being sure i think my problem might be that in production it doesn't like the cert of the external host
<JonnieCache> possibilities: what OS are you using in production?
<possibilities> linux 2.6
<possibilities> um, not sure which distro
cbuxton joined #ruby
<JonnieCache> it could well be a problem with out of date certs on your server
cbuxton joined #ruby
<JonnieCache> there has been some shuffling of CAs recently what with them all getting hacked
<possibilities> cool, just came across some info along those lines
<JonnieCache> you can get a fresh CA bundle from the cURL team here: http://curl.haxx.se/ca/cacert.pem
Araxia_ joined #ruby
<JonnieCache> how you install it/convince Net:HTTP to use it is up to you :)
<possibilities> seems like something i should talk to our sysadmin about (:
<JonnieCache> yeah well if you have that option then use it :)
ctp_ joined #ruby
airhorns joined #ruby
<possibilities> awesome thanks for getting me going in the right direction, i was dipping down near desperation
<JonnieCache> no problem
Russell^^ joined #ruby
adamkittelson joined #ruby
ianbrandt joined #ruby
youdonotexist_ joined #ruby
raythecat joined #ruby
Mahoek joined #ruby
Hellojere joined #ruby
SegFaultAX|work joined #ruby
josh__ joined #ruby
ctp joined #ruby
anachronistic joined #ruby
mr_the_shadow joined #ruby
mklappstuhl joined #ruby
Cervajz joined #ruby
Cervajz joined #ruby
moshef joined #ruby
mikepack joined #ruby
eywu joined #ruby
booginga joined #ruby
mrsolo joined #ruby
tehdekan joined #ruby
robbyoconnor joined #ruby
notbrent joined #ruby
narshlob joined #ruby
notbrent left #ruby
narshlob left #ruby
xpot-mobile joined #ruby
Tuxist joined #ruby
heftig joined #ruby
r0bby joined #ruby
eldariof joined #ruby
delian66 joined #ruby
bluOxigen joined #ruby
Ammar01 joined #ruby
rubyruy joined #ruby
rubyruy joined #ruby
jbpros joined #ruby
h4mz1d joined #ruby
linoj joined #ruby
fgro joined #ruby
<Brozilla> any data mapper superheroes here?
<Tasser> Brozilla, #datamapper
<Brozilla> yea, they're not really answering there :p
adeponte joined #ruby
flippingbits joined #ruby
cantonic joined #ruby
sie joined #ruby
shadoi joined #ruby
ceej joined #ruby
r0bby joined #ruby
friskd joined #ruby
ceej joined #ruby
mickn joined #ruby
<ceej> when doing class Auto::Ccc::NotesWorker < Auto::Ccc is it possible to inherit everything from Auto::Ccc including @ vars?
mrkris left #ruby
<ceej> seems like if I do things like extend FailedJob in Auto::Ccc those don't get inherited either
<csavola> ceej: Auto::Ccc is a module or class?
<ceej> a class
arpegius joined #ruby
io_syl joined #ruby
io_syl joined #ruby
eugynon joined #ruby
<csavola> ceej: I have to ask why an embedded class is inheriting... smells funny to me
RegEchse joined #ruby
Squarepy joined #ruby
skim1776 joined #ruby
skim1776 left #ruby
sepp2k1 joined #ruby
<ceej> csavola: I'm trying to define the default class that all the others will extend off to use that default behavior
kartouch joined #ruby
Squarepy joined #ruby
<ceej> I also want to be able to call export inside perform etc...
kuadrosx joined #ruby
wookiehangover joined #ruby
sbanwart_ joined #ruby
nerded joined #ruby
nachtwandler_ joined #ruby
sbanwart joined #ruby
cdepue joined #ruby
perryh_ joined #ruby
hukl joined #ruby
Squarepy joined #ruby
Ch4rAzZz joined #ruby
tvo joined #ruby
Squarepy joined #ruby
Ch4rAzZz joined #ruby
Morkel joined #ruby
avandenhoven joined #ruby
derekbarber joined #ruby
Indian joined #ruby
<avandenhoven> I need some advice on handling some stupid encoding issues. Most of my files are UTF-8 but some will come back as Windows ASCII. I'm going to run them through nokogiri and my first thought was to search/replace all the known bad character sequences and replace them with good ones but I try to do a gsub with the invalid character I get an "invalid byte sequence in UTF-8 (ArgumentError)" error. Any suggestions?
Xannix joined #ruby
<avandenhoven> I have no prior knowledge of which are encoded which way and there are 30k files so I'm not going to fix by hand if I can avoid it
Ch4rAzZz joined #ruby
<csavola> avandenhoven: are you on unix?
<avandenhoven> Mac
<avandenhoven> so pretty close.
gistisart joined #ruby
<csavola> avandenhoven: 'file --mime-encoding' will give you a fighting chance of distinguishing them
<csavola> ceej: I don't think you get to inherit class instance varibles as they will be associated with the class object that is "self" when they are defined
<avandenhoven> csavola: thx. I'll try that route.
voodoofish430 joined #ruby
strife25 joined #ruby
<ceej> csavola: I'm trying to avoid having to do this http://screencast.com/t/q4BZlrcmeUE
<csavola> ceej: if you made Auto:Ccc a module that you included you could use the .included hook to assign the default class instance variables you want
<ceej> csavola: would you be able to give me an example?
Tachyon joined #ruby
Tachyon left #ruby
eignerchris joined #ruby
io_syl joined #ruby
io_syl joined #ruby
<csavola> ceej: is activesupport required by your project?
<ceej> csavola: I'm using rails 3.1.3
<csavola> ceej: even if it's not the docs have an example ... api.rubyonrails.org look up activesupport::concern
<csavola> ceej: I can't figure out how to get a decent link from the new layout
r0bby joined #ruby
newneckname left #ruby
<csavola> ceej: my bad :)
<ceej> Auto::Ccc::NotesWorker needs to be a class
RegEchse joined #ruby
<csavola> Auto::Ccc::Defaults doesn't though
<csavola> Auto::Ccc::NotesWorker can include the other module
<ceej> it does because I'm doing this class Auto::Ccc < Resque::JobWithStatus
apok joined #ruby
zommi joined #ruby
kartouch left #ruby
<ceej> I just need NotesWorker to use any @ vars set in Auto::Ccc by default
youdonotexist joined #ruby
<csavola> ceej: I can't see a way that isn't a nasty hack for you to do that
<ceej> so I need to set the @ vars in every class? Seems silly you can't set default ones
ephemerian left #ruby
<avandenhoven> csavola: `file ...` worked like I charm.. hopefully i won't find too many variations in my archives but this gives me a fighting chance. Thanks for the help.
<ceej> csavola: can I access export inside of NotesWorker perform?
<shadoi> ceej: you can call super in the initialize of a subclass and get all the instance vars in a parent class.
<csavola> ceej shadoi: even those defined outside the initialize?
<shadoi> if the subclass uses those same methods, sure.
<csavola> ceej shadoi: you know we're talking about class instance vars though right?
<shadoi> class variables, or instance variables? There's no distinction for "class instance" variables.
<csavola> shadoi: yes there is... they are instance variables on a class object
jasim joined #ruby
<shadoi> @@ vs @
<shadoi> @var is an instance variable everywhere.
<shadoi> @@var is a class variable.
Ch4rAzZz joined #ruby
<shadoi> Correct, A.foo is also @@foo in the class.
<csavola> my markdown sucks by the way... go spaces :)
<shadoi> It's NOT a "class instance" variable.
<csavola> shadoi: it is not the same... @@foo can walk up a class hierarchy.. @foo cannot
jarjar_prime joined #ruby
<Mon_Ouie> shadoi: No, it's an instance variable on a class object
<Mon_Ouie> i.e. a class instance variable
<Mon_Ouie> Class variables are shared with subclasses
<shadoi> That makes no sense to me at all.
<shadoi> How can anything be an instance variable if it's not in an instantiation of something?
<Mon_Ouie> A class is an object
<yxhuvud> a class is an instance of Class.
<csavola> once you've defined a class you have an Class instance that is associated with a name
<Mon_Ouie> As such it can have all the properties of other objects
<shadoi> well fuck me.
robotmay joined #ruby
<shadoi> I never thought about classes that way at all.
<shadoi> That seems really confusing.
GreaseMonkey joined #ruby
Targen joined #ruby
<matti> Mon_Ouie: :-)
<yxhuvud> apart from @@ variables walking the inheritance chain, it is not confusing at all once you get your head around it.
<shadoi> Is this just an artifact of the pure OO design, or is it intended? Seems like pure insanity.
<yxhuvud> @@ walking the inheritance chain is why a lot of rubyists really don't like to use @@ at all.
<shadoi> I just always thought of @@ as a "class global"
Tachyon joined #ruby
<Tachyon> why the assignment doesn't work ?
QKO_ joined #ruby
<shadoi> why the parens around @fcs["ahoj"] ?
<Tachyon> i tried to rule out the error of possibly wrong operator precedence
dcarper joined #ruby
robyonrails joined #ruby
<Mon_Ouie> oddly, (foo[bar],) can be used as an lvalue
<shadoi> Tachyon: works fine without them…
<Tachyon> it doesn't work for me even with them
<ceej> thank you all for your help btw
<Mon_Ouie> Adding the parens is what's causing the syntax erro
<Mon_Ouie> error*
Jake232 joined #ruby
<Tachyon> :o)
<Tachyon> really? :D
<shadoi> @fcs["ahoj"]=proc {|arg| print arg}
<shadoi> => #<Proc:0x00000002e93660@(irb):21>
<shadoi> irb(main):022:0> @fcs["ahoj"].call("hi")
<shadoi> hi=> nil
v4n_ joined #ruby
<Tachyon> it says to me
<vauban> that looks hideous
<Tachyon> test2.rb:1:in `<main>': undefined method `[]=' for nil:NilClass (NoMethodError)
<Mon_Ouie> Because @fcs is nil
<Tasser> shadoi, puts makes for a better reading expirience, as it includes \n by default
<shadoi> @fcs = {}
<Tachyon> it must be initialized before ?
<shadoi> Tasser: Just using Tachyon's example. :)
pootpoot joined #ruby
<Tasser> Tachyon, yeah, no magic there
<Tachyon> ah ok, that is the problem :)
<Tachyon> tx vm :)
<Tachyon> ha works like charm :)
esparkman joined #ruby
Ch4rAzZz joined #ruby
kaneda joined #ruby
raythecat joined #ruby
Na_Klar joined #ruby
rbanffy joined #ruby
jasim left #ruby
p1d joined #ruby
Ankhers joined #ruby
Sunil01 joined #ruby
<Na_Klar> I know shoes != ruby but #shoes is like *tumbleweed*: Using shoes r1514, there seems to be no option to pack to .exe (nor for osx or linux) files. Only .shy is supported. Is that feature gone?
luke--_ joined #ruby
Amirh joined #ruby
apeiros_ joined #ruby
austinbv joined #ruby
xol joined #ruby
kirun joined #ruby
pantsman joined #ruby
pantsman joined #ruby
cbuxton joined #ruby
LBRapid joined #ruby
Guedes0 joined #ruby
Guedes joined #ruby
Guedes joined #ruby
jbw joined #ruby
LBRapid joined #ruby
manizzle joined #ruby
io_syl joined #ruby
Pip joined #ruby
clockwize joined #ruby
austinbv joined #ruby
dyer joined #ruby
ycy joined #ruby
<ycy> hi there
<ycy> is there a way to print a date with a localized message? e.g. the date with french names of months.
robyonrails joined #ruby
<csavola> ycy: look at localize
thepix joined #ruby
LBRapid joined #ruby
rbanffy joined #ruby
ph^ joined #ruby
Spockz joined #ruby
Axsuul joined #ruby
stephenjudkins joined #ruby
<Na_Klar> isn't there a shorter way for: foo = bar[0...(bar.length-1)] ?
ryanf joined #ruby
wookiehangover_ joined #ruby
<csavola> Na_Klar: bar[0..-1]
<apeiros_> Na_Klar: for? you probably want foo = bar[0...-1]?
<Na_Klar> hm? I tried that and it failed ... but I surley missed something :P ty
Amirh joined #ruby
<csavola> Na_Klar: you may have bar[0, -1] which will return nil
<yxhuvud> considering it is indexes, I'd use .. with -2 instead.
<apeiros_> yxhuvud: I prefer that too
<apeiros_> the third dot is easily overread
<apeiros_> overlooked? overseen? meh…
<Na_Klar> I see .. and no, no .. it was ".." vs. "..." :P
<apeiros_> Na_Klar: for Array#[], 0..-2 is the same as 0...-1
LouisJB joined #ruby
<Na_Klar> yea but 0..-1 was meaningless
<apeiros_> ?
<apeiros_> define "meaningless"
poorlilrichboy_ joined #ruby
<apeiros_> ary[0..-1] is basically the same as .dup…
<apeiros_> but not meaningless.
dankest joined #ruby
v4n_ joined #ruby
<Na_Klar> well, it is the same like foo = bar .. no sence doing foo = bar[0..-1]
havenn joined #ruby
<apeiros_> Na_Klar: it's not the same, no.
<apeiros_> you get a new object with slicing. you don't get a new one with merely assigning.
<Na_Klar> hm .. didn't know that foo = bar will not create a now object ...
<Na_Klar> s/now/new/
<apeiros_> a = "hello"; b = a; p a.object_id, b.object_id
<yxhuvud> It copies the reference, but not the object itself.
rpowell joined #ruby
<Na_Klar> apeiros_, but as soon as I change the value of b it becomes a new object
jarjar_prime joined #ruby
<apeiros_> depends on what you mean by "change the value of b"
poorlilrichboy_ joined #ruby
<apeiros_> I'd not use the term "a variable *becomes* an object", as that's in my understanding never true
<apeiros_> you can always only *assign* objects to variables
<Mon_Ouie> b << 3 # since there's only one object, a is affected too
ycy left #ruby
<apeiros_> so variables never become, neither do they become objects. they reference objects, and you can change what object a variable references.
<Na_Klar> ok, ok, but I got it. Ty
ignis joined #ruby
Ch4rAzZz joined #ruby
io_syl joined #ruby
io_syl joined #ruby
austinbv joined #ruby
voila joined #ruby
voila left #ruby
<tommylommykins> hmm
* tommylommykins seems to be having trouble putting array literals into function arguments
<tommylommykins> Hardware.new(masked_inverter, [latcher, input], [output])
<tommylommykins> ===> gates.rb:15:in `initialize': wrong number of arguments (1 for 3) (ArgumentError)
<apeiros_> that exception doesn't correlate with the code you gave
norex joined #ruby
<apeiros_> 1 for 3 would mean you passed only 1 argument. but in the code you show, you pass 3 arguments.
<csavola> apeiros_: the error is for a different class
<apeiros_> csavola: I don't see from what you gather this. no class is mentioned in the exception.
<csavola> gates.rb:15:in `initialize'
<apeiros_> that does not mention a class.
<apeiros_> it mentions a file, a line and a method.
gobji joined #ruby
<csavola> I guess a new violation wouldn't necessary throw an arity exception with the class being instantiated... my bad
<BrianE> Look at gates.rb:15. It's calling a method with one argument. It should have 3. The line you pasted just ends up executing that line
cyri_ joined #ruby
<apeiros_> csavola: of course, if the code is sane, gates.rb means it contains a class Gates. but that's just an assumption.
cpruitt joined #ruby
mickn joined #ruby
araujo joined #ruby
<tommylommykins> oh
possibilities joined #ruby
<tommylommykins> Thanks
<csavola> apeiros_: The error is a little miss leading I think though... technically .new takes a splat... it then calls #initialize with those arguments. I wonder if there is some optimisation magic happening to hide that call
AutoMan left #ruby
<apeiros_> csavola: Class#new is implemented in C
<apeiros_> for which reason you won't see it appear in the backtrace
<csavola> apeiros_: touche
Morkel joined #ruby
kenichi joined #ruby
<yxhuvud> being implemented in C counts as optimisation magic, no? :?
<apeiros_> it can also count as "make it at all possible" magic ;-)
<apeiros_> though, Class#new could be implemented in pure ruby
<apeiros_> Class#allocate
<csavola> I'm looking through Rubinius source to see what they do
<apeiros_> *Class#allocate OTOH could not.
<apeiros_> I wouldn't wonder if it was just: class Class; def new(*args, &block); obj = allocate; obj.__send__(:initialize, *args, &block); obj; end; end
Guedes joined #ruby
Guedes joined #ruby
y3llow joined #ruby
s0ber_ joined #ruby
<v4n_> when is it better to use String#bytesize instead of String#length?
burgestrand joined #ruby
ph^ joined #ruby
<csavola> that's pretty much what rubinius is doing... https://github.com/rubinius/rubinius/blob/master/kernel/alpha.rb
Nate75Sanders joined #ruby
petercoulton joined #ruby
Vendethiel joined #ruby
Muon joined #ruby
<apeiros_> v4n_: when you want to know how many bytes a string uses instead of how many characters
<Muon> what's the neatest way to transform a list of lists into a list of hashes? like [ [1, 2], [4, 5] ] to [ { :a=>1, :b=>2 }, { :a=>4, :b=>5 } ]
<apeiros_> Muon: and :a, :b come from thin air?
<Muon> apeiros_: they're known in advance
<apeiros_> Muon: doesn't answer my question. are they known by magic or what?
<Muon> apeiros_: they're known because the code expects the first element of each to map to :a and the second to :b
Ch4rAzZz joined #ruby
<yxhuvud> sounds like magic to me
<Muon> magic?
<apeiros_> keys = [:a,:b]; list.map { |values| Hash[keys.zip(values)] }
<apeiros_> Muon: and you should state such things. we can't read your mind to figure that out.
Spockz joined #ruby
Cervajz joined #ruby
<Muon> apeiros_: I hoped you would figure it out because I repeated the :a, :b twice
<apeiros_> Muon: pro-tip: don't hope
<apeiros_> you only make people angry with that
<apeiros_> you might get an answer in kind next time ("oh, I thought it'd be obvious how to puzzle that stuff together")
norex joined #ruby
brownies joined #ruby
<brownies> can someone please help me with SQL and ActiveRecord? i want to do something that i think is simple...
ada2358 joined #ruby
h4mz1d joined #ruby
<brownies> i have a bunch of objects in a table, and i'd like to count how many were created per day
<brownies> so the output would be a table of 2 columns that look like ("2011-11-20", 38)
<brownies> i vaguely remember how to do it with raw SQL, but the complication of activeRecord on top is... complicated.
<apeiros_> brownies: you want to group by the date and use the aggregate function 'count'. for AR, please use #rubyonrails
<brownies> group by! that was it. thanks.
<shaatar> brownies: also check out https://github.com/lakim/sql_funk
tyman joined #ruby
tyman joined #ruby
<shaatar> That might be a little out of date but probably pretty easy to update for your needs.
<apeiros_> if things get ugly in AR, I tend to create a view and make a model on top of that view
<apeiros_> e.g. class ObjectCounts < AR::Base; set_table_name :that_view; … end
<apeiros_> (you have to account for the missing primary key too)
<brownies> my app is going to need views... lots of views... but i'm putting that off.
<brownies> i'm pretty good with straight SQL but shoehorning it into {{ framework }}'s ORM is always a challenge
SegFaultAX|work joined #ruby
fgro joined #ruby
Azure|dc joined #ruby
austinbv joined #ruby
amacgregor joined #ruby
<ryanf> brownies: also bear in mind that if you need to do some counts or whatever, you always have the option of just doing it in raw sql
<brownies> ryanf: can you please tell me how i could drop down to just access raw SQL input and output via rails console?
<v4n_> apeiros_, ok, so for a image body, that's better to use bytesize then, right?
Amirh joined #ruby
<brownies> ryanf: i'm trying to query production server stats so i'm stuck with "heroku run console" as the entry point
<apeiros_> v4n_: for an image body, your string's encoding would better be 'binary', and then it doesn't matter. but yes, if you want to be superubersure, use bytesize.
badabim joined #ruby
<apeiros_> brownies: as said, AR should be discussed over in #rubyonrails, thank you.
<ryanf> brownies: you can do like c = ActiveRecord::Base.connection, and then c.execute "sql" I guess
<ryanf> I'm sure there are better ways too
<brownies> thanks
<ryanf> the "select" method gives more conveniently formatted results, but it's protected, so you'd have to do c.send(:select, "select * from whatevs;")
<ryanf> and then you get an array of hashes
<brownies> apeiros_: i like to start here instead, since #ror is useless and trolly, but i'll give it another chance later
xol joined #ruby
<v4n_> apeiros_, I'm receiving an image body in a Sinatra app and I want to store the image size. Should I call #force_encoding("binary") or something, or calling bytesize is enough? What's the better choice in that case?
xol joined #ruby
crescendo joined #ruby
xol joined #ruby
<apeiros_> v4n_: given that it is binary data, I'd make sure its encoding is correct. I'd assume that sinatra does that correctly already, though.
xol joined #ruby
<apeiros_> so: use bytesize. check whether sinatra gives you a string with 'binary' as encoding.
xol joined #ruby
saurium joined #ruby
sjltaylor joined #ruby
ctp joined #ruby
<apeiros_> brownies: I don't care whether #ror is useless. this is not #ror and #ror topics belong there.
xol joined #ruby
<brownies> ryanf: figured it out. thanks!
jasonseifer joined #ruby
<ryanf> np!
kevinbond joined #ruby
SegFaultAX|work joined #ruby
kevinbond_ joined #ruby
Spockz_ joined #ruby
<Tasser> apeiros_, oversized hammer again? :-P
<apeiros_> Tasser: there ain't such a thing as oversize with hammers…
sdwrage joined #ruby
anachronistic joined #ruby
xissburg joined #ruby
crankycoder joined #ruby
youdonotexist_ joined #ruby
voobles joined #ruby
cableray joined #ruby
tokumine joined #ruby
chrxn joined #ruby
axiak joined #ruby
<axiak> hey - I have installed ruby1.8 in ubuntu with gem
<axiak> and now when I install a gem I have no idea where it goes
<axiak> for example, both heroku and foreman are installed, but I can't for the life of me find either foreman or heroku
<voobles> what can i do instead of this ugliness: (eval "@var.#{some_method}(#{some_args})").another_method ? anybody?
ryanf joined #ruby
io_syl joined #ruby
<apeiros_> axiak: `gem env` in your shell, shows where what goes.
<apeiros_> voobles: Object#send
<voobles> apeiros_: thank you!
<ReinH> o_O
<axiak> thanks!
<ReinH> send: marginally better than eval
<axiak> I kept looking at /usr and $HOME
<axiak> didn't think it'd be in /var :|
bosphorus joined #ruby
igotnolegs joined #ruby
<apeiros_> ReinH: so what's "the right way"™ for method invocation by variable?
kuadrosx joined #ruby
<workmad3> apeiros_: dropping back to C and using function pointers... obviously :P
<apeiros_> workmad3: you mean that 3 letter part in your nick, dontcha?
<workmad3> apeiros_: definitely... I'm most definitely 'wor'...
<apeiros_> I knew it
<apeiros_> though I was pondering ad3 too
<apeiros_> ork is nice as well…
strife25 joined #ruby
Azure_ joined #ruby
chrxn joined #ruby
<ReinH> apeiros_: why do you have to do it in the first place?
<ReinH> simulating a hash table with method dispatch tends to be inferior to using a Hash
stkowski joined #ruby
<apeiros_> ReinH: I don't have to do it :)
<apeiros_> also a Hashtable isn't *quite* the same as an object with methods it responds to
mxweas_ joined #ruby
<apeiros_> hashtable entries don't take arguments, or do they?
<apeiros_> of course, you can store procs in your hashtable, but then the question is - didn't you just reinvent an object system? so why not just use send?
eignerchris_ joined #ruby
dbe joined #ruby
iocor joined #ruby
<ReinH> apeiros_: depends on the use case, ofc
<ReinH> but a lot of the use cases for send seem to be poor man's hash tables
Guedes joined #ruby
ChampS_ joined #ruby
sorin joined #ruby
sorin left #ruby
negative joined #ruby
<ReinH> a hash of procs makes for a nice selector for a strategy pattern, for example
<ReinH> can also use objects with some uniform interface
negative joined #ruby
cableray joined #ruby
<ReinH> (which could just be #call)
<apeiros_> that's reinventing the wheel.
atmosx joined #ruby
hukl joined #ruby
<apeiros_> or rather, the object model.
<apeiros_> pretty pointless IMO.
seejohnrun joined #ruby
<apeiros_> (funny enogh, javascript objects mostly are that - hashes with procs)
johnduhart joined #ruby
ryanf joined #ruby
namidark_ joined #ruby
tokumine joined #ruby
badabim joined #ruby
chrxn joined #ruby
_debo joined #ruby
ghanima joined #ruby
chiel joined #ruby
Targen joined #ruby
<Avi`> I'm trying to figure out the proper uhm.. I know what I need to do, but I don't know how to describe it in Ruby terms. I have a hash { } with properties. one of those properties is an array of hashes. I want to select for properties in the hashs array of hashes that have a specific value.. BUT i want to keep the whole structure intact..
<Avi`> so when i do just item[:property].select { |x| x[:value] == 1 } it destroys the structure of the object
<Avi`> and just gives me the objects inside, if that makes sense?
<Avi`> is there a useful way to say identify those and pull their whole structure out instead of just those?
Clooth joined #ruby
_debo joined #ruby
<seejohnrun> Avi`select will keep the original intact
<seejohnrun> Avi`select! will do it in place
<Avi`> thats not what i meant
<Avi`> i don't mean its modifying the original object
<Avi`> i mean that its pulling the object from item[:property] out. and i want to say keep the item structure in place
<Avi`> but only keep things that meet this 'select' criteria?
poorlilrichboy_ joined #ruby
<seejohnrun> you could do a #map and construct the hashes in the arrays inside of the map
<Avi`> i guess
<Avi`> wow im stupid
<Avi`> i should do item.select { |x| x[:property] == something }
<Avi`> what a dope
eignerchris joined #ruby
<Avi`> nvm that didn't work hah
<Avi`> okay ill go look at map
io_syl joined #ruby
io_syl joined #ruby
kf8a joined #ruby
youdonotexist joined #ruby
randym joined #ruby
VxJasonxV joined #ruby
<VxJasonxV> Is there a particularly prefered Ruby IDE? Something that really takes advantage of irb for debugging/inspecting, rails-compatible, and all that?
<VxJasonxV> Something like Perl's Padre that doesn't run like garbage in OS X :).
<apeiros_> is there any IDE that doesn't run like garbage? o0
<VxJasonxV> vim with lots and lots of custom work? :)
<chiel> if I want to print the entire structure of a variable, how would I do that?
<VxJasonxV> I completely forgot about RadRails/Aptana
<VxJasonxV> And the venerable Eclipse. But, well, I point back to the 'not like garbage'.
<apeiros_> chiel: obj.inspect and obj.pretty_inspect are used for that
<apeiros_> pretty_inspect requires you to require 'pp'
<apeiros_> also to_yaml and other serializations can be used.
renanoronfle joined #ruby
<workmad3> VxJasonxV: you could look at RubyMine... some people seem to like it
<workmad3> VxJasonxV: I just use vim personally
<chiel> apeiros_: thank you :)
<shadoi> Anyone done any benchmarks on the new stdlib json support against YAJL?
<VxJasonxV> I'm vim'ing it so far, I just saw that and the others listed at the bottom of ror.org/download. So I'm starting there.
<VxJasonxV> Thanks :).
VxJasonxV left #ruby
<Avi`> seejohnrun: okay so the solution i came up with is to do this. i make a copy of the top level item, then i call result1= item[:property].select! { my check} on it, then result2 = item2[:property].select! {myOthercheck}
<workmad3> VxJasonxV: or, if you're on a mac, you could always jump on the hipster bandwagon and go with TextMate
<Avi`> that keeps my structure intact
<Avi`> workmad3: you mean sublime text 2
<workmad3> Avi`: or maybe I mean redcar? :P
<Avi`> sublime text 2 > textmate
<Avi`> by far
Mahoek joined #ruby
dagnachewa joined #ruby
* apeiros_ throws redmine into the mix
<Avi`> bonus its not mac only
<Avi`> isn't redmine a CMS?
<apeiros_> bonus, it eats all your ram…
<workmad3> apeiros_: what the hell are you doing throwing a bug tracker in the mix?
<apeiros_> arr, damit, not redmine, *rubymine*
<chiel> apeiros_: do you happen to use the mysql2 gem?
<workmad3> apeiros_: I'd already said rubymine :P
<apeiros_> chiel: I happen to be as happy as not to use mysql
<apeiros_> workmad3: silence!
<chiel> apeiros_: clever guy :D
<apeiros_> workmad3: I keeel you!
<apeiros_> chiel: maybe just stupidly lucky guy
<workmad3> apeiros_: not if I keeel you first :P
<chiel> anyone here use the mysql2 gem? :)
<apeiros_> mysql is php-hip
<workmad3> Avi`: I tried TM for about a day and decided I couldn't be bothered :P
<apeiros_> sqlite & postgres are ruby-hip sql
<apeiros_> but even more ruby-hip are nosql's
<chiel> I can only find a way to loop results, with results.each, not a way to simply grab the first row.
<Avi`> sublimetext 2 man
<workmad3> Avi`: will it beat vim? :P
<chiel> apeiros_: perhaps, but mysql is what I am familiar with atm.
<apeiros_> chiel: is there a reason that you have to use mysql?
<chiel> apeiros_: there is not. :)
<chiel> like I said, it's what I am familiar with.
<apeiros_> chiel: do you have more than a couple of thousand records?
<Avi`> i never got into vim/emacs sorry
<Avi`> so i can't say
<chiel> Since I'm only just learning how to use ruby, I'd like to take it one step at a time. :)
<Avi`> i had a life before i found out about vim/emacs so i didn't have any spare time to bother learning them
<chiel> apeiros_: if all goes as planned, I will, yes.
<apeiros_> chiel: sqlite is *very* painless
<apeiros_> and if you use a database abstraction, you can switch to another db easily.
<tightwork> Avi`: how did you code before vim/emacs?
<chiel> apeiros_: yeah, but atm I just want to focus on learning ruby. :)
<Avi`> uhmm
<chiel> I can switch that stuff out later. ^^
<Avi`> lets see here
mxweas_ joined #ruby
<Avi`> the first IDE i ever used was borland builder i think
<workmad3> chiel: why not do a project that doesn't need to bother with a database then? save the time of learning a db driver? ;)
<apeiros_> chiel: well, it sounds to me like installing mysql for ruby gets in your way to learn ruby…
<Avi`> after that it was xcode, then textmate
<Avi`> and now sublime text 2
tightwork left #ruby
<chiel> apeiros_: I already have mysql installed locally, and the gem for it. I already can query it etc, so it's not really the issue
<chiel> when I go into production, yeah, I don't really want to use mysq
<workmad3> Avi`: I'm gone through Visual Studio, CodeWarrior, Eclipse (in various forms... carbide, plain eclipse, aptana), RubyMine, gedit, a brief stint with emacs, nano and vim :)
<chiel> buuuuut like I said, just getting used to ruby atm. :)
<apeiros_> chiel: then what's your problem? o0
<Avi`> oh wait i forgot VS
<Avi`> been awhile =)
<chiel> workmad3: I have a project I made in php before, I am trying my luck at doing it in ruby. :)
<chiel> apeiros_: I can't seem to grab just a single result. :P
mr_the_shadow joined #ruby
jonathanrwallace joined #ruby
<workmad3> chiel: if you're using the Mysql2 gem directly, you won't be able to just switch out MySQL in production...
<apeiros_> chiel: good heavens, now that's a huge problem :-p
<chiel> workmad3: I know, but the querying happens in just one class :)
<chiel> so I don't mind putting in effort later to replace it
<chiel> it's mostly a javascript centric app.
<chiel> apeiros_: lol :p
<apeiros_> chiel: you can always get a single value out of a collection in ruby…
<apeiros_> but I'd guess all you have to do is study the mysql gem's docs a bit more carefully :)
<apeiros_> alternatively, use something like sequel:
<Tasser> apeiros_, I wouldn't call sequel an O/RM ^^
<chiel> yeah, I must admit I mostly skimmed the docs. :)
<chiel> there only seems to be the github page. :)
<apeiros_> Tasser: sequel a) has an ORM, and b) I use sequel exactly for the reason that it can be used *without* the ORM part
<shadoi> Tasser: actually it is, it can behave exactly like ActiveRecord in fact.
<apeiros_> Tasser: and yes, the ORM part of sequel is very much an ORM
<Tasser> apeiros_, they don't put that on front
<apeiros_> Tasser: so?
<Tasser> oh, I see
mindCrime joined #ruby
<Avi`> so I did a quick check in irb by assigning a value to a, then saying b=a, then modifying a, and a & b were different things. but in this example..
<Avi`> it seems that line 4 is mutating the data that line 5 uses
iocor joined #ruby
<Avi`> shouldn't they be different?
<apeiros_> Avi`: you do NOT want to use the return value of select!
<apeiros_> it can be nil
<Avi`> apeiros_: yeah, well in this case thats exactly whats happening, ERROR ActionView::Template::Error: You have a nil object when you didn't expect it!
<apeiros_> also you kill your dataset
<Avi`> but it should only be nil if line 4 has modified 'closedItems' so thats sort of tangental i think
<Avi`> apeiros_: well sure the whole point was to NOT mutate 'item'
<apeiros_> noClosedItems, closedItems = item <-- both refer to the same object
<Avi`> and instead mutate these other two objects
wilmoore joined #ruby
<apeiros_> so if you modify one *in place* (which you do, with select!), the "other" sees it too (since it really *is not* another, it's the same)
<Avi`> apeiros_: err then what happened in irb when i did a = "hello"; b=a; a="test"; a,b "hello" "test"
<apeiros_> you reassigned
jsaak joined #ruby
<Avi`> apeiros_: yes what you described is what i assumed happened, but based on what i checked i didn't figure it should
<Avi`> okay so i need to say item.clone
<apeiros_> select! mutates the object
<Avi`> apeiros_: right i know
<apeiros_> that probably won't work. clone is shallow.
<apeiros_> just don't use select!, use select.
<apeiros_> you want the return value anyway
<Avi`> using .select doesn't returnthe whole object
<apeiros_> also, you can then use item straight away instead of assigning it to two other vars.
<Avi`> it returns the objects that it found, which leaves me with out item
<apeiros_> oh dear
<Avi`> it just gives me item[:relations]
pootpoot left #ruby
<apeiros_> you have a serious design issue
chrxn_ joined #ruby
<Avi`> apeiros_: basically i started using select, but select was returning again, the objects that matched the value, when i needed the 'whole' object, not just the nested object select found
chrxn_ joined #ruby
<apeiros_> Avi`: seriously, reconsider your design. it smells.
<Avi`> apeiros_: uhm the design of what?
<Avi`> having a hash with hashes with arrays of hashes?
<Avi`> seems a bit standard in ruby
<apeiros_> of your datastructures.
<Avi`> or you mean my design for trying to get data out
<apeiros_> it seems standard bad ruby, yes.
<apeiros_> standard good ruby is proper classes.
<apeiros_> classes are cheap, you know?
<Avi`> okay well its always easy to say 'gosh that design sucks, you should redo it'
<Avi`> when you are standing on the other side of things
<apeiros_> no, I know that good design is hard
<apeiros_> it doesn't help saying "oh, but it's hard"
<apeiros_> it does help to go get working
benja-M-_ joined #ruby
MHD joined #ruby
<Avi`> redesign is totally out of scope
<apeiros_> and I say that with plenty of experience backing that up.
<MHD> I have some problems with wxruby
<apeiros_> well, then good luck.
* bean agrees that proper classes would be the way to go.
<MHD> When I try to require 'wx' it reports that _ZN16wxStyledTextCtrl7SendMsgEill is not defined or something
<shadoi> instead of doing the select, instantiate a new class that can handle the data structure.
jonathanrwallace joined #ruby
Mahoek joined #ruby
dv310p3r joined #ruby
nari joined #ruby
cooper joined #ruby
ikaros joined #ruby
dbgster joined #ruby
vitoravelino joined #ruby
Pip joined #ruby
Pip joined #ruby
badabim joined #ruby
zigidias joined #ruby
bigkm joined #ruby
kuadrosx joined #ruby
Bonkers joined #ruby
austinbv joined #ruby