Daily Archives

Articles indexed Saturday May 1 2010

Page 1/76 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • TCP connection lost problems in c#

    - by alex
    Hi: In my application, I have a server listening on a port on localhost for client connection. Then I have clients running and establishes connection with the server. I used tcpListner in c# for the server and the clients were written in perl using Inet function. The connection between clients and server were established without a problem and a message from client is received by the server. However, after about 3 to 4 seconds, the connection is lost. I use netstat -a to see if the status of the connection is still "established". The result is "Close_wait" after I use netstat command on DOS. How can I debug this problem? Which side is causing the lost of connection? Thanks

    Read the article

  • Interface between two related JPA entities

    - by OpenSource
    The scenario is as below (tables shown) Delivery table ------ id channelId type 10 100 fax 20 200 email Fax table ---- id number 100 1234567 101 1234598 Email table ----- id email 200 [email protected] 201 [email protected] basically a one to one relationship between the delivery and the channel entity but since each concrete channel(fax, email) has different members I want to create a generic interface (channel) between the two entities and use it for the @OneToOne relationship. Seems to me a simple scenario where lot of you might have already gone through but I'm unable to succeed. I tried putting that targetEntity thing but no use. Still says "delivery references an unknown entity" Any ideas? thanks in advance

    Read the article

  • Does the combo of PHP5, MySQL, and a Macbook Pro constitute a LAMP stack? If not, what does?

    - by RedEye
    Hello - I mostly code in Visual Studio, I like it, but lately it's making me feel a little claustrophobic. On my MacBook Pro, I've set up PHP5 and MySQL (natively). With the built-in server on the mac, does this constitute a LAMP stack? Is Mac OSX considered a Linux Environment? I have VMWare Fusion 3, should I set up a Linux OS virtually in order to implement a LAMP stack? Should I just use CakePHP or Zend? Any guidance would be greatly appreciated.

    Read the article

  • a non recursive approach to the problem of generating combinations at fault

    - by mark
    Hi, I wanted a non recursive approach to the problem of generating combination of certain set of characters or numbers. So, given a subset k of numbers n, generate all the possible combination n!/k!(n-k)! The recursive method would give a combination, given the previous one combination. A non recursive method would generate a combination of a given value of loop index i. I approached the problem with this code: Tested with n = 4 and k = 3, and it works, but if I change k to a number 3 it does not work. Is it due to the fact that (n-k)! in case of n = 4 and k = 3 is 1. and if k 3 it will be more than 1? Thanks. int facto(int x); int len,fact,rem=0,pos=0; int str[7]; int avail[7]; str[0] = 1; str[1] = 2; str[2] = 3; str[3] = 4; str[4] = 5; str[5] = 6; str[6] = 7; int tot=facto(n) / facto(n-k) / facto(k); for (int i=0;i<tot;i++) { avail[0]=1; avail[1]=2; avail[2]=3; avail[3]=4; avail[4]=5; avail[5]=6; avail[6]=7; rem = facto(i+1)-1; cout<<rem+1<<". "; for(int j=len;j>0;j--) { int div = facto(j); pos = rem / div; rem = rem % div; cout<<avail[pos]<<" "; avail[pos]=avail[j]; } cout<<endl; } int facto(int x) { int fact=1; while(x0) fact*=x--; return fact; }

    Read the article

  • firefox scales images poorly

    - by Jabba
    Hi, I'm using Ubuntu Linux and when I zoom in on a page with "CTRL - +" the images become ugly, i.e. Firefox doesn't scale them correctly. Using Chromium-browser I don't have this issue. I have this problem on several machines with various versions of Firefox (3.5-3.6). Here is an example: http://xs.to/image-2AA4_4BDA24DE.jpg . Any idea how to change the scaling behaviour of Firefox? Thanks, Jabba

    Read the article

  • What components of your site do you typically "offload" or embed?

    - by Chad
    Here's what I mean. In developing my ASP.NET MVC based site, I've managed to offload a great deal of the static file hosting and even some of the "work". Like so: jQuery for my javascript framework. Instead of hosting it on my site, I use the Google CDN Google maps, obviously "offloaded" - no real work being performed on my server - Google hosted jQueryUI framework - Google CDN jQueryUI CSS framework - Google CDN jQueryUI CSS framework themes - Google CDN So what I'm asking is this, other than what I've got listed... What aspects of your sites have you been able to offload, or embed, from outside services? Couple others that come to mind... OpenAuth - take much of the authentication process work off your site Google Wave - when it comes out, take communication work off of your site

    Read the article

  • c# Network Programming - HTTPWebRequest Scraping

    - by masterguru
    Hi, I am building a web scraping application. It should scrape a complex web site with concurrent HttpWebRequests from a single host to a single target web server. The application should run on Windows server 2008. One single HttpWebRequest for data could take from 1 minute to 4 minutes to complete (because of long running db operations) I should have at least 100 parallel requests to the target web server, but i have noticed that when i use more then 2-3 long-running requests i have big performance issues (request timeouts/hanging). How many concurrent requests can i have in this scenario from a single host to a single target web server? can i use Thread Pools in the application to run parallel HttpWebRequests to the server? will i have any issues with the default outbound HTTP connection/requests limits? what about Request timeouts when i reach outbound connection limits? what would be the best setup for my scenario? Any help would be appreciated. Thanks

    Read the article

  • Javascript event chaining / binding

    - by Charlie Brown
    I have a select list which has a function with a jQuery .post bound on the change() event. <select id="location"> <option value="1"></option> <option value="2"></option> </select> $('#location').change(location_change); function location_change(){ var url = ''; $.post(url, callback); } What I would like to happen is other controls on the page can bind to the $.post callback function like it was an event, so after the location is changed the data is posted back to the server and once the post returns successfully, the subscriber events are fired.

    Read the article

  • This program runs but not correctly; the numbers aren't right.

    - by user320950
    this program runs but not correctly numbers arent right, i read numbers from a file and then when i am using them in the program they are not right.:brief decription of what i am trying to do can someone tell me if something doesnt look right. this is what i have to do: write a program that determines the grade dispersal for 100 students You are to read the exam scores into three arrays, one array for each exam. You must then calculate how many students scored A’s (90 or above), B’s (80 or above), C’s (70 or above), D’s (60 or above), and F’s (less than 60). Do this for each exam and write the distribution to the screen. // basic file operations #include <iostream> #include <fstream> using namespace std; int read_file_in_array(double exam[100][3]); double calculate_total(double exam1[], double exam2[], double exam3[]); // function that calcualates grades to see how many 90,80,70,60 //void display_totals(); double exam[100][3]; int main() { double go,go2,go3; double exam[100][3],exam1[100],exam2[100],exam3[100]; go=read_file_in_array(exam); go2=calculate_total(exam1,exam2,exam3); //go3=display_totals(); cout << go,go2,go3; return 0; } /* int display_totals() { int grade_total; grade_total=calculate_total(exam1,exam2,exam3); return 0; } */ double calculate_total(double exam1[],double exam2[],double exam3[]) { int calc_tot,above90=0, above80=0, above70=0, above60=0,i,j, fail=0; double exam[100][3]; calc_tot=read_file_in_array(exam); for(i=0;i<100;i++) { for (j=0; j<3; j++) { exam1[i]=exam[100][0]; exam2[i]=exam[100][1]; exam3[i]=exam[100][2]; if(exam[i][j] <=90 && exam[i][j] >=100) { above90++; { if(exam[i][j] <=80 && exam[i][j] >=89) { above80++; { if(exam[i][j] <=70 && exam[i][j] >=79) { above70++; { if(exam[i][j] <=60 && exam[i][j] >=69) { above60++; { if(exam[i][j] >=59) { fail++; } } } } } } } } } } } return 0; } int read_file_in_array(double exam[100][3]) { ifstream infile; int exam1[100]; int exam2[100]; int exam3[100]; infile.open("grades.txt");// file containing numbers in 3 columns if(infile.fail()) // checks to see if file opended { cout << "error" << endl; } int num, i=0,j=0; while(!infile.eof()) // reads file to end of line { for(i=0;i<100;i++) // array numbers less than 100 { for(j=0;j<3;j++) // while reading get 1st array or element infile >> exam[i][j]; infile >> exam[i][j]; infile >> exam[i][j]; cout << exam[i][j] << endl; { if (! (infile >> exam[i][j]) ) cout << exam[i][j] << endl; } exam[i][j]=exam1[i]; exam[i][j]=exam2[i]; exam[i][j]=exam3[i]; } infile.close(); } return 0; }

    Read the article

  • Resharper doesn't play well with XAML?

    - by John Weldon
    I've been noticing a pattern with ReSharper (both 4.5 and 5). Very often (almost always) when I have solution-wide analysis turned on, and WPF code in my solution, ReSharper will mark a number of the .xaml.cs files as being broken. When I navigate to the file, sometimes it magically updates and displays no errors, and other times I have to open other files that are not being correctly read and close them again to force resharper to correctly analyze them. I assume it has something to do with the temporary .cs code that is generated with XAML, but does anyone know why this is actually happening, and if there is a work around? Should I just file a bug report with JetBrains? Does anyone else experience this?

    Read the article

  • Hibernate list operation question

    - by Sumit Kishore
    I'm working on a utility to update a list of entities in a database as a group. The database contains a list of entities. The result of the update is a new list. The API accepts this new list. The update may end up modifying some of the entities in the list, creating new ones and deleting some. So at the entity level, I may have to do any of an insert, delete or update operation. But it's always true that the final list in the database will be the same as the list passed down to the API. Is there in Hibernate a way to treat this operation at the list level, that is, tell Hibernate to persist this list of entities, and let it take care of which need to be created, updated or deleted? There is no entity/table representing this list, btw. Just the entities themselves in a table.

    Read the article

  • Google maps API V3 code to V2 help.

    - by abemonkey
    I've started working on a project to inject markers into a map with jQuery by looping through rows on a table in the page. After getting it working I realized that I was accessing the V3 API and using V3 syntax. I've been beating my head against a wall trying to get this working in google maps API V2. If someone could please take a look at my code and help that would be great! Thanks! You can see my little test in action at www.axtsweapons.com/maptest.html. Here is the JS code: <script type="text/javascript"> $(function() { var latlng = new google.maps.LatLng(45.440000,-122.630000); var settings = { zoom: 12, center: latlng, disableDefaultUI: false, mapTypeControl:false, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), settings); $('tr').each(function(i) { var the_marker = new google.maps.Marker({ title: $(this).find('.views-field-title').text(), map: map, clickable: true, position: new google.maps.LatLng( parseFloat($(this).find('.views-field-latitude').text()), parseFloat($(this).find('.views-field-longitude').text()) ) }); var bounds = new google.maps.LatLngBounds(); var infowindow = new google.maps.InfoWindow({ content: $(this).find('.views-field-title').text() + $(this).find('.adr').text() }); new google.maps.event.addListener(the_marker, 'click', function() { infowindow.close(); infowindow.open(map, the_marker); }); }); }); </script>

    Read the article

  • Elusive race condition in Java

    - by nasufara
    I am creating a graphing calculator. In an attempt to squeeze some more performance out of it, I added some multithreaded to the line calculator. Essentially what my current implementation does is construct a thread-safe Queue of X values, then start however many threads it needs, each one calculating a point on the line using the queue to get its values, and then ordering the points using a HashMap when the calculations are done. This implementation works great, and that's not where my race condition is (merely some background info). In examining the performance results from this, I found that the HashMap is a performance bottleneck, since I do that synchronously on one thread. So I figured that ordering each point as its calculated would work best. I tried a PriorityQueue, but that was slower than the HashMap. I ended up creating an algorithm that essentially works like this: I construct a list of X values to calculate, like in my current algorithm. I then copy that list of values into another class, unimaginatively and temporarily named BlockingList, which is responsible for ordering the points as they are calculated. BlockingList contains a put() method, which takes in two BigDecimals as parameters, the first the X value, the second the calculated Y value. put() will only accept a value if the X value is the next one on the list to be accepted in the list of X values, and will block until another thread gives it the next excepted value. For example, since that can be confusing, say I have two threads, Thread-1 and Thread-2. Thread-2 gets the X value 10.0 from the values queue, and Thread-1 gets 9.0. However, Thread-1 completes its calculations first, and calls put() before Thread-2 does. Because BlockingList is expecting to get 10.0 first, and not 9.0, it will block on Thread-1 until Thread-2 finishes and calls put(). Once Thread-2 gives BlockingList 10.0, it notify()s all waiting threads, and expects 9.0 next. This continues until BlockingList gets all of its expected values. (I apologise if that was hard to follow, if you need more clarification, just ask.) As expected by the question title, there is a race condition in here. If I run it without any System.out.printlns, it will sometimes lock because of conflicting wait() and notifyAll()s, but if I put a println in, it will run great. A small implementation of this is included below, and exhibits the same behavior: import java.math.BigDecimal; import java.util.concurrent.ConcurrentLinkedQueue; public class Example { public static void main(String[] args) throws InterruptedException { // Various scaling values, determined based on the graph size // in the real implementation BigDecimal xMax = new BigDecimal(10); BigDecimal xStep = new BigDecimal(0.05); // Construct the values list, from -10 to 10 final ConcurrentLinkedQueue<BigDecimal> values = new ConcurrentLinkedQueue<BigDecimal>(); for (BigDecimal i = new BigDecimal(-10); i.compareTo(xMax) <= 0; i = i.add(xStep)) { values.add(i); } // Contains the calculated values final BlockingList list = new BlockingList(values); for (int i = 0; i < 4; i++) { new Thread() { public void run() { BigDecimal x; // Keep looping until there are no more values while ((x = values.poll()) != null) { PointPair pair = new PointPair(); pair.realX = x; try { list.put(pair); } catch (Exception ex) { ex.printStackTrace(); } } } }.start(); } } private static class PointPair { public BigDecimal realX; } private static class BlockingList { private final ConcurrentLinkedQueue<BigDecimal> _values; private final ConcurrentLinkedQueue<PointPair> _list = new ConcurrentLinkedQueue<PointPair>(); public BlockingList(ConcurrentLinkedQueue<BigDecimal> expectedValues) throws InterruptedException { // Copy the values into a new queue BigDecimal[] arr = expectedValues.toArray(new BigDecimal[0]); _values = new ConcurrentLinkedQueue<BigDecimal>(); for (BigDecimal dec : arr) { _values.add(dec); } } public void put(PointPair item) throws InterruptedException { while (item.realX.compareTo(_values.peek()) != 0) { synchronized (this) { // Block until someone enters the next desired value wait(); } } _list.add(item); _values.poll(); synchronized (this) { notifyAll(); } } } } My question is can anybody help me find the threading error? Thanks!

    Read the article

  • Duplicate a collection of entities and persist in Hibernate/JPA

    - by Michael Bavin
    Hi, I want to duplicate a collection of entities in my database. I retreive the collection with: CategoryHistory chNew = new CategoryHistory(); CategoryHistory chLast = (CategoryHistory)em.createQuery("SELECT ch from CategoryHistory ch WHERE ch.date = MAX(date)").getSingleResult; List<Category> categories = chLast.getCategories(); chNew.addCategories(categories)// Should be a copy of the categories: OneToMany Now i want to duplicate a list of 'categories' and persist it with EntityManager. I'm using JPA/Hibernate. UPDATE After knowing how to detach my entities, i need to know what to detach: current code: CategoryHistory chLast = (CategoryHistory)em.createQuery("SELECT ch from CategoryHistory ch WHERE ch.date=(SELECT MAX(date) from CategoryHistory)").getSingleResult(); Set<Category> categories =chLast.getCategories(); //detach org.hibernate.Session session = ((org.hibernate.ejb.EntityManagerImpl) em.getDelegate()).getSession(); session.evict(chLast);//detaches also its child-entities? //set the realations chNew.setCategories(categories); for (Category category : categories) { category.setCategoryHistory(chNew); } //set now create date chNew.setDate(Calendar.getInstance().getTime()); //persist em.persist(chNew); This throws a failed to lazily initialize a collection of role: entities.CategoryHistory.categories, no session or session was closed exception. I think he wants to lazy load the categories again, as i have them detached. What should i do now?

    Read the article

  • Grails - Development advice - Where do I find Plugin APIs / Troubleshoot errors / Make life easy for

    - by gav
    Hello fellow Grails Developers! I was wondering if you could help me with what must be a very common issue. I have come from a world of Java and eclipse where JavaDocs and APIs are at your fingertips. Grails has some great features and plugins but I find their inner workings completely undescoverable and that makes me sad. Take for example the excellent authentication plugin, I set this up using the brief but accurate doc. Now I'm in eclipse with STS and I'm staring at a method; applicationContext.authenticationService.filterRequest( request, response, "${request.contextPath}/authentication/index" ) Which is throwing an exception; 2010-05-01 01:17:07,292 [http-8080-1] ERROR [/grailsapp].[default] - Servlet.service() for servlet default threw exception java.lang.IllegalStateException at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407) at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:118) at org.codehaus.groovy.grails.web.sitemesh.GrailsPageResponseWrapper.sendError(GrailsPageResponseWrapper.java:91) And I have no idea where to start. I would love to have eclipse link to the source but there must be other manageable alternatives too as I know some people use TextMate or vim for development, they can't all have discovered the APIs for the plugins through trial and error!?! Is there any way of making the core Grails API more accessible / searchable? Autocomplete also doesn't seem to work for me in eclipse so if anyone has this working that would be ideal (It's an extension of the same question really). What's your approach? (Please don't say intelliJ, I can't afford it) I'm sure it's obvious and I'm just missing it, please put me out of my misery! Thanks in advance, Gav

    Read the article

  • Viewstate is setting control values incorrectly.

    - by Praesagus
    I have a page with several checkboxes on it. The checkboxes correlate to user permissions so when I change users and the page refreshes, the values of the checkboxes should change since each user is different. In spite of the fact that my code sets the value of the checkbox, viewstate or whatever changes the values to what the previous user's values were. I tried chk.EnableViewState = false; but that did not help. I set EnableViewState="false" EnableViewStateMac="false" EnableEventValidation="false" in the page directives, but that doesn't help. The only way I have been able to fix this is to add a unique value to the controls so that their names are always different. I am sure it's an issue of ignorance. Thank you for your help. There is no databinding per se. When the page loads I am creating the textboxes and setting their values via code.

    Read the article

  • General advice and guidelines on how to properly override object.GetHashCode()

    - by Svish
    According to MSDN, a hash function must have the following properties: If two objects compare as equal, the GetHashCode method for each object must return the same value. However, if two objects do not compare as equal, the GetHashCode methods for the two object do not have to return different values. The GetHashCode method for an object must consistently return the same hash code as long as there is no modification to the object state that determines the return value of the object's Equals method. Note that this is true only for the current execution of an application, and that a different hash code can be returned if the application is run again. For the best performance, a hash function must generate a random distribution for all input. I keep finding myself in the following scenario: I have created a class, implemented IEquatable<T> and overridden object.Equals(object). MSDN states that: Types that override Equals must also override GetHashCode ; otherwise, Hashtable might not work correctly. And then it usually stops up a bit for me. Because, how do you properly override object.GetHashCode()? Never really know where to start, and it seems to be a lot of pitfalls. Here at StackOverflow, there are quite a few questions related to GetHashCode overriding, but most of them seems to be on quite particular cases and specific issues. So, therefore I would like to get a good compilation here. An overview with general advice and guidelines. What to do, what not to do, common pitfalls, where to start, etc. I would like it to be especially directed at C#, but I would think it will work kind of the same way for other .NET languages as well(?). I think maybe the best way is to create one answer per topic with a quick and short answer first (close to one-liner if at all possible), then maybe some more information and end with related questions, discussions, blog posts, etc., if there are any. I can then create one post as the accepted answer (to get it on top) with just a "table of contents". Try to keep it short and concise. And don't just link to other questions and blog posts. Try to take the essence of them and then rather link to source (especially since the source could disappear. Also, please try to edit and improve answers instead of created lots of very similar ones. I am not a very good technical writer, but I will at least try to format answers so they look alike, create the table of contents, etc. I will also try to search up some of the related questions here at SO that answers parts of these and maybe pull out the essence of the ones I can manage. But since I am not very stable on this topic, I will try to stay away for the most part :p

    Read the article

  • Python dictionary formating

    - by None
    I made a python function to convert dictionaries to formatted strings. My goal was to have a function take a dictionary for input and turn it into a string that looked good. For example, something like "{'text':'Hello', 'blah':{'hi':'hello','hello':'hi'}}" would be turned into this: text: Hello blah: hi: hello hello: hi This is the code I wrote: indent = 0 def format_dict(d): global indent res = "" for key in d: res += (" " * indent) + key + ":\n" if not type(d[key]) == type({}): res += (" " * (indent + 1)) + d[key] + "\n" else: indent += 1 res += format_dict(d[key]) indent -= 1 return res #test print format_dict({'key with text content':'some text', 'key with dict content': {'cheese': 'text', 'item':{'Blah': 'Hello'}}}) It works like a charm. It checks if the dictionary item is another dictionary, in which it process that, or something else, in which it would use that as the value. The problem is: I can't have a dictionary and a string together in a dictionary item. For example: if I wanted blah: hi hello: hello again there'd be no way to do it. Is there some way I could have something like a list item in a dictionary. Something like this "{'blah':{'hi', 'hello':'hello again'}}"? And if you provide a solution could you tell me how I would need to change my code (if it did require changes). Note: I am using python 2.5

    Read the article

  • Storing Objects in columns using Hibernate JPA

    - by user210791
    Is it possible to store something like the following using only one table? Right now, what hibernate will do is create two tables, one for Families and one for people. I would like for the familymembers object to be serialized into the column in the database. @Entity(name = "family") class Family{ private final List<Person> familyMembers; } class Person{ String firstName, lastName; int age; }

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >