instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
I'm using Enunciate to build a prototype REST api and need to include a jar containing custom code as a library. My Ant Script looks like this: <!--include all jars--> <path id="en.classpath"> <fileset dir="${lib}"> <include name="**/*.jar" /> </fileset> </path> <!--define the task--> <taskdef name="e...
stackexchange/codereview
I have an array of a few million numbers. double* const data = new double (3600000); I need to iterate through the array and find the range (the largest value in the array minus the smallest value). However, there is a catch. I only want to find the range where the smallest and largest values are within 1,000 samples ...
stackexchange/codereview
Is it possible to find out who called a stored procedure? For example, say I get an error in proc3. From within that proc I want to know if it was called by proc1 or proc2.
stackexchange/codereview
In SQL, how do update a table, setting a column to a different value for each row? I want to update some rows in a PostgreSQL database, setting one column to a number from a sequence, where that column has a unique constraint. I hoped that I could just use: update person set unique_number = (select nextval('number_sequ...
stackexchange/codereview
I'm working on a billing system for a utility company, and we have the following requirements: Batch-generate and print approximately 1,500 bills per day that we then mail to customers Save the bill in a format that can emailed to the customer and also archived (probably PDF) Built with .NET with MS SQL Server databas...
stackexchange/codereview
We log values and we only log them once in a table. When we add values to the table we have to do a look up everytime to see if it needs to insert the value or just grab the id. We have an index on the table (not on the primary key) but there are about 350,000 rows (so it is taking 10 seconds to do 10 of these values)....
stackexchange/codereview
I can understand the use for one level of namespaces. But 3 levels of namespaces. Looks insane. Is there any practical use for that? Or is it just a misconception?
stackexchange/codereview
Does anyone know of a way to find out how much memory an instance of an object is taking? For example, if I have an instance of the following object: TestClass tc = new TestClass(); Is there a way to find out how much memory the instance tc is taking? The reason for asking, is that although C# has built in memory mana...
stackexchange/codereview
I have a series of performance tests I would like to show as a graph. I have a set of tests (about 10) which I run on a set of components (currently 3), and get throughput results. The Y-axis would be the throughput result from the test, and the X-axis should have an abbreviated name of the test, with the results from...
stackexchange/codereview
I am using Visual Studio 2005 with Team Foundation Server. When I right click a file under the source control and choose "compare" VS appears to freeze until I hit escape. My guess is that the window that is supposed to be popping up is somewhere I can't get to. I tried minimizing all the windows that I can and it is...
stackexchange/codereview
If my code throws an exception, sometimes - not everytime - the jsf presents a blank page. I´m using facelets for layout. A similar error were reported at this Sun forumn´s post, but without answers. Anyone else with the same problem, or have a solution? ;) Due to some requests. Here follow more datails: web.xml <erro...
stackexchange/codereview
What is an effective algorithm for nesting 1 dimensional lengths into predefined stock lengths? For example, If you required steel bars in the following quantities and lengths, 5 x 2 metres 5 x 3 metres 5 x 4 metres and these can be cut from 10 metre bars. How could you calculate the pattern for cutting the 10m bars...
stackexchange/codereview
I currently have a DetailsView in ASP.NET that gets data from the database based on an ID passed through a QueryString. What I've been trying to do now is to then use that same ID in a new cookie that is created when a user clicks either a ButtonField or a HyperLinkField. What I have in the .aspx is this: <asp:DetailsV...
stackexchange/codereview
Let's say you have a class with a Uri property. Is there any way to get that property to accept both a string value and a Uri? How would you build it? I'd like to be able to do something like one of the following, but neither are supported (using VB, since it lets you specify type in the Set declaration for the 2nd o...
stackexchange/codereview
Does anyone know of an application or system out there for tracking changes (files added/removed, diffs on text files) to a non-source controlled directory over time? Something that would let you Take a snapshot of a certain directory tree at time A Come back at time period B and see what has changed Come back at tim...
stackexchange/codereview
If the user of my winforms application resizes the main form, I want the 2 panels to stretch out also, along with the child controls. How can I achieve this?
stackexchange/codereview
I'm tidying up some older code that uses 'magic numbers' all over the place to set hardware registers, and I would like to use constants instead of these numbers to make the code somewhat more expressive (in fact they will map to the names/values used to document the registers). However, I'm concerned that with the vol...
stackexchange/codereview
It seems that when I use a tool (such as winmerge) to update my codebase... my Visual Studio Team System (VSTS) integration with Team Foundation Server (TFS) doesn't seem to pick it up. How do I know which files to check out and check back in? Is there something I am missing? Is this a feature that isn't part of VSTS &...
stackexchange/codereview
I'm trying to retrieve numeric values from a DataGridView. So far, the only way I've found is to retrieve them as a string and convert them to numeric. Convert.ToDouble(MyGrid.SelectedRows[0].Cells[0].Value.ToString()); There must be an easier way. The cell is originally populated from a DataSet with a numeric field v...
stackexchange/codereview
In java, I could do this with the 'final' keyword. I don't see 'final' in C#. Is there a substitute?
stackexchange/codereview
We are using the MVC framework (release 5) and the CrystalReportViewer control to show our reports. I cannot get any of the buttons at the top of the report viewer control to work. If I'm working with the report 'HoursSummary'. If I hover over any of the buttons on the report viewer in IE the displayed link at the bo...
stackexchange/codereview
I have got a C function in a static library, let's call it A, with the following interface : int A(unsigned int a, unsigned long long b, unsigned int *y, unsigned char *z); This function will change the value of y an z (this is for sure). I use it from within a dynamic C++ library, using extern "C". Now, here is what ...
stackexchange/codereview
Is there a way to compress a VMWare image on a ESXi server for archival purposes?
stackexchange/codereview
I have an object that I'm testing that raises an event. What is the best way of using Rhino Mocks to check that it was raised? Best I could come up with (I am certain it gets better than this): public void MyCallback(object sender, EventArgs e) { _flag = true;} [Test] public void DoSomethingRaisesEvent() { _flag ...
stackexchange/codereview
You can use ftplib for full FTP support in Python. However the preferred way of getting a directory listing is: # File: ftplib-example-1.py import ftplib ftp = ftplib.FTP("www.python.org") ftp.login("anonymous", "ftplib-example-1") data = [] ftp.dir(data.append) ftp.quit() for line in data: print "-", line W...
stackexchange/codereview
My web page sits in a DIV that is 960px wide, I center this DIV in the middle of the page by using the code: html,body{background: url(images/INF_pageBg.gif) center top repeat-y #777777;text-align:center;} #container{background-color:#ffffff;width:960px;text-align:left;margin:0 auto 0 auto;} I need the background ...
stackexchange/codereview
We are using ActiveMQ 5.2 as our implementation of choice and we picked it a while ago. It performs well enough for our use right now. Since its been a while, I was wondering what other Java Message Service implementations are in use and why? Surely there are more than a few.
stackexchange/codereview
I am using my own db for phpbb3 forum, and I wish to insert some data from the forum into my own tables. Now, I can make my own connection and it runs my query but in trying to use the $db variable(which I think is what you're meant to use??) it gives me an error. I would like someone to show me the bare bones which i ...
stackexchange/codereview
Within a spring webflow, i need to implement a navigation bar that will allow to "step back" or resume the flow to one of the previous view. For example : View 1 = login View 2 = My informations View 3 = My messages View 4 = Close session For this example, i would like to return back to view 2 from the view 4 page.
stackexchange/codereview
I am trying to match floating-point decimal numbers with a regular expression. There may or may not be a number before the decimal, and the decimal may or may not be present, and if it is present it may or may not have digits after it. (For this application, a leading +/- or a trailing "E123" is not allowed). I have...
stackexchange/codereview
Java SE 6 (64 bit only) is now on OS X and that is a good thing. As I understand it since Eclipse is still Carbon and thus 32 bit, it cannot be used for 1.6 on Leopard, only 1.5. Does anyone know if NetBeans 6.x can be used with Java SE 6 on Leopard utilizing its JVM?
stackexchange/codereview
I have a fairly good feel for what MySQL replication can do. I'm wondering what other databases support replication, and how they compare to MySQL and others? Some questions I would have are: Is replication built in, or an add-on/plugin? How does the replication work (high-level)? MySQL provides statement-based repl...
stackexchange/codereview
I am looking for an app that will let me type in code ON my cellphone. I don't need to compile or anything, and its not to program for the cellphone. Just something nice to have when an idea pops in my head. Am I completely overlooking a simple code editor for Symbian S60v3 phones? I am looking for something similar t...
stackexchange/codereview
I recently encountered an odd problem with RSACryptoServiceProvider.VerifyHash. I have a web application using it for decryption. When users running the web service were doing so over our VPN it became very very slow. When they had no connection or a internet connection they were fine. After much digging I found that ...
stackexchange/codereview
This PHP code... 207 if (getenv(HTTP_X_FORWARDED_FOR)) { 208 $ip = getenv('HTTP_X_FORWARD_FOR'); 209 $host = gethostbyaddr($ip); 210 } else { 211 $ip = getenv('REMOTE_ADDR'); 212 $host = gethostbyaddr($ip); 213 } Throws this warning... Warning: gethostbyaddr() [function.geth...
stackexchange/codereview
I've got a question concerning fields in databases which are measures that might be displayed in different units but are stored only in one, such as "height", for example. Where should the "pattern unit" be stated?. Of course, in the documentation, etc... But we all know nobody reads the documentation and that self-doc...
stackexchange/codereview
I'm building a C++/MFC program in a multilingual environment. I have one main (national) language and three international languages. Every time I add a feature to the program I have to keep the international languages up-to-date with the national one. The resource editor in Visual Studio is not very helpful because I f...
stackexchange/codereview
Given a string "filename.conf", how to I verify the extension part? I need a cross platform solution.
stackexchange/codereview
I would like my Core assembly to not expose a certain class and I would still like to be able to test it. How can I do that ?
stackexchange/codereview
I'm developing a web service whose methods will be called from a "dynamic banner" that will show a sort of queue of messages read from a sql server table. The banner will have a heavy pressure in the home pages of high traffic sites; every time the banner will be loaded, it will call my web service, in order to obtain ...
stackexchange/codereview
Our installer is written with Inno Setup and we are actually quite happy with it. Yet some customers keep asking for an MSI installer which they could more easily distribute via Active Directory. We have already gone to some lengths to make the installer deal really well with automated and unattended installations by e...
stackexchange/codereview
Why can I not see an option for copying database objects when I right click > tasks on my database?
stackexchange/codereview
I'd like to zoom and unzoom in ways the base class doesn't support. For instance, upon receiving a double tap.
stackexchange/codereview
I've written up a weekly-review GTD checklist for myself in TiddlyWiki, using CheckboxPlugin. After I'm finished with it each week, I'd like to click one link to uncheck (reset) all of the items on it, so it's ready for the next use. I'm storing the check information as tags on a separate tiddler page. I should be able...
stackexchange/codereview
What is the difference between #include and #import in C++?
stackexchange/codereview
I've got a WCF Web Service method whose prototype is: [OperationContract] Response<List<Customer>> GetCustomers(); When I add the service reference to a client, Visual Studio (2005) creates a type called "ResponseOfArrayOfCustomerrleXg3IC" that is a wrapper for "Response<List<Customer>>". Is there any way I can contr...
stackexchange/codereview
There's a famous bug in Visual Studio that prevents you from using the form designer on a subclass of an abstract form. This problem has already been elucidated and solved most elegantly by Urban Potato; that's not the part I'm having trouble with. The trouble is, I have duplicated the technique described by Urban P...
stackexchange/codereview
I'm a Mac user and I've decided to learn Emacs. I've read that to reduce hand strain and improve accuracy the CTRL and CAPS LOCK keys should be swapped. How do I do this in Leopard? Also, in Terminal I have to use the ESC key to invoke meta. Is there any way to get the alt/option key to invoke meta instead? update: Whi...
stackexchange/codereview
Given the following C function in a DLL: char * GetDir(char* path ); How would you P/Invoke this function into C# and marshal the char * properly. .NET seems to know how to do LPCTSTR but when I can't figure out any marshaling that doesn't cause a NotSupportedException to fire when calling this function.
stackexchange/codereview
In my vb.net program, I am using a webbrowser to show the user an HTML preview. I was previously hitting a server to grab the HTML, then returning on an asynchronous thread and raising an event to populate the WebBrowser.DocumentText with the HTML string I was returning. Now I set it up to grab all of the information ...
stackexchange/codereview
I'm having trouble figuring out how to access a cookie from a compiled object. I'm trying to make a compiled (DLL) object that will check the users cookie and then compare that to a database to confirm they have the correct access. I can pass in the cookie info fine and the component will work, but I'm trying to have ...
stackexchange/codereview
The scroll lock button seems to be a reminder of the good old green terminal days. Does anyone still use it? Should the 101 button keyboard become the 100 button keyboard?
stackexchange/codereview
I am looking for a replacement for javadeps, which I used to use to generate sections of a Makefile to specify which classes depended on which source files. Unfortunately javadeps itself has not been updated in a while, and cannot parse generic types or static imports. The closest thing I've found so far is Dependency ...
stackexchange/codereview
I've written a little script to iterate across files in folders to count lines of code. The heart of the script is this function to count lines of whitespace, comments, and code. (Note that for the moment it is tailored to C# and doesn't know about multi-line comments). It just doesn't look very nice to me - has anyone...
stackexchange/codereview
Each Java object (and its class) has an associated monitor. In pthread terms a Java monitor is equivalent to the combination of a reentrant mutex and a condition variable. For locking, the Win32 API provides Mutex objects (which are reentrant but heavyweight) and Critical Sections (which are non-reentrant but lightweig...
stackexchange/codereview
I have a stored procedure with the following header: FUNCTION SaveShipment (p_user_id IN INTEGER, p_transaction_id IN INTEGER, p_vehicle_code IN VARCHAR2 DEFAULT NULL, p_seals IN VARCHAR2 DEFAULT NULL) RETURN INTEGER; And I am having trouble running it from TOAD's Editor. I cannot run it as part of a select from dual...
stackexchange/codereview
Possible Duplicate: What are the obj and bin folders (created by Visual Studio) used for? The default output path for any project is Visual studio is bin/Debug, but I have noticed that obj folder is also generated which again contains dll and pdb files. Can someone tell me why is this folder generated?
stackexchange/codereview
i have a big web application running in perl CGI. It's running ok, it's well written, but as it was done in the past, all the html are defined hardcoded in the CGI calls, so as you could imagine, it's hard to mantain, improve and etc. So now i would like to start to add some templating and integrate with a framework (c...
stackexchange/codereview
When using IF statements in Python, you have to do the following to make the "cascade" work correctly. if job == "mechanic" or job == "tech": print "awesome" elif job == "tool" or job == "rock": print "dolt" Is there a way to make Python accept multiple values when checking for "equals to"? For example...
stackexchange/codereview
Right now, I have two Eclipse projects - they both use Maven 2 for all their jar-dependency goodness. Inside Eclipse, I have project Foo included in project Bar's build path, so that I can use Foo's classes from project Bar. This works really well in Eclipse land, but when I try: mvn compile inside Bar's directory, ...
stackexchange/codereview
I decided to use log4net as a logger for a new webservice project. Everything is working fine, but I get a lot of messages like the one below, for every log4net tag I am using in my web.config: Could not find schema information for the element 'log4net'... Below are the relevant parts of my web.config: <configSec...
stackexchange/codereview
How does one automatically find categories for text based on content?
stackexchange/codereview
When working with large and/or many Javascript and CSS files, what's the best way to reduce the file sizes?
stackexchange/codereview
Is it possible to use OpenID for both .NET web sites and PHP websites (Apache/Linux)? I have a manager that wants single sign-on for access to any/all web sites, regardless of which web server hosts a web site. I create .NET web apps and the PHP web sites/apps are done by another programmer. How would I go about u...
stackexchange/codereview
I have created my own Tree implementation for various reasons and have come up with two classes, a 'base' class that is a generic tree node that is chock full of logic and another class that extends that one which is more specialised. In my base class certain methods involve instantiating new tree nodes (e.g. adding ch...
stackexchange/codereview
If you have Mathematica code in foo.m, Mathematica can be invoked with -noprompt and with -initfile foo.m (or -run "<<foo.m") and the command line arguments are available in $CommandLine (with extra junk in there) but is there a way to just have some mathematica code like #!/usr/bin/env MathKernel x = 2+2; Print[x]; Pr...
stackexchange/codereview
I'm experimenting with OpenSSL on my network application and I want to test if the data sent is encrypted and can't be seen by eavesdropper. What tools can you use to check? Could this be done programmatically so it could be placed in a unit test?
stackexchange/codereview
I read a text recently saying the MVC pattern describes the layers in an application. But personally I see MVC showing several key roles in an application. Which word do you think is better, layer or role, to describe the three main pieces of MVC?
stackexchange/codereview
Summary Is that possible for webapps deployed on linux + tomcat5.5 to use/see all /usr/share/java/ jars automatically? Details I'm packaging my java webapp for Ubuntu (yet the question is related to any linux-based distro) and going to make it depend on tomcat. I'm going to put context descriptor (an xml file) to /usr/...
stackexchange/codereview
If I can do this, how do I call Java code (methods for instance) from within JavaScript code, in Wicket.
stackexchange/codereview
I'm fairly new to the AJAX methodologies (I only recently discovered jQuery a short time ago). I am interested to know if there is anyway to authenticate a user on a PHP setup; securely. Does jQuery have any special options to allow use of HTTPS (or any other way to encrypt my ajax call)? Yes, I could very well just po...
stackexchange/codereview
System Description A plotting component that uses OOXML to generate a document. Plotting component consists of several parts. All parts are written in C++ as exe + dll's, with the exception of the interface to the OOXML document. The latter component is a COM component that was created in C#/.NET. The main reason for...
stackexchange/codereview
I'm looking to create an ValidationRule class that validates properties on an entity type object. I'd really like to set the name of the property to inspect, and then give the class a delegate or a lambda expression that will be evaluated at runtime when the object runs its IsValid() method. Does anyone have a snippe...
stackexchange/codereview
Is the sorting algorithm used by .NET's Array.Sort() method a stable algorithm?
stackexchange/codereview
I have a method which should be executed in an exclusive fashion. Basically, it's a multi threaded application where the method is invoked periodically by a timer, but which could also be manually triggered by a user action. Let's take an example : The timer elapses, so the method is called. The task could take a few ...
stackexchange/codereview
In Guile 1.6.*, the function scm_istring2number(char *str,int strlen,int radix) does the work. However, this function does not exist in Guile 1.8.. How can I accomplish the same task in Guile 1.8.? This is not trivial because the function scm_string_to_number(SCM str,int radix) does not convert numbers larger than ...
stackexchange/codereview
When using Mercurial I sometimes find that it is hard to understand the relationship between changesets when there are thousands of changesets, and sometimes ten or more active branches at any one time. Currently, I use hgview which is okay, and while it makes a reasonable attempt to represent the parent relationships...
stackexchange/codereview
I need to keep as much as I can of large file in the operating system block cache even though it's bigger than I can fit in ram, and I'm continously reading another very very large file. ATM I'll remove large chunk of large important file from system cache when I stream read form another file.
stackexchange/codereview
In my specific example, I'm dealing with a drop-down, e.g.: <select name="foo" id="bar"> <option disabled="disabled" selected="selected">Select an item:</option> <option>an item</option> <option>another item</option> </select> Of course, that's pretty nonsensical, but I'm wondering whether any strict beh...
stackexchange/codereview
This is for a small scheduling app. I need an algorithm to efficiently compare two "schedules", find differences, and update only the data rows which have been changed, as well as entries in another table having this table as a foreign key. This is a big question, so I'll say right away I'm looking for either general...
stackexchange/codereview
I have a ASP.Net 2.0 website that is currently using a custom MembershipProvider and the standard login control. I would like to replace the login control with the one from DotNetOpenId. I override the ValidateUser which checks the username and password, but I shouldn't need to implement this when using OpenId. Is it ...
stackexchange/codereview
Which one should I use? catch (_com_error e) or catch (_com_error& e)
stackexchange/codereview
Is it possible to detect a valid regular expression with another regular expression? If so please give example code below.
stackexchange/codereview
I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction: Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's finished? Have you a...
stackexchange/codereview
I am trying to compare two large datasets from a SQL query. Right now the SQL query is done externally and the results from each dataset is saved into its own csv file. My little C# console application loads up the two text/csv files and compares them for differences and saves the differences to a text file. Its a very...
stackexchange/codereview
What are your favourite assemblers, compilers, environments, interpreters for the good old ZX Spectrum?
stackexchange/codereview
When coding, what in your experience is a better approach? Break the problem down into small enough pieces and then implement each piece. Break the problem down, but then implement using a top-down approach. Any other?
stackexchange/codereview
In a VB.Net Windows Service I'm currently pooling units of work with: ThreadPool.QueueUserWorkItem(operation, nextQueueID) In each unit of work (or thread I'll use for ease of understanding), it will make a couple MSSQL operations like so: Using sqlcmd As New SqlCommand("", New SqlConnection(ConnString)) ...
stackexchange/codereview
I was looking into the possibility of using CouchDB. I heard that it was similar to Lotus Notes which everyone loves to hate. Is this true?
stackexchange/codereview
I asked this earlier and was told to look at mapped by. I have 2 tables: A s_id(key) name cli type B sa_id(key) s_id user pwd. So in Jpa I have: @Entity class A...{ @OneToMany(fetch=FetchType.EAGER) @JoinTable( name="A_B", joinColumns={@JoinColumn(name="a_id", table="a",unique=false)}, inverseJoinColumns={@JoinColum...
stackexchange/codereview
I have a local mercurial repository with some site-specific changes in it. What I would like to do is set a couple files to be un-commitable so that they aren't automatically committed when I do an hg commit with no arguments. Right now, I'm doing complicated things with mq and guards to achieve this, pushing and popp...
stackexchange/codereview
Since I didn't do a good job writing the last question, and most of the answers were good, but not at all in the direction I intended for the question to go in, I deleted it and remade it as this question. I'm a solo developer on my own projects, generally very small things, but I have a few ideas that might turn into ...
stackexchange/codereview
Our clients will be uploading images to be printed on their documents and we have been asked to come up with a way to get the resolution of the image in order to warn them if the image has too low of a resolution and will look pixalated in the end-product If it comes to it we could also go with the dimensions if anyone...
stackexchange/codereview
Am I missing something or is there truly no alternative (yet, I hope) to SVCUTIL.EXE for generating WCF Web service proxies?
stackexchange/codereview
Suppose you have a program which reads from a socket. How do you keep the download rate below a certain given threshold?
stackexchange/codereview
I am looking for a command in Unix that returns the status of a process(active, dead, sleeping, waiting for another process, etc.) is there any available? A shell script maybe?
stackexchange/codereview
I have an application that writes to another application and needs to provide the date + timezone of the system. I have been using strftime with the %z argument to get the timezone, and it has been working very well on Linux. However, last week we decided to merge it to solaris just to find out that %z is not present. ...
stackexchange/codereview
I'm working with a webservice that offers almost duplicated code across two namesspaces. Lets say for example PigFeet and HorseFeet, both namespaces contain a Feet class and other code that works with the Feet class requires it to be part of that same namespace. Right now In my code I'm forced to do something like thi...
stackexchange/codereview
Does anyone know how to access ALSA (low-level audio API) in Linux using Mono? NOTE: I'm hoping to access ALSA using PInvoke.
stackexchange/codereview
I have two tables, Book and Tag, and books are tagged using the association table BookTag. I want to create a report that contains a list of books, and for each book a list of the book's tags. Tag IDs will suffice, tag names are not necessary. Example: Book table: Book ID | Book Name 28 | Dracula BookTag table: B...
stackexchange/codereview