instruction
stringlengths
34
36.1k
Good day, I'm trying to find a way to program a lambda expression generator in java with this context-free grammar, and I would want to ask ; what would be the best way to tackle this problem and be able to manipulate them with basic lambda calculus functions such as beta reduction, alpha conversion, etc.? I tried doin...
I'm building an API, a function that uploads a file. This function will return nothing/void if the file was uploaded correctly and throws an exception when there was some problem. Why an exception and not just false? Because inside an exception I can specify the reason of failure (no connection, missing filename, wrong...
What is the best practice of a multi-step processing in a micro-service system which is using publish/subscribe architecture as internal source of communication and also requires immediate response? Is that even possible? Example would be a tourist agency which is exposing an API to their partners. API allows to book ...
I recently got an inexpensive phone with minimal browser support i.e. no javascript and on a small screen. Wanting to make the most of my device, I decided I would load some ebooks onto my device through a workaround. I saved a page for offline viewing and then connected it to my computer to explore the file-system. I ...
Sometimes you get into a scenario where a software team is iterating quickly and delivering lots of software. Over time, failure to do housework and paying off technical debt leads to productivity going down. They eventually approach a point where all the resources of team are used up in overcoming the accumulated cru...
Inside our UI there's an option to select something from a dropdown. Depending on what you choose inside that menu the rest of the fields inside the UI change accordingly. At the moment we handle it with if/else clauses which I think is not a good approach. Is there a pattern or a best practice to deal with something l...
In my WPF application, I want to create a new view. Where should I do that - in ViewModel or Model? The application is a (very simple for now) one-window form-like tool with single "send" button. In case if one of checkboxes is selected, new window using the same ViewModel should pop up to ask user for some additional ...
I'm using Spring Boot with JPA / Hibernate and I'm trying to decouple the business layer from the data layer. I would like to be able to (relatively easily) switch from a relational database to a rdf triple store. Here is a partial simplified description of my current try. I have entities such as: @Entity(name="Drawer"...
The way I see it, SQL injection attacks can be prevented by: Carefully screening, filtering, encoding input (before insertion into SQL) Using prepared statements / parameterized queries I suppose that there are pros and cons for each, but why did #2 take off and become considered to be more or less the de facto way t...
Given that a local copy of the Selenium server and web drivers are required to run an automation test, i.e... junit-4.10.jar selenium-chrome-driver-2.0a4.jar selenium-java-2.53.0-srcs.jar selenium-java-2.53.0.jar selenium-server-standalone-2.53.0.jar Is there any way to run a web service where, for example, when the ...
I have to create a method CalculateMean(int[] x) If the input is an empty array, should I return 0 (or some number), or throw exception?
According to https://www.quora.com/What-are-the-key-difference-between-ReactNative-and-NativeScript/answer/Valentin-Stoychev , "ReactNative as using the notation found in React for inlining the UI declaration in a single file." Is this supposed to mean that when writing React (or ReactNative) code you have to use inlin...
A couple of years ago (at QCon London) several talks name dropped the phenomenon where the software architecture evolves to mirror the office layout but I can't remember the name. I believe this phenomenon to be an influential factor in how solutions evolve and as an architect I don't want to make solutions harder to r...
I have a program that starts a task as follows: token = this.tokenSource.Token; var t = Task.Factory.StartNew(() => { while(!token.IsCancellationRequested) { // do the work... } }, token); My goal with this task is to perform some work until the user stops the program. The user stopping the progra...
Delphi BPLs do a DLL name mangling as explained in this German article http://edn.embarcadero.com/article/27758 (use your favorite translator page if needed). The name mangling is obviously different than using __declspec(dllexport) from visual C++ Are there any known ways of using the classes exposed in a BPL from Vis...
Problem: you are given n jobs, each of which has a start and an end time. The task is to simply output the maximum number of active jobs (ones that overlap with one another, inclusive), and to return the time range of overlapping jobs. For example (format: job = start, end): J1 = 0, 1 J2 = 1, 1.2 J3 = 2, 2.5 J4 = 0.3, ...
I was reading Python's requests library's code to find out how it works. Since this library has a simple usage interface, it creates a more complex object beyond. For instance: requests.get(...) Is a shortcut to something like: s = Session() r = s.request("get", ...) return r I do like this approach but I'd like to k...
I have a large WebApi project with a few dozen controllers. Each controller represents an endpoint prefix, just as a normal MVC project would. For example: CarsController.cs represents http://api.example.com/api/Cars In the above example, the first role of that controller is to provide CRUD actions for the Car entity. ...
This is a software design question. Not sure how to ask, so I'll illustrate with a scenario. I'll update the title to help reference for others if there is a better way to ask. Scenario BizLogic is the Business layer in a typical MVVM. It handles typical CRUD operations on a List. A requirement is that Data comes wit...
In GTK+, most if not all widgets are based on GDK windows, which are in turn each backed by their own X11 window, assuming one uses the X11 backend (Note that I'm not talking about toplevel windows, but about the window specific to each widget). What is the rationale behind this? Toolkits like GTK+ support other backen...
How would you model/program the following: We have items in our domain, let's say cars. We also have categories for cars. A category has certain characteristics. So for example we could have a car named Model A and place it in the category Sedan. The Sedan category has the characteristics 'five-doors' and 'five adults...
I am working with EntityFramework 6 code first approach and SQL Server 2014 Express. However, the DBMS may change in future. That setup allows easily to create a database and add some dummy data for unit tests. Currently, I am creating one database per unit test and drop it after the unit test finished. I am not sure i...
I currently have a program that has multiple derived classes. All instances of a derived class are stored inside of that class's static vector of pointers. I also have a static vector of pointers which is inside of the base class which stores any object that has been derived from it. Whenever I add an object I currentl...
I am trying to build a very basic instant messaging platform. I have three basic immutable types, and each of them has a subclass for dealing with CRUD (for SRP purposes, separating the class from the database logic). Conversation: public class Conversation { public uint Id { get; private set; } public List<Par...
Lets take the following example of inheritance in javascript: var Employee = function(name, salary) { Person.call(this, name); this.name = name; this.salary = salary; } Employee.prototype = Object.create(Person.prototype); Employee.prototype.constructor = Employee; Employee.prototype.doWork = function() { alert...
The private modifier is used to restrict access outside the class, but using reflection other classes can access private method and fields. So I am wondering how we can restrict accessibility if it is part of requirement.
The most likely answer is no, but I've come with this doubt. Can an actor act as a class? I know actors trigger events and can have prompts, but if there's a class modeling an actor (such as an user class) can we call methods over them? Or is this a complete misunderstanding of the actor role, which is getting mixed wi...
I am designing a plugin to uniquely identify content on various web pages, based on addresses. So I may have one address which looks like: 1 someawesome street, anytown, F100 211 later I may find this address in a slightly different format. 1 someawesome street, F100 211, or perhaps as vague as someawesome street F1...
In the ASCII table, punctuation characters appear between the non-printing characters and before the numbers (!"#$%&')*+,-./), between the numbers and the uppercase letters (:;<=>?@), between the uppercase letters ([\]^_`) and the lowercase letters, and after the lowercase letters ({|}~). On first glance, one would exp...
My understanding of Microservice architect is that much of the work is shifted to the front end client side in a single page application (SPA). The SPA will then interact with the back end microservices. This begs a question: Does Spring framework with MVC still relevant here? I think only SpringBoot with Bean injectio...
is there a way of having an (yet unkown) function as an argument of a function in python: def doSomething(<func>): #do something with func() at a later stage, functions could be defined, eg: def f1(x): return x*x def f2(x): return x+1 and I could call now: doSomething(f1,x1) doSomething(f2,x1)
I am setting up Vagrant with multiple developers using ScotchBox (v2.5) in our workplace, I have got the initial vagrantfile working ok however I'm unsure of how best to handle Database migrations. We essentially have two sites :- Frontend site (AngularJS 1.x) Backend site (Zend 1.x - PHP/MySQL) Colleagues will occas...
I want to find Haskell's analogue of infinite list in c# language. I want to use any possible interfaces for such list, like these: IEnumerable ICollection IList
I'm working on a piece of software which generates configuration data for certain hardware and currently needs to be adapted each time the hardware is released in a new version by an external company (this happens around twice a year). My current task is to introduce a plugin interface so the whole application doesn't ...
This great articles explains the difference between unit testing, component level testing and UI testing. At all my previous companies great deal of attention was given to unit testing and less to automated UI testing (end-to-end integration tests). I've never seen component testing practiced in these companies. It's ...
In a code base I am "starting from" there are a handful of interfaces with many default methods. They look something like this: public interface HasXY { double getX(); double getY(); default double method1(double x, double y) {...} default double method1(HasXY other) {...} default double method2(dou...
C++ has namespaces to prevent collisions of things with the same name. Header guards serve a different purpose. They prevent includeing the same header twice. However, they can suffer from the same problem: what if two header guards from different files use the same popular name? What if there are two libraries that ha...
I have a question about modeling. Quick introduce: I develop application to sales purposes. Application have users. Every user could be customer, employee or companyOwner. It depends on: Customer - just registered account, and buy product form any registered company Employee - registered account, and company owner assi...
When writing something that creates many (1000s) of small objects often, should you try to minimize it for performance? Especially if you don't know what system it will be run on, from low to high end desktops or even mobile. For mobile, I heard that creating a lot of objects hinders the performance a good bit, though ...
Definition: Purely microservice: Not using any web framework such as Spring, Laravel, Zend, Django. Web app is a single page app loading data via Ajax calls to web services Hybrid: The web framework is still used, only some not all data will be loaded via Ajax calls to web services My initial thoughts came up with po...
I am thinking how programmers mix languages. If I want to mix C and C++ language then what should I do? And how to mix languages?
I am working with a team of web developers. We are already using Git for version control of our code and it works well. However, while we are changing our code, it is also common to change the database structure, adding / deleting / renaming columns and tables. The normal answer to that is migration files, and we are a...
We have a huge project that desperately needs to be broken apart into multiple databases and applications. I can think of 2 possible approaches to this problem: Use a REST endpoint on each service to fetch/update data. Services that are dependent on each other simply call each other's REST endpoints to fetch/update da...
When I'm building views in SQL, I tend to do one of the following: Views that contain logic and criteria for selecting and joining records. I.e. "what records am I interested in and how do they fit together?" Those that focus on returning a certain set of fields, sometimes formatted in a particular way. i.e. "for thes...
I am a lecturer writing coding problems for students. What I want to do is give the students the boilerplate code with placeholders for the functions which students are to complete. I will give the students access to a private github repo to clone this. However, I also want a version of the codebase, complete with samp...
So I went for developer job at some company who sell gourmet food boxes based on recipes, I was turned down for a job after doing a tech test, I asked why I failed to improve on next time. They said my design for the rating system was subpar. (they basically wanted a system for rating recipies). Some basic context I ha...
I'm building a small interpreter for a language I created. The grammar, lexer and syntax analyzer are already done. What's confusing me is the interpreter part. I know interpreter pattern, but it seems too much verbose (more than it needs to be), I don't feel it's the right approach. What are other alternatives I have ...
We've got a spaghetti mess of an application that I've been tasked with rebuilding. I really want to make the new code much more flexible, and also more distributed. On a basic level the application collects data from hardware, performs some control actions, displays the data, and lets the user send settings to hardwar...
I'm new on Node.js and Express and now I'm observing that when I change the method on my calling app the params are in req.param([name]), req.body.[name] or req.query and it depends by the method. Now my questions are two: Are there some differences between these three objects? (something that could explain why a diff...
I have a JSF Page (Primefaces) with a datatable that contains entries from a Database. Thoes entries represent transactions created by users. Each time this page is loaded, I do this: Clear the table Call a service that gives me all entries Fill it again with these entries Since the Bean containing the entries could ...
Suppose that I have an object used by my code, say Person: public class Person { public string Name {get;set;} public Address Address {get; set;} } public class Address { public string AddressLine1 {get;set;} public string AddressLine2 {get;set;} public string City {get;set;} public string Stat...
Since zombie processes are processes having all resources freed but still existing in process table because their parent might ask for their return status, is it a separate state in Linux like ready, waiting etc. or is it just like normal waiting process in the table and can be scheduled also?
My company develops technology for visitor management. We currently have 2 solutions, one that is in the field, running on on-site hardware. The other is cloud, running on the cloud and processing all visitor related thing remotely. Management wants us now to build a 3rd product to retire the two previous products and ...
I'm working on a web application where the server side makes calls to a foreign server's web service API. The data passed to this API could contain sensitive data (like a user's password) as part of the header and/or in the body of the request. I want to be able to log what's in the request (URI, header, body, response...
Writing SQL like parser in .NET At this point on the first basic parse select col1, col2, col4 from documents where col1 any ('a','b','c') and col2 all ('b','c') I can identify what I call all the token type select is select col1 is column col2 is column from is from where is where col1 is column any is conditio...
I've heard here and there that arrays contain runtime data about their type, making you unable to instantiate an E[] (E being a generic type parameter, for example in a class Foo<E>), and that while you can achieve the same effect by doing (E[]) new Object[n], it is bad, which is why the compiler raises a warning. I'm ...
There are two points (x1, y1) and (x2, y2), each of which can be any real integer pair. These define a rectangle R with vertices {(x1, y1), (x2, y2), (x1, y2), (x2, y1)}. The rectangle exists in a coordinate system where (0, 0) is the top left corner of the screen, positive y is down and positive x is right. I need to ...
I'm currently working on a school project inspired by these software and device. Drums anywhere: https://www.youtube.com/watch?v=8PRBx5o15-A&t=0s Mogees: https://www.youtube.com/watch?v=vUzQQUpf4C8 I found out about the input device, and kind of get the idea on how it works. I can do a little bit of coding in python, j...
I am designing a system which fits quite nicely into a RESTful architecture. Users can navigate a resource hierarchy from a root node, each resource links to other resources, resources have URIs etc. In many ways this is very similar to 99% of the CRUD web applications out there. Where things get a bit different is tha...
I'm writing an app it needs to have generic registration step item. It needs to be able to do some specific things (I use interface for that) and it needs to be a visual element (of Xamarin. It doesn't really matter, though), say VisualElement (I use abstract class for that). This is how it all looks like: public inter...
How can you actually determine the size of fixing something which is broken in an unknown way? I tell people in my classes I only know two sizes for defect fixes: 1) Trivial because I already know what’s broken and how to fix it, or 2) Infinite because I have no idea what’s broken or how to fix it! If those are the o...
We currently have 4 environments for a project (local/dev, test, acceptance, production). We created some integration tests which want to run. The big question we now have is where to run them? Run them on all environments. The pro's for this is that we know for sure it works on all environments. The cons are that a) ...
Okay, please consider the following method. Let me first tell you that my goals of the method is to determine if file system assets exist. That's to say this is an internal company site where you'd expect the base directory to already be there on the installed server and the same with the parameter passed directory and...
I'm using comet polling in Joomla (PHP) application on shared hosting. I can't use either WebSockets or Node.js, as they might not be available on client's server. I managed to maintain only one request throughout to reduce the space it will take up in Apache. However it still makes my PC very very slow. In my friend's...
I am making a module that will output a list of objects that are missing on a list. Currently the code I have takes too long for a list of about 300,000 objects. public List<SimpleObject> GetNonExistentObjects() { List<SimpleObject> source = GetNodes();//contains 300,000 List<SimpleObject> target = GetNodes()...
I would like to understand the difference between stateful and stateless applications. What would be a non web app example of a python application which is stateless vs stateful? Would a script which scrapes the web and saves the results to disk be considered stateful and one which saves the results to a database stat...
I am currently working as functional tester. I have been assigned to do web services testing for a project. The test strategy is something like this: our company is switching vendors who provide a service by accessing data in our company's system the new vendor should be able to search for a particular data in our sys...
So I am doing this project on Rock Paper Scissors, something with 5,059 combinations, but that's besides the point. In my case, being a beginner, I was wondering if it is possible to make each option a string and then later convert those strings to integers. Or as Candied Orange was saying, would a Hash Map be more e...
I recently heard of the statistic "87% of the US population can be uniquely identified by a tuple of their zip code, birth date and gender". This is apparently not true, and I was wondering how I would verify it if I had the census data. So imagining I had a 300-millions-line-long unsorted text file containing the gend...
I have a database where some tables are Collation utf8_general_ci and some tables are Collation utf8_bin. Is this an issue that will cause unexpected behavior, or is it just a matter of performance?
I couldn't find an answer, so let's try here... I thought a bit about security and came to the conclusion, that the used hash algorithm should be as slow as possible, to slow potential attackers. (Slow means like ~1.5s). I don't want to use multiple hash function or the same just a few times again, I just want a slow o...
Consider a system with a finite number of users and a finite number of groups. To each group it corresponds a set of users. (We say that users "directly belong" to a group.) Groups of users form a directed graph without cycles. If A→B for groups A and B, then I say that B is a direct subgroup of A. The following operat...
I am building an implementation of the [Merkle-Hellman Knapsack Cryptosystem] for my study.(https://en.wikipedia.org/wiki/Merkle%E2%80%93Hellman_knapsack_cryptosystem) One of the things I would like to do, is to create a new private key. A private key in the Knapsack Cryptosystem consists mostly* of a so-called superin...
I'm trying to figure out how to support the following example scenario ill be using C# as the example language. Scenario NASA is sending Rovers and Satellites to different Planets these vehicles need a lot of logging, and to reduce clutter, would like to be able to filter these logs in the following ways: i should be a...
So i have the following data for over a month ( an app that registers all i do) Lat Long On ( DateTime ) Now i am interested in creating a history on plotting the points on Google Maps, similar to this blog post How would i do this? I thought to group the queries andadding a weight per radius every 5 minutes ( eg. wi...
This question was asked by my professor in an exam and I couldn’t find an answer on Google, so here I am. I don't understand what objects are in C at all.
I've been using Web Forms for way too long now and I want to switch to ASP .NET MVC 5 because I think that it's the "next step" for a ASP .NET developer. I also find it to generate pages a lot faster and provide better control over the HTML, but I feel like the concept is physically too big to grasp. This is my main ...
I'm about one week into studying C++ so please bear with me. So let us say that I have a function that returns a value that I need to use in another function. Is it better practice for one to assign the returned value to another variable first or is it better to simply call the function as a parameter of the other? Bot...
To be able to scale I would like to use async programming. It works really well if I have to read something from db and push to frontend, however I do not know how to use it correctly in blobs of buniess logic that live their own lives. I have object, that has lots of properties that should be lazy loaded. For instanc...
In the company I'm working for we have a certain service where users can upload documents (text, sometimes document scans), it's nothing confidential but if those documents will be leaked, I'll get a lot of headache explaining why all of them are publicly available. Recently we had a breach of out network and while thi...
I'm receiving continuously data streams of log messages. In each data stream there are some special messages representing states. Now I want to track if all states reached until the data stream ends. And if not, which state reached at last. I don't know how to implement that efficiently. I was thinking to use two lists...
I am working on a CRUD app where I have things called requests that can have many iterations. I have an endpoint to hit called iteration/create/requestId. When this page is hit I show an empty table with fields for the user to fill in. I take the index of the row and assign it to a field in the iteration called the ...
I came across one of the books related to information security where i saw these two terms, fabrication and modification of data. I can't figure out how they are different? What is the difference between fabrication and modification of data? Could anyone please explain me these, in very simple terms? Update: fabricati...
I've read quite a lot about this subject in the past and watched some interesting talks like this one from Uncle Bob's. Still, I always find pretty difficult to architect properly my desktop applications and distinguish which should be the responsibilities on the UI side and which ones on the logic side. Very brief sum...
Suppose you have a file that contains all representable integers for an architecture (so, on a 64-bit machine, it would contain all integers representable in 64-bit). However, not every integer is actually present, and the goal is to find which ones are missing. For only a single integer missing, it isn't too difficult...
Is there a universally accepted classification of error handling strategies? What is a general term to refer to those strategies, which can be used while searching for books and articles that compare error handling strategies in different languages? Some languages, such as C and Go, report errors via exit codes. Anot...
After researching how a parser generates an AST, I believe that I can know attempt to create one. Before I started on this project, I began to ponder what I should be done next after creating a AST that represented my language grammar. Despite my research into this topic, I have not surfaced any quality resources expla...
Given a map that associates labels (strings, say) to lists of ints greater than or equal to 0, I'd like to get list where the labels are ordered by the sum of their associated lists' values, descending. To take a concrete example, given: "a" -> [1, 1, 1] "b" -> [2, 3] "c" -> [9] I would like the result to be: ["c", "b...
I was reviewing the big O cheatsheet at http://bigocheatsheet.com/ and ran into some listings under sort that I do not understand. Runtimes are color coded, green being better than yellow. There are cases where Ω(N) is color coded better than Ω(N+K) and even Ω(NK). An example is bubble sort best case vs counting sort...
I have a periodic functions and I have the values of this function at discrete points. So I have: f(t_i) for some t_i, i\el(0,n) Now between these discrete points I want to lineary interpolate the function such that: f(t) = f(t(i)) + (t - t(i)) ( f(t(i+1)) - f(t(i)) )/( t(i+1)-t(i) ) for t\el(t(i),t(i+1)). The implemen...
I'm just wondering if there's any popular terminology to refer to program output that is going to be compared to some canned golden data in a unit test. I'm trying to inject this terminology into my code and so far I've come up with things like int goldIdx; int outIdx; double goldValue; double outValue; so basically g...
Lets assume we have to model the following entities: Application : Application submitted by users Application Study: the study to determine if the Application should be accepted Consultation : A consultation with an external party as part of the Application Study. Consultations with external parties could also be i...
I'm focusing my question on Windows OS, desktop applications. What would be a decent way to get a unique identification for every machine? obviously there many ways to do that, such as concatenating a hash from network card's MAC address, or hard drive serial number, or even generating my own GUI number on initial laun...
Situation We are a large team of developers, using SVN for source control on our project. One of our files, FileTracker.cvs, is very large: it contains metadata about almost every file in our repo. The format of FileTracker.cvs is that each row respresents a file, and each column represents some piece of metadata about...
I'm new to Spring MVC, hence the question may appear trivial. I have a login form which is submitted via ajax and in return I receive a ModelAndView (displaying existing list of contacts of the user) from the Controller, which I use to overwrite the existing content - the existing login form HTML upon success. My model...
If A sends an async message to B like for example, to load async images to UI from the web. Where should the response message go? Should it be slant as well or direct? And where would the activation of the sender (A) would be?
I'm looking for a way to achieve some kind of code execution validation, so for example if I have a server and a client, I want the client to execute some code (assembly) and send the server validation of this code was actually executioned fully. (and make sure no one tampered with the code running) Is this thing actu...
I have seen questions similar to mine, but there are some unusual specifics to mine not covered. I have a SQL SERVER driven ASP.NET web app (website). I am using the older webforms model, not MVC. I understand that MVC is usually a better overall model from what I know of it so far, but I'm not sure in my situation so ...
I am having a scenario wherein we have a Product Entity or a Front End Module which can be Added, Edited and Deleted. Now Product ( when added or edited) can contain a Dropdown called as Manufacturer. User can select one value out of it. I have written a Spring Controller->Service->Dao->Model type of Code to serve th...
At an operating system level, mobile operating systems support the notion of push notifications or a socket level 'persistent' communication with an app, whenever it is online. Why have the major computer operating systems (OSX, Linux, Windows) embraced this idea at an OS level as a higher level abstraction. This can ...