apeiros_ changed the topic of #ruby to: programming language || ruby-lang.org || Paste >3 lines of text in http://pastie.org || Rails is in #rubyonrails
_whitelogger has joined #ruby
<robacarp> wat
<examancer> that should throw a STOP exception
<davidcelis> Time.alias_method :now, :hammer
cheba has quit ["Linkinus - http://linkinus.com"]
andrewvos has quit [#ruby]
<davidcelis> NameError: undefined method `now' for class `Time'
<davidcelis> ಠ_ಠ
<nikhgupta> guys how can i dump all the attribute names an object has
<nikhgupta> e.g. if post has a status, commentable attribute: i wanna print -> status, commentable
niku4i has joined #ruby
banister_ has joined #ruby
<davidcelis> nikhgupta: rails?
<nikhgupta> yeah.. but pure ruby will also have something like that
Vert has joined #ruby
<examancer> obviously I'm a bit bored at work: https://gist.github.com/2141673
<robacarp> nikhgupta: pretty sure you can just do post_instance.attributes on an activerecord, but its really a #rubyonrails question
startling has joined #ruby
<nikhgupta> hmm :) thank you robacarp
arphen has joined #ruby
<arphen> hey :)
<examancer> working Time.cant_touch_this implementation: https://gist.github.com/2141673
<arphen> suppose i do "return array" in a function
<arphen> will it deep or shallow copy
<examancer> if you return an array it returns the reference. no copy.
<arphen> always?
<examancer> yes
<examancer> `return array.dup` will return a copy, but not sure how deep it is
<arphen> shallow copy means the reference
<arphen> thanks :)
<shadoi> arphen: just use object.object_id to see
<arphen> i hope it works
<examancer> oh
<examancer> i see
h4mz1d has joined #ruby
<arphen> the usual trial and error process is made more difficuult by the complexity of the project im working on :(
<arphen> that's why i figured i might get the answer here quicker
<arphen> so thanks
looopy has joined #ruby
Morkel has joined #ruby
csprite has joined #ruby
kinderman has joined #ruby
bglusman has joined #ruby
<Morkel> i have a problem with bundler. When i install my gems with ' bundle install --path vendor/bundle' than i have this 'vendor/bundle/ruby/1.9.1 ' folder. But i use Ruby 1.9.3
<shadoi> 1.9.1 is the lib version
startling has quit [#ruby]
<examancer> bundler disagrees
<Morkel> shadoi: so this is no problem?
<shadoi> Morkel: expected.
n1x has quit ["Ex-Chat"]
<arphen> thanks, it works. but right now i'm astonished my code is even working
<Morkel> at the moment i have a problem with -> Error on line 131: Invalid US-ASCII character "\xE2" but i can't find any US chars at this line
<arphen> iv cut down a 1200 line imperative style program to 450 lines , hooray glorious OO
<shadoi> :)
<examancer> if you can't do it in one line its not worth doing
<arphen> i'm scared of the OO overhead though
<examancer> :-P
<shadoi> arphen: how fast does it need to be?
<examancer> in Ruby everything is already an object, so you don't realy pay much penalty for doing it right
<arphen> i have no idea yet
<shadoi> oh you do, ruby is slow. that's a given.
<arphen> it will be a server script
<shadoi> Much faster in jruby or rubinius after byte-compiling
<examancer> i'm just saying, if you use Ruby you are already paying the OO overhead whether your app is OO or not
<shadoi> ah
<shadoi> yeah
<arphen> i will have to do some real life testing to see what goes
<examancer> making your app actually OO doesn't incur an additional penalty if you are already using Ruby
<arphen> yes examancer good point
zakwilson has joined #ruby
<Morkel> shadoi: can i change the lib version to 1.9.3?
<shadoi> Morkel: you have to recompile and hack the build system your self.. but sure… ;)
<Morkel> ok than is 1.9.1 fine :-)
<shadoi> Config::CONFIG["RUBY_PROGRAM_VERSION"]
<shadoi> may be more of what you want.
<arphen> is it viable to run your website off a ram disk?
<shadoi> arphen: sure, why not?
<arphen> good
<examancer> arphen: its possible, yes, but your app is already in RAM once loaded
<arphen> it's not about the app
<arphen> my boss and me decided against using a grown out database and i'm just dumping ruby objects onto the disc
<arphen> which is very comfortable, but hdd access would kill the concept i think
<examancer> you'll just need to make sure you have a strategy to deal with the fact that the RAM drive is volative
<examancer> ie: it will disappear
<shadoi> arphen: use KyotoCabinet
<examancer> or Redis :-)
<shadoi> no
<fowl> arphen: you want to store all the content in memory?
<arphen> i will cronjob it to mirror to hdd
<shadoi> KyotoCabinet can be used as a pure library
<shadoi> very very simple.
burns180_ has joined #ruby
<arphen> what does it do
<shadoi> a lot like sqlite without the SQL
havenn has joined #ruby
<arphen> ill check it out shadoi
<arphen> yes fowl , i plan to mount tmpfs and then cronjob it to mirror every 10 minutes or so
<arphen> the content on the site will be 10 megabytish i think
<arphen> not larger than a hundred in any case
<shadoi> the third example here is good: http://fallabs.com/kyotocabinet/rubydoc/
<examancer> Redis has tons of data types, uses memory more efficiently than native Ruby types, and handles persistence for you
<arphen> shadoi, the thing is iv already done all the file accessing my way
<arphen> i'd have to rewrite all of that which was the vast part of last nights work
<examancer> if you've already got a solution don't change course, but if you start to run into technical hurdles then look at other solutions
<arphen> exactly what i was thinking
<shadoi> arphen: you mean you don't rewrite this stuff constantly? sounds scary to me. :)
<shadoi> Just saying, you could probably simplify it GREATLY.
<arphen> the data i'm handling is in its majority of very little persistent value
<arphen> it's already _ded_ simple just sayin
<examancer> yes, both KyotoCabinet or Redis would be simpler overall than your RAM Drive approach
<examancer> no mirroring or any other funny business
<shadoi> And you won't hate yourself when you have to change approaches later because it can't scale.
<shadoi> at 4am on valentines day weekend.
<examancer> right, and using Redis would allow other apps to use the data much more easily. KyotoCabinet might help with that too.
<arphen> this will scale better than any other solution i think, because at the end of the day nothing is faster than a ram drive
<shadoi> kyototycoon is a server that speaks kyotocabinet, but you don't need external service dependencies at this point.
<examancer> so when you decide your API needs to be written using node.js you can just read your Redis data with no fuss
<shadoi> arphen: filesystems are SLOW.
<arphen> wat
<Morkel> how can i set the default encoding for ruby?
<shadoi> why do you think databases exist?!
<arphen> shadoi, have you ever looked at comparsions between filesystem access on ramdisks and databases?
<arphen> databases are significantly slower
<shadoi> arphen: put the db file on the ramdisk
<examancer> arphen: shadoi is right... nothing is faster than a good in-memory database, like Redis, memcached, or Kyoto
<shadoi> the filesystem operations are what make it slow, not the fact that it's in memory or not.
<arphen> im still not getting what youre saying... how can anything be faster than directly accessing the memory
<examancer> because you have to go through slow sys calls
<arphen> tmpfs isnt even a real FS
<arphen> its just mapping memory
<examancer> which are wicked fast, but slow compared to Redis/memcached
badabim_ has joined #ruby
<robacarp> ^^
<arphen> even redis memcached HAVE to do fs access
<examancer> no
<examancer> they are in memory
<arphen> of course
<arphen> so is my database
<examancer> they directly allocate blocks of memory. no file system calls required.
badabim_ has joined #ruby
<arphen> i repeat tmpfs is just mapping memory, like any other program
<examancer> you database is in memory, but you have to use system file system calls to access it
<examancer> that's a whole layer you don't have with Redis/memcache
<examancer> *memcached
<arphen> you have to access memory sometime, correct?
<arphen> and those memory accesses are managed by the OS
<shadoi> arphen: tmpfs is fine, i'm sure you won't run into any issues until much later, or if you get slashdotted or something.
<arphen> per definition
<examancer> yes, but accessing it directly is faster than accessing it through a file system abstraction
<arphen> examancer, either you're trolling me or not reading my replies
<arphen> tmpfs is not a proper file system
<arphen> tmpfs is just mapping memory
<arphen> there is no abstraction
<examancer> arphen: yes, but its mapped memory accessed through file system sys calls
<arphen> there is no file system sys call
<shadoi> arphen: you will thank yourself if you use something structured around your data if you ever have to scale it out, but what you have is fine for now.
<arphen> shadoi i greatly appreciate your help. my app will never have more than say... 1000 simultaneous users (not per second but in the same timeframe) , is that much? i cant even tell
<arphen> examancer is trolling me though
<davidcelis> TIL that Ruby 1.8.7 DOES have Array#sample
<davidcelis> it's just unfortunately named Array#choice
<shadoi> arphen: 1000 simultaneous is pretty huge actually.
<arphen> submitting data every... couple of minutes
<arphen> at most
<shadoi> arphen: actually he's write that even tmpfs goes through the filesystem kernel calls the same way any other filesystem does.
<examancer> i'm not trolling anyone. tmpfs is in fact an abstraction. it creates file objects with things like permission flags and other meta data for each object, and is accessed through the same sys calls used to access a disk-based file system
maahes has joined #ruby
<shadoi> s/write/right/
<fowl> davidcelis: we should be moving towards the future
<examancer> memcache and redis, if accessed through a socket, provide a simpler and more directly access to the data without the need for all that file system abstraction
<fowl> plz use 1.9 and don't look back
<arphen> examancer, ok you win.
<arphen> examancer, sounds probable anyway
<examancer> that said, tmpfs is very robust and will scale pretty well
<arphen> too lazy to check
<examancer> but i suspect not *quite* as well as memcached or Redis
<shadoi> it's just less convenient and one-off code to do it.
<arphen> my boss said we shouldn't use a database from the start, so i'm not using one.
<arphen> *hides behind boss*
<shadoi> arphen: trick him and use git. :)
<arphen> how to trick him using git
<arphen> i am using git
<shadoi> there ya go, you're using a database! :)
<shadoi> haha
<examancer> i think shadoi means use git as your database
<arphen> *ugly*
<examancer> github does it all over the place pretty successfully
<shadoi> it has an API, it's distributable, compatible with your tmpfs design, etc.
<arphen> i have no idea how this will scale, eventually
<arphen> maybe i'll have to rewrite all of this in c++
<arphen> #1 this is an university project
<examancer> nah, just lean on things that are already written in C/C++ :-) .. like memcached/redis
<arphen> #2 i'm being paid for an internship
<examancer> :-)
<arphen> maybe the code as such will be too slow
<arphen> sounds unlikely, though
<examancer> the root of all evil in development is premature optimization, so don't listen to us... don't worry about shit like that until you need to
FACEFOX has joined #ruby
<examancer> I just like evangelizing the awesomeness of Redis, as I'm sure shadoi likes talking up KyotoCabinet
<shadoi> I honestly think using kyotocabinet is a hell of a lot simpler solution than memcached or redis.
mistergibson has joined #ruby
<mistergibson> is there a way to halt within a Proc (as I would break within a for loop) ?
stephenjudkins has joined #ruby
<shadoi> it'd be similar if you used kyototycoon
nemesit has joined #ruby
<examancer> redis is super simple. the only complication is the server, but most of the time that is solved with `apt-get install redis` or `brew install redis`
igaiga has joined #ruby
<examancer> i guess after deploying a few apps using redis it starts to look simple. I'm usually able to get away with the default config, though, so it really is just a matter of installing the server then done.
<shadoi> operationally it's a lot more complicated than that
<examancer> mistergibson: the simple solution is to use `next`
<shadoi> it's another service you have to monitor/manage, has it's own requirements, etc.
<examancer> true, but significantly less complex than any RDBMS
<examancer> except maybe sqlite
<examancer> which might be an RDB without the MS
<mistergibson> examancer: Proc.new { if true; how-do-I-break-here;end } ?
<mistergibson> examancer: it is within a Proc, not literally a for loop...
<examancer> mistergibson: Proc.new{ next if true }
<mistergibson> examancer: oic, cheers
<shadoi> it makes no sense, but it works. heh
<examancer> Proc.new{ if true; next; end } works also, but is uglier
<examancer> yeah, the fact that `next` works and `break` causes an error is weird
luckyruby has joined #ruby
classix has joined #ruby
mneorr has joined #ruby
<examancer> but i guess what you are doing is saying, "here, i'm done with this iteration of the proc" and returning control to whatever is calling the proc. it may yield to the proc again, or it might not, but the proc doesn't know that so it uses `next` to indicate its ready for the next call, regardless of whether there is one
Drewch has joined #ruby
workmad3 has joined #ruby
<banister_> examancer: 'next' is like 'return' in a method
<banister_> it returns out of the proc
<examancer> yes, i'm just trying to explain my assumption of the rationale behind why the keyword `next` was imbued with that strage ability
<Asher> break implies breaking out of a loop
<examancer> s/strage/strange/
<Asher> next says "we aren't necessarily done but we are done iwth this iteration"
<shadoi> but a proc isn't an iteration by definition, which makes it weird.
<arphen> is like continue in any other language
<banister_> shadoi: yeah, in the case of a proc
phantasm66 has joined #ruby
<shadoi> kinda wish they'd just made return work for procs, it'd be way less confusing.
<banister_> shadoi: 'next' finishes the proc, 'break' kills the calling method for the block, 'redo' replays the proc, 'return' exits out of the definition context of the proc
FACEFOX has joined #ruby
<banister_> shadoi: nah, that wouldn't be good, non-local returns are expected behaviour for a block
<workmad3> if you want a local return, use a lambda
s0ber has joined #ruby
y3llow has joined #ruby
<shadoi> yeah, lambda and procs being different types of the same thing is also weird.
<Asher> with an all new gem to get to lambda! :PPPP
<Asher> (to_lambda)
<shadoi> uth.
<Asher> uth?
<shadoi> s/uth/ugh/
<Asher> hehe yep
<Asher> see the description!
gen0cide_ has joined #ruby
<nobitanobi> Given a string like this: '2012-03-23'. Whats the best way of changing it to '03-23-2012' ?
y3llow has joined #ruby
<wefawa> return "03-23-2012";
andrewhl has joined #ruby
<banister_> workmad3: do you like morrissey?
<Asher> nobitanobi - use Kernel#sprintf
tommyvyo has joined #ruby
<workmad3> banister_: context?
<banister_> workmad3: the smiths
andrewhl has quit [#ruby]
<workmad3> banister_: don't think I've ever listened to anything by them
nari has joined #ruby
simao_ has joined #ruby
<banister_> workmad3: he always sings about bleak english towns, it gave me a very gloomy/grey impression of england as a whole ;)
<shadoi> nobitanobi: puts Date.parse('2012-03-23').to_time.strftime("%m-%d-%Y")
<nobitanobi> shadoi: thank you.
<workmad3> banister_: heh :) england is a bleak place
<workmad3> banister_: http://www.youtube.com/watch?v=QFWP62EoU4g <-- that's another one that really makes you want to visit here :)
<mistergibson> shadoi: a great gem for generating datetimes is Chronic
<banister_> workmad3: yeah that was going to be my q. for u, if it's accurate hehe
<shadoi> mistergibson: yes, I recommend it all the time. :)
<mistergibson> shadoi: "midnight next tuesday" > datetime
<mistergibson> ok
Caius has joined #ruby
<shadoi> mistergibson: not worth using in that case though, since the code would be exactly the same with Chronic instead of Date
<banister_> workmad3:haha my bro is going to manchester this friday, ill show him this vid, wow
<workmad3> banister_: cool, what's he coming here for?
Drewch has joined #ruby
<banister_> workmad3: there's an intellectual property law conference at manchester uni and he's giving a presentation
<shadoi> I miss the UK, lived there for 3 years. Hopefully going back in June.
<banister_> workmad3: manchester is supposed to be a fairly good uni though, at least in some disciplines
dzhulk has joined #ruby
<workmad3> banister_: yeah, manc uni is pretty good :)
pu22l3r has joined #ruby
pu22l3r has joined #ruby
<workmad3> banister_: hell, I chose to go to it :)
<banister_> workmad3: is it really as bad as the vid? if it is you need to gtfo!! :)
<mistergibson> examancer: can I extend the methods of a Proc to give it a 'return' public method? I wonder if it can be done from outside the Proc
<banister_> workmad3: move to sunny australia like the rest of the brits ;)
<workmad3> banister_: I'm allergic to sunshine :P
<Asher> mistergibson - turn it into a lambda to use return
nadirvardar has joined #ruby
<mistergibson> ok
<Asher> mistergibson - the to_lambda gem will do it attached to itself as an instance method
<workmad3> and manchester can be wet... it has a reputation for it for a reason, but it's not quite as bad as it's sometimes made out to be :)
<mistergibson> ok,cool
wilmoore has joined #ruby
pagano has joined #ruby
<banister_> Asher: you really suggesting that to a noob? :P
<banister_> Asher: only somewhat experienced programmers who properly understand cost/benefits in that approach should use it i think hehe
<banister_> Asher: but it's cool to know it's there
nikhgupta has quit [#ruby]
<Asher> what are the costs?
<Asher> it's a stupid fucking implementation, but so what
<Asher> (that's a technical assessment)
<shadoi> amen.
mneorr_ has joined #ruby
statbot2 has joined #ruby
pagano has quit ["Textual IRC Client: http://www.textualapp.com/"]
al3xnull has joined #ruby
<banister_> Asher: hehe, the costs are just that it can be confusing to use an API where you pass a block, but it has lambda semantics, i.e it errors when you dont pass it parameters (which is fine for a real block), and it doesn't "return" the way you expect. If you put a lot of effort into documenting it then it wont be such an issue, but many programmers just have a burned into expectation for how blocks should work and are liable to go 'wtf???'
<banister_> if that expectation isnt met
<Asher> meh
Vert has joined #ruby
<banister_> Asher: i guess there's a really nice C implementation for it though? is it really just a flag?
statbot2 has joined #ruby
<wefawa> How to find a specific cell in a table with Capybara? (I know the value of the cell)
<Asher> banister_ - it's just a flag… the gem is all ruby
skipper has joined #ruby
<banister_> Asher: cool i mean if you did do a C impl, if it would be just a flag, that' scool
wyhaines has joined #ruby
luckyruby has joined #ruby
statbot2 has joined #ruby
laen__ has joined #ruby
statbot2 has joined #ruby
banisterfiend has joined #ruby
statbot2 has joined #ruby
statbot2 has joined #ruby
<maahes> the install script for rvm, will it also write to my .zshrc (if I use zsh instead of bash)?
voodoofish430 has joined #ruby
<gogiel> afaik you will be told to do so even if you use bash. it's just one line
<maahes> the example on the page just said "curl this, then source your .bash_profile"
Asebolka has joined #ruby
fukushima has joined #ruby
statbot2 has joined #ruby
<gogiel> maahes: [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
statbot2 has joined #ruby
Nathandim has joined #ruby
statbot2 has joined #ruby
flou has joined #ruby
Solnse has joined #ruby
bitrot has joined #ruby
statbot2 has joined #ruby
<arphen> what's the ruby equivalent of pythons pass
<arphen> im writing i=1 but that's not what i want to do
<arphen> :D
mikepack has joined #ruby
<examancer> what does pass do?
<examancer> is that like `next` ?
<arphen> pass is the no op
<arphen> next is continue if i understood correctly
<arphen> i want a keyword that does nothing
<arphen> hm or maybe i dont
<gogiel> arphen: why do you neeed kewyord?
mikepack_ has joined #ruby
<fowl> use nil
freeayu has joined #ruby
<gogiel> arphen: you don't need to. in python you need, because they don't have end keyword
<arphen> i can write "if ... elsif... end" in ruby?
<arphen> yes thanks gogiel i just thought of that myself
<arphen> <3
rburton- has joined #ruby
gregorg_taf has joined #ruby
burns180 has joined #ruby
punkrawkR has joined #ruby
tomzx has joined #ruby
pu22l3r has joined #ruby
pu22l3r has joined #ruby
pu22l3r has joined #ruby
Vert has joined #ruby
cloke has joined #ruby
<wefawa> How to add a new route to rails so I can call the method MyController.myMethod(anId). I want the method to be /MyEntity/:id/myMethod... how do I modify the routes.rb to archive this?
Tearan has joined #ruby
shevy has joined #ruby
rboyd has joined #ruby
snip_it has joined #ruby
ChampS666 has joined #ruby
<gogiel> wefawa: #rubyonrails
<wefawa> thx
<banisterfiend> gogiel: i like the cut of your jib!