instruction
stringlengths
34
19.9k
I'm in the making of a tournament for archery but i'm stuck because they want a specific match-matching for players. There is the usual 1-32,2-31,3-30 etc but the way they want the tree is a specific one. For now i'm producing the array with this $players = range(1, $range); $count = count($players); for ($i = 0; $i < ...
If a component “A” is under MIT License ,but it contains some GPL files, according to GPL the whole code should be GPL. But the component is released under MIT. Is it possible? If yes/no, on what scenarios can it happen or can get complied Example i have Jar files contains few files which has GPL license but still jar ...
I have a class System, which uses a bunch of other classes, to achieve some complex signal processing. In debugging System, one needs to observe the output signal for patterns. This is not achievable by a debugger, because of the large number of samples going through. However, if certain parts of System can be isolated...
I have, on the server, many jobs defined by users and some of those jobs are scheduled using cron expressions. I need to check (I can execute Groovy/Java on the server) if those jobs take longer than they are scheduled (I mean job is taking 10 minutes, but scheduled to run every 5 minutes). I have been trying to find s...
I am currently writing my first bigger project in c++. Its basic linear algebra. I am aware that boost libraries and others exist, but for various reasons I need to write my own. Purpose of the library is to perform certain vector operations (adding, substraction, etc. ...) for statistical data analysation. So ease of ...
Is it possible to act as a MySQL server in a Java or Android application, such that applications like HeidiSQL can connect to it? What I want to do is to write an application for Android which behaves as a MySQL server for an arbitrary database on that device. Since there are many MySQL clients that can connect to MyS...
I have a homework assignment for a data structure/algorithm class. The task is to take an unsorted array of size n (example: [-8, 3, 2, -3, 3, 1, -3, -5]), and we have to use a divide and conquer approach, w/ recursion, to find the subsequence with the largest product. It is the same as this question: http://www.wou.ed...
For example, if I have two classes "Director" and "Follower". I want the Director to tell the follower where to go (ex: follower1.go(direction.LEFT)), and I want the Director to know what directions it can tell the Follower to go when coding in an IDE that gives completion suggestions. I know I can already either do: p...
We are developing an app for taking photos faster. We do this by actually taking videos instead of photos and processing the individual images in the video on the fly and combine them to create a high-resolution image. Since this app is heavily dependent upon the hardware of the various devices, I was wondering how we ...
I'm wondering how to write the if statement in the following block in a better way. It's supposed to operate when $a is 14, 22, 30 and for all following values at intervals of 8, up to some limit. The current way is obviously not good since the action must be performed each time that periodic pattern is fulfilled, and ...
I understand exceptions, throwing them, handling them, and propagating them to a method lower in the call stack (i.e. throws). What I don't understand is this: public static void main(String[] args) throws Exception { ... } Now, I assume that in the case that main throws an Exception, the JVM handles it (correct?)...
I have been on numerous teams that try to practice Agile methodologies and often these teams are test centric. Is testing a necessary part of practicing the Agile methodology or is it just a XP practice that has been latched on over the years?
I am trying to make a Android application which will take your URL and if there is new update on that website then it will show the user that this link have been updated. I am working on the project which will check for the website if they have been updated or not. I know that there are RSS on most of websites, but I a...
To my understanding message acknowledge deadlock problem is this: In order to sync value X between A and B A sends X to B A waits for B to send acknowledgment to A so it makes sure B has latest X B waits for A to send acknowledgment of acknowledgment that B received their acknowledgment. and so on ... How in real wor...
I've been reading a lot about sessions and security, trying to learn as much as possible before writing too much code. I've read about limiting session replay by including a timestamp within the cookie or data sent by the server: {timeStamp, sessionID, HMAC({timeStamp, sessionID}, Key)} limiting the valid time with the...
There are already questions on SE that ask if a developer should have access to the production server(s). But, given the fact that I already have a root access on the production server, should I say that, as a developer, using that access is beyond my responsibilities? Should I argue that I'm not a sysadmin and I am af...
I have a chat app made in node/socket.io. Scalability factors have made us choose Erlang/Ejabberd/xmpp and it will replace node/socket. I have a few questions: Currently using MySql for chat storage. Best alternative considering scaling and consistency as major factor? Reason why I am switching : a row for single mess...
First let assume that everybody agree that there is nothing wrong with injecting some value object into injectable object such as service. Indeed, a service can get another service injected, but could along the way get some configuration information as well. Configuration information that would be represented as Value ...
I'm writing a software which will be used mostly by companies. I then had the idea to give companies a way to register their email domain so that every user which registers with an email of the given domain will be automatically put in the company group. I know Slack does something like this and it works, but there are...
I'm a PHP developer coding in the Yii 1.x framework. I was looking for a way to encode unescaped JSON in Yii 1.x, and found the CJSON framework class for this purpose (so OOP). Since it does not support unescaped JSON though, I had to revert back to the pure PHP, procedural, non-OOP approach of using json_encode($resul...
So typically we create schemas, mime-types, etc for our objects when we're communicating to another system about objects. The document usually defines data structure of the objects for serialization purposes with no recording of the object's methods. All I am left with on the client are effectively structs with no met...
I know that functional requirements are requirements that tell the system what to do while non-functional requirements are about quality and constraints. For below requirements, which of these will fall under non-functional or functional? UI must be graphical in nature. I would put this under non-functional requiremen...
This question pertains to the re-link clause of the LGPL specifically on the Play Store. There's lots of unclear information about this topic. Assuming there's an application on the Play Store that has a dynamically linked native library where the lib in question is a seperate *.so file in the APK, is it possible to r...
I'm a contributor to a large open source project. I have made heavy changes to a submodule of that project to support more functionality, but at this point further improvements will be outside the scope of the original project. As such, I have pulled only the relevant files to the submodule into their own repo, and am ...
So I'm working on a web based game, and need to deal with the age old issue of duplicate account detection. Players often create multiple accounts to farm money/items etc to their main account, or to stash items etc. In the games I've typically played the main way this is done is by preventing multiple account to be us...
While doing a coding test, I ran into a problem where I need to initialize an array of generic type in Java. While trying to figure out how to do that, I looked at this Stack Overflow question and it requires that I suppress a warning which doesn't seem like a good practice, and might have other type safety issues. For...
The title says it all. I'm trying to build a calculator application (for self-learning purposes). The application is going to have a very common UI, with plus(+), minus(-), multiply(*) and a divide(/) button. Also, the app can do, real-number as well as complex-number calculations. So, the situation here is, depending...
TL;DR - I have a standalone application that will remain relatively small. I'm trying to evaluate between using XML files or a lightweight database for local storage of data that needs to be persisted. What factors should I consider when choosing between the two approaches? Let's assume that I have a program that wi...
Is there a general algorithm to implement SQL's ORDER BY with OFFSET/LIMIT more efficiently than sorting all the records? The algorithm for a simple TOP x is easy enough. It takes one full pass through the data, but only x records ever need to be sorted. The amortised complexity is O(n), for a set of n rows, assuming x...
This started out as a SO question but I realized that it is quite unconventional and based on the actual description on the websites, it might be better suited to programmers.se since the question has a lot of conceptual weight. I have been learning clang LibTooling and it is a very powerful tool capable of exposing ...
I got used to the following approach on bugfixing phase of the project development. The developer should add SVN commit number as a comment to the JIRA issue when resolving it. Latest artifact from CI-server shows build number which include major version, branch name and commit number. This approach helps QA easily to ...
My question is about how best to organize C++ classes around a database model, and I understand this may appear very elementary. The software I propose to create will do the following. It is intended for small FMCG manufacturers and will use Qt. The software will record non-conformance's, product complaints, correctiv...
I am developing a program for Windows 7 Enterprise Edition that will be used in a corporate environment. The application will automatically fix certain errors as soon as the user selects the application name, chooses the symptom or error message and clicking on the fix button. The idea behind is to decrease the amount ...
As I finish one project and start another, I have a small time window to come up with an architecture for the new. I am coming from the following design: Web applicationReceives domain models & DTOs, Sends DTOsapplication configuration, application-specific DTOs+mapping, application-specific services, & controllers) C...
As I painfully try to find a good natural sorting algorithm written in JavaScript, I then stumble upon a bunch of different implementations, interesting blog posts, and answers on StackOverflow. Each implementation provides its technical tricks. However, the more I looked into it the more a question became very clear: ...
I have been researching different programming paradigms. I have found a lot of people saying that one of the areas where logic and functional programming are particularly good is programming AI, but I am having a hard time finding a good explanation as to why. Could someone point me in the right direction and let me kn...
When I think of the word 'computation' - my mind jumps to lambda calculus or operations on a state machine representing a CPU. It is quite a broad definition. Now some people talk about monads as 'representing a unit of a computation'. But if we consider the identity monad - this is a 'reference to the computation'. ...
I've a web page that has many constituent parts. On some user action, a POST operation is made, which then returns JSON to update the page. The problem is that this JSON payload contains a lot of information built from many different operations and classes. The JSON data is used then to update a number of partial vie...
Let's say I have a channel endpoint where I receive messages. Because I want to process messages in a different way depending on its Header property, rather than create a massive switch I create different strategies with the contract: interface IMessageHandler { String MessageHeader {get;} void Handle(Message...
I had a little debate going on with a coworker. Simply put, is there a good reason to hide/encapsulate functions that are pure? By "pure" I mean the wikipedia definition: Always returns the same results from the same input. (For the sake of this discussion Foo Create(){ return new Foo(); } is considered impure if Foo ...
Basically, can I do this, and what actually happens? public class foo { public int id; public void bar() { //do stuff this = null; // ? //do stuff foo[] all = otherclass.FindAllFoos(); foreach(foo f in all) { if(f.id == 42) { ...
(note: I used Java to make it easer to explain my question, but the actual language is irrelevant for this dilemma) TL; DR: I have a wrapper around some underlying class. At which point should I instantiate the underlying class (in the constructor, in a separate method, on first use) and why? Lets say, for example, th...
Most programming languages (both dynamically and statically typed languages) have special keyword and/or syntax that looks much different than declaring variables for declaring functions. I see functions as just as declaring another named entity: For example in Python: x = 2 y = addOne(x) def addOne(number): return ...
My computer science teacher says Big O has an upper bound but no lower bound. When I look at a graph of an algorithm mapped out using BigO though, there isn't an upper bound at all. The upper limit goes on forever. So what do it mean to say there is an upper bound in the context of BigO?
There are countless war stories about how long a compile can take. Even xkcd made a mention of it. Now, I haven't been programming for a long time and have mostly just been exposed to Java and Python (and Python is an interpreted language, not a compiled one). I realize it's possible that I just haven't come across pr...
I have a project where I must map employees to a schedule. The basic concept is: Company Opens between 08:30 and 17:00. Employee 1 can work from 08:30 to 12:00 then from 13:00 to 1700; Employee 2 can work from 12:00 to 13:00. Employee 3 can work from 17:30 to 00:00 I would then want the employees mapped to the compan...
Is there a way to automate running VBA in Excel to clean up the file from inside an application? Everyday my office has to confirm that 50 people have shown up for work on time. The scheduling software we use allows us to run a report and export in to 4 file types: HTML, RTF, CSV, and a text file. For what I am looking...
I was taught that an object should know how to do everything with itself. So I've built an application trying to keep fields private and have a lot of methods like these: DisplayGraphically() DisplayAsText() WriteToFile() Apply() Edit() (shows a dialog box to edit it) ErrorCheck() Now I want to save the data to anoth...
Is it possible to have a generic class (let's name it Hub) which implements: - interface T - has method named Add (not a part or interface T) And now calling Add allows me to store any instance of T in internal list. And finally when I use a method XYZ from interface T on my Hub class, for example: Hub.XYZ(1), it will ...
I'm reading about TCP at the moment and there is a maximum sequence number 2 ^ 32, my question is what happens when the other host tries to send an acknowledgement for that sequence number 2 ^ 32 + 1? Does TCP handle this by resetting or does it just crash out? (Also bonus question, is the first sequence number genera...
I'm trying to determine how best to accomplish the following scenario using the Azure Service Bus. I have millions of devices (desktop software, mobile phone apps, etc) that need to have messages sent to them based on subscriptions. This in and of itself is pretty easy. However, the Service Bus has limits on the number...
In the article Building Web Services the REST Way, the author states: Design to reveal data gradually. Don't reveal everything in a single response document. Provide hyperlinks to obtain more details. Why is this considered a good practice? UPDATE: I realize that this practice is also known as HATEOAS.
I'm currently building a B2B web application. As a part of the signup process, I require users to enter their office's street address, state, and city, which I then geocode into latitude and longitude using the Bing Maps API. Since I'm primarily using their address for geocoding purposes, I haven't had any issues so fa...
When compiling an application that depends on a library we have to specify the include the library and also the header file. Since the library binary contains the actual function names couldn't the function names be provided from just the binary?
I have been using Collections.max(list) for many projects, but I occasionally want to find the index of that maximum element. I feel silly writing a function to do this for myself in every program I write. Why does the Collections Interface not supply a Collections.maxIndex(list)?
I have a Java web application that makes use of certain libraries for example: Ghost Script for converting PDFs to TIFFs and Tesseract for OCR. There are java wrappers for both of these: Ghost4J and Tess4J. What are some things I should think about when deciding whether to use the libraries or issue a command line pro...
I'm getting into web development, and I'm trying to get a grip on databases. In an app I want to make, there is a read only database that will be filled up with a large amount of data, which will be the heart of the application, and also a lot of work to put in. I'm uncomfortable with putting all this data into the dat...
i'm trying to find a way to count barrels on an image. For this I'm using Hough Transformation. I tried my code first recognising eyes and it works excellent. But now the problems is when i try to find more than one center on the image. For the eye case, I just use Hough with an accumulator, that later will tell me th...
I am currently working on introducing continuous integration and switching to git, and as part of that, we must also better structure our tests. We have agreed on splitting the tests in "integration" and "unit" - however he doesn't seem to agree that touching the database is also integration testing. The code is horrib...
I'm not sure what the most efficent solution to this algorithm is. I'm not sure this fits exact cover, and approaching it via exhaustive backtracking seems somewhat inefficient. Any suggestions on how to approach this? There are 210 Invoices and 1700 bills – these bills add up to these invoices The association between...
I read code way more often than I write code, and I'm assuming that most of the programmers working on industrial software do this. The advantage of type inference I assume is less verbosity and less written code. But on the other hand if you read code more often, you'll probably want readable code. The compiler infer...
I want 500 objects to be processed concurrently using multithreading. These objects will have some initial data before the threads are created. I am creating 5 threads and each thread takes 100 objects and starts the operation. Here is the code. public class InputData { public string initialData {get; set;} publi...
I am looking for an example (if exists at all) of a definition of a date in a programming language (Idris, Coq, etc) that features dependent types where such definition is consistent and type safe by which I mean that invalid date expression or literal would give a compile time error. If the complete definition isn't p...
When developing applications (for simplicity, use a client-server model) intended to be deployed on customer systems, when it is acceptable to expose business logic outside of compiled code (for instance in stored procedures)? I used to subscribe to the thought that any and all logic should always be within the compile...
I'll do my best to describe the problem, but I'm still very new to several concepts that I think this problem requires to be solved (namely interfaces and threads). I should preface this by saying that I'm obviously not a Comp Sci major (as you'll see). I've learned as I've built my App, therefore my theory is terrible...
Some parts of a game are easy to test in an automated way (logic, maths, input handling); but there's also a lot that's purely visual and not easily testable. I would be surprised if the games industry left all of this to manual testing; there's enough money in it that I would guess that effort has been put into being ...
I have recently started a project, a CSS/JS library, on Github. I'm already pretty far with it and was wondering: How do I make it popular? How did other libraries that are very famous now, like jQuery, become that famous. Because I don't think they just left the project on Github for awhile, and then all the intereste...
In my application users can subscribe to other users, like in every social network out there. However I'm experiencing some trouble when a user has too many subscribers. Every time a user posts something all of his subscribers are notified via the notification system. When a user has like 2000 subscribers or even more,...
It seems to be accepted that computers that have been powered on for a long time and have any sort of complex software (ie and OS) running on them they tend to develop random errors and problems. Turning the device off and back on powers off the machine and destroys all volatile memory, generally fixing the problem. F...
I have a structural problem for an application I'm working on. In the interest of full disclosure, it is for a university assignment so I'm not looking for you to code me an answer, just help me think through the best approach. I'm building a game using an OO approach. I have an abstract class called Player from whic...
I'm building my first MVC application in Visual Studio 2013 (MVC 5) and I'm a bit unclear on the best way to setup my model. I've generated an entity framework model using code-first from an existing database. My first instinct was to create some intermediary classes that would be the model used by the views and have t...
Let me try to elaborate it. Stack Frame: When we execute any function it create stack where all local variables and instructions reside. And Smart Pointer: smart pointer like std::unique_ptr allows to change ownership of object inside of smart pointer. Now my confusion is: suppose we pass a unique_ptr from a source f...
I made few modifications to few specific Ubuntu files for showing my own custom messages in place of Ubuntu specific messages. For this, I have made changes to following files: /etc/update-motd.d/00-header /etc/update-motd.d/10-help-text /etc/legal /etc/os-release /etc/lsb-release /etc/dpkg/origins/default /etc/issue /...
I'm having little difficult time of understanding the few logics of web development. Should I call home page, about page (or any other pages of a website whose contents change very rarely and no user interaction with them) etc the static pages? If yes then why should I put the contents inside a database and pull the ...
Different systems accepts different formats of formating time. E.g. java, jquery: yyyy-MM-dd HH:mm some jquery plugins: yy-mm-dd HH:MM momentjs: YYYY-MM-DD HH:mm ISO-8601: YYYY-MM-DD hh:mm etc On server I store time as Epoch time. And like to store some timeformat for user, so he see same format everywhere. But I jus...
To debug a C program using gdb effectively it is required to compile it first using the command: gcc -g programName.c otherwise on using simply gcc programName.c and running we are unable to provide gdb the Source Code i.e.programName.c resulting in an error message - dl-debug.c: No such file or directory. on deman...
I'm trying to find an elegant way to implement a decision making algorithm that allow easy maintenance because the conditions for the decision making might change often. I'm going to try and be more specific with an example here : Let's say I'm trying to manage a team of Cooking chefs in a restaurant kitchen. Every che...
Recently I was put into a position of a tech-lead on a very interesting project that I have been partially working for two years. This project carries a lot of legacy stuff with it even though we try to strip it down. I am looking and researching a solution for my scenario: the website has lots of hard-coded IDs (even...
I am in the process of cleaning up my code and making it easier to maintain. I am doing this by turning my 5000+ line file into separate smaller files. I have successfully created separate source and header files for obvious things like utilities and other components that are not tightly integrated with the application...
We are trying to globalize an application and we have run into a situation where I'm not sure how (of if) we would go about formatting the string for globalization. It's a paragraph explaining something with a list of names within it. For example: "Bob, Sue and Michael each received a point." "Bob, Sue and Michael" i...
I write a lot of open source software that I make available on my website. How do I get my software compiled for all relevant platforms including: Windows OS X Linux 32 bit deb Linux 64 bit deb Linux 32 bit rpm Linux 64 bit rpm etc I currently only have Linux 64 bit boxes, so I can only compile the 64 bit deb and r...
I'm thinking of switching my cloud provider from AppHarbor to Azure. Main reason, I love the ability of being able to scale up the number of workers as traffic/cpu usage gets really high. My question is, how to coordinate this transition for users that still point to *.apphb.com instead of www.{mycustomdomain}.com. I s...
I am having a really hard time understanding the basic structure of the Model, View, View Model pattern. I have honestly been pretty ignorant of design pattern conventions until recently. My formal education is in web media, so I got into programming through Javascript. Lately, though, I've been building a complex game...
Consider the following design public class Person { public virtual string Name { get; } public Person (string name) { this.Name = name; } } public class Karl : Person { public override string Name { get { return "Karl"; } } } public class John :...
I have a method (in C++) which generates a value based on a parameter and the parameters from previous calls. Calling it more than once with the same parameter may generate different values each time. For example: public: int getValue(const int param) { int value = param ^ previousParam; previo...
JS offers the 'arguments' object inside of functions to represent all passed arguments. Is there any broadly accepted concept for when/where this should be used? I've seen items like this in the 'wild' that seem like code smell to me: function myFxn () { var myVar = arguments[0]; // do something with myVar } this ...
I have an application that uses a database of about 15,000 Java objects, which I have to read every time the application starts. Originally I've been using JSON to store the data, but that has a few issues, mostly that it's slow (it can take 8-10 seconds to read all the objects on my lower-end machine) and also, it's ...
I'm writing a Math equation solver in python (for fun). The first design that came to my mind: Expression: base class for every item in an equation (maybe bad name). BinaryExpression extends Expression: two expressions with a sign. Expression + Expression should provide a BinaryExpression, I do this through overriding...
We have a rake task called db:sanity_check which exists in a 'core' repo. Other repositories that we have also show this rake task. But they do not define the rake task. It 'comes' from core' How do these other repositories know about the rake tasks from the 'core' repository ? Is it because they include that reposito...
I often come across this problem. Say to have a form with some controls: A B C = A + B D E = C * 2 ONLY IF D==TRUE F G = A - F The user fills A, then B. The system calculates C. The user fills D (boolean) The system calcluates E The user fills F The system calculates G But now: The user clears A The system clears C...
I have created an easy database-driven web application (with PHP+MySQL). It's written procedurally with a few controllers (index.php) in a few directories and a few template files and one stylesheet. There are a few functionalities such as access management and utility functions. As I progress with time, I notice that ...
The context we're building a web-based system and one of the design decisions (database related) was whether to have 1 main DB manage all client data VS having 1 DB per client. After reading a lot on the matter (especially in these forums), it appears that 1 DB per client is overall a better approach, especially on th...
I want to GPL some standalone web pages containing my Javascript/D3.js source code. How to use GNU licenses for your own software says that to distribute source code under the GPL, I should "include a copy of the license itself somewhere in the distribution of your program." I could bundle up the web pages into a di...
With K processor cores, how to optimally split N jobs into groups, with each group to be processed sequentially by one processor core, when the time to process each job is unknown ahead of time and there is overhead associated with processing each group of jobs? It is possible to kill a job group before it completes, b...
I have a set S of size n whose members each have associated with them a number in the range 0.00 to 1.00 inclusive. I want to select a subset T of size m with this property: the average of the numbers associated with the members of T must fall within a specified range x to y (for example, 0.65 to 0.75). Expressed diff...
We have a utility for monitoring directories and taking actions when files appear in those directories. It's in java and takes the form of a standalone jar which launches several threads when started: One thread periodically (every minute or so) checks for new instructions regarding which directories to monitor. Anoth...
It seems to me that a while loop with the appropriate break statements can replace them entirely. I understand that a break statement may not feel as "smooth" as a for loop that does something a specified number of times, but I also feel that the redundancy in their behavior is unnecessary.
Which is the better style to follow for say, changing the voltage on a 4 channel PSU: setChannelOneVoltage(voltage) setChannelTwoVoltage(voltage) setChannelThreeVoltage(voltage) setChannelFourVoltage(voltage) or setVoltage(channel,voltage)
I am going to develop an application in ember.js which is kind of a small CRM through which customer representatives can answer to queries of customers. The layout is pretty simple, I have a 3 column layout. First column respresent all the queries by customers. Second column represents the detail of query and section w...
I've recently read Reading the Privacy Policies You Encounter in a Year Would Take 76 Work Days and was pretty shocked that it was that bad. So I thought how this could be improved. Creative Commons licenses are nice, because they are modular: CC: Indicates that it is a creative commons license [-BY]: Attribution [-NC...