instruction
stringlengths
34
19.9k
I see 'the bootstrap process' mentioned in Dayle Rees Laravel tutorial "Code Bright" but no explanation of what it actually means. The Wikipedia definitions on Bootstrapping in computing don't seem to have any particular relevance.
I'm just starting on a new little pet project of mine. I started the project using a familiar pattern for using objects as "filters" in SQL Queries. I've never been much happy about its easy of use, but eventually more or less accepted it after having it drilled into my head by colleagues. The example below hopefully ...
I'm playing around with different ways of integrating d3 and angular, in the context of learning both of these frameworks, and am hoping for some input: My client application receives a JSON array of nodes and an array of edges from my server. The central component of the client is a graph visualization implemented ...
I'm designing a class that holds several types of data. Some of the properties are optional. For example, let's say I have a class that represents a person, and one of the properties is occupation. I have another property, military rank, but this property is can only be retrieved if the person's occupation is milita...
I am considering building a DBAL from scratch with PHP to use within my projects and also to learn through the process. I have noticed on SO and other reputable forums that whenever this is mentioned most users advise to use an established DBAL like Doctrine and to not "reinvent the wheel". Why is it that with this spe...
I have some classes so far. Hand stores information like SB, BB, ante, collection of Players HandState inherits from class Hand. has members like phase {POSTING BLINDS, PREFLOP, FLOP, TURN, RIVER, SHOWDOWN }, pot. I consider every action in a poker hand as a handState. Players post ante (if any), Small blind and big b...
I am making HTTP calls on the client side and the server expects me to supply a client nonce. It needs to be 4 bytes long. I am planning to use this combination: base64(parts of the MAC address + random bits generated by RNG) Given that the protocol is created by experts (thus its security is not to be questioned), is...
I need to read some of your opinions. I'm developing a desktop app (.net/winform) to keep data in one place. This is used by several clients and the data is stored in MS SQL Server (client-server arch.) One of the feature is to be able to send notifications via email when conditions met. I've never did something like t...
This is a licensing question about the Dalvik and J2SE core libraries. In particular the license governing java.util.concurrent.SynchronousQueue. The license header of the class in the JDK source states that it is GPLv2 only (see grepcode). However, the same file in the Dalvik core libraries seems to be governed by the...
I'm writing a web application in javascript that will be served to the clients' browser. The intent is for the app to appear to the client as a monolithic application, not a series of interlinked refreshing web pages. My question deals with common architecture. In order to relate the question I'll mention a specific fe...
New technologies can accomplish existing tasks in more efficient and powerful way. But sometimes old technologies cannot be discarded unfortunately, so more numbers of technologies in one system make maintain difficult. Is it worth to introduce new technologies? For instance, a legacy system uses SOAP internally and J...
In my problem I had lots of objects with slightly different behaviour, but identical attributes and methodes with identical interfaces. The objects variants were quite big in number, and I didn't want to create a class for each of them, with lots of repeting code. I circumvented creating a lot of derived classed by the...
I am in a meeting with a client later on, regarding an ASP.NET web app we are creating for him. The app includes a lot of 'form' style screens with 20-30 textboxes, and of course a 'Save' button that posts back to the server and saves the data. The client really does not like this as he is worried users will forget to ...
I currently have an app which basically runs two halves of an API - a restful API for the web app, and a synchronisation API for the native clients (all over SSL). The web app is completely javascript based and is quite similar to the native clients anyway - except it currently does not work offline. What I'm hoping to...
Is there a performance difference between using ++x over x++ increment operators? I've see developers use ++x in loops where I would normally write x++ out of habit. For example; for(int x=0; x < 10; ++x) There would be no difference in the results between ++x or x++. So I'm wondering if there is a reason some people...
Where I work we have a number of teams that are converting over to having a team dev environment. Basically a couple members of the team are putting together an image that is then installed on everyones computer. It includes an OS, an IDE (with source control managed from it), a couple of server systems they need for...
I've recently joined a project where we are extending the functionality of an external application that our company has bought. It is an Office Add-In with an admin console that allows you to create Windows Forms style forms with code-behind files, and gives you a single place to store common code. This can be quite ch...
This morning, as I was writing some html and haml, it occurred to me that the way divs are used is ridiculous. Why are divs not implied? Imagine if this: <div class="hero-img"> <img src="http://whatever.com/this.jpg"> </div> was this: <hero-img> <img src="http://whatever.com/this.jpg"> </hero-img> If the "div ...
I am creating a scoring system for a competition that is somewhat obscure, but it resembles the Olympics in terms of its high-level structure. Therefore, I will ask my question in terms of an abstracted, fictional version of the Olympics, since everyone can relate to that to some degree. Assume the following hierarchy ...
Build systems for web applications are great: they give dependency management, code minification, and the ability to use tech like SASS or CoffeeScript that require pre-processing. However, I find actually using build systems to be ugly and annoying... you need to make sure developers have the build tools installed, th...
My company is investigating using a service bus. Currently we have running prototypes of NServiceBus and Microsoft Service Bus (on premise). I'm quite happy with the pub-sub and topic messaging capabilities the bus provides but I'm getting lost in one of the requirements they are referring to. For example: They want to...
I am developing a embedded system (computer + os + programs) to sell it to a company. I am confused about the licensing and the softwares I wanted to use to develop the system.So I want to know if I can use these programs free of charge and without distributing the source code for commercial use.I wanted to use: A lin...
I am currently studding OpengGL with OpenGL Supebible 5th edition. I've found interested for me some C++ code that is distributed with the book (see also on google code). That code is under New BSD License. I am writing my software on C# with SharpGL wrapper and I'd like to know following things: Can I rewrite that C...
I'd like to preface this that this question is similar, but my question doesn't involve randomness, just finicky determinism, so the answer of "use a known seed" doesn't really apply. Likewise, this question is similar, but again, I'm not expecting the algorithm to ever fail -- I just don't know which way it will be co...
I'm trying to program a very basic FLAC player using 100% C# completely from scratch. My understanding of this type of thing is very limited, so I'm using this project as a way to learn about compression and decompression. I'm a computer science and math major currently in university, so I'm not adverse to learning wha...
I'm developing a system using .NET which will be used by multiple users. Because of that, I need to identify on the database which data belongs to each user. Explaining with an example, imagine I have the entity Product. Then each user has its own products, and so in the database on the table of products we must be abl...
I have made a simple web app, which runs completely offline - all data is saved in HTML5's localStorage. Now, I want the data to get synced with the server, so that the user is able to use the app on multiple devices at a time. What I have done so far is: For each operation the user performs, a log entry is added. Whe...
I'm creating a CRUD-based web project, and am thinking about using a server side MVC framework (such as CodeIgniter or Laravel) in tandem with a client side MVC framework (such as AngularJS). Is this a fairly common approach? After all, it's clear that I need something on the server, and that doing MVC on the client as...
I came across this term when looking into PHP's "traits" (which are apparently bad, since, among things, they're not mockable), but I can't really find a definition for this "mockability". It might be related to polymorphism? There isn't even a Wikipedia entry I could find!
I've noticed that Google and large search engines do not display "proper" paging, but display an approximation. For example, I tried to give a specific search on Google to return few results, as per below: eating +ants in malta near the sea This returned "About 71 results". However, it only showed 2 pages in the page...
I am creating something similar to a Content Management System, that can be downloaded and used by everyone that needs it. I've been working in web-development for a couple of years (mainly as a hobby, i.e. creating personal homepages for acquaintances), but have never had the need of a user to enter his own configurat...
I'm building a client library that consumes a collection of OpenStack API services. I know that as time goes on more services will be added - so I want to come up with a clean and neat way of structuring my client library to minimize development time (for future new services) and avoid duplication. So far, I've thought...
I have a class DataImport with only two public methods public void fromStream(InputStream inputStream); public ImportCommand getImportCommand(); When I test it I send some test data to fromStream method dataImport.fromStream(some stream with data...) Only way how to test the result of this method is to get the Import...
This will probably wind up being a fairly simple question, but it needs some background first... I'm modelling various hardware switches, which can be turned on and off. The switches are configurable, allowing a user to specify the numeric values that are sent to the hardware to signal that it should turn on or off. Th...
I've spent most of the last several years working mainly with C# and SQL. Every programmer I've worked with over that time was in the habit of placing the opening brace of a function or control flow statement on a new line. So ... public void MyFunction(string myArgument) { //do stuff } if(myBoolean == true) { ...
I am writting a small webapp for learning. Is it better / best practice to create multiple models or one model with multiple custom data types? For example: Let's say the web app is "PublicLibrary." The library would have shelves. Shelves would have books and locations. Books would have titles, authors, text and a dewe...
C# has the decimal type which is used for numbers that needs exact representation in base 10. For instance, 0.1 cannot be represented in base 2 (e.g. float and double) and will always be an approximation when stored in variables that are of these types. I was wondering if the reversed fact was also possible. Are there ...
This question is a result out of the discussion HERE and was moved from HERE. Is it really good practice to supply EVERY value you display in any view via a model? Especially variables like the current username. Even Microsoft odes the following in their default template for the _LoginPartial in ASP.NET MVC 3+: "Hello ...
What are the key differences between pattern matching in these two languages? I am not referring to syntax, but capability, implementation details, range of use cases and necessity. Scala applications (eg. Lift and Play) speak proudly about the languages pattern matching prowess. Clojure, on the other hand has a librar...
I'm struggling with release management of a piece of software. First some general information: It is a ClickOnce application I follow the release often practice There are about 30 parties served with this software I need full control which update will be delivered to which party Not each party is allowed to get the la...
I use git for versioning. Just yesterday I was working on refactoring my Python code base. After adding a test I found that I had introduced a bug in one of project euler solutions. So I checked out a previous version offline, found the diff and went back to latest version and fixed the problem. It was a bit after tha...
The HDBC documentation states: fetchAllRows :: Statement -> IO [[SqlValue]]Source Lazily fetch all rows from an executed Statement. You can think of this as hGetContents applied to a database result set. The result of this is a lazy list, and each new row will be read, lazily, from the database as the list is proc...
I am creating a series of small sites, I'm using the django framework. The theory goes a user comes to a master site, signs up, then he gets his own child site. Example: navigate to example.com user creates an account "mysite" user then gets his own site: mysite.example.com and he can configure this all he wants My...
I'm 100% on board with the case that one should definitely use both client-side and server-side data validations. However, in the frameworks and environments I've worked in, the approaches I've seen have never been DRY. Most of the time there's no plan or pattern - validations are written in the model spec, and validat...
I have heard of OOCSS some time ago, but never really looked into it. Today I did so, and I thought of the implications of applying OOCSS to a simple CSS theme. One problem I thought of is that, by its nature, OOCSS encourages DRYness and consequently the use of many concise classes that should be applied to elements b...
I've heard about TDD more than one year ago, but until now I didn't manage to get myself started with it. Indeed, one of my greatest doubts is always what to test. The examples given always shows test to verify if some business rule is being correctly implemented. So, for instance, in an auction software we have the bu...
I'm currently writing a series of classes in java that are meant to translate a regular expression (written with the formal definition, not language-specific shortcuts) into a deterministic finite automaton. To make the DFA, it first converts the regex to postfix, then to a syntax tree, then to an NFA, then finally to...
What strategies can be used to read every row in a large Oracle table, only once, but as fast as possible with JDBC & Java ? Consider that each row has non-trivial amounts of data (30 columns, including large text in some columns). Some strategies I can think of are: Single thread and read table. (Too slow, but liste...
I want to build up a social network, targeted to a specific interest. I want to generate revenues in form of ads. I first thought of building it from scratch, which will take a lot of time (even if it's something simple), then i remembered there are open source options like Diaspora or Friendica. I don't know if there ...
At the company I work for I want to improve the way we write software: designing our applications more SOLID. We've been in a new project for a few weeks and I've tried to apply some good practices in its design. For example, loose coupling by programming against interface instead of a concrete class, dependency inject...
Can I sell a closed source commercial product inside a virtualbox VM? This is extremely useful when you want to deliver server side software to users, and not mess in with different OS's (windows/osx). By reading some of the answers here in programmers, I get that it should not be a problem since my software does not l...
I'm tasked with changing some procedural Java code into Object Oriented re-usable module. It's an XML generator utility which uses velocity for XML generation. There are also business rule enrichments, all of which is configurable in Database tables. I have already removed huge if-else statements for rules and made the...
I've been doing some optimization for the following piece of code : public void DrawLine(int x1, int y1, int x2, int y2, int color) { _bitmap.DrawLineBresenham(x1, y1, x2, y2, color); } After profiling it about 70% of the time spent was in getting a context for drawing and disposing it. I ended up sketching the fo...
Related to the question Which hashing algorithm is best for uniqueness and speed? Is there a way to create a hash function, or find one, whose hash length depends completely on the input length, has an adjustable hash character set (Since it must be 1-to-1 function the input must comply to this character set constrain...
(For the purpose of this question, when I say 'interface' I mean the language construct interface, and not an 'interface' in the other sense of the word, i.e. the public methods a class offers the outside world in order to communicate with and manipulate it.) Loose coupling can be achieved by having an object depend on...
(Note: I used 'error' instead of 'problem' in the title for obvious reasons.. ;) ). I did some basic reading on Traits in Scala. They're similar to Interfaces in Java or C#, but they do allow for default implementation of a method. I was wondering: can't this cause a case of the "diamond problem", which is why many lan...
I'm in senior year in high school. I enjoy programming (Java) very much and aspire to do it as a career in the future. However this isn't the topic of this question. My question is: how can I start making consistent progress towards the goal of becoming a great programmer? What I mean is this: I work on my own projects...
Linked lists, as far as I have seen, are largely implemented using object-oriented ideas. (having an object that holds some information and the address of the next link). How were Linked-lists implemented before the object-oriented paradigm came out? Were they only invented(?) once the OOP was developed?
I'm building a service oriented architecture composed (mostly) of Java-based services, each of which is a Maven project (in an individual repository) with two submodules: common, and server. The common module contains the service's interfaces that clients can include in their project to make service calls. The server s...
Currently I'm developing a project that basically is built with ASP.NET Web API. The membership system I'm using is ASP.NET Identity. The only problem I'm seeing with this is that the membership system is being highly coupled with the API I'm bulding. In that case I've thought on bulding interfaces to expose the member...
I'm working a PHP 5.5/MySQL web application. If a class depends partly on some global GET and POST variables for its members, should I just refer to them directly from within the class, or should I have them as arguments in the constructor or some other initiating function? class myclass { protected $id; public fun...
Suppose I have two similar images as follows Image 1 (base) Image 2 (target) The second image is basically a variation of the first image, except with a green oval slapped on top (indeed, I used image1 as the base to produce image2). To save space, I realize that instead of storing two separate images, I simply need ...
Let's say I want to start learning C# so that I can program Unity with it. I look for a well-reviewed book and it says: "Learn Visual C#!". I ask myself what the difference between Visual C# and C# is. If I know Visual C#, do I also know C#?
I did some reading on the <<instantiate>> relationship in UML class diagrams. It's a dependency relationship where one side depends on the other. However, I'm not sure who depends on who: does the instantiating class depend on the instantiated class, or is it the other way around? I found contradicting answers to this....
I have some automated task to be done using certain types of logs generated on the server end of each day. Log files contains specific machine identification "MAC" that is to be re-written in to another text file converted into machine's name. SAMEPE LOG DATA FILES EACH CONTAINING ~2 MILLIONS LINES IN BINARY FORMAT --...
I'm planning to implement a word processor using Java, and Swing for the GUI. I was thinking how I can implement the text area where the user types the text. My idea was to subclass JTextArea. It already has a lot of functionality for setting text, changing font size, etc. I will than add all the additional functionali...
For fun and for practice, I'm thinking of maybe implementing a very basic programming language to run on a simple interpreter written in Java. My question is this: Is it a 'must' to know regular expressions when designing an interpreter, for parsing the text? Should I learn this topic before starting to implement the i...
When Google, Bing or Yahoo are crawling content from Web sites, what makes it legal? Is there a public registry of only allowed crawlers? When researchers are crawling Deep Web, what makes their efforts legal? When tester automate their tests with Selenium or JMeter and hit same site multiple times, what makes their ...
As I understand it, most pseudo-random algorithms work by taking one or more truly random longs, such as the date, time, MAC-Address, serial-number, etc., passing them through a complex series of calculations, and returning the result. However, this isn't possible in Brainf*ck. The language only has 8 valid syntax char...
I'm writing a compiler for a C-like language, and I'm looking for an elegant way to traverse my abstract syntax tree. I'm trying to implement the Visitor pattern, although I'm not convinced that I'm doing it correctly. struct Visitor { // Expressions virtual void visit(AsgnExpression&); virtual void visi...
I'm new to Objective-C programming, and creating various classes for an iOS application I'm working on. When creating objects, it seems like many classes in the built-in frameworks use the "static factory method" pattern, like this: MyObject* m = [MyObject objectWithName:@"foo" id:@7 description:@"bar"]; however, many...
I have a for loop running over a list of objects like: [{a: 2001, b: "hello"}, {a: 54, b: "hi"}....] In this loop, I filter out objects based on certain field values (like, b == hello?) and create a new list of filtered objects. Once the for loop is complete, I sort the remaining objects by the value of a. This is a...
Background Information: I'm building a 2D maze generator. I have tried Prim's algorithm, Wilson's algorithm, and a recursive backtracker algorithm for generating my maze, however was not satisfied with the difficulty of any. I have decided to create my own. I decided that two things make a maze hard. First, mazes can h...
I am currently working on a tic tac toe auto-mover game. I have come upon a decent algorithm that allows the computer to easily build towards, and claim victory spots. The problem however is that when the opponent is dangerously close to victory, the computer continues to build towards it's own victory instead of block...
I have to design an xml structure to set standard data exchange with my client. We deal with payments and its related data. At now, my XML data looks like this: <PAYMENTS> <CURRENCY>DOLLARS</CURRENCY> <PAYMENTTYPE>CHEQUE</PAYMENTTYPE> <PAYMENT> <AMOUNT>100</AMOUNT> // ALL OTHER DETAILS GO HERE </PAYMENT> <PA...
I am trying to develop a web application on a windows machine using apache wicket, java, jquery etc. Apache wicket comes with an embedded jetty server. I am using eclipse as the IDE. The application needs to access some resources like configuration files etc that are present on remote machine (linux server) to which we...
I have a PaypalCheckout object that handles the checkout process: from initiating API calls, to providing an interface for front-end code (e.g. View/Controller). The PaypalCheckout object handles: gathering price details from a basket, to redirecting to paypal for payment, to getting the customer's address details from...
Given a REST API, which throws an exception when handling a request from a client. Whenever the REST API throws an exception, it's logged and the application (in this case a console application) closes to prevent further damage. Should I send a response to the client whose request resulted in an exception, indicating ...
I'm setting up a GitLab server in my company and now I'm adding GitLab CI to it. Before start this task I'd like to understand if there are any disadvantages running my runners on the same server used by GitLab and GitLab CI. I've read that there are security concerns but we use it only internally so I don't think this...
I am running a project where I pay developers to contribute to my semi open source project. My problem is that it is easy to hire developers, but it is very difficult to get anyone to do code reviewing. I have repeatedly attempted to get the senior developers to review the code of the junior developers. I have attempte...
I've searched and read many posts about LGPL and C, and when I was able to find one that related to Java, my mind still didn't rest with ease, so I'll try to be more specific and hopefully get a viable guide lines, and I would eventually consult a lawyer obviously! Setup: There is a LGPL library, lets call it Lib-B I ...
Imagine I have file called strings.dat. Inside this file there are a lot of strings, for example: one million. Strings are sorted. Now I want to find a specified string, so I can write method like this: public long FindByName (string text) { // ... } This method can return to me a position within a file where this...
Following Martin Fowler's explanation on event sourcing, I have a message class that looks something like this: ShippingEvent { Process(Ship ship) {} } However, in my case, I need to talk to another component in the Process method. More specific, I need to access a repository to get some basic data. Is it ok to ad...
I have a few projects that use various webservices e.g. DropBox, AWS. For managing private information I use bash_profile which works great with heroku that uses env variables to manages secret informations. The problem is my bash_profile is growing significantly (HEROKU_ADD_ON_1 HEROKU_ADD_ON_2 etc.) and it bit me tod...
We are building embedded software using a Linux setup based on the Yocto project. We have a couple different configurations that we are building for different purposes (but the same target). I have been struggling with the best way to set up continuous integration for this project. Ideally, I would like to be able to...
What was the reasoning behind not explicitly storing an array's length with an array in C? The way I see it, there are overwhelming reasons to do so but not very many in support of the standard (C89). For instance: Having length available in a buffer can prevent buffer overrun. A Java-style arr.length is both clear an...
I know that in 32bit machine, cpu read from memory 32bits at a time. since the registers in this case is 32bit in size too, I can understand how this works. What I don't understand is how the cpu implement load instructions of 1 byte. does it load the whole word where the single byte is located to the register, then pe...
Here is my initial code that I would like to modify by using strategy design pattern. class Bar { int a; int b; ... } Class Foo { Bar *bar; bool action1(){ // this function does a lot of work that only uses "bar.a" } bool action2(){ // this function does also a lot of work that only uses "bar....
I work for a company that has an online store, and we constantly have to deal with a lot of spam product reviews, and bogus customer accounts. These are all created by automated systems and are more of a nuisance than anything. What I am thinking of (in lieu of captcha, which can be broken) is adding a sort of form ke...
How can I annotate in a UML class diagram that an instance of ClassA is registered as an observer of an instance of ClassB? (Both implement the appropriate interfaces). This doesn't really belong in a class diagram, because they are static, but if this is something that is important to the design - how can you annotate...
Is there some specific piece of advice around persist values that indicate type? Specifically I want to know if I should persist a flag/state indicating the type in persistence or not. I get the feeling I'm forgetting/not understanding some core concept of OO or data modelling. Something that's been on my mind for the ...
Consider this mock-up of a software stack designed with layered architecture in mind : Every application layer is decoupled through API calls, but a memory handling library is used throughout. All layers need to copy, allocate or somehow affect memory. Is this bad use of the layered architecture pattern, or is it one ...
Given a set {1,2,3} output { {}, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3} } I have only been able to find as fast as O(2^n), is there any techniques for achieving faster results (besides parallelizing)
I'm just wondering if you have an application where you define a class that defines some user configurable settings (from an xml file, or a GUI), should you design it so that it follows SOLID as much as possible like the rest of the application? More specifically, how do you change the available settings without viol...
I'm getting started on a project wherein I want to have pretty thorough test coverage, and I have the luxury of driving the test strategy. I've settled on a workable plan for unit testing, and I've also settled on using Gherkin to describe features and a port of Cucumber to run the scenarios as end-to-end acceptance t...
My team are using Scrum and we are new to this methodology. I use Essential Scrum as our guideline but I haven't finished it yet. On a chapter, it says the team should focus on idle tasks, not idle workers which I somewhat agree with it. Anyway, it doesn't say (at least on that chapter) what to do or how to solve it. W...
I am currently working an Android app that receives most of the displayed data from a REST interface. First, I request the information for a company the request includes a list of store IDs. With each ID I can then request the details for this store. As part of my app I can update the store opening hours and send them ...
When I was using the modernizr file, I came across this problem where in I need to source a file and call the script. <script src="js/modernizr-min.js"></script> <script> if (!Modernizr.input.placeholder){ $('input[placeholder], textarea[placeholder]').placeholder(); } </script> Why is that the script does n...
When I first learnt about Domain Driven Design, I was also introduced to the repository and unit of work patterns that once seemed to be top notch for the cool kids that threw SQL queries like cavemans against databases. The deeper I got into that topic, the more I learnt that they don't seem to be necessary anymore be...
Moore's law is an empirical law and in simple terms states that the number of transistors on integrated circuits doubles approximately every two years. One of the consequences of Moore's law is that CPU performance doubles every 18 Months. I've seen 'Why is Moore's Law seen as an absolute truth?' and although curious d...