instruction stringlengths 34 19.9k |
|---|
I recently came across an article where if you enter
data:text/html,%20<html contenteditable>
into the address bar of a browser that supports HTML5, you can type in the window.
I managed to figure out that with this you can basically write html in the address bar (it would be rather cumbersome) but
I do not understan... |
As an ISV, what is considered best practice for implementing application role based security? In other words, only allow users to access certain features in the application based on what roles they belong to.
We currently just use a table in our database to store this, but it has been suggested that for maximum HIPAA c... |
http://www.oodesign.com/command-pattern.html
In reading through a tutorial about the command pattern, I came across a UML diagram that seems to omit some relationships. For the following diagram, the client instantiates a stock trade, an agent, and buy and sell stock orders. Why is it that the author omits the relation... |
It is easy to implement calls to API endpoints, then to parse JSON and handle the data - but what is a good design pattern for this?
Here are some ways I have tried but I feel like there should be a better way:
Create a singleton class that manages all networking code and all data parsing code for the entire applicati... |
Is there any reason the PHP language could not be updated in a future version to make the $ prefix on variable names optional? Reasons that would break existing code?
I'm thinking it would still be required for string interpolation, like "Hello $name", but most of the time it would be optional.
For example,
$name = 'Bo... |
Just curious why whenever I see an example of a directive using a link, the parameter for scope is scope and not $scope?
This is always biting me because I'm so used to typing $scope, my brain auto-types it and I have to go back and correct it.
|
I am lost I just can't seem to get my head around backtracking/recursion approaches. I understand how simple recursion problems like factorials work I can even trace those by hand. But when it comes to backtracking problems I am so lost. I keep trying. its been 5 hours I have been reading various approaches on forums a... |
Ran across this statement by Martin Fowler circa 2002:
Unit testing in XP is often unlike classical unit testing, because in
XP you're usually not testing each unit in isolation. You're testing
each class and its immediate connections to its neighbors.
Is this still correct, and if so, why?
|
Here's the relevant quote:
A common risk with software development includes communication breakdowns between Developers and Business Stakeholders. BDD uses the specification of desired behavior as a ubiquitous language for the project team members. This is the reason that BDD insists on a semi-formal language for beha... |
Background: I'm working on an application that will manage backup generators. These generators need to be able to be "linked" together. For example, Generator B might serve as a backup for Generator A. If A fails, then the software turns B on. Or they might be linked in a load-sharing configuration, where Generato... |
What are some explicit and official guidelines or standards for template parameter naming in C++? I've done something like this in the past:
template<typename TContainer, typename TKey>
void AddKeyToMap(TContainer& the_map, TKey const& the_key);
I've also seen names like container_t and key_t. I'd also accept advice ... |
When doing method chaining, you have methods that return the object allowing you to continue the chain. However, you need to get values out of the object somehow.
Usually I've added a method that returns a value at the end, but this complicates matters if you add to the chain and that return method may not be valid an... |
I have an object which will periodically raise an event based on an action performed in an application. This will be heard by any listener(s) and acted upon accordingly.
I do not wish to use a custom type for this and would like to make use of either EventHandler<T> or IObservable<T> to manage the pub/sub mechanism I ... |
My particular situation is related to Java, but I believe this is a more general OOP question than just Java programming.
The Question: Should "mutator" methods perform deep or shallow copies?
An example:
Let's assume my object has the following structure:
public class MyObj {
ArrayList<Integer> myList;
//construct... |
I found in more than one SIMD program the instruction __attribute__((aligned(16))) . When I looked for an explanation I found
The keyword attribute allows you to specify special attributes of
variables or structure fields.
Apparently variables have attributes. Are these attributes language-specific? what attribut... |
Which algorithm does java uses to convert floating point number (Ex:0.15625) into binary(0.00101)?
Whether java uses normalized form or denormalized format?
If I type float ab=0.15625 in Java source file, which part of compiling and running the code will convert that floating point number into a format that could be st... |
I've seen this question but it doesn't help me because I'm writing functional code (Standard ML) and the answers there are heavily focused towards OOP (the OP is advised to use the Facade pattern, to use inheritance, etc -- answers that are not relevant to an SML programmer).
In two separate, largely unrelated modules... |
I have been asked to build what is essentially a query builder for a reporting application.
The variety of objects to query, potential modifiers, number of conditions, and so forth to be reported on have made me conclude that a query builder would be the best way to go about this task.
I am trying to decide the data mo... |
Say I make a program that calculates all possible (integral) factors of a certain number that has been input.
Is it theoretically more efficient to check with all integers up to the square root of the number or till half of the number.
Calculating the square root will take more time and power but will result in fewer ... |
An entity has identity, which implies there should only be one object (e.g. a particular customer) in memory.
As such, reference equality (which is what the base version of object.equals checks for) should be the only equality we care about.
A value object on the other hand would need to overrride Equals as there may b... |
I'm working on a large angular application and I'm currently using a factory class that builds HTML templates from strings. We don't have to worry about mobile support for the application and I'm wondering from an architectural standpoint, which method would you rather implement and why: static HTML files that are fet... |
Whether in C or C++, I think that this illegal program, whose behavior according to the C or C++ standard is undefined, is interesting:
#include <stdio.h>
int foo() {
int a;
const int b = a;
a = 555;
return b;
}
void bar() {
int x = 123;
int y = 456;
}
int main() {
bar();
const int n1... |
I'm having trouble setting up my program's database the 'right' way. I was hoping you guys could give me suggestions on doing it properly. I am creating a database+client for a non-profit organization that runs all across Canada.
I've started to create it already with a web based (PHP with Laravel, HTML, CSS [bootstrap... |
I am a beginner in computer programming with C/C++. I have previous experience in programming for the web. There is some confusion that I am having with the software development process in desktop applications.
Web applications are easy to upgrade because it is basically a bunch of source files, but I have a question... |
I'm created an opaque type and I have two options for its management.
The first looks like this:
type_t *a = type_init();
int err;
err = type_do(a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL);
if (!err) {
type_print_result(a);
...
}
type_free(a);
The second is:
type_t *a;
int err;
err = type_do(&a, "foo", "bar",... |
I am currently writing my first bigger project in c++. Its basic linear algebra. I am aware that boost libraries and others exist, but for various reasons I need to write my own. Purpose of the library is to perform certain vector operations (adding, substraction, etc. ...) for statistical data analysation. So ease of ... |
Apple's scripting language AppleScript was designed with localization in mind; allowing the language to be represented in multiple dialects resembling languages from around the world.
In this way, using lexing and parsing tables, programs could be written in a style similar to that of the developer's mothertongue (or o... |
I'm trying to create a word game, just like WORDAMENT, in my spare time. In order to present a new round, I need to create a board with 16 letters organized in a 4*4 grid. Currently, I'm generating the grid randomly. But it has some obvious problems. So my main purpose is to organize those 16 letters in such a way that... |
Imagine an application where the user is allowed to create his/her own musical scales. The user selects notes from a list, arranges them to a group and presses a button to create the scale.
In an MVC structure, upon pressing the button, the View would tell the controller "the user wants to create a new scale, here are ... |
I'm faced with image manipulation requirements for a mobile app I wish to develop that I could quite easily (or 'easier', at least) implement in C# or javascript, as it's what I'm most familiar with.
I'm not one to shy away from learning new things, but would it not be easier to opt for this approach and get other plat... |
In theory, if I wanted to have a developer write some sort of computer architecture/OS, could I have him/her add the capability to download + install something at the same time. I'm thinking like something where the file is shredded into pieces, and as parts are being downloaded (the user'd see it as one file), other p... |
Programming languages like Scheme (R5RS) and Python (see this Question) round towards the nearest even integer when value is exactly between the surrounding integers.
What is the reasoning behind this?
Is there a mathematical idea that makes following calculations easier to reason about?
(R5RS references the IEEE float... |
I use exceptions to catch problems early. For example:
public int getAverageAge(Person p1, Person p2){
if(p1 == null || p2 == null)
throw new IllegalArgumentException("One or more of input persons is null").
return (p1.getAge() + p2.getAge()) / 2;
}
My program should never pass null in this function. I... |
If you have a function being called in another function, do you figure out the runtime for the being called and then "add" that to function you wish to analyze the runtime for?
Function to be analyzed:
for (i = 0, i > n, ++i)
{
if (function.call() > 0)
{
\\something
}
}
Function called:
Call
{
f... |
I've got a class:
AuthenticationService
findLoggedInUser()
Checks session if User is logged in. If not, check client persistent user login cookie and log in.
loginUser($email, $pw, $remember = false)
Log User in, and if $remember is true create persistent login cookie for User and a record for it in the database.
lo... |
I'm developing an ASP.NET MVC Web Api 2 with .NET Framework 4.5.1 and C#.
I have these entities in database:
Users, which are members of groups.
Groups.
Messages. Users can sent messages to a groups.
I have this route:
config.Routes.MapHttpRoute(
name: "GroupMessagesApiRoute",
routeTemplate: "api/groups/{grou... |
I just come across this code and find it interesting to know whether you consider this as another single instance pattern?
public class Initiator
{
private static String str;
// there is many more private field here...
private static String getMethod() { ... }
// there is many more private getter here..... |
When I am using some code licensed with the MIT license, but it's not in seperate files, is it OK mark it like this?
/* Here starts code licensed under the MIT License (../MIT.txt) */
// code
/* Here is the end of code licensed under the MIT License (../MIT.txt) */
Where in ../MIT.txt file, it would contain the MIT Li... |
I create my compact test database. This is a SDF file, embedded as a visual studio resource. When test suite starts this database is copied in %LOCALAPPDATA% so my test can use it.
The first method that I want to test is the getById method. Pretty simple.
var response = repo.GetById(IdToFind)
Assert.IsNotNull(respons... |
I'm writing a software [under Windows] in C++ which later needs to be able to connect to both MySQL and ORACLE SQL. Now the software needs to be as simple for the user as possible.
Now I'm considering using ODBC.
If I use ODBC, does the software later need any additional drivers, or only during development? When I have... |
I may have been exposed to exactly the wrong languages, but though many have loops and break statements, none of the languages I am familiar with have higher-order break statements¹. While a regular break statement terminates the innermost loop inside which it is executed, such a break(n) statement would terminate the ... |
Talking about MVC with servlets and JSP's, in a context about products and manufacturers , when querying the application for a list of products:
the servlet loads a list of products from the database in a List object (or similar);
the servlet sets that list as attribute of the request and forwards the request to a JSP... |
I'm fairly new to learning haskell, so I don't really understand the typing system when it comes to constraints. There's this weird => symbol that doesn't make sense to me. Is it actually just syntax? Or is it a type constructor? I'm not sure. Below are my thoughts about it. Can someone clarify what exactly => means in... |
When unit testing functions of a class that has private functions that require online functionality. How would one go about testing it?
For example:
public class Foo
{
public int methodA()
{
int val = goOnlineToGetVal();
return val;
}
private int goOnlineToGetVal()
{
Clou... |
I have a published app (Android/iOS) and I'd like to instrument the next version so that I can remotely enable/disable or adjust features, through a web interface. This could facilitate a/b testing for example.
I'm struggling with this because I don't know what this concept is called (remote feature control?, feature f... |
I'm trying to figure out how to properly handle the web browser cache for single page apps.
I have a fairly typical design: several HTML, JS and CSS files implementing the SPA, and a bunch of JSON data that's consumed by the SPA. Problems arise when I want to push an update: I update the static portion of the site and ... |
I am trying to create a simple online card game with multiple players. Basically, there's a dealer and multiple players. I have have already implemented most of the game and it's working fine. now I want to implement a universal timer for a single game. For example, when the dealer starts a new game the timer starts an... |
basically allow a user to label specific text in a pdf file. Use the label information to create a template, which a script uses to extract text from specific pdf.
What would be a good pattern to use in such situation? For example, maybe the script that uses the templates might work for a group of well formatted pdfs b... |
Is it worth implementing interfaces, or using the getThis() trick, or even static factory methods to future proof against the need to extend this DSL?
The current design is a pair of thin fluent-method-chained-DSLs that mix the "traditional" and "enhanced" builder patterns. That's just a fancy way to say some chaine... |
I have one A File and many input files ,All files have CSV format . I want to match text of one column of all input files with one of the column of A file .
I have stored all column value of File A in HashSet for fast search.
1- Now iterate All input files uses First loop
2- {iterate all elements in each file use... |
I'm learning C++ (C++11), specifically for cross platform game development using SDL.
on Windows, I use Visual Studio 2012 (Considering buying '14' once it's out), on Mac OS X and iOS I'll be using whatever the latest XCode is (right now 5.1) and I haven't looked into options for Linux yet.
However, since I'm still try... |
I'm creating a toolset in Java consisting of many Natural Language Processing (NLP) tools, such as Tokenizer, POS tagger, Lemmatizer, Sentence parsing, etc.
I want to put all good and publicly available tools into my toolset, all sharing the same interface, so that I can change library easily without change of API.
The... |
We're looking to concentrate more on testing behaviour (as opposed to every class/method individually) in all our automated tests, as espoused by various high-profile online discussions recently. I like the idea of thinking about only what goes in and out of certain logical well-defined boundaries between components, ... |
Say I have an existing callback interface that has multiple methods. To illustrate my point I use a callback the likes that you would see in code that performs some HTTP client operations:
public interface GetCallback<T> {
public void onSuccess(T data);
public void onAuthFailure();
public void onError(Reque... |
When we document our class, method and/or function with phpDocumentor, is there any specific order I should follow according to the standards?
I know it doesn't matter for output the document. Since it is outputting the order what I have written.
This is for my knowledge and understanding if there is any order standard... |
I tried to explain to a coworker the gravity of having duplicate code in a project, on this piece of code:
+ (void)createIapInParse:(SKPaymentTransaction *)transaction {
Reachability *reach = [Reachability reachabilityWithHostname:@"www.facebook.com"];
if ([Social getFBUser]) {
NSString *iapId = [Util g... |
I'm currently working on a requirement for a desktop application - using Java
If for some reason the GUI crashes, it shouldn't affect the background
process. Once the GUI is restarted - the execution status along
with the log messages should be given back to GUI.
Desktop application is built for both windows & ub... |
Suppose, that Alice started a GPL-licensed project. Later, Bob married Alice, joined the project and made a 50% contribution to it.
Then they broke up, Alice sued Bob and by court decision took his house, car etc. :( Moreover, she decided to close the source code of the project and sell it for money. As a copyright ho... |
Consider having a project which you would want to release as open-source.
There are parts which you have removed, but still remain in version control
history. License of those parts is not compatible with the license you intend
to use to release the project.
How to solve this?
Just release source tree as is. Possibl... |
I'm part of a team building an iOS game which has multiplayer elements.
A concern right now is how to make the game more secure, from user manipulation. I know there's a lot of multiplayer games out there, and so there must be techniques they use to make their games more secure.
An example of a scenario is if the saved... |
Please correct me if I'm wrong, but I recently found myself in a pretty confusing situation and now I am unsure how to continue.
I found the jQuery.xmleditor plugin from the UNC libraries and thought it would be useful for one of our commercial products. That's where I typically first check how a library is licensed (i... |
I'm trying to determine if a language I'm investigating (Groovy) is better for developing enterprise applications than our current language (Java). Specifically I'm trying to figure out if it will save significant time in coding, re-factoring and maintenance.
But, I'm not actually asking that question here as it's waa... |
I have experience with object-oriented programming languages (C++ and Java), but I am wondering what kinds of programming languages — including OOP languages– or programming paradigms might be suitable for a rule-based natural-language translation program.
Does existing machine-translation software tend to use a certa... |
I'm a computer science TA working with some students in a senior capstone course (effectively, a consultant for a small team). I met with them to discuss how to use version control, and they're in an interesting situation:
Their current practice to to complete their tasks on their own machines without committing. Then,... |
When we are working with some MVC FW on PHP, generally we have a view loading function like load(string viewName, optional array viewVariables). My doubt here is: if we are working with some object, like a table row result, we need pass this object entirely to view or we need pass only what will be need on view?
Exampl... |
I'm developing my own programming language in my spare time as a hobby. It's an interpreted language. Currently the syntax for variables is this:
%<variable> = <value>
Here are some examples:
%test = 10
%somevar = "Hello World"
At the moment you can just declare as variable as shown above, regardless of the type. You... |
I'm building a javascript application that does continuous drawing, but relies on asynchronous scripts in the background which also need to poll for events and write to "global variables". This got me to start using Workers, but they can't access my global variables consistently. I was thinking of using Singletons to c... |
I've been working with a buddy of mine on a school project. We forecast it'll take ~2 months, so it isn't a small scale project at all. Communication and splitting the work effectively has been a NIGHTMARE though.
He doesn't have a phone, which makes communicating outside of the one 1 hour class we have together diffic... |
I'm creating a crawler app that will always, in the beginning, when the Class constructor, ensure that the basic database structure exists.
Is this a bad practice? What is the advantage OS creating the structure directly on the database?
import psycopg2
from datetime import timedelta
class DBManager:
def __init__(... |
During development on a large existing codebase I've started to capture variable values in my Exception logging. For example:
public int Foo(int a, int b)
{
int returnInt;
try{
returnInt = bar(a) * b;
}
catch (Exception ex){
ex.Message += "a: {0}, b: {1}", a, b;
logger.log(ex);
}
re... |
As we all know:
Git gets easier once you understand branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space
Which seems like jargon, but on the other hand,
All told, a monad in X is just a monoid in the category of endofunctors of X, with product × replaced by composition of endofunctors and ... |
I asked this question on Stack Overflow and it was met with negative reception. I figured that Stack Overflow wasn't the right place to ask this question, so I decided to post it here.
Beside making types like SqlBoolean act more naturally, is there any other reason? If making three state boolean types is the only purp... |
I'm trying to determine if it should be possible for a cell phone app to relay custom data along with a phone call. By "should be possible" I mean that I'm not trying to learn how to do it in iOS/Android/whatever, I'm just trying to determine if:
It is permitted by standards: the standards for the metadata that initia... |
As practice, I'm planning to implement a multivariable calculator library. The idea is that you can define a function, such as f(x, y) = sin(x)^2 + 3*y^3, and then you can evaluate it with specific variable values (e.g. f(4, 3)) or take the derivative with respect to a certain variable and get another function. The ide... |
Assume an application that shows a data table. The data is loaded from a database when the program is initialized.
Each value in the table is represented by an input field, where each keypress in one of those fields causes a refresh:
The data is written to the database
Then, each value in the table is refreshed by rea... |
Imagine a website operating from the US, providing some web services to customers around the world.
Sometimes is takes up to 200ms just to establish a connection between Australia and US.
It's pretty straightforward to accelerate static content delivery by introducing some CDN, but what are the options when dealing wit... |
Currently I am working on a simple app which will be able to connect to MongoDB which is deployed in Google Cloud. I have set it up MongoDB ocaly on my computer and I have made a little JAVA console app which connects to local MongoDB an I am able to do certain tasks like creating new collections, databases, retrievien... |
I'm trying to improve my testing skills. I frequently hear about mocking framework to build fake objects (as far as I understand). Right now I need to test my repository (the usual add, remove, update and GetById methods).
I do this test to be sure that every operation on the database happens correctly.
The question ... |
In an environment where refactoring is difficult extensibility can be a life saver. However, this is no excuse to over engineer code.
Given that a thin fluent builder method chain is backed by well designed classes that abstract the work away from the method chain, is there much point to making the fluent builder exte... |
Recently I read up on Wikipedia about Nginx. What puzzled me was this paragraph:
Nginx uses an asynchronous event-driven approach to handling requests, instead of the Apache HTTP Server model that defaults to a threaded or process-oriented approach, where the Event MPM is required for asynchronous processing. Nginx's ... |
I have the suspicion that many bug-fixes carried out by our developers sooner or later cause another bug, simply because the product is too complex.
I'd like to improve the quality of bug-fixes, i.e. make sure bug-fixes do not produce additional errors in the code. For that, I'd like to be able to measure how the qual... |
We've just deployed a new system for our users. The product owner asked us to check the log files every day in the next iteration for error messages and exceptions. We have written the following user story:
As a [web system] user I want that developers to check log files every day in the next iteration for errors so I... |
I'm converting an application from C# WebForms to MVC.
The application gets settings from a centralized location using Web Services. These are settings you would typically find in a Web.Config, but the desire of the company is to store these values in a centralized location for all apps.
Currently, any time you request... |
When working with methods which accept a parameter in various forms (e.g. nil, a single string, a single string containing multiple data or an array of strings) I tend to unify them - splitting, sanitizing and putting them into an array because this simplifies further processing and removes the need for nil, type and s... |
I have the following map:
Map<Double, List<SoundEvent>> soundEventCells = new HashMap<Double, List<SoundEvent>>();
This HashMap maps double values (which are points in time) to the corresponding SoundEvent 'cell': each 'cell' can contain a number of SoundEvents. That's why it's implemented as a List<SoundEvent>, becau... |
I'm making a web app that will be querying an existing database. I'm thinking of putting the names of the tables and columns and such into a single static class, and then referencing that when constructing queries. I think this would help with maintainability since if in the future a column gets renamed for some reason... |
Can I somehow protect a source available (you can see the source, but you don't have rights to use it) application against piracy? Is it even theoretically possible?
Not all of the application has to be available, "security module" or how to call it can be closed source, no licensing issue here.
|
I'm coding an script in C, which is going to check constantly an array of events, the idea is to check if the Date and time of certain event is equal to de current time and trigger something, i'm doing this with a while(1){}, but this approach causes a high CPU usage, do you have any suggestion of how can i do this wit... |
I am designing a REST API and figured I'll just look at how others are naming their resources and choosing the routes.
I look at Twitter's API and see that they have nested resources. For example:
https://dev.twitter.com/rest/reference/get/statuses/retweets_of_me
The resource is called retweets_of_me but it's also nes... |
I'm running a team that takes care of 3 products that are distinct in language/product type so that 2 out of 6 developers I manage are only ever locked to coding on 2 of the products (thick client applications). The other 4, are the web developers and look after a very rich/complicated web application.
The process the ... |
Let's say that I create a page in my marketplace web application where buyers can see a catalog of all products offered by some or all sellers or sellers can see just their own products in a preview of this buyer's view.
Within my JavaScript code I would create a model object that synced data with the server, one or mo... |
I've been writing model specs for a while now and I'm gradually moving towards integration testing. Right now, I'm looking at the best way to test the output of my ActiveAdmin dashboard but I'm unsure which is the best type of spec for the job.
My dashboard contains two tables which summarise yesterday's and today's or... |
Nouns are good and verbs are bad.
HTTP codes + the endpoint /user/123 can signify user create, read, update and delete operations. But what should the signin and signout endpoint be called?
How can i avoid method-driven-naming my API?
|
I'm making a class similar to the following:
public class KeyValue
{
public readonly string key;
public readonly object value;
}
Value could be of any object type as a result of this design.
Alternatively, I could just use dynamic for value and it'll make my life easier, because it would mean no type-casting, ... |
We're currently storing two Dynamic CRM solutions in Github and have triggers to automatically deploy these solutions once a change has been pushed to the master branch.
This works really well in the development world, but we'd now like to hand over the system to relatively non technical users who will make system cha... |
Got a fairly large web application in asp.net using C#. Also have a mobile setup using a common api that we wrote to basically share data across both of our apps using web methods and common classes.
Email was initially thrown together in maybe two days using a simple email class and some basic properties.
For instanc... |
Given the number 15 and the array [1, 2, 3, 4, 5, 6]
Possible combinations (sum=15) would be:
[1, 2, 3, 4, 5]
[2, 3, 4, 6]
[1, 3, 5, 6]
[4, 5, 6]
Their respective sum of squares would be:
55, 65, 71 and 77
Any number in the array can only be used once in any of the number combinations (no repeating numbers). The soluti... |
While using an 'if' statement to check whether a variable is an empty string or not we can write it in two ways i.e. if('' == $variable) and if($variable == ''). I want to know what is the impact of above in different cases?
Thanks in advance!!
|
Say I push to a public repository an original file that I cover under a specific license. I later (or even immediately) find out that this license is incompatible with other licenses in the project. (Say one is the GNU GPL and the other is something incompatible with it.) I would like to know how I should responsibly a... |
I have a message class that holds the name of a destination, and a generic variable acting as the message payload
public class Message<T> {
public string Destination
public T Payload
// ... constructors, functions, etc. ...
}
This way, I should be able to create messages of any type (without needing to ex... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.