Daily Archives

Articles indexed Thursday January 13 2011

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

  • Sudoku Recursion Issue (Java)

    - by SkylineAddict
    I'm having an issue with creating a random Sudoku grid. I tried modifying a recursive pattern that I used to solve the puzzle. The puzzle itself is a two dimensional integer array. This is what I have (By the way, the method doesn't only randomize the first row. I had an idea to randomize the first row, then just decided to do the whole grid): public boolean randomizeFirstRow(int row, int col){ Random rGen = new Random(); if(row == 9){ return true; } else{ boolean res; for(int ndx = rGen.nextInt() + 1; ndx <= 9;){ //Input values into the boxes sGrid[row][col] = ndx; //Then test to see if the value is valid if(this.isRowValid(row, sGrid) && this.isColumnValid(col, sGrid) && this.isQuadrantValid(row, col, sGrid)){ // grid valid, move to the next cell if(col + 1 < 9){ res = randomizeFirstRow(row, col+1); } else{ res = randomizeFirstRow( row+1, 0); } //If the value inputed is valid, restart loop if(res == true){ return true; } } } } //If no value can be put in, set value to 0 to prevent program counting to 9 setGridValue(row, col, 0); //Return to previous method in stack return false; } This results in an ArrayIndexOutOfBoundsException with a ridiculously high or low number (+- 100,000). I've tried to see how far it goes into the method, and it never goes beyond this line: if(this.isRowValid(row, sGrid) && this.isColumnValid(col, sGrid) && this.isQuadrantValid(row, col, sGrid)) I don't understand how the array index goes so high. Can anyone help me out?

    Read the article

  • How to fit page to Silverlight WebBrowser control?

    - by Igor V Savchenko
    Hello. I use WebBrowser Silverlight 4 control to load some page: <WebBrowser Height="350" Name="webBrowser" Width="400" /> ... webBrowser.Navigate(new Uri("http://mail.live.com")); But page loads with horizontal and vertical scroll bars. So I'm trying to find some ways to get actual size of loaded page (then I can change Height/Width of control) OR change scale of loaded page (to fit it to the actual WebControl control). Is it possible to do with standard WebControl methods?

    Read the article

  • How to add SQL elements to an array in PHP

    - by DanLeaningphp
    So this question is probably pretty basic. I am wanting to create an array from selected elements from a SQL table. I am currently using: $rcount = mysql_num_rows($result); for ($j = 0; $j <= $rcount; $j++) { $row = mysql_fetch_row($result); $patients = array($row[0] => $row[2]); } I would like this to return an array like this: $patients = (bob=>1, sam=>2, john=>3, etc...) Unfortunately, in its current form, this code is either copying nothing to the array or only copying the last element.

    Read the article

  • How should I avoid memoization causing bugs in Ruby?

    - by Andrew Grimm
    Is there a consensus on how to avoid memoization causing bugs due to mutable state? In this example, a cached result had its state mutated, and therefore gave the wrong result the second time it was called. class Greeter def initialize @greeting_cache = {} end def expensive_greeting_calculation(formality) case formality when :casual then "Hi" when :formal then "Hello" end end def greeting(formality) unless @greeting_cache.has_key?(formality) @greeting_cache[formality] = expensive_greeting_calculation(formality) end @greeting_cache[formality] end end def memoization_mutator greeter = Greeter.new first_person = "Bob" # Mildly contrived in this case, # but you could encounter this in more complex scenarios puts(greeter.greeting(:casual) << " " << first_person) # => Hi Bob second_person = "Sue" puts(greeter.greeting(:casual) << " " << second_person) # => Hi Bob Sue end memoization_mutator Approaches I can see to avoid this are: greeting could return a dup or clone of @greeting_cache[formality] greeting could freeze the result of @greeting_cache[formality]. That'd cause an exception to be raised when memoization_mutator appends strings to it. Check all code that uses the result of greeting to ensure none of it does any mutating of the string. Is there a consensus on the best approach? Is the only disadvantage of doing (1) or (2) decreased performance? (I also suspect freezing an object may not work fully if it has references to other objects) Side note: this problem doesn't affect the main application of memoization: as Fixnums are immutable, calculating Fibonacci sequences doesn't have problems with mutable state. :)

    Read the article

  • extjs 3 - Check which tabs are hidden and which are not in tabpanel

    - by user427969
    Hi everyone, I have a tabpanel where some tabs are hidden. How can i check which tabs are hidden and which are not. For example: - There are 5 tabs tab1, tab2, tab3, tab4, tab5. tab2 and tab4 are hidden. - if i m in tab1 then tab2.hidden is true or tab2.isVisible() is false - if i m in tab1 then tab3.hidden is true or tab3.isVisible() is false So how can i check the actual hidden tabs???? Thanks a lot for help Regards

    Read the article

  • Why can I not register a PropertyEditor for String in Spring MVC?

    - by Tom Tucker
    I'm using Spring 3.0.3. I've enabled the default ConversionService by adding this line to my Spring configuration XML. <mvc:annotation-driven/> I'm also using custom PropertyEditor's for certain data types, so I've registered them for corresponding data types like the following and they work fine. webDataBinder.registerCustomEditor(Date.class, new MyPropertyEditor()); I have a custom tag library that extends Spring's Form tag library, and I can acess these PropertyEditor's through getPropertyEditor() of AbstractDataBoundFormElementTag. What I don't understand is that I can't register a custom PropertyEditor for String for some reason. The following wouldn't work. webDataBinder.registerCustomEditor(String.class, new MyPropertyEditor()); When I do getPropertyEditor(), it always returns a ConvertingPropertyEditorAdapter, instead of MyPropertyEditor. Is this a bug? EDIT: I realized that I didn't do some stuff right. Spring works just fine.

    Read the article

  • How do I modify this download function in Python?

    - by TIMEX
    Right now, it's iffy. Gzip, images, sometimes it doesn't work. How do I modify this download function so that it can work with anything? (Regardless of gzip or any header?) How do I automatically "Detect" if it's gzip? I don't want to always pass True/False, like I do right now. def download(source_url, g = False, correct_url = True): try: socket.setdefaulttimeout(10) agents = ['Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)','Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1)','Microsoft Internet Explorer/4.0b1 (Windows 95)','Opera/8.00 (Windows NT 5.1; U; en)'] ree = urllib2.Request(source_url) ree.add_header('User-Agent',random.choice(agents)) ree.add_header('Accept-encoding', 'gzip') opener = urllib2.build_opener() h = opener.open(ree).read() if g: compressedstream = StringIO(h) gzipper = gzip.GzipFile(fileobj=compressedstream) data = gzipper.read() return data else: return h except Exception, e: return ""

    Read the article

  • Maven mercurial extension constantly fails

    - by TheLQ
    After 2+ hours I was able to get the maven-scm-provider-hg extension (for pushing to mercurial repos from Maven) semi working, meaning that it was executing commands instead of just giving errors. However I think I've run into a wall with this error [INFO] [deploy:deploy {execution: default-deploy}] [INFO] Retrieving previous build number from pircbotx.googlecode.com [INFO] Removing C:\DOCUME~1\Owner\LOCALS~1\Temp\wagon-scm1210107000.checkout\pir cbotx\pircbotx\1.3-SNAPSHOT [INFO] EXECUTING: cmd.exe /X /C "hg clone -r tip https://*SNIP*@site.pircbotx.googlecode.com/hg/maven2/snapshots/pircbotx/pircbotx/1.3-SNAPSHOT C:\DOCUME~1\Owner\LOCALS~1\Temp\wagon-scm1210107000.checkout\pircbotx\pircbotx\1.3-SNAPSHOT" [INFO] EXECUTING: cmd.exe /X /C "hg locate" [INFO] repository metadata for: 'snapshot pircbotx:pircbotx:1.3-SNAPSHOT' could not be found on repository: pircbotx.googlecode.com, so will be created Uploading: scm:hg:https://site.pircbotx.googlecode.com/hg/maven2/snapshots/pircbotx/pircbotx/1.3-SNAPSHOT/pircbotx-1.3-SNAPSHOT.jar [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error deploying artifact: Error listing repository: No such command 'list'. What on earth would cause that error? I'm on a Windows box, so any commands that aren't commands give "'list' is not recognized as an internal or external command...", not "No such command 'list'." POM <build> <extensions> <extension> <groupId>org.apache.maven.scm</groupId> <artifactId>maven-scm-provider-hg</artifactId> <version>1.4</version> </extension> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-scm</artifactId> <version>1.0-beta-7</version> </extension> </extensions> ... <distributionManagement> <snapshotRepository> <id>pircbotx.googlecode.com</id> <name>PircBotX Site</name> <url>scm:hg:https://site.pircbotx.googlecode.com/hg/maven2/snapshots</url> <uniqueVersion>false</uniqueVersion> </snapshotRepository> </distributionManagement> Mercurial version W:\programming\pircbot-hg>hg version Mercurial Distributed SCM (version 1.7.2) Any suggestions?

    Read the article

  • servlet-mapping for Wordpress on Tomcat using Quercus

    - by Jeremy
    I have a web app running in Tomcat and I'm trying to add a Wordpress blog to it using Quercus. It works if I hit a .php file in my blog, but links to my articles are structured like http://myapp.com/blog/2011/01/my-first-post/ which don't work. Below is my web.xml: <welcome-file-list> <welcome-file>index.do</welcome-file> <welcome-file>index.php</welcome-file> </welcome-file-list> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/myapp-service.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>myapp</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>myapp</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <servlet> <servlet-name>Quercus Servlet</servlet-name> <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Quercus Servlet</servlet-name> <url-pattern>*.php</url-pattern> </servlet-mapping> I've tried many combos of url-pattern such as /blog, /blog/*, etc. I can't get anything to work. Any help is appreciated. Thanks!

    Read the article

  • Quick MVC2 checkbox question

    - by kevinmajor1
    In order to get my EF4 EntityCollection to bind with check box values, I have to manually create the check boxes in a loop like so: <p> <%: Html.Label("Platforms") %><br /> <% for(var i = 0; i < Model.AllPlatforms.Count; ++i) { %> <%: Model.AllPlatforms[i].Platform.Name %> <input type="checkbox" name="PlatformIDs" value="<%: Model.AllPlatforms[i].Platform.PlatformID %>" /><br /> <% } %> </p> It works, but it doesn't automatically populate the group of check boxes with existing values when I'm editing a model entity. Can I fudge it with something like? <p> <%: Html.Label("Platforms") %><br /> <% for(var i = 0; i < Model.AllPlatforms.Count; ++i) { %> <%: Model.AllPlatforms[i].Platform.Name %> <input type="checkbox" name="PlatformIDs" value="<%: Model.AllPlatforms[i].Platform.PlatformID %>" checked=<%: Model.GameData.Platforms.Any(p => PlatformID == i) ? "true" : "false" %> /><br /> <% } %> </p> I figure there has to be something along those lines which will work, and am just wondering if I'm on the right track. EDIT: I'm purposely staying away from MVC's check box HTML helper methods as they're too inflexible for my needs. My check boxes use integers as their values by design.

    Read the article

  • A simple example of validation in ASP.Net applications

    - by nikolaosk
    I am going to start a new series of posts and I am going to cover in depth all the validation mechanisms/techniques/controls we have available in our ASP.Net applications. As many of you may know I am a Microsoft Certified Trainer and I will present this series of posts from a trainer's point of view. This series of posts will be helpful to all of novice/intermediate programmers who want to see all the tools available for validating data in ASP.Net applications. I am not going to try to convince...(read more)

    Read the article

  • Article Sharing &ndash; Windows Azure Memcached Plugin

    - by Shaun
    I just found that David Aiken, a windows azure developer and evangelist, wrote a cool article about how to use Memcached in Windows Azure through the new feature Azure Plugin. http://www.davidaiken.com/2011/01/11/windows-azure-memcached-plugin/ I think the best solution for distributed cache in Azure would be the Windows Azure AppFabric Caching but since it’s only in CTP and avaiable in the US data center David’s solution would be the best. Only one thing I’m concerning about, is the stability of windows verion Memcached.

    Read the article

  • memcache fast-cgi php apache 2.2 windows 7 creating problems

    - by Ahmad
    hi, i am trying to run memcache, fast-cgi with apache 2.2 + php on a windows 7 machine. if i dont use memcache everything works fine. the moment i disable extension=php_memcache.dll in php.ini everything returns to normal. once i start apache, the apache logs say: [Wed Jan 12 18:19:23 2011] [notice] Apache/2.2.17 (Win32) mod_fcgid/2.3.6 configured -- resuming normal operations [Wed Jan 12 18:19:23 2011] [notice] Server built: Oct 18 2010 01:58:12 [Wed Jan 12 18:19:23 2011] [notice] Parent: Created child process 412 [Wed Jan 12 18:19:23 2011] [notice] Child 412: Child process is running [Wed Jan 12 18:19:23 2011] [notice] Child 412: Acquired the start mutex. [Wed Jan 12 18:19:23 2011] [notice] Child 412: Starting 64 worker threads. [Wed Jan 12 18:19:23 2011] [notice] Child 412: Starting thread to listen on port 80. and after accessing the page [the page just has echo phpinfo()]. i get this error in the error.log [Wed Jan 12 18:20:54 2011] [warn] [client 127.0.0.1] (OS 109)The pipe has been ended. : mod_fcgid: get overlap result error [Wed Jan 12 18:20:54 2011] [error] [client 127.0.0.1] Premature end of script headers: index.php i have php_memcache.dll in my ext directory and httpd.conf is like this: LoadModule fcgid_module modules/mod_fcgid.so FcgidInitialEnv PHPRC "c:/php" FcgidInitialEnv PATH "c:/php;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;" FcgidInitialEnv SystemRoot "C:/Windows" FcgidInitialEnv SystemDrive "C:" FcgidInitialEnv TEMP "C:/WINDOWS/Temp" FcgidInitialEnv TMP "C:/WINDOWS/Temp" FcgidInitialEnv windir "C:/WINDOWS" FcgidIOTimeout 64 FcgidConnectTimeout 32 FcgidMaxRequestsPerProcess 500 <Files ~ "\.php$>" AddHandler fcgid-script .php FcgidWrapper "c:/php/php-cgi.exe" .php </Files> so the problem has to be related to memcache coz if i disable it, fast-cgi seems to be working fine. any possible reasons for this?? the memcache service is running.. i can check it through control panel-services

    Read the article

  • Best Pratices for a Network File Share?

    - by Chris
    So we have a file share that was started 10 years or so ago and it started off with the best intentions. But now it's gotten bloated, there's files in there that nobody know who put them there, it's hard to find information, ect ect. You probably know the problem. So what I'm wondering is what do people do in this situation. Does anyone know of a decent program that can go through a file share and find files that no body has touched? Duplicate files? Any other suggestions on cleaning this mess up?

    Read the article

  • Which hardware changes require operating system reinstallation?

    - by Mark
    I'm about to upgrade my computer but might keep some parts. Just wandering what I would have to keep to prevent me having to reinstall my OSs, at the moment I have a dual boot setup with ubuntu and windows 7. I'm pretty sure you can't just take your hard drive with the OS on it and put it into a different box and keep going (can you?) but I know you can change the graphics cards, secondary hard drives and ram with out a problem. So what is it that you can't change? The CPU? Motherboard? Thanks for any replies

    Read the article

  • UTF-8 bit representation

    - by Yanick Rochon
    I'm learning about UTF-8 standards and this is what I'm learning : Definition and bytes used UTF-8 binary representation Meaning 0xxxxxxx 1 byte for 1 à 7 bits chars 110xxxxx 10xxxxxx 2 bytes for 8 à 11 bits chars 1110xxxx 10xxxxxx 10xxxxxx 3 bytes for 12 à 16 bits chars 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 4 bytes for 17 à 21 bits chars And I'm wondering, why 2 bytes UTF-8 code is not 10xxxxxx instead, thus gaining 1 bit all the way up to 22 bits with a 4 bytes UTF-8 code? The way it is right now, 64 possible values are lost (from 1000000 to 10111111). I'm not trying to argue the standards, but I'm wondering why this is so? ** EDIT ** Even, why isn't it UTF-8 binary representation Meaning 0xxxxxxx 1 byte for 1 à 7 bits chars 110xxxxx xxxxxxxx 2 bytes for 8 à 13 bits chars 1110xxxx xxxxxxxx xxxxxxxx 3 bytes for 14 à 20 bits chars 11110xxx xxxxxxxx xxxxxxxx xxxxxxxx 4 bytes for 21 à 27 bits chars ...? Thanks!

    Read the article

  • Rainmeter customization issues, pretty basic

    - by user62865
    I'll admit it; I'm new to using Rainmeter. What I want to do is create two panels (one left, the other on the right) that mirror one another. One side I want to work for the Eastern US while the other for the UK. I want to keep digital clocks, the same style etc., on both sides with their respective time zone. On top of this I want to have weather reports for the whole day (Current weather and temp, morning, afternoon, and night) for each location. However, I have not been able to find any skins which allow this. For whatever reason every time I try to load a skin for a clock I can only load it for one clock of that type and I'm having the same issue with the weather skins. Could anyone please tell me what skins I should look at and how to get a mirrored look?

    Read the article

  • Internet Explorer cannot download rss.php

    - by davethegr8
    Whenever I try to go to an RSS feed in IE7 directly, I get a very strange error. IE 7 tries to download the page, but fails. It throws an error, Internet Explorer cannot download rss.php from www.example.com. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. But when I click a link to view the same feed, it doesn't throw an error but displays the XML instead. Are there any ways I caan fix this, that don't involve OS hacks? Also, if I try to put an xsl stylesheet on it, it tries to download the file no matter what and still errors.

    Read the article

  • How to delete a podcast from an iPod and not have it reappear after syncing with iTunes?

    - by Mike
    Hi everyone, Say I have subscribe to a single podcast and I have Episode 1 and Episode 2 on my iPod. Each episode is 30 minutes long. I listen to the entirety of Episode 1 and just the first 15 minutes of Episode 2. I delete Episode 1 using my iPod's menu. Say Episode 3 has just come out. I want to be able to sync with iTunes, and after doing so, have just Episodes 2 and 3 on my iPod (with Episode 2 "half listened to"). How can I do this? Ideal state... Episode 1 = deleted Episode 2 = 15 minutes played already Episode 3 = unplayed I've found that if I set the Sync Podcast option in iTunes to "all new", I get: "All new" Episode 1 = not on the iPod Episode 2 = not on the iPod Episode 3 = unplayed and if I set the Sync Podcast option in iTunes to "all unplayed" "All unplayed" Episode 1 = unplayed Episode 2 = 15 minutes played already Episode 3 = unplayedv neither option does what I want. Is there an option to get my "ideal state"?

    Read the article

  • ODAC 11.2 Release 3(11.2.0.2.1)?????:64bit?ODP.NET?TimesTen????

    - by Yusuke.Yamamoto
    ODAC 11.2 Release 3(11.2.0.2.1) ??????????? Oracle Data Provider for .NET(ODP.NET) ?? Oracle Providers for ASP.NET ?64bit??????????????? ????????·????????? Oracle TimesTen In-Memory Database ??????????????? Oracle Data Access Components(ODAC) ?????? Oracle Data Access Components(ODAC) ?????? ??? .NET ????????? .NET ?????????????????? Oracle Database ????????? ???????/???1????!.NET + Oracle Database 11g ???????????? ?????????? .NET|???????????

    Read the article

  • Help needed on a UI/Developer Interview

    - by AJ Seth
    I have a phone interview with a major Internet company and it is a mostly front-end developer position. If anyone has experience with UI/developer interviews and can give some advice/questions asked etc. that'll be great. Additionally, what resources can be read and reviewed for the following: Designing for performance, scalability and availability Internet and OS security fundamentals EDIT: Now I am told that the interview I am told will be mostly on coding, Data Structures, design questions etc. Anyone?

    Read the article

  • Generic Content Player?

    - by Jantire
    The general idea on the web appears to be that video/audio are to be separated with plain text. By separated, I mean you have a place that plays video/audio and a place that you read text. This is because it is widely understood that they are vastly different. However, audio and video are just another way of communication, just like text. So why do we separate the two even if they are nearly the same thing? Correct me if I'm wrong but, most tutorials are either plain text how-to's (wiki-style) or visual/auditory instructional videos (YouTube). Why aren't the two combined? Or, if it's already been done can someone reply with the link? This might be bordering off-topic and if it is off-topic then please point me to the right place so it won't be. This might also appear to be an obvious question, however I'm not sure if this subject has really been deeply thought-out by more than a few individuals.

    Read the article

  • Slow internet browsing in Ubuntu

    - by Mark
    I have a dual boot set up with windows and ubuntu, when I'm using windows internet browsing is a lot faster than when I'm using ubuntu and I don't know why. It's like there's just a big latency rather than the maximum speed is lower, there's a big delay before anything happens when using Ubuntu, it happens with all websites all the time. I've never configured the internet connection because it just worked straight away. I have broadband connection through a router shared with some other computers, when we set up the router and internet connection everything was done with windows. Any ideas on what I could do to fix this? Thanks to anyone who replies.

    Read the article

  • Ubuntu 10.10 forgets desktop theme.

    - by Marcelo Cantos
    (I posed this question on superuser.com and haven't received any answers or comments, then I came across this site, so my apologies to anyone who has seen this already.) I am running Ubuntu in VirtualBox (on a Windows 7 host). Several times now, the top-level menu bar, the task bar — and seemingly every system dialog — have forgotten the out-of-the-box "Ambiance" theme they conform to when I first installed the system. Window captions still preserve the theme, but pretty much nothing else does. I have searched high and low on Google for assistance with this problem. Everything I've found suggests either running some gconf reset or deleting .gconf* .gnome* and other similar directories. I have followed all this advice and nothing works. I still get a boring Windows-95-style gray 3D look and feel. On previous occasions, after much messing around I've given up and rebooted the VM instance, and been pleasantly suprised to see the original "Ambience" theme restored throughout the UI, but invariably it disappears again some time later, usually after a reboot, so I can never figure out what I did that broke it. Here's a sample from Ubuntu's site of what I want it to look like. And here's a screenshot of my system as it currently looks. Also note that my GNOME Terminals normally have a nice purple semi-translucent look, and as can be seen from the screenshot, they are now just a solid matt white. This last time (just yesterday), trying numerous combinations all the usual tricks and rebooting several times hasn't fixed it, so here I am on SU wondering: How do I recover the out-of-the-box theme for my Gnome/Ubuntu desktop, noting that blowing away all config files — as suggested in many places online — fails to achieve this? It might help to know that it seems to fail either after I resize the VM instance, forcing the Ubuntu desktop to resize itself, or after I play around with Compiz settings. I haven't been able to figure out which of these it is, and it could be neither. Given the amount of pain I have had to go through to get things back to normal (and given that I am at a loss as to how to do so), it has proven difficult to definitively isolate the cause.

    Read the article

  • How can I allow robots access to my sitemap, but prevent casual users from accessing it?

    - by morpheous
    I am storing my sitemaps in my web folder. I want web crawlers (Googlebot etc) to be able to access the file, but I dont necessarily want all and sundry to have access to it. For example, this site (superuser.com), has a site index - as specified by its robots.txt file (http://superuser.com/robots.txt). However, when you type http://superuser.com/sitemap.xml, you are directed to a 404 page. How can I implement the same thing on my website? I am running a LAMP website, also I am using a sitemap index file (so I have multiple site maps for the site). I would like to use the same mechanism to make them unavailable via a browser, as described above.

    Read the article

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