I have several pages that using the prototype library, so, I added " javascript_include_tag 'prototype'" in my RoR application. But I want to DRY my code. Is there any way, like a root page, and all view is subclass from this page, that allow me to add this once, and all my view will get the javascript_include_tag 'prototype' automatical...
So I did some refactoring and two of my classes now look exactly the same except for their constructors.
The classes wrap an API object that isn't very pretty, and add some functionality that belong at the edge of the API.
class A extends API {
public A {
this.APIOption = Option1;
this.AnotherAPIOption = Option2;
// a few...
I'm building a website with very small amounts of Javascript, just to add things to the page (like a contact form) without having to go to a new page.
I understand that I should build the contact page anyways (just in case the user doesn't have javascript turned on) and then use javascript if they've got it.
So where do I store the HTM...
I am starting to have some difficulty making this more DRY:
http://gist.github.com/471225
The gist of it is this:
I have a bunch of Models, contact_email, contact_call, contact_letter, etcetera.
They essential were a way for me to instantiate instances of the Email model (think of it as a template) matched with a specific instance/re...
Let's say I've got a folder in my project with bunch of png files in it (or mp3 files, or mov files etc).
I would like to create an NSArray populated with the items within that folder... for instance an array of UIImages for the folder of images (or just an array of NSStrings of the image name).
Is this possible? I know I could create ...
In my .html.erb file, I have a lot of lines of information to display. I am accomplishing this with a simple: (using blueprint css)
<% for event in @user.events %>
<div class="span-5 border">Descriptor:</div> <div class="span-5 last"><%=h event.foo%></div><br/>
<% end %>
How can I make it so that I can call some function that would re...
In my app I want the time/date to display as Month/Year (e.g. 7/10). The problem is sometimes I get class Date and sometimes class Time so I wind up with the following code in the application controller ...
class Date
def as_month_and_year
self.strftime("%m").to_i.to_s + self.strftime("/%y")
end
end
class Time
def as_month_an...
Hi Guys,
Trying not to repeat myself (to be DRY) here, help me out. =)
I have a double which represents a rating / 5.
The possible values are:
0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5.
I want to convert this to a string without the decimal place.
So the values would become:
"0", "05", "1", "15", "2", "25", "3", "35", "4", "45",...
I have a linq-to-sql object from a table. I want to store a similar data in the profile collection. Technically, I don't need all of the data in the linq2sql table and do not really prefer the legacy naming construct. My first thought would be to create a collection of CRUD objects.
But, if I choose this solution I will have double the ...
I have several models: ContactEmail, ContactLetter, ContactCall
My controller doesn't know what is being passed into it. It only knows it as an event (so event can be specific instance of ContactEmail, ContactLetter, ContactCall)
Each of these has a different attribute. ContactEmail has email_id; ContactLetter has letter_id, Contact...
I have two windows in my WPF app: a login window and an options window. Both have the same form with a user name and password field, as well as some other fields for providing credentials. I want some code that knows there will be a txt_userName TextBox available, for example, and can do things based on that. I was thinking I could m...
I have a django model like this:
class Something(models.Model):
title = models.CharField(max_length=200, default=u'')
text = models.CharField(max_length=250, default=u'', blank=True)
photo = models.ImageField(upload_to=u'something')
def photo_thumb(self):
if self.photo:
return u'<img src="%s" />'...
The end goal is to create a helper found at the end called show_status(contact,event).
Event can be any object, Email, Letter, etcetera. The combination of an Email template sent to a Contact is a specific record ContactEmail. Because each event has a different corresponding Model I need to do the .find on, I have duplication. There ...
I have a Rails-based site with a basic two-column layout. On the right is a sidebar with different (let's just say) vertical widgets. Depending on what page you visit, the widgets can be included, excluded, and in different order. For ex:
Main Page (Application)
PAGE CONTENT...
SIDEBAR
Widget A
Widget B
Widget C
Page X
PAGE CO...
Hi,
I needed some advice on how i can remove the repetition in my current project.
I have several colorbox dialog windows which are of the same size, have the same transition etc when they are called but perform different jquery manipulations, AJAX calls etc when they have completed loading.
Currently they are all in their own seperat...
I have the following code:
public ActionResult Foo()
{
var a = "a";
return View(new FooModel { A = a});
}
[HttpPost]
public ActionResult Foo(....)
{
// I need to set all the values of the ViewModel again, not to get a null exception in the view
return View(new FooModel { A =...
Is there a way to DRY this jQuery up?
<script type="text/javascript">
$('form input#search').watermark('search...');
</script>
<script type="text/javascript">
$('form input#post_title').watermark('title');
</script>
<script type="text/javascript">
$('form input#post_tag_list').watermark('tag (separate tags with a comma)');
</scrip...
Back story:
So I've been stuck on an architecture problem for the past couple of nights on a refactor I've been toying with. Nothing important, but it's been bothering me. It's actually an exercise in DRY, and an attempt to take it to such an extreme as the DAL architecture is completely DRY. It's a completely philosophical/theoretic...
Hi,
I have a problem with my MVP structure that is built upon generic presenters, views etc. and I feel I'm violating DRY and I dont know how to get around it.
Example.
public class Presenter<TView, TModel>
where TView : IView
where TModel : Model
{}
So far everything is fine, but I want to have it like this
public class Presen...
Hello there!
Given this ugly method:
public function convert_cell_value( $val, $type )
{
if($type == 'String')
{
return $val;
}
elseif($type == 'Number')
{
if($val - intval($val) > 0)
{
return $val;
}
else
{
return intval($val);
}
}
...