instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
I am trying to implement the following functionality: class WeightResolver { WeightMonitor _source; bool _cancelled; Weight _threshold; public Cancel() { _cancelled = true; } public Weight Resolve(){ _cancelled = false; while(_source.CurrentWeight < threshold ) { if(_cancelled) ...
stackexchange/codereview
I am actually developing and application that has around 15 modules, all of them using the same database. I am using Apache + Mongrel, I cannot use Passenger because I am working on Windows (please forgive me for this deadly sin!) Which of the following is a better approach? Deploy multiple small rails applications us...
stackexchange/codereview
I created a simple .NET windows application in Visual Studio 2005 and on just entering the main form load event my threads window is as in the following image: http://img519.imageshack.us/my.php?image=threadshh4.jpg My questions are 1)Why are there so many threads in the first place when I haven't started any(apart fro...
stackexchange/codereview
I need to understand the differences between windows main/mdi/child/dialogs.... how win32 messages should be propagated... why some messages are present in one type and not other...
stackexchange/codereview
Is there any facility of transposing rows to columns in SQL Server (it is possible in MS-Access)? I was befuddled because this facility is available in MS-Access but not in SQL Server. Is it by design that this feature has not been included in SQL Server?
stackexchange/codereview
On our live/production database I'm trying to add a trigger to a table, but have been unsuccessful. I have tried a few times, but it has taken more than 30 minutes for the create trigger statement to complete and I've cancelled it. The table is one that gets read/written to often by a couple different processes. I ...
stackexchange/codereview
Is there any elegant way in the Android API for detecting new media when it is written to the device? I’m mainly interested in photos taken by the camera, video taken by the camera and audio recorded from the mic. My current thinking is to periodically scan each media content provider and filter based on last scan time...
stackexchange/codereview
I've got a tomcat instance with several apps running on it... I want the root of my new domain to go to one of these apps (context path of blah).. so I have the following set up: <Location /> ProxyPass ajp://localhost:8025/blah ProxyPassReverse ajp://localhost:8025/blah </Location> it kinda works... going to m...
stackexchange/codereview
I'm currently on chapter 4 of Real World Haskell, and I'm trying to wrap my head around implementing foldl in terms of foldr. (Here's their code:) myFoldl :: (a -> b -> a) -> a -> [b] -> a myFoldl f z xs = foldr step id xs z where step x g a = g (f a x) I thought I'd try to implement zip using the same technique,...
stackexchange/codereview
Summary: Can I program a "thick client" game in C without reinventing wheels, or should I just bite the bullet and use some library or SDK? I'm a moderate C programmer and am not afraid to work with pointers, data structures, memory locations, etc. if it will give me the control I need to make a great...
stackexchange/codereview
Question I'm looking for a Java in-memory object caching API. Any recommendations? What solutions have you used in the past? Current Right now, I'm just using a Map: Map cache = new HashMap<String, Object>(); cache.put("key", value); Requirements I need to extend the cache to include basic features like: Max size Tim...
stackexchange/codereview
Our application executes a long, hairy stored procedure with multiple result sets. The users are experiencing long wait times for this query, so I set out to determine what is causing the delay. I put a Stopwatch on executing and reading the data, and it takes 6-7 seconds each time. I timed the execution of the store...
stackexchange/codereview
I'd like to know if it is possible to redirect StreamWriter output to a variable Something like String^ myString; StreamWriter sw = gcnew StreamWriter([somehow specify myString]) sw->WriteLine("Foo"); then myString will contain Foo. The reason I would like to do this is to reuse a complex function. I should probably r...
stackexchange/codereview
I'm trying to add parameters to an objectDataSource at runtime like this: Parameter objCustomerParameter = new Parameter("CustomerID", DbType.String, customerID); Parameter objGPDatabaseParameter = new Parameter("Database", DbType.String, gpDatabase); //set up object data source parameters ...
stackexchange/codereview
How can I Submit an InfoPath form to a SharePoint library AND to an email box at the same time when the user hits SUBMIT? I need my form to be approved by several users in a particular order; then re-submitted to the SharePoint site, and to another email box so that the next approver can see the approvals, and approve ...
stackexchange/codereview
I want to implement user stories in a new project where can i find a good template or other ones used in agile development?
stackexchange/codereview
When using C++ namespaces, do you prefer to explicitly name them, like this: std::cout << "Hello, world!\n"; Or do you prefer using namespace: using namespace std; cout << "Hello, world!\n"; And if if you prefer the latter, do you declare your usings at file or function scope? Personally I prefer to explicitly name t...
stackexchange/codereview
I have a table that has a column with a default value: create table t ( value varchar(50) default ('something') ) I'm using a stored procedure to insert values into this table: create procedure t_insert ( @value varchar(50) = null ) as insert into t (value) values (@value) The question is, how do I get it to...
stackexchange/codereview
How often do we see stuff like "Send this page to a friend" on a webpages? Well, I see them quite often. My question is, how do you guys see it's effectiveness? If I hit a webpage that's interesting, and I think my friend would enjoy it, I can just copy the URL from my browser bar, paste it into the email and press "Se...
stackexchange/codereview
Let's say you've inherited a C# codebase that uses one class with 200 static methods to provide core functionality (such as database lookups). Of the many nightmares in that class, there's copious use of Hungarian notation (the bad kind). Would you refactor the variable names to remove the Hungarian notation, or would ...
stackexchange/codereview
Edit: I am using SqlDataAdapters to fill the data sets. Sorry--I should have been more clear. I'm working on a project where I need to fill a number of strongly-typed data sets with information from stored procedures. Right now, I have a generic method in my data access layer: public static DataSet FillDataSet(DataSet ...
stackexchange/codereview
PHP has a very nice function, isset($variableName). It checks if $variableName is already defined in the program or not. Can we build similar feature for C/C++ (some kind of symbol table lookup)?
stackexchange/codereview
I'm using VisualC++ 6.0. (and, yes, I'm using Mosaic browser..;) My VC++ project has different dependency setting for 'Debug' and 'Release' build configuration. So, when I switch from one configuration to other, I have to change the dependency by hand every time. Is there any better way to do this? Can I keep my depen...
stackexchange/codereview
What is the data that Process and Thread will not share ? An advance thanks goes to everybody who provide their time
stackexchange/codereview
I have an single threaded, embedded application that allocates and deallocates lots and lots of small blocks (32-64b). The perfect scenario for a cache based allocator. And although I could TRY to write one it'll likely be a waste of time, and not as well tested and tuned as some solution that's already been on the fro...
stackexchange/codereview
I'm building an app in Ruby on Rails, and I'm including 3 of my models (and their migration scripts) to show what I'm trying to do, and what isn't working. Here's the rundown: I have users in my application that belong to teams, and each team can have multiple coaches. I want to be able to pull a list of the coaches ...
stackexchange/codereview
I'm working on a project in C and it requires memalign(). Really, posix_memalign() would do as well, but darwin/OSX lacks both of them. What is a good solution to shoehorn-in memalign? I don't understand the licensing for posix-C code if I were to rip off memalign.c and put it in my project- I don't want any viral-typ...
stackexchange/codereview
If the amount of data stored within a given field of a database is unknown, and could be very large, should I store it in an external file rather than within a field in the database?
stackexchange/codereview
I want to I check whether a string is in ASCII or not. I am aware of ord(), however when I try ord('é'), I have TypeError: ord() expected a character, but string of length 2 found. I understood it is caused by the way I built Python (as explained in ord()'s documentation). Is there another way to check?
stackexchange/codereview
I'm investigating the differences between using log4net and System.Diagnostics.Trace for logging, and I'm curious about the performance differences I've observed. I created a test application to compare the performance of both logging methods in several scenarios, and I'm finding that log4net is significantly slower th...
stackexchange/codereview
Using OpenXML SDK, I want to insert basic HTML snippets into a Word document. How would you do this: Manipulating XML directly ? Using an XSLT ? using AltChunk ? Moreover, C# or VB examples are more than welcome :)
stackexchange/codereview
Would it suppose any difference regarding overhead to write an import loading all the types within one package (import java.*); than just a specific type (i.e. import java.lang.ClassLoader)? Would the second one be a more advisable way to use than the other one?
stackexchange/codereview
I have the following problem using subversion: I'm currently working on the trunk of my project and plan to do some refactoring (which includes renaming files or moving files to different directories). At the same time someone else is working on the same project on a branch. At some time I want to merge the changes mad...
stackexchange/codereview
How can I count the number of elements in an array, because contrary to logic array.count(string) does not count all the elements in the array, it just searches for the number of occurrences of string.
stackexchange/codereview
Developing software solutions which already exist and are available for re-use (either commercial or open-source). AKA "re-inventing the wheel". Same as above, but your solution being broken. AKA "re-inventing the square wheel". Developing solutions for problems which do not exist. Again, I'm interested in a more for...
stackexchange/codereview
I have a Tomcat application which, the first time I start Tomcat after starting Eclipse, I get an odd NoClassDefFoundError. If I then stop and restart Tomcat through Eclipse, it works fine. I have single, double, and triple checked the classpath and everything seems fine. Anyone ever seen anything like this before? ...
stackexchange/codereview
I'm trying to create a logger for a GWT application as an exercise to evaluate GWT. What I specifically want to do is have it so that I can post messages to a client side label at any point from the server side. So, if some interesting stuff has happened on the server the client can be updated. My First question is, is...
stackexchange/codereview
Any ideas how i can best drive a USB POS printer from c#. POS printers are usually serial, TCP/IP or USB based. I know how to accomplish serial and TCP/IP but have no idea about communications through USB in C#. I know that there is a layer available from Microsoft called POS.NET, but I want to try and avoid using this...
stackexchange/codereview
I'd like a consistent and simple way to throw exceptions in JNI code; something that handles chained exceptions (implicitly from the env->ExceptionOccurred method, or explicitly by parameters, either way is good) and saves me looking up constructors every time I want to do this. All of the above is preferably in C, al...
stackexchange/codereview
I'm writing a function to find triangle numbers and the natural way to write it is recursively: function triangle (x) if x == 0 then return 0 end return x+triangle(x-1) end But attempting to calculate the first 100,000 triangle numbers fails with a stack overflow after a while. This is an ideal function to memo...
stackexchange/codereview
I look for a tool/framework to make automatic acceptance-testing. The interface to create new tests should be so easy, that a non-programmer (customer, boss) will be able to add specifications for which will be tested automatically. It should be some way to execute the tests from command-line, to include a run of the t...
stackexchange/codereview
I'm currently using Toad for my day-to-day work on our databases (queries, updates, small scripts, browsing of db objects, etc.). My question is: since my version of Toad is old and buggy, which are the (possibly free, but not necessarily) alternatives to Toad? The database versions we are using are 10g and 9i. Thanks ...
stackexchange/codereview
I need a tool to execute XSLTs against very large XML files. To be clear, I don't need anything to design, edit, or debug the XSLTs, just execute them. The transforms that I am using are already well optimized, but the large files are causing the tool I have tried (Saxon v9.1) to run out of memory.
stackexchange/codereview
Question My question is how can you teach the methods and importance of tidying-up and refactoring code? Background I was recently working on a code review for a colleague. They had made some modifications to a long-gone colleagues work. During the new changes, my colleague had tried to refactor items but gave up as so...
stackexchange/codereview
How is Oracle date implemented? Is it stored as milliseconds or something like that?
stackexchange/codereview
I'd like to use the newer <button> tag in an ASP.NET website which, among other things, allows CSS-styled text and embedding a graphic inside the button. The asp:Button control renders as <input type="button">, is there any way to make a preexisting control render to <button>? From what I've read there is an incompatib...
stackexchange/codereview
In my program, how can I read the properties set in AssemblyInfo.cs: [assembly: AssemblyTitle("My Product")] [assembly: AssemblyDescription("...")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Radeldudel inc.")] [assembly: AssemblyProduct("My Product")] [assembly: AssemblyCopyright("Copyright @ me ...
stackexchange/codereview
I have few different applications among which I'd like to share a C# enum. I can't quite figure out how to share an enum declaration between a regular application and a WCF service. Here's the situation. I have 2 lightweight C# destop apps and a WCF webservice that all need to share enum values. Client 1 has Meth...
stackexchange/codereview
I'm involved with updating an Access solution. It has a good amount of VBA, a number of queries, a small amount of tables, and a few forms for data entry & report generation. It's an ideal candidate for Access. I want to make changes to the table design, the VBA, the queries, and the forms. How can I track my change...
stackexchange/codereview
Can Visual Studio 2005 Team edition for Developer coexist peacefully with Visual Studio 2008 Database edition on my machine? Are they completely separate applications that won't interfere in any way with each other? Update: What about Visual Studio 2008 Developer edition? If I install this on the same machine as 2008 ...
stackexchange/codereview
What is the best way to make trailing slashes not matter in the latest version of Routes (1.10)? I currently am using the clearly non-DRY: map.connect('/logs/', controller='logs', action='logs') map.connect('/logs', controller='logs', action='logs') I think that turning minimization on would do the trick, but am under...
stackexchange/codereview
I am currently using Telerik's carousel control, but it is lacking many features and is buggy. Is there a good control out there that looks the the coverflow control in itunes?
stackexchange/codereview
What is the best way to create several scrollable regions in an ActionScript 3 visualization that extends flash.display.Sprite and makes use of hierarchy of of low level DisplayObjects (Sprite'a, Shape's, TextField)? I have tried to use three mx.containers.Canvas objects added as children of the main Sprite and have a...
stackexchange/codereview
I'm a total amateur writing a small App to track to changes in folders. I imagine I'll be keeping information about the directories to watch in one datatable bound to a gridview, when the user clicks a button, the program will create FileSystemWatchers to keep an eye on the directories and they will send their event me...
stackexchange/codereview
I am curious to do what happens when you edit a post on this site. I am using wmd for my markdown editor, of course when I goto edit, I get the HTML it generated not the markdown like on stackoverflow. Now, is there a way I can store both? or is it reliable enough to simply convert the HTML back to markdown to show i...
stackexchange/codereview
I am having the worst luck with this. We bought a template to update our own website (don't have enough time to start our own from scratch!) but when I make simple changes in the Flash CS4 native file and re-export the swf, it doesn't work correctly! I am wondering if anyone has run across the same problems with a Temp...
stackexchange/codereview
I want to add a drupal form to the top of a view. The view does not need to receive the results of the form but the _submit hook of the form should be able to read the first argument of the view that the form was on. Where is the best place to add this? Custom module or template file and what are the necessary filena...
stackexchange/codereview
I have two arrays. One contains id=>count and the other contains id=>name. I'm trying to produce a single array that is name=>count. Any suggestions on a straightforward way to do this? I have looked at the Array Functions in the PHP Manual and didn't see anything that stood out as doing what I want, so I'm guessing I'...
stackexchange/codereview
I'm working on a file sharing website, I need a way to take screenshots of the uploaded documents. The site will support several file formarts, from plain text to office documents (doc, xls, ppt, ...), videos (mpeg, avi, ...), images (jpg, gif, png, ...) PDF's, Open Office, etc. Each document need to have a "preview" o...
stackexchange/codereview
I have a requirement of reading subject, sender address and message body of new message in my Outlook inbox from a C# program. But I am getting security alert 'A Program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this'. By some googling I found few third party COM libraries to...
stackexchange/codereview
Derik Whitaker posted an article a couple of days ago that hit a point that I've been curious about for some time: should business logic exist in controllers? So far all the ASP.NET MVC demos I've seen put repository access and business logic in the controller. Some even throw validation in there as well. This result...
stackexchange/codereview
Can JQuery and YUI live together w/o any conflicts?
stackexchange/codereview
Recently, I made a post about the developers I'm working with not using try catch blocks properly, and unfortuantely using try... catch blocks in critical situations and ignoring the exception error all together. causing me major heart ache. Here is an example of one of the several thousand sections of code that they ...
stackexchange/codereview
I'm trying to run some commands in paralel, in background, using bash. Here's what I'm trying to do: forloop { //this part is actually written in perl //call command sequence print `touch .file1.lock; cp bigfile1 /destination; rm .file1.lock;`; } The part between backticks (``) spawns a new shell and executes th...
stackexchange/codereview
What language or method would I use to listen to the event when a removeable drive is plugged into the PC?
stackexchange/codereview
I've worked in shops where I've implemented Exception Handling into the event log, and into a table in the database. Each have their merits, of which I can highlight a few based on my experience: Event Log Industry standard location for exceptions (+) Ease of logging (+) Can log database connection problems here (+) C...
stackexchange/codereview
In Silverlight how can I launch / navigate to another page?
stackexchange/codereview
I know VS2008 has the remove and sort function for cleaning up using directives, as does Resharper. Apart from your code being "clean" and removing the problem of referencing namespaces which might not exist in the future, what are the benefits of maintaining a "clean" list of using directives? Less code? Faster compil...
stackexchange/codereview
I am running GNU Emacs on Windows so entering: M-x shell launches the Windows command-line DOS shell. However, I would like to instead be able to run the Cygwin Bash Shell (or any other non-Windows shell) from within Emacs. How can this be easily done?
stackexchange/codereview
Can a JApplet use a JFileChooser so that the user can select a file on his hard-drive? Or would this violate Java applet security? (I'm assuming that the default security settings are being used. I don't want to ask my users to grant me extra permissions.)
stackexchange/codereview
To make click-able divs, I do: <div class="clickable" url="http://google.com"> blah blah </div> and then $("div.clickable").click( function() { window.location = $(this).attr("url"); }); I don't know if this is the best way, but it works perfectly with me, except for one issue: If the div contains a click-ab...
stackexchange/codereview
Not sure if the title is quite right for the question but I can't think of any other way to put it.. Suppose you wanted to create multiple different web apps, but you wanted a user who was logged into one app to be able to go straight to your other app without re-logging in (assuming they have perms to look at the othe...
stackexchange/codereview
I am using java language,I have a method that is supposed to return an object if it is found. If it is not found, should I: return null throw an exception other Which is the best practise or idiom?
stackexchange/codereview
I am trying to connect to 2 databases on the same instance of MySQL from 1 PHP script. At the moment the only way I've figured out is to connect to both databases with a different user for each. I am using this in a migration script where I am grabbing data from the original database and inserting it into the new one, ...
stackexchange/codereview
I'm probably doing this all wrong. I have a text file full of data and I want to match and replace patterns of "item" and "catalog number" that are in the file. But the order of each element in the file is very important, so I want to match/replace starting from the top of the file and then work my way down. The code s...
stackexchange/codereview
What's the best way to trim a DateTime object to a specific precision? For instance, if I have a DateTime with a value of '2008-09-29 09:41:43', but I only want it's precision to be to the minute, is there any better way to do it than this? private static DateTime TrimDateToMinute(DateTime date) { return new DateT...
stackexchange/codereview
for working with MS word files in python, there is python win32 extensions, which can be used in windows. How do I do the same in linux? Is there any library?
stackexchange/codereview
Is there an easy way to convert between color models in Java (RGB, HSV and Lab). Assuming RGB color model: How do I calculate black body spectrum color palette? I want to use it for a heatmap chart. How about single-wavelength spectrum? Edit: I found that the ColorSpace class can be used for conversions between RGB/...
stackexchange/codereview
I am attempting to compare files in a directory using SML. Using the TextIO library is fairly easy but I need to compare the files at the bit level. That is, a binary compare. I am using a function similar to this: fun listDir (s) = let fun loop (ds) = (case OS.FileSys.readDir (ds) of "" => [] before OS.Fil...
stackexchange/codereview
c# + sql server: I have to import a few tables from Access into sql server. The new sql server tables are already defined and created. The Access tables have primary key - foreign key relationships that have to be maintained. I would like to have the new sql tables use identity values for the primary keys, but I can't ...
stackexchange/codereview
Alright, after doing a ton of research and trying almost every managed CPP Redist I can find as well as trying to copy my DLLs locally to the executing directory of the app I cannot figure out what dependencies i'm missing for this mixed mode library. Basically I have a large C# application and I'm trying to use a mixe...
stackexchange/codereview
I'm using C# & .NEt 3.5. What is the difference between the OptionA and OptionB ? class MyClass { private object m_Locker = new object(); private Dicionary<string, object> m_Hash = new Dictionary<string, object>(); public void OptionA() { lock(m_Locker){ // Do something with the dic...
stackexchange/codereview
I have seen this theme present itself more than once now. I am hoping that people here who are currently in similar situations or have been in the past can offer some insightful advice. It might be useful if you share your past experiences as well. So there is this fairly large windows forms application that has been d...
stackexchange/codereview
I have a Visual Studio (2008) solution consisting of several projects, not all in the same namespace. When I build the solution, all the DLL files used by the top level project, TopProject, are copied into the TopProject\bin\debug folder. However, the corresponding .pdb files are only copied for some of the other proje...
stackexchange/codereview
We have consumed a third party web service and are trying to invoke it from an ASP.NET web application. However when I instantiate the web service the following System.InvalidOperationException exception is thrown: Method 'ABC.XYZ' can not be reflected. System.InvalidOperationException: Method 'ABC.XYZ' can not b...
stackexchange/codereview
I have always wondered WHaT tHE HecK?!? is the difference between JScript and JavaScript.
stackexchange/codereview
Making a small app, and I want a function to execute 50% of the time. So if I were to dbl click the exe half the time the function would execute, and the other half it wouldn't. I can't seem to find anyway to easily do this, the one solution I tried seemed to determine the chance on compile rather than on run. Thank...
stackexchange/codereview
I am writing an application where I will be accessing the database from django and from a stand alone application. Both need to do session verification and the session should be the same for both of them. Django has a built in authentication/session verification, which is what I am using, now I need to figure out how t...
stackexchange/codereview
I have a PHP/AJAX/MYSQL chat application. I want to add video chatting to my application. How can I create live video streaming to be used for live video conferences/chatting in a PHP application. What are the key-terms I need to know if I wanted to build such a system? Is it a good idea in the first place to use PHP? ...
stackexchange/codereview
Is there an easy way to have the form helpers set the tabindex parameter automatically when using form helpers in Rails? Basically, I don't want to have to manually set the tab index on every form element when building forms (I keep forgetting to update them when I change things). The majority of the forms I write are...
stackexchange/codereview
I need to perform a filtered query from within a django template, to get a set of objects equivalent to python code within a view: queryset = Modelclass.objects.filter(somekey=foo) In my template I would like to do {% for object in data.somekey_set.FILTER %} but I just can't seem to find out how to write FILTER.
stackexchange/codereview
Because of several iframes, XUL browser elements, and so forth, I have a number of window objects in my XULRunner application. I'm looking for the best way to find the window object that a specified node belongs to using JavaScript. So, to be more specific, given node x, I need to find the specific window object that c...
stackexchange/codereview
We are currently designing a website that will be accessed from kiosks in a museum. Users will need to be able to browse through a number of different web pages that will currently contain static HTML content as well as go through various interactive presentations that will be based on flash and run in flash player. Us...
stackexchange/codereview
My view-state to action-state transition does not appear to be happening. In the following example, I want the view-state to transition to the action-state when the user submits the form. Pretty basic stuff. But the setA() method does not get called. In the jsp, does the submit input element need to have a name of ...
stackexchange/codereview
I wonder why no browser out there has such simple but essential feature. Am I missing something? Is there a technical reason? I'm tired of all those javascript/flash/java hacks out there ...
stackexchange/codereview
When debugging JavaScript in Visual Studio 2008 and I use the ? command in the command window to list a JavaScript object's members I always get that ellipses {...}. Example: >? Page_Validators {...} [0]: {object} [1]: {object} [2]: {object} [3]: {object} [4]: {object} [5]: {object} length...
stackexchange/codereview
I was wondering if there's a way to see the output of any command, straight inside vim, rather than first redirecting it into a file and then opening that file. E.x. I need something like $ gvim < diff -r dir1/ dir2/ This gives ambiguous redirect error message I just want to see the diffs between dir1 and dir2 straig...
stackexchange/codereview
I'm using a small site to experiment with the uploading of pictures and displaying them. When someone clicks "add a picture", they get taken to a page with a form on it. They can select a file and click the submit button. But what I want to do now is this: put a second submit button labeled "Cancel" next to the normal ...
stackexchange/codereview
I have a defined MenuItem that I would like to share between two different menus on one page. The menu contains functionallity that is the same between both menus and I do not want two copies of it. Is there anyway to define a MenuItem in the Page.Resources and reference it in the ContextMenu XAML below? <Page.Resource...
stackexchange/codereview
The project I'm working on needs to render an ESRI shape file, which can have a large number of polygons/shapes. When I add all these polygons, lines, points, etc to the canvas I'm using, it gets really slow. To draw the shapes on the map, I'm creating a Path object, and setting it's Data property to a StreamGeometry....
stackexchange/codereview