instruction stringlengths 34 36.1k |
|---|
I've encountered a problem in a personal project that I think could be solved by a particular data structure but I'm not sure what. The problem is as follows:
Given a set of k-tuples, provide an efficient data structure that given a position, i, and a value, p, returns a list of tuples that contain value p at position... |
AFAIK, C does not have a print function. The most basic we can get is printf. So, is there a reason why this function is not simply named print, instead of printf?
Note that this question is about scanf/readf and printf/writef. This one is about printf/print.
|
I need help architecting a data access layer using Entity Framework. Here are the requirements:
The database is preexisting, an absolute mess, and it's structure and cannot be altered
Entity Framework will be used
The database will be used by dozens of .NET MVC applications each with their own set of business objects,... |
Assuming I create a RESTful web service that looks up a user in a database given the id as a parameter.
If the user does not exist, should I return a 404 response (because user not found)? Or a 200 response with a "User not found" error message?
What's the better practice?
|
I'm new to Agile as a methodology, although I believe a have a basic grasp on its principles.
My team is currently building a framework that will support our client's application in the future. As an input, we have a bunch of requirements and even a suggestion of how the application should be implemented, at a VERY hig... |
Is it a normal practice, or a sign of a bad design?
For example I have a function that loads prefabs in a main logic class nearing 200 lines, and I can either move it out into a separate file LoadPrefabs.cs by making it partial or making it a separate class and calling extra code just by new LoadPrefabs(ref prefabs);
... |
I want to push a local repo to multiple remote GIT repositories to achieve redundancy in my backup scheme. So, let's say I plan to use Github and BitBucket to host my repositories.
I have two questions.
Is this approach advisable?
If so, how should I best approach writing a shell script to automate my backup procedure... |
I'm working on an application where I want to keep a timeout value computed dynamically using a moving average of say 100 previous response times for service A.
This value + some buffer (~3 seconds) will be used as a timeout for network requests to service A.
The problem here is, I want this timeout to improve with net... |
My current understanding of Inheritance implementation is that one should only extend a class if an IS-A relation is present. If the parent class can further have more specific child types with different functionality but will share common elements abstracted in the parent.
I'm questioning that understanding because of... |
I'm currently developing on a rather large e-commerce application that handles multiple different business-fields. Like every e-commerce application we have a Concept called an Order which has one or more OrderItems.
Due to the fact that we cover multiple business-fields the OrderItems need to store different Informati... |
Lately my team has started considering the implementation of MVP pattern in some of our applications.
We followed the several guides and tutorials out there, basically ending up with regular PresenterInterface and ViewInterface, the latter being implemented by an Activity or a Fragment.
As for the PresenterInterface, w... |
I'm working on creating a C# wrapper library around a native C library that allows me to directly communicate with a particular piece of hardware over a serial (COM) port.
Of course, the C library returns success/failure codes from its methods. I'd like to translate those into exceptions, but I'm having a hard time fi... |
I downloaded a GPL program, I want to modify this GPL program in order to make it calling a non gpl program (commercial license) via fork+exec.
Concerning the input/output data of the non-gpl program:
The input data are the arguments of the command line of the non GPL program
The non-gpl program is sharing his output ... |
Background
Here is how I currently log any exceptions that occur in my code:
Pass each object instance the path to a file where I want all of the logging to happen.
Each of the objects have their own exception logging code, which is called in a finally statement.
One downside I could see to this, would be that if I h... |
I have an array of items. Some items have a number on both sides. I'll call these "matched pairs". I need to sort the items between the matched pairs in a particular way.
There's a "from number" and a "to number"
There may be more from -> nil than
nil-> to, or vice-versa.
There may also be NO items between the match... |
Is there a phrase in common use for a counter that is incremented every time the state of an object changes?
It's not quite a timestamp and it's not quite a revision but maybe there is a common name for this.
The usage is to provide loosely coupled portions of code with a simple way to quickly check if a large object h... |
This is a function that searches child nodes recursively until it finds one that is a text:
_.findPrevText = (node) => {
if (node.nodeType === 3) return node
return _.findPrevText(node.lastChild)
}
I could also write it like this:
_.findPrevText = (node) => {
if (node.nodeType !== 3) return _.findPrevText(node.l... |
interface IRepository {
Data getData();
}
class BaseRepository implements IRepository {
public Data getData() {
...
}
}
class CacheRepository implements IRepository {
private final IRepository mRepository;
private final ICache mCache;
public CacheRepository(IRepository repository, ICache cache) {
... |
Examples:
isKeyValid -> keyIsValid
hasPostThumbnail -> postHasThumbnail
The first case is easier to remember (convention). The second is easier/more natural to read.
Which should I use?
|
I've recently deleted a java answer of mine on Code Review, that started like this:
private Person(PersonBuilder builder) {
Stop. Red flag. A PersonBuilder would build a Person; it knows about a Person. The Person class shouldn't know anything about a PersonBuilder - it's just an immutable type. You've created a circ... |
I recently found a website (LINK) which explains various ways of performing curve fitting using Math.Net. This is one of the only websites I have found that explains the methods and also provides example code. As a result I downloaded the source code to examine and alter for my own purposes. At the top of each class is... |
My understanding of escrow, as it is used in software projects between a "client" (commissioning the software/app) and a "contractor" (developer; provider of application services) is as follows:
The client & contractor sign some type of Master Service Agreement (MSA) and 1+ Statements of Work (SoW), which identifies h... |
I have a table that contains the percentiles from a reference data set.
CREATE TABLE [Core].[RiskFactor](
[SpecialtyCode] [char](2) NOT NULL,
[RiskCategoryId] [int] NOT NULL,
[Percentile] [tinyint] NOT NULL,
[RiskFactor] [numeric](5, 4) NOT NULL
)
Each combination of SpecialtyCode and RiskCategoryId will have 101 rows... |
We're building some Roslyn analyzers concerning GetHashCode(), including an analyzer that implements it for you in a given class.
While researching the subject we've found that there are many considerations to take into account, mainly on what kind of members should be avoided in a GetHashCode() implementation.
The mai... |
Background
I've been doing a bit of image manipulation recently in PHP/JS. The basic functionality is such:
Web page loads, an <img> tag points to a PHP script which generates an image "on the fly". Interacting with various parts of the page changes the src via jQuery's .attr('src', 'newsrc').
I had thought about putt... |
I am trying to implement an agile-ish approach to our firm. Right now we have a very much waterfall like approach to designing, coding, testing, and releasing. One major issue we haven't found an answer for is the idea of quoting. We allow our customers to request small to large changes in the system and pay for those ... |
Most of DDD tactical design patterns belong to object-oriented paradigm, and anemic model describes the situation when all business logic is put into services rather than objects thus making them a kind of DTO. In other words anemic model is a synonym of procedural style, which is not advised for complex model.
I am no... |
I have a simple zero sum, discrete, deterministic, complete information board game. I want to machine learn an evaluation function for an AI agent.
Suppose each board state has ~20 identifiable features which could be weighted to form an evaluation function.
Suppose the time constraint for both players is 15 seconds fo... |
In Sweden the abbreviation "t.ex." means "for example" ("till exempel") and it is extremely common. Every time I write that t.ex. in an email or in a text message it gets marked up as a clickable hyperlink which damages my message.
How difficult is it to match hyperlinks without getting false positives?
I remember see... |
I want to play video using ASP.NET MVC. In my understanding, the model deals with the video files stored in file system and data in database. The controller retrieves the path of video file from model and sends it to the View. So who handles the work of streaming video actually? To find it out, I searched online and f... |
Why is it that some languages don't even have a boolean type (and uses a constant TRUE instead), but they have many other and modern types? Sometimes it can be trouble if you make a boolean and then realize it can have three different values or more, then it's going to be difficult if you have old data with the boolean... |
I was wondering if long long specifies a single datatype then why don't things like int int work? I meant obviously that's not a data type but there is a long data type. Essentially what I'm asking is:
int a = 0; //okay
long b = 0; //still fine
long long c = 0; //really long number but its okay....
int int d = 0; //e... |
A friend of mine was recently asked this question in an interview.
Lets say there is a continuous stream of incoming events E1, E2 each with timestamp of entry associated with them. Write a java module to Make a call to raiseAlert() if at any point of time there are more than 1000 elements incoming at the same time.... |
What i'm trying to implement is a program that is searching for the fastest connection from one station to other at a given time of the day.
I have a number of stations n, and a number m of lines that connect this stations. Each line has (departStation, arrivalStation, busDepartTime, busTravelTime).
When I want to sear... |
I am trying to implement DNS-SD, and I understand how it works, but don't really understand the purpose, so I have a few questions about it.
Let us assume that we have two devices on local network, and we registered services both devices provide, how dns-sd really helps us, it just replaces ip:port/path/to/service with... |
After I installed "Wappalyzer", extension wich display technology, wich site using. I checked many sites and in most of cool projects, like "Youtube", "Github","stackoverflow" etc, wappalyzer display only some js framework and comercial things.
But when I checked sites, wich I builded on Django, wappalyzer display all ... |
I am writing a poker application and trying to figure out how to deal with split pots and side pots
There are four rounds of betting and each round of betting can have multiple orbits
Can only bet the chips in front of you
So if a player is all in a side pot is created
Hands can tie - in which case the pot is s... |
So we are writing medium size software,and it has two parts frontend is written in angularJS and backend in laravel. Laravel provides api and nothing else.
Now very often one of many dependencies gets updated.
Now shall we take the bite and upgrade or do not disturb the system since it is working fine?
|
I develop iOS app with some GitHub controls and Framework as like FMDB,AFNetworking,OpenCV,RadioButton,CheckBoX etc... but now my worry is I want to distribute this app with Apple Enterprise account (not on app store).
I already read some post which say we can use to distribute app with these licence but they were in w... |
I have a question about assigning values to nodes laid out in a physical space:
There is a set of N fixed nodes spread out throughout a certain 2 dimensional region that need to be assigned a value from 1 to M. In this case, M is less than N. Preferably, nodes that have the smallest distance between one another should... |
While I am starting to get a hold of NodeJS programming, I am a bit confused by when to use request params and how their practical use differs from using query strings.
In particular, I can do localhost:8080/:param1 in the URL followed by req.params in the code or localhost:8080/?param1=value in the URL followed by re... |
Let us say that I want to create a workout app and a website, the user enters his workout stats and the app display his stats with graphs percentage and such.
This is an example I don't want to create a workout app, just to understand how platforms work.
Assuming that I want to have an Android, iOS app and a website. A... |
In today's cross-platform C++ (or C) world we have:
Data model | short | int | long | long long | pointers/size_t | Sample operating systems
...
LLP64/IL32P64 16 32 32 64 64 Microsoft Windows (x86-64 and IA-64)
LP64/I32LP64 16 32 64 64 64 ... |
I am looking for an algorithm to create a raffle, where each participant is assigned a ticket with a random series of numbers.
Each raffle hast N participants, and there should exist same amount of raffle tickets, one ticket per user.
The user should know her ticket numbers before the draw, so she can follow the draw, ... |
I have a class that enforces database-friendly formatting for some of its properties in the __construct() method.
This guarantees that if a new object is created and saved, it will be saved correctly. But saving new objects happens rarely. Retrieving them happens thousands of times more frequently, and these same rules... |
I need to perform quick searches against a combination of tags while including date ranges:
Example:
Users
who have requested notifications
who did not respond to a notification sent at least 3 days ago
and who have not been sent any other notification in the past 3 days
Data Structure
The event data structure is... |
Can anyone suggest an algorithm for this problem.
Given an undirected unweighted cyclic graph, and a given start and end node in that graph, I'd like to determine if there is exactly one valid path from start to end visiting all nodes (i.e. a Hamiltonian path, not a cycle).
It's NP-hard, but my N is relatively small (u... |
I have been working on a application that up until now has been pure Node. However I am concerned about performance and overhead since the application performs a lot of file system operations (Copy directory, file writes, Remove Directory, zip....)
Everything works like a charm, but I am thinking it would be best to m... |
I am reading Think Python: How to Think Like a Computer Scientist, the author says that an algorithm is:
A general process for solving a category of problems.
But I don't know if that a right definition of an algorithm. Isn't an algorithm aimed at solving a specific problem [finding if a number is odd or even, for e... |
I am currently working on a project which requires data fetching from a 3rd party closed API (over SOAP).
Currently I'm in a situation where I have to do argument and data validation inside our application code, because the mentioned 3rd party API does not return anything relating to errors. Examples:
Request somethin... |
Problem Statement
I am going to write a library to control a whole bunch of relays, and I am just trying to think conceptually right now.
Here are my design constraints:
We have an exact number of relays that need to be controlled, and this number will never change (because once we build a board we will never add rela... |
If we are working on multiple ASP.NET MVC projects that share a lot of common stuff like CSS, Scripts, or even utility C# methods, etc... what is a good way to keep them in one place ? Currently I have my own CSS, another developer has his own CSS for the same stuff ,etc.. and this gets out of sync this way. We are usi... |
I am looking for the following workflow:
Add an entry to a table of my Postgres database with a end_date and state (with the following values: active or done) columns.
Execute a lambda at the exact end_date value to update the state of this specific entry from active to done
The only ressources I found on Google abou... |
I see a lot of programs that does write a pidfile, and check at boot its existence. And this is good. But many application does not start even if they check that the pidfile exists, yes, but no process with that pid is running.
Why this behavior? Is it not more simple to remove the pidfile and warn the user, at most?
|
I recently came across a website that contained an anchor element without a href attribute.
I immediately thought that was stupid, but, could there be an actual situation where having an anchor without a href makes sense?
|
I'm working on a project with web services, and I've been structuring things where:
The web service contains the business logic layer
A library which handles the data access layer
I've recently been learning about micro services. In hindsight, I'd want to split the service in multiple services each covering a specifi... |
Continuing from Author has inserted copyright into code with gnu public license notice - implications?, can I add my author name to a new file (with original code) that I added to a project that comes with a GPL license - as in:
# GPL License and Copyright Notice ============================================
# This file... |
Linq has a method Select, which takes a Func<TIn, TOut> and maps it over an iterable.
I'm trying to come up with a good name for a method that takes an Action <TIn>, transforms it to return its argument, and maps that over an iterable.
The method is
public static IEnumerable<T> MyMap<T>(this IEnumerable<T> source, Act... |
Recently, I've gone through techcrunch article where it says, Dropbox is working in Project Infinite technology which allows to load cloud content in local PC without actually storing in memory/drive
Today at the Dropbox Open conference in London, the company announced
Project Infinite with the goal of giving busine... |
I've been studying the cyber security field with great interest. I understand how networking can help cyber security but I am not sure how advanced programming knowledge can help fight cyber crime or why certain cyber security experts need programming knowledge.
In my experience so far with penetration testing tools a... |
Should I write my code to be clear what I am doing and rely on the optimizer to clean up my code efficiency, or should I be obsessive about getting every last ounce of power out of my code?
And how much speed/size am I losing on by choosing one option over the other?
|
I am working on a game framework that would allow users to use multiple mods/plugins to add additional features to the game.
For the remainder of the post, I'll use the following definitions:
mod: code that requires changes to both the client and the server. For example, adding a new packet to the protocol.
plugin: cod... |
Is it considered good practice to start a transaction in the "service/application" layer, and then have objects in the domain model make DAO calls which participate in that transaction?
|
In the excellent book Node.js the right way the author shows this example:
const
fs = require('fs'),
zmq = require('zmq'),
// socket to reply to client requests
responder = zmq.socket('rep');
// handle incoming requests
responder.on('message', function(data) {
// parse incoming message
let r... |
Do I need an "application/service" layer to manage transactions if the domain layer only services the UI?
In other words, can't I just manage transactions in the UI when I have only one consumer of the domain layer? In this case isn't the "application/service" layer just an un-needed extra layer of abstraction?
|
I'm working on an application to help create printed-page layouts (to be then fed into a custom script for InDesign). I'm facing a problem regarding placing images on a page. Either a single image could be placed on a page, or multiple images.
If a single image is placed, the user should be able to define whether it's... |
Should I write unit tests for complex regular expressions in my application?
On the one hand: they are easy to test because input and output format is often simple and well-defined, and they can often become so complex so tests of them specifically are valuable.
On the other hand: they themselves are seldom part of th... |
We recently started learning about binary search trees. We created one of our own using integers as our Key/Data. It's easy to achieve the BST property using an int key, but what happens when we template our tree? How do we achieve our BST property with say a char, string or foo? - These don't seem fitting for keys. Do... |
This question is about handling namespaces and unit testing in ZF2.
Let's say I have a module called Application. I have constructed composer.json to be like so
"autoload":{
"psr-4": {
"Application\\" : ["module/Application/src", "module/Application"],
}
}
where first path is for the main code in the src... |
For a C project, I'm upgrading my build process from
MingGW-GCC / make and Android Studio under Windows (2 separate processes)
to
Clang / CMake under Debian 8, using wclang and wine to compile and run the Windows build
It seems to me as if we build for one platform at a time. I suppose there is a large part of the ... |
I recently came across the ReactiveX pattern for asynchronous data-flows. I studied the information provided there and also watched this talk by a Netflix engineer on how they used Observables to redesign their web API architecture.
ReactiveX certainly seems like a clean and powerful abstraction, but I don't see the di... |
I have a car maintenance garage program that has an abstract Vehicle class that has several derived classes like Car MotorCycle, etc. Each of those derived vehicles in turn is either a fuel or an electric vehicle. So instead of having a FuelCar, ElectricCar, FuelMotorCycle, ElectricMotorCycle etc, I'm trying to impleme... |
Let's say i have two class named Object (base class) and an actor class (derived class). The actor class uses physics so i need to implement it on the Actor class. But there are other derived class of the "Object" class that don't use physics so i don't want to have physics implemented on them because it would be usele... |
For the fields that you have as encapsulated members of a class, does it make sense to declare their type to be of the interface that you are using? For example:
public class PayrollInfo
{
private Map<String, Employee> employees;
public PayrollInfo()
{
employees = new HashMap<>();
}
}
This gives you max... |
I'm in RFP phase working with outsourcing vendors on the 100% rewrite of a fully operational prototype asp.net app that I wrote, to make it commercially viable.
I have an idea for a project design and I'd like some feedback on whether it makes sense. In summary it is to write the JS and the server software in paralle... |
I have a question about software modeling terminology, when modeling time.
Say you have a repeating schedule MWF 4-5 p.m.
What do you call Monday 4-5 p.m.? What's the term for that?
using System;
namespace myproject.biz
{
public class ScheduleComponent
{
public DayOfWeek DayOfWeek;
public TimeSpan StartTim... |
Why does c# compiler force an abstract class to define (as opposed to implement) all the methods of the inherited interface ? why does it not mark unimplemented methods of an inherited interface as abstract on its own ?
I'm unable to appreciate this constraint, Is it because the language designers wanted the programme... |
I'm in RFP phase on a 100% re-code of a fully functional asp.net prototype. The prototype was reverse-spec'd into a detailed requirements document and a full set of wireframes.
I can understand the need for a database designer, however, who should be doing the application module architecture? And I'm meaning that at ... |
I have a project which involves using C++ files along with an API on a local PC to communicate with a remote server app, and for sake of maintaining a semblance of non-disclosure with any hired developer(s), I'd like to 'mask' the context of the logic by renaming all variables to something less-obvious.
However, the lo... |
I'm working on wrapping a C++ API which provides access to a data store (Hazelcast) in C functions, so that the data store can also be accessed from C-only code.
The Hazelcast C++ API for the Map datastructure looks like this:
auto map = hazelcastClient->client->getMap<int, string>(mapName);
map.put(key, value);
It m... |
My question is more about the transformation from programming code to control flow graph.
Say, I have a piece of code:
public class Contractor
{
// other member fields...
private bool isVerified;
private int noOfA;
private int noOfB;
// other member methods...
public int GetNumberOfDependents... |
I am trying to understand the advantages and disadvantages of a Foreign Function Interface (FFI) (in which the high-level languagd can call most C functions directly and can manipulate C data structures) vs. a C/C++/etc. API, in which the native function is passed runtime-specific data structures and must use runtime-p... |
I have built a simple authentication system for my web application that makes use of the open-source time-based OTP algorithm (RFC 6238). The key for each user is generated when the user is registered in the system. When the user first signs into their account, they are asked to set up their authenticator apps with the... |
By "real" I mean Exceptions that would work as the ones predefined by the system.
I mean for a custom exception you have to use the reserved word throw CustomException once you have checked the condition that might cause the Exception, but if you have done that there's not that big o f a need to throw the Exception, yo... |
I have a perfectly parallel function that would run great on a machine with 1024 cores and 4GB RAM. There's quite a lot of branching (doing set union and traversing structs). There is no communication between threads (except when the whole calculation is complete). Each thread needs less than 1MB of private memory, and... |
Questions
I am trying to understand whether Rust fundamentally and sufficiently improves upon the concurrency facilities of C++ so that to decide if I should spend the time to learn Rust.
Specifically, how does idiomatic Rust improve upon, or at any rate diverge from, the concurrency facilities of idiomatic C++?
Is the... |
I have been looking at AWS Elastic Beanstalk service for the deploymeny of my rails application, and I came to think it was actually a bad idea given some specific requirements of my application.
But then, it is still quite a pain to configure manually the other services that provide scaling/elasticity, so I would like... |
I have been reading on the internet about the metric "number of bugs per 1000 lines of code" and what would be a good number.
However, I wonder how someone would compute such a metric? The reason a bug is in there is that nobody has found it. And testing can't show you that there are no more bugs.
You may assume that ... |
Example case:
You have a truck, that can hold 2.8m by 3.2m by 16m of storage capacity.
You you get a bunch of physical objects you want to store in that truck.
These objects are not always cubic, but sometimes rounded, or have concave shapes.
The problem to solve
I want to implement an algorithm, that finds the optimal... |
I am working on a project that involves a "team builder" type application, if you will using C#.
For the sake of simplicity, let us say it involves the user creating a "Team." There are three teams to choose from.
Each team has "positions," for example, such as Captain, Shooter and Runner.
Each Captain has 3 possible ... |
I have two classes. The first, called Game_Events, controls the objects and manages the general tasks. The second, called Button, is for one of those object instances.
The example below is wrong but shows how I want to do it:
class Button
{
public:
Button(void (*f)()) : f_m(f)
~Button(){}
private:
... |
The Vertical Bar Operator (|) is used in a variety of constants to mean OR in some way:
C-style languages use a | b to mean bitwise OR of a and b, a || b to mean logical OR of a and b.
Regular expressions use a|b to mean match with a or match with b.
Context Free Grammars use x := a | b in much the same sense as regexe... |
I want to use an existing project as a starting point for a new project by copying or cloning it.
There are at least two ways of doing this.
Method 1: Copy it.
cp -R /path/to/source /path/to/dest
and
Method 2: Clone it.
git clone /path/to/source
What are the relative advantages and disadvantages of each approach ... |
I want to know if there's a way or known way to implement this:
Lets say I have:
a C# WinForms program
a Javascript Mobile Application (Android / iOS)
What I want to do is:
for my C# application to show a one-time use (disposable) code or token.
The user enters the code or token in the mobile app
The code is no lon... |
simple question, I want to know if there's a word/term used to describe the collection/pair of a key and value in a C# Dictionary.
|
Regarding GPL software use in a commercial project, I have the following situation:
I would like to commercially distribute an Excel-Macro application,
which uses a GPL licensed software (G77 compiler) and some Fortran codes.
The Macro and Fortran codes are all written by myself. No changes are made
to any of the GPL s... |
I'm writing a small application in TypeScript that has to do some asynchronous operation and I'm doing it with Promise and async/await sugar. But my problem do not rely on the particular language or asynchronicity strategy.
The operation are both I/O and network operation, something like:
every 2 minutes find a suitab... |
Our API accepts PUT requests in order to change status of resources. Think of this as a state machine. Client can specify the target state of the resource via PUT request but it is possible that the resource is not in a state from where it can go into the target state specified by the client. What HTTP code should we r... |
I would like to know if it is possible to include source code licensed under:
Mozilla Public License (MPL) version 2.0
In a project licensed with:
The MIT License (MIT)
If yes I would like to ask:
Can I modify the code from MPL, but keeping their credits?
|
Suppose that I have a Java code base and I want to be able to execute multiple tasks that are based on this same base:
Run an embedded Jetty web server.
Run a one-time initialization of database (creation, seed, etc.)
Run a cron-scheduled maintenance operation (cleanup, backup, etc.)
Maybe more ...
I was thinking abo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.