Daily Archives

• Minimax algorithm: Cost/evaluation function?

- by Dave
Hi guys, A school project has me writing a Date game in C++ (example at http://www.cut-the-knot.org/Curriculum/Games/Date.shtml) where the computer player must implement a Minimax algorithm with alpha-beta pruning. Thus far, I understand what the goal is behind the algorithm in terms of maximizing potential gains while assuming the opponent will minify them. However, none of the resources I read helped me understand how to design the evaluation function the minimax bases all it's decisions on. All the examples have had arbitrary numbers assigned to the leaf nodes, however, I need to actually assign meaningful values to those nodes. Intuition tells me it'd be something like +1 for a win leaf node, and -1 for a loss, but how do intermediate nodes evaluate? Any help would be most appreciated.

• split currency and amount from a string

- by webber
I am importing a file which has amount with different currency signs £12.10 \$26.13 €12.50 I need to import and convert this into single currency. I am splitting the string as follows \$parts = split(' ', preg_replace("/([0-9])/", ' \${1}', \$amount, 1)); Couldn't make preg_split work with PREG_SPLIT_DELIM_CAPTURE \$parts = preg_split("/\d/", \$amount, 2, PREG_SPLIT_DELIM_CAPTURE); I have an array of currency sign to currency code \$currencySymbols = array('£'=>'GBP', '\$'=>'USD','€'=>'EUR') I need to 1. split the string into currency sign and value - if there is a better way then what i am doing 2. map the currency sign to currency code. Not able to map with \$currencySymbols[\$parts[0]] Any help will be appreciated. (PHP 5.2.6) using charset=utf-8 Many thanks

• QTKit Capture API: How to implement video screen recording (as in Quicktime X Player)?

- by bjoern
Does the QTKit Capture API support screen recording- i.e., can I specify the current screen output as the input source to record? If so, how? Quicktime Player X supports screen recording, yet the QTKit Capture API Documentation only mentions capturing from external cameras.

• ASP.NET validations not showing up after AJAX calls are made (SharePoint 2007)

- by Josh
I have an AJAX form on SharePoint 2007. If I don't call AJAX on the page, the validations all work fine and the css for the validations shows up. Once I make an AJAX call (say, Create Customer), all the validations still work, but the css for the validations does not show up. Any ideas?

• Multiple calls to different page methods in same web page are not running in parallel (JQuery/Ajax/A

- by Tony_Henrich
I have several page methods defined in the code behind of an aspx page. I have several JS calls (see example below), one after the other, in the ready() method of JQuery to call these page methods. I noticed the javascript calls run asynchronously but the .NET page methods do not run in parallel. Page method 1 finishes first before page method 2 runs. Is there a way to get all the page methods to run all at the same time? My workaround is to put each method in its own aspx page or use iframes but I am looking for better solutions. \$.ajax({ type: "POST", url: (page/methodname), data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { .... } } });

• Best method of achieving bi-directional communication between Apple iPad "clients" and a Windows Ser

- by user361910
We are currently starting to build a client-server system which will see 10 or more Apple iPad client devices communicating to a central Windows server over a wireless LAN. We wanted to some existing plumbing (.NET remoting/WCF/web services/etc) that would allow us to implement a reliable, secure solution without having to start at a low level (e.g. sockets) and recreate the wheel. One of the major requirements that complicates this scenario is that unlike a traditional web service, the windows server needs to be able to arbitrarily notify the clients whenever certain events occur -- so it is not a simple request/response scenario like the web. Initially, we were going to use Windows clients, so our plan was to use the full-duplex mode of .NET WCF over HTTP|TCP. But now using the iPad, we don't have any of the WCF infrastructure. So my question is: what is the best way to allow an iPad and a Windows server to (securely) communicate over a LAN, with each device able to initiate communication to the other? Am I stuck writing low-level socket code? Thanks!

• Gtkbuilder subclasses

- by Masterofpsi
Hi all. I'm developing an application with Gtk and Glade. My impression is that it's common practice to create a subclass of GtkWindow for your main window, but I'm stuck on how I would construct my subclass from a GtkBuilder definition. Does anyone know how?

• Load text from specific external DIV using AJAX?

- by Josh
I'm trying to load up the estimated world population from http://www.census.gov/ipc/www/popclockworld.html using AJAX, and so far, failing miserably. There's a DIV with the ID "worldnumber" on that page which contains the estimated population, so that's the only text I want to grab from the page. Here's what I've tried: \$(document).ready(function(){ \$("#population").load('http://www.census.gov/ipc/www/popclockworld.html #worldnumber *'); });

• Formatting text in an html table column?

- by DavidR
So, I have a table like below. Imagine there are multiple columns, I thought by formatting the <col/> tag I would be able to change the formatting of every <td> in that column. I want to give data in the first column a text-align:center, but it doesn't seem to work. Is there a way to get this to work other than adding a class to every <td>? <table> <col class="column"/> <tr> ... </tr> <tr> ... </tr> <tr> ... </tr> </table>

• vb.net module visibility

- by dcp
If I have a module in a VB.Net class library, will it's visibility be limited to the assembly? What I'm looking for is the VB.Net equivalent of a C# internal static class. Does anyone know the equivalent?

• Finding an object's position in an array in actionscript

- by Comma
var array1:Array = new Array(); var array2:Array = new Array(); var obj1:Object = new Object(); array1.push(obj1); array2.push(obj1); How can I do this what command should I use? //obj1's position in array1 //result: 0 //obj1's position in array2 //result: 0

• Cufon font replacement issue

- by sterling
I copied the working files from a demo url to the live site and cufon refuses to work after modifying everything I can think of. I even regenerated the font thinking I may have accidentally specified a domain for restricting the use. The trouble url is sterlingross.com and I am unable to see where I have gone wrong. Thank you for your help.

• is it possible to programmatically check the service provider for a cell number?

- by I__
is there a database or API available where i can enter a cell phone number and it will spit out whoever the providor is like tmobile or verizon?

• setting jQuery .data() within .getJSON callback

- by hackmaster.a
I'm doing a couple of .getJSON calls and if any one of them succeeds, I'm trying to set a bool to true so I can then do some other stuff elsewhere on the page. I was trying to use jquery's .data() function, but I don't seem able to set it from inside the .getJSON callback. for example: \$('#citations_button').data('citations', false); \$.getJSON(apaurl, function(data) { \$('#apacite').html("<td class=\"bibInfoLabel\">APA Citation</td><td class=\"bibInfoData\">"+data+"</td>"); \$('#citations_button').data('citations', true); }, "html"); // other .getJSONs look like above... console.log("citations? "+\$('#citations_button').data('citations')); prints false, even when I know the data came through. I thought this would work since .data() uses the cache to store the key/value pair. how can i flag successes?? appreciate any assistance!!

• Handle Arbitrary Exception, Print Default Exception Message

- by inspectorG4dget
I have a program, a part of which executes a loop. During the execution of this loop, there are exceptions. Obviously, I would like my program to run without errors, but for the sake of progress, I would like the program to execute over the entire input and not stop when an exception is thrown. The easiest way to do this would be by implementing and except block. However, when I do this, it excepts all exceptions and continues with the program and I never get to see the exception message (which I need in order to debug). Is there a way to except any arbitrary exception and be able to print out the exception message in the except block?

• CakePHP session sharing between two apps, on the same domain

I am having two cakephp application working on the same domain. I access them like localhost:8080/wishlist & localhost:8080/lighthouse The wishlist is a separate cakePHP application and the lighthouse is a separate CakePHP application. The login page is at localhost:8080/lighthouse, now i want the session generated by the lighthouse application to be used in the wishlist application. The directory structure is /htdocs /wishlist /app /config .... /lighthouse /app /config .... I have edited the core.php file for both the application. I am using the same session cookie name and the same security sale but i am not able to get the session on the wishlist application. Can some one let me know how can i share session in between my two application.

• Updating the icons in an ObjectListView

- by Eric
I'm using an TreeListView (a sub type of ObjectListView) in my current project. Each item in the list is given an icon, but the icon my vary depending on the state of the item. For example if the item is readonly I want to use an icon with a little lock symbol. When the items are first added to the TreeListView the icons are show correctly, yet later when the state of an item changes the icons are not updating. How do I force the control to regenerate all the icons?

• "first time here?" message with django

- by panchicore
Hi, Im writing an app that will display the register view depending if is first time visitor. What and How is the better way to do this with Django? thxs.

• VB.NET - 'Title' is not a member of 'Calendar.Appointment'

- by Daniel
I am having a problem with my code. I am using VB.NET and Visual Studio 2010 to write my program. The source of the control that I am using can be found here. First, I imported the Calendar.DayView.dll file into my toolbox to use as a control. Then I added the following code to my existing code: Private Sub DayView1_NewAppointment(ByVal sender As System.Object, ByVal args As Calendar.NewAppointmentEventArgs) Dim appointment As New Calendar.Appointment() appointment.StartDate = args.StartDate appointment.EndDate = args.EndDate appointment.Title = args.Title appointments.Add(appointment) End Sub I get this error 'Title' is not a member of 'Calendar.Appointment'. I have no access to the Calendar namespace or the Appointment class. I am able to view the properties of both in the Object Browser but I can't edit any of them. Any suggestions?

• Smooth text animation (Marquee) using WPF

- by Goran
Trying to build a marquee control with smooth text animation. Current efforts include: Using translate transform Using animation on Canvas dependency properties (Left, Right) Using animation on custom dependency property (Point) and using drawing visuals (formattedtext) Using CompositionTarget.Rendering But the animation is still choppy and resource intensive. Checklist: Confirmed no software rendering is taking place (ms performance tool and checking RenderCapability.Tier) Calling freeze on any imaginable object Running app on dual core machine with decent graphic card (NVidia 9600) Disabled any bitmap effect and transparency Checked all marquee controls out there (same issues) Any ideas (or better yet code example)?

• AJAX: how to get progress feedback in web apps, and to avoid timeouts on long requests?

- by David Dombrowsky
This is a general design question about how to make a web application that will receive a large amount of uploaded data, process it, and return a result, all without the dreaded spinning beach-ball for 5 minutes or a possible HTTP timeout. Here's the requirements: make a web form where you can upload a CSV file containing a list of URLs when the user clicks "submit", the server fetches the file, and checks each URL to see if its alive, and what the title tag of the page is. the result is a downloadable CSV file containing the URL, and the result HTTP code the input CSV can be very large ( 100000 rows), so the fetch process might take 5-30 minutes. My solution so far is to have a spinning javascript loop on the client site, which queries the server every second to determine the overall progress of the job. This seems kludgy to me, and I'm hesitant to accept this as the best solution. I'm using perl, template toolkit, and jquery, but any solution using any web technology would be acceptable.

• dll's loaded through reflection - Phantom Bug

- by Seattle Leonard
Ok, I got a strange one here and I want to know if any of you have ever run accross anything like it. So I've got this web app that loads up a bunch of dll's through reflection. Basically it looks for Types that are derived from certain abstract types and adds them to the list of things it can make. Here's the weird part. While developing there is never a problem. When installing it, there is never a problem to start with. Then, at a seemingly random time, the application breaks while trying to find all the types. I've had 2 sites sitting side by side and one worked while the other did not, and they were configured exactly(and I mean exactly) the same. IISRESET's never helped, but this did: I simply moved all the dll's out of the bin directory then moved them back. That's right I just moved them out of the bin directory then put them right back where they came from and everything worked fine. Any ideas? Got some more info When the site is working I notice this behavior: After IISRESET it still works, but recycling the app pool will cause it to break. When the site is broken: Neiter IISRESET nor recycling the app pool fixes it, but moving a single dll out then back in fixes it.

• Dynamic Data Associate Related Table Value?

- by davemackey
I have create a LINQ-to-SQL project in Visual Studio 2010 using Dynamic Data. In this project I have two tables. One is called phones_extension and the other phones_ten. The list of columns in phones_extension looks like this: id, extension, prefix, did_flag, len, ten_id, restriction_class_id, sfc_id, name_display, building_id, floor, room, phone_id, department_id In phones_ten it looks like this: id, name, pbxid Now, I'd like to be able to somehow make it so that there is an association (or inheritance?) that essentially results in me being able to make a query like phones_extension.ten and it gives me the result of phones_ten.name. Right now I have to get phones_extension.ten_id and then match that against phones_ten.id - I'm trying to get the DBML to handle this translation automatically. Is this possible?

• MYSQL: Display Skipped records after LOAD DATA INFILE?

- by Nate Murray
In MySQL I've used LOAD DATA LOCAL INFILE which works fine. At the end I get a message like: Records: 460377 Deleted: 0 Skipped: 145280 Warnings: 0 How can I view the line number of the records that were skipped? SHOW warnings doesn't work: mysql> show warnings; Empty set (0.00 sec)