Search Results

Search found 1421 results on 57 pages for 'arbitrary'.

Page 36/57 | < Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >

  • PHP OOP: Unique method per argument type?

    - by sunwukung
    I'm writing a little homebrew ORM (academic interest). I'm trying to adhere to the TDD concept as a training exercise, and as part of that exercise I'm writing documentation for the API as I develop the class. Case in point - I'm working on a classic "getCollection" type mapper class. I want it to be able to retrieve collections of asset X (let's say blog posts) for a specific user, and also collections based on an arbitrary array of numeric values. So - you might have a method like any one of these $User = $UserMapper->load(1); $ArticleCollection = $ArticleMapper->getCollection(range(10,20)); $ArticleCollection = $ArticleMapper->getCollection($User); $ArticleCollection = $ArticleMapper->getCollection($User->getId()); So, in writing the documentation for the getCollection method - I want to declare the @param variable in the Docblock. Is it better to have a unique method for each argument type, or is it acceptable to have a method that delegates to the correct internal method/class based on argument type?

    Read the article

  • Zend Database Adapter - Complex MySQL Query

    - by Sonny
    I have defined a function in my Navigation model that executes a query, and I was wondering if there's a more "Zendy" way of generating/executing the query. The query I'm using was proposed by Bill Karwin on another thread here for setting arbitrary record order. I tried using a prepared statement, but the values in the SIGN() function got quoted. I'm using the PDO adapter for MySQL. /** * */ public function setPosition($parentId, $oldPosition, $newPosition) { $parentId = intval($parentId); $oldPosition = intval($oldPosition); $newPosition = intval($newPosition); $this->getAdapter()->query(" UPDATE `navigation` SET `position` = CASE `position` WHEN $oldPosition THEN $newPosition ELSE `position` + SIGN($oldPosition - $newPosition) END WHERE `parent_id` = $parentId AND `position` BETWEEN LEAST($oldPosition, $newPosition) AND GREATEST($oldPosition, $newPosition) "); return $this; }

    Read the article

  • How do I use an enum with custom values for a Sharepoint Web part?

    - by Jeff
    I'm trying to design a Web Part that has a drop-down list for the user to choose from. Eventually, these values will be automatically generated based on some kind of outside data source, so they're going to have somewhat arbitrary numeric values associated with them. This is the code I have now: public enum filterChoice { All=0, BOCC=12, Sustainability=15, Clerk=4, DA=13, Emergency=7, Highlights=3, POS=6, PR=1, PH=5, SHPR=2, Test=8, Transportation=14, Volunteer=16 }; These are different categories I want the user to choose from. When I choose one and save the settings for my Web Part, Sharepoint is only saving the values in numeric order; that is, All=0, BOCC=1, Sustainability=3 [...] so my Web Part then thinks the user chose the value with the corresponding number (PR when they chose BOCC, Highlights when they chose Sustainability, etc.) How can I make Sharepoint honor my custom values?

    Read the article

  • Why does the Scala compiler disallow overloaded methods with default arguments?

    - by soc
    While there might be valid cases where such method overloadings could become ambiguous, why does the compiler disallow code which is neither ambiguous at compile time nor at run time? Example: // This fails: def foo(a: String)(b: Int = 42) = a + b def foo(a: Int) (b: Int = 42) = a + b // This fails, too. Even if there is no position in the argument list, // where the types are the same. def foo(a: Int) (b: Int = 42) = a + b def foo(a: String)(b: String = "Foo") = a + b // This is OK: def foo(a: String)(b: Int) = a + b def foo(a: Int) (b: Int = 42) = a + b // Even this is OK. def foo(a: Int)(b: Int) = a + b def foo(a: Int)(b: String = "Foo") = a + b val bar = foo(42)_ // This complains obviously ... Are there any reasons why these restrictions can't be loosened a bit? Especially when converting heavily overloaded Java code to Scala default arguments are a very important and it isn't nice to find out after replacing plenty of Java methods by one Scala methods that the spec/compiler imposes arbitrary restrictions.

    Read the article

  • Can you use Win32 GUI in a browser plugin?

    - by John
    Of course it would mean you're plugin is not cross-platform but let's focus on the technical side... Is a browser plugin (like done in NPAPI) restricted in what it can do? Or do you get fairly free reign to access the PC and the render-window you're given? For instance can you create Win32/MFC controls in your browser this way? A side question - is your browser plugin conceptually akin to a .DLL, which is therefore just arbitrary compiled code implementing a specific interface for browser control/communication?

    Read the article

  • Xcode File management. What is best practice?

    - by ian1971
    I've been using Xcode for a while now. One thing that always bugs me is the way it handles files. I like to have my files all in nested folders rather than one big physical folder, but when you create a group in Xcode by default it does not create a folder just a virtual folder within the project. I can see that virtual folders are great for linking code in arbitrary places into your project but once you get beyond a few classes I find the one big folder approach really painful. And then if you try to fix it later it takes ages and is easy to break your build. Is it possible to change this behaviour so that by default it creates a physical folder? Or am I doing it wrong and trying to cling to some other way of working? How do other people work with files in Xcode?

    Read the article

  • Java Swing UI Changing Method

    - by vigilant
    I would like to use Swing to program a simple learning game. I am wondering what would be best way to switch between UI screens. For example, I would have a screen for the Main Menu, and then when the user presses a button on that screen, I would swap out the whole screen for a completely different one. Then, arbitrary screens can be swapped in at any moment, and all of their event handlers would be reactivated while the inactive screen's event handlers will be deactivated. What type of Swing component/control would I use for each of the 'screens'. Is this even doable?

    Read the article

  • Which relational databases exist with a public API for a high level language?

    - by Jens Schauder
    We typically interface with a RDBMS through SQL. I.e. we create a sql string and send it to the server through JDBC or ODBC or something similar. Are there any RDBMS that allow direct interfacing with the database engine through some API in Java, C#, C or similar? I would expect an API that allows constructs like this (in some arbitrary pseudo code): Iterator iter = engine.getIndex("myIndex").getReferencesForValue("23"); for (Reference ref: iter){ Row row = engine.getTable("mytable").getRow(ref); } I guess something like this is hidden somewhere in (and available from) open source databases, but I am looking for something that is officially supported as a public API, so one finds at least a note in the release notes, when it changes. In order to make this a question that actually has a 'best' answer: I prefer languages in the order given above and I will prefer mature APIs over prototypes and research work, although these are welcome as well.

    Read the article

  • How to go about signing text in a verifiable way from within ruby in a simple yet strong & portable

    - by roja
    Guys, I have been looking for a portable method to digitally sign arbitrary text which can be placed in a document and distributed while maintaining its verifiable origin. Here is an example: a = 'some text' a.sign(<private key>) # => <some signature in ASCII format> The contents of a can now be distributed freely. If a receiver wants to check the validity of said text they can do the following: b = 'some text' b.valid(<public key>, <signature supplied with text>) # => true/false Is there any library out there that already offers this kind of functionality? Ruby standard library contains SHA hashing code so at lest there is a portable way to perform the hashing but from that point I am struggling to find anything which fits purpose. Kind Regards, Roja

    Read the article

  • Why do virtual memory addresses for linux binaries start at 0x8048000?

    - by muteW
    Disassembling an ELF binary on a Ubuntu x86 system I couldn't help but notice that the code(.text) section starts from the virtual address 0x8048000 and all lower memory addresses seem to be unused. This seems to be rather wasteful and all Google turns up is either folklore involving STACK_TOP or protection against null-pointer dereferences. The latter case looks like it can be fixed by using a single page instead of leaving a 128MB gap. So my question is this - is there a definitive answer to why the layout has been fixed to these values or is it just an arbitrary choice?

    Read the article

  • How to write a value validation method for core data?

    - by mystify
    The docs say: you should implement methods of the form validate:error:, as defined by the NSKeyValueCoding protocol so lets say I have an attribute which is an int: friendAge I want to make sure that any friend may not be younger than 30. So how would I make that validation method? -validateFriendAge:error: What am I gonna do in there, exactly? And what shall I do with that NSError I get passed? I think it has an dictionary where I can return a humanly readable string in an arbitrary language (i.e. the one that's used currently), so I can output a reasonable error like: "Friend is not old enough"... how to do that?

    Read the article

  • Right-click on a Listbox in a Silverlight 4 app.

    - by AngryHacker
    I am trying to implement what I used to take for granted in Winforms applications. I am a Silverlight noob, so hopefully all this is elementary. I have a listbox in a Silverlight 4 app. I'd like to do the following: Right-click on the listbox Have the item under the location where I click highlight itself I'd like a context menu to popup (with my own items in the context menu) From my research so far, it appears that there is no ContextMenu construct in Silverlight, instead we have to build up a Grid/Canvas structure and attach it to a Popup object, which is what is then popped up. My questions are as follows: To accomplish #2, I need some kind of hit test on the listbox. I can't figure out how to do that and my google-fu isn't helping. Once I do identify the index under the mouse, how do I actually select the item? Is there a reusable Context menu component somewhere that I can use? Extra credit if the component allows arbitrary sub-menus.

    Read the article

  • How do I arbitrarily reorder lines in a text file using a Unix shell?

    - by Tim Bellis
    I've got a text file with an arbitrary number of lines, e.g.: one line some other line an additional line one more here I'd like to write a script to reorder those lines based on a given order. e.g. An input of 2 1 3 4 would swap the first and second lines. An input of 3 1 2 4 would put the 3rd line first, the 1st line second, the 2nd line third and keep the 4th line fourth. I could hack something together, but I'm wondering if there's an elegant solution? I can use either bash or ksh.

    Read the article

  • Can Visual Studio Express run from USB drive?

    - by system PAUSE
    Using an arbitrary Windows machine (2000/XP or later), I can install Eclipse CDT to a USB drive move that USB drive onto a different Windows machine--one that does not have any form of Eclipse software already installed, and potentially a different version of Windows (but 2000/XP or later) use Eclipse to develop application-level C/C++ programs on that second machine (and that includes using the debugger), running directly from the USB drive without copying anything to C:. I can do all this without having Administrator privileges on either machine. I can do the same with NetBeans, and with several other IDEs that support C/C++ development. Is it possible to do this with any version of Visual Studio Express? If not, can you explain the technical reason(s) this doesn't work?

    Read the article

  • php and XML range into array

    - by Mike
    The code below helps be to get the WHOLE XML and put it into an array. What I'm wondering is, what would be a good way to get the XML only from item 3 - 6 or any arbitrary range instead of the whole document. $mt_arr = array(); $d = new DOMDocument(); $d->load('http://news.google.com/?output=rss'); foreach ($d->getElementsByTagName('item') as $t) { $list = array ( 'title' => $t->getElementsByTagName('title')->item(0)->nodeValue); array_push($mt_arr, $list); } Thanks

    Read the article

  • Securely using exec with PHP to run ffmpeg

    - by Venkat D.
    I would like to run ffmpeg from PHP for video encoding purposes. I was thinking of using the exec or passthru commands. However, I have been warned that enabling these functions is a security risk. In the words of my support staff: The directive 'disable_functions' is used to disable any functions that allow the execution of system commands. This is for more security of the server. These PHP functions can be used to crack the server if not used properly. I'm guessing that if exec is enabled, then someone could (possibly) execute an arbitrary unix command. Does anyone know of a secure way to run ffmpeg from PHP? By the way, I'm on a dedicated server. Thanks ahead of time!

    Read the article

  • How to detect if breaking an edge will make a graph disjoint?

    - by the_graph_guy
    I have a graph that starts off with a single, root node. Nodes are added one by one to the graph. At node creation time, they have to be linked either to the root node, or to another node, by a single edge. Edges can also be created and deleted (one by one, between any two nodes). Nodes can be deleted one at a time. Node and edge creation, deletion operations can happen in any arbitrary order. OK, so here's my question: When an edge is deleted, is it possible do determine, in constant time (i.e. with an O(1) algorithm), if doing this will divide the graph into two disjoint subgraphs? If it will, then which side of the edge will the root node belong? I'm willing to maintain, within reasonable limits, any additional data structure that can facilitate the derivation of this information. Maybe it is not possible to do it in O(1), if so any pointers to literature will be appreciated.

    Read the article

  • python: find and replace numbers < 1 in text file

    - by hjp
    I'm pretty new to Python programming and would appreciate some help to a problem I have... Basically I have multiple text files which contain velocity values as such: 0.259515E+03 0.235095E+03 0.208262E+03 0.230223E+03 0.267333E+03 0.217889E+03 0.156233E+03 0.144876E+03 0.136187E+03 0.137865E+00 etc for many lines... What I need to do is convert all the values in the text file that are less than 1 (e.g. 0.137865E+00 above) to an arbitrary value of 0.100000E+01. While it seems pretty simple to replace specific values with the 'replace()' method and a while loop, how do you do this if you want to replace a range? thanks

    Read the article

  • jQuery .ajax request failing

    - by user1644808
    I currently have a jQuery ajax request set up like this $(document).ready( function() { $.ajax({ url : "http://www.my-computer.com:51000/getJson", cache : false, dataType: "json", success : renderPage, error: handleError }) }); If I manually naviate to http://www.my-computer.com:51000/getJson, I see it returns a json string correctly, but with the above request, I always fall into "handleError" method, with textStatus "error" and not much helpful information. Can anyone help? Thanks! EDIT: sorry about the my-computer domain. this stackoverflow submission won't let me input localhost, so I put in an arbitrary domain instead. I've tried firebug, but had no luck in getting the json back.

    Read the article

  • averaging matrix efficiently

    - by user248237
    in Python, given an n x p matrix, e.g. 4 x 4, how can I return a matrix that's 4 x 2 that simply averages the first two columns and the last two columns for all 4 rows of the matrix? e.g. given: a = array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) return a matrix that has the average of a[:, 0] and a[:, 1] and the average of a[:, 2] and a[:, 3]. I want this to work for an arbitrary matrix of n x p assuming that the number of columns I am averaging of n is obviously evenly divisible by n. let me clarify: for each row, I want to take the average of the first two columns, then the average of the last two columns. So it would be: 1 + 2 / 2, 3 + 4 / 2 <- row 1 of new matrix 5 + 6 / 2, 7 + 8 / 2 <- row 2 of new matrix, etc. which should yield a 4 by 2 matrix rather than 4 x 4. thanks.

    Read the article

  • Centre of a circle that intersects two points

    - by Jason
    Given two points in a 2D plane, and a circle of radius r that intersects both of those points, what would be the formula to calculate the centre of that circle? I realise there would two places the circle can be positioned. I would want the circle whose centre is encountered first in a clockwise direction when sweeping the line that joins the two points around one of those points, starting from an arbitrary angle. I guess that is the next stage in my problem, after I find an answer for the first part. I'm hoping the whole calculation can be done without trigonometry for speed. I'm starting with integer coordinates and will end with integer coordinates, if that helps.

    Read the article

  • Referencing invalid memory locations with C++ Iterators

    - by themoondothshine
    I am a big fan of GCC, but recently I noticed a vague anomaly. Using __gnu_cxx::__normal_iterator (ie, the most common iterator type used in libstdc++, the C++ STL) it is possible to refer to an arbitrary memory location and even change its value without causing an exception! Is this expected behavior? If so, isn't a security loophole? Here's an example: #include <iostream> using namespace std; int main() { basic_string<char> str("Hello world!"); basic_string<char>::iterator iter = str.end(); iter += str.capacity() + 99999; *iter = 'x'; cout << "Value: " << *iter << endl; }

    Read the article

  • how to find out if a shape is passable

    - by jd
    I have a complex polygon (possibly concave) and a few of its edges marked as entry/exit points. there is a possibility that inside this polygon may lie one or more blockades of arbitrary shape. what approaches could I use to determine whether a path of certain width exists between a pair of entry/exit edges? having read through the question it looks like a homework type - it is not. I just wish to have a at least a few leads I could pursue, as this is new to me.

    Read the article

  • Is correct name enough to make it happen?

    - by Knowing me knowing you
    Guys, I've just dipped in to limits.h by MS. I tried to check what's the return type for max() fnc and to my surprise I see something like this: // TEMPLATE CLASS numeric_limits template<class _Ty> class numeric_limits : public _Num_base { // numeric limits for arbitrary type _Ty (say little or nothing) public: static _Ty (__CRTDECL min)() _THROW0() { // return minimum value return (_Ty(0)); } static _Ty (__CRTDECL max)() _THROW0() { // return maximum value return (_Ty(0));//EXACTLY THE SAME WHAT IN min<<------------------ } //... other stuff }; so how is it possiple that in both min and max return does exactly the same? So does it mean if I would write makeSanwich() return (_Ty(0)) it would make a sandwich for me? How is it possible that having this same code just fnc names different we are getting different results?

    Read the article

  • multitreading scheduling related java

    - by vichi
    class A implements Runnable{ B b=new B(); public void run(){ while(true){ System.out.println("H1"+Thread.currentThread().getName()); } } } public class Test { public static void main(String[] str){ A a1 =new A(); // A a2 =new A(); // Thread t1 =new Thread(a1, "Vichi"); Thread t2 =new Thread(a1,"Vishu"); t1.start(); t2.start(); } } what will be the ans: 1) only one of them will get the chance to execute 2) both will get chance in arbitrary manner please suggest possible ans with explations

    Read the article

< Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >