instruction stringlengths 34 19.9k |
|---|
It's known 2-way Merge sort takes N*logN time.
I wonder, what would be the running time if we split an array of the size N into N subarrays and then do the same thing as we would do for 2-way Merge?
|
I have a web-application with an async HTTP backend, which gets called by the client by AJAX requests. The client has to start a job and then polls for the result.
I started with a simple 150ms polling interval, which was fine for small jobs, but big jobs, which could take several minutes, threw many failed requests to... |
I want to build a website that will contain a lot of images. I don't want users who visit the website to be able to save the images.
I have blocked the right click option, but is there any other way to keep users from saving the images?
|
Here's the scenario...
I have a web site that has a generic handler written in asp.net (.ashx file) that accepts http requests, gets relevant data, converts the result into xml and then passes that back via the response.
This will eventually be used so that a windows application can make data requests to this web site.... |
My web application will use AJAX calls often and so I have set up some JavaScript to handle "messages" or "responses". These responses are returned (from my ASP.NET application) as JSON objects that act as feedback once a function is complete.
Suppose my responses have three basic elements.
Type (error, warning, info,... |
I've met the criterion of good system desing as its stability relative to requirements change.
Small req. changes should raise small changes in design.
Yet I have gut feeling that almost for any somewhat complex software system it's possible to state the set of small changes in requirements which causes unacceptable am... |
Background
I have this tables
+-------------------------+ +------------------------+
|Airport | |Country |
|-------------------------| |------------------------|
|airport_code string (PK) | |country_code string (PK)|
|address string | |name string |
|name str... |
When a program doesn't compile, error messages are sometimes esoteric. Often a simple Google search leading to a site like stack exchange solves the problem. Now why can't we automate this?
How about a Siri for coding? By Siri, I mean an intelligent personal assistant. Not talking about speech recognition here.
I wond... |
I'm facing a choice of whether to start building Haskell components for a certain production app that is all done in Ruby.
I'm leaning toward Haskell for several reasons, primarily speed (compiled Haskell is like 4-8x faster), greater transparency (via Haskell type system), and safer refactorability (type system). I'v... |
I'm programming a windows phone 7 app which needs authentication for news-like read access.
I use Application.UnhandledException to handle (my) AuthFailedException, which can be thrown from any page, and navigate to a login page.
To mimic a modal dialog, I do the following:
I attach a BackKeyPress event handler to cl... |
I have a (browser based) web application. On each page, I want to have a little label and link in a corner that displays the user's username and other account information along with a logout button. The information that will be displayed is immutable.
Should I store that account information in session attributes when a... |
If you have to pay the price of performance to make code more readable would you prefer that or you would always prefer performance over it?
|
We are about 40 developers working on the same code base and we use Git for version control.
My question is: can there be problems if, for example, some developers have a much older version of Git installed on their system ? Or should we try to enforce some rule that says something like "you should upgrade Git on your ... |
Hypothetical scenario: codebase is exercised by unit tests run by a TeamCity build-bot, that also uses the built-in dotCover tool to provide coverage metrics. The build will fail if less than X% of the code is covered.
Unscrupulous developer running NCrunch (or a pre-tested commit in TC) sees that his next checkin will... |
I was asked about how to run a suite of 65.000.000.000 tests and I wonder if it is normal to have a project with such a huge amount of tests.
Have you worked in projects with this characteristic?
|
Mention the pros and cons of UIBinder in GWT.
I want to develop a big project. Is it flexible to use UIBinder for my project?
|
I am designing an application that interacts with a RESTful API.
When returning error messages like Unable to sign up user
Should the error message be generated by the app? or by the API? I am looking for best practices.
|
I have multiple functions and a lot of code inside $(document).ready(function()). I am using jasmine to test the functions inside the ready function as well as the code inside ready() but when the test cases inside describe are executed it is not able to access the code inside the ready function.
$(document).ready(func... |
Often in a table that has no natural key, it is still useful for users to be able to have a uniquely generated identifier. If the table has a surrogate primary key (and in such a case you would certainly expect it to) should that key be exposed to the user or should another field be used for that purpose?
One reason n... |
Here's a *hypothetical* issue.
There is a performance issue in the current release. Its difficult to find the cause of this issue because the performance tests haven't been run in roughly 10+ releases (with anywhere from 10 - 100 changes per release). My idea is to automate the process of running the performance te... |
I was asked this question in an interview. For eg: UITableviewDelegate protocol has CellForRowAtIndexpath. Why make it a delegate method in a protocol not a method in the UITableView class and call it directly?
|
I'm currently examining the possibilities and implications of linking against a GPL library for an application in a commercial context.
From what I've understood of the GPL, as long as the application is used internally there is no obligation to release its code (even if a copy is moved to a controlled subsidiary).
Wha... |
Someone asked me this. The answer he gave was HTML5 in UIWebView can cache the app data so it can run offline. I thought the same thing can be achieved using safari add to home screen, no?
|
Given a file > 5Gb, simply with lines like Apache's access.log.
I need to get number of lines.
Any constructions like
file(filename).read().counter('\n')
would read all of the file and it would take a very long time.
On the other hand, e.g.
os.stat(filename).st_size
works very fast.
It is possible to get at least an ... |
I am working on creating a new data processing system, where there are multiple steps each fulfilled by different services. For example, there is a scheduling service that kicks of something, an analysis service that does the processing, and a notification service that summarizes and emails out results. Data flows thro... |
Consider the following scenario:
I am writing a Dispatcher Servlet that delegates processing to various handlers depending on the request URL; the handler objects having previously registered themselves for URL patterns, pretty much as Servlets register themselves in web.xml.
When a Handler registers or unregisters its... |
Applications and operating systems have a ton of windows and controls, sub windows and sub controls. I've noticed its common to have sub controls have their coordinate systems reset to start at 0 making drawing much easier. However I'm not sure how that is done and how I'd be able to do that.
I'm going to be creating a... |
About a year or so ago, I forked a project licensed under Apache 2.0 and made extensive changes and additions to the code, a good portion of which I contributed back freely to the community.
Recently, the code moderator changed the licensing to LGPLv3, and I wanted to find out if I was correct in my belief that this l... |
I am working on a C# console application that loads the data from a third party and bulk inserts into tables. Basically the code consists of a static method with logging statements. In these scenarios, how does one write the unit test cases?
Example code
void Main(string[] args)
{
// for loop here to read config fr... |
Mushroom cultivation requires fairly precise chemical composition of substrate (a.k.a. growing medium). Let's pretend we're growing shitakes and that this is the required composition of their substrate:
Nitrogen | Benzene | Toluene | Dioxygen Diflouride
5% | 5% | 10% | 80%
We want to create an appropria... |
There seems to be divided opinion on this subject, and I wanted to get people's insights on whether they've found using underscore prefixes and suffixes to be helpful with coding or not.
You know, code like this:
class MyClass
{
private int _someInteger; // some advocate local vars prefixed with underscore
privat... |
I have a class that will end up having more than ~30 methods. They all make sense to be part of the same class because they require access to the same data.
However, does it make any sense to split up a large class into several smaller abstract classes (by functionality, type, use, etc.) and have the main class extend ... |
As far as I know, Apache Solr Lucene project is a web-app which is used for rich text searching.
I just wanted to know:
Why can't I use MySQL for that and just for rich text searching, why we use Solr?
When all the other things can be performed using any DB ?
|
I am an objective-c/iOS apps developer and I was wondering if I perform Unit Tests on my code, how should I go about it?
What is unit test anyway? Ain't I testing a specific part of code while running the whole app itself?
What is its use?
I have read few articles, wikipedia etc. but I am not sure whether unit testing ... |
I have three questions about REST API design that I'm hoping someone can shed some light on. I've searched relentlessly for many hours but haven't found answers to my questions anywhere (maybe I just don't know what to search for?).
Question 1
My first question has to do with actions/RPC. I've been developing a REST AP... |
Where I work we recently switched the Agile development using Scrum. We went through the typical growing pains but have reached an approach that seems to work for now (whether it'll work in the long term is for another question!).
Obviously, the department management is happy the transition to Scrum is working. But t... |
I was going through the analysis of quicksort in Sedgewick's Algorithms book. He creates the following recurrence relation for number of compares in quicksort while sorting an array of N distinct items.
I am having a tough time understanding this... I know it takes 1/N probability for any element to become the pivot ... |
The concept
I'm programming an interface over pygame as a personal project, to make the creation of games easier for me.
So far I managed to design an architecture that behaves like this :
Objects are displayable components that can appear and move on the screen
Objects can have children objects
When an object display... |
Are there some best practices on the repository front, or some common newcomer-traps that I should avoid?
I have recently been reading about the benefits of repositories even for single-developer projects and, in addition, I am likely to start working with multiple other engineers in a short while but, how do I go from... |
From Real World OCaml (beta):
OCaml distinguishes between non-recursive definitions (using let) and
recursive definitions (using let rec) largely for technical reasons:
the type-inference algorithm needs to know when a set of function
definitions are mutually recursive, and for reasons that don't apply
to a pu... |
Would something like This program uses code written by Nathan2055 satisfy the requirements for the BSD license, or do I need to copy out the whole notice? I know it asks that the notice is kept intact, but if I'm only using one file of code it's a waste to have to copy the entire license into the main copyright file.
|
While getting my code reviewed here the issue of using the const keyword came up. I understand that it is used for implementing read-only behaviour on variables.
I am confused about what are the various situations when it can be useful.
Should it be used for the sake of clarity in function prototypes?
Should it be use... |
I have been working for a long time with PHP, and tried to be as good as possible on it (good coding practices, knowing how every request is handled from the start to the end, etc.), but now, for job reasons I have to start learning ASP.NET and C#.
I've read and tried to understand it's foundations, as ASP.NET is alway... |
Background
The "all-PK-must-be-surrogates" approach is not present in Codd's Relational Model or any SQL Standard (ANSI, ISO or other).
Canonical books seems to elude this restrictions too.
Oracle's own data dictionary scheme uses natural keys in some tables and surrogate keys in other tables. I mention this because th... |
We currently have 5 scrum teams that work off their own product backlog for the past year.
Each team works on their own dedicated system but underlying technology is the same .Net.
There has been a lot of discussion on moving to feature based teams working off a single backlog. The reason is one of our main systems ha... |
A basic calculator can perform a wide variety of operations. How does the claculator 'get' the concept of adding two numbers in the same way a human does? I dont think people that make claculators store every possible result of every possible addition on the chip before shipping it. Soemhow the chip needs to 'learn' ho... |
I need to write a server application that fetches mails from different mail servers/mailboxes and then needs to process/analyze these mails.
Traditionally, I would do this multi-threaded, launching a thread for fetching mails (or maybe one per mailbox) and then process the mails.
We are moving more and more to servers... |
I'm in the middle of a redesign on the part of my current project that deals with user permissions and authorization. I have an interface named IUserPermissions that encapsulates this information.
One part of a user's permissions are the Roles which they are a member of. I'm trying not to violate the Open/Closed Princi... |
Preface: My question does not exclusively pertain to Google and it doesn't exclusively pertain to iOS. I'm only using Google and iOS as examples because they are familiar to many. I could have just as easily used 'Company X', apps 'A', 'B', 'C', 'D', and 'E', and 'Android', but I wanted to keep my question rooted in th... |
A common operation in JavaScript is to replace an object method with a new one while still calling the original method. This is often done like this:
var originalMethod = obj.method;
obj.method = function(arg) {
// call original method
originalMethod.call(this, arg);
// do my stuff new stuff
}
I'd like to ... |
I was working with a query I wrote today had to change the code from the WHERE clause to use a IN(list of stuff) filter instead of using something like
item_desc = 'item 1'
OR item_desc = 'item 2'
OR item_desc = 'item 3'
OR item_desc = 'item 4'
The above ran for 15 minutes and returned nothing, yet the following gave ... |
This construction is considered wrong
unless
#..
else
#..
end
This is for the general reason of double-negative confusions. It translates to:
if not
#..
if not not
#..
end
We all agree this is confusing.
Is there any situation (include semantic) that the unless..else construction would be more appropriate?... |
This one's all over our codebase but I'm not sure I've ever heard a name put to it.
We have C# and Java (and Rails but we don't have to touch it very often) so I'll speak more generally. It's like the data concerns never get fully established until you're literally right in a view controller preparing to drop it on the... |
I need to do some text processing tasks with short XML fragments.
The section "details" shows an example... My solution is to use a tokenizer based on regular expresions, but it is not elegant and not uses any build-in function. The candidate build-in functions (that others indicates to me) are strtok and SimpleXML.
S... |
I have commit access on an open source project named Foo hosted on GitHub (there are many other committers if that is relevant). I would like to make a change via pull request so that someone else reviews it before it gets committed to the master branch of the Foo codebase.
To make this pull request, I can either make... |
I am working on a tool (Python, may or may not be important) that will allow a user to maintain a configuration file containing arbitrary shell and/or language code to be executed on particular events and intervals. The code will potentially involve multiple statements.
I understand there are potential behavioral and s... |
I am developing a project in C# and due to a design decision it is not possible to have a static class inherit another static class. But I have, in my opinion, a case where this would make sense.
I have a music player which is able to play music from many different music sources: local files, YouTube, SoundCloud, Jamen... |
Background
One of the advantages of decoupled components in systems is that you can extend the system without having to touch the existing code.
Sometimes you don't even have to recompile the old code because you can dynamically load classes from disk like this:
clazz = Demo.class.getClassLoader().loadClass("full.packa... |
I was curious, why do we prefer byte[] array to transfer data over the network and not anything else?
Or if I am missing anything, what are the other ways to transfer the data over a network.
|
Why Redis for queuing?
I'm under the impression that Redis can make a good candidate for implementing a queueing system. Up until this point we've been using our MySQL database with polling, or RabbitMQ. With RabbitMQ we've had many problems - the client libraries are very poor and buggy and we'd like not to invest too... |
We have a generic parameter table whose important attributes are :
id number auto increment not null
domain varchar (200) not null
classification varchar (200) not null
param_name varchar (200) not null
value CLOB/text
created_by, created_date, updated etc
Here the id is unique for the table plus at the functional lev... |
I am very new to continuous integration, but I decided to give it a shot. Unfortunately I found there to be huge quantities of different tools, and each one is sizable and seems to be difficult (I am new so of course it intimidates me).
What I am looking for however is a tool that can
run my junit tests
execute my bui... |
I've been tasked to correct some issues on the backend of a large website project that has been outsourced for some time. The original developers and us are not on good terms so it's not feasible to get them involved.
The technology stack is as follows:
MySQL 5.x
PHP 5.3 (and a variety of supporting libraries)
Apache... |
I'm trying to provide a by-reference getter to a list of objects in a class. My setup looks something roughly like this:
class c_Container
{
public:
c_Item* Get(int uid);
private:
c_Item itemList[10];
}
class c_Item
{
public:
int uid;
}
c_Item* c_Container::Get(int uid)
{
for (int i = 0; i < 10; i++)
... |
Suppose I have a function that I need to call a lot, maybe a few thousand times on every mouse down or mouse move. It uses an instance of a function (class), called Transform:
function func1(a, b, c) {
var t = new Transform();
t.rotate(a);
t.scale(b, c);
return t.m[0];
}
So I'm creating thousands of new transf... |
It was suggested on my Stack Overflow question that this might be better suited to this site, so I'm cross-posting it.
I'm working on my first ground-up build of an MVC site. I have a collection of views, a collection of models, and I've tested most of my views and fixed the obvious bugs.
The last step I need to do is ... |
Let's suppose I have a code file that reads (I'll use Java-ish syntax) and it is being interpreted. Kind of like a ruby script.
class A{
int fieldName = 4;
A(){...}
void doSomething(){...}
}
A instanceOfA = new A();
A.fieldName = 7;
This is what I understand to happen when this file is interpreted.
Fil... |
I have a problem I am developing a solution for and currently I solve it with a brute force solution that checks all possibilities. It works for small numbers of bins but I'd like to work with a reasonable speed for increasing numbers, however the algorithm I use (brute force) increases in computing time in a factorial... |
I picked up some Project Euler questions today and decided to find more effective ways to Answer the questions l had already answered.
So on the question about finding the sum of the even Fibonacci terms up to 4 million; I noticed that if we had a separate sequence for the even Fibonacci terms (starting with 0 & 2 as ... |
I am working on a set implementation in JavaScript currently. This should kind of simulate generics as known from Java or C#. I need a mutable version of that (allows for adding/removing set values) and an immutable one.
My constructor signature looks like this:
new GenericSet( 'number', [ 10, 20, 30 ] );
,
// mutabl... |
In my team, we are about to start the reimplement of a service. One of the important steps to do to accomplish this is how do we ensure that we are doing it in the right way and we are not introducing new bugs.
So, what we have in mind is create a bunch of test to verify the following:
The behavior. Both services sho... |
I'm starting to introduce myself in CQRS concepts, but I get stucked with the following situation:
Supouse you have an entity that must have an unique name. In order to verify that, prior to create the entity you must make a query, thus you are verifing against the query subsystem.
But what happens if the syncronizati... |
Problem
I was just trying to debug a set of file-manipulation routines I wrote for a program I am working on. One of them kept returning an INVALID_HANDLE error.
Explanation
I figured out what the problem was. It turns out that because I provided several overloads so that I could call the function with either a file ha... |
There is something not clear for me and this is how to prevent other people read my code. The thing is that I want people create their own branches but not to view the other's branches. If someone is responsible for networking, I don't want this guy to view graphics codes. S/He must be forced to work on his branch only... |
This is not strictly related to C++ but its type system serves to illustrate the problem well.
Assume:
We have a generic template Container<T> (such as a std::vector<T>) which stores an unspecified number of elements of the same type T on the heap. Each element is allocated and deallocated via the constructor and des... |
On wikipedia it says that GDI is an API and core operating system component responsible for representing graphical objects and transmitting them to output devices.
I'm not finding much on what GDI+ actually does so I'm wondering, is GDI+ replaceable with gui frameworks like wxWidgets and GTK+ or are those frameworks ra... |
As a software engineer, we are always eager to get effective tools to boost our productivity.
And in our daily work, we are often unsatisfactory with the existing tools and would like to have better ways such as better GDB script config, Vim script and some Python script to make boring things automatic.
However, it is ... |
I have two tree data-structures that I made in C++ , and they give a response for range queries/point queries in that program. I am using Ubuntu. I need help in understanding the way to compare the performance of these two data structures (for answering the query in that program) in external memory. How can I do this?
... |
I'm writing a small C++ class, Block, to transform serialized data into a memory structure, and supply the structured data to callers through several accessor methods. I've tried to keep its scope specific and limited. The users of the class are very low-level - they, too, are very narrow in their focus and have as f... |
After learning the basics of computing simple die throwing games and calendar applications, I want to explore simple graphics - drawing and moving around geometric objects is ok to start with, eventually adding pixel graphic of course.
I've taken an introductory Java course but would rather do it in C++, Python or a co... |
Much has been said lately of continuous delivery. It does sound appealing, but runs against the grain of convention wisdom in big corporations.
Jez Humble - Continuous Delivery
Thoughtworks Presentation - Continuous Delivery - Part 1
Thoughtworks Presentation - Continuous Delivery - Part 2
Assuming the following:
Y... |
We were migrating from Java 6 to Java 7. The project is behind schedule and risks being dropped, in which case it will continue to use Java 6.
What are the specific improvements in Java 7 that we could go back to our manager with and convince him it is important to use JDK 7? Looking for bug fixes that I could highli... |
My team has about 18 members and the code is generally good, using TDD and good specifications makes for working code. But I think they abuse comments in favor of writing cleaner, more readable code.
I would like to introduce them to the concept and I'm wondering how can I do that on a larger scale without sitting with... |
When it is necessary to integrate with a web application, and an API is unavailable, is it a viable solution to simulate a web browser interacting with the web application as a real user would interact with it?
UPDATE
Some context.
Web App belongs to a vendor/partner. Their timeline for building a proper API will not m... |
I have just completed my Bachelors degree in IT field. I have deep interest in coding and really want to be a professional in it. Now, apart from college courses, I have been learning programming(C#) on my own (college level programming is too basic). Now I feel I need a little more time to be close to professional pro... |
I'm trying to come up with a sane architecture to delay a task for 24 hours. So far I've thought of:
unix cron job, but this will not be able to take the load we give it, since we will have many thousands of delayed tasks per day
Use RabbitMQ with dead letter exchange, however, this is a hack and being a hack is ridd... |
I jumped in to a project and I see that the other developers are adding a lot of logic in the setters of synthesized properties.
I understand how this works, but I think that it makes it hard to understand the flow of the program; while reading the code, whenever I see self.something = whatever, I always check if somet... |
I'm creating a simple game development framework with Ruby.
There is a node system. A node is a game entity, and it has position. It can have children nodes (and one parent node). Children are always drawn relatively to their parent.
Nodes have a @position field. Anyone can modify it. When such position is modified, th... |
It is usual for me, when doing web development, to copy attributes from my model classes to the other class that will be sent to the client. Usually, with a class that accepts a model and extracts the necessary information this is sufficient (something like a adapter I suppose), but sometimes it is not that easy.
In so... |
At the end of the answer to "Can I do ++x and x++ in Python?" on this page: http://norvig.com/python-iaq.html, you can read:
[...] I'm with my fellow Dane, Bjarne Stroustrup, on this one. He said in The Design and Evolution of C++ ``If I were to design a language from scratch, I would follow the Algol68 path and make ... |
Background
To start off, at work I work with a legacy system that, in its day, was quite spectacular, but now is ...interesting... to work with. It uses IBM (now Rocket) UniVerse as its backing database. One particular part of it that has caused some issues is its lack of data-integrity checks. By data integrity, I don... |
JVM supports so many languages other than Java like Groovy,Clojure,Scala etc which are functional languages unlike Java(I am referring to Java before Version 8 where Lambda's are not supported) that doesn't support functional capabilities.On a high level what makes the JVM so versatile that it can support both Object O... |
If I already have integration test for my program, and they all passed, then I have a good feel that it will work. Then what are the reasons to write/add unit tests? Since I already have to write integration tests anyway, I will like to only write unit test for parts that not covered by integration tests.
What I know t... |
I developed an intranet (local network) ASP.NET web project for my co-workers.
In the development process I used Chrome and Firefox and didn't test much with Internet Explorer.
The website works well with Firefox and Chrome and with IE it had major bugs.
Is it legitimate to ask the users to use Chrome or Firefox?
They ... |
I've attempted test first in Ruby on Rails using Test Unit and RSpec.
I'm wondering how to do test first in situations that are more closely tied to the OS/filesystem.
Problem: Building a USB stick of MP4 files.
Inputs:
List of mp4 file name, destination directory pairs.
List of source directories
List of destination ... |
Code Reuse as a Problem
I was thinking about this question on software delivery, and I kept coming back to the issue of repeatability and / or reproducibility. They matter, because if you don’t repeat a project then it becomes more difficult to improve the process you used to build the project. Engineering involves c... |
One year ago, I discovered the WPF technology and I developed a little application, as first experiment, to compare the content of two different directories. The content of each directory is shown in a different DataGrid.
At that time, I didn't develop the application using MVVM pattern, because it was only an experim... |
We need to define our requirements for a REST API. What are tools which aid in creating a document which will fully describe the webservice so it can be created by another entity?
|
I currently have a set of components named DataValues, ValueParsers, ValueFormatters and ValueValidators. The first one defines an abstract base class DataValue and contains a whole load of implementations. The 3 other components each define in interface similar to their name (minus the "s"), and also contain a bunch o... |
I heard the terms "application-level testing" and "system-level testing". I think I know the difference, but I am not sure. I tried to do some research on the internet, but the closest explanation of the difference that I can find is this http://en.wikipedia.org/wiki/Software_testing#Unit_testing (unit testing and syst... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.