instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
Is it possible to define an implicit conversion of enums in c#? something that could achieve this? public enum MyEnum { one = 1, two = 2 } MyEnum number = MyEnum.one; long i = number; If not, why not?
stackexchange/codereview
I am looking for a tool which would create ejb-jar.xml configuration file from annotated EJB3 classes. Something like XDoclet, but for annotations, not tags in comments.
stackexchange/codereview
How do I concatenate two std::vectors?
stackexchange/codereview
I'm running my C++ program in gdb. I'm not real experienced with gdb, but I'm getting messages like: warning: HEAP[test.exe]: warning: Heap block at 064EA560 modified at 064EA569 past requested size of 1 How can I track down where this is happening at? Viewing the memory doesn't give me any clues. Thanks!
stackexchange/codereview
I have the following code that I wrote but it the SQLBindCol does not seem to work correctly (of course I could have screwed up the whole program too!.) The connection works, it creates the table in the DB, addes the record fine and they all look good in SQL Enterprise Manager. So what I need help with is after the c...
stackexchange/codereview
In my independent study of various compiler books and web sites, I am learning about many different ways that a compiler can optimize the code that is being compiled, but I am having trouble figuring out how much of a benefit each optimization will tend to give. How do most compiler writers go about deciding which opti...
stackexchange/codereview
What is the difference between new/delete and malloc/free? Related (duplicate?): In what cases do I use malloc vs new?
stackexchange/codereview
I've been doing "plain old java objects" programming for 10 years now, with Swing and JDBC, and I consider myself pretty good at it. But I start a new job in two weeks where they use JBoss, and I'd like to get a heads up and start learning all this stuff before I start. What are good resources? On-line tutorials, bo...
stackexchange/codereview
So I know that autocommit commits every sql statement, but do updates to the database go directly to the disk or do they remain on cache until flushed? I realize it's dependent on the database implementation. Does auto-commit mean a) every statement is a complete transaction AND it goes straight to disk or b) every...
stackexchange/codereview
I'm running PHP 5.2.6 on a Windows Server 2003 Enterprise box. IIS is set to deny anonymous access and use Integrated Windows authentication. I'm using a PHP script to save a file uploaded from a web form. The file is uploaded to a temp folder, the script creates a file name and path depending on other variables from ...
stackexchange/codereview
What do you insert into Python source code to have it break into pdb (when execution gets to that spot)?
stackexchange/codereview
Sorry, if this is a noobish question, but I'm just getting started with Rails and jQuery. I have the following scenario: I have 3 classes: contacts, companies and contact_company_joins (ccj). For all three classes I created models, controller and views. Obviously, contacts and companies are connected via the join-tab...
stackexchange/codereview
How do I query the iPhone's current IP address?
stackexchange/codereview
I have an ASP .Net (3.5) website. I have the following code that uploads a file as a binary to a SQL Database: Print(" protected void UploadButton_Click(object sender, EventArgs e) { //Get the posted file Stream fileDataStream = FileUpload.PostedFile.InputStream;...
stackexchange/codereview
I'm developing a library for use in other apps and this library has lots of debugging and logging statements thanks to NLog. Is it possible to exclude the reference to NLog.dll when I switch to release mode? Cheers,
stackexchange/codereview
Is there any way to make Visual Studio 2008 Express store all the files as UTF-8 by default? Thanks for your time. Best regards.
stackexchange/codereview
I have taken an image from UIImagePickerController, but the file looks too big to be transferred through internet, I'd like to resize the image. I couldn't find any method related to the image process. Any recommendation?
stackexchange/codereview
In my web app, my parameters can contain all sorts of crazy characters (russian chars, slashes, spaces etc) and can therefor not always be represented as-is in a URL. Sending them on their merry way will work in about 50% of the cases. Some things like spaces are already encoded somewhere (I'm guessing in the Html.Buil...
stackexchange/codereview
Simple question. If you have a compiled and published ASP.NET web application running on a server and you need to update, say, a line in one of the codebehind files. Do you shut down the entire site, republish, then load the site back up? Or do you publish straight to your live site with users still using it?
stackexchange/codereview
Question: Is there an easy way (library function) to perform a bitwise AND or OR on numbers larger than 32-bit in ActionScript? From the docs: "Bitwise operators internally manipulate floating-point numbers to change them into 32-bit integers. The exact operation performed depends on the operator, but all bitwise ope...
stackexchange/codereview
I'm about to start (with fellow programmers) a programming & algorithms club in my high school. The language of choice is C++ - sorry about that, I can't change this. We can assume students have little to no experience in the aforementioned topics. What do you think are the most basic concepts I should focus on? I know...
stackexchange/codereview
Should log classes open/close a log file stream on each write to the log file or should it keep the log file stream open throughout the application's lifetime until all logging is complete? I'm asking in context of a desktop application. I have seen people do it both ways and was wondering which approach yields the ...
stackexchange/codereview
I'm trying to create a use-once HTTP server to handle a single callback and need help with finding a free TCP port in Ruby. This is the skeleton of what I'm doing: require 'socket' t = STDIN.read port = 8081 while s = TCPServer.new('127.0.0.1', port).accept puts s.gets s.print "HTTP/1.1 200/OK\rContent-type: text/p...
stackexchange/codereview
I was looking into embedding custom version strings using in assemblies a while back, and one approach that the documentation suggested was to embed a windows resource. The only way I can see to create a windows resource is to use the 'Native Resource Template', but the template is a binary file that isn't suitable for...
stackexchange/codereview
How would I set an image to come from a theme directory (my theme changes so I don't want to directly reference) I am sure this is possible but every example I find doesn't seem to work. They are usually along the lines of: asp:image ID="Image1" runat="server" ImageUrl="~/Web/Mode1.jpg" / where Web would be a sub direc...
stackexchange/codereview
Microsoft has come out with this fairly new technology that I am considering using for a .NET 3.5 application. I am curious, is anyone using this technology already? I am worried that the use of the secure virtual machine will negatively affect performance. Also, the way Microsoft advertises the product, it seems as...
stackexchange/codereview
I am trying to create a StringNameSpaceBinding using the wsadmin tool of Websphere 6.1 Here are the steps i take set cell [$AdminConfig getid /Cell:cell/] $AdminConfig create StringNameSpaceBinding $cell { {name bindname} {nameInNameSpace Bindings/string} {stringToBind "This is the String value that gets bound"} } But...
stackexchange/codereview
We have similar code to the following in one of our projects. Can anyone explain (in simple English) why the fixed statement is needed here? class TestClass { int iMyVariable; static void Main() { TestClass oTestClass = new TestClass(); unsafe { fixed (int* p = &oTestClas...
stackexchange/codereview
We have sales reps who access our 'system' via terminal services. In our system we would like to enable clicking the number of a client and launching skype on their local machine not in the terminal services session. We see two potential ways of this working... Clicking on a URL ( eg skype:01234569?call ) and it work...
stackexchange/codereview
We have several workflows, all are default Sharepoint workflows - approval / feedback etc. Once all actions have been completed (and marked as so), the status of the document workflow remains "In Progress". I have found several mentions of this on the web - but no solutions. Any assistance will be extremely helpful -...
stackexchange/codereview
I have a TreeView bound to an XmlDataProvider. The name of a node is reflected in the tree and the data of the node is in a TextBox. When you click on a tree item, it loads the data in the TextBox. What is the best way to determine when a user has changed the source data referenced by the XmlDataProvider. I would lik...
stackexchange/codereview
Here is my short implementation of Russian Peasant Multiplication. How can it be improved? Restrictions : only works when a>0,b>0 for(p=0;p+=(a&1)*b,a!=1;a>>=1,b<<=1);
stackexchange/codereview
We have a website, where transactions are entered in and put through a workflow. We are going to follow the standard BLL(Business Logic Layer), DTO(Data Transfer Object), DAL(Data Access Layer) etc. for a tiered application. We have the need to separate everything out because some transactions will cross multiple appli...
stackexchange/codereview
I'm looking for a LHarc de/compressing library, with source if possible.
stackexchange/codereview
What are some good solutions for handling automatic web based software updates for windows forms projects? I am aware of microsoft one-click, but am not interested in it at this time.
stackexchange/codereview
The title may not really explain what I'm really trying to get at, couldn't really think of a way to describe what I mean. I was wondering if it is good practice to check the arguments that a function accepts for nulls or empty before using them. I have this function which just wraps some hash creation like so. Public ...
stackexchange/codereview
How can I make xargs execute the command exactly once for each line of input given? It's default behavior is to chunk the lines and execute the command once, passing multiple lines to each instance. From http://en.wikipedia.org/wiki/Xargs: find /path -type f -print0 | xargs -0 rm In this example, find feeds the inpu...
stackexchange/codereview
I have to concatenate a bunch of Strings in Javascript and am searching for the fastest way to do so. Let's assume that the Javascript has to create a large XML-"file" that, naturally, consists of many small Strings. So I came up with: var sbuffer = []; for (var idx=0; idx<10000; idx=idx+1) { sbuffer.pu...
stackexchange/codereview
What is their use if when you call the method, it might not exist? Does that mean that you would be able to dynamically create a method on a dynamic object? What are the practical use of this?
stackexchange/codereview
I'm working on keyboard input for a very basic kernel that I'm developing and I'm completely stuck. I can't seem to find any information online that can show me the information I need to know. My kernel is running in protected mode right now, so I can't use the real mode keyboard routines without jumping into real mode...
stackexchange/codereview
Is there any way to remove the dotted line rectangle, which indicates the keyboard focus, on a Win32 common control, without owner draw or subclass them? It seems that under WPF one can control the visual style of the focus rectangle, but I failed to find corresponding API on a Win32 common control.
stackexchange/codereview
I have some cross platform DNS client code that I use for doing end to end SMTP and on windows I can find the current DNS server ip addresses by looking in the registry. On the Mac I can probably use the SystemConfiguration framework as mentioned in the first answer, however the exact method of doing so is not immediat...
stackexchange/codereview
I am having a problem getting a list of fields from a query defined at run time by the users of my program. I let my users enter a SQL query into a memo control and then I want to let them go through the fields that will return and do such things as format the output, sum column values and so forth. So, I have to get...
stackexchange/codereview
I have a main window (#1) on my webpage from which I open a new browser window (#2) from which I open a new window (#3). Now if my user closes window#2 before window#3, I have the problem that window#3 no longer can call function in its window.opener since it has gone away. What I would like to do is to set window#3.op...
stackexchange/codereview
I want to read line n1->n2 from file foo.c into the current buffer. I tried: 147,227r /path/to/foo/foo.c But I get: "E16: Invalid range", though I am certain that foo.c contains more than 1000 lines.
stackexchange/codereview
For my apps, I store some configuration file in xml along with the assembly(exe), and something other temporary files for proccessing purpose. I found some quirk with ".\\" and Application.StartupPath. I've been using String configPath = ".\\config.xml"; It works fine until I called OpenFIleDialog to open some file...
stackexchange/codereview
I have a CMFCRibbonStatusBar in my mainframe to which I add a CMFCRibbonButtonsGroup which again has a CMFCRibbonButton. This button has the same ID as a menu entry. Creating the button is done as follows: CMFCRibbonButtonsGroup* pBGroup = new CMFCRibbonButtonsGroup(); CMFCToolBarImages images; images.SetImageSize(CSi...
stackexchange/codereview
I am developing an iPhone application, in my table view I wanted custom color for Cell Selection Style, I read the UITableViewCell Class Reference but there are only three constants defined for Selection style (Blue, Gray, None). I saw one application that used a different color than those defined in the reference. How...
stackexchange/codereview
if i decide to use the 'publish' option for my ASP.NET website, instead of a Web Deployment Project, can i do custom msbuild things? Or do i need to stick with WDP's if i want to do custom msbuild stuff during compile/deployment.
stackexchange/codereview
I'm trying to use NAnt/NAntContrib build script to build a web application on Windows 2008 (IIS 7.0). In the build file, there is mkiisdir task, which fails with: [mkiisdir] The webservice at 'localhost' does not exist or is not reachable. All the documents/posts I found so far (non for w2k8, only Vista) say to install...
stackexchange/codereview
How have you explained nested arrays to a programmer. I'm thinking someone that has an entry level understanding of programming, but is trying to do more complicated coding. The array with array works, but they can't quite get their mind around the idea. Edit: example of a nested array: array( 'array1' => array( ...
stackexchange/codereview
The 3-argument form of list::splice() moves a single element from one list to the other. SGI's documentation explicitly states that all iterators, including the one pointing to the element being moved remain valid. Roguewave's documentation does not say anything about iterator invalidation properties of splice() meth...
stackexchange/codereview
Is it best practice to not use C:\Inetpub\wwwroot\wss\ for SharePoint? My concern is that the configuration wizard seems to look for this C: path and it may be too complicated to not use the default path(s),
stackexchange/codereview
So for this one project, we have a bunch of queries that are executed on a regular basis (every minute or so. I used the "Analyze Query in Database Engine " to check on them. They are pretty simple: select * from tablex where processed='0' There is an index on processed, and each query should return <1000 rows on a ta...
stackexchange/codereview
I have a website in which I provide tool-tips for certain things using a hidden <span> tag and JavaScript to track various mouse events. It works excellently. This site somewhat caters towards people with vision issues, so I try to make things degrade as well as possible if there is no JavaScript or CSS and generally I...
stackexchange/codereview
I would like create my own collection that has all the attributes of python list and also knows how to save/load itself into/from a database. Also I want to make the load implicit and lazy, as in it doesn't happen at the point of creation of the list, but waits until its first used. Is there a single__xxx__method I ca...
stackexchange/codereview
Java process control is notoriously bad - primarily due to inadequate support by the Java VM/JDK classes (e.g. java.lang.Process). I am wondering, are there any good open source libraries out there that are reliable. The requirements would be: OSS Start/Stop processes Manage STDIN and STDOUT cross platform (at least L...
stackexchange/codereview
My automated deployment system updates a latest version of my site trough subversion. Instead of having my live site point to the trunk (which is always almost a work in progress version), I have my live site point to a tag. E.g. I work on trunk and when my v1.0 is finished I create a tag called 1.0 and do a checkout o...
stackexchange/codereview
struct elem { int i; char k; }; elem user; // compile error! struct elem user; // this is correct In the above piece of code we are getting an error for the first declaration. But this error doesn't occur with a C++ compiler. In C++ we don't need to use the keyword struct again and again. So why doesn't anyone upda...
stackexchange/codereview
Example. 123456, and we want the third from the right ('4') out. The idea in practise is to access each digit seperately (ie. 6 5 4 3 2 1). C/C++/C# preferred.
stackexchange/codereview
Markdown is a great tool for formatting plain text into pretty html, but it doesn't turn plain-text links into URLs automatically. Like this one: http://www.google.com/ How do I get markdown to add tags to URLs when I format a block of text?
stackexchange/codereview
I have a problem with the FreeTextBox rich Text Editor in my ASP.NET site. The problem occurs when I access the site with firefox, and I have a freetextbox instance in a hidden div. The hidden div might also be an AJAX Tab Panel. The actual problem is that when the page loads it throws an uncaught exception (firebug sh...
stackexchange/codereview
I was looking at the Java code for LinkedList and noticed that it made use of a static nested class, Entry. public class LinkedList<E> ... { ... private static class Entry<E> { ... } } What is the reason for using a static nested class, rather than an normal inner class? The only reason I could think of, was that E...
stackexchange/codereview
I'm trying to bind a datasource to a repeater, for instance, to a web service (.asmx from a different website) on page load. The webservice returns a DataSet from an sql call. What is the best way to go about doing this?
stackexchange/codereview
I know how to capture a camera snaphot on Windows Mobile 5.0/6 using SHCameraCapture. But is there something more extensive that allows me much finer control? Namely to get available zoom levels and to set the zoom level programmatically, also e.g. different ISO modes / lightsensitivity and setting of macro mode if ava...
stackexchange/codereview
i want to be a good developer citizen, pay my taxes, and disable things if we're running over Remote Desktop, or running on battery. If we're running over remote desktop (or equivalently in a Terminal server session), we must disable animations and double-buffering. You can check this with: /// <summary> /// Indicates ...
stackexchange/codereview
I want to display an image within a scroll area. The view port of the scroll area shall have a defined initial size. That means, if the image's size is bigger than the initial size of the view port, scroll bars will be visible, otherwise not. // create label for displaying an image QImage image( ":/test.png" ); QLabel ...
stackexchange/codereview
I want to create a subclass of TabPage that contains some control, and I want to control the layout and properties of those controls through the designer. However, if I open my subclass in the designer, I can't position them like I could on a UserControl. I don't want to have to create a TabPage with an UserControl i...
stackexchange/codereview
My company has a large application written in VB6, and for historical reasons, the application is navigated with the Enter key instead of with the Tab key. I don't know VB6, but I know that they currently set the focus for each control in a big select statement in the Form's KeyUp event if it's an EnterKey. Now we ar...
stackexchange/codereview
So I'm trying to figure out how the Form's AutoScaleMode property can possibly help to support a system with a font or DPI that is different from my work development machine. From the SDK: AutoScaleMode Enumeration public enum AutoScaleMode None Automatic scaling is disabled. Font Controls scale relativ...
stackexchange/codereview
For example if I have an auto-numbered field, I add new records without specifying this field and let DB engine to pick it for me. So, will it pick the number of the deleted record? If yes, when? // SQL Server, MySQL. // Follow-up question: What happens when DB engine runs out of numbers to use for primary keys?
stackexchange/codereview
I'm trying to determine what kinds of interactions a mobile website can handle. For example, I obviously can't track page-level dragging operations because this scrolls on mobile browsers. So, I'm looking for demos that can tell me what interactions work, how well, and hopefully for information about how consistently t...
stackexchange/codereview
The AppKit release notes for Leopard say: In many applications it is not appropriate to present page setup panels to the user, or even include a Page Setup... item in the File menu, but there has been no other easy way to let the user specify page setup parameters to be used when printing. (New UI advice...
stackexchange/codereview
I have been reading the post here: http://encosia.com/2008/10/04/using-jquery-to-enhance-aspnet-ajax-progress-indication/ But it wants to use the following object: Sys.WebForms.PageRequestManager.getInstance() Which doesn't exist when using the MVC AJAX code. Has anyone tried to hook when the postback ends from MVC A...
stackexchange/codereview
I have been asked to provide information on available techniques for assessing our current, and any future websites for security problems. the request is in the form of Do you know of any good free one that examines for security holes? I think our data security is probably worth a small amount of upfront spend so any...
stackexchange/codereview
I have a line (actually a cube) going from (x1,y1,z1) to (x2,y2,z2). I would like to rotate it so that it is aligned along another line going from (x3,y3,z3) to (x4,y4,z4). Presently I am using Math::Atan2 along with Matrix::RotateYawPitchRoll. Any better ways to do this? Edit: I think I've worded this post very badly....
stackexchange/codereview
I have the following code which works just fine when the method is "POST", but changing to "GET" doesn't work: HttpWebRequest request = null; request = HttpWebRequest.Create(uri) as HttpWebRequest; request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; request.Method = "POST"; // Doesn't work with "G...
stackexchange/codereview
I'd like to pass parameters on the command line to my C++ program in the following manner: ./myprog --setting=value Are there any libraries which will help me to do this easily?
stackexchange/codereview
I have a webpp which works fine when under a light load. However, when we run a lot of threads each with their own database connection, then we start getting the error ORA-12519: TNS:no appropriate service handler found After looking online I found that running lsnrctl services was a good diagnostic step, so I did th...
stackexchange/codereview
template <class T> bool BST<T>::search(const T& x, int& len) const { return search(BT<T>::root, x); } template <class T> bool BST<T>::search(struct Node<T>*& root, const T& x) { if (root == NULL) return false; else { if (root->data == x) return true; else if(root-...
stackexchange/codereview
I've written some custom model binders (implementing IModelBinder) in our ASP.NET MVC application. I'm wondering what is a good approach to unittest them (binders)?
stackexchange/codereview
I've recently started using code coverage tools (particularily Emma and EclEmma), and I really like the view that it gives me as to the completeness of my unit tests - and the ability to see what areas of the code my unit tests aren't hitting at all. I currently work in an organization that doesn't do a lot of unit tes...
stackexchange/codereview
I am only one person working on project - so I am developer without PM above me. I finished portal, hovewer client from time to time attacks me with request such as "make font bigger" or change margin in css or make button which makes "xxx and yyy". There are simple task, sometimes only for few clicks, but it takes my...
stackexchange/codereview
In Netbeans 6.5, I've got two different C++ application projects - my application and the unit tests. I want to set it up so that if my main application is rebuilt, the unit tests are rebuilt as well (and vice versa). Netbeans is good at resolving the dependencies for library projects, and rebuilding them if necessary...
stackexchange/codereview
I'm working on moving from using tables for layout purposes to using divs (yes, yes the great debate). I've got 3 divs, a header, content and footer. The header and footer are 50px each. How do I get the footer div to stay at the bottom of the page, and the content div to fill the space in between? I don't want to ...
stackexchange/codereview
I am using ASP.NET to transmit a .jar file. This code works perfectly on IE. However on Firefox the file downloads, corrupt. What is the best way to fix it? Below is the code I am using. private void TransferFile() { try { string filePath = Server.MapPath("SomeJarFIle.jar"); FileInfo file =...
stackexchange/codereview
I need to implement an OpenID Provider in .Net and wondered....Is there's any OpenSource code already written and available?
stackexchange/codereview
We have a software product that evolves at the rhythm of clients' needs and of a more general roadmap. Because we are in a SCRUM project environment, it happens very regurlarly that a new feature makes its way to the product, and then we are confronted with the choice of: implementing this feature in an already releas...
stackexchange/codereview
I'm trying to export a Crystal Report to an HTML file, but when I call the Export method, I immediately get this error: Source: Crystal Reports ActiveX Designer Description: Failed to export the report. I have tried both crEFTHTML40 and crEFTHTML32Standard as export format types - and both result in the same error. ...
stackexchange/codereview
I'm writing an application using Qt4. I need to download a very short text file from a given http address. The file is short and is needed for my app to be able to continue, so I would like to make sure the download is blocking (or will timeout after a few seconds if the file in not found/not available). I wanted to us...
stackexchange/codereview
JsUnit provides an ant-script with the target 'standalone_test'. This target uses the property url to identify the HTML-site, that executes the tests. These site is checked in, so that everyone should be able after a checkout to execute this tests. This works, but the url-proprty must be set to an absolute path, like f...
stackexchange/codereview
How do you create a simple, custom rule using the jQuery Validate plugin (using addMethod) that doesn't use a regex? For example, what function would create a rule that validates only if at least one of a group of checkboxes is checked?
stackexchange/codereview
What's the simplest way to convert a Unicode codepoint into a UTF-8 byte sequence in C? The only way that springs to mind is using iconv to map from the UTF-32LE codepage to UTF-8, but that seems like overkill.
stackexchange/codereview
I want to filter the selectable dates on a datepicker. I basically need to filter by work days - i.e. make holidays and weekends not selectable. I know you can specify dates using a function in the beforeShowDate: and you can also use $.datepicker.noWeekends. Question is: can you do both?
stackexchange/codereview
I'm displaying a series of images in a UIScrollView. I pretty much want to replicate the Photos application. My current architecture is: A parent UIScrollView with content size that is wide enough for x number of pages + some extra space for margins in between the images. Each image is contained in a UIImageView. Ea...
stackexchange/codereview
Does it mean that two threads can't change the underlying data simultaneously? Or does it mean that the given code segment will run with predictable results when multiple threads are executing that code segment?
stackexchange/codereview
There are truckloads of counters available in perfmon for ASP.NET. What are the best (I am thinking of choosing 5-10) that will be the best to monitor in our test environment so that we can feed back to developers. I am thinking of things like request time, request queue length, active sessions etc.
stackexchange/codereview
Ok, I am reading in dat files into a byte array. For some reason, the people who generate these files put about a half meg's worth of useless null bytes at the end of the file. Anybody know a quick way to trim these off the end? First thought was to start at the end of the array and iterate backwards until I found so...
stackexchange/codereview
I need to make an Ajax call inside OFBiz framework using prototype.js. I am doing that from a .ftl file. I am confused about how to handle the server side - through Java event or Java service? What is the best practice? And also I am having problems making the framework recognize the prototype.js file. There is some is...
stackexchange/codereview
My database consists of 3 tables (one for storing all items, one for the tags, and one for the relation between the two): Table: Post Columns: PostID, Name, Desc Table: Tag Columns: TagID, Name Table: PostTag Columns: PostID, TagID What is the best way to save a space separated string (e.g. "smart funny wonderful") int...
stackexchange/codereview