Search Results

Search found 1022 results on 41 pages for 'pseudo'.

Page 25/41 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • Connecting data to a GUI - OOP

    - by tau
    I have an application with several graphs and tables on it. I worked fast and just made classes like Graph and Table that each contained a request object (pseudo-code): class Graph { private request; public function setDateRange(dateRange) { request.setDateRange(dateRange); } public function refresh() { request.getData(function() { //refresh the display }); } } Upon a GUI event (say, someone changes the date range dropdown), I'd just call the setters on the Graph instance and then refresh it. Well, when I added other GUI elements like tables and whatnot, they all basically had similar methods (setDateRange and other things common to the request). What are some more elegant OOP ways of doing this? The application is very simple and I don't want to over-architect it, but I also don't want to have a bunch of classes with basically the same methods that are just routing to a request object. I also don't want to set up each GUI class as inheriting from the request class, but I'm open to any ideas really.

    Read the article

  • How can you pass GET values to another url in php? GET value forwarding

    - by gobackpacking
    Ok, so I'm using Jquery's AJAX function and it's having trouble passing a URL with a http address. So I'm hoping to "get" the GET values and send them to another URL — so: a local php file begin passed GET values, which in turn forwards the GET values to another url. Maybe curl is the answer? I don't know. It's got to be a very short answer I know. pseudo code: //retrieve the GET values $var retrieve [GET] //passing it to another url send get values to url ($var, url_address)

    Read the article

  • help implementing All Nearest Smaller Values algorithm

    - by davit-datuashvili
    http://en.wikipedia.org/wiki/All_nearest_smaller_values this is site of the problem and here is my code but i have some trouble to implement it import java.util.*; public class stack{ public static void main(String[]args){ int x[]=new int[]{ 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 }; Stack<Integer> st=new Stack<Integer>(); for (int a:x){ while (!st.empty() && st.pop()>=a){ System.out.println( st.pop()); if (st.empty()){ break; } else{ st.push(a); } } } } } and here is pseudo code from site S = new empty stack data structure for x in the input sequence: while S is nonempty and the top element of S is greater than or equal to x: pop S if S is empty: x has no preceding smaller value else: the nearest smaller value to x is the top element of S push x onto S

    Read the article

  • How to use TestAndSet() for solving the critical section problem?

    - by Dan Mantyla
    I'm studying for an exam and I'm having difficulty with a concept. This is the pseudo code I am given: int mutex = 0; do { while (TestAndSet(&mutex)); // critical section mutiex = 0; // remainder section } while (TRUE); My instructor says that only two of the three necessary conditions (mutual exclusion, progress, and bounded waiting) are met with this code, but I don't understand which one isn't being met...?? How should the code be modified to support the missing condition to solve the critical region problem? Thanks in advance for any insight!

    Read the article

  • Partition a rectangle into near-squares of given areas

    - by Marko Dumic
    I have a set of N positive numbers, and a rectangle of dimensions X and Y that I need to partition it in N smaller rectangles such that: the surface area of each smaller rectangle is proportional to it's corresponding number in given set all space of big rectangle is occupied and there is no leftover space between smaller rectangles each small rectangle should be shaped as close to square as feasible the execution time should be reasonably small I need directions on this. Do you know of such algorithm described on the web? Do you have any ideas (pseudo-code is fine)? Thanks.

    Read the article

  • Where to place the login/authentication related actions in MVC

    - by rogeriopvl
    I've searched around and found that when implementing an authentication module in MVC architecture some people opt to place the login related actions in the User controller while others place it in a controller dedicated to authentication only. In pseudo-java-like code: class UserController extends Controller { public login() { //... } } Accessed with http://mydomain.com/user/login. vs. class AuthController extends Controller { public login() { //... } } Accessed with http://mydomain.com/auth/login. I would like to know which approach is better, and why. That is, if there's really any difference at all. Thanks in advance.

    Read the article

  • How to implement a book preview (2 page spread) without using Flash?

    - by littlejim84
    I'm looking into a solution for work, where you have a two page spread of the book to preview. Either side of this, you can hover in the corner to create a pseudo-flip and then click the mouse button to actually turn the page. I know there is many Flash solutions out there, but in this case we cannot use it... So we are looking for a possible solution that can work across all major browsers (yes, including IE6)... I looked a few canvas solutions, but with Google's canvas extension for IE, these will terribly slow. So was thinking about an SVG/VML solution, like Raphael Javascript library. This could be good, but then trying to look into how to code this, without examples, could be a challenge with the time constraint. Is there a solution out there that fits (or almost fits) this problem?

    Read the article

  • Javascript: How to filter object array based on attributes?

    - by JGreig
    I have the following JavaScript JSON array of real estate home objects: var json = { 'homes' : [ { "home_id":"1", "price":"925", "sqft":"1100", "num_of_beds":"2", "num_of_baths":"2.0", }, { "home_id":"2", "price":"1425", "sqft":"1900", "num_of_beds":"4", "num_of_baths":"2.5", }, // ... (more homes) ... ]} var xmlhttp = eval('(' + json + ')'); homes = xmlhttp.homes; What I would like to do is be able to perform a filter on the object to return a subset of "home" objects. For example, I want to be able to filter based on: price, sqft, num_of_beds, and num_of_baths. Question: How can I perform something in javascript like the pseudo-code below: var newArray = homes.filter( price <= 1000 & sqft >= 500 & num_of_beds >=2 & num_of_baths >= 2.5); Note, the syntax does not have to be exactly like above. This is just an example.

    Read the article

  • Is there a way to set up a Linux pipe to non-buffering or line-buffering?

    - by ern0
    My program is controlling an external application on Linux, passing in input commands via a pipe to the external applications stdin, and reading output result via a pipe from the external applications stdout. The problem is that writes to pipes are buffered by block, and not by line, and therefore delays occur before my app receives data output by the external application. The external application cannot be altered to add explicit fflush() calls. When I set the external application to /bin/cat -n (it echoes back the input, with line numbers added), it works correctly, it seems, cat flushes after each line. The only way to force the external application to flush, is sending exit command to it; as it receives the command, it flushes, and all the answers appears on the stdout, just before exiting. I'm pretty sure, that Unix pipes are appropiate solution for that kind of interprocess communication (pseudo server-client), but maybe I'm wrong. (I've just copied some text from a similar question: Force another program's standard output to be unbuffered using Python)

    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

  • Apple HTML5 progressive streaming

    - by seanc
    Is there a copy of the file saved to the ipad/ipod when using progressive http download (apple segmented) that the user could potentially copy off the device? meaning, is this scenario considered 'safe' from a content protection pov: 1. user comes to websites with movies behind paywall 2. user selects a movie to watch online (progressively downloaded or 'pseudo-streamed') 3. segments are downloaded seamlessly by html5 video tag as part of .m3u8 4. movie plays/ends. is there any full copy of this movie on the device that can be transferred off? anyone know apple's stance on this?

    Read the article

  • How many double numbers are there between 0.0 and 1.0?

    - by polygenelubricants
    This is something that's been on my mind for years, but I never took the time to ask before. Many (pseudo) random number generators generate a random number between 0.0 and 1.0. Mathematically there are infinite numbers in this range, but double is a floating point number, and therefore has a finite precision. So the questions are: Just how many double numbers are there between 0.0 and 1.0? Are there just as many numbers between 1 and 2? Between 100 and 101? Between 10^100 and 10^100+1? Note: if it makes a difference, I'm interested in Java's definition of double in particular.

    Read the article

  • What is dbReferenceProperty?

    - by user246114
    Hi, In the python app engine docs, I see something called dbReferenceProperty. I can't understand what it is, or how it's used. I'm using the java interface to app engine, so I'm not sure if there's an equivalent. I'm interested in it because it sounds like some sort of pseudo-join, where we can point a property of a class to some other object's value - something like if we had: class User { private String mPhotoUrl; private String mPhone; private String mState; private String mCountry; .. etc .. } class UserLite { @ReferenceProperty User.mPhotoUrl; private String mPhotoUrl; } then if we had to update a User object's mPhotoUrl value, the change would somehow propagate out to all UserLite instances referencing it, rather than having to update every UserLite object instance manually, Thanks

    Read the article

  • Check result of ASP.Net validator clientside

    - by Steffen
    I know the built-in ASP.Net validators come with a client-side framework, however I've been unable to find anything that lets me check a single validator for it's Valid state. I expect it to be possible though, so I hope someone in here knows how to do it :-) The validator in question is a RegularExpressionValidator, which I use to determine whether an e-mail address is valid or not. Here's some brief code: <script> function CheckForExistingEmail() { Page_ClientValidate(); // Ensure client validation if (revEmail.IsValid) // pseudo code! { // Perform server side lookup in DB for whether the e-mail exists. } } </script> <asp:TextBox runat="server" id="tbEmail" onblur="CheckForExistingEmail();" /> <asp:RegularExpressionValidator id="revEmail" runat="server" ControlToValidate="tbEmail" ErrorMessage="Not a valid e-mail address" ValidationExpression="([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})" />

    Read the article

  • running code when two events have triggered

    - by Evert
    This is mostly a language-agnostic question. If I'm waiting for two events to complete (say, two IO events or http requests), what is the best pattern to deal with this. One thing I can think of is the following (pseudo js example). request1.onComplete = function() { req1Completed = true; eventsCompleted(); } request2.onComplete = function() { req2Completed = true; eventsCompleted(); } eventsCompleted = function() { if (!req1Completed || !req2Completed) return; // do stuff } Is this the most effective pattern, or are there more elegant ways to solve this issue?

    Read the article

  • Count number of messages per user

    - by Pr0no
    Consider the following tables: users messages ----------------- ----------------------- user_id messages msg_id user_id content ----------------- ----------------------- 1 0 1 1 foo 2 0 2 1 bar 3 0 3 1 foobar 4 3 baz 5 3 bar I want to count the number of messages per user and insert the outcome into users.messages, like this: users ----------------- user_id messages ----------------- 1 3 2 0 3 2 I could use PHP to perform this operation, pseudo: foreach ($user_id in users) { $count = select count(msg_id) from messages where user_id = $user_id update users set messages = $count } But this is probably very inefficient as compared to one query executed in MySQL directly: UPDATE users SET messages = ( SELECT COUNT(msg_id) FROM messages ) But I'm sure this is not a proper query. Therefore, any help would be appreciated :-)

    Read the article

  • Running a python script for a user-specified amount of time?

    - by Rob
    Sorry, this is probably a terrible question. I've JUST started learning python today. I've been reading a Byte of Python. Right now I have a project for Python that involves time. I can't find anything relating to time in Byte of Python, so I'll ask you: How can I run a block for a user specified amount of time and then break? For example (in some pseudo-code): time = int(raw_input('Enter the amount of seconds you want to run this: ')) while there is still time left: #run this block or even better: import sys time = sys.argv[1] while there is still time left: #run this block Thanks for any help. Also, additional online guides and tutorials would be much appreciated. I really like Byte of Python. Dive into Python can't quite hold my attention, though. I suppose I should suck it up and try harder to read that one.

    Read the article

  • record mouse movements, clicks and keyboard input with Java or C++

    - by Joe
    I want to be able to record mouse movements, clicks and keyboard input from a user. It would be great if it was a cross platform solution. I'd like to get back something like this (pseudo code): mouse moved to 500, 500 mouse double clicked mouse moved to 800, 300 mouse left clicked keyboard typed "Hello World" Does either C++ or Java have any classes that can do this? If I was using C++, I would probably working with the QT framework. Edit: I should have said this originally, but I want to record the movements and clicks outside of the applications gui, so on the desktop too.

    Read the article

  • Scolling list with jQuery

    - by Chris
    My javascript is not up to scratch at the moment and I am stumped with this! I need to create an animated list with javascript like this one - http://www.fiveminuteargument.com/blog/scrolling-list. What I want is to take a list like so <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> <li>Item 5</li> <li>Item 6</li> </ul> And display two at once, then display them in a loop, 2 at a time. Even pseudo code would help to get me started.

    Read the article

  • Find the period of over speed ?

    - by Vimvq1987
    Just something interesting come in my mind. Assume that we have a table (in SQL Server) like this: Location Velocity Time What is the best way to determine over speed periods (speed barrier is defined) ? My first idea was loading the table into an array, and then iterate over array to find these periods: (Pseudo C# code) bool isOverSpeed = false; for (int i =0;i<arr.Length;i++) { if (!isOverSpeed) if (arr[i].Velocity > speedBarrier) { #insert the first record into another array. isOverSpeed = true; } if(isOverSpeed) if (arr[i].Velocity < speedBarrier) { #insert the record into that array isOverSpeed = false; } } It works, but somewhat "not very effectively". Is there a "smarter" way, such as a T-SQL query or another algorithm to do this?

    Read the article

  • Concatinate integer arrays iteratively

    - by Ojtwist
    I have a methode in2.getImagesOneDim() which gives me an array of integers, to be more precise the pixel values of an image. Now i want to create one big array with all the pixel values of all the images. Therefore I have to call this method several times. Now I would like to concatenate the previous output to the current output until all images are read. In some kind of pseudo code, where the + is a concatination ... : for (int i = 1; i < 25; i++) { ConArray = ConArray + in2.getImagesOneDim("../images/"+i); } How would I do this in java ?

    Read the article

  • C++ dynamic array sizing problem

    - by Peter
    The basic pseudo code looks like this: void myFunction() { int size = 10; int * MyArray; MyArray = new int[size]; cout << size << endl; cout << sizeof(MyArray) << endl; } The first cout returns 10, as expected, while the second cout returns 4. Anyone have an explanation?

    Read the article

  • How to determine magnitude of trigonometric function? C++

    - by seaworthy
    > if (((test>=0) && (test<=90)) || ((test>270) && (test<=360))){n_y=1;} > else {n_y=-1;} I need the magnitude of trigonometric function in order to determine the sign of the trigonometric function for an angle falling into a particular quadrant. My plan is to replace the code above with something equivalent. Here is what I want to do in pseudo-code. n_y = cos(test) / (magnitude of cos (test)); This will give me same thing. Abs() only takes integers. Any help is appreciated.

    Read the article

  • is this code correct? [closed]

    - by davit-datuashvili
    hi i have poste this code from this title http://stackoverflow.com/questions/2896363/hi-i-have-question-here-is-pseudo-code-about-sift-up-and-sift-down-on-heaps i have following code of siftup on heap is it correct?i have put here because i have changed at old place my question and it became unreadable so i have posted here public class siftup{ public static void main(String[]args){ int p; int n=12; int a[]=new int[]{15,20,12,29,23,17,22,35,40,26,51,19}; int i=n-1; while (i!=0){ if (i==1) break; p=i/2; if (a[p]<=a[i]){ int t=a[p]; a[p]=a[i]; a[i]=t; } i=p; } for (int j=0;j<n;j++){ System.out.println(a[j]); } } } //result is this 15 20 19 29 23 12 22 35 40 26 51 17 is it correct?

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >