I'm learning ruby on rails on a linux box and dusting off my VIM skills (skillz?).
When I got started on VIM way back in my c++ days, I had a friend with a great vimfiles folder that had tons of stuff to get started. Starting from scratch, vim is great, but it feels like it could be a lot better.
I currently have:
vim-ruby
buffer ...
Q: The title is perhaps too big of question and the answer probably is "it depends"? However, providing some practical cases/examples should help developers, like myself, recognize when to apply what. I'll start out with my particular situation. Would you or would you not use custom error classes? Why/why not?
Other examples as the one...
Is there any way to feather an image from code? (If you don't know what feathering is, check this out - I'm not using dirty language)
I know professional design applications like Photoshop can do this, but I would for users to upload images to my site and then display them in a feathered fashion. (Now there's a sentence you don't hear...
I've seen all of these:
is_valid
is_valid?
valid?
Is there a preferred one?
EDIT: More conditionals:
has_comment has_comment? comment?
was_full was_full? full?
Please do add more descriptive examples.
...
q = {"It", "was", "the", "best", "of", "times", "it", "was", "the", "worst", "of", "times"}
write an expression to return
wasworsttimes
without using any character or string literals.
Can someone help me figure out how to do this?
...
I don't have much experience with statically typed languages (currently learning Scala and loving it!) but one thing I've noticed is that they don't ever seem to have anything like Ruby's method_missing or ColdFusion's onMissingMethod. Is there some inherent limitation in statically typed languages that prevent or make this difficult?
...
Currently I'm parsing a HTML document using Nokogiri and iterating through all the code tags like this:
html = Nokogiri::HTML(doc)
html.css("code").each do |code|
# do something with code
if /^@@@@/.match(code.text.split("\n")[0])
return "this code element is at line blah"
end
end
I don't have to use Nokogiri, it wa...
I assume that for all of these i need to get a better understanding of Ruby itself but does (say) Padrino translate directly into skills i would use in Rails or is it indirect.
I am a PHP programmer but as i have used PHP frameworks which are clones of Rails i am finding it not too difficult
...
str = "some html code [img]......[/img] some html code [img]......[/img]"
I want use regex get the array:
["[img]......[/img]","[img]......[/img]"]
Any ideas anyone?
...
I have a has_one association that is reflective on the objects of another association. I have Project, which has many ProjectUsers, which tie Projects and Users. One of those ProjectUsers is authoritative. The issue is that both the has_one and the has_many use the same foreign key on project_users. Here's the base idea of the models...
I have recently been researching NoSql options. My scenario is as follows:
We collect and store data from custom hardware at remote locations around the world. We record data from every site every 15 minutes. We would eventually like to move to every 1 minute. Each record has between 20 and 200 measurements. Once set up the hardware rec...
In Ruby 1.9 (YARV) you can get a count of all currently allocated objects like so:
ObjectSpace.count_objects
which returns a hash like
{:TOTAL=>1226560, :FREE=>244204, :T_OBJECT=>26141, :T_CLASS=>9819, :T_MODULE=>1420, :T_FLOAT=>287,
:T_STRING=>260476, :T_REGEXP=>4081, :T_ARRAY=>72269, :T_HASH=>14923, :T_STRUCT=>4601, :T_BIGNUM=>7,
...
I'm working on a bit of an extension for Radiant CMS that processes survey data. I'm trying to use form_for, fields_for and various helpers that rails provides inside pre-defined radius tags. These tags would generate the survey on Radiant pages.
Here's what I have in mind for integrating with Radiant:
<r:survey id="200">
<r:survey:f...
I am new to Ruby so forgive me if the question is inconsistent. Can I iterate over class members like through array in Ruby? How do I achieve this?
...
Find.find("d") {|path| puts path}
I want to exclude certain type of files, say *.gif and directories
PS: I can always add code inside my block to check for the file name and directory type, but I want 'find' itself to filter files for me
...
Heyya guys.
So i thought about this coolio idea, if you are logged in then you get some sort of dashboard, else you get an information/login/sign up page.. So how do i do that..
I mostly wants to do this in Routes = not something like
def index
if current_user.present?
render :action => 'logged_in'
else
render :action => ...
/facebook/promo/#access_token=162592277090170%7C2.yCch3otjrdit_rgBFS6F0A__.3600.1285369200-727781553%7CtugQmoO0bRiadumHVQrrSiPRD9Y&expires_in=7174
This is the request facebook calls back. How can I parse the access_token ffrom the url? I could not find any way to get the access_token value.
Please aware that it is not a reqular paramet...
Hi
Ruby newbie here. I'm trying to use the Easyjour module ( http://easyjour.rubyforge.org/ ) from irb. After a gem install easyjour this is what I get:
irb(main):002:0> service = Easyjour.serve("files", 'http', 3000)
NameError: uninitialized constant Easyjour
What am I missing here? Do I need to import the module first somehow?
...
I'm trying to create a Ruby Hash of objects, where the keys are the object @name member:
# m is an object with an @name instance variable (a string)
myHash = {}
myHash[m.name] = m
It's giving this error:
#<TypeError: can't convert String into Integer>
Anyone know why? I'm sure that m.name is a valid string...
...
I am a user of Ruby on Rails framework and am thinking of giving back to it by contributing to the code.
I understand that there is a need for thorough understanding of the Ruby language concept to contribute?
Ive cloned the project, looked at the code, check out the tickets and have no clue how to begin?
From what i see the Rails Framew...