Search Results

Search found 156 results on 7 pages for 'karl cassar'.

Page 4/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Rails STI: SuperClass Model Methods called from SubClass

    - by Karl
    I would like a little confirmation that I'm doing this correctly. Using rails single table inheritance I have the following models and class method: class PhoneNumber < ActiveRecord::Base def self.qual?(number) klass = self klass.exists?(:phone_number => phone_number) end end class Bubba < PhoneNumber end class Rufus < PhoneNumber end Bubba.qual?("8005551212") Tests pass and everything seems to work properly in rails console. Just wanted to confirm that I'm not headed for future trouble by using self in the superclass PhoneNumber and using that to execute class methods on subclasses from the parent. Is there a better way?

    Read the article

  • Run Configuration Batch Script

    - by Karl
    For the purpose of a demonstration I'm looking for a way to start an eclipse run configuration from outside using a script (e.g. windows batch script). I have no idea if that's possible or how to do it.. Does anybody have an idea?

    Read the article

  • Inserting only unique values into an array

    - by karl
    I have a set of values that I'm pushing into an array in the order they occur $valsArray = array(); //I process each value from a file (code removed for simplicity) //and then add into the array $valsArray[] = $val; How do I turn this into an associative array instead where the value gets inserted (as $key of associative array) only if it doesn't exist. If it does exist increment its count ($value of associative array) by 1. I'm trying to find a more efficient way of handling those values compared to what I'm doing now.

    Read the article

  • Google maps nearest points avoiding rivers / by itinerary

    - by Karl Lacroix
    Here is the deal : I need to find the closest points from a point with a radius. For example, I need to get all the points in a 15 km radius. Thats easy with Google Maps Radius and all the examples on the web ;) The problem is that from my office, a point is under the 15km radius, but it's on the other side of a river, so the car itinerary is about 30 km (using a bridge)! Is there a simple solution to exclude those points or to calculate by intineraries ? I supposed that I'll need to calculate all itineraries with returned points? DirectionsRequest API? Thanks! :)

    Read the article

  • Clean Up Controller, Update Item Quantity within Cart

    - by Karl Entwistle
    Hi guys I was wondering if anyone could help me out, I need to clean up this controller as the resulting code to simply update an items quantity if it already exists seems way too complex. class LineItemsController < ApplicationController def create @product = Product.find(params[:product_id]) if LineItem.exists?(:cart_id => current_cart.id) item = LineItem.find(:first, :conditions => [ "cart_id = #{@current_cart.id}"]) LineItem.update(item.id, :quantity => item.quantity + 1) else @line_item = LineItem.create!(:cart => current_cart, :product => @product, :quantity => 1, :unit_price => @product.price) flash[:notice] = "Added #{@product.name} to cart." end redirect_to root_url end end ` As always any help is much appreciated, the code should be fairly self explanatory, thanks :) PS posted it here as well as it looks a bit funny on here http://pastie.org/994059

    Read the article

  • Weird use of generics

    - by Karl Trumstedt
    After a bit of programming one of my classes used generics in a way I never seen before. I would like some opinions of this, if it's bad coding or not. abstract class Base<T> : where T : Base<T> { // omitted methods and properties. virtual void CopyTo(T instance) { /*code*/ } } class Derived : Base<Derived> { override void CopyTo(Derived instance) { base.CopyTo(instance); // copy remaining stuff here } } is this an OK use of generics or not? I'm mostly thinking about the constraint to "itself". I sometimes feel like generics can "explode" to other classes where I use the Base class.

    Read the article

  • Form With Quantity doesn't seem to submit

    - by Karl Entwistle
    Hey guys, I've been trying to understand the documentation and find an example, but I'm at a loss. This is just a submit form within the cart for updating the quantity. However, the updated quantity is not getting saved to the database -- it always makes the quantity 0. Please help. Form <% for line_item in @cart.line_items %> <% form_for :lineitems, :url => {:controller => "line_items", :action => "cart_update", :id => "#{line_item.product_id}"} do |l| %> <%= l.text_field :quantity, :size => '3', :value => line_item.quantity %> <%= l.submit 'cart_update' %> <% end %> Route map.connect 'line_item_update', :controller => 'line_items', :action => 'cart_update' Controller def cart_update @product = Product.find(params[:id]) item = LineItem.find_or_create_by_cart_id(:cart_id => current_cart.id, :product_id => @product.id, :quantity => 0, :unit_price => @product.price) item.quantity = (params[:quantity]).to_i item.save redirect_to :controller => 'products' end

    Read the article

  • JQuery post not working when moving web-app to a win server 2003

    - by karl
    I have build a webapplication using ASP.NET MVC and JQuery. On my local machine this works fine,but when moving it to a Windows server 2003 the JQuery method post stops working. I'm also using the load method and this works fine. function methodOne(id) { alert("debug1: <%= Url.Action( "MethodOne", "controller" ) + "/" %>" + id); $.post <%= Url.Action( "MethodOne", "controller" ) + "/" %>" + id, function(data) { alert("debug2"); ... } else { alert("Debugg: Add presentation to user failed"); } }); } The debug2 is never outputed. $('#panel').load("<%= Url.Action( "Method", "Controller" ) %"); Works fine.

    Read the article

  • Why does using Collections.emptySet() with generics work in assignment but not as a method parameter

    - by Karl von L
    So, I have a class with a constructor like this: public FilterList(Set<Integer> labels) { ... } and I want to construct a new FilterList object with an empty set. Following Joshua Bloch's advice in his book Effective Java, I don't want to create a new object for the empty set; I'll just use Collections.emptySet() instead: FilterList emptyList = new FilterList(Collections.emptySet()); This gives me an error, complaining that java.util.Set<java.lang.Object> is not a java.util.Set<java.lang.Integer>. OK, how about this: FilterList emptyList = new FilterList((Set<Integer>)Collections.emptySet()); This also gives me an error! Ok, how about this: Set<Integer> empty = Collections.emptySet(); FilterList emptyList = new FilterList(empty); Hey, it works! But why? After all, Java doesn't have type inference, which is why you get an unchecked conversion warning if you do Set<Integer> foo = new TreeSet() instead of Set<Integer> foo = new TreeSet<Integer>(). But Set<Integer> empty = Collections.emptySet(); works without even a warning. Why is that?

    Read the article

  • PHP - While loop

    - by Karl Entwistle
    print "<ul>"; foreach ($arr as $value) { echo("<li>" . $value[storeid] . " " . ($value[dvdstock] + $value[vhsstock]) . "</li>"); } print "</ul>"; Will output •2 20 •2 10 •1 20 •1 20 •1 10 I was wondering how I would adapt this loop so it outputs the total values for each &value[storeid] •1 50 •2 30 Thanks very much :)

    Read the article

  • java: relationship of the Runnable and Thread interfaces

    - by Karl Patrick
    I realize that the method run() must be declared because its declared in the Runnable interface. But my question comes when this class runs how is the Thread object allowed if there is no import call to a particular package? how does runnable know anything about Thread or its methods? does the Runnable interface extend the Thread class? Obviously I don't understand interfaces very well. thanks in advance. class PrimeFinder implements Runnable{ public long target; public long prime; public boolean finished = false; public Thread runner; PrimeFinder(long inTarget){ target = inTarget; if(runner == null){ runner = new Thread(this); runner.start() } } public void run(){ } }

    Read the article

  • Great Circle & Rhumb line intersection

    - by Karl T
    I have a Latitude, Longitude, and a direction of travel in degrees true north. I would like to calculate if I will intersect a line defined by two more Lat/Lon points. I figure the two points defining the line would create my great circle and my location and azimuth would define my Rhumb line. I am only interested in intersections that will occur with a few hundred kilometers so I do not need every possible solution. I have no idea where to begin.

    Read the article

  • Finding the right terminology for a dictionary table

    - by Karl Forner
    My concern is about what I currently call "dictionary tables", that are database tables containing a list of controlled vocabulary. Let's use an example: Suppose you have a table User containing fields: user_id : primary key first_name last_name user_type_id : foreign key to the UserType table and another table UserType with just two fields: user_type_id : primary key name : the name/value of a particular type of user. For instance, the UserType table may contain (1, Administrator), (2, PowerUser), (3, Normal)... My question is: what is the canonical term for a table like UserType, that only contains a list of (dictinct) words. I want to publish some code that help managing this kind of tables, but first I have to name them ! Thanks for your help. Current state of thought: For now I feel Lookup Tables is a good term. It is also used with the same meaning in these posts: http://dbix-class.35028.n2.nabble.com/RFC-Component-for-Lookup-tables-td3504085.html http://tonyandrews.blogspot.de/2004/10/otlt-and-eav-two-big-design-mistakes.html Lookup Tables Best Practices: DB Tables... or Enumerations The only problem is that lookup table is also sometimes used to name a junction table.

    Read the article

  • Redirect all requests to a subdirectory

    - by Karl Keefer
    I have a drupal site install at example.com/drupal but now that the site is built I want to forward all requests to that directory, without it ever showing "drupal" in url. I think this can be done with .htaccess, but I didn't know if that was a hack-y answer. I'm using mediatemple's GridServer so I don't have complete control over apache settings and stuff, although I do have SSH.

    Read the article

  • trouble accessing localhost from ie7 running on parallels (win xp) on mac os x

    - by Karl R
    I'm running the app engine devserver on localhost:8080, and want to access it from ie7 running on parallels. I've tried all of the tips here: http://stackoverflow.com/questions/61449/how-do-i-access-the-host-from-vmware-fusion And they seem like they should work, particularly accessing via the gateway ip address. I've also sudo ipfw add allow tcp from 8080 to 8089 for good measure. Still no dice. I can access the external internet from ie7. The connection settings on parallels are set to 'Shared networking'. I'm out of ideas.

    Read the article

  • after_create :create a new line in DB

    - by Karl Entwistle
    Hey guys I was wondering if anyone could help me with an issue im having, basically id like to have Account.create after a PayPal notification is received, There is a simple cart model which corresponds to line_items within the cart so add_account_to_market would look like this in pseudo code def add_account_to_market if status == "Completed" find the line items(via cart_id) that correspond to the cart.id that just been paid create an account with user_id set to the current carts user id end end Ive never tried to do something like this in Rails and its not working, Ive been pulling my hair out all night trying to fix this, hopefully someone can help or point me in the right direction. Thanks :) class PaymentNotification < ActiveRecord::Base belongs_to :cart serialize :params after_create :mark_cart_as_purchased after_create :add_account_to_market private def mark_cart_as_purchased if status == "Completed" cart.update_attribute(:purchased_at, Time.now) cart.update_attribute(:paid, true) end end def add_account_to_market if status == "Completed" l = LineItem.find(:all, :conditions => "cart_id = '#{cart.id}'") for l.quantity Account.new(:user_id => cart.user_id) end end end end PS mark_cart_as_purchased method is working fine, its just the add_account_to_market im having issues with.

    Read the article

  • C++ Header file questions

    - by Karl
    So I'm trying to learn C++ and I've gotten as far as using header files. They really make no sense to me. I've tried many combinations of this but nothing so far has worked: Main.cpp: #include "test.h" int main() { testClass Player1; return 0; } test.h: #ifndef TEST_H_INCLUDED #define TEST_H_INCLUDED class testClass { private: int health; public: testClass(); ~testClass(); int getHealth(); void setHealth(int inH); }; #endif // TEST_H_INCLUDED test.cpp: #include "test.h" testClass::testClass() { health = 100; } testClass::~testClass() {} int testClass::getHealth() { return(health); } void testClass::setHealth(int inH) { health = inH; } What I'm trying to do is pretty simple, but the way the header files work just makes no sense to me at all. Code blocks returns the following on build: obj\Debug\main.o(.text+0x131)||In function main':| *voip*\test\main.cpp |6|undefined reference totestClass::testClass()'| obj\Debug\main.o(.text+0x13c):voip\test\main.cpp|7|undefined reference to `testClass::~testClass()'| ||=== Build finished: 2 errors, 0 warnings ===| I'd appreciate any help. Or if you have a decent tutorial for it, that would be fine too (most of the tutorials I've googled haven't helped)

    Read the article

  • [Rails] HTTP Get Request

    - by Karl
    I've been trying to get Rails to play with the new Facebook Graph API. After I get the authorization "code", I need to send another request which returns the access token in JSON form. It seems to work fine, however I want to fetch the access token JSON without redirecting the user. I'm attempting to use Net::HTTP.get, but I'm not sure how to use it to get a request body, or even if it's the right thing to use to begin with. Can anyone give an example of performing an HTTP GET?

    Read the article

  • Emacs align-regexp on = but not ==

    - by Karl
    I am working in Haskell and frequently come across code similar to the following: func i j | i == j = i | otherwise = j I want to align on the '=' character using align-regexp but don't have the elisp knowhow. I have tried just doing " = " without the quotes, but this inserts an unwanted space character before each '='. I have found a proposed solution here but I can't seem to get that to do anything at all. Please help me write a function or hard-coded macro that will allow me to set a keybinding for this.

    Read the article

  • .NET Migrations Engine

    - by Karl Seguin
    I was once under the belief that Microsoft was working on an official, ruby-like, Migration framework. However, I haven't been able to find any additional information (or even the original source of my belief). Does anyone know any information about an official migration framework? or possibly an open source one?

    Read the article

  • Codeigniter Template library, add_js() method

    - by Karl
    using This Template Library when i try and use the add_js() function it errors out. I add the regions $_scripts to the template header file but when i load the page it says undefined variable _scripts. any thoughts? changed <?= $_scripts ?> to <?= (isset($_scripts)) ? $_scripts : “”; ?> and obviously i lose the error but the js file still isnt loading. I did an echo at each step though the add_js() method and the output is correct. I also did an output of $this-js and they both had the corret output. So it gets through the get_js method fine and sets the class variable fine but i dont get anything added to the actual page.

    Read the article

  • Which framework should I choose - Seam, Wicket, JSF or GWT?

    - by karl
    I'm debating whether to use Seam, Wicket, JSF or GWT as the foundation for my presentation layer in a Java project. I narrowed my selection of Java web frameworks down to this subset based on job market considerations, newness of the technology and recommendations from other S.O. users. What factors should I take into consideration in deciding among these?

    Read the article

  • Can someone explain this java interface to me please?

    - by Karl Patrick
    I realize that the method run must be declared because its declared in the runnable interface. But my question comes when this class runs how is the Thread object allowed if there is no import call to a particular package? how does runnable know anything about Thread or its methods? does the runnable interface extend the thread class? Obviously i dont understand interfaces very well. thanks in advance. class PrimeFinder implements Runnable{ public long target; public long prime; public boolean finished = false; public Thread runner; PrimeFinder(long inTarget){ target = inTarget; if(runner == null){ runner = new Thread(this); runner.start() } } public void run(){ } }

    Read the article

  • lazyinializationexception with transactional annotation in messageconvert

    - by Karl
    Hi, I have a Rest-Service exposed through spring-mvc. I have a particular method which is correctly mapped and called through a http-call. My spring application contains the hibernatetransactionmanager and transactions are configured through @Transactional-annotations. I annotated the method with @Transactional. @Transactional(readOnly = true) @Override @RequestMapping(value = "/start", method = RequestMethod.GET) @ResponseBody public List start(....) Whenever I call the http-method I get org.hibernate.LazyInitializationException from my org.springframework.http.converter.json.MappingJacksonHttpMessageConverter which is bound in my application context. Is the @Transactional annotation valid for the MessageConverter as well?

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >