instruction stringlengths 34 36.1k |
|---|
EDIT: In case you aren't familiar with OData, here you go.
I am trying to determine whether it is worth learning this technology or if it is something that is not going to catch on.
The premise is interesting, and as a developer of APIs it seems like a good way to offer more flexibility to the developers that consume t... |
Should unit tests be written by the developer who wrote the code or someone else ? And how effective is writing units tests as a method of learning a new system ?
|
The start of the ISC license is:
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
I'm not interested in attention or credit, so I'd like to remove the line:
... |
For my program, I implemented AABB collision which works fine. When AABB collision detects a collision between 2 boxes, I want to find the surface area of portion where the 2 boxes are overlapping. Is there a simple equation to use to find out that surface area?
The main issue: So it was really easy for me to point ou... |
I need to handle different elements in a vector, each element owning a specific parameter (integer or string), so that I can easily handle encoding/decoding of a series of elements.
Encoding a list of elements serializes the elements, inserting a separator in-between each.
Decoding a string consists in finding the sep... |
We want to be able to implement cross-browser compatibility by overriding markup, scripts and styles only where necessary. We want to avoid forking everything sent to the browser, as has been done in the past!
This has led me to a directory structure with one folder per "page", with "master" markup, script and style fi... |
I am writing a library which deals a lot with sub-sequences of ordered containers.
So for example I have a container (1,2,3,4,5,6) and a user wants to access (3,4,5).
I am providing the subsequence by a pair of iterators, pointing to its first and last element respectively, i.e. 3 and 5.
Since the library is written in... |
I wasn't sure exactly what to call these situations, so I'll illustrate it.
If I have something like this in a method:
if (i <= 5)
doSomething();
else
doSomethingElse();
but I know that i will never be less than or equal to 5 once it exceeds 5, it becomes unnecessary to continue checking the if-statement on... |
Consider the prototypes of C's dynamic allocation functions
malloc - void* malloc(size_t size);
calloc - void* calloc(size_t n,size);
realloc - void* realloc(void* ptr,size_t newsize);
Now a statement like following
int* p=(int*)malloc(sizeof(int));
I know that casting to (int*) isn't needed in C since a void poin... |
While reading Computer Architecture by Patterson (page 194) I got this question. IEEE 754 uses 127 as bias for single precision floating point so that it will be easy to compare floating point numbers using hardware.
1.0 * 2^-128
biased exponent = -128+127 = -1 = 1111 1111
1.0 * 2^1
biased exponent = 1+127 = 128 = 100... |
I am in the process of designing 3 components that will work in symphony with one another:
A RESTful web service which requires BasicAuth over HTTPS on all calls, and which is what actually does all the heavy lifting for my system (does the work)
A web UI that translates end user actions into API calls to the above-me... |
The PM of the company I work on, always asks me to estimate maintenance issues and since there are several legacy systems that I didn't build, makes this hard to get.
He says getting estimations for every task is necessary to have a clear plan, since I'm involved in projects and maintenance tasks.
Do you guys have the ... |
There is a piece of software, free, and open source, under the MIT License.
I make modifications to it, make it better, etc. I distribute this new software, also for free and open source.
But can I revoke from those that use my new version the right to sell? I'm not ever going to sell my modified software; it will alwa... |
Given an app, controller, model and repository (which holds representation of model), where should the sync service for the repository live?
In my specific implementation, my app/controller are AngularJS, models are generic JS and repository is a repository/datastore containing a representation of the data from model. ... |
Switching to new system and need to keep old data going for some time. So, we need to update old database with data when new system being updated.
It's a transactional data, like orders/shipments. Databases similar in principle but structures different. When change made to Order in new system - up to 10 tables need to ... |
I have a programmer on my team who wants to take all the control flow logic for handling events sent by any module and put it all in a single file, because they think it will make an already-complex system easier to maintain and grow. How can I convince them that this is a bad idea?
Sources to reading material are welc... |
I've been trying to figure out an algorithm to go from an infix equation to a syntax tree, like so:
(1+3)*4+5
+
* 5
+ 4
1 3
However, I don't just want it to handle operators, I want it to handle functions with arbitrary argument numbers as well, i.e:
max(1,3,7)*4+5
+
* 5
max 4
1 3 7
Her... |
Various online resources offer proxy lists claiming that they offer various levels of anonymity. I'm trying to find out how this can be programmatically tested. I suspect the answer lies in headers. Would testing a proxy's security by running a sender/receiver and seeing what headers come through the proxy on the recei... |
In the Importing External Crates section of the Rust book the author creates main.rs file in an already existing library project. I randomly picked up a bunch of crates from crates.io, examined their structure and did not find any project containing both lib.rs and main.rs files. So i'm wondering if it is common to hav... |
I've been attempting to learn C++, but it is famously plagued by bad tutorials. I learned about a clever little trick called RAII (Resource Acquisition is Initialization), where one wraps a heap variable in an object placed on the stack. One would free the resources in the destructor of this object, so one would not ha... |
Here's a chunk of commit messages from our repo. It's mercurial but I believe in this context git will be relevant as well:
Viktor Bubnidze TEST: chat send url fix changeset
Kate Gunicky PROJ-15754: [work-space] Chat Section CSS issues
Vadym Malan Merge
Vadym Malan TEST: char send url test
Ron Cosby M... |
By this below definition(pre 1.8) of Iterable,
package java.lang;
import java.util.Iterator;
public interface Iterable<T> {
Iterator<T> iterator();
}
I would say that, Iterable is dependent on Iterator interface as shown below,
package java.util;
public interface Iterator<E> {
boolean hasNext();
E n... |
I'd like to avoid having the cookies banner on my websites where possible. Could I store session id's in localStorage to bypass implementing the banner?
|
I have a private helper method that uses no instance variables or methods, I feel it would be less confusing if it was static (this way, it's given fewer points it can access).
I am a bit unsure if this question applies to private methods too.
I've also taken a look at this second question but again testing is not goin... |
I'm doing some changes in the Linux kernel code and have noticed a pointer being cast into integer.
Check out buf below (full code):
snd_pcm_sframes_t snd_pcm_lib_read(struct snd_pcm_substream *substream, void __user *buf, snd_pcm_uframes_t size)
{
....
return snd_pcm_lib_read1(substream, (unsigned long)buf, si... |
I have following entities:
Data:
User_id
Categories: Interests, Disinterests, Categories A, B C...
Each categories have sub categories: Interests=Gaming, Physics, Programming etc..
Now each user could belong to multiple sub categories.
So there is M:N relation ship between categories and users.
Scale:
1 Billion User... |
I want to setup a continuous integration pipeline for the first time. I have a website that includes a config file that points to MySQL and Redis. I would like to build a package once and then deploy it to test, UAT and live environments.
I don't want to rebuild the package after deploying it to each environment becaus... |
According to the Stable Dependencies Principle, the dependency
should be in the direction of the stability
But:
if you don't know what types of changes are likely, it is best to wait and see what happens as the system evolves.
Now:
Say I'm designing a blog, I am tempted to think the stability ranking is:
Comment ... |
Why do most programmers use i++ in cycles? Doesn't it mean evaluate and increment. I find more logical to use just an increment i+=1, because that's all I want.
WriteLn(i++); would evaluate i and then increment, does it somehow remove the evaluation part if i++ is used in cycles?
|
I have recently discovered the Builder pattern and the Step Builder pattern which are essentially just like object initialisers but with the Step Builder pattern you can add mandatory fields.
We have classes which have lots of constructors which have tons of parameters and each constructor is just a variation on what p... |
I'm in the beginning of a project which I want to have the best testability and maintainability possible. To achieve this, I'm reading a lot about concepts in the DDD area, mainly.
To get you contextualized, suppose the following entities:
User
It's basically a container for Accounts (see below) and configurations;
Ac... |
Is a long XSLT file a code smell?
In imperative programming languages it's generally acknowledged that very large classes and/or sub-routines are an indication of possible problems, e.g. a class that is doing too much. Such a class should be considered for refactoring into multiple smaller classes, each having a clear... |
I have a component which outputs an ICollection of the following type:
public class CoordinatedInjectableValue
{
public int XOffset { get; set; }
public int YOffset { get; set; }
public object Value { get; set; }
}
This is used to describe what is basically a dataset, so for a given XOffset value, the "V... |
The litterature on multi-label learning uses the terms: multi-label learning and multi-label classification. I was wondering what the difference between these terms is, and when to use one over the other??
|
I've followed a series of optimizations to make our APIs faster. We microoptimized a lot of PHP code to faster, native methods, we unset variables where they were not being used anymore, and basically improved anything that could be improved in the server code (MySQL queries were left untouched).
We improved the time a... |
Sorry for the poor title but I didn't have a better way to phrase it...
So there's this amazing game by Nintendo (yes!) on Wii called WiiPlay. There're 9 minigames in it, and my favorite one is called Tanks!. It's about destroying COM enemy tanks without getting yourself destroyed. Here's a screenshot of a level:
One ... |
So I'm making a clone of Super Mario Bros in pygame. As of now I am in the middle of making my keypoll function, to check all the keys that are currently being pressed. I am wondering which would be better:
Have the keypoll function modify marios attributes (ex. horizontal direction), then based on those, have mario d... |
It's a pretty established convention that database table names, in SQL at least, should be singular. SELECT * FROM user; See this question and discussion.
It's also a pretty established convention that RESTful API resource names should be plural. GET /users/123 and POST /users See this one.
In the simplest database-bac... |
Consider the following loop (in Swift - but my question is language independent):
var index = standardizedTimeSpans.count - 1
while index >= 0 && timeSpan < standardizedTimeSpans[index] {
index--
}
index++
In the above code, the standardizedTimeSpans variable is an array of Doubles and the tim... |
An algorithm is given on GeeksForGeeks.com for constructing a Binary Search Tree from its preorder traversal.
They say that the time complexity for the following code is O(n^2). But in my opinion it should be O(nlogn). I'm confident about calculating O() for most algorithms, but here there's a divide and conquer algori... |
Let's say I have a field called "FooName" and I have "FooName" in several places across my web application (ASP.NET MVC4). I have a check box that allows me to turn "FooName" on and off across the application. Currently, I have access to the checked value (I can grab the saved value from the database) but I'm not sure ... |
I noticed that the filesize of Ruby's interpreter seems suspiciously small.
I would have expected /bin/dash to be the smallest of all, but is 20x larger than Ruby:
Interpreter Bytes
------------ ---------
Node 0.10.32 8,790,152
Python 3.4.0 4,061,272
Bash 4.3.11 1,021,112
gawk 4.0.01 441,512
Dash ... |
I'm building a desktop app with a Java front-end and very performance critical Fortran libraries. We've recently started pushing more of our code out of Java and into Fortran (see below)
Soon we will likely have modules in SCALA (using akka.io or JPPF's distributed computing system).
I'm wondering what I can do to try ... |
I'm making my first C# app and I am having a bit of difficulty with separation of concerns. I understand the concept, but I don't know if I'm doing it right. I have this as a quick example to illustrate my question. In an app such as a game, there is a main class that runs the main loop, such as Program or Game. My que... |
I want to design Database which works as below explained.
We have some members and they are listed in many categories.
Among members, some have special privileges.
We have Memeber Table
We have Category Table
Member- category relation maintained in separate table
Member- privilege relation maintained in separate ... |
So far I was under the perspective that while working in the kernel code, working with memory implies working with long integers and not pointers because dereferencing pointers shouldn't be done in the kernel code:
A quote on the topic from LDD3:
Although, conceptually, addresses are pointers, memory administration
... |
I want to distribute a Java class I borrowed from the GPLv2'ed OpenJDK and modified for my own needs as a part of my proprietary application.
The header at the top of the source file states (and I've preserved the same in the modified copy):
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reser... |
I have developed the bare bones on a socket server in Python. I'm trying to capture the HTTP packets going to a web server without blocking them.
try:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.bind(('0.0.0.0', configuration.get('port')))
except OSError as OE:
... |
I'm looking for a understandable definition of memory pages. Please help me clarify the following questions:
Is a "memory page" always related only to a data chunk of virtual memory?
Are physical RAM addresses also split into pages?
How does a definition of a "memory page" as the smallest unit of data for memory manag... |
My proprietary Java app includes a modified version of a 3rd party library distributed under Apache Software License, version 2.0. The 3rd party library doesn't come from the Apache Software Foundation, neither does it include any NOTICE file (mentioned in 4.(d) section of the License).
Do I need to distribute the mod... |
I am creating simple desktop application in javaFX 8 and I would like to be able to save the state of the model and load it next time the application starts. Therefore I am implementing the Serializable interface with all my custom model classes. First they were pure POJOs.
But in javaFX application when I want to bind... |
I understand that in HPC hybrid systems, for instance a MIC architecture, main memory access is much slower than access to data in own cache or in the cache of another core.
I read that HPC MIC architecture works best with programs with streamed memory access, or negligeable memory access.
When do we say that w program... |
I spent the last week deep diving into the Akka docs and finally understand what actor systems are, and the problems that they solve.
My understanding (and experience with) traditional JMS/AMQP message brokers is that they exist to provide the following:
Asynchronous processing between producer and consumer; and
Messa... |
The standard practice in the Objective C world has been to follow that laid down in the Java world when it comes to code management. i.e. Your application source code goes in one directory, and your unit test code goes in another.
I've always found this a bit of a pain. Especially as I tend to organise XCode the same ... |
I have two classes. 1. Node 2. MixedStateManager
Node class:
Node class maintains the state of nodes in the system. One such data is state.
public class Node
{
private int state;
public void setState(int s)
{
state = s;
}
public int getState()
{
return state;
}
... |
I often write code which makes an object and then use static methods in static classes to manipulate said object.
Am I missing the point of OOP? How do I know whether I'm thinking in the OOP mind set? I doubt I am...
|
I am doing a coding project in rails. I have a user model, and I want to add a "spouse_id" to it (which would reference other users). Can a model reference itself in a foreign key?
|
Dedicated interfaces seems to be a good way to expose the optional features in a domain-specific type hierarchy. However, they impede the use of decorator and composite patterns, which is also common in this kind of hierarchy.
Especially, probably no one wants to implement a decorator/composite for each possible combin... |
I am designing a REST api for a document management system. To make the API more natural, I thought about using the natural identifier for a file, which is it's path (usually having forward slashes "/" in it), and not something like an artificial id such as a UUID.
Naturally, a user would identify a file by it's path:
... |
I finished building a Python script containing eight functions which download files, extracts them, manipulate and analyze their data and then produce graphs and export them into PNG files.
The input files are located in a remote FTP site, but some intermediate files and the output PNG files as well are saved locally ... |
I am learning the union and struct and I wrote the code below. What I do not understand is why the output is different when I change from a little endian to a big endian machine.
My understanding is that endianness is important when you have more than one byte. But I have only 8 bits.
This code is not portable at this ... |
I know this is a fairly large/broad category, but I've been racking my brain over the last few weeks on how to simulate fluid flowing through pipes. In the environment I'm working, I can have a single pipe segment connect in any of the six directions (the four cardinal directions plus up/down) and am not restricting my... |
So I was reading section 3.2 (One definition rule section) in the latest working draft of the C++ standard and came across this:
Every program shall contain exactly one definition of every non-inline
function or variable that is odr-used in that program; no diagnostic
required.
This struck me as strange with rega... |
Here is my exact scenario.
I must make requests to a third party service
The service takes ~15 seconds to respond
It also has no webhooks or any call back mechanisms
These requests are not made constantly throughout the day, but in chunks
The requests to the third party service are made from a consumer that is pull... |
tl;dr: I need a development workflow for ASP.NET apps that works for the designer on a Mac, the content writers who don't have visual studio, and the C#/.NET developers (mostly me), such that we can have Continuous Integration and normal branching and merging.
Current workflow
A designer and a few content editors make ... |
I'm very new to Parse and trying to set up what is basically a voting app where I can collect data on how many times all users have pressed a button. I found some information on Atomic Increment Operations from Parse but I'm trying to have this feature be implemented as something like a singleton.
So if I wanted to do... |
From what I've read and understand MVCS (Model-View-Controller-Store) is a design pattern that lets you do the following:
View - Application view, what the user will see.
Controllers - Manages the views and calls the models.
Model - Business logic.
Stores - Calls to db for CRUD operations retrieving and putting data.
... |
I know this has been said to be pretty much statistically impossible but that's a different question. What would be the consequences if against all odds, this did occur?
|
I am wondering if the absence of a license file (not having one at all) in code exposed to the client side provides any rights to copy or modify the code? Specifically, in reference to client-side JavaScript code packaged as a single page app.
Do people have no rights to my code unless I give them rights via a license... |
I am working on a blog project, powered by Jekyll. I'm having trouble figuring out how to phrase the licensing text, or indeed how to correctly license it all.
Most of the tools, including Jekyll itself are Ruby gems, so that part is pretty clear: those gems are under whatever license they're under. I have a Gemfile ca... |
I'm wondering when you create a new file format, what are the options to protect said format from being used without consent? I don't think you can patent a file format based off what I have read so far. So not sure if anyone has any idea on this.
I know this might seem like a weird question given that file formats are... |
I have a friend who works in financing. His company wants a website for the company. He is really confused about a web site and a web app, and I don't really understand them enough to explain. Can you all give me some clear explanation about it?
|
I have put together a large quiz data structure. It is in JSON format but I guess it could be XML etc. It may look something like this simplified:
{
"quiz":{
"title": "Welcome to Quiz"
"entries": [
{
"question": "programmers.so is awesome?"
"answers": [
... |
I'm working on a VM (and a scripting language for it) that I plan to implement JITing for. I'm only working on the "plumbing" of it now, but I don't want the JIT compiler to be an afterthought. However, while I understand the fundamentals of it, I'm a bit confused on what exactly the JIT should do.
There are two ways I... |
I try to practice with the design patterns and explore one of the possible implementations of the Observer Design Pattern in Java. I paid attention, that in this example the object is defined with the interface type and not the class one:
//user-made observer interface
public interface Observer {…}
//observer class to... |
Alistair Cockburn says in Writing Effective Use Cases, that validation requirements should not go into the use cases. However, even after reading the chapter on Missing Requirements (meaning the requirements not covered by Use Cases), I'm not sure where I should put validation and data formats, or how I should structur... |
I'm designing an API for a JavaFX control to be submitted to the ControlsFX library. This control is called the ViewManager, and its purpose is to hold a collection of View instances, all of which feed off of the same set of data (items to display, selection state, view settings, etc...)
My original attempt was to have... |
Within a small project, a class Storage is meant to store any type of Item. Now, an Item has a String name, and an interaction. For example, a clock item might implement the interaction increment(int num), whereas a seat might implement sit(bool true).
Should I be simply writing classes for Item, Clock and Seat and let... |
We have a legacy application with, among other things, the ability to create instances classes within VB6 DLLs dynamically and call methods with varying signatures.
We have no way of accessing the legacy application's code and no way of removing it from production right now.
Our requirement is to build small plugin-typ... |
When we have a system which utilizes Domain Events, it can be quite hard to comprehend the whole workflow (sequence of events) of processing a particular command: how many active handlers we have, how many other events they give raise to, and so on.
On the other hand procedural workflow of Transaction Script is much ea... |
In my head, AI attempts get sorted into two categories. I'm wondering if the distinction is present in reality or just my imagination. If this it's real, I'd like to know of any terms for them. The two types are as follows.
The first (in an arbitrary order) is mostly seen in modern times. It consist of simulating the h... |
Is it an anti-pattern to depend on a particular order of an enum's instance declarations? For example, consider:
public enum CompassPoint {
North,
East,
South,
West;
}
These points are in clockwise order. Is there a good reason to not have code rely on this fact? More specifically, is it "OK" to rely o... |
In my code, I've got two interfaces, let's say IOpenable and IExaminable. IOpenable allows the user to Open or Close the object, and IExaminable allows the user to Examine the object.
Now, we have some sort of Tile structure which contains objects which adhere to the following: Not all objects are openable, not all obj... |
There are a lot of projects out there that rely on the public sphere to process data for them, but I do wonder how they ensure that every computer participating has processed the data properly.
The first one that comes to mind is Bitcoin mining. I know that the Bitcoin network has a mathematical way of verifying that t... |
I am trying to avoid anemic domain models as it's said to be an anti-pattern. But doing so leaves my services to duplicate some of the logic.
class User
{
public $status;
public function ban()
{
$this->status = 'banned';
}
}
Now, a ban service allows to ban users by only having user's id, so t... |
Suppose I have two interfaces I and J that is implemented by Test class. Now I need one object of class Test that is referenced by I and J both interfaces. I can do it by singleton design pattern. But the problem is sometime I won't need a single object in the program. So there is also another approach that I have know... |
I've been doing a lot of work in C# recently (my primary language is Python) and I love that I can do something like
public string MyProperty{ get; set; }
Going back to Python I miss that sort of functionality. I don't like that I would have to do
class MyClass:
@property
def foo(self):
return self.... |
C# has the out and ref keywords. Why are these two required?
Disclaimer: I don't have deep knowledge of C#.
|
I'm looking at the source code for a Rails application that uses Backbone and there are template files with .jst.ejs extensions.
The templates include HTML with lines of JavaScript wrapped in double-square-brackets like this this example:
[[ if (currentUser) { ]]
<h1>Welcome, back!</h1>
[[ } else { ]]
<h1>Please si... |
I need to build a system that can handle a fairly high amount of delayed tasks (e.g. scheduled emails). For non-delayed tasks I would go for something like RabbitMQ.
But, is it ok to let tasks lingering in the queue for extended amounts of time, like days?
Would it make more sense to store the tasks in a database and ... |
The become: message in Smalltalk causes one object to change into another, affecting all references to it.
What uses does this language feature have? Does it get used in real code? Is it just a curiosity? Is it considered a good/bad practice to use it?
|
tl;dr What would be a simple way of incorporating functions into a Shunting-Yard algorithm implementation?
If only expressions like function(arg1, arg2, arg3) were allowed (where function is some builtin function), then it would be really easy, since I could just treat function like an operator. But consider a case whe... |
One of the major issues that I have seen occur in a system with microservices is the way transactions work when they span over different services. Within our own architecture, we have been using distributed transactions to resolve this, but they come with their own issues. Especially deadlocks have been a pain so far.
... |
Imagine some code like the following:
class Cache {
private Map<String, String> values = new HashMap<String, String>();
public String getFromCache(String key) {
if (!values.containsKey(key)) {
throw new NoEntryException();
}
return values.get(key);
}
public void set... |
Imagine a scenario of two different microservices. One to handle Authentication within the service, the other one takes care of User Management. They both have a concept of a User, and will talk about Users through calls to each other.
Where would the Domain model of a "User" belong though? Would they both have a diffe... |
I have an algorithm which creates a collection of objects. These objects are mutable during creation, since they start out with very little, but then they are populated with data in different places within the algorithm.
After the algorithm is completed, the objects should never be changed - however they are consumed... |
I am trying to find out the best possible way to save the POST data in session and making it available in different page requests.
For example at website's homepage I have a Search form with different fields. On Submitting the form a product's page is displayed containing a list of all product matching the search crite... |
I started working on a website,for tracking and rating watched anime/manga/etc. and recommendations, and it should also have an API, for providing the info about series and other things.
On similar sites, I have noticed that, to use an API, one typically needs a token/auth of sorts, and there are certain usage limits, ... |
I'm building an app based on ng-seed which is angular setup with routing out of the box. I'm backing the app with a rest interface of which I aim for Richardson level 3 compliance.
Often it seems like there is some tension between the two. Lets say the api exposes some resources with links to other parts of the api. Sa... |
Although grammatically incorrect, when writing identifiers for functions, variables etc. does it make sense to simply append an "s" to plurals of words ending in Y? My reason for this would be that if you need to find-and-replace, for example, replacing "company" with "vendor", "company" would match both singular and p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.