instruction stringlengths 34 36.1k |
|---|
I love taking apart applications, software, and websites to see how developers were able to create a feature or how a game handles AI.
Something I'd like to be able to do is view an app's files (code specifically) but I haven't been able to find a solution on Google. I've seen YouTube videos before mention things abou... |
I just learned that static library building skips the linking stage, which explains why my build process succeeds all the time when it's possible I actually haven't implemented a function in my header. In an executable project, the linking stage would alert me if I had done this.
What is the typical workflow for static... |
Say we have a normal pure function such as
function add(a, b) {
return a + b
}
And then we alter it such that it has a side effect
function add(a, b) {
writeToDatabase(Math.random())
return a + b;
}
It's not considered a pure function as far as I know because I often hear people call pure functions "functions w... |
A week ago, I was at LFNW and as I was talking with Larry Hastings after his talk, he said (paraphrased):
There's something in Git that makes the Pull Request workflow possible that isn't there in Mercurial. That's why Pull Requests on BitBucket are not great.
(For context, we were discussing the fact that Python is ... |
At my company, we're building an SDK consisting of a number of assemblies. For example, we deliver an assembly called Company.Platform.Security that contains the implementation of our authorization model.
Now, this assembly contains code that talks to other services over HTTPS. It therefore needs to discover where thos... |
For the company I work at, all of our projects,
including a new one started last year, are written in C89.
We write for vxWorks (a real time embedded operation system).
Our software runs multi-threaded through various spawned "tasks"
We are massively behind schedule, and I am struggling to be productive based on the co... |
Say I have a method that writes a string to a file:
public void write(String content, File out) {
// writes content to out
}
If I want to protect the parameters and ensure that they are not re-assigned a new value within this write method, I can use the final keyword to prevent this:
public void write(final String... |
I'm hoping this question isn't too broad or too prone to opinionated answers, since I could really use some pointers.
I'm trying to come up with a way to persist tabular, spreadsheet-like1, data in a backend. Since the data could very well end up being rather fuzzy (not easily identifiable as being identical, even thou... |
I have a Bash script that processes files read from standard input, one pathname per line, and runs a CPU intensive task on each file. I happened to notice that even with four cores (grep -c ^processor /proc/cpuinfo) only about 25% of the processor was being utilized and that the disk IO rate was way lower than its cap... |
I'm currently trying to understand Yen's k shortest paths algorithm. I based myself on the original paper as well as on the Wikipedia article, but still cannot see why it is correct if k > 2. In fact, I don't even see why it works on the following example:
For instance, let's consider the 3 shortest paths from A to D.... |
I'm uploading to GitHub for the first time and I am facing all sort of doubts about licensing. I did not know that topic was that uncovered in the net! But even it is complex, my situation is so typical that I guess most people using Github knows already about this.
I just want to upload publicly an app which is refere... |
I have a variable which I want to use in only one function. I can write my code like this:
var theAnswerToLife = 42
var multiplyIt = function(x) {
return ++theAnswerToLife * x
}
I have some other functions in that file, which don't use that variable. Therefore, in order to limit access to that variable to only the ... |
For classes with optional fields, is it better to use inheritance or a nullable property? Consider this example:
class Book {
private String name;
}
class BookWithColor extends Book {
private String color;
}
or
class Book {
private String name;
private String color;
//when this is null then it is ... |
I am currently applying some pre-processing to this dataset. Some of the digits are extremely rotated and I would like to know how others managed to get them 'upright'.
I have implemented something on matlab which finds the difference between (most bottom pixel) - (most top pixel) and (most right pixel) - (most left pi... |
If I have function which returns a future, is there any reason to also include a callback where the callback is simply called right before the future completes?
The only advantage I can think of would be to guarantee that some action be performed prior to any tasks pending on the future and also that the action be guar... |
Valgrind does not report a memory leak during my actual usage, only during my scripted test that I scripted with a shell script to test my own shell. I found that I didn't have to use malloc every time I did. For example, strdup could do it for me. Now I wonder if it is possible to formally prove that I really need ma... |
The classic development phases are
requirement elicitation
design
implementation
testing
maintenance
Currently we are having issues with UX joining the mix. My current job lets UX build wireframes as the very first step, and they are treated as SRS. This has led to a lot of incomplete designs, wrong technical assumpt... |
The following code uses a boolean preference active: In the active state, it does an operation which could throw an exception. On this exception, it does fall back to the non-active state.
let active = somePreference;
function getValue(parameter) {
try {
if ( active ) {
return valueStore.query(p... |
Is there a concrete reason to prefer executing callbacks to functions before or after exiting the called function? Example
function doSomethingPossiblyAsync(callback) {
if (errorDetectedImmediately) {
// call callback immediately before doSomethingPossilbyAsync has returned
callback(someError);
}
...
... |
I am trying to automate Business Process which can be characterized as a
pipeline with distinct stages.
Pipeline can be perceived as A->B->C, where A,B,C are distinct Business Steps that work on some common POJO.
For example, lets consider this Business process:
Business needs to identify whether a Book can be sold ... |
I learnt about the check testing framework today that seems good. This far I've scripted tests that uses valgrind so that the tests both display output from the tests and from valgrind. Is there a disadvantage in using many test frameworks like valgrind testing for internal memory management, check testing for unit tes... |
In a method where any positive number returned would signify success, would it be good practice to use negative numbers to define error conditions? Could then use enums to make readable.
|
We are implementing a CAD program (in C++, Qt) where we have interdependant classes :
The smallest brick is the Pattern, it is just a distribution of points. Then we have Layouts which contain Patterns at a given height (z = constant). And finally Stacks, which are a stacking of Layout.
All these entities have a unique... |
I have a class that uses a type, but it doesn't need to know anything about that type. In Swift, I can code this up one of two ways:
protocol Type { }
class Class {
// use Type
}
or
class Class<Type> {
// use Type
}
Right now I'm leaning toward the latter because if the client wants to use an empty protocol... |
I have one BL function and one SQL stored procedure (let's name it: getPersonDetailsById) which returns person details by passing his PersonId.
Now I need to get the same details (data table) but by passing the person's Email because for the same flow I don't have the person Id.
What's the right way to do it:
Option 1
... |
I feel like I should be able to register all my components into the application composition root container no matter what the current state of the environment is, even in the case environment lacks parts of configuration required to proper working of some of its components.
Currently, I sometimes run into code that for... |
Let's say you're building a social web app where an aggregate root (f.e. BlogPost) could be liked and unliked. Now consider a malicious user who wrote a script to perform an endless amount of like and unlike on the same aggregate, maybe he hijacked multiple user accounts to do it in parallel. This would mean the aggreg... |
Background
I have an object that represents a test procedure that I need to run on a product. This object may be used multiple times during run-time, depending on how many times the user elects to run the test. Here is where the design challenge starts. This TestProcedure object contains many members that maintain thei... |
What is the proper way of storing a changelog, similar to git, for data in a database.
Currently, I have it set up so that every line in a table is given a unique string id that is used to determine where an edit occurs. When a user wants to change the value in column juice from Apple to Orange, it logs the date, tim... |
So there are two ways of teaching a neural network as far as I am aware of.
You supply the AI with test data and the correct solution to the problem. After some time the network will be able to get the answers right.
Example: Hand-writing recognition. You supply the network with images and tell it what numbers they re... |
So recently in school we have started programming klm25z boards using ARM Assembly. I was wondering if in most industry jobs, microcontrollers are really programmed in assembly over C. It seems to take at least 2-3 times longer to program in assembly and does not seem to have any significant enhancements in speed, that... |
I'm writing a game in Typescript, and decided going in that I was going to try to adhere to the idea of "interface based programming", where you write code based on an interface, instead of the implementation, of an object.
I wrote up a good number of interfaces, and classes that implement them, then took a step back ... |
I've recently been looking into using JavaScript for templating and I was wondering about the legibility of using this approach.
I understand that JavaScript templating is a very common and much accepted form of templating and I do see the benefits of using this technique.
My question stems more from curiosity as stor... |
I am working on a social networking platform using a database wrapper released under GPL. I'm fairly new to using open source software, so I'm not sure what would require me to release my source code.
From my understanding, if the code is modified and distributed, the modified code must be released. I am planning on ad... |
I am dealing with a pretty extensive data set. After a few joins, the foundation table has something like 40 columns. The next 40 columns will all be calculated. I am trying to keep my Java clean of the business logic because it is fairly verbose, at times difficult to follow, and not necessarily belonging to a single ... |
I've looked up this question many many times but keep seeing different answers, what is the BEST way to save array's? It seems ludicrously infantile that there is no standard or easy way to save arrays like you would save a String or Int... How should this be done? As I understand, putting to much information into Shar... |
I'm trying to draw a UML activity diagram for the functionality of a user retrieving his password when she has forgotten it. It looks like this:
As you can see, this functionality requires two requests at different stages, one for the input of the username, the other for the input of the verification code. So the whol... |
I have set-up a MVC/PAC-like structure for a web application (unsure if it fits any of these design patterns fully). In short it is:
Routing in index.php, which selects the controller and method using the URL http://example.com/controller/method/<params>
Controller's method requests data from 'model(s)' and assigns it... |
I am looking for a system for building state machines with timed/scheduled transitions, and with events that happen periodically during a given state. I can implement it myself, though I feel like this is a common enough requirement that there would be a category of software for it.
I don't need a library recommendatio... |
I am maintaining a large portion of legacy code, written in C. This code was initially written to be comiled against Windows 3 for Workgroups, and later a version for NT was created. This legacy application is still in use today, merrily running along on 3.11 and NT workstations from the early 90's. It works and it doe... |
According to Richardson Maturity Model there are several levels of maturity in REST approach. http://martinfowler.com/articles/richardsonMaturityModel.html
Since DDD uses ubiquitous language, I am wondering what level of maturity is recommended, if a REST API is a presentation layer of my DDD project?
Using ubiquitous ... |
I want to ask if the following workflow is correct!
It is referring to a small private team.
There is a master branch where no one merges there ( except the maintainer ),
a development branch and individual branches for every user. So,every user will push to development branch.
So:
* clone the repo to your local machin... |
I'm building a software and I want to release it under Apache 2.0 license.
Unfortunately, right now, I've no time to put sources codes on public repository like Github or BitBucket. And more, I didn't give the source code to the final users.
Is it conform to Apache 2.0 license?
If the final users request the sources... |
I have created string to linq query library for internal company needs. We will use this library for querying over REST mainly, but it could be used in a lot of other different situations.
The gist of it is this, a user can create a query and put it in a url like this:
www.test.com/api/v1/users?query=$where[#eq(Name,Te... |
I really like this article about leaving the code/camp site in a nicer state than you found it - it seems like a practical approach in the real world to keep on top of code cleanliness.
I also really like feature branches as a way of developing features in isolation so that, if you don't like it, you can easily not mer... |
So this came up in a discussion over lunch about how weird the HTML, CSS and JS triangle of web technology is. HTML is a markup language, one of many. Javascript is a programming language, one of many. However CSS is really weird, it's a style sheet language.
I tried googling around but I really couldn't find a lot of ... |
How can an open source license be compatible with a multi-licensing scheme?
According to a similar question, the author of a library could potentially change its license. But problems arise when the project as already received contributions from the community, because the contributors kind of 'own' the software it self... |
I've encountered a problem in a personal project that I think could be solved by a particular data structure but I'm not sure what. The problem is as follows:
Given a set of k-tuples, provide an efficient data structure that given a position, i, and a value, p, returns a list of tuples that contain value p at position... |
AFAIK, C does not have a print function. The most basic we can get is printf. So, is there a reason why this function is not simply named print, instead of printf?
Note that this question is about scanf/readf and printf/writef. This one is about printf/print.
|
I need help architecting a data access layer using Entity Framework. Here are the requirements:
The database is preexisting, an absolute mess, and it's structure and cannot be altered
Entity Framework will be used
The database will be used by dozens of .NET MVC applications each with their own set of business objects,... |
Assuming I create a RESTful web service that looks up a user in a database given the id as a parameter.
If the user does not exist, should I return a 404 response (because user not found)? Or a 200 response with a "User not found" error message?
What's the better practice?
|
I'm new to Agile as a methodology, although I believe a have a basic grasp on its principles.
My team is currently building a framework that will support our client's application in the future. As an input, we have a bunch of requirements and even a suggestion of how the application should be implemented, at a VERY hig... |
Is it a normal practice, or a sign of a bad design?
For example I have a function that loads prefabs in a main logic class nearing 200 lines, and I can either move it out into a separate file LoadPrefabs.cs by making it partial or making it a separate class and calling extra code just by new LoadPrefabs(ref prefabs);
... |
I want to push a local repo to multiple remote GIT repositories to achieve redundancy in my backup scheme. So, let's say I plan to use Github and BitBucket to host my repositories.
I have two questions.
Is this approach advisable?
If so, how should I best approach writing a shell script to automate my backup procedure... |
I'm working on an application where I want to keep a timeout value computed dynamically using a moving average of say 100 previous response times for service A.
This value + some buffer (~3 seconds) will be used as a timeout for network requests to service A.
The problem here is, I want this timeout to improve with net... |
My current understanding of Inheritance implementation is that one should only extend a class if an IS-A relation is present. If the parent class can further have more specific child types with different functionality but will share common elements abstracted in the parent.
I'm questioning that understanding because of... |
I'm currently developing on a rather large e-commerce application that handles multiple different business-fields. Like every e-commerce application we have a Concept called an Order which has one or more OrderItems.
Due to the fact that we cover multiple business-fields the OrderItems need to store different Informati... |
Lately my team has started considering the implementation of MVP pattern in some of our applications.
We followed the several guides and tutorials out there, basically ending up with regular PresenterInterface and ViewInterface, the latter being implemented by an Activity or a Fragment.
As for the PresenterInterface, w... |
I'm working on creating a C# wrapper library around a native C library that allows me to directly communicate with a particular piece of hardware over a serial (COM) port.
Of course, the C library returns success/failure codes from its methods. I'd like to translate those into exceptions, but I'm having a hard time fi... |
I downloaded a GPL program, I want to modify this GPL program in order to make it calling a non gpl program (commercial license) via fork+exec.
Concerning the input/output data of the non-gpl program:
The input data are the arguments of the command line of the non GPL program
The non-gpl program is sharing his output ... |
Background
Here is how I currently log any exceptions that occur in my code:
Pass each object instance the path to a file where I want all of the logging to happen.
Each of the objects have their own exception logging code, which is called in a finally statement.
One downside I could see to this, would be that if I h... |
I have an array of items. Some items have a number on both sides. I'll call these "matched pairs". I need to sort the items between the matched pairs in a particular way.
There's a "from number" and a "to number"
There may be more from -> nil than
nil-> to, or vice-versa.
There may also be NO items between the match... |
Is there a phrase in common use for a counter that is incremented every time the state of an object changes?
It's not quite a timestamp and it's not quite a revision but maybe there is a common name for this.
The usage is to provide loosely coupled portions of code with a simple way to quickly check if a large object h... |
This is a function that searches child nodes recursively until it finds one that is a text:
_.findPrevText = (node) => {
if (node.nodeType === 3) return node
return _.findPrevText(node.lastChild)
}
I could also write it like this:
_.findPrevText = (node) => {
if (node.nodeType !== 3) return _.findPrevText(node.l... |
interface IRepository {
Data getData();
}
class BaseRepository implements IRepository {
public Data getData() {
...
}
}
class CacheRepository implements IRepository {
private final IRepository mRepository;
private final ICache mCache;
public CacheRepository(IRepository repository, ICache cache) {
... |
Examples:
isKeyValid -> keyIsValid
hasPostThumbnail -> postHasThumbnail
The first case is easier to remember (convention). The second is easier/more natural to read.
Which should I use?
|
I've recently deleted a java answer of mine on Code Review, that started like this:
private Person(PersonBuilder builder) {
Stop. Red flag. A PersonBuilder would build a Person; it knows about a Person. The Person class shouldn't know anything about a PersonBuilder - it's just an immutable type. You've created a circ... |
I recently found a website (LINK) which explains various ways of performing curve fitting using Math.Net. This is one of the only websites I have found that explains the methods and also provides example code. As a result I downloaded the source code to examine and alter for my own purposes. At the top of each class is... |
My understanding of escrow, as it is used in software projects between a "client" (commissioning the software/app) and a "contractor" (developer; provider of application services) is as follows:
The client & contractor sign some type of Master Service Agreement (MSA) and 1+ Statements of Work (SoW), which identifies h... |
I have a table that contains the percentiles from a reference data set.
CREATE TABLE [Core].[RiskFactor](
[SpecialtyCode] [char](2) NOT NULL,
[RiskCategoryId] [int] NOT NULL,
[Percentile] [tinyint] NOT NULL,
[RiskFactor] [numeric](5, 4) NOT NULL
)
Each combination of SpecialtyCode and RiskCategoryId will have 101 rows... |
We're building some Roslyn analyzers concerning GetHashCode(), including an analyzer that implements it for you in a given class.
While researching the subject we've found that there are many considerations to take into account, mainly on what kind of members should be avoided in a GetHashCode() implementation.
The mai... |
Background
I've been doing a bit of image manipulation recently in PHP/JS. The basic functionality is such:
Web page loads, an <img> tag points to a PHP script which generates an image "on the fly". Interacting with various parts of the page changes the src via jQuery's .attr('src', 'newsrc').
I had thought about putt... |
I am trying to implement an agile-ish approach to our firm. Right now we have a very much waterfall like approach to designing, coding, testing, and releasing. One major issue we haven't found an answer for is the idea of quoting. We allow our customers to request small to large changes in the system and pay for those ... |
Most of DDD tactical design patterns belong to object-oriented paradigm, and anemic model describes the situation when all business logic is put into services rather than objects thus making them a kind of DTO. In other words anemic model is a synonym of procedural style, which is not advised for complex model.
I am no... |
I have a simple zero sum, discrete, deterministic, complete information board game. I want to machine learn an evaluation function for an AI agent.
Suppose each board state has ~20 identifiable features which could be weighted to form an evaluation function.
Suppose the time constraint for both players is 15 seconds fo... |
In Sweden the abbreviation "t.ex." means "for example" ("till exempel") and it is extremely common. Every time I write that t.ex. in an email or in a text message it gets marked up as a clickable hyperlink which damages my message.
How difficult is it to match hyperlinks without getting false positives?
I remember see... |
I want to play video using ASP.NET MVC. In my understanding, the model deals with the video files stored in file system and data in database. The controller retrieves the path of video file from model and sends it to the View. So who handles the work of streaming video actually? To find it out, I searched online and f... |
Why is it that some languages don't even have a boolean type (and uses a constant TRUE instead), but they have many other and modern types? Sometimes it can be trouble if you make a boolean and then realize it can have three different values or more, then it's going to be difficult if you have old data with the boolean... |
I was wondering if long long specifies a single datatype then why don't things like int int work? I meant obviously that's not a data type but there is a long data type. Essentially what I'm asking is:
int a = 0; //okay
long b = 0; //still fine
long long c = 0; //really long number but its okay....
int int d = 0; //e... |
A friend of mine was recently asked this question in an interview.
Lets say there is a continuous stream of incoming events E1, E2 each with timestamp of entry associated with them. Write a java module to Make a call to raiseAlert() if at any point of time there are more than 1000 elements incoming at the same time.... |
What i'm trying to implement is a program that is searching for the fastest connection from one station to other at a given time of the day.
I have a number of stations n, and a number m of lines that connect this stations. Each line has (departStation, arrivalStation, busDepartTime, busTravelTime).
When I want to sear... |
I am trying to implement DNS-SD, and I understand how it works, but don't really understand the purpose, so I have a few questions about it.
Let us assume that we have two devices on local network, and we registered services both devices provide, how dns-sd really helps us, it just replaces ip:port/path/to/service with... |
After I installed "Wappalyzer", extension wich display technology, wich site using. I checked many sites and in most of cool projects, like "Youtube", "Github","stackoverflow" etc, wappalyzer display only some js framework and comercial things.
But when I checked sites, wich I builded on Django, wappalyzer display all ... |
I am writing a poker application and trying to figure out how to deal with split pots and side pots
There are four rounds of betting and each round of betting can have multiple orbits
Can only bet the chips in front of you
So if a player is all in a side pot is created
Hands can tie - in which case the pot is s... |
So we are writing medium size software,and it has two parts frontend is written in angularJS and backend in laravel. Laravel provides api and nothing else.
Now very often one of many dependencies gets updated.
Now shall we take the bite and upgrade or do not disturb the system since it is working fine?
|
I develop iOS app with some GitHub controls and Framework as like FMDB,AFNetworking,OpenCV,RadioButton,CheckBoX etc... but now my worry is I want to distribute this app with Apple Enterprise account (not on app store).
I already read some post which say we can use to distribute app with these licence but they were in w... |
I have a question about assigning values to nodes laid out in a physical space:
There is a set of N fixed nodes spread out throughout a certain 2 dimensional region that need to be assigned a value from 1 to M. In this case, M is less than N. Preferably, nodes that have the smallest distance between one another should... |
While I am starting to get a hold of NodeJS programming, I am a bit confused by when to use request params and how their practical use differs from using query strings.
In particular, I can do localhost:8080/:param1 in the URL followed by req.params in the code or localhost:8080/?param1=value in the URL followed by re... |
Let us say that I want to create a workout app and a website, the user enters his workout stats and the app display his stats with graphs percentage and such.
This is an example I don't want to create a workout app, just to understand how platforms work.
Assuming that I want to have an Android, iOS app and a website. A... |
In today's cross-platform C++ (or C) world we have:
Data model | short | int | long | long long | pointers/size_t | Sample operating systems
...
LLP64/IL32P64 16 32 32 64 64 Microsoft Windows (x86-64 and IA-64)
LP64/I32LP64 16 32 64 64 64 ... |
I am looking for an algorithm to create a raffle, where each participant is assigned a ticket with a random series of numbers.
Each raffle hast N participants, and there should exist same amount of raffle tickets, one ticket per user.
The user should know her ticket numbers before the draw, so she can follow the draw, ... |
I have a class that enforces database-friendly formatting for some of its properties in the __construct() method.
This guarantees that if a new object is created and saved, it will be saved correctly. But saving new objects happens rarely. Retrieving them happens thousands of times more frequently, and these same rules... |
I need to perform quick searches against a combination of tags while including date ranges:
Example:
Users
who have requested notifications
who did not respond to a notification sent at least 3 days ago
and who have not been sent any other notification in the past 3 days
Data Structure
The event data structure is... |
Can anyone suggest an algorithm for this problem.
Given an undirected unweighted cyclic graph, and a given start and end node in that graph, I'd like to determine if there is exactly one valid path from start to end visiting all nodes (i.e. a Hamiltonian path, not a cycle).
It's NP-hard, but my N is relatively small (u... |
I have been working on a application that up until now has been pure Node. However I am concerned about performance and overhead since the application performs a lot of file system operations (Copy directory, file writes, Remove Directory, zip....)
Everything works like a charm, but I am thinking it would be best to m... |
I am reading Think Python: How to Think Like a Computer Scientist, the author says that an algorithm is:
A general process for solving a category of problems.
But I don't know if that a right definition of an algorithm. Isn't an algorithm aimed at solving a specific problem [finding if a number is odd or even, for e... |
I am currently working on a project which requires data fetching from a 3rd party closed API (over SOAP).
Currently I'm in a situation where I have to do argument and data validation inside our application code, because the mentioned 3rd party API does not return anything relating to errors. Examples:
Request somethin... |
Problem Statement
I am going to write a library to control a whole bunch of relays, and I am just trying to think conceptually right now.
Here are my design constraints:
We have an exact number of relays that need to be controlled, and this number will never change (because once we build a board we will never add rela... |
If we are working on multiple ASP.NET MVC projects that share a lot of common stuff like CSS, Scripts, or even utility C# methods, etc... what is a good way to keep them in one place ? Currently I have my own CSS, another developer has his own CSS for the same stuff ,etc.. and this gets out of sync this way. We are usi... |
I am looking for the following workflow:
Add an entry to a table of my Postgres database with a end_date and state (with the following values: active or done) columns.
Execute a lambda at the exact end_date value to update the state of this specific entry from active to done
The only ressources I found on Google abou... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.