Search Results

Search found 8286 results on 332 pages for 'defined'.

Page 66/332 | < Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >

  • emacs -- keybind questions

    - by user565739
    I have successfully used Ctrl+Shift+Up ' Ctrl+Shift+down ' Ctrl+Shift+left' Ctrl+Shift+Right to different commands. But when I tried to use Ctrl+s to the command save-buffer and Ctrl+Shift+s, which is equivalent to Ctrl+S, to another command, it has some problem. save-buffer works fine, but when I type Ctrl+Shift+s, it excute the command save-buffer. I used Ctrl+q to find the control sequences of Ctrl+s and Ctrl+Shift+S, I get the same result, which is ^S. I expect that I will get ^s for Ctrl+s, but it doesn't. Anyone knows the reason? Another queston is: I use Ctrl+c for the command killing-ring-save. In this case, all commands (which are of large number) begin with Ctrl+c don't work now. Is there a way to replace the prefix Ctrl+c by another customized prefix? I may pose my question in the wrong direction. I use ctrl+c as killing-ring-save. It works fine in emacs (no mode). But if I open a .c file (C-mode), then when I type Ctrl+c, it waits me to type another key. I think in this case, ctrl+c is regarded as a prefix. In this case, I need the following modifications: Using a custom defined prefix, say Ctrl+a, as Ctrl+c ; Remove the prefix Ctrl+c ; Using Ctrl+c as killing-ring-save. I add the following to my ~/.emacs : (defun my-c-initialization-hook () (define-key c-mode-base-map (kbd "C-a") mode-specific-map) (define-key c-mode-base-map (kbd "C-c") 'kill-ring-save)) (add-hook 'c-initialization-hook 'my-c-initialization-hook) But this doesn't work. Ctrl+c is still regarded as a prefix, so I can't use it as kill-ring-save. Furthermore, if I type Ctrl+a Ctrl+c, it said it's not defined. (I thought it will have the same result as I type Ctrl+c Ctrl+c)

    Read the article

  • Is it possible for a function called from within an object to have access to that object's scope?

    - by Elliot Bonneville
    I can't think of a way to explain what I'm after more than I've done in the title, so I'll repeat it. Is it possible for an anonymous function called from within an object to have access to that object's scope? The following code block should explain what I'm trying to do better than I can: function myObj(testFunc) { this.testFunc = testFunc; this.Foo = function Foo(test) { this.test = test; this.saySomething = function(text) { alert(text); }; }; var Foo = this.Foo; this.testFunc.apply(this); } var test = new myObj(function() { var test = new Foo(); test.saySomething("Hello world"); }); When I run this, I get an error: "Foo is not defined." How do I ensure that Foo will be defined when I call the anonymous function? Here's a jsFiddle for further experimentation. Edit: I am aware of the fact that adding the line var Foo = this.Foo; to the anonymous function I pass in to my instance of myObj will make this work. However, I'd like to avoid having to expose the variable inside the anonymous function--do I have any other options?.

    Read the article

  • entity framework vNext wish list

    - by Fred Yang
    I have been intensively studying and use ef4 in my project. I do feel the improvement that it has over version 1. But I found that I have something I cannot get around easily. Here is a list I want it to be better in ef vNext. the model designer should allow multiple view of the same model, so that I don't need cram all my entity into a single view. respect user's manual edit of edmx. Currently, the some database view object simply can not be imported to the model because the designer "smartly" think that the view does not have a primary key, so that I have to manually edit the edmx to correct designer's behavior. But in the next "update from database" task, designer will revert my customization. For now, I simply fallback to manually edit the edmx file at all, or I have to use compare tool to keep the new update, and rollback and put the new update into my old edmx file manually. Designer should be improved to allow default behavior and user's manual control. I want control not to let the designer refresh the change of imported object. support user defined table function. linq is about Composability, stored proc dos not support composability. I wish I could use user defined table function which support this. What are you wishes for EF vNext?

    Read the article

  • Why is F# member not found when used in subclass

    - by James Black
    I have a base type that I want to inherit from, for all my DAO objects, but this member gets the error further down about not being defined: type BaseDAO() = member v.ExecNonQuery2(conn)(sqlStr) = let comm = new MySqlCommand(sqlStr, conn, CommandTimeout = 10) comm.ExecuteNonQuery |> ignore comm.Dispose |> ignore I inherit in this type: type CreateDatabase() = inherit BaseDAO() member private self.createDatabase(conn) = self.ExecNonQuery2 conn "DROP DATABASE IF EXISTS restaurant" This is what I see when my script runs in the interactive shell: --> Referenced 'C:\Program Files\MySQL\MySQL Connector Net 6.2.3\Assemblies\MySql.Data.dll' [Loading C:\Users\jblack\Documents\Visual Studio 2010\Projects\RestaurantService\RestaurantDAO\BaseDAO.fs] namespace FSI_0106.RestaurantServiceDAO type BaseDAO = class new : unit -> BaseDAO member ExecNonQuery2 : conn:MySql.Data.MySqlClient.MySqlConnection -> sqlStr:string -> unit member execNonQuery : sqlStr:string -> unit member execQuery : sqlStr:string * selectFunc:(MySql.Data.MySqlClient.MySqlDataReader -> 'a list) -> 'a list member f : x:obj -> string member Conn : MySql.Data.MySqlClient.MySqlConnection end [Loading C:\Users\jblack\Documents\Visual Studio 2010\Projects\RestaurantService\RestaurantDAO\CreateDatabase.fs] C:\Users\jblack\Documents\Visual Studio 2010\Projects\RestaurantService\RestaurantDAO\CreateDatabase.fs(56,14): error FS0039: The field, constructor or member 'ExecNonQuery2' is not defined I am curious what I am doing wrong. I have tried not inheriting, and just instantiating the BaseDAO type in the function, but I get the same error. I started on this path because I had a property that had the same error, so it seems there may be a problem with how I am defining my BaseDAO type, but it compiles with no error, which further confuses me about this problem.

    Read the article

  • PropertyPlaceholderConfigurer vs Filters -- Spring Beans

    - by John
    Hi there. I've got a question regarding the difference between PropertyPlaceholderConfigurer (org.springframework.beans.factory.config.PropertyPlaceholderConfigurer) and normal filters defined in my pom.xml. I've been looking at examples, and it seems that even though filters are defined and marked to be active by default in the pom.xml they still make use of PropertyPlaceholderConfigurer in Spring's applicationContext.xml. This means that the pom.xml has a reference to a filter-LOCAL.properties while applicationContext.xml has a reference to application.properties and they both contain the same settings. Why is that? Is that how it is supposed to be done? I'm able to run the goal mvn jetty:run without the application.properties present, but if I add settings to the application.properties that differ from the filter-LOCAL.properties they don't seem to override. Here's an example of what I mean: pom.xml <profiles <profile <idLOCAL <activation <activeByDefaulttrue </activation <properties <envLOCAL </properties </profile </profiles applicationContext.xml <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" <property name="locations" <list <valueclasspath:application.properties </list </property <property name="ignoreResourceNotFound" value="true"/ </bean <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" <property name="driverClassName" value="${jdbc.driver}"/ <property name="url" value="${jdbc.url}"/ <property name="username" value="${jdbc.username}"/ <property name="password" value="${jdbc.password}"/ </bean an example of the content of application.properties and filters-LOCAL.properties jdbc.driver=org.postgresql.Driver jdbc.url=jdbc:postgresql://localhost/shoutbox_dev jdbc.username=tester jdbc.password=tester Can I remove the propertyConfigurer from the applicationContext, create a PROD filter and disregard the application.properties file, or will that give me issues when deploying to the production server?

    Read the article

  • Do COM Dll References Require Manual Disposal? If so, How?

    - by Drew
    I have written some code in VB that verifies that a particular port in the Windows Firewall is open, and opens one otherwise. The code uses references to three COM DLLs. I wrote a WindowsFirewall class, which Imports the primary namespace defined by the DLLs. Within members of the WindowsFirewall class I construct some of the types defined by the DLLs referenced. The following code isn't the entire class, but demonstrates what I am doing. Imports NetFwTypeLib Public Class WindowsFirewall Public Shared Function IsFirewallEnabled as Boolean Dim icfMgr As INetFwMgr icfMgr = CType(System.Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwMgr")), INetFwMgr) Dim profile As INetFwProfile profile = icfMgr.LocalPolicy.CurrentProfile Dim fIsFirewallEnabled as Boolean fIsFirewallEnabled = profile.FirewallEnabled return fIsFirewallEnabled End Function End Class I do not reference COM DLLs very often. I have read that unmanaged code may not be cleaned up by the garbage collector and I would like to know how to make sure that I have not introduced any memory leaks. Please tell me (a) if I have introduced a memory leak, and (b) how I may clean it up. (My theory is that the icfMgr and profile objects do allocate memory that remains unreleased until after the application closes. I am hopeful that setting their references equal to nothing will mark them for garbage collection, since I can find no other way to dispose of them. Neither one implements IDisposable, and neither contains a Finalize method. I suspect they may not even be relevant here, and that both of those methods of releasing memory only apply to .Net types.)

    Read the article

  • Can I specify default value?

    - by atch
    Why is it that for user defined types when creating an array of objects every element of this array is initialized with default ctor but when I create built-in type this isn't the case? And second question: is it possible to specify default value to be used while initialize? Something like this (not valid): char* p = new char[size]('\0'); And another question in this topic while I'm with arrays. I suppose that when creating an array of user defined type and knowing the fact that every elem. of this array will be initialized with default value firstly why? If arrays for built in types do not initialize their elems. with their dflts why do they do it for UDT, and secondly: is there a way to switch it off/avoid/circumvent somehow? It seems like bit of a waste if I for example have created an array with size 10000 and then 10000 times dflt ctor will be invoked and I will (later on) overwrite this values anyway. I think that behaviour should be consistent, so either every type of array should be initialized or none. And I think that the behaviour for built-in arrays is more appropriate.

    Read the article

  • Checking if any of a list of values falls within a table of ranges

    - by Conspicuous Compiler
    I'm looking to check whether any of a list of integers fall in a list of ranges. The ranges are defined in a table defined something like: # Extra Type Field Default Null Key 0 int(11) rangeid 0 NO PRI 1 int(11) max 0 NO MUL 2 int(11) min 0 NO MUL Using MySQL 5.1 and Perl 5.10. I can check whether a single value, say 7, is in any of the ranges with a statement like SELECT 1 FROM range WHERE 7 BETWEEN min AND max If 7 is in any of those ranges, I get a single row back. If it isn't, no rows are returned. Now I have a list of, say, 50 of these values, not stored in a table at present. I assemble them using map: my $value_list = '(' . ( join ', ', map { int $_ } @values ) . ')' ; I want to see if any of the items in the list fall inside of any of the ranges, but am not particularly concerned with which number nor which range. I'd like to use a syntax such as: SELECT 1 FROM range WHERE (1, 2, 3, 4, 5, 6, 7, 42, 309, 10000) BETWEEN min AND max MySQL kindly chastises me for such syntax: Operand should contain 1 column(s) I pinged #mysql who were quite helpful. However, having already written this up by the time they responded and thinking it'd be helpful to fix the answer in a more permanent medium, I figured I'd post the question anyhow. Maybe SO will provide a different solution?

    Read the article

  • What would be different in Java if Enum declaration didn't have the recursive part

    - by atamur
    Please see http://stackoverflow.com/questions/211143/java-enum-definition and http://stackoverflow.com/questions/3061759/why-in-java-enum-is-declared-as-enume-extends-enume for general discussion. Here I would like to learn what exactly would be broken (not typesafe anymore, or requiring additional casts etc) if Enum class was defined as public class Enum<E extends Enum> I'm using this code for testing my ideas: interface MyComparable<T> { int myCompare(T o); } class MyEnum<E extends MyEnum> implements MyComparable<E> { public int myCompare(E o) { return -1; } } class FirstEnum extends MyEnum<FirstEnum> {} class SecondEnum extends MyEnum<SecondEnum> {} With it I wasn't able to find any benefits in this exact case. PS. the fact that I'm not allowed to do class ThirdEnum extends MyEnum<SecondEnum> {} when MyEnum is defined with recursion is a) not relevant, because with real enums you are not allowed to do that just because you can't extend enum yourself b) not true - pls try it in a compiler and see that it in fact is able to compile w/o any errors PPS. I'm more and more inclined to believe that the correct answer here would be "nothing would change if you remove the recursive part" - but I just can't believe that.

    Read the article

  • jQuery > Update inline script on form submission

    - by Andrew Kirk
    I am using the ChemDoodle Web Components to display molecules on a web page. Basically, I can just insert the following script in my page and it will create an HTML5 canvas element to display the molecule. <script> var transform1 = new TransformCanvas('transform1', 200, 200, true); transform1.specs.bonds_useJMOLColors = true; transform1.specs.bonds_width_2D = 3; transform1.specs.atoms_useJMOLColors = true; transform1.specs.atoms_circles_2D = true; transform1.specs.backgroundColor = 'black'; transform1.specs.bonds_clearOverlaps_2D = true; transform1.loadMolecule(readPDB(molecule)); </script> In this example, "molecule" is a variable that I have defined in an external script by using the jQuery.ajax() function to load a PDB file. This is all fine and good. Now, I would like to include a form on the page that will allow a user to paste in a PDB molecule definition. Upon submitting the form, I want to update the "molecule" variable with the form data so that the ChemDoodle Web Components script will work its magic and display molecule defined by the PDB definition pasted into the form. I am using the following jQuery code to process the the form submission. $(".button").click(function() { // validate and process form here //hide previous errors $('.error').hide(); //validate pdb textarea field var pdb = $("textarea#pdb").val(); if (pdb == "") { $("label#pdb_error").show(); $("textarea#pdb").focus(); return false; } molecule = pdb; }); This code is setting the "molecule" variable upon the form submission but it is not being passed back to the inline script as I had hoped. I have tried a number of variations on this but can't seem to get it right. Any clues as to where I might be going wrong would be much appreciated.

    Read the article

  • Array: Recursive problem cracked me up

    - by VaioIsBorn
    An array of integers A[i] (i 1) is defined in the following way: an element A[k] ( k 1) is the smallest number greater than A[k-1] such that the sum of its digits is equal to the sum of the digits of the number 4* A[k-1] . You need to write a program that calculates the N th number in this array based on the given first element A[1] . INPUT: In one line of standard input there are two numbers seperated with a single space: A[1] (1 <= A[1] <= 100) and N (1 <= N <= 10000). OUTPUT: The standard output should only contain a single integer A[N] , the Nth number of the defined sequence. Input: 7 4 Output: 79 Explanation: Elements of the array are as follows: 7, 19, 49, 79... and the 4th element is solution. I tried solving this by coding a separate function that for a given number A[k] calculates the sum of it's digits and finds the smallest number greater than A[k-1] as it says in the problem, but with no success. The first testing failed because of a memory limit, the second testing failed because of a time limit, and now i don't have any possible idea how to solve this. One friend suggested recursion, but i don't know how to set that. Anyone who can help me in any way please write, also suggest some ideas about using recursion/DP for solving this problem. Thanks.

    Read the article

  • How to index a table with a Type 2 slowly changing dimension for optimal performance

    - by The Lazy DBA
    Suppose you have a table with a Type 2 slowly-changing dimension. Let's express this table as follows, with the following columns: * [Key] * [Value1] * ... * [ValueN] * [StartDate] * [ExpiryDate] In this example, let's suppose that [StartDate] is effectively the date in which the values for a given [Key] become known to the system. So our primary key would be composed of both [StartDate] and [Key]. When a new set of values arrives for a given [Key], we assign [ExpiryDate] to some pre-defined high surrogate value such as '12/31/9999'. We then set the existing "most recent" records for that [Key] to have an [ExpiryDate] that is equal to the [StartDate] of the new value. A simple update based on a join. So if we always wanted to get the most recent records for a given [Key], we know we could create a clustered index that is: * [ExpiryDate] ASC * [Key] ASC Although the keyspace may be very wide (say, a million keys), we can minimize the number of pages between reads by initially ordering them by [ExpiryDate]. And since we know the most recent record for a given key will always have an [ExpiryDate] of '12/31/9999', we can use that to our advantage. However... what if we want to get a point-in-time snapshot of all [Key]s at a given time? Theoretically, the entirety of the keyspace isn't all being updated at the same time. Therefore for a given point-in-time, the window between [StartDate] and [ExpiryDate] is variable, so ordering by either [StartDate] or [ExpiryDate] would never yield a result in which all the records you're looking for are contiguous. Granted, you can immediately throw out all records in which the [StartDate] is greater than your defined point-in-time. In essence, in a typical RDBMS, what indexing strategy affords the best way to minimize the number of reads to retrieve the values for all keys for a given point-in-time? I realize I can at least maximize IO by partitioning the table by [Key], however this certainly isn't ideal. Alternatively, is there a different type of slowly-changing-dimension that solves this problem in a more performant manner?

    Read the article

  • How to deserialize implementation classes in OSGi

    - by Daniel Schneller
    In an eRCP OSGi based application the user can push a button and go to a lock screen similar to that of Windows or Mac OS X. When this happens, the current state of the application is serialized to a file and control is handed over to the lock screen. In this mobile application memory is very tight, so we need to get rid of the original view/controller when the lock screen comes up. This works fine and we end up with a binary serialized file. Once the user logs back in, the file is read in again and the original state of the application restored. This works fine as well, except when the controller that was serialized contained a reference to an object which comes from a different bundle. In my concrete case the original controller (from bundle A) can call a web service and gets a result back. Nothing fancy, just some Strings and Numbers in a simple value holder class. However the controller only sees this as a Result interface; the actual runtime object (ResultImpl) is defined and created in a different bundle (bundle B, the webservice client implementation) and returned via a service call. When the deserialization now tries to thaw the controller from the file, it throws a ClassNotFound exception, complaining about not being able to deserialize the result object, because deserialization is called from bundle A, which cannot see the ResultImpl class from bundle B. Any ideas on how to work around that? The only thing I could come up with is to clone all the individual values into another object, defined in the controller's bundle, but this seems like quite a hassle.

    Read the article

  • Problem in inferring instances that have integer cardinality constraint

    - by Mikae Combarado
    Hello, I have created an RDF/OWL file using Protege 4.1 alpha. I also created a defined class in Protege called CheapPhone. This class has a restriction which is shown below : (hasPrice some integer[< 350]) Whenever, a price of a phone is below 350, it is inferred as CheapPhone. There is no problem for inferring this in Protege 4.1 alpha. However, I cannot infer this using Jena. I also created a defined class called SmartPhone. This class also has a restriction which is shown below : (has3G value true) and (hasInternet value true) Whenever, a phone has 3G and Internet, it is inferred as SmartPhone. In this situation, there is no problem inferring this in both Protege and Jena. I have started to think that there is a problem in default inference engine of Jena. The code that I use in Java is below : Reasoner reasoner = ReasonerRegistry.getOWLReasoner(); reasoner = reasoner.bindSchema(ontModel); OntModelSpec ontModelSpec = OntModelSpec.OWL_MEM_MINI_RULE_INF; ontModelSpec.setReasoner(reasoner); // Create ontology model with reasoner support // ontModel was created and read before, so I don't share the code in order // not to create garbage here OntModel model = ModelFactory.createOntologyModel(ontModelSpec, ontModel); OntClass sPhone = model.getOntClass(ns + "SmartPhone"); ExtendedIterator s = sPhone.listInstances(); while(s.hasNext()) { OntResource mp = (OntResource)s.next(); System.out.println(mp.getURI()); } This code works perfectly and returns me the instances, but when I change the code below and make it appropriate for CheapPhone, it doesn't return anything. OntClass sPhone = model.getOntClass(ns + "CheapPhone"); Am I doing something wrong ?

    Read the article

  • Scope of "library" methods

    - by JS
    Hello, I'm apparently laboring under a poor understanding of Python scoping. Perhaps you can help. Background: I'm using the 'if name in "main"' construct to perform "self-tests" in my module(s). Each self test makes calls to the various public methods and prints their results for visual checking as I develop the modules. To keep things "purdy" and manageable, I've created a small method to simplify the testing of method calls: def pprint_vars(var_in): print("%s = '%s'" % (var_in, eval(var_in))) Calling pprint_vars with: pprint_vars('some_variable_name') prints: some_variable_name = 'foo' All fine and good. Problem statement: Not happy to just KISS, I had the brain-drizzle to move my handy-dandy 'pprint_vars' method into a separate file named 'debug_tools.py' and simply import 'debug_tools' whenever I wanted access to 'pprint_vars'. Here's where things fall apart. I would expect import debug_tools foo = bar debug_tools.pprint_vars('foo') to continue working its magic and print: foo = 'bar' Instead, it greets me with: NameError: name 'some_var' is not defined Irrational belief: I believed (apparently mistakenly) that import puts imported methods (more or less) "inline" with the code, and thus the variable scoping rules would remain similar to if the method were defined inline. Plea for help: Can someone please correct my (mis)understanding of scoping regards imports? Thanks, JS

    Read the article

  • Circular dependency with generics

    - by devoured elysium
    I have defined the following interface: public interface IStateSpace<State, Action> where State : IState where Action : IAction<State, Action> // <-- this is the line that bothers me { void SetValueAt(State state, Action action); Action GetValueAt(State state); } Basically, an IStateSpace interface should be something like a chess board, and in each position of the chess board you have a set of possible movements to do. Those movements here are called IActions. I have defined this interface this way so I can accommodate for different implementations: I can then define concrete classes that implement 2D matrix, 3D matrix, graphs, etc. public interface IAction<State, Action> { IStateSpace<State, Action> StateSpace { get; } } An IAction, would be to move up(this is, if in (2, 2) move to (2, 1)), move down, etc. Now, I'll want that each action has access to a StateSpace so it can do some checking logic. Is this implementation correct? Or is this a bad case of a circular dependence? If yes, how to accomplish "the same" in a different way? Thanks

    Read the article

  • translate a PHP $string using google translator API

    - by Toni Michel Caubet
    hey there! been google'ing for a while how is the best way to translate with google translator in PHP, found very different ways converting URLS, or using Js but i want to do it only with php (or with a very simple solution JS/JQUery) example: //hopefully with $from_lan and $to_lan being like 'en','de', .. or similar function translate($from_lan, $to_lan, $text){ // do return $translated_text; } can you give me a clue? or maybe you already have this function.. my intention it's to use it only for the languages i have not already defined (or keys i haven't defined), that's why i wan it so simple, will be only temporal.. EDIT thanks for your replies we are now trying this soulutions: function auto_translate($from_lan, $to_lan, $text){ // do $json = json_decode(file_get_contents('https://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=' . urlencode($text) . '&langpair=' . $from_lan . '|' . $to_lan)); $translated_text = $json->responseData->translatedText; return $translated_text; } (there was a extra 'g' on variables for lang... anyway) it returns: works now :) i don't really understand much the function, so any idea why is not acepting the object? (now i do) OR: unction auto_translate($from_lan, $to_lan, $text){ // do // $json = json_decode(file_get_contents('https://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=' . urlencode($text) . '&langpair=' . $from_lan . '|' . $to_lan)); // $translated_text = $json['responseData']['translatedText']; error_reporting(1); require_once('GTranslate.php'); try{ $gt = new Gtranslate(); $translated_text = $gt-english_to_german($text); } catch (GTranslateException $ge) { $translated_text= $ge->getMessage(); } return $translated_text; } And this one looks great but it doesn't even gives me an error, the page won't load (error_report(1) :S) thanks in advance!

    Read the article

  • How do I find all paths through a set of given nodes in a DAG?

    - by Hanno Fietz
    I have a list of items (blue nodes below) which are categorized by the users of my application. The categories themselves can be grouped and categorized themselves. The resulting structure can be represented as a Directed Acyclic Graph (DAG) where the items are sinks at the bottom of the graph's topology and the top categories are sources. Note that while some of the categories might be well defined, a lot is going to be user defined and might be very messy. Example: On that structure, I want to perform the following operations: find all items (sinks) below a particular node (all items in Europe) find all paths (if any) that pass through all of a set of n nodes (all items sent via SMTP from example.com) find all nodes that lie below all of a set of nodes (intersection: goyish brown foods) The first seems quite straightforward: start at the node, follow all possible paths to the bottom and collect the items there. However, is there a faster approach? Remembering the nodes I already passed through probably helps avoiding unnecessary repetition, but are there more optimizations? How do I go about the second one? It seems that the first step would be to determine the height of each node in the set, as to determine at which one(s) to start and then find all paths below that which include the rest of the set. But is this the best (or even a good) approach? The graph traversal algorithms listed at Wikipedia all seem to be concerned with either finding a particular node or the shortest or otherwise most effective route between two nodes. I think both is not what I want, or did I just fail to see how this applies to my problem? Where else should I read?

    Read the article

  • SQL query to get latest record for all distinct items in a table

    - by David Buckley
    I have a table of all sales defined like: mysql> describe saledata; +-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ | SaleDate | datetime | NO | | NULL | | | StoreID | bigint(20) unsigned | NO | | NULL | | | Quantity | int(10) unsigned | NO | | NULL | | | Price | decimal(19,4) | NO | | NULL | | | ItemID | bigint(20) unsigned | NO | | NULL | | +-------------------+---------------------+------+-----+---------+-------+ I need to get the last sale price for all items (as the price may change). I know I can run a query like: SELECT price FROM saledata WHERE itemID = 1234 AND storeID = 111 ORDER BY saledate DESC LIMIT 1 However, I want to be able to get the last sale price for all items (the ItemIDs are stored in a separate item table) and insert them into a separate table. How can I get this data? I've tried queries like this: SELECT storeID, itemID, price FROM saledata WHERE itemID IN (SELECT itemID from itemmap) ORDER BY saledate DESC LIMIT 1 and then wrap that into an insert, but it's not getting the proper data. Is there one query I can run to get the last price for each item and insert that into a table defined like: mysql> describe lastsale; +-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ | StoreID | bigint(20) unsigned | NO | | NULL | | | Price | decimal(19,4) | NO | | NULL | | | ItemID | bigint(20) unsigned | NO | | NULL | | +-------------------+---------------------+------+-----+---------+-------+

    Read the article

  • How to have multiple instances of jQuery plugin on single page?

    - by James Skidmore
    I'm writing a simple jQuery plugin, but I'm having trouble being able to use multiple instances on a page. For instance, here is a sample plugin to illustrate my point: (function($) { $.fn.samplePlugin = function(options) { if (typeof foo != 'undefined') { alert('Already defined!'); } else { var foo = 'bar'; } }; })(jQuery); And then if I do this: $(document).ready(function(){ $('#myDiv').samplePlugin({}); // does nothing $('#myDiv2').samplePlugion({}); // alerts "Already defined!" }); This is obviously an over-simplified example to get across the point. So my question is, how do I have two separate instances of the plugin? I'd like to be able to use it across multiple instances on the same page. I'm guessing that part of the problem might be with defining the variables in a global scope. How can I define them unique to that instance of the plugin then? Thank you for your guidance!

    Read the article

  • For a set of sql-queries, how do you determine which result-set contains a certain row?

    - by ManBugra
    I have a set of sql - queries: List<String> queries = ... queries[0] = "select id from person where ..."; ... queries[8756] = "select id from person where ..."; Each query selects rows from the same table 'person'. The only difference is the where-clause. Table 'person' looks like this: id | name | ... many other columns How can i determine which queries will contain a certain person in their subset? For example: List<Integer> matchingQueries = magicMethod(queries, [23,45]); The list obtained by 'magicMethod' filters all sql queries present in the list 'queries' (defined above) and returns only those that contain either the person with id 23 OR a person with id 45. Why i need it: I am dealing with an application that contains products and categories where the categories are sql queries that define which products belong to them (queries stored in a table also). Now i have a requirement where an admin has to see all categories an item belongs to immediately after the item was created. Btw, over 8.000 categories defined (so far, more to come). language and db: java && postgreSQL Thanks,

    Read the article

  • Calculating a total cost in Python

    - by Sérgio Lourenço
    I'm trying to create a trip planner in python, but after I defined all the functions I'm not able to call and calculate them in the last function tripCost(). In tripCost, I want to put the days and travel destination (city) and the program runs the functions and gives me the exact result of all the 3 functions previously defined. Code: def hotelCost(): days = raw_input ("How many nights will you stay at the hotel?") total = 140 * int(days) print "The total cost is",total,"dollars" def planeRideCost(): city = raw_input ("Wich city will you travel to\n") if city == 'Charlotte': return "The cost is 183$" elif city == 'Tampa': return "The cost is 220$" elif city == 'Pittsburgh': return "The cost is 222$" elif city == 'Los Angeles': return "The cost is 475$" else: return "That's not a valid destination" def rentalCarCost(): rental_days = raw_input ("How many days will you rent the car\n") discount_3 = 40 * int(rental_days) * 0.2 discount_7 = 40 * int(rental_days) * 0.5 total_rent3 = 40 * int(rental_days) - discount_3 total_rent7 = 40 * int(rental_days) - discount_7 cost_day = 40 * int(rental_days) if int(rental_days) >= 3: print "The total cost is", total_rent3, "dollars" elif int(rental_days) >= 7: print "The total cost is", total_rent7, "dollars" else: print "The total cost is", cost_day, "dollars" def tripCost(): travel_city = raw_input ("What's our destination\n") days_travel = raw_input ("\nHow many days will you stay\n") total_trip_cost = hotelCost(int(day_travel)) + planeRideCost (str(travel_city)) + rentalCost (int(days_travel)) return "The total cost with the trip is", total_trip_cost tripCost()

    Read the article

  • Best way to use PL/SQL Pacakge Cursors from Pro*C

    - by Greg Reynolds
    I have a cursor defined in PL/SQL, and I am wondering what the best way to use it from Pro*C is. Normally for a cursor defined in Pro*C you would do: EXEC SQL DECLARE curs CURSOR FOR SELECT 1 FROM DUAL; EXEC SQL OPEN curs; EXEC SQL FETCH curs INTO :foo; EXEC SQL CLOSE cusr; I was hoping that the same (or similar) syntax would work for a packaged cursor. For example, I have a package MyPack, with a declaration type MyType is record (X integer); cursor MyCurs(x in integer) return MyType; Now I have in my Pro*C code a rather unsatisfying piece of embedded PL/SQL that opens the cursor, does the fetching etc., as I couldn't get the first style of syntax to work. Using the example EXEC SQL EXECUTE DECLARE XTable is table of MyPack.MyType; BEGIN OPEN MyPack.MyCurs(:param); FETCH MyPack.MyCurs INTO XTable; CLOSE MyPack.MyCurs; END; END-EXEC; Does anyone know if there is a more "Pure" Pro*C approach?

    Read the article

  • How can I define an empty array in a Perl construtor?

    - by Laimoncijus
    I am just beginner with Perl, so if it sounds stupid - sorry for that :) My problem is - I am trying to write a class, which has an empty array, defined in constructor of a class. So I am doing this like this: package MyClass; use strict; sub new { my ($C) = @_; my $self = { items => () }; bless $self, ref $C || $C; } sub get { return $_[0]->{items}; } 1; Later I am testing my class with simple script: use strict; use Data::Dumper; use MyClass; my $o = MyClass->new(); my @items = $o->get(); print "length = ", scalar(@items), "\n", Dumper(@items); And while running the script I get following: $ perl my_test.pl length = 1 $VAR1 = undef; Why am I doing wrong what causes that I get my items array filled with undef? Maybe someone could show me example how the class would need to be defined so I would not get any default values in my array?

    Read the article

  • Excel 2007 UDF keeps failing, why?

    - by Zan
    I've been trying to browse info about this for a while now. The user defined functions in Excel 2007 just make no sense to me whatsoever. According to all the tutorials, it should be really simple. Just press alt + f11, insert a new module, and enter the VBA code there. At this point typing '=FUNCTIONNAME(parameters)' into any cell should make it work. It did, at first. Then upon closing and reopening the worksheet it stopped working. I checked to see that macros were enabled, but either way, that didn't help. Then I browsed the graphic UI from the function button to locate user defined functions. I found it there by name of 'MyExcelWorksheet.xls!FUNCTIONNAME.FUNCTIONNAME' and clicking that, it started working again. Now, a day later, I get back to working on this and it's broken, again. I just get #NAME? error or some "Function Arguments - Function doesn't use any arguments" -popup (translated from Finnish Excel, not sure what that msg is in English) when I select the function from the GUI. So what does it take to just create a function, and actually make it work and KEEP working? For the life of me I can't figure out why this has to be so difficult. :) I'm starting to think my company has some weird settings enabled or whatever, because judging by the lack of information I've found on the subject, this isn't supposed to happen.

    Read the article

< Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >