Search Results

Search found 28877 results on 1156 pages for 'do good'.

Page 52/1156 | < Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >

  • Coming Up with a Good Algorithm for a Simple Idea

    - by mkoryak
    I need to come up with an algorithm that does the following: Lets say you have an array of positive numbers (e.g. [1,3,7,0,0,9]) and you know beforehand their sum is 20. You want to abstract some average amount from each number such that the new sum would be less by 7. To do so, you must follow these rules: you can only subtract integers the resulting array must not have any negative values you can not make any changes to the indices of the buckets. The more uniformly the subtraction is distributed over the array the better. Here is my attempt at an algorithm in JavaScript + underscore (which will probably make it n^2): function distributeSubtraction(array, goal){ var sum = _.reduce(arr, function(x, y) { return x + y; }, 0); if(goal < sum){ while(goal < sum && goal > 0){ var less = ~~(goal / _.filter(arr, _.identity).length); //length of array without 0s arr = _.map(arr, function(val){ if(less > 0){ return (less < val) ? val - less : val; //not ideal, im skipping some! } else { if(goal > 0){ //again not ideal. giving preference to start of array if(val > 0) { goal--; return val - 1; } } else { return val; } } }); if(goal > 0){ var newSum = _.reduce(arr, function(x, y) { return x + y; }, 0); goal -= sum - newSum; sum = newSum; } else { return arr; } } } else if(goal == sum) { return _.map(arr, function(){ return 0; }); } else { return arr; } } var goal = 7; var arr = [1,3,7,0,0,9]; var newArray = distributeSubtraction(arr, goal); //returned: [0, 1, 5, 0, 0, 7]; Well, that works but there must be a better way! I imagine the run time of this thing will be terrible with bigger arrays and bigger numbers. edit: I want to clarify that this question is purely academic. Think of it like an interview question where you whiteboard something and the interviewer asks you how your algorithm would behave on a different type of a dataset.

    Read the article

  • UIView frame origin doesn't set good

    - by Infinity
    Hi guys! Here is my code: frame = _pageContentView.frame; NSLog(@"%f; %f; %f; %f;", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); frame.size.height = pageContentView.frame.size.height; NSLog(@"%f; %f; %f; %f;", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); _pageContentView.frame = frame; NSLog(@"%f; %f; %f; %f;", _pageContentView.frame.origin.x, _pageContentView.frame.origin.y, _pageContentView.frame.size.width, _pageContentView.frame.size.height); And the NSLog outputs these values: 0.000000; 0.000000; 317.648956; 0.000000; 0.000000; 0.000000; 317.648956; 768.000000; 0.000007; 0.000004; 317.648956; 768.000000; Can you see? In the last row the x and y coordinates are a bit crazy... Where do these number come frome? What's the problem here?

    Read the article

  • Is AsParallel() good practice in a web environment?

    - by Bjorn Bailleul
    I have no doubt that for client applications, AsParallel() will bring some out-of-the-box performance gains. But what if I would use it in a web environment. Let's say I have a widget framework that loops over all widgets to get their data and render output. This would parallelize great no? I do have my doubts on using AsParallel() in this scenario. What if I have a large number of visitors for my site, isn't IIS going to use multiple threads to handle all requests? Aren't there going to be locking issues presented after a while, or threads dying because all processors are in use? It's just a thought, what do you think about this?

    Read the article

  • Good P2P Flash video conferencing package

    - by Justin Alexander
    Looking for a flash p2p (RTMFP) packaged solution, that includes the following features Time limited sessions: at confrence start, there is a set time limit, when this expires the session ends. Session extension: Sessions can be extended, but require authorization from the server via some sort of REST or Ajaxy response. Generally customizable theme Any suggestions?

    Read the article

  • Any good source of explanatory documentation on ColorMatrix?

    - by mackenir
    I'd like to try using ColorMatrix, but am only able to find examples that convert an image to grayscale. And even then, they tend to be presented as a chunk of 'magic numbers' code with no explanation. Does anyone know of a 'tutorial' on how to use ColorMatrix? For example I'd be interested in converting a grayscale image to a color image, where white == transparent, and black = a solid color, with gray pixels somewhere in between. Could ColorMatrix do that?

    Read the article

  • What is model driven development good for?

    - by happyappa
    Microsoft, of Cairo fame, is working on Oslo, a new modeling platform. Bob Muglia, Senior Vice President of Microsoft Server & Tools Business, states that the benefits of modeling have always been clear. In simple, practical terms, what are the clear benefits that Oslo bestows upon its users?

    Read the article

  • Gtk+ Tables for Layout - Good or Bad?

    - by wag2639
    Hi, I'm just starting to play around with GTK+ and I wanted to stop bad habits before they happen. I see that GTK+ seems to be a little based in HTML/CSS and I was wondering if there are any reasons to avoid using tables for layout.

    Read the article

  • Any good tutorials on using OAuth with Piston?

    - by Hank Gay
    I've looked at the relevant section of the Piston documentation, but it only seems to focus on how to turn it on, not what it would look like for clients or how to test it to verify it's working. The example only seems to use HTTP Basic and curl. Finally, Ned Batchelder's question makes it look like a tutorial is in order. Thanks.

    Read the article

  • What's a good Lua IDE for linux?

    - by Brendan Abel
    I'm looking for a lua IDE on linux. The majority of suggestions I've seen so far are windows only. I would have liked to use one of the Eclipse plugins for lua, but both of them -- LuaEclipse and LunarEclipse -- haven't been updated in nearly two years, and don't seem to work with Eclipse 3.5. If you have had any luck in getting lua working in Eclipse, I would be very interested.

    Read the article

  • does anyone know of good delphi docking components?

    - by X-Ray
    we'd like to add movable panels to an application. presently we've used DevExpress docking library but have found them to be disappointingly quirky & difficult to work with. it also has some limitations that aren't so great. auto-hide, pinning, and moving of pages by drag-and-drop are all features we'd like to use. the built-in delphi docking doesn't seem to be full-featured enough to do the things we need (also see sample below). perhaps i should dig deeper into delphi's docking abilities...my initial impression is that they seem very toolbar-oriented rather than something i can drop a frame into. i'm not experienced at docking topics. my only experience has been with the DevExpress docking library where i needed to programmatically create & dock panels. is it my imagination or are DevExpress's products unduly difficult to use/learn? the DevExpress Ribbon Bar component compared to the d2009 Ribbon Bar was certainly a useful experience. i will migrate to the d2009 Ribbon Bar as soon as convenient to do so. it was refreshingly straight-forward to learn and use. a sharp contrast compared to the DevExpress equivalent. if it takes 4x as longer to make it using the DevExpress equivalent, it's time to change direction. what would you suggest in regard to the docking library? thank you for your suggestions/comments!

    Read the article

  • What are some good design patterns for CRUD?

    - by Extrakun
    I am working with a number of data entities which can be created, read, updated and deleted, and I find myself writing more or less the same code for them. For example, I need to sometimes output data as JSON, and sometimes in a table format. I am finding myself writing 2 different types of view to export the data to. Also, the creation of those entities within DB usually differs just by the SQL statements and the input parameters. I am thinking of creating a strategy pattern to represent different 'contexts'. For example, the read() method of an AJAX context will be to return the data as JSON. However, I wonder if others have deal with this problem beforehand and will like to know what design patterns are usually use for CRUD operations.

    Read the article

  • Is there a good way of automatically generating javascript client code from server side python

    - by tat.wright
    I basically want to be able to: Write a few functions in python (with the minimum amount of extra meta data) Turn these functions into a web service (with the minimum of effort / boiler plate) Automatically generate some javascript functions / objects for rpc (this should prevent me from doing as many stupid things as possible like mistyping method names, forgetting the names of methods, passing the wrong number of arguments) Example python: def hello_world(): return "Hello world" javascript: ... <!-- This file is automatically generated (either dynamically or statically) --> <script src="http://myurl.com/webservice/client_side_javascript"> </script> ... <script> $('#button').click(function () { hello_world(function (data){ $('#label').text(data))) } </script> A bit of research has shown me some approaches that come close to this: Automatic generation of json-rpc services from functions with a little boiler plate code in python and then using jquery and json to do the calls (still easy to make mistakes with method names - still need to be aware of urls when calling, very irritating to write these calls yourself in the firebug shell) Using a library like soaplib to generate wsdl from python (by adding copious type information). And then somehow convert this into javascript (not sure if there is even a library to do this) But are there any approaches closer to what I want?

    Read the article

  • Looking for a good dev environment for OSGi bundles

    - by Riduidel
    Hi, I'm currently investigating in the field of dev environment for OSGi bundles. My goal is to find a way to develop, test and debug with ease the bundles I'll be coding. Besides, I have some "cultural" requirements. I want to be able to use java continuous integration servers (typically, Hudson) As a consequence of that first requirement, I want to have a repeatable, one-click build process. My typical tool for that is maven. And finally, being long-term Eclipse user, and having the m2eclipse at hand to merge my eclipse env with my maven one, I obviously want to be able to test and debug with that IDE. So far, here are the infos I know I can use (and have already tested) maven-bundle-plugin, maven-ipojo-plugin which both offer clean packaging facilities I have tested maven pax (and eclipse pax) and am not really satisfied with both : maven pax generates a very heavy project, where adding dependencies is very error-prone (the maven pax:import-bundle command line, with all its arguments, is a hell per se) I have taken a look at Karaf, which seems to have some nice direct maven provisionning, but I don't know how to integrate it with my Eclipse, besides using the traditionnal JPDA bridge. However, it seems to be more production-oriented than dev-oriented, and as such may require heavy configuration to fit my need (although the reading of its user manual doesn't revedal that). Have you got any ideas ? Some maven/eclipse plugins ?

    Read the article

  • Anyone knows of a good addressbook implementation?

    - by Tsahi Levent-Levi
    I am looking to add an address book to one of my programs. For that purpose, I want to have something that is flexible and customizable to the point of allowing me to hook up additional metadata to contacts in it from third parties. I don't mind paying for a solution as long as I get something that is usable for me. My requirements: Optimized to run on embedded devices Preferably in source code form Ability to add my own fields to contacts over those the address book provides out of the box Ability to plugin "stuff" to it to enhance it without changing its base code too much Has a C or C++ interface

    Read the article

  • Good practices for intialising properties ?

    - by Rubans
    HI, I have a class property that is a list of strings, List. Sometimes this property is null or if it has been set but the list is empty then count is 0. However elsewhere in my code I need to check whether this property is set, so currently my code check whether it's null and count is 0 which seems messy. if(objectA.folders is null) { if(objectA.folders.count == 0) { // do something } } Any recommendation on how this should be handled? Maybe I should always initialise the property so that it's never null? Appolgies if this is a silly question.

    Read the article

  • Good-looking Java Swing Look&Feel?

    - by eric
    I'm working on an open-source Java Web Start application, and I'd like to give it a consistent theme across platforms. Metal is totally ugly, and I'm not particularly happy with Substance (esp. performance). What are the best Swing Look&Feel options out there today?

    Read the article

  • TortoiseSVN : Good 'patch file' viewer ?

    - by mishal153
    Hi, The default patch file viewer is messy (ie. no side by side diff view etc). I tried setting the path of beyondCompare exe in "Settings-Unified Diff Viewer-custom", but beyond compare also behaves same as default diff tool. Is there a way to atleast allow side by side diff in patch files ? If so, what is the method ? My aim is to allow emailing of changes so that they can be reviewed before I commit them :) Mishal

    Read the article

  • Reference for good Android UI design patterns.

    - by sat
    Hi, I would like to get some links for getting started with design patterns.My requirement is , (at Initial stage) How to go about developing a particular pattern , say customized ListView which can be shared across applications . e.g. Applications will call something like drawCustomizedListView(params...) and my code will draw the listview according to the parameters supplied. This is particularly useful when across the applications I have to draw customized views. My intention is, I should not repeat the same code everywhere for doing similar task. Any references for the above requirement ?

    Read the article

  • a good smart phone for java development?

    - by pstanton
    Hi all, I'd like to do some development of smart phone apps and my native programming language is java. The first application I'd like to write will need to be able to (attempt to) connect to a network (LAN or WiFi) automatically in the background (on a schedule). would an android phone be the best path or are there competitive purer java options?

    Read the article

  • How to develop good debugging skills? [closed]

    - by Sasha
    Possible Duplicate: Debugging techniques How can I improve my debugging skills? I am thinking in the context of C++ under UNIX, C#, and in general. Please suggest how I can improve in these areas in terms of: Approaches to take, where to start, and how to proceed. Tools to use, and how use them effectively. Recommended material (books, articles) to read and lectures to watch.

    Read the article

< Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >