instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
So I made some timers for a quiz. The thing is, I just realized when I put javascript: alert("blah"); in the address, the popup alert box pauses my timer. Which is very unwanted in a quiz. I don't think there is any way to stop this behaviour... but I'll ask anyway. If there is not, mind suggesting what should I do?
stackexchange/codereview
I was always wondering if there is operator for deleting multi dimensional arrays in the standard C++ language. If we have created a pointer to a single dimensional array int *array = new int[size]; the delete looks like: delete [] array; That's great. But if we have two dimension array, we can not do delete [][] two...
stackexchange/codereview
I have an ellipse centered at (0,0) and the bounding rectangle is x = [-5,5], y = [-6,6]. The ellipse intersects the rectangle at (-5,3),(-2.5,6),(2.5,-6),and (5,-3) I know nothing else about the ellipse, but the only thing I need to know is what angle the major axis is rotated at. seems like the answer must be really ...
stackexchange/codereview
I am using trigger_error to "throw" errors in a custom class. My problem is that trigger_error prints out the line number where trigger_error was called. For example, given the following code: 01 <?php 02 class Test { 03 function doAction() { 04 $this->doSubAction(); 05 } ...
stackexchange/codereview
I'm adding repeating events to a Cocoa app I'm working on. I have repeat every day and week fine because I can define these mathematically (3600*24*7 = 1 week). I use the following code to modify the date: [NSDate dateWithTimeIntervalSinceNow:(3600*24*7*(weeks))] I know how many months have passed since the event was ...
stackexchange/codereview
I read an interesting DailyWTF post today, "Out of All The Possible Answers..." and it interested me enough to dig up the original forum post where it was submitted. This got me thinking how I would solve this interesting problem - the original question is posed on Project Euler as: 2520 is the smallest number that c...
stackexchange/codereview
I have a ArrayList made up of different elements imported from a db, made up of strings, numbers, doubles and ints. Is there a way to use a reflection type technique to find out what each type of data each element holds? FYI: The reason that there is so many types of data is that this is a piece of java code being wr...
stackexchange/codereview
What is the best way to secure the use/loading of a DLL with a license file?
stackexchange/codereview
I'm trying to enter a little bit of HTML into an ASP.NET Dynamic Data MultilineText_Edit control, just a couple of <br> tags to have line breaks when I output the value of the column on a web page. However, when I try to click the "Update" link on the Dynamic Data edit page, nothing happens. I don't even get an erro...
stackexchange/codereview
Is there any good tool or tool-chain that allows UML images in the .svg format to be created from a textual source file? The reason for this question is that I want to automate the generation of these images to avoid having to manually create and update this set of images.
stackexchange/codereview
My IDE crashes any time I try add a new component to the toolbar. I've already tried Resetting the toolbar. Where does the the information about the toolbar exist on the filesystem to see what may be the offending control?
stackexchange/codereview
We have developed a software system using ActiveX/COM (VB6) technology from microsoft. In the last year, i get more and more interested in automated build processes and SCM at a whole. I intensively searched big parts of the web for information about best practices how to do scm with COM based software systems. The "pr...
stackexchange/codereview
I've got a client that, during testing, is giving me conflicting information. I don't think they are lying but more confused. So, I would like to setup some simple auditing in my ASP.Net application. Specifically, right when any page is called, I want to immediately insert the Querystring and/or form POST data into ...
stackexchange/codereview
Has anyone got to some good code to zoom into an image using javascript? I know I could just resize it etc but was being lazy and looking for something clever to zoom to different levels, move around when zoomed etc
stackexchange/codereview
I want to define a CSS class that will provide the same style as HTML's <pre> element. I tried this: .mystyle { display: block; font-family: monospace; white-space: pre; } which works fine on FF but not on IE (white-spaces are not kept). Does anyone have a clue?
stackexchange/codereview
At the moment a default entry looks something like this: Oct 12, 2008 9:45:18 AM myClassInfoHere INFO: MyLogMessageHere How do I get it to do this? Oct 12, 2008 9:45:18 AM myClassInfoHere - INFO: MyLogMessageHere Clarification I'm using java.util.logging
stackexchange/codereview
I want to get a System.Type given only the type name in a string. For instance, if I have an object: MyClass abc = new MyClass(); I can then say: System.Type type = abc.GetType(); But what if all I have is: string className = "MyClass";
stackexchange/codereview
I recall reading somewhere that using references to smart pointers can cause memory corruption. Is this simply because of using the reference of the smart pointer after its been destroyed? Or does the reference counting get messed up? Thanks for clarifying
stackexchange/codereview
I'm using Exchange Web Services to Find, Create, Update, and Delete appointments from the calendars for one or more people. The application would be used by a manager to view employees' vacation time, as well as assign appointments based on availability. In order for this to all work, an authenticated user's credential...
stackexchange/codereview
Say I've got two scheduled processes: A and B. Given that B should not run until A has completed, how might I gracefully enforce this dependency? Approaches that have been considered: Have A schedule B upon completion. This has the downside of B never being scheduled if for some reason A failed. When B runs, have it p...
stackexchange/codereview
I downloaded Squeak, the Image file, and the Sources file, but I can't figure out how to write Smalltalk code. Is there something obvious I'm missing? Is Squeak even the right IDE for serious Smalltalk development?
stackexchange/codereview
Our team has a task system where we post small incremental tasks assigned to each developer. Each task is developed in its own branch, and then each branch is tested before being merged to the trunk. My question is: Once the task is done, who should define the test cases that should be done on this task? Ideally I th...
stackexchange/codereview
I am learning and using Emacs. What I found annoying is that Ctrl-Space input will be stolen by Windows XP to switch the language bar instead of setting the mark in Emacs. The "language bar" is the native input languages selection such as Chinese keyboard other than English keyboard. Is there a way to temporarily pr...
stackexchange/codereview
I wrote the wrong thing in a commit message. How can I change the message? The commit has not been pushed yet.
stackexchange/codereview
This is kind of a weird problem, but I have to create a search box for our site that will be iframed on another site. When the user clicks the search button, it needs to redirect the parent frame to our search results page. At the moment what I've done is to make the search button a postback trigger then registering a...
stackexchange/codereview
In the past I've done web application development using Visual Studio. Initially I'd use the design view, editing the page visually. But over time I learned more and more (X)HTML, CSS, and Javascript. I became familiar with the tags for ASP.NET server controls and their common attributes. I got to the point where I'd d...
stackexchange/codereview
I have a some JPA entities that inherit from one another and uses discriminator to determine what class to be created (untested as of yet). @Entity(name="switches") @DiscriminatorColumn(name="type") @DiscriminatorValue(value="500") public class DmsSwitch extends Switch implements Serializable {} @MappedSuperclass publ...
stackexchange/codereview
Usually pagination queries look like this. Is there a better way instead of making two almost equal methods, one of which executing "select *..." and the other one "count *..."? public List<Cat> findCats(String name, int offset, int limit) { Query q = session.createQuery("from Cat where name=:name"); q.setStr...
stackexchange/codereview
I want to write a query like this: SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order o But this isn't how the MAX function works, right? It is an aggregate function so it expects a single parameter and then returns the MAX of all rows. Does anyone know how to do it my way?
stackexchange/codereview
I've got a VS2008 deployment project that builds an installer for a couple of Windows services. Each service references several different projects: CustomerName.MailSendingService -> CustomerName.Network -> CustomerName.Data -> CustomerName.Security CustomerName.ProductIntegrationService -> CustomerName.Core -> ...
stackexchange/codereview
I installed Tomcat 6.0.18 on a windows server 2003 box and it will not start as a service. I'm running it with jdk 1.6.0_07. It runs when I start it with tomcat6.exe. I got a vague error in the System Event Log on Windows. The Apache Tomcat 6 service terminated with service-specific error 0 (0x0).
stackexchange/codereview
I'm using Lucene.Net in an ASP.NET application on a shared host. Got this stack trace shown below. What's the work around? [SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] ...
stackexchange/codereview
I'm currently developing a website and my client wants the text of various articles to overflow into two columns. Kind of like in a newspaper? So it would look like: Today in Wales, someone actually Nobody was harmed in did something interesting. the incident, although one Authorities are baffled by th...
stackexchange/codereview
I'm at my wit's end here. I'm trying to use an auto-complete extender from the asp.net ajax extensions toolkit, which is filled from a bog-standard webservice. The application is a .net 3.5 web site, hosting the webservice in a subdirectory (real, not virtual). Whenever I try to post to the webservice I get the followi...
stackexchange/codereview
I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in the interpreter: class Foo(object): _var = ...
stackexchange/codereview
We have a RTE editor based on htmlarea which consists of content with editmode enabled inside an iframe. The question is how to automatically bring the focus into the editor?
stackexchange/codereview
I want to put a Canvas with an image in my window, and then I want to pack widgets on top of it, so the Canvas acts as a background. Is it possible to have two states for the pack manager: one for one set of widgets and another for another set?
stackexchange/codereview
It seems redundant to have zlib compress a web page during every request. It is also the bottleneck of my files' response times. Is there a way to cache the zlib'd file so that it is compressed only once at each modification? Or should I just keep wishing?
stackexchange/codereview
I have a curious question about efficiency. Say I have a field on a database that is just a numeric digit that represents something else. Like, a value of 1 means the term is 30 days. Would it be better (more efficient) to code a SELECT statement like this... SELECT CASE TermId WHEN 1 THEN '30 days' ...
stackexchange/codereview
When writing a batch file to automate something on a Windows box, I've needed to pause its execution for several seconds (usually in a test/wait loop, waiting for a process to start). At the time, the best solution I could find uses ping (I kid you not) to achieve the desired effect. I've found a better write-up of it ...
stackexchange/codereview
In mysql, how do I get the primary key used for an insert operation, when it is autoincrementing. Basically, i want the new autoincremented value to be returned when the statement completes. Thanks!
stackexchange/codereview
When developing a module (device driver, middleware, etc...) that will run in the kernel space, we would like to have some way to capture the reason an operation might fail. In VxWorks, The errno mechanism seems to be a good way to do this. Is it possible to define my own errno values?
stackexchange/codereview
I'm trying to get the contents of a XML document element, but the element has a colon in it's name. This line works for every element but the ones with a colon in the name: $(this).find("geo:lat").text(); I assume that the colon needs escaping. How do I fix this?
stackexchange/codereview
The following simple "calculator expression" grammar (BNF) can be easily parsed with the a trivial recursive-descent parser, which is predictive LL(1): <expr> := <term> + <term> | <term> - <term> | <term> <term> := <factor> * <factor> <factor> / <factor> ...
stackexchange/codereview
I need help please. No clue in xml & WebtextEdit, I am editing an xslt stylesheet that creates asp controls. Below is the WebTextEdit control, I want to add an mousemove event: <xsl:element name="igtxt:WebTextEdit"> <xsl:attribute name='id'><xsl:value-of select='$Name' /></xsl:attribute> <xsl:attri...
stackexchange/codereview
I have an Apache 2 installation on Debian with mod_ssl installed. The server private key is protected by a passphase that needs to be entered on start-up. The error and access logs are subject to logrotate on a weekly basis. I find that Apache crashes with a passphrase-related error shortly after logrotate runs. I u...
stackexchange/codereview
What is the most efficient way to go through and update every single node in a drupal site, to, for instance mechanically add tags? Drupal 6 has a shiny new batch API, but what to do in Drupal 5? I started writing a script that keeps a pointer and then goes around all nodes on a cron, loads them and then saves them, bu...
stackexchange/codereview
Is it possible to initialize an array of pointers to structs? Something like: struct country_t *countries[] = { {"United States of America", "America"}, {"England", "Europe"}, {"Ethiopia", "Africa"} } I want to do that in order to get the entities in not-contiguous memory, and the pointer...
stackexchange/codereview
So most Java resources when speaking of packages mention a com.yourcompany.project setup. However, I do not work for a company, and don't have a website. Are there any naming conventions that are common? An email address, perhaps?
stackexchange/codereview
What is the % code-coverage on your project? I'm curious as to reasons why. Is the dev team happy with it? If not, what stands in the way from increasing it? Stuart Halloway is one whose projects aim for 100% (or else the build breaks!). Is anyone at that level? We are at a painful 25% but aspire to 80-90% for new co...
stackexchange/codereview
In a web interface, I've got a text field. When user enters text and accepts with enter, application performs an action. I wanted to test the behavior with Selenium. Unfortunately, invoking 'keypress' with chr(13) insert representation of the character into the field. Is there a way other then submitting the form? I'd ...
stackexchange/codereview
We're using SQL Server 2005 in a project. The users of the system have the ability to search some objects by using 'keywords'. The way we implement this is by creating a full-text catalog for the significant columns in each table that may contain these 'keywords' and then using CONTAINS to search for the keywords the u...
stackexchange/codereview
How to translate MS-SQL Server 2005 stored procedures into Oracle stored procedures? A chart contrasting corresponding features from each environment with each other - would be helpful.
stackexchange/codereview
I'd like to show a div that has a background-color with the height and width set to 100% but no content. Is it possible to do that without putting a &nbsp; inside? Edit: Thanks to Mark Biek for pointing out that empty div with width and height styles shows how I'd expect. My div is in a table cell, where it does not sh...
stackexchange/codereview
I need to find a way to crawl one of our company's web applications and create a static site from it that can be burned to a cd and used by traveling sales people to demo the web site. The back end data store is spread across many, many systems so simply running the site on a VM on the sale person's laptop won't work. ...
stackexchange/codereview
I've been looking into implementing an external activator in SQL Server Express 2005, and I added the queues, services, contracts, and event notifications to the database. I also added a trigger to send a message to the target queue. Everything parses, runs, and the trigger is firing. However, when I select from the ta...
stackexchange/codereview
I need to create an ODBC link from an Access 2003 (Jet) database to a SQL Server hosted view which contains aliased field names containing periods such as: Seq.Group In the SQL source behind the view, the field names are encased in square brackets... SELECT Table._Group AS [Seq.Group] ...so SQL Server doesn't complai...
stackexchange/codereview
Is it possible to make such buttons (http://img225.imageshack.us/img225/6452/buttonslw9.jpg) using CSS? It should be Menu, and PHP would just feed the text to html/css and css should take care of the design. Maybe I want too much out of CSS - especially with that red outline of the text.. ? Any ideas how i can achieve...
stackexchange/codereview
I have 2 classes for accessing the database: MovieDAO - access database using "select" statements only; the purpose is for retrieving data for displaying in the web browser. and MovieExtendedDAO (extends MovieDAO) - which is more complete and allows for creating/updating/deleting a movie in addition to the inherited f...
stackexchange/codereview
Basically, I'm trying to create an object of unique objects, a set. I had the brilliant idea of just using a JavaScript object with objects for the property names. Such as, set[obj] = true; This works, up to a point. It works great with string and numbers, but with other objects, they all seem to "hash" to the same va...
stackexchange/codereview
I'm starting a project which requires reading outlook msg files in c#. I have the specs for compound documents but am having trouble reading them in c#. Any pointers would be greatly appreciated. Thanks.
stackexchange/codereview
I have a web service running, and it uses Spring.NET for it's IoCness. One of the classes needs to do some stuff when it loads (I'm using AfterPropertiesSet) and "some stuff" involves a call to ContextRegistry.GetContext(). The problem is this code in the ContextRegistry class: if (rootContextCurrentlyInCreation) { ...
stackexchange/codereview
Consider a database table holding names, with three rows: Peter Paul Mary Is there an easy way to turn this into a single string of Peter, Paul, Mary?
stackexchange/codereview
I'm looking for some succinct, modern C# code to generate a random date between Jan 1 1995 and the current date. I'm thinking some solution that utilizes Enumerable.Range somehow may make this more succinct.
stackexchange/codereview
I am working on a project that does a large amount of hashing, signing, and both asymmetric and symmetric encryption. Since these steps have a significant effect on our performance and available load, I was wondering if there is a hardware based solution to offloading the work. I have done some surfing to find out, an...
stackexchange/codereview
I am researching the feasibility of setting up a mapping tool for my alliance in an online game. The game is not based in the real world so I am not interested in the content of the map tools available, just the functionality. Minimally, I would like the map to display information about where allied cities are locate...
stackexchange/codereview
I'm wondering if anyone has any experience using log4net in a multi-threaded environment like asp.net. We are currently using log4net and I want to make sure we won't run into any issues.
stackexchange/codereview
I have a DataGrid, with an ItemTemplate that has an image and label. In the EditItemTemplate the label is replaced by a textbox. My problem is that the edit template only shows when I click the Edit button the second time. What gives?
stackexchange/codereview
I want to prevent my script running more than once at a time. My current approach is create a semaphore file containing the pid of the running process read the file, if my process-id is not in it exit (you never know...) at the end of the processing, delete the file In order to prevent the process from hanging, I se...
stackexchange/codereview
If I have an Address class that implements IEditableObject, I might have EndEdit implementation like this: public void EndEdit() { // BeginEdit would have set _editInProgress and save to *Editing fields if (_editInProgress) { _line1 = _line1Editing; _line2 = _line2Editing; _city = _c...
stackexchange/codereview
I have a pretty standard django app, and am wondering how to set the url routing so that I don't have to explicitly map each url to a view. For example, let's say that I have the following views: Project, Links, Profile, Contact. I'd rather not have my urlpatterns look like this: (r'^Project/$', 'mysite.app.views.proj...
stackexchange/codereview
I have a large project that I want to start using visual studio 2005 to edit. I want to tell it "Here are all the files I want you to track, now get on with it" and have them displayed as a directory tree, for example: Folder 1 - File A - File B - File C Folder 2 - Folder 3 - File X - File Y - File D - File...
stackexchange/codereview
I'm running into an odd problem with Visual Studio 2005: I have a data breakpoint that's set to run a macro and continue (that is, I select a macro and check Continue Execution.) Now, instead of silently running the macro when the value in the data breakpoint (tracepoint, really) changes, I first get a message box info...
stackexchange/codereview
I created an app for a small business. Some of the employees in the office can not see the form correctly. The reason is they have their DPI setting set to above 96dpi. Does anybody know of a way to control this? For all of you who have experience with winforms apps, how do you control your form layout so that DPI do...
stackexchange/codereview
Or would a conventional client-server VCS be more appropriate? I'm currently using TortoiseSVN, but I'm interested in a DVCS, but I'm not sure if it's even a good idea to try to use something like that solo.
stackexchange/codereview
Do you know a good and free Hashtable imlementation for Delphi 5 ? I need to organize a huge amount of data in a hastable and I am bit worried about memory leak issues that I found in most available implementations on the web. Tks
stackexchange/codereview
I am writing a tracing tool which needs to deal with the output of a a JIT, so the stack can look pretty bizarre at times. I'd like to try to apply some heuristics to addresses to determine if they are code, data or garbage. (If I'm wrong some of the time, it's no big deal; however if the process crashes, not so much...
stackexchange/codereview
Where do the type/member/parameter descriptions that you see in the Intellisense bubble come from? Are they stored in type attributes? EDIT: I'm specifically interested in the built-in types.
stackexchange/codereview
I have an XmlDocument that already exists and is read from a file. I would like to add a chunk of Xml to a node in the document. Is there a good way to create and add all the nodes without cluttering my code with many .CreateNote and .AppendChild calls? I would like some way of making a string or stringBuilder of a va...
stackexchange/codereview
Is a new (or different) instance of TestCase object is used to run each test method in a JUnit test case? Or one instance is reused for all the tests? public class MyTest extends TestCase { public void testSomething() { ... } public void testSomethingElse() { ... } } While running this test, how many instances of...
stackexchange/codereview
I'm working on a MS Access database. I've made some changes to one of the modules. I want to go out for lunch, but when I try closing the database, I get the following message: "You do not have exclusive access to the database. Your design changes cannot be saved at this time. Do you want to close without saving yo...
stackexchange/codereview
Is there an easy way to create a table in SQL Server (2005) from an Excel spreadsheet. I'm thinking maybe some tool? Thanks in advance.
stackexchange/codereview
The problem is that the compiler says that there is a redefinition of a function between a library that belongs to MySQL and math.h from the std library. I have been over this for two days and I still can't figure it out. Has this ever happened to anyone? This is the output from the compiler C:\mingw\bin\mingw32-mak...
stackexchange/codereview
I've just found out about Stack Overflow and I'm just checking if there are ideas for a constraint I'm having with some friends in a project, though this is more of a theoretical question to which I've been trying to find an answer for some time. I'm not much given into cryptography but if I'm not clear enough I'll try...
stackexchange/codereview
I recently had a need to interpret a DEC 32-bit floating point representation. It differs from the IEEE floating point representations in the number of bits allocated to the exponent and mantissa. Here's a description of a bunch of floating point formats: http://www.quadibloc.com/comp/cp0201.htm I managed to roll my o...
stackexchange/codereview
What's the best way of adding spaces between strings myString = string.Concat("a"," ","b") or myString = string.Concat("a",Chr(9),"b") I am using stringbuilder to build an XML file and looking for something efficient. Thanks Edit ~ Language VB.NET
stackexchange/codereview
Are there any methods/systems that you have in place to incentivize your development team members to write "good" code and add comments to their code? I recognize that "good" is a subjective term and it relates to an earlier question about measuring the maintainability of code as one measurement of good code.
stackexchange/codereview
Seems so basic, I can't believe I don't know this! I just need a scratch folder to dump some temporary files to. I don't care if it gets wiped out between usages or not, and I don't think I should have to go through the hassle of creating one and maintaining it myself from within my application. Is that too much to ask...
stackexchange/codereview
Does a new SessionFactory and Session object have to be created for each database? I have a data store for my application data, and a separate data store for my employee security, which is used to validate users. Do I have to create a new SessionFactory ans Session object for calls to the 2 different databases?
stackexchange/codereview
Ok, this is bit of an obscure question, but hopefully someone can help me out with it. The system I'm working on builds a dynamic SQL string for execution inside a stored procedure, and part of that dynamic SQL defining column aliases, which themselves are actually values retrieved from another table of user generated ...
stackexchange/codereview
When is it better to use a List vs a LinkedList?
stackexchange/codereview
I'm having problems when trying to mock objects with __get and __set methods (using simpletest). Writing mock responses for __get doesn't smell right - the tests seem too tightly tied to implementation. Any recommendations for testing, or should I just avoid the magic methods completely?
stackexchange/codereview
What is the easiest way to find out how much memory an object uses in .NET? Preferably without having to resort to a third party tool. Marshal.SizeOf or the sizeof operator look useful but only work with a restricted range of types. Some related posts: Object Memory Analysis in .NET Does an empty array in .NET use an...
stackexchange/codereview
I got one big question. I got a linq query to put it simply looks like this: from xx in table where xx.uid.ToString().Contains(string[]) select xx The values of the string[] array would be numbers like (1,45,20,10,etc...) the Default for .Contains is .Contains(string). I need it to do this instead: .Contains(string[]...
stackexchange/codereview
I have a serializiable object with listeners registered. Currently the list of listeners is stored in the object as transient. When the object is serialized and then deserialized, obviously the listeners are no longer registered. What would be the safest and best way to go about re-registering the listeners automatical...
stackexchange/codereview
Currently I am developing a site with about seven partial classes, a few icons, three pages and an App_Themes folder. I was interested to know, is there an industry standard directory structure for anything larger than a small project? For example, I want to keep the classes in separate folders, the images in separate ...
stackexchange/codereview
I'd love to figure it out myself but I was wondering roughly what's the algorithm for converting a function with yield statements into a state machine for an enumerator? For example how does C# turn this: IEnumerator<string> strings(IEnumerable<string> args) { IEnumerator<string> enumerator2 = getAnotherEnumerator(); ...
stackexchange/codereview
If I have the following: Public Class Product Public Id As Integer Public Name As String Public AvailableColours As List(Of Colour) Public AvailableSizes As List(Of Size) End Class and I want to get a list of products from the database and display them on a page along with their available sizes and col...
stackexchange/codereview
I'm learning XML, currently of Wikibooks, but that is kinda huge and not oversee-able... anybody know a better place?
stackexchange/codereview
I have a database in ISO-8859-2 format, but I need to create XML in UTF-8. This means that I must encode the database before printing in UTF-8. I know very little about ASP.Net. In PHP I would do something like this: db_connect(); mysql_query("SET NAMES 'UTF8'"); mysql_query("SET character_set_client='UTF8'"); This i...
stackexchange/codereview