instruction
stringlengths
34
36.1k
I am writing a Web application for copying files between servers. I decided to write a WebSocket server which will receive and send relevant messages (that is communicate with a browser), start and stop copying processes. Accordingly my design decision, there is at most one copying process for a given user. A user does...
Consider this example class which in encrypting some data and sending it to some other service. Consider the test for redirect method. This is how you consume the class: <?php $safeLink = new SafeLink('some_secret_key'); $safeLink->redirect('http://external.service.com/receiver.php', $someData); and the class is smt....
I don't understand the connection between type inference and advanced type systems. I don't see why Haskell or Standard ML or OCaml could not have existed without type inference. My only guess is that type inference might have been a trend in the 70s when ML first came out and the descendent languages simply kept that ...
Everytime I press a certain button, it should remove a random index from a dictionary and then save that dictionary everytime its modified. I have done this using NSUserDefaults. I have found that all the info persists even after turning the app off and back on. Although, when I delete the app from the simulator or ex...
In C++ Is using this->data slower than data ?
I could not think of a better name. I have a class called MoveObjects which holds position and move info. Then I have two classes, Items and Attacks. Both have MoveObjects in common. What I am trying to do, is loop through move objects and the loop determine if it is associated with a Item or Attack. Basically (but can...
As a comment on a response to this question, someone says: It is not advisable to put the password in the URL for this file is saved on the .git/config . Is not safe, it is better to use ssh key Why? Understanding the password will be visible if I type git remote -v, that it'll show up in my bash history, and that a...
I have great trouble doing recursion, especially trying to visualize it. A great example is the aging wine problem described in the top answer of this link: https://www.quora.com/Are-there-any-good-resources-or-tutorials-for-dynamic-programming-besides-the-TopCoder-tutorial. In the example, you are tasked with finding ...
As you know SQL doesn't have arrays. So if you make a table "article" and wish to have comments on your articles I presume you would make another table "comment". Inside "comment" table you have the content and a foreign key named "article_id" which points to the article's id. So to get all of the article comments you ...
How do I know if my code is running fast enough? Is there a measurable way to test the speed & performance of my code? For example, I have script that is reading CSV files and writing new CSV files while using Numpy to calculate statistics. Below, I'm using cProfiler for my Python script but after seeing resulting sta...
What are some good practices to do error management in a web application of about 30 people divided into 5 people team, where each team is responsible of a specific part of the application? I am looking for answers on: How do you make sure that new errors get addressed or triaged? How do you make sure that current err...
As someone used to C++ and new to JavaScript, I find this behavior odd. Whether a program runs directly on the platform like C++ ones, or it runs at a higher (or deeper?) level like JavaScript ones, conceptually, a program a program and an exception is an exception. Then why does JavaScript have this behavior? Is JavaS...
While curiosing on the main page of a scripting programming language's site, I encountered this passage: When a system gets too big to keep in your head, you can add static types. This made me remember that in many religious wars between static, compiled languages (like Java) and dynamic, interpreted languages (mainl...
All languages I have seen so far have multiple builtin data types (int, double, float, char, long...). But if we look closely, they are just arbitrary arrays of bits, the only difference between them are their methods (addition, dividing, toString, etc.). So why did all those programming languages decided to provide m...
On pages 136 and 137 in The Clean Coder, Robert C. Martin describes how chips could be independently deployed thanks to a vtable: The solution was pretty simple. Each chip had to be decoupled from all the others. Each had to be turned into an independent compilation unit that could be burned independently of all t...
I've been reading the C++ for dummies book and I'm loving it! I'm on the section where he is talking about short circuit evaluation. Here is my understanding of short circuit evaluation. Short circuit evaluation is only applied to bitwise operators, for example AND && and OR ||. So if condition1 is not true then the ...
I have been studying software architecture and design patterns for the past weeks, and for a week now I can't stop thinking about the performance problems that come with the flexibility of the data mapper pattern. In the book written by Martin Fowler, he gives an example of the pattern with some find methods and just o...
Given a list of items, what's the most efficient way of ranking those items with the least number of comparisons? Is there a name for this type of algorithm (that way I can focus my search)? Also, is there a way to do this and receive a partially completed ranking in order (1st, 2nd, etc) that's still near-optimal in t...
I’m creating an app that allows users to post, sell, and purchase items. Every item has a count integer attribute that is set by the initial user and which is reduced by n with each purchase. When count is 0, that item can no longer be sold unless one of the previous user buyers reposts the item they purchased: in whic...
I am building a web spider to crawl through several different sites, but one of them uses javascript buttons instead of links for several functions. And while I could learn to follow them, it adds an extra layer of complexity I would rather avoid if possible. But, on the other hand, the mobile site, easily accessible w...
I'm building an app for slack. While I've completed the POC, and everything works well for a single instance of the app, I'm having an issue of wrapping my mind around the scaling of it. The specific issue is this: the app utilizes the slackbot. A slackbot is a node.js app that opens a websocket to Slack with the rel...
I have a number x. I know its prime factors and their multiplicity. Does anyone know an algorithm that decomposes it into all possible combination of its divisors (without respect to order)? E.g. x=18 (prime factor , multiplicity): (2,1), (3,2) Decompositions: (18) (1,18) (2,9) (3,6) (1,2,9) (1,3,6) (2,3,3) (1,2,3,3) ...
Since learning object oriented programming I've been confused about how to deal with multiple ways of storing data that have different levels of functionality and efficiency. I'm kind of new to this so I'm probably missing something or approaching this wrong. Say I'm writing a hypothetical image editing program (I'm no...
I am going to create a stock market android app. Stock quotes change every few seconds, so to keep the app updated I decided to implement a reactive functional design. My IDEAL design would be: Everytime that the server has a new value for a stock, the app is passed the new data. Finally, the data is displayed to the ...
I'm currently joining a project in which there's a core REST API already developed which is used for a mobile app. The next step will be to build a web app which should also consume the API. My doubt is in which frameworks would be good for doing something like this. Normally I would use rails, but I'm not quite sure b...
I need to strengthen my OOP skills and hence I thought to implement an Elevator simulator. At first what seem to be a simple design has grown into a complete mess and has left me confused about my knowledge of OOP. Below is the implementation classes. /** * 1. User enter the elevator. * 2. Elevator checks the maximum...
Currently um working in an application and it has the following hierarchy WEB API2 Controllers (hilds the end points) Business Logic Layer (Dedicated for business logic handling ) Data Access Layer (Repositories) If we want to impose a validation which does not related to a business logic as for an example a character ...
I have a MCU-based design that essentially controls other hardware and this MCU is controlled through an app. I was hoping someone could help me figure out how to secure this communication between the app and MCU. I've tried something like SipHash which essentially appends a hash of the message with a plain text messag...
I have a java plugin written for a software called icy. Since the entry point of program is when the plugin is activated from the software, I am having trouble about how to mention that in manifest.mf file. When I give the main class (which has event handler and not the main method) it says resources not found. How ca...
We keep being told we are going to be working in an agile way on a new project by senior management. They have set up stand-ups, sprint planning, retrospectives etc. etc. However, they have now come up with a plan detailing all work they want us to deliver with dates against each element and showcase dates again with w...
I haven't started building my back end yet but I need to now. My needs are the following: Database needs to be holding millions of game information (just info that can be stored in a typical db like match_id, win or loss, hero id #, item id # etc...) Needs to be able to perform a basic division calculation based on c...
Reading Ian Sommervilles's Software engineering, he mentiones there are following interfaces: Paramater interface: data or functions are passed from one component to another Shared memory interface: block of memory is shared between components Procedural interface: interfaces where one component encapsulates a set of ...
I have a class that has several fields which can only be filled consecutively by a lot of calculation. The 1st field can be set very easily. To fill the 2nd field, we take the 1st field's content and calcuate a lot. The 3rd, 4th and 5th field must be calculated together from field1 and field2 (it is not possible to cal...
Recently digitized and turned into a repo, the original Apollo 11 guidance computer source code has been made available for viewing on Github. In MAIN.agc, the repo author comments that they split the huge monolithic source code into smaller, more manageable chunks--i.e., into individual source # files. A bit later, ...
I'm writing an interpreted implementation of a new programming language (just for fun). In this implementation language is first being compiled to an intermediate language, which is then interpreted by an interpreter. Interpreter is written in Mono C#. However I got this idea to translate methods, which return no data ...
I spent a few hours cleaning up a really old Python library, ProxyTypes. Two days from now will mark 10 years since it was updated. Today, I updated it to support the newer Python 3, and to be compliant with the PEP8 style guide. I've stripped out some of the code I don't need, but the functionality and logic of the re...
This is a follow-up question of my previous one: https://stackoverflow.com/questions/38421950/better-class-structure-for-logical-expression-parsing-and-evaluation Brief introduction: rules as strings combinations of logical-and, logical-or, logical-negation and grouping by parenthesis of identifiers (ID's) Example: ...
I am currently rewriting one of my projects in Java and want to implement a service layer that will be used by different clients (CLI/GUI/Web) to communicate with my core application. For now it will mostly just delegate the same calls to the Business Model, but I want to add User authentication later on and I read, th...
I have a bit of a problem regarding implementing Scrum into a project. The team I'm working with is generally just very bad at coming up with ideas. I'm not sure if it's a matter of them not feeling comfortable with the environment or what. I've worked with them before, and they actually work best under a Waterfall de...
I want to sell my source code, it's written in PHP and CodeIgniter. And it's actually a CMS for personal website. My intention is to create only one license for one use only, if someone buy this code and install it on his/her server, then when he/she tries to install it again somewhere else, it can't be done. Software ...
I am currently looking into re-architecture of some of my organization applications. Other questions aside, the one that I am currently trying to figure out the best approach for currently is the application communication. Here's the current thinking: Client Application (UI client) - handles user interaction Admin App...
Today we are working with Stored Procedures to access the database. In order to allow unit testing, we implemented an interface for each group of related stored procedures, for example: ICustomerRepository { GetAllCustomer(); GetCustomerById(); GetEnrolledCustomers(); // etc.. } We plan to implement DDD in all pro...
Let's say you have a software solution that has a data layer that accesses a SQL server. It can do this either directly and also over a HTTP connection. In both cases Datasets are used. Now when migrating away from Datasets to a more modern technical solutions of course using an ORM framework might be the natural choic...
Given k sets ,each contain several elements . I want to split them to two groups , the first group contains m sets ,the second group contain n sets , m + n = k . Let w1 be the sum of the weights of all the elements in the union of the first group of sets . and w2 be the sum of the weights of all the elements in the uni...
I've been recently thinking about the following question: When are requirements good enough for implementation? I'm trying to create a checklist of some sort that can at least semi-objectively answer this question. Here are some of my thoughts about methods and checks to ensure good requirements: Ambiguity Poll (are t...
I'm working on the import of land-use data into Openstreetmap. Unfortunately I've encountered a problem that has delayed my time table. Take a look at the picture below: the red line is the main road (it is correctly mapped using GPS devices). The white area is the region that indicated the presence of the road: it sho...
I frequently come across projects that strictly define an interface for each and every class. 90% of those interfaces feature only a single implementation. Proponents of these "preemptive interfacs" defend this approach as follows: In Java one should always program to interfaces to minimize refactoring efforts, when a...
I am generating a 2D "world map" in Unity which I use C# and Perlin noise for. I have a Tile object that holds the graphic of the tile and position. There are a few more attributes to this class, but they are not of importance here. I have provided the base implementation below: public class Tile() { public GameO...
In gitlab, there is Merge Requests (MR) like in github there is Pull Requests (PR). If the MR is rejected, sure, we close it. But what if the MR is merged ? In that case the button to close the MR stay available. So, what is the right way ? Should we close all MR at the end of the story ? And if so, when to close it ?...
I am looking for advice on how to design the following scenario: I have a 3-dimensional vector class, the entries are of type double. I want two vectors to be considered equal if their corresponding elements differ by less than a given tolerance, e.g. 10^(-10). (Code examples are in C# syntax mixed with pseudocode.) pu...
Given the following code snippet in a Laravel Controller: $this->userRepository->saveByProject( $this->fileRepository->saveByProject( $this->metricRepository->saveByProject( $this->projectRepository->saveByUser( $request->attributes->get('user'), $request->all(), $id ...
Currently we have about 20 solutions. The majority of these have multiple projects, including share utils projects, data access, etc. We've had a few problems where a contractor changed something in a common project and unknowingly this breaks a number of other solutions. We currently have 7 perm developers and 3 lo...
I'm refactoring a huge WPF application whose complexity stems from the way it deals with flow control. It has a lot of "tiny business rules" that make it really difficult to make a modification without breaking something. These rules are things like If the window mode is foo but this is the first time they've pressed ...
Whenever I solve a problem with overlapping subproblems, I reach for memoization because it's so simple to implement. However, memoizing in an immutable language that doesn't have built-in support for memoizing without copying the memory on every insert isn't that efficient. What techniques are common in immutable lan...
I am wondering what is the difference between DDS and AUTOSAR. As I know, both of them are communication middlewares. AUTOSAR WAS originally proposed by a group of car manufacturer that's why I guess should be much more suitable for intra-vehicle communications. DDS was proposed for military and critical-mission use ca...
I'm about to fork an MIT licenced project, I'm planning to use it as a starter. I was wondering how I have to handle the licence. What I understand When I will mimifie my javascript application, I'll have to include Copyright 201x (c) Original Owner in the header. Questions Can I modify the LICENCE file to include m...
Question: For a 16 bit word with 6 bits for an opcode How many different instructions could I fit into the instruction set? What is the largest number that I could use as data? Answer: Number of instructions: 26 = 64 largest operand: 210 - 1 = 1023 Source My question is how did they calculated 210 from 16 bit wor...
I wrote a supersuccessful answer to a question on an SE site that got (at least) 21 upvotes in a 24-hour period. In theory, I should have gotten 210 rep points, but there is a daily reputation limit of 200 points (20 upvotes) on a single site, so my daily score was capped at 200. This much I understand. Then I received...
I am doing a summer assignment for AP Computer Science. For this I am learning about different number base systems and how to convert them. These topics led to me wondering about why programmers use different number base systems. So I was wondering Why do programmers use different number base systems? Why not use the f...
I'd like to be able to request Linux to schedule two or more threads in the same time. I mean today when my multi-threaded program is being executed I know that in worst case only one of my threads is being physically executed (scheduled) at a time. Now I'd like to tell Linux: here is the list of thread Ids, please tr...
Why do we use normal form(like Conjuctive Normal Form and Disjunctive Normal Form) in Artificial intelligence?What is the specific purpose of Making a sentence in Normal Forms?
I have been studying DDD for 1.5 weeks now, and I came a cross the use of the Unit Of Work pattern together with Data Mapper pattern. I understood why they are both important and when to use them but, I couldn't find anywhere how the Data Mapper can "know" that a save method, for example, was called in the middle of a ...
I'd like to design a robust version of this class (C++11): class Oscillator { private: std::vector<double> trajectory_; // Some numbers that are needed to get the trajectory double xinit_; double vinit_; double omega_; public: Oscillator(double xinit, double vinit, double omega): xini...
From Roy Fielding's comment on his own article decrying fake REST apis: A truly RESTful API looks like hypertext. Every addressable unit of information carries an address, either explicitly (e.g., link and id attributes) or implicitly (e.g., derived from the media type definition and representation structure). Q...
In larger projects, there can often be a group of tests that test the functionality of related classes. These tests often share a lot of setup and preparation functionality. What happens then is that a base class is defined for these test cases so that they can share there instance fields and common functionality. Thi...
Problem description I have a situation where I want to enforce that a relationship can only be defined once and I want to solve it on database (Postgres) level. The following situation I consider invalid, because the relationship is defined twice. user_id | friend_id ---------+----------- 1 | 35 35...
I am new to Java and was reading its documentation on exceptions., and especially the Unchecked Exceptions — The Controversy page. The bottom-line says: If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make ...
I am inexperienced with iteration in R and am hoping to speed up a process as I am implementing some analysis in a website. I realise that this may be a Q for SO but I couldn't get an answer from them... I found a very useful tutorial that allows me to iterate through a matrix, pick out the criteria data above a certai...
I'm currently working on an Arduino project where I need to keep track of entries for a certain amount of time, in this case, 30 days. Our company will attempt to sell this product to cities and governments. Therefore it really has to just work, which makes me want to refrain from dynamically allocating memory. The ent...
Forgive me if I'm using the wrong terminology, but I'm attempting to explain to a non-technical person the difference between something happening in a program due to either a Math.Random (seed PRNG) and something happening every nth time. So, picture you have a queue of items, every 10th item will be stamped. This is ...
I am going to develop which will be web application as well as mobile (android / iOS / windows) application. The database in this application will be managed by Hibernate. Also as it is cross platform application, web service will also be used. What I know so far is: HIBERNATE: POJO Files (the getter-setter ones which...
I'm developing a desktop application, and this application requires some information to run, but it doesn't change any of this information (the data must be loaded on every execution of the app, but the data is never changed). The data must be stored on the same computer as the app is running (client-side storage?). It...
I'm wondering the following: suppose we are building a system where there needs to be some filtering functionality to search for some entity. For example, one might want to apply the filtering to a table listing the entities to find something, or use it to generate a report on a filtered set, whatever. The point is: we...
I am currently developing a web application (in Ruby on Rails) for my university's department. The web application's user base have several roles: director (the director and assistant director of the laboratory for the department), lab assistant (students who work in the laboratory ), faculty and student. The roles div...
I'm wondering if there is any good convention for key attributes in relational datatables. ID or Id seems to be good. however it conflict with others ids when joining. MyTableNameId does not conflicts when joining, however your software must know the ID name for each table. There is any good practice?
I want to store temporary data that can be accessed across multiple http request. The question may be similar to How to persist temporary data over multiple HTTP requests?. The accepted answer is too specific to ASP. However, in my case i'm using rails as the framework. I want to know possible pattern that at least wil...
Currently I am working on php application, to create interface that will receive POST data from mobile app, and process them into shared database. To do things right at a first time, I was searching for rule of thumb to design the web service. Quickly I found the recommendation by using RESTful API . I have read throug...
I'm writing a lot of stored procedures for a SQL Server database that take an id or code that is a CHAR instead of an INT. Most of these haven't changed size in a long time, but when a customer wants to increase the size we generally do. This wouldn't be a problem except for the fact that any stored procedure with a pa...
I want to explore code paths in Cassandra database, so after getting the code from git and explore it a bit I noticed that it starts a daemon process when I run it from Eclipse. I supposed that when this happens, I can no longer use the IDE to follow where the code is. Due to another problem I created this question and...
We start with a variable that holds an integer for the "number of items" that we have somewhere, somehow. Then, the algorithm is applied: each one of those items have a 70% chance to be destroyed. If the algorithm was something like round( num_of_items * 0.7 ), that wouldn't work as expected, for obvious reasons (one w...
I am currently working with a contractor who's code instantiates a large number of objects upfront at the start of the application. This application is written in ruby, but I wonder how something like this is viewed in programming in general. So, are there any cases where instantiating a large number of objects upfron...
I just want to ask an opinion, which are the best practice to use html between this two option: 1) Use JSP by creating html page there 2) Generate html using Java server side by using PrintWriter Which one are the best practice? And if I got some situation like only to generate small line of html, is it better to crea...
I want to build a .jar that encapsulates a vendor api, so we can use our own objects as parameters to communicate with the api. I've read some articles and topics here in SO, but I still am a bit confusing if I'm getting dependency injection right. For examples of House objects with Doors and Windows, it's easy to unde...
I've seen in some applications that were written in compiled languages where plug-ins are accepted and the solution to the question of how still eludes me. For example in Eclipse, Google Chrome, Firefox, and IntelliJ developers can write plug-ins for the software and it runs as though it was apart of the program. From ...
I have a standard C# MVC project which has a domain layer using EF and repository pattern. Say I have a model like: public class MainModel { public int MainModelID {get; set;} //Many other properties public List<Organization> CompetingOrganizations {get;set;} } On submission I need to populate the list of...
Here is how I was told to deploy my ASP.net(mostly intranet) website\program\application to the production web server in my company. Change necessary settings in web.config for production web server. Copy EVERYTHING of my source codes, then paste in the designated virtual directory\folder in the web server. As far as...
I am developing web apps using the Model-View-ViewModel approach with Knockout.js. After reading on the original introduction of MVVM by John Gossman, I realized that my ViewModel always contains ALL the app's logic, not only UI logic, but everything. I've read somewhere that with Knockout, the model is considered the ...
I have an external ecommerce link that varies based based on environment (testing and production systems). Where should it go in Rails? Possibilities include: a conditional directly in the template, on the button (not a good solution, IMO) database (though there's no model for this so it would be a specific case possi...
I am consuming a web service in C# using REST APIs. So, I have created a wrapper classes for each endpoint. It seems like a good idea to implement the wrapper using statics. This makes code look much cleaner. For example, consuming a method on Albums endpoint looks as follows. List<Album> albums = AlbumsEndpoint.GetAll...
I got to develop a web service that will help synchronize some of our data with APIs from Google, as well other services in the future. I thought, and my boss too, we should go for a stand alone web service mounted on a React server, allowing everybody to interact with it through HTTP. There's a synchronization databas...
We have an occasionally connected, event sourced system: a budgeting application where each client can pull other client's event store from a separate storage (network share, dropbox,...). It is our idea to assign each event the current client's (incremented) vector clock so that we can determine a global order of eve...
Every time a user submits a score, Socket.IO causes all the users get their leaderboard updated. This causes every single user connected through Socket.IO to read from the Dynamo DB database (every time the a user submits a score). As a result, my database gets several reads/sec. This costs me ALOT! How do I reduce re...
In this book I'm reading I'm going over bitwise operators. Its says the following in the book. Bitwise operations can potentially store a lot of information in a small amount of memory. Many traits in the world have only two possibilities that are either this way or that way. You are either married or you're not. you...
I want to write assembly program using windows syscall Interrupt number , so in order to use system call in assembly level using int of sys call, In windows are there kernel calls like posix library unitsd.h in assembly level. where can i find windows system call list for opening file, mkdir,etc.(interrupt number), ...
I am attempting to write a python script that with remove some of the tedium of my everyday actions. Specifically, I always need to run Eclipse, Java VisualVM, and a docker container. I had planned on importing the os module and just executing a few os.system commands to get everything running: # set_up.py # Starts up ...
Assume that we have a 4GB RAM processor. Let's say we want to play a 4GB movie in VLC player. Now, processor first starts VLC Process and then starts to load 4Gb data. My question is how does this data transfer occur, Is it like getting almost all of 4Gb and storing some in swap area and bringing whenever it is require...
What I need to do : I've been asked to add a feature to one of our application that would allow a supervisor to send a message to all or one of the users currently using the application. The application is a winform application using c# and ef6 with a mysql database and is using a RabbitMQ server for different purpose...
I'm struggling to understanding how I can deserialize the following response from an RSS feed. I need the text blah blah blah etc as well as the embedded image source http://host/path/to/picture.jpg. <description>blah blah blah blah br /&gt; <![CDATA[<img src=http://host/path/to/picture.jpg>]]>&lt;br /&gt; blah blah bl...
Our application is composed of a main webapp and a handful of windows services that perform a variety of jobs that feed, sanitize and optimize that webapp. In order to ease the task of maintaining this services I would like to unify them in a single application and while I have several years of practice in C# developm...
Following up with this, I have a bunch of coordinates and I draw them on a bitmap image as a coordinate system. Now, I would like to get rid of all the noise, and filter coordinates to give a "clearer" or "cleaner" path and "less" or "better" data to work on. To explain more, I will need to expose my awesome painting s...