instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
So I've got a Ruby method like this: def something(variable, &block) .... end And I want to call it like this: something 'hello' { do_it } Except that isn't working for me, I'm getting a syntax error. If I do this instead, it works: something 'hello' do do_it end Except there I'm kind of missing the nice look of...
stackexchange/codereview
We need a mailing list package similar to Python Mailman. I'd use Mailman except for one thing: we want to link the subscriber list to a table in our MySQL database. We want people to be able to opt in/out and control delivery options directly from our site in addition to via the email interface. I don't think Mailman ...
stackexchange/codereview
For example for the following XML <Order> <Phone>1254</Phone> <City>City1</City> <State>State</State> </Order> I might want to find out whether the XElement contains "City" Node or not.
stackexchange/codereview
I'm looking to write a html sanitiser, and obviously to test/prove that it works properly, I need a set of XSS examples to pitch against it to see how it performs. Here's a nice example from Coding Horror <img src=""http://www.a.com/a.jpg<script type=text/javascript src="http://1.2.3.4:81/xss.js">" /><<img src=""http...
stackexchange/codereview
I have a 'Purchase Order' class. It contains information about a single purchase order. I have a DAO class for database methods. Where should the responsibility reside for the methods that will load and update the purchase order? Should the PurchaseOrder class have '.update', 'insert', 'delete', and '.load' methods tha...
stackexchange/codereview
What is preferable, keeping a dataset in session or filling the dataset on each postback?
stackexchange/codereview
Alright, I know how the fieldset/legend works out in HTML. Say you have a form with some fields: <form> <fieldset> <legend>legend</legend> <input name="input1" /> </fieldset> </form> What should I use the legend for? It's being displayed as a title, but isn't a legend semantically an explanatio...
stackexchange/codereview
Any ideas on how i get MVP working with Silverlight? How Do I get around the fact there is no load event raised? This the view I have: public partial class Person: IPersonView { public event RoutedEventHandler Loaded; public Person() { new PersonPresenter(this); ...
stackexchange/codereview
Seeking a method to: Take whitespace separated tokens in a String; return a suggested Word ie: Google Search can take "fonetic wrd nterpreterr", and atop of the result page it shows "Did you mean: phonetic word interpreter" A solution in any of the C* languages or Java would be preferred. Are there any existing Open ...
stackexchange/codereview
I'm overriding WndProc, so I want to write code like if (m.Msg == WM_COMMAND) my special stuff else base.WndProc(ref m)
stackexchange/codereview
The only thing I can get python omnicomplete to work with are system modules. I get nothing for help with modules in my site-packages or modules that I'm currently working on.
stackexchange/codereview
I'm running zsh as the default shell on a Ubuntu box, and everything works fine using gnome-terminal (which as far as I know emulates xterm). When I login from a windows box via ssh and putty (which also emulates xterm) suddendly the home/end keys no longer work. I've been able to solve that adding these lines to my z...
stackexchange/codereview
I've got a little problem, I need to be able to have a reoccurring event (forever) that marks the day after the second Tuesday of each month. Your probably thinking, why not just Wednesday of each month. October 2008 is an example, it starts on a Wednesday. :( Really I just need it in Outlook, probably (but not limited...
stackexchange/codereview
Today I happens to find that one C# class can inherit one interface both in implicit and explicit way. This surprises me. If C# works in this way, then one instance can behave differently when referenced in different way. interface IFoo { void DoSomething(); } class Foo : IFoo { #region IFoo Members public...
stackexchange/codereview
If you have a class member that is static and public. Would you write static public or public static? I know they are the same. But is there some recommendation / best practice for writing this?
stackexchange/codereview
I have sets of 5, 6 and 7 digit numbers. I need them to be displayed in the 000/000/000 format. So for example: 12345 would be displayed as 000/012/345 and 9876543 would be displayed as 009/876/543 I know how to do this in a messy way, involving a series of if/else statements, and strlen functions, but there has to ...
stackexchange/codereview
I'm consuming a third-party resource (a .dll) in a web service, and my problem is, that invoking this resource (calling a method) is done asynchronous - I need to subscribe to an event, to get the answer for my request. How do I do that in a c# web service? Update: With regard to Sunny's answer: I don't want to make my...
stackexchange/codereview
I have overridden the windows ListBox in order to display an image and a piece of text in each ListBoxItem, but I need to filter the contents of the text displayed I was hoping to do this by accessing the DisplayMemberPath of the actual ListBox however I can't get it working. <Setter Property="ItemContainerStyle"> ...
stackexchange/codereview
I'm having trouble getting the right number of elements in the ArrayList alt in the JSP page below. When I view the JSP it shows the size is 1 (<%=alt.size()%>) when it should be 3; I think I'm adding that method to the array in the generator class, so I don't understand why it's showing 1. This is my jsp page: <% A...
stackexchange/codereview
I have a project using GWT and it displays data in a table. I need a Table for GWT that supports: sorting by particular column scrolling the data, while the header is immobile filtering rows for data searched in the table The project is being created for internal purpose of the company, so I look for a solution that ...
stackexchange/codereview
You sometimes hear it said about Perl that there might be 6 different ways to approach the same problem. Good Perl developers usually have well-reasoned insights for making choices between the various possible methods of implementation. So an example Perl problem: A simple script which recursively iterates through a d...
stackexchange/codereview
Is the asp.net membership system used over wcf (transport security turned on) enough for high security internet scenarios with thousands of clients spread all over the internet? I'm just evaluating possible solutions and wanted to know if this might fit in this category. If not, what would be the best method to provide...
stackexchange/codereview
I have a ListCtrl that displays a list of items for the user to select. This works fine except that when the ctrl is not large enough to show all the items, I want it to expand downwards with a vertical scoll bar rather than using a horizontal scroll bar as it expands to the right. The ListCtrl's creation: self.subject...
stackexchange/codereview
I'm writing an intranet application for a client and I want to give them the ability to configure through an admin interface, which users and user groups can access certain areas. What I'd like to know is the best way of storing the reference to the user or group that is assigned to an area of the intranet. Should I b...
stackexchange/codereview
I have quickly read over the Microsoft Lambda Expression documentation. This kind of example has helped me to understand better, though: delegate int del(int i); del myDelegate = x => x * x; int j = myDelegate(5); //j = 25 Still, I don't understand why it's such an innovation. It's just a method that dies when the "m...
stackexchange/codereview
Any ideas on how to disable, but not uninstall Resharper 4.x or above?
stackexchange/codereview
Are there any libraries out there (preferably a self contained Text Edit Control) for .NET that have Spell Check capabilities. I would like to add the typical red underline to miss-spelled words in the edit area of my application. Edit: To clarify, this is for WinForms
stackexchange/codereview
How do you debug getResource-style methods that are failing, returning null? I am sure the file it's looking for is there, but it's returning NULL. How do I know what it is looking for to try to spot any mismatch?
stackexchange/codereview
A lot of my C# code follows this pattern: void foo(string param1, string param2, string param3) { try { // do something... } catch(Exception ex) { LogError(String.Format("Error in foo(param1={0}, param2={1}, param3={2}), exception={3}", param1, param2, param3, ex.Message)); } } ...
stackexchange/codereview
When doing TDD, how to tell "that's enough tests for this class / feature"? I.e. when could you tell that you completed testing all edge cases?
stackexchange/codereview
Is there a csh script/command to list all the files in source source tree which have line endings that show up as "^M" in emacs (under linux). Thanks!
stackexchange/codereview
Working with TCL and I'd like to implement something like the Strategy Pattern. I want to pass in the "strategy" for printing output in a TCL function, so I can easily switch between printing to the screen and printing to a log file. What's the best way to do this in TCL?
stackexchange/codereview
I have a WPF control, that has a list of "Investors", and in the right column of the list, a "Delete" button. I could either waste some time making an image of an "x" in photoshop. Or, I could just use Wingdings font and set the content to "Õ" (which makes a cool looking delete button). Is this appropriate? My thinking...
stackexchange/codereview
I want to examine the contents of a std::vector in GDB, how do I do it? Let's say it's a std::vector<int> for the sake of simplicity.
stackexchange/codereview
I have a web application that has many faces and so far I've implemented this through creating themes. A theme is a set of html, css and images to be used with the common back end. Things are laid out like so: code/ themes/theme1 themes/theme2 And each instance of the web application has a configuration file that sta...
stackexchange/codereview
Can someone tell me how i can change the .xml file that a flash movie loads using c#. ie: i would like an ActionScript variable that defines the location of the flash movie. I would like to be able to change this variable using c# if possible. i dont really know how it would look, but something like: <object xmlpath='...
stackexchange/codereview
I'm a complete Ada newbie, though I've used Pascal for 2-3 years during HS. IIRC, it is possible to call Pascal compiled functions from C/C++. Is it possible to call procedures & functions written in Ada from C++?
stackexchange/codereview
Is there a relatively simple way in nant, without writing a custom task, to get the name of the newest folder in a certain directory? Recursion is not needed. I have been trying to do it with directory::get-creation-time and a foreach loop and if statements, yada yada. It's too complex, and I'm about to create a cust...
stackexchange/codereview
I have a web service that is protected by requiring the consuming third party application to pass a client certificate. I have installed the certificate on the providing web service in production and on the client as well. This process is currently working fine for other clients with a similar setup. The current ver...
stackexchange/codereview
I'm struggling to get around the 404 errors from asp.net mvc beta when deploying on IIS 6. I had this working in one of the previews by mapping .mvc in IIS but this no longer works. I've read Omar's post and several others on the web and tried their solutions but no luck so far. The home page opens without a problem on...
stackexchange/codereview
I need to setup an application that watches for files being created in a directory, both locally or on a network drive. Would the FileSystemWatcher or polling on a timer would be the best option. I have used both methods in the past, but not extensively. What issues (performance, reliability etc.) are there with eithe...
stackexchange/codereview
I've decided to integrate NUnit with VWD2008. I did the following- 1) Installed NUnit - Ran a Sample project that was included with the installation all the tests were fine. 2) Installed TestDriven.Net 2.0 - Personal distribution. 3) I have written on an MVC Project a test and when I try to right click the context and ...
stackexchange/codereview
In CSS, you can specify the spacing between table cells using the border-spacing property of a table. However, this results in uniform spacing between columns and rows, and I am finding more situations where the designs I am using call for gaps between rows, but not columns, or visa versa. If I have a solid background,...
stackexchange/codereview
Does anyone know how I can add a class to the link rendered using the Html.RouteLink helper method in ASP.Net MVC, it has the htmlAttributes object as the last parameter which I assumed I would be able to use, but since class is obviously a reserved word, I cannot supply this as one of the properties on the object.
stackexchange/codereview
I'm sorry for this very newbish question, I'm not much given into web development. I've got this cool JavaScript in a .js file that we want to use on a small web site. (It's a script to run Cooliris on it). How do use the .js file or attach it to my HTML code?
stackexchange/codereview
I have good knowledge on C++ (not C) and recently bought a Symbian-based phone. This gave me reasons to start learning on how to program this beast. I have searched for Symbian programming tutorials but there is so much knowledge that it is hard to choose best for startup. So I'm asking for hints, tips on where to star...
stackexchange/codereview
I want to start learning HTML and AJAX using a Linux distribution. Can anyone recommend a distribution that has these requirements: Local Host Admin interface (like PHPmyAdmin) IDE for Javascript... etc
stackexchange/codereview
I'm using a local artifactory to proxy the request, but the build and test phases are still a bit slow. It's not the actual compile and tests that are slow, it's the "warmup" of the maven2 framework. Any ideas?
stackexchange/codereview
I'm trying to use a generic List as a property on a ServicedComponent class... public class MyCOM : ServicedComponent { public enum MyEnumType { Value1, Value2, Value3 } public List<MyEnumType> MyList { private set; get; } public MyCOM() { MyList = new List<MyEnumType>(); } } Th...
stackexchange/codereview
I have a Bluehost account where I can run Python scripts as CGI. I guess it's the simplest CGI, because to run I have to define the following in .htaccess: Options +ExecCGI AddType text/html py AddHandler cgi-script .py Now, whenever I look up web programming with Python, I hear a lot about WSGI and how most framework...
stackexchange/codereview
I have Apache running on a public-facing Debian server, and am a bit worried about the security of the installation. This is a machine that hosts several free-time hobby projects, so none of us who use the machine really have the time to constantly watch for upstream patches, stay aware of security issues, etc. But I w...
stackexchange/codereview
Possible duplicate Windows Forms application like Google Chrome with multiple processes Chrome / IE8 multi-process design, is it possible in .NET? Sample for Multi-process C# app like Google Chrome Both IE8 and Google Chrome browser have separate processes for each tab that is opened. For example, you launch IE8 and ...
stackexchange/codereview
I have two tables say, t1 and t2 that have t1.t1_id and t2.t2_id as primary keys. They are related by table t3 with columns t3.t1_id and t3.t2_id, respectively. Using LINQ I get an EntitySet<t3> on class t1 and t2, but what I want is an EntitySet<t2> on class t1 and EntitySet<t1> on class t2. How do I do this?
stackexchange/codereview
I have a branch in an SVN tree which contains the source to a third party product. I need to update that branch with the latest version. If I check it out and copy the new source over the old source, I can easily add the new files and do a commit. However, I would also like make sure that any files that are the old ver...
stackexchange/codereview
Having a bit of trouble with the syntax where we want to call a delegate anonymously within a Control.Invoke. We have tried a number of different approaches, all to no avail. For example: myControl.Invoke(delegate() { MyMethod(this, new MyEventArgs(someParameter)); }); where someParameter is local to this method The ...
stackexchange/codereview
I'd like to post some form variables into a classic ASP page. I don't want to have to alter the classic ASP pages, because of the amount of work that would need to be done, and the amount of pages that consume them. The classic ASP page expects form variables Username and Userpassword to be submitted to them. username ...
stackexchange/codereview
This is a follow-up to a previous question I had about interfaces. I received an answer that I like, but I'm not sure how to implement it in VB.NET. Previous question: Should this property be part of my object's interface? public interface Foo{ bool MyMinimallyReadOnlyPropertyThatCanAlsoBeReadWrite {get;} } How can...
stackexchange/codereview
I have two databases, one is an MS Access file, the other is a SQL Server database. I need to create a SELECT command that filters data from the SQL Server database based on the data in the Access database. What is the best way to accomplish this with ADO.NET? Can I pull the required data from each database into two ne...
stackexchange/codereview
I'm new to the VxWorks Environment are there any good sources of information out there?
stackexchange/codereview
I need a modal dialog to gather some user input. I then need the same data to be consumed by the application MainFrame. Usually my Modal Dialog would have a pointer to some DataType able to store what I need, and I'd be passing this object by reference from the MainFrame in order to be able to recover data once the mo...
stackexchange/codereview
Scenario is that we send out thousands of emails through SMTP server. Content is created in advance and picked up when sent. The thing is we want to find where our bottlenecks are in production environment and where work needs to be done. Goal is to be able to send half a million emails in ten minutes*. Should we c...
stackexchange/codereview
I have created a class for a dashboard item which will hold information such as placement on the dashboard, description, etc. I am currently using a pair of Collections to hold those dashboard items contained in the "library" and those items showing on the dashboard itself. I have been asked to make this dashboard mu...
stackexchange/codereview
Is there a way to resize a std::vector to lower capacity when I no longer need previously reserved space?
stackexchange/codereview
Can anyone give me pointers to good books or web sites that teach how to do Flex programming?
stackexchange/codereview
I have to generate two random sets of matrices Each containing 3 digit numbers ranging from 2 - 10 like that matrix 1: 994,878,129,121 matrix 2: 272,794,378,212 the numbers in both matrices have to be greater then 100 and less then 999 BUT the mean for both matrices has to be in the ratio of 1:2 or 2:3...
stackexchange/codereview
after hours of searching on the net I'm quite desperate to find solution for this. I've up & running OGG Theora decoder in DirectShow which ouputs YV12 and YUY2 color models. Now, I want to make a RGB pixel manipulation filter for this output and to process it into video renderer. According to this and this, it shoul...
stackexchange/codereview
Would it be possible to define layouts depending on the report type? ie. The layout size for PDFs would be different from the web layout. Let's say we publish the report to the web. The user has the option of exporting this custom report to PDF. We want to be able to specify how the report should look like when exporte...
stackexchange/codereview
I am trying to setup tracd for the project I am currently working on. After creating a password file with the python script given in the site I am trying to start the server with authentication on. But it throws up warning saying No users found in the realm. What actually is a realm - I tried using trac as the value an...
stackexchange/codereview
I work for a small digital marketing company as a programmer, and we are not a Microsoft partner or any sort (Gold/Silver/Bronze). However, we use .NET. What I am confused about is that the developer before me has left, and he gets subscription DVDs of latest Microsoft tools, delivered to the company (Sql Server etc). ...
stackexchange/codereview
I'm working on a program to do some image wrangling in Python for work. I'm using FreeImagePy because PIL doesn't support multi-page TIFFs. Whenever I try to save a file with it from my program I get this error message (or something similar depending on which way I try to save): Error returned. TIFF FreeImage_Save: ...
stackexchange/codereview
I'm working on a program that is form based but I have been asked to add some command line support, this works fine apart from the form flashes up and closes down when running from the command line. Is there anyway to hide the form whilst the command line is running? Some code does refer to controls so the gui would ne...
stackexchange/codereview
How do I check if a number is a palindrome? Any language. Any algorithm. (except the algorithm of making the number a string and then reversing the string).
stackexchange/codereview
I'm addicted to Vim, it's now my de facto way of editing text files. Being that it's mainly a text editor and not an IDE, has anyone got tricks for me to make it easier when developing Java apps? Some questions I have: How do I invoke a maven task without leaving vi? Can I get code completion? How's the syntax highlig...
stackexchange/codereview
I'm using Jython to write tests for a Java project. It works well, but I can't figure how to get access to a java public nested class. package mypackage; public class NyClass { public class MyNestedClass { ... } } Does somebody knows how to do this?
stackexchange/codereview
I'm developing my first Word 2007 addin, and I've added an OfficeRibbon to my project. In a button-click handler, I'd like a reference to either the current Word.Document or Word.Application. I'm trying to get a reference via the OfficeRibbon.Context property, which the documentation says should refer to the current Ap...
stackexchange/codereview
I'll preface this by saying that I usually work in C#/.Net. Normally, I use a naming scheme that puts common, reusable components into a namespace that reflects our organization and project-specific components into a namespace tied to the project. One of the reasons I do this is that I sometimes share my components wi...
stackexchange/codereview
I am starting new project with SqlServer and Linq to Sql. What data type would be better for surrogate keys in tables: identity or uniqueidentifier ? As I understood, identity is automatically generated on insert, while uniqueidentifier should be generated in code (GUID). Are there any significant performance differe...
stackexchange/codereview
I have a VB application which extracts data and creates 3 CSV files (a.csv, b.csv, c.csv). Then I use another Excel spreadsheet (import.xls) to import all the data from the above CSV files into this sheet. import.xls file has a macro which opens the CSV files one by one and copies the data. The problem I am facing is t...
stackexchange/codereview
This might be a little hard to explain, but I will try. I want to display a list of categories (stored in 1 table), and number of domains associated with each category (stored in another table). The monkey wrench in this case is that each domain has a set of records associated with it (which are stored in a 3rd table)...
stackexchange/codereview
I'm trying to see if the user has pressed a decimal separator in a text box, and either allow or suppress it depending on other parameters. The NumberdecimalSeparator returns as 46, or '.' on my US system. Many other countries use ',' as the separator. The KeyDown event sets the KeyValue to 190 when I press the period....
stackexchange/codereview
How can I setup a default value to a property defined as follow: public int MyProperty { get; set; } That is using "prop" [tab][tab] in VS2008 (code snippet). Is it possible without falling back in the "old way"?: private int myProperty = 0; // default value public int MyProperty { get { return myProperty; } s...
stackexchange/codereview
Preface I'm using the newly released Microsoft Virtual Earth SDK v6.2 which has built-in support for pushpin clustering. I realize there are custom ways of doing clustering where my question is easy to answer, but I'd like to leverage the built-in support as much as possible, so this question is specifically related t...
stackexchange/codereview
I've been using the macro from this blog entry for attaching the Visual Studio debugger to an already running instance of the Web Application I'm currently working on. However, if I have more than one instance of the Visual Studio web server running it's pot luck which one it'll attach to. Is there a way to determine w...
stackexchange/codereview
I currently have a Visual Studio solution with 8 web applications. When I try run one of these applications, 8 instances of the Casini Web Development Servers are launched. Is there anyway to specify that only the web application I have set as startup project will be launched and not all 8. I am using Visual Studio 200...
stackexchange/codereview
Can someone explain how XSS works in plain english? Maybe with an example. Googling didn't help much.
stackexchange/codereview
I've seen several responses to questions asking for IDEs where text editors were suggested and vice-versa. That makes me think that people treat them as the same thing, where I draw clear distinctions. How do you define "text editor" and "IDE"? Do you see a difference between the two tools? Note that I accepted an an...
stackexchange/codereview
Does Geronimo provides a standalone transaction manager? And if it does, is it possible to use it in Tomcat?
stackexchange/codereview
I am using prototype and I can't find any built in extensions to set or retrieve cookies. After googling for a little bit, I see a few different ways to go about it. I was wondering what you think is the best approach for getting a cookie in JavaScript?
stackexchange/codereview
I'm looking for the concept to spawn a process such that: it has only access to certain libraries/APIs it cannot acess the file system or only specific parts it can do least harm should malicious code run in it This concept is known as sandbox or jail. It is required to do this for each major Operating system (Window...
stackexchange/codereview
System.InvalidOperationException: DragDrop registration did not succeed. ---> System.Threading.ThreadStateException: What does this exception mean? I get it at this line trying to add a panel to a panel at runtime... splitReport.Panel1.Controls.Add(ChartPanel); Working in VS2008 C#
stackexchange/codereview
I'm new to the VxWorks environment, I'm wondering what C and C++ compilers are available for use with VxWorks?
stackexchange/codereview
Does a tool exist for dynamically altering running javascript in a browser? For example, to change the values of javascript variables during runtime.
stackexchange/codereview
From the documentation that I have read so far, ADO.Net data services is positioned as way of exposing a CRUD like interface to tables in a database in a RESTful way. This is great for applications that only do those four operations, but what about applications that do more? What about verbs like Print, Approve, Submi...
stackexchange/codereview
I need to generate an XML file in C#. I want to write the code that generates this in a file that is mostly XML with code inside of it as I can in an ASP.NET MVC page. So I want a code file that looks like: <lots of angle brackets...> <% foreach(data in myData) { %> < <%= data.somefield %> <% } %> M...
stackexchange/codereview
I'd like to use Oracle's utl_match.edit_distance function. It supposed to compare two strings and return the Levenshtein distance. select utl_match.edit_distance('a','b') from dual returns 1 as expected, but select utl_match.edit_distance('á','b') from dual returns 2. Obviously I'd like to get 1. It seems to be, it d...
stackexchange/codereview
In SQL Server, why is this: [dbo].[table_name] preferable to this: dbo.table_name And along those lines, why even list the dbo at all if there's only one schema?
stackexchange/codereview
I am new to SVN and make heavy use of the externals property. I have a repository located on my PC and the externals properties have a hardcoded 'localhost' in the name, which is now giving me problems. For example: /project1/trunk /shared/trunk project1/trunk depends on the shared folder so has an svn:externals pro...
stackexchange/codereview
pl give vb code for custom paging and sorting in asp:repeater using stored procedure
stackexchange/codereview
I have now 1gb ram at work(i hope that will change soon) and jboss takes almost half of it and that is too much, i turned off logging to file, what more can i do to reduce memory usage ?
stackexchange/codereview
Is user profiles an appropriate place to store things like number of items per page in a custom grid user selected? (I you can store it in the view, but it won't be per user this way). My first though was to store these settings in user profiles, but there are problems with access permissions for programmatically creat...
stackexchange/codereview