instruction stringlengths 34 36.1k |
|---|
I'm looking to build a mobile application (iOS / Android) that digests information from a secured API. The API will require OAuth2 authentication to be able to digest any resources. The service I'm providing via this API contains both information that is considered public, as well as information that requires an auth... |
I'm learning Web Services Addressing and SOAP, but I can't get the importance of WS-Addressing in SOAP. This is quoted from Wikipedia "standardized way of including message routing data within SOAP headers".
As far as I understand that message routing data for a WS is already included in the HTTP header, then why add i... |
I am thinking about using JavaScript for direct connection to our database server. I think I have solutions to all the possible problems about it.
Security: Modern database management systems support SSL connections (e.g.
PostgreSQL). We can securely connect to a DBMS. There is no
difference between securely connectin... |
Is there any situation where an array is not suitable but a variable variable is? I cannot think of one or find one on any Stack Programmer Q&A.
<?php
$foo = array();
for($i = 0;$i < 3; $i++){
$foo[$i] = "bar ".$i;
}
var_dump($foo); // ["bar 0", "bar 1", "bar 2"]
for($i = 0;$i < 3; $i++){
$foo = "bar".$i... |
I know this might just be semantics, but reading the article titled Write code that is easy to delete, not easy to extend made me think that perhaps it is more or less along the same lines of creating code that is easy to maintain. Now whether it is to make the software easy to update or modify by making it extensible ... |
Consider a use case of the form:
The system shows a list of potential filters (by name, by creation time...).
User chooses a filter and supplies necessary parameters.
System shows a list of potential objects.
User chooses a single object.
System returns the chosen object in some way.
I'm stuck on how this sequentiali... |
How can I best implement a global counter in a Rails API app? (A central component in a system with several.)
Basically I have a transaction id I need to increment and roll over past a maximum value. So it has some custom logic attached and needs to be managed, more than simply auto-incrementing to infinity.
I'm thinki... |
I have some (presumably stable) legacy C code that uses POSIX system calls to read binary files. It's nothing more than creat(), read(), and write(). The program doesn't sit close to the metal at all (it loads string data into memory), so it seems wrong that it's using syscalls. I think I can refactor it easily to use ... |
I find it more convenient to 'modify'existing classes rather than extending them. Thus, I violate the open closed principle of 'not modifying the compiled and tested source code, instead extending the functionality'. I feel comfortable in modifying the source code because of unit test cases. Whenever I am modifying the... |
I have been modifying an existing software (which was under the GPL licence). At my workplace, they needed to use the software, but needed some modifications (like new features, different structure, feature modification and removing unused functionalities).
I am about to finish this, but would not like to disrespect th... |
Wadler's original paper on Monads for Functional Programming ( Haskell ) ,he says
Another question with a long history is whether it is desirable to base programs on array update. Since so much effort has gone into developing algorithms and architectures based on arrays, we will sidestep this debate and simply assume... |
In Java, I've run this method:
private static void floatAddition() {
float a = 0.1F, b = 0.2F, c = a+b;
System.out.println(a + " + " + b + " = " + c);
}
and the result is 0.3 for floatAddition. I'm now trying to get behind why it is adding to a round result, and not to something slightly off due to floating po... |
We are currently maintaining a homegrown python "web server" where generating the response for some requests can take a very long time mostly due to heavy computations - these requests are basically posts with very long timeouts (think minutes to tens of minutes).
One problem of this architecture is that there is somet... |
when we import the Scanner class to a program which is the best and most suitable method from these two?
import java.util.*
import java.util.Scanner
I'm a totally newbie to the programming and I haven't any idea about choosing the best method. personally I think method mentioned in number 1 will be the best choice s... |
I'm playing around with creating a parser in PHP for my own flavor of BNF, to match strings against grammar in this BNF variant. It's still a work in progress and subject to change (I may even end up switching to support ABNF or EBNF, in stead of my own variant), but it's coming along quite nicely.
Now, forgive me if I... |
What is a clean way to store items that reference multiple other items of the same type in a relational database?
Say I have a list of jar files and their dependencies:
package1 depends on package2,package3
package2 depends on package3
package2 depends on nothing
Now I could store that in a database as follows
CREATE ... |
So, in the recent weeks I delved into C++ programming, and I programmed some things in SDL. Doing so, you always have to deal with a lot of (ugly) C++ code, which looks more like C than C++.
One thing I noticed I when programming with SDL as opposed to college programming, that I do a lot of procedural programming. The... |
Lately when I've been writing C or C++, I'll declare all my variables on the stack just because it's an option, unlike with Java.
However, I've heard that it's a bad idea to declare large things on the stack.
Why exactly is this the case? I figure stack overflow is involved, but I'm not very clear on why that happen... |
Introduction
The Schwartzian transform -- also known as map-sort-map or decorate-sort-undecorate (DSU) --, attributed to Randal Schwartz of the Perl community, sorts elements of a list or array by a metric which maps each element to its “sort value”.
Example for those who are not familiar with the Schwartzian transform... |
I want to use production data to generate "user activity" metrics.
My thought is to set up a cron job that regularly reads production databases to summarize user activity and then stores the results in a separate metrics database. This metrics database can then be used to generate various dashboards.
However, directly... |
I have been searching the web for quite some time now, but the plethora of opinions/comments/articles about licensing questions make it difficult to verify how trustworthy the various sources are. Also, they're often contradictory which left me behind confused after my search. Since it's probably a common situation an ... |
In colleges and in algorithm textbooks, it is quite common for the teacher and author to explain control flow in pseudo-code. With the advent of more expressive languages like Python and Haskell among others, is it reasonable that colleges switch to explain algorithms via one of these languages?
The only advantage of p... |
I am working on a personal project using Python. I have been using version control to the best of my abilities and if you would like to check it out and run the app https://github.com/CodeAmend/old-bull-tools/tree/develop
If you prefer Floobits, look at my actual code in a editor here:
https://floobits.com/CodeAmend/ol... |
At our company, we do not use any product design documents. We have three employees total so all product design discussion happens in person, or on Slack. (We are also on the basic Slack package that only allows viewing the most recent messages.)
Our product is still in early stages, and we often revisit design element... |
I am creating a website in php for one of my client. i wanted to use few piece of code from a Open source code based on GPL-3.0 license. e.g i wanted to use validation code from that lib and modify the 30% of the code for my requirements.
Only my client will be using that software and i will provide him complete source... |
If a personal repository with copyright/bsd license file is transferred to a github organization that consists of more than just the original copyright holder, since a group of people (the organisation) agreed on further developing that code -- what happens to the license and copyright stated in the original personal r... |
Currently I'm studying .NET Core and in the early docs which first introduced .NET Core we see that talk about the many different verticals. This can be seem in this picture:
In all the verticals we see the runtime, the framework, but there's also this "App Model" thing.
Also, watching a video about .NET Core CLI it w... |
I am in the process of writing a Ruby on Rails web application for my university's department.
For some of our resources in the web application, e.g. Project, are complex with their view layer logic:
a Project can be created by admin or faculty users.
after submission, faculty cannot update some attributes of their P... |
In many approaches to software development like agile methodologies, Domain-Driven Design and Object Oriented Analysis and Design, we are encouraged to take one iterative approach to development.
So we are not supposed to get our domain model done right in the first time we start working in the project. Instead, as ti... |
Normally, browsers should not send cookies that have Secure option if connection is unsecured (i.e. http instead of https).
Is there a configuration option or a plugin that would allow to change this behaviour for particular domain in Firefox or Chrome?
I would like to use such option for convenience when developing a... |
I have a problem with the tcp and udp synchronization.
On the server it accepted the tcp connection with the: SDLNet_TCP_Accept();
But now I need to know how to get the remote address of the udp_socket of the client to use it to send upd packets.
I already tried to use(on the server) the function SDLNet_TCP_GetPeerAddr... |
According to this abstract:
The "Ninja gap" [...] is the
performance gap between naively written C/C++ code that is parallelism
unaware (often serial) and best-optimized code on modern
multi-/many-core processors.
It appears that they are saying that a programmer who can skilfully handle concurrency can write ... |
I am working with Docker to run my integration tests, it works pretty nice:
I startup my docker containers (one with my server and one with the database)
I run the IT using arquillian against these containers
Now we are moving to AWS and we would like to use Amazon RedShift for some analysis. The problem is that RedS... |
Are there any programming (or scripting) language (or some domain specific language) having two binary operators opl and opr of same precedence with opl being left-associative and opr being right-associative?
(I cannot find such an example, but I am trying to code some parser general enough to handle that weird case)
H... |
I am currently developing my first custom data mapper layer but have run into a conceptual problem that seems to be glossed over all books and guides I have read.
My problem is as follows. My data mapper knows the database and maps the database fields (from multiple tables, not shown in example) to the model fields. Ho... |
We expose some webservices on a server, written in C#. Now we have to distribute the services to multiple servers, so the solution is distributed. And each request is dispatched to one the servers to eliminate single-point-of-failure (SPOF) situation.
At first we looked at the Service-broker from Microsoft SQL-server, ... |
I am designing a JSON based data schema to describe the visual appearance of blocks similar to HTML elements.
It should feel familiar for somebody knowledgable in HTML/CSS but is more restrictive due to constraints of the enviroment that it will be used in.
Now I am unsure how to model "width".
Acceptable are either pi... |
I'm currently writing a program that communicates with a server over TCP sockets. I originally planned for the communication to include a message confirming successful communication at the end of correspondence. Either the server and the client would wait for a response after each communication, depending on who initia... |
My situation
I will make a Xamarin application for Android that can access an ASP.NET MVC webserver with API's. The problem is when I'll send an API to the server, all the connected clients must receive an API with the changes that happens by client one. An example below:
In other words: The server must broadcast data... |
When load reaches a certain level in IaaS environemnt, new VM instances are created to reduce load (scalability).
My Questions that these VMs are not created on the same physical server, right?
I mean one VM with like 10 users will give the same performance as 2 VMs on the same physical server with each VM has 5 users.... |
I'm about to write a program and test(s) for it. This question is about how to structure the top-most level integration test.
At the top level, the main program takes a chunk of data, and outputs another chunk; specifically, it takes in a whole load of business data such as wages, material costs and so on from a config... |
I was having a look at a basic example of spam filtering using a logistic regression algorithm and an answer posted on this Stack Overflow question: https://stackoverflow.com/questions/29291263/mllib-classification-example-stops-in-stage-1
Correct me if I'm wrong, but these algorithms don't appear to use any sort of to... |
I'm new to MongoDB and am wondering how to decide to store some cryptographic hashes. Should I store the binary data itself, as a blob, or should I store its string representation as a string?
My instinct is to just use a string and be done with it, but I'm not sure if this is the best approach. A blob would take up l... |
I've read Unit of Work pattern and tons of MVC/EF Unit of Work examples but what I'm trying to do is encapsulate multiple unit-of-work into a large set. Maybe this pattern already exists somewhere, but I'm unaware of it if it does.
To keep my EF DbContexts clean, I've broken them down into different domains, however s... |
I am building a small application and want to save my business objects to a database.
I have my business objects and a model that acts as a container for my business objects and provides methods for creating and deleting them. Updating the business objects is done by directly altering the objects attributes. I also hav... |
I'm going to implements password recovery in my authentication. I haven't put this together in a while and wondering if there is anything I ought to be aware of.
My idea at the moment is:
User clicks "Forgot my password" to go the password recover page: a
form with an email field
They enter their email, and an email i... |
Assigning variables with values during definition is a good practice.
A common practice is to assign variables with 0 and pointers with NULL.
int p = NULL; // instead of int p = 0;
int *ptr = NULL;
int &ref=p;
Are there reasons to assign NULL instead of 0 to a non-pointer variable type? The int p = NULL c... |
I'm getting ready to take the bend out of asp and into an mvc framework, asp.net mvc or nancy. Wherever I go, I see folders for controllers/modules and folders for views. Is this just a pavlovian reflex of tidying things away by type, or is there some deeper wisdom operating? I have a little proof-of-concept project wh... |
I've found a piece of code like this in one of our projects:
SomeClass QueryServer(string args)
{
try
{
return SomeClass.Parse(_server.Query(args));
}
catch (Exception)
{
return null;
}
}
As far as I understand, suppressing errors like... |
My primary goal is to create a Euchre game in Python. Euchre card games are rare on the Linux platform, no matter the language or the desktop flavor of choice. For now I want to be able to just create a simple game like BlackJack or Rummy. My platform is Linux Mint 17, and I'm using PyCharm.
The thing that is stum... |
In my company we have a 'production pipeline', which is a bunch of code which we use to produce data, with the data later shipped to customers. The code is still being developed, bugs get fixed etc.
Currently, we are still using SVN, but we are on the process of moving to git. Using SVN, we used revision numbers to d... |
I asking a question on Stackoverflow earlier and someone pointed me to a previous post of his, He states that injecting a dependency into an entity violates the Single Responsibility Principle.
To save you clicking the link and give some context here is the entity being discussed
public class MyEntity
{
private re... |
An array of T, a pointer to T, and a reference to T (represented as T[], T*, and T& respectively by Type.ToString) all share the similarity that they are constructed from an "element" type (which can be returned by Type.GetElementType). What is the correct term to address all these types? I am inclined to say "derived"... |
I am trying to understand an example in Chapter 12 (Query Processing) of Database System Concepts, Sixth Edition.
A relation does not need recursive partitioning if M > nh +1, or
equivalently M > (bs/M) + 1, which simplifies (approximately) to M > √
bs .
For example, consider a memory size of 12 megabytes, divided... |
Consider the following situation:
I am working on project foo, and write some code that I think will have a generalized use in the future. I separate this code into a small library, and release it separately under MIT. Do I now need to credit the library in foo, even though the code was written in foo first? Assume foo... |
I mainly hear about people applying the principle to classes and methods, but do people also apply it to solutions/DLLs? For example, if I was writing a library to parse data from UsefulProgram, and then I had some more code that was related to UsefulProgram, should I have them in two separate libraries or just one Use... |
Say that you have an web application which prints pages in a document. Suppose that after validating the page range, the application does the following:
If a billing option is turned on, it first checks with the server to confirm the print.
After confirming the print (or doing nothing if the billing option is not turn... |
I'm working on a small fitness app in which the user (whom is authenticated with the a server) could create their own workout plan which will be synced with a server.
The problem with this is that What if the user has installed the app on multiple devices then he edited a workout plan's title on device A when it was of... |
Reading and observing some of the startups and well-known services, almost every time I found that people there are using cross-technology system in their architecture. For example like Twitter, used ruby on rails on their front-end parts, and scala for their more of back-end parts. Or the other stories like how some s... |
At my new job, they are currently spending scores of labor hours that we don't have to do manual QA testing after every build. Nothing is automated at all. (We can only afford three developers, and they are all far too busy to be involved on the testing side)
So I'm building an automated testing framework that basicall... |
I am integrating Serilog into and existing multilayer library that I've create. The previous logging technique I used was simply passing a string up the layers with events. I'd like to get away from this.
I've been told for years that you should never expose children to objects on their parents level but this is the on... |
Currently I have one web server running Django, which takes a series of images from a user, uploads them to an Amazon S3 bucket, and finally calls an Amazon Lambda instance, which runs a python script that uses ffmpeg to create a video from the series of images, and uploads it to the same storage bucket.
The issue is ... |
Situation: I've recently joined a new project, and I've quickly noticed that the team is very keen on keeping the code "flexible." It seems that for each class or function, they don't want to prevent the users of this framework from using things "however they want." As such, the team wants to provide multiple ways of d... |
We have developed a small ERP application and the architecture right now is a 1-1 deployment/codebase for each client.
We are now trying to convert it to a SaaS solution and we have the following approaches possible
Separate DB for each client
Pros
Easier conversion of the existing applications
Data is isolated
Con... |
I read this Wikipedia article, but I found it quite abstract. How can an effect system help me as a programmer?
|
In my app every user that connects to the server needs to get a random distinct color and I have to keep track of them. About 20 to 30 will be connected in the same time. When a user disconnects, his color gets dismissed.
My question is if I did this correctly concerning performance and thread safety.
public class Rand... |
I was reading about common practices for naming functions and variables. Most of the seasoned programmers say verb should be used when a function changes the state of the program, and noun should be used if the function is used to return a certain value.
UPDATE: please check https://stackoverflow.com/a/1991341/1088314... |
I'm building a new CMS with Node.js, and I have a question.
Would adding WordPress-like multi-site support to the system be a good idea? Or should I let the user handle it via a reverse proxy like nginx?
I realise that having a single process handling vhosts that share a single database can be advantageous in some ways... |
I am working on a .NET project with, which started out as a prototype that now has to scale. We have the ASP.NET MVC stack with Entity Framework (code first).
I would like to hear how to scale this into a "proper architecture" with API, repository that handles caching and so forth probably.
Note: I am not looking for a... |
Suppose we have an application with multiple layers in .Net:
Domain layer (entities)
Data access layer (entity framework)
Business layer
Web Services layer (Web Api)
Presentation layer (MVC)
Now I want to add token authentication for web services layer. The usual recomendation is to use a standar login/authentication... |
I had a basic question regarding using a git repository in different environments. I'm more of a Sys admin than a web developer, so the teams I've worked on before just worked right in the master, which obviously isn't the right way to do it.
I'm setting up a dev/prod/stage environment for a small company, and the Git ... |
Recently, I had the task to implement a research project where I had to read an XML file. XML file contained a list of messages that I had to send to some other system on a specific port. Each message has a type which can be either receive/transmit. Receive means that I have to receive a message from some port and tran... |
I am building a package that implements native-like sessions in a PSR7 middleware architecture.
I created a middleware which is responsible to create and persist a session cookie. The session is also propagated in the request using withAttribute.
I want my package to embrace the same philosophy as PSR7, my sessions are... |
I have a web application which has a shopping cart with cart items. The cart items are added to the user session, so must be serializable.
I have a checkout class which takes the cart items and saves them in the DB. There are some special types of cart items however which will require pre and post processing actions, f... |
I am having trouble understanding http://jsonapi.org/. Say, I have the following endpoints in my API for authors and articles.
/authors
/authors/:id/articles
If I wanted to fetch the details for a single article, I can use
/authors/:id/articles/:id
which returns data that looks like
{
"id": "1",
"type": "artic... |
In other programming languages, I have seen Map and Reduce, and those are cornerstones of functional programming. I could not find any reasoning or history why LINQ has Aggregate (same as Reduce) and Select (same as Map)?
Why I am asking is that it took me a while to understand it is the same thing and I am curious wha... |
The problem:
We want to restrict access to properties returned from our services.
Details:
We have route level permissions working with no issue.
For a user that can view /product/{id} for example, that user may or may not have permission to view the purchasePrice property. (if they don't have permission it would eithe... |
I am designing a library with a bunch of interfaces with annotated exceptions. (The example is in (pseudo)PHP, but I am sure one could do something equivalent in Java or other.)
For now, the interfaces have some exceptions in common (e.g. DogProvider and CatProvider both throw an AnimalProviderException). But there are... |
I've begun implementing a support library for curses in Python.
Along the way, I became curious why the project was called "curses" to begin with. According to one NCURSES documentation, the name is explained thusly
Curses is a pun on the name "cursor optimization"
I don't get it. How is "CURSES" a pun for "cursor o... |
The Windows OS tries to conserve physical memory usage by allowing DLLs loaded in their base (desired) address in different processes to use the same physical pages with copy-on-write semantics; this article, for example, describes the mechanism.
Now, the Windows Virtual Memory API allows you to change the protection m... |
I am working on JSON model classes in a swift project. Examples of the sample JSON and classes are below. In the JSON response, there can be many different unique statistics returned, but they all follow the same JSON dictionary pattern. The challenge that I ran into was the the value in the JSON result can be an integ... |
I mean, does something, for example in C#, like
String test = "Test";
txtCtrl.Text = test;
consumes more RAM than just
txtCtrl.Text = "Test";
?
As it's said, a variable is a reserved space in memory. But does that mean that not using a variable won't "reserve" (consume, take) a space in memory?
|
I'm writing an application that sends and receives messages over the network and pushes them into a std::deque queue. and I'm looking for the appropriate programming pattern to handle all of the different possible types of messages that it could receive.
Each type message will have a completely different set of data. F... |
I am trying to find a music track for my Android game. It's a free game but includes ads.
I found a good music on this site. As per the FAQs and the licensing terms (Creative Commons License Attribution-NoDerivs 3.0), I can include this music in my application without any paid subscription as long as I give the owner ... |
Many Scrum books and articles say that a failed sprint (when the team fails to complete some features from the Sprint Backlog) is not something that bad, it happens from time to time, and it can actually be useful if the team learns from their mistakes and improves something in the following sprints. And the team shoul... |
Currently, everything that is in the public_html folder automatically gets published live. The git repository is also inited in this folder (though this can change if it's necessary).
What is a good git workflow/set up such that my changes are only published when I do a git push, instead of automatically whenever I do ... |
NB: For the purpose of this question, alternate scenarios are scenarios that aside from the main scenario also lead to the completion of the user goal; exceptional scenario are scenarios that do not lead to the completion of the user goal.
I've been having a conversation with my professor regarding one of his statement... |
I'm currently looking for a good solution for the following use-case in C++ (preferably C++11 or C++14):
The program is running a server with a TCP connection. Other clients can connect at any time to this server and trigger a calculation (which takes a few seconds). There should only run one calculation at a time. Oth... |
I am stuck at understanding a concept related to Logger creation, especially in the context of Java EE.
In my experience, I nearly always used one logger per application, with few cases when I needed a specific logger for a specific part of the application. Only in these cases I was creating through my wrapper a new lo... |
I'm writing code that imports values from a CSV file. As part of the import process, I need to write warnings to a log (displayed on screen) when values in the CSV file are invalid.
The method below takes a string value, and a maximum value to check against.
My concern is that the method does two things: it parses a va... |
Intent
Packages should be designed to perform a single function well.
Ideally this means that they should be highly modular and different packages should be able to be 'plugged-in' simply by ensuring that they share a common interface.
However, I'm unsure how to do this without creating some kind of dependency between ... |
Javascript in the DOM has a peculiar characteristic. There's a different Object object that an object (by default) inherits per window.
In order to find what kind of object is being sent to a function when an object from a different window may be given, the methods I've read to know what was given are the use of duck-t... |
I'm not talking about distributing any GPL software. I'm talking about using the output of a GNU GPL software in commercial purposes.
For example: I use kdenlive for my video editing and inserting titles in my videos. So basically, the titles are the text, and in the gnu website faq they are saying that when a software... |
I'm using Spring-Boot + Jackson to implement a Rest API. When I return some object from my methods the controllers are building a JSON compliant response. However, that's not happening when I return primitive wrappers as String or Long (they don't act as property-value maps, they're just value wrappers in Java). Is it ... |
We know the Decorator design pattern, but how would someone go about implementing mutually exclusive decorators?
Let's say I have a decorator pattern to implement weapon modifiers in a game. The decorators would be, for example, "poisonous", "fire-enchanted", "ice-enchanted", etc. Now let's say I don't want my weapon t... |
I'm modelling a system that is a combination of two distinct yet similar data repositories**: one containing patent data and one containing trademark data. There is a very large overlap in the schemae, i.e. each database contains much of the same type of information.
To get more specific: there are "cases" -- patent c... |
I'm unsure of how to go about implementing a certain aspect of my objects.
Given a model class that represents an object, with business functionality based on various events, how can we graph the object without invoking those events?
Basic Model
public class MyObject
{
ObservableCollection<RelatedEntity> RelatedEnt... |
Is there an algorithm to generate the pips on a die or domino?
I know that there is usually an odd number of columns and even number of rows (unless the max number of pips is not a perfect root).
At this time, I have a lookup map which stores where the pips are located on the face, based on the count. If you would lik... |
Sorry for the terrible title but hopefully these snippets will give you the gist.
Method 1:
class Person:
def __init__(self, name):
self.name = name
def set_name(self, new_name):
self.name = ' '.join(s[0].upper() + s[1:] for s in new_name.split(' '))
def __main__():
me = Person('Foo')
... |
I find that in my code, many methods in a class or a set of related classes have quite similar arguments:
Arguments:
dt_start (datetime): Starting date.
Needs to meet complex requirements x and y and z. If not p then q or
the unicorns will be bitten by the python. An antidote may be hard to
find. Bla bla bla, lo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.