instruction stringlengths 34 36.1k |
|---|
Often in modeling, data processing, and optimization; the intensive portions of the code can often reduce to solving a lot of linear equations.
e.g.
solve for x1 in A x1 = b1
solve for x2 in A x2 = b2
... and so on
Sometimes the matrix 'A' doesn't change between computations, and my question is how (and when) can I ta... |
I am looking to take a product of a large number of transpositions, and boil it down to a smaller number of products. I have the following code, and would like some input on efficient ways to boil these products down. Before I give the code, it is important to recognize the following:
Transpositions, a cyclic permutati... |
We are building several applications that will eventually be one front-end application. It is split up into several projects at the moment where each project is managed by its own scrum team.
The older applications were built on Angular 1, while the newer ones were built on React. The result is inconsistency in the loo... |
I recently took an exam for the introductory course on Computer Science. One question was about sequence diagrams (very simple example, boiled down to its essentials):
The Bank object sends a message withdraw(100) to the Account object. In the message, 100 is called a parameter. True or false?
Being a Java programme... |
I have a bunch of microservices whose functionality I expose through a REST API according to the API Gateway pattern. As these microservices are Spring Boot applications, I am using Spring AMQP to achieve RPC-style synchronous communication between these microservices. Things have been going smooth so far. However, the... |
I have several uncommon questions related to the design of REST services hosted on a server communicating with local or remote applications.
As an example, let's say that I have 2 machines ("A" and "B") located in two different countries.
The machine "A" host a server that run a REST endpoint (=ip adress with an assoc... |
We have just started to work with React and some of my team mates proposed to split the components in 3 types (each one in its specific folder):
components: reusable components like buttons, inputs and anything that would make sense as an open source shared component
screens: pages of the application
blocks: component... |
Basically, I have a blog where I want to add a rating system, which will allow users to rate each post on a scale from 1 to 5. I do not want the users to sign in, as that is too much hassle from my part. However, I also want to save some of the ratings.
For instance, lets say X is a user who rated an article 3/5. When ... |
I have heard that nesting try-catch statements can often be a code smell, so I'm wondering whether this situation is an exception. If not, what would be some good ways to refactor?
My code looks like the following:
try{
X x = blah;
otherStuff;
for (int i = 0; i < N; i++){
try{
String y =... |
I have a project structure like this:
My Project
- Other Team's Project
-Third Party Dependency
My Project requires Other Team's Project to function, and both My Project and Other Team's Project require Third Party Dependency to function. We are using a dependency management system to manage these.
From a desig... |
Problem at hand:
Finding separate subgraphs. Update on adding or removing edges.
First I've been thinking about running DFS after every operation from both ends of the edge, but if I keep information about subgraph in the vertices, then adding edge is O(1); you just join subgraphs of both ends.
Now, if I wanted to remo... |
When designing REST endpoints idempotency is a crucial tool. Say we have a HTTP endpoint accepting PUT which we would like to be idempotent.
In case a client makes the same request multiple times, should the server always return the same, or is it acceptable to return an error the second time?
If the answer is yes is ... |
I am writing a Java library that needs to make http GET && POST requests. There will be two types of users of this library:
Those with understanding of callbacks and know how to use them.
Those that....don't.
So please consider the following two methods:
public void methodWithCallback(ServiceCallback callback) {
... |
I am a build manager and release engineer with a programming/SW dev background. I manage build scripts and makefiles for our SW team on our project to produce different versions of releases and I thoroughly enjoy my job especially the automation and optimization aspects of it, even though I do not get to write product... |
So, I was thinking about writing custom exceptions today, and considered the invalid operation exception. This exception can mean many many things, and in some actions, the operations might be invalid due to multiple independent causes. Consider this example. (And yes, I know that an ArgumentException would be better h... |
I am using a 3rd party API which yields JSON which has two ways of loading data - as a list of items, or as a singular item. The problem is that a given item in the list has different properties than the same item if you load it as an individual. The two load methods yield items which are similar, but different.
For ... |
I'm looking for some input on how to keep certain benefits of both a binary file and a SQL database in an interesting data storage problem.
I have a legacy custom binary file format that is essentially several hundred multi-dimensional arrays that are serialized to a file with fwrite()'s in C. Each file is a fixed siz... |
I have to design for a bunch of user control types, each of which share some common properties but some of which have special unique properties.
For example, the common properties across all the controls would be title, caption, field length, etc. But for specific types like Dropdown, FileUpload, apart from common pr... |
I work in the IT function at a large retailer and we have just started a project with the business to redesign a key system for our Website.
The business users know they want to update the system and improve it. They have some very very high level principles around how it should work but that's about it.
Management w... |
We want to allocate a Int32 value for a coming new GUID, which is not exist in our system.
One solution is to use auto-incremental Id in Mysql, but it's not convenient for later usages. Another method is to use a Hash function, to hash the GUID string to a Int32, but 32bit is too short to avoid high hash collision.
An... |
I'm facing a design problem with Spring's profile and Maven multimodule project from which i'm building a product, as a web as application that can be customized for differents clients. For this i need quite some organization of my code, this is why i'm seaking advises on how to organises my profiles around my code.
At... |
I'm interested in how calling Console.WriteLine() actually displays text.
I've had a look at the source code from:
http://referencesource.microsoft.com/#mscorlib/system/io/textwriter.cs,5f99350fdf8dae53
and can see that this method from TextWriter ends up getting called:
// Writes a character to the text stream... |
The .NET Framework CLR files are located in the following folders under C:\Windows\Microsoft.NET\Framework:
v1.0.3705
v1.1.4322
v2.0.50727
v4.0.30319
(Yes, there's v3.0 and v3.5 as well, but they contain only additional libraries, not the CLR.)
Note that the framework versions .NET 4.0, 4.5, 4.5.1, 4.5.2, 4.6 and 4.6.... |
I have been asked to create a filtering functionality for e-commerce application written in PHP. Since the app is using MySQL database, I made the decision to use Elasticsearch with Logstash and Kibana.
Now this part is clear, using Logstash to transfer data from MySQL to Elasticsearch and then using Elasticsearch php ... |
I have this small code:
int* array_int = new int[10];
array_int[0] = 1;
array_int[1] = 2;
array_int[2] = 3;
array_int[3] = 4;
array_int[4] = 5;
array_int[5] = 6;
array_int[6] = 7;
array_int[7] = 8;
array_int[8] = 9;
array_int[9] = 10;
print(array_int);
print(array_int + ... |
Should Erlang systems (or anything running on the BEAM VM) be monolithic, i.e. everything running in the same distributed application, or should they be split into multiple microservices like any python/go/c++ shop would do?
Since each process in Erlang has its own memory space, it seems like they behave like microser... |
I am developing a RESTful API and I think it is convenient to use DAOs for my resources because although I plan on just using memory to store them, I don't want to close a door to whoever is using my library if they decided to use a database implementation for the DAO.
My question is whether the DAO should be a singlet... |
We inherited a large ASP.NET website built entirely in WebForms. The website has over 200 pages, spread across 60 WebForms projects inside of the website's solution. About half of the pages are static content while the other half has a varied amount of server side complexity, mainly data capture and display. There is n... |
I am developing a RESTful API and I am using DAOs to serve data to the service.
I am having trouble deciding where certain responsibilities should fall, whether in the service or in the DAO contract. Or not just responsibilities but just deciding what each component should do or should not do.
In the scenario of the CR... |
Given these example REST API / HATEOAS applications:
InfoQ How to GET a Cup of Coffee example
Java Spring REST API example
... where POST/PUT/PATCHING resources clearly alters the state/availability of (other) resources — for example in:
(REST example API 1)
PUT /order/1234 HTTP/1.1
...
<order>
...
<status>prep... |
I know that assembler is the one which converts to machine code. So here in 8085 instruction set LDA has opcode "3A". My question is how assembler convert mnemonics to opcode and finally to machine code.
How LdA mnemonic is converted to 3A hex code
If I come up with a new architecture and new instruction set. How the... |
In this short article Public versus Published
Interfaces from 2002, Martin Fowler distinguishes between easily changeable "public interfaces" and harder to change "published interfaces":
The key difference is being able to find
and change the code that uses an interface.
For a published interface, this isn’t possi... |
Recently I have come across this article, which claims that "low-code" development is very important in the rapidly changing world of software engineering. I got the idea that "low-code" has something to do with high-level programming and small sized code, but without a formal definition of what it actually is, the con... |
We have a rather large code base that interacts with many SOAP based XML services.
Each one of these services makes 1 to n service calls A typical low level web service call looks like this (simplified):
public XElement ExecuteWebService(string xmlRequest)
We use WCF to build the SOAP message send it and get back t... |
After doing some investigation* I have learned that I could potentially have a concurrency problem.
I'm currently building a Tournament Platform in ASP.NET MVC 5 with Entity Framework 6. So far, I've never had concurrency problems (Mostly because they fell into the overly-optimistic scenario). I ask money for people t... |
I'm creating a 3-tier Web API application based on the Azure guide here. This has a middle tier and a data tier both in Web API.
So far my application is pretty simple, the middle tier receives a request, translates it to the domain model, passes it to the data tier which performs a CRUD operation which is then passed ... |
I hate referencing paywalled content, but this video shows exactly what I'm talking about. Precisely 12 minutes in Robert Martin looks at this:
And says "One of my favorite things to do is getting rid of useless braces" as he turns it into this:
A long time ago, in an education far far away, I was taught not to do th... |
I am struggling to understand the design of an Oracle database that I have been working with for the past 9 months. The database is for our business management system and I work with it mostly for reporting and data warehousing.
The database has just over 5,000 tables (not all of them are being used) and so when I star... |
Would a value such as monthly cost from source data be represented as a fact?
If yes, how would a date dimension table be designed around that fact?
|
I've been trying to design a program in Java (because I might need to create an app that does the controlling part) with GUI that can run scripts on a few local computers.
It should do the following:
Client: It should just listen for incoming connections, and accept them from a specific port and IP. When a connection i... |
In the example below, I have a Person class and class B that holds a reference to a Person.
Person has a public foo1 method that can alter its state (it's a mutable object).
Suppose clients of class B want to know the salary, name and email of person object. Should I rewrite the getters from Person class in class B (wi... |
I was looking at the type of map for Try[T] in Scala, which is:
def map[S](f: T=>S): Try[S]
From Haskell, I am used to the type of map being:
map :: (a->b)->[a]->[b]
This seems very logical. Map takes a function and a group of elements and applies that function over all elements of the set.
However, I don't understan... |
I've worked for a few companies and even developed projects on my own - these projects were based on Java Enterprise Edition. Sometimes with Spring Framework involved, sometimes it was a pure JEE. However, building Java-based applications has one major flaw for me - too many heterogenous environments.
Different applic... |
I'm really struggling to understand git, so here's a tighter rephrasing of a previous question I had asked. I'm going to explain a hypothetical scenario, detailing what I think happens when you download some code using git and install it on a machine, and hopefully somebody can tell me which part I am incorrect about!
... |
Here is my question.
class Gen<T> {
T ob;
Gen() {
ob = new T(); // Illegal!!!
}
}
Why is it illegal? Could you please explain it.
|
I was looking at this lecture, https://class.coursera.org/reactive-002/lecture/135 at 2:15.
The lecturer talks about the duality of Future and Try in Scala. For his demonstration he changes the type:
(Try[T] => Unit) => Unit
into:
Unit => (Unit => Try[T])
and he says something about duality(which I'm not familiar wit... |
What i mean is something like:
I have 2 array var and type, you can input the name of the variable on the var array and type of variable on the type array(type depend on language used), then i want to use the value from these array to define varriable i.e:
Var[1] as type[1]
Var[2] as type[2]
Is it possible to do someth... |
I'd like to use the MIT License for a project I'm working on. Most of the files in the repository are mine but 1 had to be copied from another open-source project (also under the MIT License).
What should I do to indicate that the copyright notice in the license excludes certain files that I did not write?
|
I am working on a project that will scrape data from roughly about 6,000 websites. I am considering using a server/client model in which the server is responsible for scraping the data and importing them into a database while the client accesses the data.
To scrape the data, I am considering using a html parser like Ht... |
I'm reading a paper about the actor model and they describe how a fork-join behaviour can be implemented using it:
Let us consider how a system of actors, when requested to calculate some value, can split up the load among themselves and combine the results to form the final answer. Actor F receives a request
messag... |
I wrote a library in Python and I want to have an EULA and agreement box to pop up upon opening the program for the first time, but I don't have a lawyer. I don't know much about terms and conditions, licensing, privacy policies, etc. I picked around on the web and I decided to use the LGPL 3.0 license (Lesser General ... |
A small company without any IT skills wants to run a web application where customers can enter various bits of data and upload pdfs.
The documents regard product specifications and have to be kept secure.
They have one external IT guy who wants to sell them a PHP application for the task. He wants to store the document... |
I am hoping for some advice on how best to perform a particular bitbucket/git maneuver which will fork a repo back to a team from which it was previously forked.
Let's call it Repo R, originally in the Untitled Projects project of Team T.
Some months ago, Repo R was forked to User U's personal account, who worked on i... |
I have been using Python for a fairly long time and now I want to modify a Python library to fit my needs.
There are two ways to do this as far as I know. One is to modify the source code itself. Other is to write a wrapper around the original library.
But I don't understand which is better, doing what is a good pract... |
I'm into creating a php based web chatting system.
About 1000 concurrent users across the world will be using it, so what would be the best tech to deploy?
As I did some research online, mainly I found systems using ajax and jquery for chatting while there're some using web sockets. I'm not sure as to which would work... |
django.contrib.auth has User and Group models. I'm using the User model for my users, and the Group model to manage their broad permissions (access to admin site, access logs, etc).
I also have my own Client model (representing a business client corporate entity). Let's say I'm going to have many clients, and I don't ... |
I implemented sync for my app (with a REST backend), it works well but there are some problems:
Blocks - Since I don't want to overwrite possible inputs of the user during sync, I block the UI (progress overlay) during sync. This of course affects negatively the user experience.
Size - If the data is large the request... |
So I'm responsible for maintaining and enhancing a PHP codebase that runs to around 1,100 files and 120,000 lines of code.
In general, it's not terrible, although since it was written over some 10+ years starting in the PHP 4 era, some parts are more terrible than others. However, this entire codebase has a grand tota... |
In Ruby, is there a standard class or gem to work with dates that can be - but are not required to be - historical in nature? The dates have precision (to the nearest million years, decade, century, year, month, second, etc). For example:
20th century
2000's
5th century, BCE
1920's
June, 1945
4.6 million years ago
19... |
I'm looking for suggestions on how to read large Javascript codebases, for example, of a framework. For example, let's say P5js, but this applies to any large framework (i.e like AngularJS, Ember, etc)
My goal is to be able to look through a Javascript framework's source code and be able to understand what various func... |
Case1: There are two snippets of code that are very similar and very gzip-able, one at the start of the document and the other is beyond 32kb at the end of the document. Does the minifier bring the two snippets together so that gzip will reach the second snippet?
Case 2: A snippet of code is used multiple times. Gzip r... |
I have a sample code here:
Dim a As Boolean = False
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If a = True Then
Console.WriteLine("Example of a task that needs to be done during tick event")
End If
End Sub
You can see there that I have a timer tick event, but the eve... |
I really like the concept of assertions in Java in the way how to use them. It's much easier than to write an if and then throw an Exception/Error.
But the thing I don't understand is, why do they need to get enabled with -ea to work? That makes them unreliable and that's the reason I don't use them. What is the purpos... |
I'm drawing an activity diagramm and I'd like to know how draw a timed trigger. My process is that when a task is created it should be done immediatly when it has a high priority or once a week if it has a normal priority.
I know there is the time signal symbol but in all examples I saw it's combined with the joinsymbo... |
Here's a skeleton of a class I built that loops through and deduplicates data - it's in C# but the principles of the question aren't language specific.
public static void DedupeFile(FileContents fc)
{
BuildNameKeys(fc);
SetExactDuplicates(fc);
FuzzyMatching(fc);
}
// algorithm to calculate fuzzy similarity... |
Recently I have come across with another way of writing a function expression, like this: setTimeout(() =>{/*code*/},1000); as opposed to: setTimeout(function(){/*code*/},1000);
What is the benefit of using () = > rather than function(){}
Can I use it all the time or only in the certain situations?
Thanks.
|
Let's say I have a function (written in Ruby, but should be understandable by everyone):
def am_I_old_enough?(name = 'filip')
person = Person::API.new(name)
if person.male?
return person.age > 21
else
return person.age > 18
end
end
In unit testing I would create four tests to cover all scenario... |
I have a large customer facing web applicaton (.net mvc if that matters) that I need to split down to a number of services. Some of these services will then be shared with other applications.
At the moment all of the servers I have are part of a web cluster that we use for this app, though this may change in the future... |
I am reading the book "Learning TypeScript" by Remo Jansen. In one section the author describes how to create a very simple proof-of-concept MVC framework including how to create the Model class and says the following:
A model needs to be provided with the URL of the web service that it consumes. We are going to use a... |
We will implement a system , which will receive quite a lot of requests through web service interface. We will have to queue the requests and process them asynchronously. Consequently we will have to have also some output queue with responses (QR).
The web service client will have the possibility to query his (and only... |
So here is the use case:
You have users and they have many addresses. Say you want to filter and eager load on addresses (say...only US addresses). In order to do so you have to filter the eager load AND filter using whereHas so your result set is only those users with US addresses and only their US addresses are retu... |
I am working on an API in C#. I am trying to think about the simplest way to expose my API for consumers of it. In particular, I have a class in my exposed data model that has a dictionary property. I'm trying to decide if the dictionary property should use strings as keys or an enum that I define as keys.
My concer... |
I'm very new to ruby. I have to code in ruby at work and a coworker gave me some tests he wrote in ruby. I have some difficulties to understand a line he wrote.
We have a class like this:
class Port
attr_accessor :nature, :name
def initialize(name)
@name = name
end
end
The test consists in:
x_port... |
here's the problem.
I have developed an Azure-Based Web application which exploits some VMs. On top of these VMs I'm running a modified code which is licensed under the GPL license. Here's the flow:
Now, I would like to sell the access to the WEB-APP in the form of a private login to some customers.
1) Is there any li... |
I have two separate inheritance hierarchies that represent objects that can be "matched" to each other to consitute a FooBarMatch (which contains references to the matched FooBase and Bar partners):
_____________
| FooBarMatch |
|-------------|... |
I have a few questions about how to implement models and what the results are of those implementations:
When I only need a few variables set, isn't it memory consuming to
create an entire object? E.g. an entire site_object just to pass on
site_id's and site_names?
Is it considered to be good practice to put all the da... |
I won't explain what backtracking is, Wikipedia article does it well enough.
Backtracking solver is usually implemented using recursive function that traverses a tree of potential candidates that is discovered at the same time.
Now that function can return early when it finds the first solution or traverse the whole tr... |
I come from a C# background, where LINQ evolved into Rx.NET, but always had some interest in FP. After some introduction to monads and some side-projects in F#, I was ready to try and step to the next level.
Now, after several talks on the free monad from people from Scala, and multiple writeups in Haskell, or F#, I ha... |
It is not unlikely that what I want to do is not possible, but it doesn't hurt to ask.
Imagine a set of lists, each containing positive integers (in my case, a list always consists of four integers, but that shouldn't make any difference).
a = [35, 2, 123684, 647]
b = [453, 346457546457, 6, 0]
c = ...
Then there is an... |
We are a Microsoft shop, developing with Visual Studio. We are building a single page app, and we have elected to use Gulp to handle a lot of the script build tasks (javascript minification, css minification, etc).
We are using typescript, and the thing I find intriguing is that I can use Visual Studio (and MSBuild fr... |
I am a high school student working on a C# project with a friend of mine with about the same skill level as me. So far, we have written roughly 3,000 lines of code and 250 lines of test code in a span of 100 commits. Due to school, I put off the project for a few months and recently I was able to pick it back up again.... |
Let's say I am developing a program for Windows. What are some things I can / can't do if I want it to be usable for 32 / 64 bit platforms?
|
I need some help in answering questions
This is Sprint 1 and I have a 2 week sprint with the first week completed and the current burndown chart looks like:
Day 1 with 50 Story points
Day 2 with 57 Story points
Day 3 with 50 Story points
Day 4 with 34 Story points
Day 5 with 25 Story points
It is assumed that wor... |
The requirement is that once the product has been delivered, user can update the logic as he wants.
An example of logic I have is follows-
An institute teaches English has following requirements -
At the time of registration student can choose either Writing or Reading or both.
Student can choose Speaking only if it ... |
I'm currently refactoring on an older project, which has classes that expose both a single object and also multiple properties from that object. Ex:
public class Foo
{
private MyObj myObj;
public IMyObj Bar
{
get
{
return myObj;
}
}
public int So... |
DevOps means developers now take responsibility for infrastructure and release - but what are the drivers behind this change?
I'll put my cards on the table: I am a developer and having worked in both "DevOps" and non- cultures. Having to worry about infrastructure and releases and QA and the associated ceremony is a h... |
I need some help in answering this question
Some Info on the diagram
On the left it says "Your wait time from here is about 14/18 days"
The numbers at the bottom of the columns are the maximum number of
Kanban cards allowed in each column
Little's Law states that:
The long-term average number of customers in a stab... |
I have a model class like below. I need to edit items, but the model has to know when any object has been modified. Also I need to provide very often with the objects inside to the view, which is who's going to eventually edit them. That's why I need an edit method but I don't know a proper way to do it.
public class C... |
I have a large image distributed over multiple machines for which I need to implement the flood fill algorithm used in MS Paint. I am able to do it with a single machine but what approach must be followed for multiple machines.
|
Let's say I have some library "foo" and I have it listed as dependency of my project. For example in Python I have requirements file saying
foo==1.0
foo library needs "bar" library and it lists it as dependency. At one point I realize "bar" can be useful for my project too, and I have an idea of calling some function ... |
I have been building a personal framework of mine which started off as a way to learn the MVC pattern and has progressed now into something that I like more than most frameworks out there (which is probably because I add what I like and change what I don't like but nevertheless) and for good or bad I use it in some pro... |
In this thread it is discussed if it is legally possible to take on open source project and close its sources. But this seems to refer to someone else's project.
So, my question is: What about my own source? Let's say I release the first version as open source, then I make some changes and I want the code from now on t... |
Initially I needed only one queue to be created by the MessageQueueFactory:
container.RegisterSingleton<IMessageQueueFactory>(() => {
var uploadedWaybillsQueuePath = ConfigurationManager
.AppSettings["msmq:UploadedDocumentsQueuePath"];
return new MessageQueueFactory(uploadedWaybillsQueuePath);
});
Now ... |
Q.1 I know that when we are talking about synchronous HTTP, for each request a Thread may be spawn and get blocked, so when number of simultaneous connections increase, we will encounter massive thread overhead. Asynchronous mode will tolerate some overhead polling responses for something desired, but number of Threads... |
What JSON format is a better choice for key value pairs and why?
[{"key1": "value1"}, {"key2": "value2"}]
Or:
[{"Name": "key1", "Value": "value1"}, {"Name": "key2", "Value": "value2"}]
Or:
{"key1": "value1", "key2": "value2"}
The first variant seems more compact and more "semantically meaningful". The second variant... |
I'm developing a website with some simple HTML exercises (like the ones in Codeschool and Codacademy), and now I'm stuck at the correction phase, how can I compare two HTML strings and decide if the user has submitted a correct one?
For example, suppose we have the correct answer as:
<h1>Hello World</h1>
<h2>Welcome</... |
I am considering learning C.
But why do people use C (or C++) if it can be used 'dangerously'?
By dangerous, I mean with pointers and other similar stuff.
Like the Stack Overflow question Why is the gets function so dangerous that it should not be used?. Why do programmers not just use Java or Python or another compil... |
I want to add some extra methods closely related to Book without extending Book. So I found the decorator pattern.
Most examples I have seen are eg. extending an abstract decorator class which implements an interface etc.
I am wondering if this could be considered as decorator pattern?
class Book { ... }
class MyBookD... |
I want to use two particular open-source libraries, in unmodified form, as dependencies of a project. One of the libraries is published under the MIT license; the other library is published under the Mozilla Public License version 2.0. The project itself is licensed under the Apache Public License version 2.0.
Can I ... |
I'm considering a hash function for a tuple of and maximum-valued integers for example (3 ,2, 5 ) -- where each element of the tuple has some maximum value N.
My plan is to treat the elements of the tuple as the digits of a number in base N, so that in the trivial case of N = 10 the tuple(3 ,2, 5 ) hashes to 325, or 21... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.