Search Results

Search found 597 results on 24 pages for 'naughty coder'.

Page 8/24 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Parallelizing some LINQ to XML

    - by Lol coder
    How can I make this code run in parallel? List<Crop> crops = new List<Crop>(); //Get up to 10 pages of data. for (int i = 1; i < 10; i++) { //i is basically used for paging. XDocument document = XDocument.Load(string.Format(url, i)); crops.AddRange(from c in document.Descendants("CropType") select new Crop { //The data here. }); }

    Read the article

  • Truncating double without rounding in C

    - by Coder
    Lets consider we have a double R = 99.999999; (which may be obtained by a result of some other computation),now the desired output is 99.99 I tried using printf("%.2lf",R); but it's rounding off the value.How to get the desired output ? (preferably using printf)

    Read the article

  • how to find distinct digit set numbers over a range of integers?

    - by evil.coder
    Suppose i have a unsigned integer, call it low and one another call it high such that highlow. The problem is to find distinct digit set numbers over this range. For example, suppose low is 1 and high is 20 then the answer is 20, because all the numbers in this range are of distinct digit sets. If suppose low is 1 and high is 21, then the answer is 20, because 12 and 21 have same digit set i.e.1, 2. I am not looking for a bruteforce algo., if anyone has a better solution then a usual bruteforce approach, please tell..

    Read the article

  • Difference between these two namespaces in javascript

    - by Lol coder
    First off, all I'm trying to do is to structure my javascript code properly. I've been told I must not have anything global. So I took the 2 types of namespaces declaration from this answer and now asking you guys for the pros and cons of each. var namespace1 = new function () { var internalFunction = function () { }; this.publicFunction = function () { }; }; var namespace2 = { publicFunction: function () { } }; Also, how do i have a private function in the last one namespace2?

    Read the article

  • Incorrect sizing of a JPanel in a JScrollPane In Java 1.5

    - by Coder
    Hi, I am making an image loading component which consists of a JPanel containing a JScrollPane, which in turn contains another JPanel. What this component does is allows images to be dropped on top of it, after which point the image is loaded and the inner most JPanel is set to the size of the image dropped. This in turn causes the scroll bars to show up and the user can scroll the image. This all works fine. The problem comes in when i try to auto-shrink the image to the maximum visible area in the outer JPanel. In this case i do a uniform scale of the image to be less than or equal to the width and height of the outer JPanel. What happens now is that both the horizontal and vertical scroll bars show up indicating the the inner JPanel is bigger than the visible area (which should not be the case). I verified that the image is scale to the proper dimensions(ie. the maximum width and height is respected). I also verified that if i decrease the maximum height by 3 pixels, then no scroll bars appear. What i believe the problem is, is that panel.getWidth() and panel.getHeight() don't actually return the visible area (maximum area) that sub components can take up. Ie. there is likely some more width and height taken up by the border around the JPanel or something like that. My question is, how do i get around this problem. Functionally all i want is to determine the maximum size a JPanel can be in a JScrollPane, then set the panel to that size and paint an image over top of it and be assured that the scroll bars of the scroll pane will not show up. Right now the scroll bars are set to AS_NEEDED. Thanks!

    Read the article

  • Correct (pretty) window redraw during the creation

    - by Coder
    Does anyone know what is a correct way to redraw window during lengthy initialization operations? Say I have HWND with NULL brush, and it does some not so quick child window initialization (Window initialization is not so quick on Vista and 7, especially on netbooks, even with threaded app). With this config window stays black for half a second on slower laptops. But if I supply window color brush, it seems that there are some sort of child controls or something that draws black squares on top of it, which also seems ugly. Even though the controls are created without WS_VISIBLE initially. Oh, the window has the WS_EX_COMPOSITED style, which should do the double buffering to avoid flicker. But it still behaves ugly. Are there any other tricks I've forgotten, missed?

    Read the article

  • Netbeans 6.1 Incorrect CVS Status on a file that does not exist

    - by Coder
    Hi, I have been trying to figure this out for a few hours off and on now and can't figure it out. I committed a lot of binary (jar files) to cvs and they worked fine, but one of the 6 directories, netbeans thinks has a file that it keeps trying to commit, but it doesn't actually exist in the file system. There is also another file in the same directory that i did commit, and netbeans cvs status says that it's an unknown file, but when i delete the directory and check it out, it shows up fine, but netbeans can't get the correct cvs status for the file. I looked in the repository and all looks fine. There is only one file present as it should be. Looking at the CVS directory in the checkout folder also reveals nothing suspicious. I don't know what to do about this. I don't know why netbeans thinks there is a file in that directory that is not actually there. I did a search in my working directory and my netbeans project directory for any file containing a reference to this file but there is nothing.

    Read the article

  • Keypress event on inserted span (jQuery)

    - by Coder
    Hi, I've been researching for a long time, and haven't found a possible solution. The problem I have is that I'm trying to attach an event handler to an span element just inserted. So basically the problem is, when a user performs a particular action that I set (clicking a button by example) I call this function: function AppendSpan() { $('#mydiv').append('<span id="someid" contenteditable="true">Some TExt</span>'); //Then I want to handle the keypress event on the inserted span $('#someid').keypress(function(event){//Do something here}); } The problem is that the keypress event is never triggered on the inserted span, I tried with the click event and it works fine, but not the keypress or keydown,keyup events. I also tried with $('span').live("keypress",function(event){//Do something}); but didn't work. Any suggestions would be appreciated, I need this to work only in FF, so no support for IE required.

    Read the article

  • Is there a Javascript equivalent of .NET HttpWebRequest.ClientCertificates?

    - by Coder 42
    I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create("https://x.com/service"); request.Method = "GET"; // Add X509 certificate var bytes = Convert.FromBase64String(certBase64); var certificate = new X509Certificate2(bytes, password); request.ClientCertificates.Add(certificate, "password")); Is there any way to reproduce this request in Javascript? Third-party libraries would be fine for my purposes.

    Read the article

  • Having issue with OpenGL 1.0 for HP slate 7

    - by Roy Coder
    I have issue with HP slate when i am trying to draw Line in OpenGL Draw method. But working in other devices. In Hp Slate Green line not drawn properly as like in another device. My Code is: gl.glPushMatrix(); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertexFloatBuffer); gl.glColorMask(true, true, true, true); gl.glDepthMask(true); gl.glLineWidth(8.0f); setColor(gl); gl.glDrawArrays(GL10.GL_LINES, 0, fPoints.length / 2); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glPopMatrix(); Suggest me at which place i am wrong or missing something? UpdateImage

    Read the article

  • creating BeanInfo objects in NetBeans 6.1 does not work for some objects

    - by Coder
    I have recently learned about BeanInfo classes in Java, and have successfully used them to add icons to my custom GUI components which extend swing components such as JTextField, however i have a more specialized GUI component which extends from another one of my GUI components, which then extends from JTextField. Ie. the class hierarchy is of the form "A - B - JTextField". I can create a bean info object that works for class B, but when i click on the bean info editor option in netbeans to create a bean info object for class A, nothing happens. Ie. there is no error pop-up and a bean info object is not created. There isn't much difference between class A and B. Both A and B have default no argument constructors and they are very similar to each other. The only thing i can really think of is that A uses generics and B does not. I would like to create a beaninfo object for class A so that i can add custom icons for that component. Any help would be appreciated. Thanks.

    Read the article

  • SQL: Get count of rows returned from a left join

    - by Rogue Coder
    I have two tables, one called calendars and one called events. There can be multiple calendars, and multiple events in a calendar. I want to select every calendar, also getting the number of events in the calendar. Right now I have : SELECT C.*, COUNT(*) AS events FROM `calendars` AS C LEFT JOIN `events` E ON C.ID=E.calendar GROUP BY C.ID But that doesn't work. Items with no events still return 1. Any ideas?

    Read the article

  • New Comer to JS Looking for Guidance

    - by New Coder
    I'm fairly new to JavaScript. Can anyone share some good advice on getting started? I have a little experience in ActionScript 3 and have taken a few Java classes toward my CS degree but my background is of a designer transitioning into development. My goal is to become a well rounded front-end developer and I'd like to move beyond the simple slideshow animations and rollover effects. Any guidance/wisdom will be much appreciated!

    Read the article

  • Error CS0103: The name 'Class1' does not exist in the current context

    - by Mad coder.
    In my website I created a class e.g. Class1.cs in App_Code folder when I am trying to load default page which is using this Class file I am getting the following error CS0103: The name 'Class1' does not exist in the current context for the code String something = Class1.item1(text1.Text, text2.Text); and Class1.cs consists of protected static string item1(string a, string b) { //some action here return null; } Everything works fine in my VS2010 but when I host the website in my server I am getting this issue.

    Read the article

  • Converting OCaml to F#: F# equivelent of Pervasives at_exit

    - by Guy Coder
    I am converting the OCaml Format module to F# and tracked a problem back to a use of the OCaml Pervasives at_exit. val at_exit : (unit -> unit) -> unit Register the given function to be called at program termination time. The functions registered with at_exit will be called when the program executes exit, or terminates, either normally or because of an uncaught exception. The functions are called in "last in, first out" order: the function most recently added with at_exit is called first. In the process of conversion I commented out the line as the compiler did not flag it as being needed and I was not expecting an event in the code. I checked the FSharp.PowerPack.Compatibility.PervasivesModule for at_exit using VS Object Browser and found none. I did find how to run code "at_exit"? and How do I write an exit handler for an F# application? The OCaml line is at_exit print_flush with print_flush signature: val print_flush : (unit -> unit) Also in looking at the use of it during a debug session of the OCaml code, it looks like at_exit is called both at the end of initialization and at the end of each use of a call to the module. Any suggestions, hints on how to do this. This will be my first event in F#. EDIT Here is some of what I have learned about the Format module that should shed some light on the problem. The Format module is a library of functions for basic pretty printer commands of simple OCaml values such as int, bool, string. The format module has commands like print_string, but also some commands to say put the next line in a bounded box, think new set of left and right margins. So one could write: print_string "Hello" or open_box 0; print_string "<<"; open_box 0; print_string "p \/ q ==> r"; close_box(); print_string ">>"; close_box() The commands such as open_box and print_string are handled by a loop that interprets the commands and then decides wither to print on the current line or advance to the next line. The commands are held in a queue and there is a state record to hold mutable values such as left and right margin. The queue and state needs to be primed, which from debugging the test cases against working OCaml code appears to be done at the end of initialization of the module but before the first call is made to any function in the Format module. The queue and state is cleaned up and primed again for the next set of commands by the use of mechanisms for at_exit that recognize that the last matching frame for the initial call to the format modules has been removed thus triggering the call to at_exit which pushes out any remaining command in the queue and re-initializes the queue and state. So the sequencing of the calls to print_flush is critical and appears to be at more than what the OCaml documentation states.

    Read the article

  • Mix and match class in C++/MFC

    - by Coder
    I'm trying to re-factor a code base, and there is some common functionality among unrelated classes that I'd love to unite. I would like to add that functionality in common base class, but I'm not sure if it's clean and good approach. Say I have CMyWnd class and CMyDialogEx class, both different, so they cannot inherit from one base class. I want to add a button to both classes and add the message handlers to both classes as well. So I'd like to do something like this: CMyWnd : public CWnd, public COnOkBtnFunctionality, public COnCancelBtnFunctionality CMyDialogEx: public CWnd, public COnOkBtnFunctionality Where COnOkBtnFunctionality would define CButton m_buttonOk, and all the afx_msg functions it should have. And so on. Is this approach doable/good? Or are there better patterns I should resort to?

    Read the article

  • Was Visual Studio 2008 or 2010 written to use multi cores?

    - by Erx_VB.NExT.Coder
    basically i want to know if the visual studio IDE and/or compiler in 2010 was written to make use of a multi core environment (i understand we can target multi core environments in 08 and 10, but that is not my question). i am trying to decide on if i should get a higher clock dual core or a lower clock quad core, as i want to try and figure out which processor will give me the absolute best possible experience with Visual Studio 2010 (ide and background compiler). if they are running the most important section (background compiler and other ide tasks) in one core, then the core will get cut off quicker if running a quad core, esp if background compiler is the heaviest task, i would imagine this would b e difficult to seperate in more then one process, so even if it uses multi cores you might still be better off with going for a higher clock cpu if the majority of the processing is still bound to occur in one core (ie the most significant part of the VS environment). i am a vb programmer, they've made great performance improvements in beta 2, congrats, but i would love to be able to use VS seamlessly... anyone have any ideas? thanks, erx

    Read the article

  • Iframe not displaying content

    - by a coder
    This snippet was gathered from a random youtube video: <iframe class="youtube-player" src="http://www.youtube.com/embed/http://www.youtube.com/v/gnrvYsZWR1c?rel=0" title="YouTube video player" type="text/html" frameborder="0" height="390" width="480"></iframe> Again, a little easier to read: <iframe class="youtube-player" src="http://www.youtube.com/embed/http://www.youtube.com/v/gnrvYsZWR1c?rel=0" title="YouTube video player" type="text/html" frameborder="0" height="390" width="480" ></iframe> It is not displaying the embedded youtube in Firefox 15.0.1 on Windows or Linux. Is there a problem with how this snippet is constructed, or is Firefox simply not displaying iframe content?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >