Daily Archives

Articles indexed Thursday June 10 2010

Page 1/121 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Domain-Driven Design

    Domain-Driven Design is the way to build/design your application when you are focused on the Domain Model, when you do not depend on Infrastructure and when your Developers talk on the same language with Customers.

    Read the article

  • RESTlet startup initialization deprecated?

    - by Chris Kaminski
    I'm trying to use the restlet.org library to build a RESTful web interface, and I've noticed that unlike it's servlet counterpart, it has no complement to GenericServlet.init(). Short of building another servlet to do my startup logic, is there any built-in way to avoid building my database factories and the like on the first request (and all the commensurate locking I'll have to do to avoid multiple initializations)?

    Read the article

  • ASP.NET MVC & Detached Entity won't save

    - by Justin
    Hey all, I have an ASP.NET MVC POST action for saving an entity on submit of a form. It works fine for insert but doesn't work for update, the database doesn't get called, so it's clearly not tracking the changes, as it's "detached". I'm using Entity Framework w/.NET 4: //POST: /Developers/Save/ [AcceptVerbs(HttpVerbs.Post)] public ActionResult Save(Developer developer) { developer.UpdateDate = DateTime.Now; if (developer.DeveloperID == 0) {//inserting new developer. DataContext.DeveloperData.Insert(developer); } //save changes - TODO: doesn't update... DataContext.SaveChanges(); //redirect to developer list. return RedirectToAction("Index"); } Any ideas would be greatly appreciated, thanks, Justin

    Read the article

  • Sequence reduction in R

    - by drknexus
    Assume you have a vector like so: v <- c(1,1,1,2,2,2,2,1,1,3,3,3,3) How can it be best reduced to a data.frame like this? v.df <- data.frame(value=c(1,2,1,3),repetitions=c(3,4,2,4)) In a procedural language I might just iterate through a loop and build the data.frame as I go, but with a large dataset in R such an approach is inefficient. Any advice?

    Read the article

  • Exception Errno::EPIPE in Passenger RequestHandler (Broken pipe)

    - by Millisami
    Hi, Upgraded to Rails 2.3.2 and Passenger 2.2.4 on Ubuntu hardy slice at slicehost with Apache2 I'm getting this same above discussed error in my Apache error.log of system /var/logs/apache2/ [ pid=4249 file=ext/apache2/Hooks.cpp:638 time=2009-07-04 11:47:32.752 ]: No data received from the backend application (process 4383) within 45000 msec. Either the backend application is frozen, or your TimeOut value of 45 seconds is too low. Please check whether your application is frozen, or increase the value of the TimeOut configuration directive. *** Exception Errno::EPIPE in Passenger RequestHandler (Broken pipe) (process 4391): from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/rack/request_handler.rb:93:in `write' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/rack/request_handler.rb:93:in `process_request' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_request_handler.rb:206:in `main_loop' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/railz/application_spawner.rb:376:in `start_request_handler' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/railz/application_spawner.rb:334:in `handle_spawn_application' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/utils.rb:182:in `safe_fork' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/railz/application_spawner.rb:332:in `handle_spawn_application' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_server.rb:351:in `__send__' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_server.rb:351:in `main_loop' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_server.rb:195:in `start_synchronously' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_server.rb:162:in `start' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/railz/application_spawner.rb:213:in `start' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/spawn_manager.rb:261:in `spawn_rails_application' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_server_collection.rb:80:in `synchronize' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_server_collection.rb:79:in `synchronize' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/spawn_manager.rb:254:in `spawn_rails_application' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/spawn_manager.rb:153:in `spawn_application' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/spawn_manager.rb:286:in `handle_spawn_application' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_server.rb:351:in `__send__' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_server.rb:351:in `main_loop' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/ phusion_passenger/abstract_server.rb:195:in `start_synchronously' from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/bin/passenger-spawn- server:61 *** Exception Errno::EPIPE in Passenger RequestHandler (Broken pipe) (process 4383): and these too. pid=4362 file=ext/apache2/Hooks.cpp:638 time=2009-07-04 11:55:19.251 ]: No data received from the backend application (process 4383) within 45000 msec. Either the backend application is frozen, or your TimeOut value of 45 seconds is too low. Please check whether your application is frozen, or increase the value of the TimeOut configuration directive. [ pid=4298 file=ext/apache2/Hooks.cpp:638 time=2009-07-04 11:55:19.255 ]: No data received from the backend application (process 4252) within 45000 msec. Either the backend application is frozen, or your TimeOut value of 45 seconds is too low. Please check whether your application is frozen, or increase the value of the TimeOut configuration directive. [Sat Jul 04 11:55:19 2009] [error] [client 86.96.226.13] Premature end of script headers: 41, referer: http://domain.com/ [ pid=4373 file=ext/apache2/Hooks.cpp:638 time=2009-07-04 11:55:19.559 ]: Its getting me mad and on the browser, sometimes its show and when refreshed, Application Error 500 shows up in frequent basis. any directions??

    Read the article

  • Is this the correct way of speaking to a "Content Manager" Class?

    - by DeanMc
    I am creating a silverlight site. I am currently breaking out my ideas into pieces of functionality. One of the idea's I have is the concept of a content manager. This is essentially a UI control with 4 regions. Top, Bottom, Right & Left. I also have a collection of objects that are considered "Menu Items". These are controls that function as a way to navigate around, similar to links. The idea I have is to implement an IMenuItem interface. Among the standard pieces of information (Text, PageReference, etc) I was also going to hold a reference to the content manager. My idea behind this thinking is that I can pass the PageReference to a property on the ContentManager and then call a method which knows how to update the content manager accordingly. Is this the best way of implementing this or is their some sort of pattern for it?

    Read the article

  • Sample uniformly at random from an n-dimensional unit simplex.

    - by dreeves
    Sampling uniformly at random from an n-dimensional unit simplex is the fancy way to say that you want n random numbers such that they are all non-negative, they sum to one, and every possible vector of n non-negative numbers that sum to one are equally likely. In the n=2 case you want to sample uniformly from the segment of the line x+y=1 (ie, y=1-x) that is in the positive quadrant. In the n=3 case you're sampling from the triangle-shaped part of the plane x+y+z=1 that is in the positive octant of R3: (Image from http://en.wikipedia.org/wiki/Simplex.) Note that picking n uniform random numbers and then normalizing them so they sum to one does not work. You end up with a bias towards less extreme numbers. Similarly, picking n-1 uniform random numbers and then taking the nth to be one minus the sum of them also introduces bias. Wikipedia gives two algorithms to do this correctly: http://en.wikipedia.org/wiki/Simplex#Random_sampling (Though the second one currently claims to only be correct in practice, not in theory. I'm hoping to clean that up or clarify it when I understand this better. I initially stuck in a "WARNING: such-and-such paper claims the following is wrong" on that Wikipedia page and someone else turned it into the "works only in practice" caveat.) Finally, the question: What do you consider the best implementation of simplex sampling in Mathematica (preferably with empirical confirmation that it's correct)? Related questions http://stackoverflow.com/questions/2171074/generating-a-probability-distribution http://stackoverflow.com/questions/3007975/java-random-percentages

    Read the article

  • .htaccess rewrite rule to add a string in the middle of the URL

    - by Mike Crittenden
    Using a .htaccess rewrite rule, I need to add "?q=" before the path on any URL's containing the word "imagecache" Therefore, if the URL is: http://mysite.com/sites/default/files/imagecache/myimage.jpg ...then it will really try: http://mysite.com/?q=sites/default/files/imagecache/myimage.jpg But that will ONLY happen if the URL contains "imagecache." Otherwise, it does no rewriting. Also, this will only happen if /sites/default/files/imagecache/myimage.jpg isn't already an existing image file. I believe I can do that using: RewriteCond %{REQUEST_FILENAME} !-f ...right? It's just the first part that I can't figure out.

    Read the article

  • Taking "do the simplest thing that could possible work" too far in TDD: testing for a file-name kno

    - by Support - multilanguage SO
    For TDD you have to Create a test that fail Do the simplest thing that could possible work to pass the test Add more variants of the test and repeat Refactor when a pattern emerge With this approach you're supposing to cover all the cases ( that comes to my mind at least) but I'm wonder if am I being too strict here and if it is possible to "think ahead" some scenarios instead of simple discover them. For instance, I'm processing a file and if it doesn't conform to a certain format I am to throw an InvalidFormatException So my first test was: @Test void testFormat(){ // empty doesn't do anything nor throw anything processor.validate("empty.txt"); try { processor.validate("invalid.txt"); assert false: "Should have thrown InvalidFormatException"; } catch( InvalidFormatException ife ) { assert "Invalid format".equals( ife.getMessage() ); } } I run it and it fails because it doesn't throw an exception. So the next thing that comes to my mind is: "Do the simplest thing that could possible work", so I : public void validate( String fileName ) throws InvalidFormatException { if(fileName.equals("invalid.txt") { throw new InvalidFormatException("Invalid format"); } } Doh!! ( although the real code is a bit more complicated, I found my self doing something like this several times ) I know that I have to eventually add another file name and other test that would make this approach impractical and that would force me to refactor to something that makes sense ( which if I understood correctly is the point of TDD, to discover the patterns the usage unveils ) but: Q: am I taking too literal the "Do the simplest thing..." stuff?

    Read the article

  • Why not allow mutation of the this binding?

    - by gnucom
    Hi Everyone, I'm building a interpreter/compiler for a school project (well now its turning into a hobby project) and an instructor warned me not to allow mutation of the 'this' binding (he said it was gross and made a huge deal about it) but I never learned why this is so... dangerous or bad. I'm very curious about why this is so bad. I figured this sort of feature could be useful in some way or another. I'm wondering if anyone familiar with building languages can tell me what sort of problems mutation on the 'this' binding can cause, and if they know of any cool or useful tricks that one could do if it actually was allowed. Do any languages that you're aware of allow mutation of 'this'? Thanks,

    Read the article

  • [SOLVED] Store files in C# EXE file

    - by sublay
    It is actually useful for me to store some files in EXE to copy to selected location. I'm generating HTML and JS files and need to copy some CSS, JS and GIFs. Snippet System.IO.File.WriteAllBytes(@"C:\MyFile.bin", ProjectNamespace.Properties.Resources.MyFile); doesn't work for me! On "WriteAllBytes" it says: "cannot convert from 'System.Drawing.Bitmap' to 'byte[]'" for image and "cannot convert from 'string' to 'byte[]'" for text file. Help! UPDATE: Solved below.

    Read the article

  • learning the Lower levels of computing

    - by Ben
    I am a software developer with four years experience in .Net development, I always like to keep up to date with the latest technologies (.net related normally) being released and love learning them. I didn't however go to university and learnt all I know through helpful colleagues, .Net courses, the internet and good old books. I feel that I am a good developer, but without learning the lower levels of a computer as you would in the first year of a computer related Uni course, I get lost when talking to people about a lot of more technical lower level computing. Is there a book(s) that anyone could recommend, that would cover the lower levels of what is going on when I click "Run" in Visual Studio? I feel out of my depth when my boss says to me "Thats running in the CPU cache" or "you're limited by disk reads there", and would like to feel more confident when talking about how the hardware talks to each other (CPU to RAM etc). Apologise if thats a vague question, or has been asked before (i did check and couldn't find anything on here that answers my question).

    Read the article

  • Java / Groovy Socket - Detecting the socket being closed in a non-blocking way

    - by John Arrowwood
    I'm trying to create a small HTTP proxy that can re-write the request/headers as needed to suit my requirements. If one already exists, please, point me to it. Otherwise... I've written something that ALMOST works. It can do the proxy function, but not the re-write (yet). Problem is, I can't detect when the remote socket has been closed down without doing a blocking read. It is CRITICAL for the functionality of this thing that it be able to detect the socket being closed without blocking. I have SCOURED the Java API documentation, and I can't find ANY indication that it is even possible. Here's what I have: while ( this.inbound.isConnected() && this.outbound.isConnected() ) { try { while ( ( available = readFromClient.available() ) != 0 ) { if ( available > 1024 ) available = 1024 bytesRead = readFromClient.read( buffer, 0, available ) writeToServer.write( buffer, 0, bytesRead ) } while ( ( available = readFromServer.available() ) != 0 ) { if ( available > 1024 ) available = 1024 bytesRead = readFromServer.read( buffer, 0, available ) writeToClient.write( buffer, 0, bytesRead ) } } catch (e) { print e } println "Connected: " + this.inbound.isConnected() println "Bound: " + this.inbound.isBound() println "InputShutdown: " + this.inbound.isInputShutdown() println "OutputShutdown: " + this.inbound.isOutputShutdown() print "\n"; Thread.sleep( 10 ) } The tests for the socket being closed never indicate that the socket was closed. And, as I mentioned, I can't find ANY examples of how to detect the 'END OF FILE' condition on the stream without doing a blocking read. There HAS to be a way. Does anyone here know what it is?

    Read the article

  • Asterisk Manager API SIPPeers - Permission Denied

    - by Matt H
    I'm wanting to use the asterisk manager api to show the status of all my SIP lines in a PHP web interface. I thought I'd start simple and use telnet to see it working. So I created a user in /etc/asterisk/manager.conf [portal] secret = password read = all,system,call,log,verbose,command,agent,user Then telnet to localhost on port 5038 This is what I get. asterisk ~ # telnet localhost 5038 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Asterisk Call Manager/1.0 Action: login Username: portal Secret: 8u9sdgk Events: off Response: Success Message: Authentication accepted Action: SIPPeers Response: Error Message: Permission denied Why am I getting permission denied? I thought the user has basically full access? Do I need to restart asterisk to make this work? I didn't restart it. On the other hand, I was able to log in which makes me think that the manager.conf has been reloaded as the portal user didn't exist before. Any ideas?

    Read the article

  • is there anyway to know if your supposedly fully dedicated server is really a virtually resource-sha

    - by siran
    Hi, sometimes I feel my server not responding as smoothly as I would expect (i have a Intel(R) Xeon(TM) CPU 2.80GHz Quad Core), given that for example, the 'top' commands reports a low load < 0.5, CPU are almost completely idle ... I maybe have internet connectivity issues, so I don't really know if it's me or if it's the server itself. Is there anykind of benchmarking script (or something analogous) I could run and see the actual performance of the server ?

    Read the article

  • openssl api verify the public key matches private key

    - by AC
    How do I write an openssl server that on a single port has two different active RSA private keys? The openssl documentation seems to implies there can only be one rsa private key active at time with in a context. So I was thinking I have two active context, but what is the code to handle figuring out which connection matches which context. Or am I going about this the wrong way.

    Read the article

  • Comparing two Oracle schema, other users

    - by Igman
    Hello! I have been tasked with comparing two oracle schema with a large number of tables to find the structural differences in the schema. Up until know I have used the DB Diff tool in Oracle SQL Developer, and it has worked very well. The issue is that now I need to compare tables in a user that I cannot log into , but I can see it through the other users section in SQL developer. The issue is that whenever I try to use the diff tool to compare those objects to the other schema it does not work. Does anyone have any idea how to do this? It would save me a very large amount of work. I have some basic SQL knowledge if that is whats needed. Thanks.

    Read the article

  • Mutability design patterns in Objective C and C++

    - by Mac
    Having recently done some development for iPhone, I've come to notice an interesting design pattern used a lot in the iPhone SDK, regarding object mutability. It seems the typical approach there is to define an immutable class NSFoo, and then derive from it a mutable descendant NSMutableFoo. Generally, the NSFoo class defines data members, getters and read-only operations, and the derived NSMutableFoo adds on setters and mutating operations. Being more familiar with C++, I couldn't help but notice that this seems to be a complete opposite to what I'd do when writing the same code in C++. While you certainly could take that approach, it seems to me that a more concise approach is to create a single Foo class, mark getters and read-only operations as const functions, and also implement the mutable operations and setters in the same class. You would then end up with a mutable class, but the types Foo const*, Foo const& etc all are effectively the immutable equivalent. I guess my question is, does my take on the situation make sense? I understand why Objective-C does things differently, but are there any advantages to the two-class approach in C++ that I've missed? Or am I missing the point entirely? Not an overly serious question - more for my own curiosity than anything else.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >