instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>It strikes me that Properties in C# should be use when trying to manipulate a field in the class. But when there's complex calculations or database involved, we should use a getter/setter.</p>
<p>Is this correct?</p>
<p>When do you use s/getter over properties?</p>
| <p>The .NET design guidelines provide some answers to this question in the <a href="http://msdn.microsoft.com/en-us/library/bzwdh01d(VS.71).aspx#cpconpropertyusageguidelinesanchor1" rel="noreferrer">Properties vs. Methods</a> section.</p>
<p>Basically, properties have the same semantics as a field. You shouldn't let ... | <p>Forget the Getter and Setter methods. Just use Properties. </p>
<p>An interesting thing to mention is that Properties are ending up as Setter and/or Getter method(s) in the assembly. Setter and/or Getter become a Property just by a little bit of metadata. So in fact, properties = setter/getter methods.</p>
| 9,264 |
<p>I'm attempting to bind a <code>DependancyProperty</code> in one of my usercontrols to the <code>Width</code> property of a <code>Column</code> in a <code>Grid</code>. </p>
<p>I have code similar to this:</p>
<pre><code><Grid x:Name="MyGridName">
<Grid.ColumnDefinitions>
<ColumnDefinition... | <p>Well I have got a bit of a kludge working, I'll explain how for future generations:</p>
<p>Essentially I have a 2 column, multi row grid with a splitter right aligned in the first column so it can be resized by the user if the content it contains requires more space. To complicate things I have a user control being... | <p>Have you tried setting up the binding in xaml, the following should work for you.</p>
<pre><code><ColumnDefinition
x:Name="TitleSection"
Width="{Binding
Path=TitleWidth,
RelativeSource={RelativeSource AncestorType=MyUserControl}}"
/>
</code></pre>
<p>Otherwise... | 36,292 |
<p>Take this code:</p>
<pre><code><?php
if (isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
}
if ($action) {
echo $action;
}
else {
echo 'No variable';
}
?>
</code></pre>
<p>And then access the file with ?action=test
Is there any way of preventing $action... | <p>Check your php.ini for the <code>register_globals</code> setting. It is probably on, you want it off.</p>
<blockquote>
<p>Why would I want the variable to be declared for me?</p>
</blockquote>
<p><a href="http://us3.php.net/manual/en/security.globals.php" rel="nofollow noreferrer">You don't.</a> It's a horrible ... | <p>You can test, whether all variables are declared properly by turning the PHP log-level in PHP.INI to </p>
<pre><code>error_reporting = E_ALL
</code></pre>
<p>Your code snippet now should generate a NOTICE. </p>
| 12,736 |
<p><strong>The Setup:</strong></p>
<p>I'm working on a website that uses <code>Formsauthentication</code> using cookies to store the login ticket. The site also has an <code>HTTPHandler</code> that manages images stored in the database. The handler caches the images to be public and expire in 20 minutes. We have no... | <p>We are assuming the cookie is in the Response Header and is writing out the same cookie that exist on Person A's machine to Person B. Its important to note that this issue occured with Person A in IE 7 and Person B in FireFox. Also when Person A logged out it logged out Person B was logged out as well since the Fo... | <p>Why does Person B get Person A's cookie? I'm assuming you mean Person B's session cookie is being associated with A's login ID. That's the nub of the problem.</p>
<p>It sounds to me that A's login ID is being stored in a place that could cross requests -- such as a temp file or in the DB -- without associating it... | 33,008 |
<p>We have a junior programmer that simply doesn't write enough tests.<br>
I have to nag him every two hours, "have you written tests?"<br>
We've tried:</p>
<ul>
<li>Showing that the design becomes simpler</li>
<li>Showing it prevents defects</li>
<li>Making it an ego thing saying only bad programmers don't</li>
<li>T... | <p>This is one of <em>the hardest things</em> to do. Getting your people to <em>get it</em>.</p>
<p>Sometimes one of the best ways to help junior level programmers 'get it' and learn the right techniques from the seniors is to do a bit of pair programming.</p>
<p>Try this: on an upcoming project, pair the junior guy... | <p>Based on your comment, "Showing that the design becomes simpler" I'm assuming you guys practice TDD. Doing a code review after the fact is not going to work. The whole thing about TDD is that it's a design and not a testing philosophy. If he didn't write the tests as part of the design, you aren't going to get a ... | 2,888 |
<p>I'm sure you've all seen them. Line of Business UIs that have logic such as: "When ComboA is selected, query for values based on that selection, and populate Textbox B", or "When ButtonC is pressed, disable Textboxes C and D", and on and on ... it gets particularly bad when you can have multiple permutations of the... | <p>Something you might want to look at is whether some of those dependencies don't imply that while looking similar and serving the same functions these elements should be split out over multiple pages that are similar but actually different. Someone maybe grouped these onto on page because there were enough similariti... | <p>Start with the KISS principle, and work from there. Don't over-engineer the solution, and try to think about the problem from the user's POV. Your first impression of what would make a good layout is probably close to what you should be building, as a good UI is intuitive. </p>
<p>That being said, single screen ver... | 41,525 |
<p>can anybody show me how to build a string using checkbox. what would be the best way to do this.</p>
<p>for example i have 4 checkbox's each with its own value (valueA, valueB, valueC, valueD)
the thing is i want to display each result in different lines.</p>
<p>result if B & C is selected : </p>
<p>valueB <b... | <p>Use a StringBuilder to build the string, and append Environment.NewLine each time you append:</p>
<pre><code>StringBuilder builder = new StringBuilder();
foreach (CheckBox cb in checkboxes)
{
if (cb.Checked)
{
builder.AppendLine(cb.Text); // Or whatever
// Alternatively:
// builder.... | <pre><code>"if I saved this into a database" ?
</code></pre>
<p>You'll need to be a bit more specific with your homework assignments if you're actually going to receive any help here ... </p>
<p><strong>Edit:</strong> ok, it <em>might</em> not be homework but it certainly read like it - after all, manipulating a GUI... | 28,809 |
<p>Lately I've been in the habit of assigning integer values to constants and simply using the constant name as a means of identifying its purpose. However, in some cases this has resulted in the need to write a function like typeToString($const) when a string representation is needed. Obviously this is inefficient and... | <p>The performance difference will be negligible unless you're storing a lot of them.
I'd write the <code>toString()</code> method more concisely:</p>
<pre><code>$strings = array
(
self::USER_TYPE_ADMIN => 'admin',
self::USER_TYPE_USER => 'user',
);
if (!isset($strings[$type]))
return 'unknown';
re... | <p>In the example you write you could drop all the methods and make the class static and you would have created your self an Enumerator. Like this:</p>
<pre>
class Enumeration{
public static const One=1;
public static const Two=2;
public static const Three=3;
}
</pre>
<p>One other handy way to use constants is... | 30,803 |
<p>I need to add a specific column if it does not exist. I have something like the following, but it always returns false:</p>
<pre><code>IF EXISTS(SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'myTableName'
AND COLUMN_NAME = 'myColumnName')
</code></pre>
<p>How ... | <p>SQL Server 2005 onwards:</p>
<pre><code>IF EXISTS(SELECT 1 FROM sys.columns
WHERE Name = N'columnName'
AND Object_ID = Object_ID(N'schemaName.tableName'))
BEGIN
-- Column Exists
END
</code></pre>
<p>Martin Smith's version is shorter:</p>
<pre><code>IF COL_LENGTH('schemaName.tableName', 'c... | <pre><code>IF EXISTS(SELECT 1 FROM sys.columns
WHERE Name = N'columnName'
AND Object_ID = Object_ID(N'schemaName.tableName'))
</code></pre>
<p>This should be the fairly easier way and straightforward solution to this problem. I have used this multiple times for similar scenarios. It works like a charm, no d... | 16,109 |
<p>I have been bitten by a poorly architected solution. It is not thread safe! </p>
<p>I have several shared classes and members in the solution, and during development all was cool...<br>
BizTalk has sunk my battle ship. </p>
<p>We are using a custom BizTalk Adapter to call my assemblies. The Adapter is calling ... | <p>Using app domains you could do something like this:</p>
<pre><code>public class Loader
{
private string connectionString;
private string fileName;
private Stream stream;
private DataFile dataFile;
public Loader(Stream stream, string fileName, string connectionString)
{
this.connect... | <p>Why not just put a lock around the code you want to execute sequentially?
It will be a bottleneck, but it should work in a multithreaded environment.</p>
<pre><code>public class Loader
{
private static object SyncRoot = new object();
private string connectionString;
private string fileName;
private... | 39,542 |
<p>I'm writing a custom swing component (something completely new, but think JTree or JList). I'm trying to follow the general design of JTree, JTable, JList etc for consistency (I've also seen various poor 3rd party components abandon the separable model and/or renderer approach).</p>
<p>So, I have a model full of no... | <p>Good question. This is not specific to Swing, but a philosophical question about the difference between a model and a view.</p>
<p>In general, is converting objects into text the job of the model or the view? My purist head says that actually you want a hierarchy of views - one to convert object model to text, and ... | <p>AFAIK neither JList nor JTree require the renderer to render text. The renderer gets passed the data object and return a JComponent which gets positioned as a child in Tree/List itself and then rendered.<br>
I would go with this. A renderer for text would simply return a JLabel. If you want to be able to change the ... | 26,433 |
<p>I'm running into a mental roadblock here and I'm hoping that I'm missing something obvious.</p>
<p>Anyway, assume I have a table that looks like this:</p>
<pre>
ID LookupValue SortOrder
============================================
1 A 1000
2 B ... | <p>Key is a string.</p>
<p>Key.Count counts the characters in the string.</p>
<hr>
<p>Change the select to include the group</p>
<pre><code>Select Key, SortOrder, Group
</code></pre>
<p>and change the where clause to count the group</p>
<pre><code>KeySortPairs.Where(Function(t) t.Group.Count() > 1)
</code></pr... | <p>I think you need a groupby in your for each statement.</p>
<p>Try something like</p>
<pre><code>For Each Entry in KeySortPairs.GroupBy(expression).Where(
</code></pre>
| 24,086 |
<p>How to put underline for first letter for access key for ?</p>
| <p>asp:buttons are output as html "input" tags with a type of "submit". The text displayed on them is output in the "value" attribute of the tag, and so cannot contain any styling or html. If you could get an asp:button to output as an html button then you could try something like:</p>
<pre><code><button id="mybutt... | <p>Tried the AccessKey attribute?</p>
<pre><code><asp:button id="Button1" runat="server" Text="Print" AccessKey="P" />
</code></pre>
<p>If it is really underlined is out of your control. The user agent (e.g. browser) is deciding that.</p>
| 27,224 |
<p>I need to create at runtime instances of a class that uses generics, like <code>class<T></code>, without knowing previously the type T they will have, I would like to do something like that:</p>
<pre><code>public Dictionary<Type, object> GenerateLists(List<Type> types)
{
Dictionary<Type, ob... | <p>You can't do it like that - the point of generics is mostly <em>compile-time</em> type-safety - but you can do it with reflection:</p>
<pre><code>public Dictionary<Type, object> GenerateLists(List<Type> types)
{
Dictionary<Type, object> lists = new Dictionary<Type, object>();
foreac... | <p>Depending on how often you're calling this method then using Activator.CreateInstance could be slow. Another option is to do something like this:</p>
<p>private Dictionary> delegates = new Dictionary>();</p>
<pre><code> public Dictionary<Type, object> GenerateLists(List<Type> types)
{
D... | 28,965 |
<p>This is a very basic question. I'm just on my mission to learn ASP.NET (C#). I've done classic ASP and PHP before.</p>
<p>For this project I have <strong>ASP.NET 2.0</strong> at my hands.</p>
<p>I have a Web Form that has a <a href="http://www.trirand.com/blog/" rel="nofollow noreferrer">jqGrid</a> Datagrid that I... | <p>Using System.Xml (or System.Xml.Linq) would be less overhead in terms of getting it right than hand-coding Response.Write and making sure you quote everything you need to, sort out the encoding etc. Why would you want to reinvent the wheel?</p>
<p>Create a new ashx instead of aspx page, create the appropriate XmlDo... | <p>working example of test.ashx:</p>
<pre><code><%@ WebHandler Class="XMLHandler" %>
Imports System.Xml
Public Class XMLHandler : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context as HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/xml"
Dim input a... | 48,983 |
<p>I have a process that reads an XML file. It uses the XMLTextReader class to do this as it is supposed to be a fast, forward only XML parser/reader.</p>
<p>Works just great with a 1 megabyte test file but comes to a complete halt when working on a 12 meg file in the live system.</p>
<p>Are there any solutions to th... | <p><a href="http://sourceforge.net/project/showfiles.php?group_id=95340" rel="nofollow noreferrer">SAXExpat</a> used to be really good. Expat is <em>the</em> XML parser, almost a reference implementation. I remember using it to read some synchronization XML files sent over a TCP connection, sometimes really big files (... | <p>I have had similar performance issues in the past. I traced it back to trying to remotely resolve against a DTD/schema. Are you doing this? Try setting XmlTextReader.XmlResolver to null if possible.</p>
| 19,609 |
<p>What libraries can I use to build a GUI for an Erlang application? Please one option per answer.</p>
| <p>Most people don't code the actual GUI in Erlang. A more common approach would be to write the GUI layer in Java or C# and then talk to your Erlang app via a socket or pipe.</p>
<p>With that in mind, you probably want to look into various libraries for doing RPC between java or .Net applications and Erlang:</p>
<p... | <p>I'm not sure there are any... but I found <a href="http://erlbol.dougedmunds.com/" rel="nofollow noreferrer">Erlbol</a> on the web, and a <a href="http://projects.openmoko.org/forum/forum.php?forum_id=397" rel="nofollow noreferrer">X11 GUI</a> which sounds interesting, and <a href="http://www.erlang.se/euc/05/1620cr... | 12,301 |
<p>Is there anyway to change the length of the field that Sharepoint uses to store URLs. Its default is 255, which is just not long enough to hold links to content within the sharepoint site.</p>
| <p>No, this is a hard limit in SharePoint. Studying the schema of the content database reveals the limit originates from the primary key columns DirName and LeafName in the AllDocs table.</p>
<p>I recently worked on a project where this problem also surfaced because users tended to create deep folder structures with l... | <p>I've no idea how to solve this, I am having exactly the same problem, I found a hotfix for MOSS which will not work for WSS v3, it proposes to increase the length of the hyperlink field but is not compatable with WSSv3. It's a shame really.</p>
| 44,365 |
<p>I have a user script that would be much more useful if it could dynamically change some of its execution dependent on what the user wanted. Passing simple switches would easily solve this problem but I don't see any way to do it.</p>
<p>I also tried embedding a keyword in the script name, but <em>Xcode</em> copies ... | <p>You can't pass parameters to user scripts — instead, user scripts operate on the context you're working in (e.g. the selected file, the selected text, etc.).</p>
<p>You should use the context to determine what the user really wants.</p>
| <p>User scripts are accessible via the script menu in Xcode's menubar (between the Window and Help menus). Wasn't sure what else to call them. What I'm asking about are not "run script" build phase scripts.</p>
| 6,974 |
<p>What number would you give someone who wants a concrete target number for API code coverage?</p>
<p>UPDATE: To clarify, statement/line code coverage. I realize concrete numbers don't make much sense, but this is for the situation where you tell people that concrete numbers don't make much sense and they still insis... | <p>Putting <code>*args</code> and/or <code>**kwargs</code> as the last items in your function definition’s argument list allows that function to accept an arbitrary number of arguments and/or keyword arguments.</p>
<p>For example, if you wanted to write a function that returned the sum of all its arguments, no matter ... | <p>Just to clarify how to unpack the arguments, and take care of missing arguments etc.</p>
<pre><code>def func(**keyword_args):
#-->keyword_args is a dictionary
print 'func:'
print keyword_args
if keyword_args.has_key('b'): print keyword_args['b']
if keyword_args.has_key('c'): print keyword_args['c']
de... | 36,514 |
<p>New to javascript/jquery and having a hard time with using <code>this</code> or <code>$(this)</code> to get the current object.</p>
<p>I have a table with a set of <code>radio buttons</code> on each row, each named <code>s_<rowindex></code>. None of the radio buttons are checked by default:</p>
<pre><code>&l... | <p>This will get you the index, using the HTML you've provided:</p>
<pre><code>$(document).ready(function() {
$("input:radio").click(function() {
var index = parseInt(this.name.split('_')[1])
});
});
</code></pre>
<p>Another thing that may help you: retrieving the number of rows in your table:</p>
<p... | <p>Here's some untested code, off the top of my head:</p>
<pre><code>$("#div_s_0 input[type='radio']").onclick = function() {
if ($("#div_s_0 input[type='radio']:last").attr('checked') == 'checked') {
/* add a new element */
}
}
</code></pre>
<p>What that does is attach an onclick event to each of the rad... | 25,763 |
<p>How can I use reflection to create a generic List with a custom class (List<CustomClass>)? I need to be able to add values and use
<code>propertyInfo.SetValue(..., ..., ...)</code> to store it. Would I be better off storing these List<>'s as some other data structure?</p>
<p>Edit:</p>
<p>I should have s... | <pre><code>class Foo
{
public string Bar { get; set; }
}
class Program
{
static void Main()
{
Type type = typeof(Foo); // possibly from a string
IList list = (IList) Activator.CreateInstance(
typeof(List<>).MakeGenericType(type));
object obj = Activator.CreateInsta... | <p>Here's an example of taking the List<> type and turning it into List<string>.</p>
<p>var list = typeof(List<>).MakeGenericType(typeof(string));</p>
| 40,696 |
<p>What is the best way to get started with programming things outside of your computer? </p>
<p>I don't mean mainstream things like cell phones with APIs.</p>
<p>Please assume working knowledge of C/C++</p>
| <p>Brian, you might find the <a href="http://www.arduino.cc/" rel="nofollow noreferrer">Arduino</a> interesting. It is inexpensive and pretty popular. I started playing around with micro controller boards and such a few years back and that lead to an interest in robots. Kind of interesting, at least to me.</p>
<p>I... | <p>There are a lot of programmable robots around. In fact, even some of the Roombas (automated vacuums) can be programmed. This is particularly good if you want to teach kids how to program. </p>
| 17,457 |
<h1>Example</h1>
<p>There is an application that measures temperature in each town of the world. Each measurement is taken every 5 minutes and written in to the Measurement table.</p>
<pre><code>CREATE TABLE [dbo].[Measurement](
[MeasurementID] [int] IDENTITY(1,1) NOT NULL,
[Town] [varchar](50) NOT NULL,
[D... | <p>Here are a couple that should work: </p>
<p>SELECT<br>
m1.Town, m1.Temp<br>
FROM<br>
Measurement AS m1<br>
LEFT JOIN<br>
Measurement AS m2<br>
ON<br>
m1.Town = m2.Town<br>
AND m1.Date < m2.Date<br>
WHERE<br>
m2.MeasurementID IS NULL<br>
ORDER BY m1.Town</p>
<hr>
<p>You'll need an index... | <pre><code>select s.*
from Measurement s
where exists (
select 1
from Measurement s1
where s.Town = s1.Town
group by s1.Town
having max( s1.Date )= s.Date)
order by s.Town
</code></pre>
| 37,915 |
<p>I am using the following code to set a tray icon in Windows and Linux. It works wonderful in Windows and works okay in Linux. In Linux (Ubuntu) I have my panel set to be (somewhat) transparent and when I add a GIF (with a transparent background) the background of the icon shows up all grey and ugly (see image, green... | <p>The problem lies in the sun.awt.X11.XTrayIconPeer.IconCanvas.paint() method!</p>
<p>Before painting, the icon background is amateurishly cleared by simply drawing a rectangle of IconCanvas’ background color, to allow image animations.</p>
<pre><code>public void paint(Graphics g) {
if (g != null && curW... | <p>Have you tried converting it to a .PNG (with transparency) instead? I've found they tend to be better supported by Java (In my experience)</p>
| 42,939 |
<p>In my php script which connects to mysql, I have to query 2 databases in the same script to get different information. More specifically Faxarchives in one database and Faxusers in the other. </p>
<p>In my code I query faxusers and then foreach user, I query Faxarchives to get the user history. </p>
<p>I might d... | <p>You have several problems. First, your function, getUserarchive, pulls back all rows all the time. Looks like you forgot to restrict your SQL to only a specific userid. That's a big cause of your speed issues.</p>
<p>Another option would be to pass in all userids you are interested in. Rewrite the SQL as SELECT... | <p>Are you aware that you can query tables in separate databases by qualifying the tablename?</p>
<p>For example, I think you can get all your information in a single SQL query like this:</p>
<pre><code>SELECT sent, received
FROM Faxarchive.faxarchivetable
WHERE userid IN ( SELECT DISTINCT userid FROM Faxusers.faxus... | 39,859 |
<p>I have a table like this:</p>
<pre><code><table>
<tfoot>
<tr><td>footer</td></tr>
</tfoot>
<tbody>
<tr><td>Body 1</td></tr>
<tr><td>Body 1</td></tr>
<tr><td>Body 1&... | <p>Try this, if you don't mind not having borders.</p>
<pre><code><style>
table {
border-collapse: collapse;
}
table tbody {
border-top: 15px solid white;
}
</style>
<table>
<tfoot>
<tr><td>footer</td></tr>
</tfoot>
<tbody>
&... | <h2>NEW ANSWER</h2>
<p>You can use as many <code><tbody></code> tags as you like. I didn't realize that was ok by W3C until now. Not to say my below solution doesn't work (it does), but to do what you're trying to do, assign your <code><tbody></code> tags classes and then reference their individual <code>&... | 37,648 |
<p>I have a specialized list that holds items of type <code>IThing</code>:</p>
<pre><code>public class ThingList : IList<IThing>
{...}
public interface IThing
{
Decimal Weight { get; set; }
Decimal Velocity { get; set; }
Decimal Distance { get; set; }
Decimal Age { get; set; }
Decimal Anothe... | <p>(Edited to reflect .NET 2.0 answer, and LINQBridge in VS2005...)</p>
<p>There are three situations here - although the OP only has .NET 2.0, other people facing the same problem may not...</p>
<p>1) Using .NET 3.5 and C# 3.0: use LINQ to Objects like this:</p>
<pre><code>decimal maxWeight = list.Max(thing => t... | <blockquote>
<p><del>Conclusion: There is no better way for .Net 2.0 (with Visual Studio 2005).</del></p>
</blockquote>
<p><del>You seem to have misunderstood the answers (especially Jon's). You can use option 3 from his answer.</del> If you don't want to use LinqBridge you can still use a delegate and implement the... | 18,414 |
<p>I would like to do this:</p>
<pre><code>[RequiresAuthentication(CompanyType.Client)]
public class FooController
{
public ActionResult OnlyClientUsersCanDoThis()
public ActionResult OnlyClientUsersCanDoThisToo()
[RequiresAuthentication]
public ActionResult AnyTypeOfUserCanDoThis()
</code></... | <p>We're looking into a way to expose other filters, but no promises.</p>
<p>Applying a filter to the controller isn't really a "scope", it's merely a short-hand for applying it to all filters. Unfortunately, that means you can't include all but one action. One simple way you could do this is to put that one method in... | <p>you can put authorisation logic into the OnActionExecuting(..) method of the Controller, i.e.</p>
<pre><code>public override void OnActionExecuting(ActionExecutingContext filterContext) {
base.OnActionExecuting(filterContext);
new RequiresAuthentication()
{ /* initialization */ }.OnActionExecuting(filte... | 34,527 |
<p>What is the best breakdown of responsibility when using a virtual grid and the MVP pattern in a winforms application.</p>
<p>including:</p>
<ol>
<li>Getting callbacks from the grid on user changed cell updates</li>
<li>Callback from the grid to set the style and value of a cell given a row and column</li>
</ol>
| <p>The exact responsibilities in the many patterns that are referred to as Model-View-Presenter vary. Mainly they vary about how much control is exerted over the view by the presenter. Martin Fowler has an in depth discussion of a number of different variants in his chapter on <a href="http://martinfowler.com/eaaDev/ui... | <p>If I understand you correctly, the grid is part of the view implementation and is not visible to the presenter. In that case, the presenter should not need to know how the data is displayed, only how to provide them.</p>
<p>I would probably create a helper class, an adapter of some sort, which the grid communicates... | 23,581 |
<p>Besides the DateTime ctor (new DateTime(year, month, day)) , is there any other way to truncate a date?</p>
| <p><a href="http://msdn.microsoft.com/en-us/library/system.datetime.date.aspx" rel="noreferrer">DateTime.Date</a></p>
<p>Returns just the date component (the time is midnight).</p>
| <pre><code>DateTime.Now.ToShortDateString();
</code></pre>
<p>Also, ToString() is overloaded in DateTime, you can pass a few dozen formatting options to it.</p>
<p>See:
<a href="http://authors.aspalliance.com/aspxtreme/sys/demos/datetimeformats.aspx" rel="nofollow noreferrer">http://authors.aspalliance.com/aspxtreme/... | 31,456 |
<p>When you're using a factory pattern, how do you inject dependencies into constructors at runtime?</p>
<p>I'm building Foos with different formats - boolean, array, freetext, matrix, etc. That format list will grow as we find different uses for Foo. Here's my basic core domain:</p>
<pre><code>public interface IFo... | <p>Maybe you can do something along these lines where your abstract FooFormat becomes IFooFormat and a generic FooFormat provides an Init method that gets passed the parameter.</p>
<p>Then a single overload of Build lets you pass in the parameter.</p>
<pre><code>public interface IFooFormat
{
}
public class FooFormat... | <p>A factory is basically the object oriented version of a static variable. I'd avoid using one alltogether. Instead of forcing clients to use a factory, perhaps you can simply inject objects into their constructors, sidestepping the need for a factory.</p>
| 48,794 |
<p>I just saw this question:</p>
<p><a href="https://stackoverflow.com/questions/353968/understanding-nets-securityaction-parameter-for-permissions">Understanding .NET’s “SecurityAction” parameter for permissions</a></p>
<p>And I have a question. With the following code:</p>
<pre><code>private void button1_Click(obj... | <p>Calling .Deny() on a CodeAccessPermission will cause the .NET Security runtime to set the deny flag on the security object for the current stack frame for that permission.
So even if you call GC.Collect() after calling .Deny(), it doesn't really matter, the permission will stay in effect. The permission object is j... | <p>Upon first look, I would guess that the permission object is still in scope, as it is defined inside the method, it falls out of scope after the completion of the Layer2 method, thus allowing the last line of your application to function.</p>
<p>As noted by the accepted answer, this is becuase it is in scope for th... | 46,179 |
<p>I'm implementing a plugin architecture to implement authentication an external authentication mechanism for a web site. One of the plugins I plan to provide is an ActiveDirectory plugin. I'd like to implement some of the features of a MembershipProvider, including MinRequiredPasswordLength, but don't want to fully... | <p>The root of the domain has a property called "minPwdLength" There are several other attributes related to password policy (minPwdAge, maxPwdAge, lockoutDuration, etc)</p>
<p>In a Windows Server 2008 Domain with Fine Grained Password policy this get's more complicated though since you can have different password po... | <p>just a hint: I use DirectorySearcher (System.DirectoryServices) to query the ActiveDirectory, I don't kbow if there is a way to query what you're looking for...</p>
<p>Hope it helps</p>
| 27,990 |
<p>I am running a site about PHP Frameworks, but I can't find a exact definition for it, and I am always thinking a question, how to make out a good PHP framework? Features? Manual? Efficiency? Or something?</p>
| <p>Asking a programming forum what is a good framework is like asking a car forum what is a good car. The opinions vary wildly, and in 95% of cases, it really doesn't matter what you choose, as long as it's actively developed. Most of your replies will be based on religion and not subjective comparisons. :)</p>
| <p>PHP framework is a library that makes the life of site developer easier by for example hiding some complexities of HTTP protocol or by adding some useful functions.
For example the <a href="http://www.cakephp.org/" rel="nofollow noreferrer">CakePHP</a> implements so called <a href="http://en.wikipedia.org/wiki/Model... | 38,635 |
<p>I have a XML File like that</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<Configurations>
<EmailConfiguration>
<userName>xxxx</userName>
<password>xxx</password>
<displayName>xxxxx</display... | <pre><code>public class Options
{
public string UserName { get; set; }
public string Password { get; set; }
public string DisplayName { get; set; }
public string HostAddress { get; set; }
public bool SSL { get; set; }
public string Port { get; set; }
public bool LogEnable { get; set; }
... | <p>I've found something like this and this actually satisfied me how I want :)
<strong>But I wanna learn that is a efficient way to retrieve data from XML ?</strong>
Here is the code tho :</p>
<pre><code>XmlDocument doc = new XmlDocument();
doc.Load(HttpContext.Current.Server.MapPath("config.xml"));
... | 47,038 |
<p>I can't seem to retrieve an ID I'm sending in a html.ActionLink in my controller, here is what I'm trying to do</p>
<pre><code><li>
<%= Html.ActionLink("Modify Villa", "Modify", "Villa", new { @id = "1" })%></li>
public ActionResult Modify(string ID... | <p>Doesn't look like you are using the correct overload of ActionLink. Try this:-</p>
<pre><code><%=Html.ActionLink("Modify Villa", "Modify", new {id = "1"})%>
</code></pre>
<p>This assumes your view is under the /Views/Villa folder. If not then I suspect you need:-</p>
<pre><code><%=Html.ActionLink("Modif... | <p>If the target action requires a parameter, you can use an anonymous object to pass parameter values:</p>
<p>@Html.ActionLink(“View Movies”, “Index”, “Movies”, new{id=1},null) </p>
<p>Where:</p>
<p>-View Movies-->String LinkText</p>
<p>-Index--> string ActionName</p>
<p>-Movies-->string ControllerName</p>... | 40,921 |
<p>I have just branched our Common Business Layer projects from the main to a new branch, and included them in a new solution. Everything compiles but when I run the unit tests I get the following error for every single test...</p>
<blockquote>
<p>Unit Test Adapter threw exception: Unable to load one or more of the ... | <p>Try cleaning the solution and trying again.</p>
<p>Also try clicking on the link that appears in yellow bar of the Test Results window, this sometimes gives more information about why tests cannot be run.</p>
| <p>I did run into the same errors and the cleaning did not do the job. </p>
<p>I resolved this one by going into the TestRunConfig file, Code Coverage Menu, and putting the right SNK file in the "Re-signing Key File" text box.</p>
<p>Hope this help.</p>
| 44,683 |
<p>I just want to know the best way to emulate a C# style enumeration in Ruby.</p>
| <blockquote>
<p>Specifically, I would like to be able to perform logical tests against the set of values given some variable. Example would be the state of a window: "minimized, maximized, closed, open"</p>
</blockquote>
<p>If you need the enumerations to map to values (eg, you need minimized to equal 0, maxi... | <p>Making a class or hash as others have said will work. However, the Ruby thing to do is to use <a href="http://www.rubytips.org/2008/01/26/what-is-a-ruby-symbol-symbols-explained/" rel="nofollow noreferrer">symbols</a>. Symbols in Ruby start with a colon and look like this:</p>
<pre><code>greetingtype = :hello
</cod... | 19,908 |
<p>Are there any tools that can help find race conditions when testing multi-threaded .net code? I'm looking for something with similar capabilities to IBM's <a href="http://www.alphaworks.ibm.com/tech/contest" rel="noreferrer">ConTest</a> tool for Java.</p>
| <p><a href="http://docs.typemock.com/racer/##RacerHelp.chm/html/4744c118-5744-4885-a3d0-8433d5f8ccc7.htm" rel="nofollow noreferrer">Typemock Racer</a> might be what you're looking for but I haven't used it - I just remembered something about deadlocks :)</p>
<p>Or this: <a href="http://www.lockexplorer.com/" rel="nofo... | <p>Have you seen <a href="http://www.debuginspector.com" rel="nofollow noreferrer">Debug Inspector</a> (www.debuginspector.com) ?</p>
<p>It does managed and unmanaged deadlocks and covers both WaitForSingleObject and WaitForMultipleObjects and works for XP and Vista</p>
| 24,446 |
<p>Is there an application , which can parse a given set of stored procedures (SQL Server 2000) and gets all tables and associated columns that are being used in it.
The stored procedure can have tables from different databases.</p>
<p>Output should be like
TableA
columnA
columnC
columnD</p>
<p>TableB
... | <ul>
<li><b>UPDATE - 20 Jan 2009</b> *</li>
<li>Visual Studio DB Professional Edition shipped with a full T-SQL script DOM parser</li>
<li><a href="http://blogs.msdn.com/gertd/archive/2008/08/21/getting-to-the-crown-jewels.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/gertd/archive/2008/08/21/getting-to-the-cro... | <p>You could <strong>call the stored procedures programmatically</strong> (in a development environment) and <strong>get the resulting columns</strong>. Maybe you have a naming convention in order to avoid calling insert and update procedure. You'll have to find way to set the right parameters too.</p>
<p><strong>Note... | 35,894 |
<p>I ran into an interesting (and very frustrating) issue with the <code>equals()</code> method today which caused what I thought to be a well tested class to crash and cause a bug that took me a very long time to track down. </p>
<p>Just for completeness, I wasn't using an IDE or debugger - just good old fashioned te... | <p>In Java, the <code>equals()</code> method that is inherited from <code>Object</code> is:</p>
<pre><code>public boolean equals(Object other);
</code></pre>
<p>In other words, the parameter must be of type <code>Object</code>. This is called <em>overriding</em>; your method <code>public boolean equals(Book other)</c... | <p>recordId is property of the object</p>
<pre><code>@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Nai_record other = (Nai_record) obj;
... | 22,491 |
<p>I'm new to Delphi, and I've been running some tests to see what object variables and stack variables are initialized to by default:</p>
<pre><code>TInstanceVariables = class
fBoolean: boolean; // always starts off as false
fInteger: integer; // always starts off as zero
fObject: TObject; // always starts off ... | <p>Yes, this is the documented behaviour:</p>
<ul>
<li><p>Object fields are always initialized to 0, 0.0, '', False, nil or whatever applies.</p></li>
<li><p>Global variables are always initialized to 0 etc as well;</p></li>
<li><p>Local reference-counted* variables are always initialized to nil or '';</p></li>
<li><p... | <p>Newly introduced (since Delphi 10.3) inline variables are making the control of initial values easier.</p>
<pre><code>procedure TestInlineVariable;
begin
var index: Integer := 345;
ShowMessage(index.ToString);
end;
</code></pre>
| 16,089 |
<p>I need to upload a file using C# from a windows mobile app to a website. It's running PHP as the webservice on the other side, though I guess it really doesn't have to if there's another way to be able to get the file up there. There is no server-side ASP support, however. My problem really isn't the PHP, it's the m... | <p>Have a look at this article <a href="http://msdn.microsoft.com/en-us/library/aa446517.aspx" rel="nofollow noreferrer">Improving .NET Compact Framework HTTP Communications using HttpWebRequest and Custom ASP.NET Providers</a> in MSDN. It is specific for ASP technology,
but the Compact Framework remains the same. Basi... | <p>The following code snippet may help solve the problem we have been discussing here.
Please ignore this if it irrelevant to this topic.</p>
<p>A brief description of how to use the article or code. The class names, the methods and properties, any tricks or tips. </p>
<p>Blocks of code should be set as style "Format... | 39,284 |
<p>Which functions are available within Delphi to play a sound-file?</p>
| <p>Here's the fastest way:</p>
<pre><code>uses MMSystem;
procedure TForm1.Button1Click(Sender: TObject);
begin
sndPlaySound('C:\Windows\Media\Tada.wav',
SND_NODEFAULT Or SND_ASYNC Or SND_LOOP);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
sndPlaySound(nil, 0); // Stops the sound
end;
</code></p... | <p>A full tutorial is available at: <a href="http://sheepdogguides.com/dt3f.htm" rel="nofollow noreferrer">http://sheepdogguides.com/dt3f.htm</a></p>
<p>It is a bit old. But it should work.</p>
| 30,627 |
<p>This is the exception that I'm getting when I'm trying to bind to a System.Type.Name.</p>
<p>Here is what I'm doing:</p>
<pre><code>this.propertyTypeBindingSource.DataSource = typeof(System.Type);
/* snip */
this.nameTextBox1.DataBindings.Add(
new System.Windows.Forms.Binding(
"Text",
this.p... | <p>Indeed, there is special treatment of Type... this approach is used in the IDE etc to configure meta-data ahead of time. If you look at IDE-generated bindings, they do things like:</p>
<pre><code>bindingSource1.DataSource = typeof(MyObject);
</code></pre>
<p>saying "when we get real data, we expect MyObject isntan... | <p>One of the possible reason for this error is table/ Dataset do not have specified column.
Specially, in case of Typed DataSet make sure you have proper names in XSD matching with column names from table</p>
| 27,139 |
<p>Is there a way to dynamically invoke a method in the same class for PHP? I don't have the syntax right, but I'm looking to do something similar to this:</p>
<pre><code>$this->{$methodName}($arg1, $arg2, $arg3);
</code></pre>
| <p>There is more than one way to do that:</p>
<pre><code>$this->{$methodName}($arg1, $arg2, $arg3);
$this->$methodName($arg1, $arg2, $arg3);
call_user_func_array(array($this, $methodName), array($arg1, $arg2, $arg3));
</code></pre>
<p>You may even use the reflection api <a href="http://php.net/manual/en/class.r... | <p>Still valid after all these years! Make sure you trim $methodName if it is user defined content. I could not get $this->$methodName to work until I noticed it had a leading space.</p>
| 31,325 |
<p>In Java, we can always use an array to store object reference. Then we have an ArrayList or HashTable which is automatically expandable to store objects. But does anyone know a native way to have an auto-expandable array of object references?</p>
<p>Edit: What I mean is I want to know if the Java API has some class... | <p>Java arrays are, by their definition, fixed size. If you need auto-growth, you use XXXList classes.</p>
<p>EDIT - question has been clarified a bit</p>
<p>When I was first starting to learn Java (coming from a C and C++ background), this was probably one of the first things that tripped me up. Hopefully I can sh... | <p>if you can write your code in javascript, yes, you can do that. javascript arrays are sparse arrays. it will expand whichever way you want.</p>
<p>you can write</p>
<p>a[0] = 4;<br>
a[1000] = 434;<br>
a[888] = "a string";</p>
| 29,968 |
<p>Using the debugger in Netbeans 6.1, I'd like to step into a method of the JSF library (specifically method saveSerializedView of class StateManager), but I cannot figure out how to specify through the IDE the location of the source code for the JSF library. I'm even having trouble determining which jar file or files... | <p>This answer applies to Netbeans 6.1 circa September 2008:</p>
<p>It sounds as if you need to explore the "Libraries" dialog. Select "Tools" from the menu bar and "Libraries" from the menu. If you select "JSF" on the left, you'll see an association of jar files, sources (currently none in my Netbeans 6.1) and java... | <p>download the jsf source and point to the working folder for source lookup..
It will dig into the code</p>
| 11,299 |
<p>What was the motivation for having the <code>reintroduce</code> keyword in Delphi?</p>
<p>If you have a child class that contains a function with the same name as a virtual function in the parent class and it is not declared with the override modifier then it is a compile error. Adding the reintroduce modifier in s... | <p>If you declare a method in a descendant class that has the same name as a method in an ancestor class then you are hiding that ancestor method — meaning if you have an instance of that descendant class (that is referenced as that class) then you will not get the behavior of the ancestor. When the ancestor's method i... | <p><strong>reintroduce</strong> allows you to declare a method with the same name as the ancestor, but with different parameters. It has nothing to do with bugs or mistakes!!!</p>
<p>For example, I often use it for constructors...</p>
<pre><code>constructor Create (AOwner : TComponent; AParent : TComponent); reintrod... | 7,736 |
<p>When I try to connect to WMI from Powershell, ConfigMgr, or WMI explorer, I can talk to the majority of my computers, but some (maybe 30%?) return an 0x800706ba (RPC server is unavailable).</p>
<p>If I turn the firewall off on the remote machine, the queries start working. I have tried a bunch of different configu... | <p>I suppose you should make an alias for selected value:</p>
<pre><code>select concat(column1, column2) as concatenated from table1
</code></pre>
| <p>I suppose you should make an alias for selected value:</p>
<pre><code>select concat(column1, column2) as concatenated from table1
</code></pre>
| 48,212 |
<p>The Database Tuning Advisor is recommending that I create a bunch of statistics in my Database. I'm something of a SQL n00b, so this was the first time I'd ever come across such a creature. The entry in MSDN was a little obtuse - could someone explain what exactly this does, and why it's a good idea?</p>
| <p><a href="http://en.wikipedia.org/wiki/Query_optimizer" rel="noreferrer">Cost Based Query Optimisation</a> is a technique that uses histograms and row counts to heuristically estimate the cost of executing a query plan. When you submit a query to SQL Server, it evaluates it and generates a series of <a href="http://... | <p>In a nutshell, it prepares your database to work effectively. By having prepared statistics, your database knows (before it needs to figure out an execution plan) what is likely to be its most efficient route.</p>
| 15,594 |
<p>When I measure request times on "the inside" of an Asp.Net application and compare it to timings on "the outside" of the app, I get different values -- 1000-5000ms strange overheads from time to time. </p>
<p>Maybe the requests are beeing queued up in front of IIS? </p>
<p>Or something strange is going on in an Ht... | <p>You can create your own module and register it on top to trace every request with more accuracy, but the measure will start once the IIS delegates the request to the ASP.NET ISAPI module. To get more accuracy you can go to IIS logs.</p>
| <p>You can turn on tracing in your web.config file. The line should say something like <code><trace enabled="true" pageOutput="true" /></code>. The MSDN page is <a href="http://msdn.microsoft.com/en-us/library/6915t83k.aspx" rel="nofollow noreferrer">here</a>.</p>
| 17,881 |
<p>I'm trying to connect to a remote private MSMQ queue using the path:</p>
<pre><code>"FormatName:DIRECT=OS:remoteMachineName\Private$\MyQueue"
</code></pre>
<p>and I'm getting the following error: </p>
<pre><code>"The specified format name does not support the requested operation. For example, a direct queue forma... | <p>Is this a transactional queue? Remote read from transactional queue is not possible. Maybe the spring framework try to check if this a transactional queue, and this is also an operation that is supported only on local queue.</p>
<p>The recommanded why to work with queues is to write to remote queue and read from lo... | <p>the first thing striking my eyes is the casing of your endpoint address. At least all other examples posted in this thread or <a href="http://www.infosysblogs.com/microsoft/2007/05/msmq_receiving_messages_from_r.html" rel="nofollow noreferrer">here</a> use different casing. Second you are not escaping the backslashe... | 49,243 |
<p><strong>PHP has a <a href="http://php.net/var_dump" rel="noreferrer">var_dump()</a> function which outputs the internal contents of an object, showing an object's type and content.</strong></p>
<p>For example:</p>
<pre><code>class Person {
private $firstName;
private $lastName;
public function __construct($... | <p><strong>It is not quite as baked-in in Java, so you don't get this for free.</strong> It is done with convention rather than language constructs. In all data transfer classes (and maybe even <em>in all classes you write...</em>), you should implement a sensible <a href="http://java.sun.com/javase/6/docs/api/java/l... | <p>You XML serialization, and you should get a very neat representation even of deeply nested objects.</p>
| 38,693 |
<p>What is the difference between the Project and SVN workingDirectory Config Blocks in CruiseControl.NET?</p>
<p>I setup Subversion and now I'm working on CruiseControl.NET and noticed there are two workingDirectory blocks in the config files. I've looked through their google groups and documentation and maybe I miss... | <p>I think the project working directory is used as the root folder for all commands in the CruiseControl block. So if I have a Nant task/script with relative folders, it will be appended to this root folder for actual execution. </p>
<blockquote>
<p>The Working Directory for the project
(this is used by other bl... | <p>See <a href="http://confluence.public.thoughtworks.org/display/CCNET/Project+Configuration+Block" rel="nofollow noreferrer">Project Configuration Block</a> and <a href="http://confluence.public.thoughtworks.org/display/CCNET/Subversion+Source+Control+Block" rel="nofollow noreferrer">Subversion Source Control Block</... | 17,251 |
<p>someone has an idea how can I do that ?</p>
<p>thanks</p>
| <p>If you need to do something to each element of a set of <code>n</code> elements, you cannot do it with better than O(<code>n</code>) performance.</p>
| <p>No. It's physically impossible. However, you can use vector instructions to make it some O(n * 1/k) time, where k is the width of a vector setter instruction. That's still O(n), but the constant is shrunk.</p>
| 38,998 |
<p>Can the iPhone SDK take advantage of the iPhone's proximity sensors? If so, why hasn't anyone taken advantage of them? I could picture a few decent uses.</p>
<p>For example, in a racing game, you could put your finger on the proximity sensor to go instead of taking up screen real-estate with your thumb. Of course t... | <p>Assuming you mean the sensor that shuts off the screen when you hold it to your ear, I'm pretty sure that is just an infrared sensor inside the ear speaker. If you start the phone app (you don't have to be making a call) and hold something to cast a shadow over the ear speaker, you can make the display shut off.</p... | <p>@Dipak Patel & @Coderer</p>
<p>You can download working code at
<a href="http://spazout.com/google_cheats_independent_iphone_developers_screwed" rel="nofollow noreferrer">http://spazout.com/google_cheats_independent_iphone_developers_screwed</a></p>
<p>It has a working implementation of proximityStateChanged a... | 19,995 |
<p>I have code running in a loop and it's saving state based on the current time. Sometimes this can be just milliseconds apart, but for some reason it seems that DateTime.Now will always return values of at least 10 ms apart even if it's only 2 or 3 ms later. This presents a major problem since the state i'm saving de... | <p>Curiously, your code works perfectly fine on my quad core under Win7, generating values exactly 2 ms apart almost every time.</p>
<p>So I've done a more thorough test. Here's my example output for <code>Thread.Sleep(1)</code>. The code prints the number of ms between consecutive calls to <code>DateTime.UtcNow</code... | <p>You could use DateTime.Now.Ticks, read the artical on <a href="http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx" rel="nofollow noreferrer">MSDN</a></p>
<blockquote>
<p>"A single tick represents one hundred nanoseconds or one ten-millionth of a second."</p>
</blockquote>
| 39,588 |
<p>I'm trying to print a supporting base which will house the spindle for an electrostatic rotor. It's basically just a truncated cone with a hole down it's center to house the spindle.</p>
<p>For reasons that I cannot fathom, Ultimaker Cura keeps on adding an unrequested top/bottom layer (color-coded yellow in the sc... | <p>It would appear that your model does not conform properly to STL standards. I base this conclusion on a couple of factors. When I loaded the model into Simplify3D slicer, it displayed fine, but when sliced, displayed nothing. Using the onboard repair feature, it presented the entire model as being composed of non-ma... | <p>I had the same issue exporting from Sketchup to STL. I imported my STL to Tinkercad and then exported it again and it resolved my issue.</p>
<p>Tinkercad is a free and online tool.</p>
| 1,443 |
<p>What is the use of the <code>yield</code> keyword in Python? What does it do?</p>
<p>For example, I'm trying to understand this code<sup><strong>1</strong></sup>:</p>
<pre><code>def _get_child_candidates(self, distance, min_dist, max_dist):
if self._leftchild and distance - max_dist < self._median:
yi... | <p>To understand what <code>yield</code> does, you must understand what <em>generators</em> are. And before you can understand generators, you must understand <em>iterables</em>.</p>
<h2>Iterables</h2>
<p>When you create a list, you can read its items one by one. Reading its items one by one is called iteration:</p>
<p... | <p><code>yield</code> is used to create a <code>generator</code>. Think of generator as an iterator whihc gives you value on each iteration. When you use yield in the loop you get a generator object which you could use to get items from the loop in an iterative manner</p>
| 28,691 |
<p>I need to write a function that receives a property as a parameter and execute its getter.</p>
<p>If I needed to pass a function/delegate I would have used:</p>
<pre><code>delegate RET FunctionDelegate<T, RET>(T t);
void func<T, RET>(FunctionDelegate function, T param, ...)
{
...
return functi... | <p>You can use reflection, you can get a MethodInfo object for the get/set accessors and call it's Invoke method.</p>
<p>The code example assumes you have both a get and set accessors and you really have to add error handling if you want to use this in production code:</p>
<p>For example to get the value of property ... | <p>Re: aku's answer:</p>
<p>Then you have to obtain that property info first. It seems "use reflection" is the standard answer to the harder C# questions, but reflection yields not-so-pretty hard-to-maintain code. Dror, why not just create a delegate that reads the property for you? It's a simple one-liner and is prob... | 13,581 |
<p>This is written in PHP, but it's really language agnostic.</p>
<pre><code>try
{
try
{
$issue = new DM_Issue($core->db->escape_string($_GET['issue']));
}
catch(DM_Exception $e)
{
throw new Error_Page($tpl, ERR_NOT_FOUND, $e->getMessage());
}
}
catch(Error_Page $e)
{
... | <p>You're using Exceptions for page logic, and I personally think that's not a good thing. Exceptions should be used to signal when bad or unexpected things happen, not to control the output of an error page. If you want to generate an error page based on Exceptions, consider using <a href="http://www.php.net/set_excep... | <p>Depending on your needs this could be fine, but I am generally pretty hesitant to catch an exception, wrap the message in a new exception, and rethrow it because you loose the stack trace (and potentially other) information from the original exception in the wrapping exception. If you're <strong>sure</strong> that y... | 12,923 |
<p>When using <code>grep --color=always</code> I can get pretty color highlighting for regex matches.</p>
<p>However, <code>grep</code> only returns lines with at least one match. Instead, I am looking for a way to simply highlight regex matches, while leaving all other input alone, without dropping lines without any... | <p>The simplest solution would be to use <code>egrep --color=always 'text|^'</code> which would match all line beginnings but only color the desired text.</p>
| <p>I recently made something similar as a filter. I use it to color the "headers" in a tail with multiple files, like this:</p>
<p>tail -f access.log error.log foo.log | logcol.sh</p>
<p>The headers look like this:</p>
<p>==> access.log <==</p>
<p>I got confused by the quick changes between the different logfile... | 29,870 |
<p>Say that I have two models- Users and Accounts. Each account can have at most n users associated with it, and a user can only be associated with one account. </p>
<p>It would seem natural to say that User </p>
<pre><code>belongs_to :account
</code></pre>
<p>and Account </p>
<pre><code>has_many :users
</code></pr... | <p>At first, if your users table has foreign key account_id then you need to use</p>
<pre><code>class User
belongs_to :account
end
</code></pre>
<p>In this way you will ensure that User can be associated just to one Account.</p>
<p>If you want to limit that Account can have e.g. at most 3 users then you can define... | <p>I think your rule is subject to a different interpretation. Think of the rule as being "You cannot add a user to an account that already has 3 users." Now that it is a user rule, implementing it on the user object seems perfectly natural and @Raimond's solution will suffice.</p>
<p>You could also think about impl... | 37,311 |
<p>I'm running into a recurrent problem with git on windows (I'm running MSysGit from package Git-1.6.0.2-preview20080923.exe, i tried as well with Git-1.5.6.1-preview20080701.exe and the results are the same).</p>
<p>It happens very offen that some files are shown as changed when I didn't change them, and in git-gui ... | <p>You may have line-ending problems, if you haven't handled that either in your text editor or in the Git configuration.</p>
<p>To solve this in Git, set the autocrlf option in the Git config file:</p>
<pre><code>$ git config --global core.autocrlf true
</code></pre>
<p>This causes git to convert the newlines to th... | <p>If you are using Visual Studio then it is probably visual studio converting tabs into spaces (#@%$#). You can turn this "feature" off somewhere in the visual studio settings. You can also set git up to not check for whitespace changes, but I cannot recommend that.</p>
<p>The suggestion above setting autocrlf could ... | 40,368 |
<p>For quite a while, I thought that Free Software was Open Source Software. I've found out that this view is incorrect, and that Open Source Software is not necessarily Free Software. I honestly can't see any differences.</p>
<p>What am I missing here? What are the distinguishing traits of both parties?</p>
| <p>Both are basically the same, except the free software movement puts more emphasis on the freedom to modify and redistribute the code. For example, GNU GPL would be more "free" than MIT licence, because MIT license does not enforce copyleft and thus someone can develop closed-source software based on the code.</p>
<... | <p>Freeware software is just small software which are free but their codes are not accessible.It can be downloaded ,used ,copied without restrictions.</p>
<p>Shareware software are just a demo version of the full software developed by small software company and the modification and other usability lies with the develo... | 34,938 |
<p>How can I set up GNU screen to allow the mouse's scrollwheel to scroll around in the scrollback buffer? I tried to Google about this, but most hits were on how to allow applications inside screen to use the scrollwheel.</p>
| <p>I believe you can just add a line like this to your <code>~/.screenrc</code>:</p>
<pre><code>termcapinfo xterm* ti@:te@
</code></pre>
<p>Where "xterm*" is a glob match of your current TERM. To confirm it works, ^A^D to detach from your screen, then <code>screen -d -r</code> to reattach, then <code>ls</code> a few ... | <p>If the answers above don't work for you, make sure you don't have a <strong>caption</strong> or the <strong>alwayslastline</strong> option set in your .screenrc. If you have them, this will not work:</p>
<pre><code>termcapinfo xterm* ti@:te@
</code></pre>
<p>If you need this information, you can try setting it in ... | 46,834 |
<p>I'm trying to learn Actionscript 2 or 3, with AS2 I eventually figured by trial and error that I could get any named instance and modify it using a string with its name using</p>
<pre><code>var theinstance = "titletext"; // actually exctracted from an array
_root[theinstance].htmlText = "New text with <b>HTML... | <p>Just use either "root" (no underscore) or "stage" depending on exactly what you want to do.</p>
<p>However - Why not just store a reference to the textField in the array instead of a string?</p>
| <p>"flash.display.DisplayObject" is not literally part of the actual code that you call. Rather, the documentation is telling you that the stage property is available on any <em>instance of the DisplayObject class</em> -- for example, a movieClip or a sprite.</p>
<p>For example, if you have a movieClip named foo, you... | 39,264 |
<p>When an item is clicked in the checkedlistbox, it gets highlighted. How can I prevent this highlighting effect? </p>
<p>I can hook into the SelectedIndexChanged event and clear the selection, but the highlighting still happens and you see a blip. In fact, if you hold down the mouse click, never releasing it after y... | <p>this will do it apart from you still get the dotted line bit.</p>
<pre><code>this.checkedListBox1.SelectionMode = System.Windows.Forms.SelectionMode.None;
</code></pre>
<p>although now you can't click the check boxes... so you'll have to do something like so:</p>
<pre><code> private void checkedListBox1_Click(ob... | <p>ooh cool add
put all the code from answer from Hath in a</p>
<pre><code> checkedListBox1_MouseMove(object sender, MouseEventArgs e)
</code></pre>
<p>add in if mouse button bit in to the switch</p>
<pre><code>case CheckState.Checked:
if (e.Button == MouseButtons.Right)
{
checkedListBox1.SetItemCheckS... | 43,385 |
<p>Can anyone recommend a good .NET based lexical analyser, preferably written in C#?</p>
| <p>ANTLR has a <a href="http://www.antlr.org/wiki/display/ANTLR3/Antlr+3+CSharp+Target" rel="nofollow noreferrer">C# target</a> </p>
| <p>Download the Visual Studio SDK; it includes a managed parser/lexer generator.</p>
<p>(Edit: It was written on my university campus, apparantly :D)</p>
| 16,001 |
<p>I have a program that needs to do a <strong>compile time checkable</strong> map from one known set of values to another known set of values:</p>
<pre>
in out
------------
8 37
10 61
12 92
13 1/4 109
15 1/4 151
etc
</pre>
<p>This would be easy if the inputs were either integers or evenly spac... | <p>Can't you use a hash map?</p>
| <p>Sounds like you want to want to use something like a sorted binary tree. Both lookup and iteration are fast and the tree won't care about the spacing of the entries.</p>
<p>If your multiple axes are independent, you could create one for each axis.</p>
| 45,323 |
<p>I have a simple Google App Engine app, that I wrote using ordinary strings. I realize I want to make it handle unicode. Are there any gotchas with this? I'm thinking of all the strings that I currently already have in the live database. (From real users who I don't want to upset.)</p>
| <p><a href="https://stackoverflow.com/questions/245094/upgrading-google-application-engine-program-to-use-unicode#245159">Alexander Kojevnikov</a> said: "The datastore internally keeps all strings in unicode."</p>
<p>In other words, your application is already using unicode everywhere. Thank the google folks for a sen... | <p>The datastore internally keeps all strings <a href="http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html#str" rel="nofollow noreferrer">in unicode</a>.</p>
| 30,404 |
<p>I am familiar with several approaches to making the back button work in AJAX applications in various situations, but I have not found a solution that will work gracefully in my specific scenario.</p>
<p>The pages I am working with are the search interface for a site. You enter terms in a normal search box, click "... | <p>Just use a <strong>cookie</strong>.</p>
| <p>Would it help to trigger a page change event using the "Add some info to the # at the end of the URL approach".</p>
<p>That way, clicking the back button shouldn't actually change the page, and you should be able to restore state without the first page load.</p>
| 5,441 |
<p>I want to learn algorithms using some very basic simple tutorials. Are there any out there? I have heard of recursion and stuff and I would like to get good at it. Any help would be appreciated.</p>
| <p>I would start out by taking a look at <a href="http://www.eternallyconfuzzled.com/jsw_home.aspx" rel="noreferrer">EternallyConfuzzled</a> which contains great tutorials for basic Data Structures an Algorithms including linked lists and binary search trees, sorting and searching algorithms. If you want to learn more... | <p>Recursion is a language feature, and less an "algorithm" per se. All recursion can be replaced with proper data structures (like a stack).</p>
<p>I'd recommend grabbing a book. The problem with algorithms is that it's a relatively progressive topic. You first need to learn simple searches before you can learn so... | 40,423 |
<p>What free or open source WPF diagramming libraries have you used before? I'm working on my thesis and have no money to pay for the commercial alternatives.</p>
<p>Valid answers should support undo/redo, exporting to XML and hopefully good documentation.</p>
<p>I'm building an open source UML / database diagramming... | <p>sukram has a excellent series on CodeProject... it's a MUST READ!</p>
<ul>
<li><a href="http://www.codeproject.com/KB/WPF/WPFDiagramDesigner_Part1.aspx" rel="noreferrer">Part 1</a></li>
<li><a href="http://www.codeproject.com/KB/WPF/WPFDiagramDesigner_Part2.aspx" rel="noreferrer">Part 2</a></li>
<li><a href="http:/... | <p>What kind of Diagram drawing you are looking for?
WPF has great set of basic control <a href="http://msdn.microsoft.com/en-us/library/ms751808.aspx" rel="nofollow noreferrer">library</a> which supports most mathematical drawing models like Spline Curve, Line, PolyLine, arc etc etc</p>
| 15,151 |
<p>We currently use VSS 6, this is not going to change I am afraid.</p>
<p>I am attempting to write a script that will allow a user to quickly copy all files that they have checked out to another directory tree. In order to do this I need to get a list of all the files that the user has checked out, and the directory ... | <p>Two links that may be of use:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/003ssz4z(VS.80).aspx" rel="noreferrer">VSS CommandLine Commands</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/hsxzf2az(VS.80).aspx" rel="noreferrer">VSS CommandLine Options</a></p>
<p>To expand on Panos reply</p>
... | <p>See <a href="http://msdn.microsoft.com/en-us/library/d6kac9fd(VS.80).aspx" rel="nofollow noreferrer">here</a> for the command line usage of Status command. The command </p>
<pre><code>ss.exe Status $/ -R -U
</code></pre>
<p>shows every file in the system that is checked out by the current user.</p>
| 32,885 |
<p>I've got a stored procedure in my database, that looks like this</p>
<pre><code>ALTER PROCEDURE [dbo].[GetCountingAnalysisResults]
@RespondentFilters varchar
AS
BEGIN
@RespondentFilters = '''8ec94bed-fed6-4627-8d45-21619331d82a, 114c61f2-8935-4755-b4e9-4a598a51cc7f'''
DECLARE @SQL nvarchar(600)
SET @SQL =
... | <p>You need single quotes around each GUID in the list</p>
<pre><code>@RespondentFilters = '''8ec94bed-fed6-4627-8d45-21619331d82a'', ''114c61f2-8935-4755-b4e9-4a598a51cc7f'''
</code></pre>
| <p>Tank you all for your ansewers. They all helped a lot. I've dealt with the problem by writing a split function, and it works fine. It's a litte bit overhead from what I could have done, but you know, the deadline is hiding around the corner :)</p>
| 11,921 |
<p>Is there a special project type for creating a WCF to be hosted in IIS?</p>
| <p>You don't need to use a special project type for hosing inside IIS. As long as you put the dlls in the bin folder and create a .svc file it will work. A standard web site project would do the trick.</p>
| <p>You can use the "WCF Service Application" template if you like, but as has been said, you don't really need anything special.</p>
| 26,919 |
<p>I guess I need to know what I need in the classpath (what jar) in order to execute WebSphere 6.1 ant tasks. If someone can provide an example that would be perfect.</p>
| <p>For Websphere 6.1, you can use the jar com.ibm.ws.runtime_6.1.0.jar to access the ant tasks.</p>
<p>On Windows, the jar is located in the plugins directory (for me this is: C:\Program Files\IBM\WebSphere\AppServer\plugins).</p>
| <p>websphere's ant tasks are screwed up and they invoke wsadmin.bat</p>
<p>you can do that yourself</p>
| 19,784 |
<p>I have a import directive in my inline .aspx page (no code-behind).</p>
<p>Getting an error: The type or namespace name 'Dts' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)</p>
<p>What is the issue? Do I need a /bin directory with the .dll in it or something?</p>
| <p>Sounds like there is no "project". In that case, to reference a dll (assembly) you use an <a href="http://msdn.microsoft.com/en-us/library/d864zc1k.aspx" rel="nofollow noreferrer"><code><%@ Assembly ></code></a> directive.</p>
<pre><code><%@ Assembly Name="microsoft.sqlserver.manageddts.dll" %>
<%@ ... | <p>Does your project reference microsoft.sqlserver.manageddts.dll?</p>
| 46,599 |
<p>We are running part of our app as a windows service and it needs to b able to access DSNs in order to import through ODBC. However there seem to be a lot of restrictions found through trial and error on what DSNs it can access. For example it seems that it cannot
1. access a system DSN unless the account that is ... | <p>This is somewhere between your #1 and #2: sometimes correct file permissions are also necessary. I once had troubles on a Vista machine connecting to a DB2 DSN because, for whatever reason (maybe to write out temp files; although I don't know why it would do such a thing in this location instead of a user-specific... | <p>You cannot connect to mapped drives with a service. A mapped drive has to interact with memory called the desktop heap which tracks the icons on the desktop. Services do not have access to that memory. If you have to use a dsn create a systemdsn. better would be to use a connection string and store that in the a... | 15,527 |
<p>Hoping to get some help with something I'm trying to accomplish. Unfortunately, due to my being a noob with 3D modeling in general, I'm coming here for hopefully more direct help.</p>
<pre><code>Env. Details: OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13541 (Git)
Build type: R... | <p>A wide line works if there is something below it to squeeze the filament against, but if you don't have a full layer below it, it will stay thinner and it will droop. I would not use extreme ratios on overhangs. Still, do a parametric test: a overhang tower (a compact one) at different line widths and layer heights.... | <p>In terms of Cura's model for showing overhangs, I'm nearly sure it's just the ratio - rise over run, or rather run over rise. And indeed that's what makes sense mathematically:</p>
<p>At least some portion of the wall extrusion in layer N+1 needs to sit on top of the corresponding wall extrusion in layer N. For a g... | 1,666 |
<p>In a forms model, I used to get the current logged-in user by:</p>
<pre><code>Page.CurrentUser
</code></pre>
<p>How do I get the current user inside a controller class in ASP.NET MVC?</p>
| <p>If you need to get the user from within the controller, use the <code>User</code> property of Controller. If you need it from the view, I would populate what you specifically need in the <code>ViewData</code>, or you could just call User as I think it's a property of <code>ViewPage</code>.</p>
| <p>In the IIS Manager, under Authentication, disable:
1) Anonymous Authentication
2) Forms Authentication</p>
<p>Then add the following to your controller, to handle testing versus server deployment:</p>
<pre><code>string sUserName = null;
string url = Request.Url.ToString();
if (url.Contains("localhost"))
sUserNa... | 32,989 |
<p>Xcode has these handy time savers in the scripts menu called "Code->Place Accessor Defs on Clipboard" and "Code->Place Accessor Decls on Clipboard". These scripts allow you to automate the generation of getter and setter methods for any highlighted instance variables. </p>
<p>Does anyone know of a similar script th... | <p>Check out:</p>
<ol>
<li><p><a href="http://cocoawithlove.com/2008/12/instance-variable-to-synthesized.html" rel="nofollow noreferrer">Matt Gallagher's property accessors script for XCode</a> </p></li>
<li><p><a href="http://www.kevincallahan.org/software/accessorizer.html" rel="nofollow noreferrer">Accessorizer</a>... | <p>I also recommend textexpander which makes the process a little more intuitive and generalized such that the same "snippets" can be used across text editors.</p>
| 36,029 |
<p>I have wrist pain when I type and I would like to start writing SQL statements, stored procedure, and views using speech recognition.</p>
| <p>Yes. SQL is well-suited to speech recognition (as well-suited as a programming language can be, that is), given it's limited vocabulary and sentence-like structure. Aside from formatting the SQL so that it looks nice, I can dictate it much faster than typing. Dictating code isn't for everyone, however. It can be qui... | <p><a href="http://voicecode.io" rel="noreferrer">http://voicecode.io</a></p>
<p>I recently released VoiceCode, a coding-by-voice solution I created to solve my own RSI issues.</p>
<p>I use it for coding in Sublime Text and Xcode, as well as general computer usage. It works for writing code in any language including ... | 45,601 |
<p>I need a 'good' way to initialize the pseudo-random number generator in C++. I've found <a href="http://www.cplusplus.com/reference/clibrary/cstdlib/srand.html" rel="noreferrer">an article</a> that states:</p>
<blockquote>
<p>In order to generate random-like
numbers, srand is usually initialized
to some disti... | <p>The best answer is to use <a href="http://en.cppreference.com/w/cpp/header/random" rel="nofollow noreferrer"><code><random></code></a>. If you are using a pre C++11 version, you can look at the Boost random number stuff.</p>
<p>But if we are talking about <code>rand()</code> and <code>srand()</code><br>
The <s... | <p>Include the header at the top of your program, and write:</p>
<pre><code>srand(time(NULL));
</code></pre>
<p>In your program before you declare your random number. Here is an example of a program that prints a random number between one and ten:</p>
<pre><code>#include <iostream>
#include <iomanip>
u... | 41,797 |
<p>I am trying to create a very simple ASP.NET application that presents information retrieved from a database based on the URL, in a similar way to a wiki, but in this case the site is read-only. An example of a URL I'd like would be:</p>
<pre><code>http://www.foo.com/bar
</code></pre>
<p>The application would then ... | <p>IIS6 only directs requests to the asp.net engine if that extension has been registered. By default the registered extensions are aspx ascx asmx etc...</p>
<p>If you cannot base you database query on a query string parameter (e.g. foo.com/default.aspx?query=bar) then the best you can do on IIS6 is a wildcard mapping... | <p>Just for the record, IIS URL Rewrite 2 supports this, you can install the extensibility samples that include a DB provider. Works on IIS 7+ only.</p>
<p><a href="http://www.iis.net/download/urlrewrite" rel="nofollow">http://www.iis.net/download/urlrewrite</a>
http://code.msdn.microsoft.com/rewriteextensibility</p>
| 43,600 |
<p>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? </p>
<p>I'm asking in context of a desktop application. I have seen people do it both ways and was wondering which approach ... | <p>If you have frequent read/writes it is more efficient to keep the file open for the lifetime with a <strong>single open/close</strong>.</p>
<p>You might want to <strong>flush periodically or after each write</strong> though. If your application crashes you might not have all the data written to your file. Use fflush... | <p>The advantage to closing the file every time is that the OS will guarantee that the new message is written to disk. If your leave the file open and your program crashes, it is possible the entire thing wouldn't be written. You could also accomplish the same thing by doing an fflush() or whatever is the equivalent ... | 19,830 |
<p>I wonder what type of servers for internal usage you virtualize in the last -say- 6 months. Here's what we got virtual so far:</p>
<ul>
<li>mediawiki</li>
<li>bugtracker (mantis)</li>
<li>subversion</li>
</ul>
<p>We didn't virtualize spezialized desktop PCs which are running a certain software product, that is onl... | <p>My standard answer to questions like this is, "virtualization is great; be aware of its limitations".</p>
<p>I would never rely on a purely-virtual implementation of anything that's an infrastructure-level service (eg the authoritative DNS server for your site; management and monitoring tools). </p>
<p>I work for ... | <p>Our build machine running FinalBuilder runs on a Windows XP Virtual Machine running in VMWare Server on Linux.</p>
<p>It is very practical to move it and also to backup, we just stop the Virtual Machine and copy the disk image.</p>
<p>Some days ago we needed to change the host pc, it took less than 2 hours to have... | 3,112 |
<p>I am using windsor DI framework in one of my MVC project. The project works fine when I tried to run from Visual Studio 2008.</p>
<p>But when i tried to run the project creating an application in IIS7 then I recieved the following error message:</p>
<blockquote>
<p>Looks like you forgot to register the http modu... | <p>Try adding it to the <code>system.webServer</code> section as well?</p>
<pre><code><configuration>
<system.web>
<httpModules>
<add name="PerRequestLifestyle" type="..." />
</httpModules>
</system.web>
<system.webServer>
<mo... | <p>I wrote a blog post that explains the issue in a code-level by decompiling the Castle.Windsor.dll. </p>
<p><a href="https://sitecorelogy.com/2016/05/25/fixed-sitecore-forgot-to-register-the-http-module-castle-microkernel-lifestyle-perwebrequestlifestylemodule/" rel="nofollow">Fixed and Explained: Forgot to register... | 32,199 |
<p>The purpose of using a Javascript proxy for the Web Service using a service reference with Script Manager is to avoid a page load. If the information being retrieved is potentially sensitive, is there a way to secure this web service call other than using SSL? </p>
| <p>If your worried about other people access your web service directly, you could check the calling IP address and host header and make sure it matches expected IP's addresses.</p>
<p>If your worried about people stealing information during it's journey from the server to the client, SSL is the only way to go.</p>
| <p>Though SSL would be best, there are a number of client-side cryptography libraries that could alleviate some of the security concerns - see <a href="https://github.com/jbt/js-crypto" rel="nofollow">https://github.com/jbt/js-crypto</a> for a nice collection</p>
| 14,773 |
<p>I have written an assembly I don't want other people to be able to use. My assembly is signed with a strong name key file, but how do I secure the code so that only my other assemblies signed with the same key can call the members in this assembly?</p>
| <p>There are a few options, none very effective as they merely will make things a tiny bit difficult, but would not prevent a committed user to work around any restriction:</p>
<p>On every one of your entry points, you can call Assembly.GetCallingAssembly() and compare the result with a list of assemblies that are all... | <p>Sounds to me like an impossible problem. You can't trust your environment. That's a fundamental computing principle, and the reason for public/private key encryption. </p>
| 16,831 |
<p>Is there an Oracle equivalent to MS SQL's full text search service?</p>
<p>If so, has anyone implemented it and had good / bad experiences?</p>
| <p><a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/content.htm#sthref2643" rel="noreferrer">Oracle Text</a> is the equivalent functionality.</p>
<p>I've had good experiences with it. Assuming that you are maintaining the text index asynchronously, that tends to be the first source of problems,... | <p>And further to what Justin said, it is possible to create the index so it updates on commit, although this is not recommended for large amounts of text.</p>
<p>It offers much more power than a simple LIKE compare against %string%.</p>
| 24,779 |
<p>How can I calculate the number of work days between two dates in SQL Server? </p>
<p>Monday to Friday and it must be T-SQL.</p>
| <p>For workdays, Monday to Friday, you can do it with a single SELECT, like this:</p>
<pre><code>DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate = '2008/10/01'
SET @EndDate = '2008/10/31'
SELECT
(DATEDIFF(dd, @StartDate, @EndDate) + 1)
-(DATEDIFF(wk, @StartDate, @EndDate) * 2)
-(CASE WHEN... | <p>That's working for me, in my country on Saturday and Sunday are non-working days.</p>
<p>For me is important the time of @StartDate and @EndDate.</p>
<pre><code>CREATE FUNCTION [dbo].[fnGetCountWorkingBusinessDays]
(
@StartDate as DATETIME,
@EndDate as DATETIME
)
RETURNS INT
AS
BEGIN
DECLARE @res int
... | 31,460 |
<p>When multiple <code>scanf()</code> statements are encountered in the code, then, except the first <code>scanf()</code> statement, all others are skipped, that is, there is no prompt for input for those <code>scanf()</code> statements when the code is run.</p>
<p>I have a tried a few suggestions. For eg, use of <cod... | <p>Check the return value of scanf()! </p>
<p>From the man page:
"scanf returns the number of input items assigned, which can be fewer than provided for, or even zero, in the event of a matching failure. Zero indicates that, while there was input available, no conversions were assigned; typically this is due... | <p>I've always thought scanf() was dangerous as it can leave your input streams in an indeterminate state.</p>
<p>I prefer to use other (safer) commands to bring in a string (fgets and such) then use sscanf to process it. Then you can always back up to the start of the string and restart.</p>
| 10,606 |
<p>I was looking at ways to authenticate users in a web app, but in a way where the main web app doesn't need to process the password. Something like OpenId, but the authentication server would definitely need to be hosted on an intranet, internet services can't be accessed by the application server.</p>
<p>My environ... | <p>You could <a href="http://wiki.openid.net/Run_your_own_identity_server" rel="nofollow noreferrer">run your own OpenID server</a>.</p>
<p>You didn't mention your environment, but another option is to use Windows Authentication with Active Directory if you're running in a Windows domain situation.</p>
| <p>There's always some kind of <a href="http://www.isrl.uiuc.edu/systems/Documentation/ldap_webauth_howto.html#examples" rel="nofollow noreferrer">LDAP</a> if you're not into using either your own OpenID server or Windows Active Directory.</p>
| 38,927 |
<p>I'm writing an Emacs major mode for an APL dialect I use at work. I've gotten
basic font locking to work, and after setting comment-start and
comment-start-skip, comment/uncomment region and fill paragraph also
work.</p>
<p>However, comment blocks often contain javadoc style comments and i
would like fill-paragraph... | <p>The problem was that the paragraph-start regexp has to match the entire line to work, including the actual comment character. The following elisp works for the example I gave:</p>
<pre><code>(setq paragraph-start "^\\s-*\\#\\s-*\\\\\\(arg\\|ret\\).*$")
</code></pre>
<p>Here a page that has an example regexp for ph... | <p>There's other modes that have less complex functions used for <code>fill-paragraph-function</code>. Browsing through my install, it looks like the ones in ada-mode and make-mode are good examples.</p>
| 9,734 |
<p>When running one of our software, a tester was faced with the data execution prevention dialog of Windows.</p>
<p>We try to reproduce this situation on a developer computer for debugging purposes : with no success.</p>
<p>Does anyone know how to find what may cause the DEP protection to kill the application?
Is th... | <p>The DEP dialog will typically only show when you try to execute code from a region that you're not marking as executable. This might be caused by 'thunks' in a library you're using, e.g. ATL windowing. This problem is fixed in ATL 8.0.</p>
<p>A stack-trashing bug - for example, a buffer overrun - can also cause thi... | <p>Potentially I would think any time you try to write to memory that isn't allocated this would be a possible result. Could be anything along the lines of deleting an object then using it, or writing a string into a buffer which is too small to hold it.</p>
| 16,911 |
<p><em>Comment on Duplicate Reference: Why would this be marked duplicate when it was asked years prior to the question referenced as a duplicate? I also believe the question, detail, and response is much better than the referenced question.</em></p>
<p>I've been a C++ programmer for quite a while but I'm new to Java... | <ol>
<li><p>Create a new Java project in Eclipse. This will create a src folder (to contain your source files).</p></li>
<li><p>Also create a lib folder (the name isn't that important, but it follows standard conventions).</p></li>
<li><p>Copy the <code>./com/*</code> folders into the <code>/src</code> folder (you can... | <p>In the menu go to :
- File
- Import
- as the filter select 'Existing Projects into Workspace'
- click next
- browse to the project directory at 'select root directory'
- click on 'finish'</p>
| 17,264 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.