instruction stringlengths 34 19.9k |
|---|
I'm trying to build a database for an upcoming Ruby on Rails webproject.
There will be 4 tables minium: tasks, users, attachments and comments.
And 1 table to join the n:m relations (tasks <-> users).
One task has many users, many comments and many attachments.
One comment has many attachments and was created by one us... |
I am working on a web application that displays some data and uses JavaScript.
Right now, we are serving up parts of our JavaScript code (to display certain types of information, that is, "Render a View") via our server which dynamically writes the JavaScript code with the needed data embedded in it using JSPs.
Three m... |
For my basic kernel I refuse to implement the dreaded confusion of virtual memory scheming, so I want only real memory addresses for everything. Some people have argued with me that since virtual memory is hardware supported, and sometimes the MMU hardware is integrated with the CPU, is that a rule that virtual memory ... |
So, I have an authentication module I wrote some time ago. Now I'm seeing the errors of my way and writing unit tests for it. While writing unit tests, I have a hard time coming up with good names and good areas to test. For instance, I have things like
RequiresLogin_should_redirect_when_not_logged_in
RequiresLogin_sh... |
I'm in the process of designing an HTTP API, hopefully making it as RESTful as possible.
There are some actions which functionality spreads over a few resources, and sometime needs to be undone.
I thought to myself, this sounds like a command pattern, but how can I model it into a resource?
I will introduce a new resou... |
Problem
I want to clone an svn repo with git-svn.
The problem is the subversion repository changed layouts at r1235.
Specifics
From revision 1 to 1234, foo used the standard svn folder layout with:
/trunk/src
/tags/version/src
At revision 1235, the author added bar to the repo. To do so they restructured the master r... |
The situation would be:
I develop 2 projects in my Node.js development environment, P1 and P2.
P1 required the development of two simple modules, mod1 and mod2, which are stored in P1/lib. Each one of this modules resolves find their external dependencies in P1/node_modules. Necessary dependencies for P1 have been ins... |
The Problem
I regularly find myself writing the same code over and over again.
For example if I want a value from a nested array structure I end up writing something like this:
$config = function_to_get_nested_array();
$node = $config;
foreach(array('vendor','product','config','leave') as $index => $key){
if(! isse... |
I am trying to understand how a radio button is created in a Dynamic field by reading from an XML using Netbeans 7.0.
I know the radio button is created because of the XML being read from database, but I cannot see how the radio button is created.
Also, since I don't know where to place the break points, I can't see ho... |
Our business requirements required to create a layered and modular architecture. So I designed an architecture to make it as decoupled and as modular as possible. I will list my layers below
ASP .NET MVC Application (UI)
Business Logic Layer (BLL)
Data Access Layer (DAL)
I have further used IOC where each BLL module... |
I want to apply k-means clustering to a (sparse) adjacency graph. For this I need to assign the nodes to a position in an euclidean space. Trivially I can do this by having a space with as many dimensions as there are nodes where each component corresponds to another node.
Now, in order to make the clustering a bit mo... |
I'm in the planning stage for an employee intranet system to be built with ASP.NET MVC 4. We'd like the site to consist of separate "modules", each of which provides a different feature: messaging, payroll changes, etc. I'd like these modules to be able to be enabled or disabled at compile time. The homepage will displ... |
It seems like, when reading something like this Wikipedia article about "pure functions", they list Today() as an example of an impure function but it seems pretty pure to me. Is it because there is no formal input argument? Why is the actual time of day not treated as the "input to the function" in which case if you g... |
I know method overload is not allowed in Scala and I have read some posts regarding the reasons. But still, I see some functions overloaded in Scala library (example: println). I want to know how it is done and if I can use the same mechanism to some of my methods.
|
I'm building a website for a restaurant. They have a downloadable PDF version of their menu (which is what the "real-world" menu is printed from), but we also want to have a text-based version of the menu on the website (because it's the 21st century and you shouldn't have to read a PDF when browsing a site like this).... |
In imperative languages, it is trivial to devise a programming test of language's use of "value semantics" or "reference semantics". One could do the following and check the value of a (where Vertex {one, two, three :: Integer}):
a := Vertex 3 4 5
b := a
one b := 6
two b := 8
three b := 10
However, since variab... |
Recently I've started using Git at work. Previously I've only ever used VSS (which has some problems) and so far, Git is orders of magnitude better.
The key differences here is that Git is distributed while VSS has a centralized "server" version, and that VSS uses a "checkout-lock-checkin" workflow while Git doesn't. ... |
I know what recursion is in programming. I do understand the basics of version control systems (have used svn that is). But I have often wondered what the meaning of "recursion" or "recursive" is with respect to version control systems.
What does a function calling itself have to do with working with files and direct... |
I see two common patterns for blocks in Objective-C. One is a pair of success:/failure: blocks, the other is a single completion: block.
For example, lets say I have a task that will return an object asynchronously and that task might fail. The first pattern is -taskWithSuccess:(void (^)(id object))success failure:(voi... |
So I am undertaking a project which does navigation sort of thing. So here is how the problem statement looks like.
Say, given a map of a floor, with different rooms, now somehow, this information is provided to the program and what the program does is, it takes two more inputs,
The starting location.
The final locatio... |
I was reading Joel Spolsky's mercurial introduction when it struck me:
"And now what they do is this: each new feature is in a big #ifdef block. So they can work in one single trunk, while customers never see the new code until it’s debugged, and frankly, that’s ridiculous."
Why is this so ridiculous anyway, isn't th... |
Background
Consider the following scenario:
Link. User provides a link to some poorly formatted website (e.g., creative commons content).
Scrape. Server downloads the content (web scrape), always throttled.
Format. Server formats the content (e.g., performs natural language processing).
Return. Server posts formatted ... |
Let's say I have a feature (topic) branch that I keep rebased on top of my development branch. During the course of the project (before merging in my feature branch), I decide that I need to make a large refactor to my project (for example, after updating a 3rd part module).
So I do this large refactoring on my develop... |
I'm using a combination of docstrings and Sphinx to document my Python programs. With Sphinx's autodoc, I can write a lot of documentation into the source as docstrings. Is there any standard for how much documentation to put in each?
For example,
case 1 is index.rst
.. automodule:: foo
:members:
and foo.py
"""do... |
I'm talking the kind of search that auto-suggests your query as you type, the way Google does, the way Wikipedia does, the way Stack Exchange suggests other questions as you type the title, etc. And Wikipedia used to have an awful search implementation, for those of us who remember. It had no auto-suggest, was shut dow... |
My specific case here is that the user can pass in a string into the application, the application parses it and assigns it to structured objects. Sometimes the user may type in something invalid. For example, their input may describe a person but they may say their age is "apple". Correct behavior in that case is ro... |
I work in a small team of four devs, one domain expert and one manager. We are looking to move to using scrum to try and formalise our processes.
From what I understand of agile, it seems to be close(ish) to what we are doing anyway. We have a brief document with the overall features our product will have. As we come t... |
Here is the Reddit's hot algorithm:
cpdef double _hot(long ups, long downs, double date):
"""The hot formula. Should match the equivalent function in postgres."""
s = score(ups, downs)
order = log10(max(abs(s), 1))
if s > 0:
sign = 1
elif s < 0:
sign = -1
else:
sign = 0
... |
First off, I do not have anything against OO programming (I'd be mad if i believed so). But I was thinking on some sort of procedural MVC pattern with PHP; let me explain better.
As we all know, variable scopes, unless they are taken from $_SESSION (, database, redis, etc.) are never global and only refer to a singular... |
One objection that I have often heard raised against Python that it is difficult to synchronize a team of many programmers on large Python project. Note: that synchronization is possible in such a project does not necessarily entail that it is practical, cheap or easy. There's still n*(n-1) communication channels betwe... |
The app I'm developing needs to display lists of items. Simple enough, but there are a number of things which can change based on user input:
Items can be added to/removed from the list.
The items in the list can be updated. Multiple items can be updated simultaneously!
The filters can be updated. Multiple filters can... |
I'm reading Accelerated C++ and in Chapter 4 they bring up the concept of lvalues. There's an example of something that shouldn't work, but after trying it myself I found that it does indeed work.
Specifically they state that, given these functions:
// return an empty vector
vector<double> emptyvec()
{
vector<double>... |
I'm aware of many version control systems: CVS, SVN, TFS etc...
I've googled for the very first "revision control/version control system" and seen various conflicting answers.
When was source control invented? Who invented it? What was it called?
|
Are there any studies that aggregate data over a wide population of contributed code, that establish a correlation between amount of code written in a commit and the # of bugs discovered in that code ? It'd be hard to do in github without knowing whether a change was due to new functionality or a bug, but you could det... |
I'll preface this question by saying that I am very new to professional software dev.
I work on a team that takes data in from other groups in my company and turns this data into reports usable by business execs.
In the process of transferring and parsing data we have some SQL statements that do a lot of processing of... |
I have a list of entities. Every entity contains a number that holds how many times the entity has been selected. I need to make a function that selects n (say 25%) of the entities, randomly. What I want to do is increase the odds for entities that have been selected the least times. Suppose after 5 runs the times the ... |
In C#, using statement is used to dispose in a deterministic manner the resources without waiting for garbage collector. For example, it may be used to:
Dispose SQL commands or connections,
Close streams, freeing the underlying source like a file,
Free GDI+ elements,
etc.
I noticed that using is used more and more in... |
I'm trying to validate the contents of Excel sheets that follow several different templates. For each one, there are three possible validation actions for various cells:
Regex (e.g. "XYZ-123" fails because it doesn't fit pattern "[A-Z]{4}-\d{3}")
Date/Time format (e.g. "Jan 24, 2013" fails because it's not mm/dd/yyyy... |
I am creating a site where people can write on a niche topic. It is almost like a blog, however the area as I mentioned is a small niche with (hopefully) passionate users.
I want a functionality where once someone posts his article. People with similar experience can be notified, so that they can read about. Now my que... |
I am currently building an audio streamer and I have a CPP .dll that I use functions of inside the WPF C# GUI.
The program needs to deal with sorts of events such as
Lower/Increase Volume
Manipulate Equalizer Bands
To this point I have used named events to deal with this issue. What would be a better way of handling ... |
I code Java for at least 5 years now and I really appreciate how the language works. When looking at new JVM languages (e.g. Scala, Clojure) there is a trend to more functional ways to code and this way has some major advantages.
Anyway, are there patterns to achieve a more functional style even when using Java or othe... |
Are there any words for the design model implemented by HTML + CSS + JavaScript, either for that specific set of technologies or any abstract pattern that they follow?
|
I would like to know more about the general concepts behind dividing data of a database into different servers. For example, suppose I have a SQL Server database which has a massive table. Assume one single server cannot handle the amount of data in this table. I would like to break that table down and split its conten... |
Given that out and ref parameters have slight different connotations would writing code like below be considered a bug (even though it doesn't cause an issue at present), or just a lack of understanding on ref and out parameters?
public void MyMethod()
{
int myInt = 0;
MyMethodWithRef(ref myInt);
}
public voi... |
I want to licence a non-trivial PHP application I have been working on under Affero GPL v3 (because I want every admin, who will use it, also release the source code).
However, something troubles me. I have a file localSettings.php, where the admin is supposed to write keys and some more information for MySQL database ... |
I am working as a contractor designing enterprise Java application for my client in the role of a technical lead. The application will be used by end users and there will be a support team who will support the application when we leave.
The other technical leads with whom I am working are under the impression that exc... |
The statement of the question seems little abstract to me, so please read the details below.
Since the time when C++ was the first choice Object Oriented Language for almost anything, we had a big problem of Multiple inheritance in C++ when two different implementations of same function declared or defined in a (abstra... |
How does Google or amazon implement the auto-suggestion at their search box. I am looking for the most used algorithm with technology stack.
PS: I have searched over the net and found this and this and many many more. But I am more interested in not what they do but how they do it. NoSQL database to store the phases? o... |
ISTQB does not distinct between these (it reads "Branch/decision coverage") but some sources do say it is different.
I would have two question. The essential one is about the difference. And the other one - does this whole concept belongs under the unit testing? Or white box testing?
Thanks
From the ISTQB:
branch cove... |
This might be a stupid question but I've never created a class library before
The reason I don't want to be connecting to a database through the class library is error handling.. should I just leave the errors to throw back to whatever code is using the class library? should I handle it there? or should I just leave it... |
Im trying to create an SMS gateway .. I have a request coming in from a client (web form or API or database record) that I need to process and forward on to a 3rd Party API - or SMS provider. So that things would be simpler going forward I decided to create an interface that each provider implementation would implement... |
The hash table data structure can be easily spread across multiple machines with a simple algorithm to distribute the keys:
machine_to_query = item_key % machine_count
When you want to read and write key value pairs, you use the key to work out which machine stores the data, then you talk to that machine. If you want... |
What's the purpose of a base address in an executable?
For example, in Microsoft Visual C++'s linker, you can set a base address, or use the default of 0x1000000. But with virtual memory, why would a base address be needed?
Why would you not just link it to 0x0 and put the initialization routine (mainCRTStartup on Wind... |
We have reached the point in our project where we have almost a thousand tests and people have stopped bothering with running them before doing a check in because it takes so long. At best they run the tests that are relevant to the piece of code that they changed and at worst they simply check it in without testing.
I... |
I'm creating a pizza place application where employees will be able to create orders for customers(pizza and any number of toppings). This is for a school project but the requirements have nothing to do with this question.
On the GUI I have a number of checkboxes that the employee will use to determine which toppings ... |
I have a ASP.NET application which puts the users through a series of forms in a wizard like fashion and has them fill out fields on the form. In code, these forms and fields are represented as "Step" objects, with a collection of "Field" objects as properties.
Currently I have only one Step class, and each individual... |
As a school project, we are rolling out our initial set of user stories. Should a user story record the original idea from a user, without combining them or separate them?
For example, John added that "I want to post multiple choice questions.", and Mike added that "Except multiple questions, I want to post true/false ... |
I am in the process of designing RESTful web services and got stuck at one point. The design is very simple with 3 entities:
- Project
- Status
- Employee
The part I am having trouble with is capturing the relationships:
- A project has a current status (1 to 1 between Project and Status).
- A project has multiple 'po... |
I'm writing maven plugin which depends on several java tools. I'm quite happy with it and want to share it with the community. I'm interested in correct way to handle dependency to these tools:
Use usual dependency way - put to central repository. But I'm not owner of these tools and I'm not going to maintain them. Bu... |
I have run into a corner-case problem with the general guidance of:
nouns for variables
verbs for functions
Specifically, I have a case where the word is ambiguous - it can be either a verb or a noun. And in some cases when we're discussing the application, it will be used both ways in the same sentence.
My intent i... |
Ken Thompson Hack (1984)
Ken Thompson outlined a method for corrupting a compiler binary (and other compiled software, like a login script on a *nix system) in 1984. I was curious to know if modern compilation has addressed this security flaw or not.
Short description:
Re-write compiler code to contain 2 flaws:
When c... |
In my code either of the above two options would work equally well but I am interested in finding out the pros and cons of both approaches.
|
I used to work for a professional consulting firm, and we worked under many different contract terms. When we could get a time & materials project, we ran it with SCRUM and tracked the backlog in our issue tracker system.
Most of the time, however, we had to deliver under a fixed price contract. This required a specif... |
I'm asking this here and not on the security related site because this one is a question about "software architecture" and "development methodologies", which are both covered by the FAQ.
EDIT: I'm talking about purely remote root / admin software exploits. Not about insider physically breaking into labs / companies / ... |
People advise me to "find a job doing something that you are good at", but the truth is that I don't believe I am good with anything other than just writing code. I don't think that I can design or structure a program though.
Don't get me wrong, I'm not the kind of programmer who can't write a fizz buzz program; I'm ... |
I have a question regarding workflow in web development. I'm building my project in Symfony, and it's in Git.
Right now, I have three environments, dev (local), staging and prod. The project itself is hosted on GitHub in a private repo.
I'm wondering what a good way is to update the staging & production environments. S... |
I have to calculate the proper quantum of time for Round Robin process scheduling algorithm. As I read in Tanenbaum's book, the quantum of time should cover like 80% of the running time of all processes.
Is there a formula how to find the optimal quantum of time?
|
I am developing an MVC website in PHP, and for the first time, I would like to implement a service layer. I have some design considerations I would like to get some advice on. The backend will by no means be a large enterprise system, so I am looking to keep things relatively simple while still leveraging the benefits ... |
I am working on an asp.net MVC web application which contains several projects.
One is BusinessObjects, which contains business logic / processes.
Another is EmailGeneration which is used to send marketing campaign / customer emails.
The EmailGeneration project references the BusinessObjects project because it need to ... |
There must be a good reason why Java designers didn't allow any state to be defined in interfaces . Can you please throw some light on this aspect of design decision ?
|
I have been wondering this for a few days. I basically understand how networks and packets work. But what happends when an unexpected packet arrives? Like, when I didn't send a request for a website's index, but it sends the index to my machine anyways ? Does my browser pop up? Does it ignore it? Anyway to actually cat... |
What are some techniques I might use to consistently refactor code removing the reliance on existential types? Typically these are used to disqualify undesired constructions of your type as well as to allow consumption with a minimal of knowledge about the given type (or so is my understanding).
Has anyone come up with... |
This is a problem I come across pretty often. Basically we are using an application to make art content. Often times this requires writing custom tools for it.
Sometimes you run into parts of the application where doing something is not directly supported in the UI, which means it will either be a little more involved ... |
I am administering hundreds of RHEL servers. There are many daily tasks to perform. Right now I am working with bash scripting and python. I was wondering if other languages such as Erlang, Lua, Ruby, Haskell, or Clojure.
|
What's the recommended method for setting up tests on code that requires a private key to make calls to external web services?
Full on mock objects or is there a way of distributing open source unit tests with a neat method to add in a tester's own private key at test time?
I'm using python but any general best practic... |
Empty glasses of water are arranged in the following order:
When you pour liquid into the 1st glass if it's full, then the extra liquid would be flown into the glasses 2 and 3 in equal quantities. When glass 2 is full, the extra liquid would be flown into 4 and 5 and so on.
Given an N liters of liquid and maximum capa... |
I am creating a tree where some nodes have a reference to their parent as well as their children. It feels like a tree version of a doubly linked list.
Is there a name for this?
|
My question is conceptual, yet extremely vital for me.
I'm an intermediate Python developer. I know fair enough about it, and actually use it on a daily basis. Now, I would like to transform my capabilities from a library/API user to "designer" one.
I found that "Python Requests" library by Kenneth Reitz is an extreme... |
I'm going through a MVC tutorial, and I notice that convention seems to be to expose a tables primary key on detail pages/urls (ie. /Movies/Details/5 as an example from the tutorial).
It's obviously not a problem for things like a movie record or a SO post, but it might be a bit different for an invoice or transaction ... |
I am new to UI development, but I feel very uncomfortable with how CSS works.
My use case is that I wanted to apply some specific styles inside a particular div on a page.
CSS attempt:
div.class1 {
font: normal 12px arial, helvetica, sans-serif;
font-color: #f30;
}
div.class1 div.class2 {
border: 1px solid... |
I have good number of Service and DAO classes which has the same set of 30 line exception code block which gets repeated and it shows up in Code Duplication report.
The approach which I can think of is to
Extract the common exception code blocks to a common method and call
the method in one shot
Re-organize the me... |
I've recently been going through the Learn You a Haskell for Great Good guide and as practice I wanted to solve Project Euler Problem 5 with it, which specifies:
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
I decided to first write a function determining whether a ... |
I assigned a POC project to someone where I asked to implement both Command Query Responsibility Segregation, Inversion of Control (with Dependency Injection) and Repository pattern. “Someone” gave me a POC solution project but I am not sure whether this is the way it is done. I will brief here about the POC project
... |
It seems to be a generally accepted good practice not to push invalid, broken, or incomplete code. But one of the huge advantages of version control systems is that it gives you a remote place for your code, so you can work on the same codebase from more than one place.
Suppose you are working on a feature with a coupl... |
I don't have a specific context in which I'm asking the question, but while I was reading a beginner book on C++ I noticed the use of both an endl stream manipulator and a newline escape character when dealing with a stream object.
The exmaple is as follows:
cout << "Hello World" << endl;
cout << "Hello World\n";
My q... |
In our software environment, we often run a/b tests, as is probably good practice. However, our environment is set up such that, in very short order, the code starts to become very crufty with dead tests. The testing registry is little more than a collection of internal wiki pages.
I thought of a "dead man's switch" st... |
I'm working with a new plugin (flexbox), and I ran into the MS-PL license, which I had not run into before.
In the past, I've used mainly MIT and Apache licensed projects, so I have no idea what the main differences are with this one.
Here's a link to it: http://opensource.org/licenses/MS-PL
Can anyone help explain the... |
We've been thinking of using GPL components to make a GPL application, and freely give it away. We then want to use that as a loss-leader. In that free application, where even the source code is available, we plan to have an advertisement for some payware. The payware would be for functionality that is completely diffe... |
There are plenty of compilers and REPL services on the web. For example: Fay ide.
I find that implementing some similar technology would be very interesting. But it seems like a major security hole. Am I wrong in thinking that exposing a compiler would be risky? An interpreter seems even worse.
update: I can be a bit m... |
I was asked an interesting question: Should a database contains all data? Or heavy binary files should be stored in file system?
Example of heavy binary files : videos or heavy pdf files (+200 MB)
With an old aspx web app (1.1) I tried to open a 200MB pdf file stored as a blob in an Oracle 11g database, and it just run... |
This question is asked on SO and this site often it looks like. "How do I do a dynamic enum?" Answers range from you shouldn't to possible compile time solutions. Now my question is do I want a dynamic enum that is generated from look up tables in the DB, or do I want something else that is similar?
I have a solut... |
I'm wondering what's better design wise for usability/maintainability, and what's better as far as fitting with the community.
Given the data model:
type Name = String
data Amount = Out | Some | Enough | Plenty deriving (Show, Eq)
data Container = Container Name deriving (Show, Eq)
data Category = Category Name derivi... |
I recently started learning to write code, and in my book I came across this question. "Why is a Boolean value stored as a byte inside of a computer when it only requires one bit?" can someone shed more light on this question?
|
Unlike C++, in Java, we cannot have just function declarations in the class and definitions outside of the class. Why is it so?
Is it to emphasize that a single file in Java should contain only one class and nothing else?
|
I'm designing an abstraction over ASP.Net's built in caching to make it not so horrible to use. One design decision I'm having to look at is if I should restrict people to using just one cache policy on each item.
For example, say you're caching the HTML generated by your blog post or some such. Would you ever want to... |
I know that Python, Perl, Java, Lua and obviously C (as it's the only array that's in ANSI standard afaik) support faster looking of numerically indexed arrays than doing a hash lookup or anything like that. Does Javascript also?
As an example in code of what I mean, in the case of Perl:
for(i=0;i<10;i++)
{
# Do so... |
I am a native PHP developer, and have been for about a year or so. I love PHP and it was very easy for me to learn, but I have developed some bad habits along the way due to never having a formal education in programming. It's pretty easy to get the job done in PHP without writing the best code.
I am looking to work m... |
There is a lot of information about tools and techniques for improving legacy codebases, but I haven't come across any successful real world case studies. Most advice is on the micro level, and while helpful, doesn't convince many people because of a lack of evidence it can help at the macro level.
I am looking specif... |
Recently my Scrum team has received several requests for optimizing certain parts of our code. Looking at the software with a profiler found some spots where the code could be improved.
We agreed to plan mostly based on user stories to ensure that everything we do has actual benefit for an end user, but how would this ... |
I have a number of business logic methods that store and retrieve (with filtering) objects and lists of objects from cache.
Consider
IList<TObject> AllFromCache() { ... }
TObject FetchById(guid id) { ... }
IList<TObject> FilterByPropertry(int property) { ... }
Fetch.. and Filter.. would call AllFromCache which would... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.