Daily Archives

Articles indexed Sunday April 18 2010

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

  • Sudoku Solver

    - by merrillaldrich
    Today I am putting up something silly, just for fun. I set myself the task a while back to write a Sudoku solver in T-SQL, but with two dumb constraints that I would never follow given a real problem: I didn’t look at any documented techniques for solving Sudoku, and I specifically avoided T-SQL solutions, even though this has been done already many times. (The first thing I do with a real problem is to see who solved it already, and how, since most things have been done already. Not checking is...(read more)

    Read the article

  • Is it a good practice to suppress warnings?

    - by Chris Cooper
    Sometimes while writing Java in Eclipse, I write code that generates warnings. A common one is this, which I get when extending the Exception class: public class NumberDivideException extends Exception { public NumberDivideException() { super("Illegal complex number operation!"); } public NumberDivideException(String s) { super(s); } } // end NumberDivideException The warning: The serializable class NumberDivideException does not declare a static final serialVersionUID field of type long. I know this warning is caused by my failure to... well, it says right above. I could solve it by including the serialVersionUID, but this is a one hour tiny assignment for school; I don't plan on serializing it anytime soon... The other option, of course, is to let Eclipse add @SuppressWarnings("serial"). But every time my mouse hovers over the Suppress option, I feel a little guilty. For programming in general, is it a good habit to suppress warnings? (Also, as a side question, is adding a "generated" serialVersionUID like serialVersionUID = -1049317663306637382L; the proper way to add a serialVersionUID, or do I have to determine the number some other way?)

    Read the article

  • SQL Select queries

    - by sds
    Which is better and what is the difference? SELECT * FROM TABLE_A A WHERE A.ID IN (SELECT B.ID FROM TABLE_B B) or SELECT * FROM TABLE_A A, TABLE_B B WHERE A.ID = B.ID

    Read the article

  • Strange Email Activity Ruby on Rails

    - by Stranger
    Environment.rb ActionMailer::Base.delivery_method = :sendmail ActionMailer::Base.sendmail_settings = { :address = "mail.example.org", :domain = "example.org", :port = 25, :authentication = :login, :user_name = "email+email.org", :password = "password" } ActionMailer::Base.perform_deliveries = true ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.default_charset = "utf-8" Development.log Sent mail to [email protected] Date: Sat, 17 Apr 2010 19:38:08 -0500 From: example.org To: [email protected] Subject: Hello Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 The process of sending email is ok but when I check my email I didn't recive any. What seems to be wrong?

    Read the article

  • understanding func<T, TResult> C#

    - by Satish Raj
    Hi I am trying to refactor some of my code to use Func I have created a sample to try to understand how it works but I am getting compilation error. In the e.g. below when I am trying to access the parameter attributes or return the return value the compiler complain. Clarifications please. using System; namespace chsarp { class Program { static void Main(string[] args) { ParamInput input = new ParamInput(); input.ReservationID = 10; Test testMethod = new Test(); Func<ParamInput, ReservationResult> methodToInvoke = testMethod.GetStatus; ReservationResult result = TestFn(methodToInvoke, input); } static Result TestFn<Param, Result>(Func<Param, Result> methodToInvoke, Param parameter) where Result : new() { Result result = new Result(); try { result = methodToInvoke(parameter); } catch (Exception exception) { result.status = string.Format("Error-{0} during reserving {1}", parameter.ReservationID, exception.Message); } return result; } } class Test { public ReservationResult GetStatus(ParamInput msg) { ReservationResult result = new ReservationResult(); result.status = string.Format("The ReservationID-{0}", msg.ReservationID); return result; } } class ParamInput { public int ReservationID { get; set; } } class ReservationResult { public string status { get; set; } } }

    Read the article

  • C++ trouble with pointers to objects

    - by Zibd
    I have a class with a vector of pointers to objects. I've introduced some elements on this vector, and on my main file I've managed to print them and add others with no problems. Now I'm trying to remove an element from that vector and check to see if it's not NULL but it is not working. I'm filling it with on class Test: Other *a = new Other(1,1); Other *b = new Other(2,2); Other *c = new Other(3,3); v->push_back(a); v->push_back(b); v->push_back(c); And on my main file I have: Test t; (...) Other *pointer = t.vect->at(0); delete t.vect->at(0); t.vect->erase(t.vect->begin()); if (pointer == NULL) { cout << "Nothing here.."; } // Never enters here..

    Read the article

  • Printing entire array in C#

    - by DMan
    I have a simple 2D array: int[,] m = {{0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0} }; How can I print this out onto a text file or something? I want to print the entire array onto a file, not just the contents. For example, I don't want a bunch of zeroes all in a row: I want to see the {{0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0} }; in it.

    Read the article

  • Send instance method to module

    - by Matchu
    Given the following module, module Foo def bar :baz end end def send_to_foo(method) # ...? end send_to_foo(:bar) # => :baz What code should go in send_to_foo to make the last line work as expected? (send_to_foo is obviously not how I would implement this; it just makes clearer what I'm looking for.) I expected Foo.send(:bar) to work at first, but it makes sense that it doesn't. It would if the method were defined as def self.bar, but that's no fun.

    Read the article

  • PHP Performance Metrics

    - by bigstylee
    I am currently developing a PHP MVC Framework for a personal project. While I am developing the framework I am interested to see any notable performance by implementing different techniques for optimization. I have implemented a crude BenchMark class that logs mircotime. The problem is I have no frame of reference for execution times. I am very near the beginnig of this project with a database connection and a few queries but no output (bar some debugging text and BenchMark log). I have a current execution time of 0.01917 seconds. I was expecting this to be lower but as I said before I have no frame of reference. I appreciate there are many variables to take into account when juding performance but I am hoping to find some sort of metric to a) techniques to measure performance for example requests per second and b) compare results for example; how a "moderately" sized PHP application on a "standard" webserver will perform. I appreciate "moderately" and "standard" are very subjective words so perhaps a table of known execution times for a particular application (eg StackOverFlow's executing time). What are other techniques of measuring performance are there other than execution time? When looking at MVC Framework Performance Comparisom it talks about Requests Per Second (RPS). How is this calculated? I am guessing with my current execution time of 0.01917 seconds can handle 52 RPS (= 1 / 0.01917 ). This seems to be significantly lower than that quoted on the graph especially when you consider my current limited funcitonality.

    Read the article

  • How to set AeDebug to get a minidump with the name of the process ?

    - by JC Martin
    I have to perform some post mortem debugging on a C++ project. Known way to perform is to set the cdb debugger as a minidump generator and to process the dumps collects afterwards. I read nearly the whole web and I didn't find a solution to produce a minidump with the name of the process that has crashed Is there a way to set AeDebug\Debugger registry variable in such a manner that cdb generates a dump file with the name of the process ? When I encapsulate the call to cdb.exe in a batch file, it starts well but stays blocked on the symbol searching. I must perform a Ctrl+C in order to stop the batch, then the minidump, with the correct process name, is created... but of course I can't set up such a thing in an unattended production environment... Has anybody done that before ?

    Read the article

  • Finding a handle that persists when relaunching parent

    - by cidtek
    I need to interact with 3'rd party applications by knowing the handle of certain text fields, but the hWnd always changes when that window is recreated. Is there any method that would allow me to identify a window and repeatedly be able to access that window (even after it is closed and then reopened) without having the user manually identify the window? I need the user to be able to identify a window with the usual click, drag and release method but only have to do it once and not every time the target window is recreated.

    Read the article

  • htaccess not called when the url point to an existing folder

    - by Eldad
    Hi, I'm running zend server on windows 7. I'm using the htaccess from jooml: Options +FollowSymLinks RewriteEngine On RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR] RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR] RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) RewriteRule ^(.*)$ index.php [F,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/index.php RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC] RewriteRule (.*) index.php RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] when I'm calling this url: http://localhost/ABC/ the data is been redirect to index.php but if I'm creating the folder ABC the server is showing the ABC folder content and not redirecting the data back to index.php. how can I prevent that, I want all the calls data to be directed into index.php? Thanks

    Read the article

  • Raising events vs direct method calls differences

    - by dotnetdev
    Hi Raising an event, will call its event handler. eg http://msdn.microsoft.com/en-us/library/aa645739%28VS.71%29.aspx What is the difference between using the events mechanism and direct calls to other methods (eg if a condition is met in method A(), call B() )? And what is the difference between consuming and raising events? Thanks

    Read the article

  • What's your preferred pointer declaration style, and why?

    - by Owen
    I know this is about as bad as it gets for "religious" issues, as Jeff calls them. But I want to know why the people who disagree with me on this do so, and hear their justification for their horrific style. I googled for a while and couldn't find a style guide talking about this. So here's how I feel pointers (and references) should be declared: int* pointer = NULL; int& ref = *pointer; int*& pointer_ref = pointer; The asterisk or ampersand goes with the type, because it modifies the type of the variable being declared. EDIT: I hate to keep repeating the word, but when I say it modifies the type I'm speaking semantically. "int* something;" would translate into English as something like "I declare something, which is a pointer to an integer." The "pointer" goes along with the "integer" much more so than it does with the "something." In contrast, the other uses of the ampersand and asterisk, as address-of and dereferencing operators, act on a variable. Here are the other two styles (maybe there are more but I really hope not): int *ugly_but_common; int * uglier_but_fortunately_less_common; Why? Really, why? I can never think of a case where the second is appropriate, and the first only suitable perhaps with something like: int *hag, *beast; But come now... multiple variable declarations on one line is kind of ugly form in itself already.

    Read the article

  • Ajax doesn't trigger a change-event on a webkit based browser

    - by user319464
    I have adapted a Jquery plugin to for-fill my needs to send GET requests to servers as a way of "pinging" them. I've also added some javascript code to add some fancy features like: depending on the changed value in a that the Jquery plugin changes, it changes the Icon accordingly. To make it all work essentially, I made so that when Ajax gets a "complete" event, it forces a "onChange" event to the span, triggering the javascript validation function to change the status icons. Here is the code of my slightly modified jQuery Plugin: /** * ping for jQuery * * Adapted by Carroarmato0 (to actually work instead of randomly "pinging" nowhere instead of faking * * @auth Jessica * @link http://www.skiyo.cn/demo/jquery.ping/ * */ (function($) { $.fn.ping = function(options) { var opts = $.extend({}, $.fn.ping.defaults, options); return this.each(function() { var ping, requestTime, responseTime ; var target = $(this); var server = target.html(); target.html('<img src="img/loading.gif" alt="loading" />'); function ping() { $.ajax({url: 'http://' + server, type: 'GET', dataType: 'html', timeout: 30000, beforeSend : function() { requestTime = new Date().getTime(); }, complete : function() { responseTime = new Date().getTime(); ping = Math.abs(requestTime - responseTime); if (ping > 2000) { target.text('niet bereikbaar'); } else { target.text(ping + opts.unit); } target.change(); } }); } ping(); opts.interval != 0 && setInterval(ping,opts.interval * 1000); }); }; $.fn.ping.defaults = { interval: 3, unit: 'ms' }; })(jQuery); target.change(); is the code that triggers the "onchange" event in the span: echo " <td class=\"center\"><span id=\"ping$pingNb\" onChange=\"checkServerIcon(this)\" >" .$server['IP'] . "</span></td>"; In Firefox this works, checkServerIcon(this) gets executed and passes the span object to the function. function checkServerIcon(object) { var delayText = object.innerHTML; var delay = delayText.substring(0, delayText.length - 2); if ( isInteger(delay) ) { object.parentNode.previousSibling.parentNode.getElementsByTagName('img')[0].src = 'img/servers/enable_server.png'; } else { if (delay == "bezig.") { object.parentNode.previousSibling.parentNode.getElementsByTagName('img')[0].src = 'img/servers/search_server.png'; } else { object.parentNode.previousSibling.parentNode.getElementsByTagName('img')[0].src = 'img/servers/desable_server.png'; } } } My guess would be that there's something different in WebKit browsers in the way object.parentNode.previousSibling.parentNode. .... works...

    Read the article

  • Rails Multiple Models per Form, Optional FK Association

    - by ckarbass
    Given the following pseudo-code: Company has_many :jobs Job belongs_to :company I'm creating a form to post a new job. In the form, I want to have two fields for an optional company. On submission, if a company was entered, I want to either create or update the company and associate it with the new job. I know if the company exists by searching the companies table for the company's url. Is it possible to do this using form_for, fields_for, and accepts_nested_attributes_for given the company may not exist?

    Read the article

  • Java 2D Game Frameworks

    - by Software Monkey
    I have been looking at frameworks for writing 2D games in Java - part of a growing desire to rediscover my roots in writing those simple but addictive video games. I have googled and found some possibilities, but it's hard to judge which is best without investing significant time in each. Does anyone out there have any recommendations from experience, preferably with a list of pro's and con's for the framework. NOTE: I am not looking so much for comparisons between frameworks but, rather, feedback on any given framework from actually having used it firsthand, or knowing someone who has. The other possibility I am considering is rolling my own, but would rather not. EDIT: I am targeting Java on the Desktop, and expect capable machines, though not state of the art. Some of the 2D engines I have found: Free PulpCore (License: BSD) Slick2D (License: BSD) GTGE - Golden T Game Engine JGame GAGE - Genuine Advantage Gaming Engine GameFrame for Java Basilisk (2D and 3D) Free for non-commercial use Genuts EasyWay - a high-level 2D engine

    Read the article

  • Trouble with pointers and references in C++

    - by KingNestor
    I have a PolygonList and a Polygon type, which are std::lists of Points or lists of lists of points. class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; typedef std::list<Point> Polygon; typedef std::list<Polygon> PolygonList; // List of all our polygons PolygonList polygonList; However, I'm confused on reference variables and pointers. For example, I would like to be able to reference the first Polygon in my polygonList, and push a new Point to it. So I attempted to set the front of the polygonList to a Polygon called currentPolygon like so: Polygon currentPolygon = polygonList.front(); currentPolygon.push_front(somePoint); and now, I can add points to currentPolygon, but these changes end up not being reflected in that same polygon in the polygonList. Is currentPolygon simply a copy of the Polygon in the front of polygonList? When I later iterate over polygonList all the points I've added to currentPolygon aren't shown. It works if I do this: polygonList.front().push_front(somePoint); Why aren't these the same and how can I create a reference to the physical front polygon rather than a copy of it?

    Read the article

  • How to clear the entire second level cache in NHibernate

    - by Bittercoder
    I wish to clear the entire second level cache in NHibernate via code. Is there a way to do this which is independent of the cache provider being used? (we have customers using both memcache and syscache within the same application). We wish to clear the entire cache because changes external the database would have occurred (which we have no guarantees re: which tables/entities were affected).

    Read the article

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