instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I had a realtivley simple ajax application, which I have broken up to be more modular. The code is at the link below, and what I have mainly done is add the GetRecordSet function and allowed fetchcompelte to take a variable for which layer to put data in. It should work fine in thery. When I put alert()s in, the cod... | <p>Django implements model inheritance with a OneToOneField between the parent model's table and the child model's table. When you do <code>Base.object.all()</code>, Django is querying just the Base table, and so has no way of knowing what the child table is. Therefore, unfortunately, it's not possible to go directly... | <p>It feels brittle because it is. (This is a reprint of an answer in a different context. <a href="https://stackoverflow.com/questions/243082/c-casting-programmatically-can-it-be-done">See C++ casting programmatically : can it be done ?</a>)</p>
<p>Read up on polymorphism. Almost every "dynamic cast" situation is a... | 45,441 |
<p>Delphi 8 introduced Class Helpers for the purposes of mapping the VCL/RTL to the .NET object hierarchy. They allow injecting methods into an existing class without overriding the the class or modifying the original. Later versions of Delphi found class helpers improved and they were ported to Win32.</p>
<p>In the... | <p>Depends what you mean by "new code". </p>
<p>They aren't really relevant for classes you are newly developing, so in that case, no, they probably shouldn't be used. </p>
<p>But even in a brand new project, you may still need to modify an existing class that you can't change in other ways (vcl class, third-party cl... | <p>These sound like C# extension methods. I would say that while extension methods like these are useful when you don't have the ability to modify a class that you need to extend with functionality, they are a poor way to design your own code. When designing your own code, you'd like all the functionality to be locat... | 46,251 |
<p>Is there a way to iterate (through foreach preferably) over a collection using reflection? I'm iterating over the properties in an object using reflection, and when the program gets to a type that is a collection, I'd like it to iterate over the contents of the collection and be able to access the objects in the co... | <p>I had this issue, but instead of using reflection, i ended up just checking if it was IEnumerable. All collections implement that.</p>
<pre><code>if (item is IEnumerable)
{
foreach (object o in (item as IEnumerable))
{
}
} else {
// reflect over item
}
</code></pre>
| <p>When your using reflection you aren't necessarily using an instance of that object. You would have to create an instance of that type of be able to iterate through the object's properties. So if you are using reflection use the ConstructorInfo.Invoke() (?) method to create a new instance or point to an instance of t... | 13,023 |
<p>I can't quite figure this out. Microsoft Access 2000, on the report total section I have totals for three columns that are just numbers. These <code>=Sum[(ThisColumn1)], 2, 3</code>, etc and those grand totls all work fine. </p>
<p>I want to have another column that says <code>=Sum([ThisColumn1])+Sum([ThisColumn2]... | <p>Give the 3 Grand Totals meaningful Control Names and then for the Grand Grand Total use:</p>
<pre><code>=[GrandTotal1] + [GrandTotal2] + [GrandTotal3]
</code></pre>
<p>Your Grand Total formulas should be something like:</p>
<pre><code>=Sum(Nz([ThisColumn1], 0))
</code></pre>
| <p>Create a new query, and the sql should look like this:</p>
<pre><code>SELECT SUM(Column1 + Column2 + Column3),
SUM(Column1),
SUM(Column2),
SUM(Column3),
FROM Your_Table;
</code></pre>
| 14,972 |
<p>I have a table in <code>MySQL</code> that has 3 fields and I want to enforce uniqueness among two of the fields. Here is the table <code>DDL</code>:</p>
<pre><code>CREATE TABLE `CLIENT_NAMES` (
`ID` int(11) NOT NULL auto_increment,
`CLIENT_NAME` varchar(500) NOT NULL,
`OWNER_ID` int(11) NOT NULL,
PRIMARY KEY (`ID... | <p>MySQL cannot enforce uniqueness on keys that are longer than 765 bytes (and apparently 500 UTF8 characters can surpass this limit).</p>
<ol>
<li>Does CLIENT_NAME really need to be 500 characters long? Seems a bit excessive.</li>
<li>Add a new (shorter) column that is hash(CLIENT_NAME). Get MySQL to enforce uniquene... | <p><a href="http://www.xaprb.com/blog/2006/04/17/max-key-length-in-mysql/" rel="nofollow noreferrer">Here</a>. For the UTF8 charset, MySQL may use up to 3 bytes per character. CLIENT_NAME is 3 x 500 = 1500 bytes. Shorten <code>CLIENT_NAME</code> to 250.</p>
<p><em>later:</em> +1 to creating a hash of the name and u... | 11,550 |
<p>I'm setting up a web application with a FreeBSD PostgreSQL back-end. I'm looking for some database performance optimization tool/technique.</p>
| <p><a href="http://pgfouine.projects.postgresql.org/" rel="noreferrer">pgfouine</a> works fairly well for me. And it looks like there's a <a href="http://portsmon.freebsd.org/portoverview.py?category=databases&portname=pgfouine" rel="noreferrer">FreeBSD port</a> for it.</p>
| <p>DBTuna <a href="http://www.dbtuna.com/postgresql_monitor.php" rel="nofollow">http://www.dbtuna.com/postgresql_monitor.php</a> has recently started supporting PostgreSQL monitoring. We use it extensively for MySQL monitoring, so if it provides the same for Postgres then it should be a good fit for you too.</p>
| 5,771 |
<p>Reporting Services 2000 SP2</p>
<p>I've got a matrix displaying the number of employees </p>
<pre><code> Business1 Business2 Business3
StartBefore99 9 14 4
StartAfter99 30 20 34
</code></pre>
<p>I'd like to display percentages eg</p... | <p>If you want to declare the dictionary once and never change it then declare it as readonly:</p>
<pre><code>private static readonly Dictionary<string, string> ErrorCodes
= new Dictionary<string, string>
{
{ "1", "Error One" },
{ "2", "Error Two" }
};
</code></pre>
<p>If you want to dictionar... | <pre><code>public static class ErrorCode
{
public const IDictionary<string , string > m_ErrorCodeDic;
public static ErrorCode()
{
m_ErrorCodeDic = new Dictionary<string, string>()
{ {"1","User name or password problem"} };
}
}
</code></pre>
<p>Probably initi... | 40,392 |
<p>I want to add complex databinding to my custom winforms control, so I can do the following:</p>
<pre><code>myControl.DisplayMember = "Name";
myControl.ValueMember = "Name";
myControl.DataSource = new List<someObject>();
</code></pre>
<p>Does anyone know what interfaces, etc. have to be implemented to achieve... | <p>Apply one of the following attributes to your custom control, depending on which kind of data binding you need:</p>
<ul>
<li>For complex data binding: <a href="https://learn.microsoft.com/dotnet/api/system.componentmodel.complexbindingpropertiesattribute" rel="nofollow noreferrer" title="Documentation"><code>Comple... | <p>Your class needs to inherit the DataBoundControl class instead of UserControl.</p>
| 30,448 |
<p>I have this problem:</p>
<p>The text "ABCD\r\nEFGHJ" loaded from a file is matched with java regex "EFGH". Matcher object of course says start of the matched string is in position 6. The matcher counts \r \n as two positions.</p>
<p>I put the original text in a AWT TextArea Component and then call select(6,10) to ... | <p>Simple solution: remove all \r from the text... :-P</p>
<p>Not as stupid as it sounds, unless you have inconsistent end of lines (it can happen) and want to keep them unchanged... And that's probably what the component does anyway.</p>
| <p>I cant mess with the text because it is protocol data and \r and \n characters have semantics that dont have to do with display or line separation. I just want a component that will treat each one input character separately and treat it as one displayed and counted, no matter how it is displayed. </p>
| 28,853 |
<p>Anyone know of a good free winforms html editor for .NET. Ideally I would like html and preview modes along with the possibility of exporting to a pdf, word doc or similar. </p>
<p>Although the export I could probably create myself from the html output.</p>
<p>Another nice feature would be a paste from word that r... | <p>You can use the <a href="https://learn.microsoft.com/en-us/dotnet/framework/winforms/controls/webbrowser-control-windows-forms" rel="nofollow noreferrer">WebBrowser</a> control in design mode with a second <code>WebBrowser</code> control set in view mode.</p>
<p>In order to put the <code>WebBrowser</code> control i... | <p>see <a href="http://www.maconstateit.net/tutorials/JSDHTML/JSDHTML12/jsdhtml12-02.htm" rel="nofollow noreferrer">http://www.maconstateit.net/tutorials/JSDHTML/JSDHTML12/jsdhtml12-02.htm</a> for an sample HTML edtior that makes use of editing surport in IE.</p>
<p><a href="http://www.mozilla.org/editor/midasdemo/" r... | 26,328 |
<p>I have a web application where users enter arbitrary sql queries for later batch processing. We want to validate the syntax of the query without actually executing it. Some of the queries will take a long time, which is why we don't want to execute them. I'm using Oracle's dbms_sql.parse to do this.</p>
<p>However,... | <p>You should be able to prepare a SQL query to validate the syntax and get result set metadata. Preparing a query should not execute it.</p>
<pre><code>import java.sql.*;
. . .
Connection conn;
. . .
PreparedStatement ps = conn.prepareStatement("SELECT * FROM foo");
ResultSetMetadata rsmd = ps.getMetaData();
int num... | <p>If you want to do this strictly through pl/sql then you could do the following:</p>
<pre><code>DECLARE
lv_stat varchar2(100) := 'select blah blah blah';
lv_cur INTEGER;
lv_col_cnt INTEGER;
lv_desc DBMS_SQL.desc_tab;
BEGIN
DBMS_SQL.parse(lv_cur,lv_stat,DBMS_SQL.NATIVE);
DBMS_SQL.describe_columns(lv_cur,... | 19,750 |
<p>Our shop is in the process of converting our internal project management application from ASP.NET Web Forms to ASP.NET MVC. </p>
<p>I would like to provide an RSS feed for our customers of their current open issues ... but I would like to do so with some type of authorization, e.g. login and a password. </p>
<p>... | <p>I'm not sure of the best way, but can think of a few, none are super great though.</p>
<ul>
<li><p>Use IIS WindowsAuthentication with basic security and implement the validation method and then mark the RSS action with an authorize filter. If they are using an RSS feeder that doesn't allow http authentication, you... | <p>If private feeds are part of the RSS spec, you should look there for the mechanics of RSS auth.</p>
<p>I've thought about this before for a project and came to the conclusion that secure RSS will never work because not enough clients (e.g. google reader) support it.</p>
<p>Sorry, don't have a complete answer, but ... | 37,514 |
<p>I am trying to learn Emacs and trying to find best keyboard layout for me. One thing is really annoying me. I have added following lines to .emacs</p>
<pre class="lang-lisp prettyprint-override"><code>(global-set-key "\C-y" 'scroll-up)
(global-set-key "\M-y" 'scroll-down)
</code></pre>
<p>When I hold <kbd>Control<... | <p>Could this be a side affect of using the Windows key as Meta? I'm thinking this because in a non-Emacs situation if you press and hold the Windows key and another key for a short cut (Win+E for Explorer, Win+R for Run dialog, etc.) the desired action only triggers once, not multiple times if you keep holding it down... | <p>You should use the patched EmacsW32 version, if you want the Windows key as Meta.</p>
<p>From the site about the patches:</p>
<p>"Changes that makes it possible to use the window keyboard keys as META in Emacs. Without this patch key sequences like E will always do what they by default does in windows, ie in this... | 16,433 |
<p>I know we can do like mget *.xml which will download all xml files. But how is it possible that we using mget with certain file name patterns. can we do something like *SS.xml which mean it will download all files ending with SS.xml?</p>
| <p>Do you mean the <code>mget</code> command within FTP?</p>
<p>Yes, that should be possible, particularly if the remote server is a Unix server where file extensions have no special meaning on the server, they're just another part of the filename.</p>
| <p>Try using ncftp for the ftp client. The user interface is friendlier and may have better wildcard support. If you're trying to write a program to automate downloads, Expect is a programming language extension to TCL designed to automate interactive tasks. </p>
| 31,521 |
<p>For a long time now C++ has been the dominate game development language. Many AAA quality 3D engines are available to fit any budget. </p>
<p>My question is, with the rise of XNA, has C# and the .NET framework been positioned well enough to take over as the new standard game development platform? Obviously the inhe... | <p>I think C++ will go out of fashion in the next 10 years just the same way as assembly did. I'm a professional game programmer for more the 15 years. In early 90's lot of people said that C is not efficient enough for games. In the late 90's same people said that C is OK but C++ is just way too slow for performance c... | <p><a href="http://www.lua.org/" rel="nofollow noreferrer">Lua</a> should be of interest to you, as you can embed it in C# and access your objects from LuaScript. </p>
| 46,425 |
<p>Can anyone tell me what exactly does this Java code do?</p>
<pre><code>SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
byte[] bytes = new byte[20];
synchronized (random)
{
random.nextBytes(bytes);
}
return Base64.encode(bytes);
</code></pre>
<hr>
<p>Step by step explanation will be useful so that... | <p>Using code snippets you can get to something like this</p>
<pre>
Dim randomNumGen As RandomNumberGenerator = RNGCryptoServiceProvider.Create()
Dim randomBytes(20) As Byte
randomNumGen.GetBytes(randomBytes)
return Convert.ToBase64String(randomBytes)
</pre>
| <p>Basically the code above:</p>
<ol>
<li>Creates a secure random number generator (for VB see link below)</li>
<li>Fills a bytearray of length 20 with random bytes</li>
<li>Base64 encodes the result (you can probably use Convert.ToBase64String(...))</li>
</ol>
<p>You should find some help here:
<a href="http://msdn.... | 9,808 |
<p>I use vim (7.1) on OpenVMS V7.3-2.</p>
<p>I connect to VMS trough a telnet session with SmartTerm, a terminal emulator.</p>
<p>It works fine.</p>
<p>But when I start a telnet session from a VMS session (connected via SmartTerm) to another VMS session, some keys doesn't work properly.</p>
<pre><code>|------------... | <p>In addition to tweaking which terminal emulation is used, it's also a good idea to learn vim's keystrokes for the actions you're trying to perform. These are more reliable and don't depend on the terminal or the keyboard. For instance:</p>
<ul>
<li>Insert: i</li>
<li>Home: ^ goes to first non-whitespace char, 0 goe... | <p>Usually this is because of the terminal emulation - so something isn't passing the right keys thru. It's been ages since I've done this, but look for stuff like VT-100 and the like. I doubt it's specific to vim, either :)</p>
<p>Sorry I can't be more help.</p>
| 31,712 |
<p>I have a set of XSDs from which I generate data access classes, stored procedures and more.</p>
<p>What I don't have is a way to generate database table from these - is there a tool that will generate the DDL statements for me?</p>
<p>This is not the same as <a href="https://stackoverflow.com/questions/16443/creat... | <p>Commercial Product: Altova's <a href="http://www.altova.com/features_sql.html" rel="noreferrer">XML Spy</a>.</p>
<p>Note that there's no general solution to this. An XSD can easily describe something that does not map to a relational database.</p>
<p>While you can try to "automate" this, your XSD's must be desig... | <p>Create a Java Model using Axis wsdl2java (which can take in .xsd files).</p>
<p>Use a database generation tool for Java that takes in a Java Model. Surely something like Hibernate can do this? I wrote my own tool (takes a couple of days, also generates CRUD code in Java too) to save myself time at work, maybe this ... | 16,785 |
<p>I am aware of <a href="http://www.capify.org/" rel="nofollow noreferrer">Capistrano</a>, but it is a bit too heavyweight for me. Personally, I set up two <a href="http://www.selenic.com/mercurial/wiki/" rel="nofollow noreferrer">Mercurial</a> repositories, one on the production server and another on my local dev mac... | <p>I used to use git push to publish to my web server but lately I've just been using rsync. I try to make my site as agnostic about where it's running as possible (using relative paths, etc) and so far it's worked pretty well. The only challenge is keeping databases in sync, and for that I usually use the production d... | <p>@Andrew</p>
<p>To use git push to deploy your site you will need to do first set up a remote server in your .git/config file to push to. Then you need to configure a hook that will basically perform a git reset --hard to copy the code you just copied to the repository to the working directory.</p>
<p>I know this i... | 5,873 |
<p>I am receiving an error from the Oracle JDBC driver (ojdbc14_g.jar) when trying to obtain a connection to a 10g database. The driver has an oracle.jdbc.driver.OracleLog class which could help but the Oracle documentation is unclear how best to use it. Has anyone had any success using this class? If so, some guidance... | <p>I don't think this is a question that will get you an objective answer - Flash developers will tell you Flash is better, web developers will say JavaScript. Trying to remain objective, I'd say that both technologies are suitable for what you describe, but have different advantages.</p>
<p>Flash will definitely rend... | <p>Do you need to use canvas, what you're describing could be done with just javascript and the DOM. It would perform perfectly well unless there are a huge number of elements and it would be cross-browser compatible. For canvas you would require <a href="http://excanvas.sourceforge.net/" rel="nofollow noreferrer">ex... | 22,003 |
<p>Say we are traversing a graph and want to quickly determine if a node has been seen before or not. We have a few set preconditions.</p>
<ol>
<li>Nodes have been marked with integers values 1..N</li>
<li>Graph is implemented with nodes having an adjacency list</li>
<li>Every integer value from 1..N occurs in the gra... | <p>You can use a <a href="http://cvs.haskell.org/Hugs/pages/libraries/base/Data-Set.html" rel="nofollow noreferrer">Data.Set</a>. You add an element by creating a new set from the old one with <code>insert</code> and pass the new set around. You look up whether an element is a member of the set with <code>member</code>... | <p>I believe that Data.BitSet might be O(n).</p>
| 36,674 |
<p>My problem is that I want a grid that is populated with a set of times spent on tasks. It needs to have the days of the week at the top (these would preferably be fixed - i.e. Sun, Mon... Sat) and task names down the left column. The contents of the grid will have the individual hours spent for that day on that ta... | <p>I'll take a rough hack at it not knowing your structure but guessing you have a task table and a tasktime table that stores the actual times and dates that are charged to each task. This isn't tested but:</p>
<p>select t.taskname, sum(case when datepart(d,tt.taskdate)= 1, tt.taskhours) else 0 end) as Sunday,
sum(c... | <p>You seem to imply that the data currently resides in a database. The optimal solution depends on the amount of internal processing of the data and the existing infrastructure of the project.</p>
<p>I would either use a big SQL query to pull all the data together and bind the <code>ResultSet</code> directy to the Gr... | 44,616 |
<p>From an application I'm building I need to print existing PDFs (created by another app).
How can I do this in C# and provide a mechanism so the user can select a different printer or other properties. </p>
<p>I've looked at the PrintDialog but not sure what file it is attempting to print, if any, b/c the output is... | <p>Display a little dialog with a combobox that has its Items set to the string collection returned by <code>PrinterSettings.InstalledPrinters</code>.</p>
<p>If you can make it a requirement that <a href="http://pages.cs.wisc.edu/~ghost/gsview/gsprint.htm" rel="noreferrer">GSView</a> be installed on the machine, you c... | <p>You will need Acrobat or some other application that can print the PDF. From there you P/Invoke to <a href="http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx" rel="nofollow noreferrer">ShellExecute</a> to print the document.</p>
| 34,484 |
<p>With the recent announcement of .NET 4.0 and Visual Studio 2010, it is becoming ever more difficult to keep track of what .NET Framework versions build on what version of the CLR and belong with which version(s) of Visual Studio.</p>
<p>Is there a definitive table that shows these relationships?</p>
| <pre>
Visual Studio CLR .NET Framework
----------------------------------------------------------------------------------------
Visual Studio .NET (Ranier) 1.0.3705 1.0
Visual Studio 2003 (Everett) 1.1.4322 1.1
Visual Studio 2005 (Wh... | <p>Framework 4.0 RTM<P>Visual Studio 2010<p>Assembly Version 4.0.30319<p>Date 4/12/2010</p>
| 26,165 |
<p>I have a simple model called <code>Party</code> with a corresponding table called <code>parties</code>. There's also a controller with all the usual CRUD actions and so on. This model is used in a website and only one admin user is allowed to edit the parties - everyone else is allowed to call GET actions (index, sh... | <p>A simple "front_page" attribute would suffice or another model like you mentioned, using the has_one relationship would be fine as well.</p>
<p>Using another model would allow you to maintain some more information, like how long should it remain on the front page (expiration date?) or how many times it was featured... | <p>Personally I'm very strong on data integrity being enforced by my database so would probably add that extra table and enforce it as a foreign key constraint there.
It can seem like overkill, but is the only* solution that prevents data integrity issues.</p>
<p>Could you maybe add it as a field to the admin table/mo... | 42,886 |
<p>I am looking for a way to truncate a string in Python that will not cut off the string in the middle of a word.</p>
<p>For example:</p>
<pre>
Original: "This is really awesome."
"Dumb" truncate: "This is real..."
"Smart" truncate: "This is really..."
</pre>
<p>I'm looking for a way to accomplish the "... | <p>I actually wrote a solution for this on a recent project of mine. I've compressed the majority of it down to be a little smaller.</p>
<pre><code>def smart_truncate(content, length=100, suffix='...'):
if len(content) <= length:
return content
else:
return ' '.join(content[:length+1].split... | <p>For Python 3.4+, I'd use <a href="https://docs.python.org/3/library/textwrap.html#textwrap.shorten" rel="nofollow noreferrer">textwrap.shorten</a>.</p>
<p>For older versions:</p>
<pre><code>def truncate(description, max_len=140, suffix='…'):
description = description.strip()
if len(description) <= max... | 31,145 |
<p>The test driven development guys refer to a <em>quick, exploratory, investigation that involves coding something up to see if it works</em>, a <strong>spike</strong>.</p>
<p>Any ideas why they came up with that word?</p>
<p><strong>Update:</strong> The coinage by Kent Beck looks like the 'original' one to me, alth... | <p>Ward Cunningham writes on <a href="http://c2.com/cgi/wiki?SpikeSolution" rel="noreferrer">WardsWiki</a> (referring to Kent Beck):</p>
<blockquote>
<p>I would often ask Kent, "What is the
simplest thing we can program that
will convince us we are on the right
track?" Such stepping outside the
difficulties ... | <p>I believe it is an engineering expression. A spike is a temporary solution, something you try out to see if it works, before you make the permanent solution. Railroad engineers talk about <em>spiking a track switch</em>: inserting a rail spike into the switch, so it cannot be moved.</p>
| 31,092 |
<p>I have an ASP.Net 2.0 web site, using the DotNetNuke framework (4.09), and it will not compile, but when I hit the site in a browser, it works. Even the parts that don't compile will work. How is IIS able to compile and run this site, when Visual Studio can't? Everything is the same in both places... I copied the en... | <p>Is this a web site or a web application? If it's a web application, you're probably still running off the last successfully built bits in the bin.</p>
| <p>To give you an answer on this we would need to know what the errors are.</p>
| 14,915 |
<p>We've been trying to hunt down some heap corruption issues in our multi-threaded C++ apps. As one technique, we tried add -lmcheck to the libraries line of the application. This is causing the app to crash out with apparent heap corruption in relatively short order.</p>
<p>Our app does use both malloc/free and new/... | <p>No, mcheck is not thread-safe and should not be used with multi-threaded applications. Doing so can introduce additional problems since there is no synchronization between the threads. Here is the response from Ulrich Drepper (glibc maintainer) on the subject a few months ago:</p>
<blockquote>
<p>mcheck does no... | <p>As an alternative I can highly recommend valgrind - it will work with multithreaded applications - although it emulates threads, it doesn't actually itself use threads.</p>
| 40,650 |
<p>I recently started using Git as my version control system for some Cocoa projects I'm working on and wondered if there are best practices for working with version control systems on Cocoa projects.</p>
<p>There is the obvious "build" directory which I exclude from versioning as it's not important and can change qui... | <p>Here's my Mercurial <code>.hgignore</code> file, which is based on <a href="http://boredzo.org/blog/archives/2008-03-20/hgignore-for-mac-os-x-applications" rel="noreferrer">Peter Hosey's</a>.</p>
<pre><code>syntax: glob
.DS_Store
*.swp
*~.nib
build
*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.pyc
</code... | <p>I never commit the ${LOGNAME}.* files as they're basically preferences information for the current user; the project sources, targets, dependencies and so on are in the project.pbxproj file. And as you mentioned in your question, the build directory (assuming you have the Place Build Products in: Project directory o... | 29,222 |
<p>There is some documentation on the internet that shows that Windows changes the behavior of the NotifyIcon.BalloonTipShown command if the user is currently idle and this is <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=343411&SiteID=1" rel="nofollow noreferrer">detected by checking for keyboard ... | <p>How about the Win32 <a href="http://www.codeproject.com/KB/cs/GetIdleTimeWithCS.aspx" rel="nofollow noreferrer">LASTINPUTINFO</a> function?</p>
<pre><code>using System.Runtime.InteropServices;
[DllImport("User32.dll")]
static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
struct LASTINPUTINFO
{
publi... | <p>Thanks for the responses, I ended up going with the GetLastInputInfo function as it is pretty straight forward to implement in the application I'm working on.</p>
| 3,966 |
<p>I have experience writing console and network client/server applications in C and C++, but I know next to nothing about using the win32 visual API, MFC, Qt, wxWidgets, etc. Where is a good place to start, and what method should I specialize in, so as to be future ready and robust?</p>
| <p>This is a rather broad question, as programming GUI applications in Windows can be done in so many ways.</p>
<p>There are two main parts to developing any GUI app: the <strong>language</strong> and the <strong>API/framework</strong>. Considering you're interested in learning to build Windows GUI apps, the language ... | <p>For business apps, Windows Forms is very mature. It provides a gentle path from auto-generating a lot for you into allowing fine-grained control and rolling your own. There are tons of high-quality third party controls and a large body of examples, docs, etc out there. It's hard to run into a problem that someone e... | 2,636 |
<p>OK, so I don't want to start a holy-war here, but we're in the process of trying to consolidate the way we handle our application configuration files and we're struggling to make a decision on the best approach to take. At the moment, every application we distribute is using it's own ad-hoc configuration files, whet... | <p>XML XML XML XML. We're talking <em>config files here</em>. There is no "angle bracket tax" if you're not serializing objects in a performance-intense situation. </p>
<p>Config files must be human readable and human understandable, in addition to machine readable. XML is a good compromise between the two.</p>
<... | <p>What platform are you working on? I'd recommend trying to use the preferred/common method for it.</p>
<ol>
<li>MacOSX - plists</li>
<li>Win32 - Registry (or are there a new one here, long since I developed on it)</li>
<li>Linux/Unix - ~/.apprc (name-value perhaps)</li>
</ol>
| 3,325 |
<p>I am trying to display an HTML page inside another SharePoint webpart page.</p>
<p>I used the Out-of-the-box page viewer webpart, but the page viewer webpart displays a disabled scrollbar inside it.</p>
<p>I also tried using a content editor webpart with an IFRAME tag in it, but still it didnt't work.</p>
<p>This... | <p>"width:100%;height:100%" may be the culprit. make size of the iframe larger than the frame window. Also try using scrolling="no"</p>
| <p>I get the best results with the web capture web part instead of the page viewer web part.</p>
<p>Make sure your content doesn't have defined sizes (so it flows in the smaller frame) and then tweak the web capture part sizes until the scroll bars disappear.</p>
<p>Cheers,
Reeves</p>
| 48,109 |
<p>Compared to </p>
<ul>
<li>Simple memory access</li>
<li>Disk access</li>
<li>Memory access on another computer(on the same network)</li>
<li>Disk access on another computer(on the same network)</li>
</ul>
<p>in C++ on windows.</p>
| <p>relative timings (shouldn't be off by more than a factor of 100 ;-)</p>
<ul>
<li>memory-access in cache = 1</li>
<li>function call/return in cache = 2</li>
<li>memory-access out of cache = 10 .. 300</li>
<li>disk access = 1000 .. 1e8 (amortized depends upon the number of bytes transferred)
<ul>
<li>depending mostl... | <p>Depends on what that function does, it would fall 2nd on your list if it were doing logic with objects in memory. Further down the list if it included disk/network access.</p>
| 12,040 |
<p>I have created a Visual Studio 2008 sp1 test suite web test that uploads a document to a document library in SharePoint. The test is a lot like the one described <a href="http://www.helloitsliam.com/Lists/Posts/Post.aspx?ID=139" rel="nofollow noreferrer">here</a>.</p>
<p>All is fine until the test is converted to a... | <p>...so it turns out that while the files name was included in the test as a deployment item and the file was added to the visual studio project, the visual studio file property "Copy to Output Directory" was set as "Do not copy". Changing this to "Copy always" fixes the issue.</p>
| <p>...so it turns out that while the files name was included in the test as a deployment item and the file was added to the visual studio project, the visual studio file property "Copy to Output Directory" was set as "Do not copy". Changing this to "Copy always" fixes the issue.</p>
| 32,157 |
<p>SQL databases seem to be the cornerstone of most software. However, it seems optimized for textual data. In fact when doing any queries involving numerical data, integers specifically, it seems inefficient that the numbers are getting converted to text and then back to native formats both ways between the applicatio... | <p>Don't suppose. Measure.</p>
<p>Format conversion is not likely to be a measurable cost for database work, unless you are misusing the database as an arithmetic engine.</p>
<p>The IO cost for LOBs, especially for CLOBS with character conversion, can become significant; the remedy here, once you know that the simple... | <p>Numerical data in a database is not stored as text. I guess it depends on the database, but it certainly doesn't have to be and isn't.</p>
<p>BLOBs are stored exactly how you set them -- by definition, the DB has no way to interpret the information -- I guess it could compress if it found that to be useful. BLOBs ... | 27,047 |
<p>I've got a Palm OS/Garnet 68K application that uses a third-party static library built with CodeWarrior. Can I rebuilt the application using PRC-Tools, the port of GCC for the Palm OS platform and still link with the third-party library?</p>
| <p><em>(Expanding on Ben's original answer... not sure of the exact etiquette for that but I can't edit yet so I'll re-post)</em></p>
<p>No, CodeWarrior uses a different object file format than PRC-Tools. Also, the compiler support libraries are different, so even if the code could be statically linked together, it ma... | <p>No, CodeWarrior uses a different object file format than PRC-Tools. Also, the compiler support libraries are different, so even if the code could be linked together, it may use symbols in a different way.</p>
<p>However, if you can wrap the third-party library into a shared library using CodeWarrior, then you shou... | 3,784 |
<p>Trying the easy approach:</p>
<blockquote>
<p>sqlite2 mydb.db .dump | sqlite3 mydb-new.db</p>
</blockquote>
<p>I got this error:</p>
<blockquote>
<p>SQL error near line 84802: no such column: Ð</p>
</blockquote>
<p>In that line the script is this:</p>
<blockquote>
<p>INSERT INTO vehiculo VALUES(127548,'21... | <p>Simply open the v2 database with the sqlite3 binary CLI, and then save it. The database file will be transparently migrated to v3.</p>
<pre><code>$ sqlite3 v2database.db
sqlite> .quit
$
</code></pre>
<p>Note: you may need to insert/delete a row before quitting to force an update.</p>
| <p>I tried to do it without windows intervention:</p>
<blockquote>
<p>*by calling sqlite2 on old.db, and send the dump directly to a file</p>
<p>*and then call sqlite3 on new.db and loading the dump directly from the file.</p>
</blockquote>
<p>Just in case windows was messing with the characters on the command-line.</p... | 12,071 |
<p>Instead of having to remember to initialize a simple 'C' structure, I might derive from it and zero it in the constructor like this:</p>
<pre><code>struct MY_STRUCT
{
int n1;
int n2;
};
class CMyStruct : public MY_STRUCT
{
public:
CMyStruct()
{
memset(this, 0, sizeof(MY_STRUCT));
}
};
<... | <p>You can simply value-initialize the base, and all its members will be zero'ed out. This is guaranteed</p>
<pre><code>struct MY_STRUCT
{
int n1;
int n2;
};
class CMyStruct : public MY_STRUCT
{
public:
CMyStruct():MY_STRUCT() { }
};
</code></pre>
<p>For this to work, there should be no user declared con... | <p>It's a bit of code, but it's reusable; include it once and it should work for any POD. You can pass an instance of this class to any function expecting a MY_STRUCT, or use the GetPointer function to pass it into a function that will modify the structure.</p>
<pre><code>template <typename STR>
class CStructWr... | 13,723 |
<p>How can i draw a dotted line in .NET/WinForms/GDI+?</p>
<pre><code>Pen p = new Pen (Color.Black)
</code></pre>
<p>gives me only solid line pen. </p>
<p>I am trying to have a dotted (or dashed) lines; can't seem to be able to google it up successfully.</p>
<p>Will much appreciate any help on this one.</p>
| <pre><code>p.DashStyle = DashStyle.Dash;
</code></pre>
<p>I believe.</p>
| <p>Set the DashStyle property on your Pen object.</p>
| 32,519 |
<p>I'm adding C# WPF dialogs to an existing C++ MFC app, using a C++/CLI interface layer. I've got things working, except I'm having a problem with modality. For example:</p>
<ol>
<li>MFC app shows a WPF dialog using ShowDialog. Works as expected.</li>
<li>That WPF dialog shows a MFC dialog using DoModal. The WPF dial... | <p>When opening a CDialog, the trick is to use a WindowsInteropHelper to get the parent WPF dialog's HWND. Then, you can use CWnd::Attach to wrap that HWND in a CWnd class to pass to the CDialog's constructor.</p>
<p>The problem I had was that I already had the CDialog constructed., but not yet displayed. The various ... | <p>When showing the WPF dialog, are you using the <a href="http://msdn.microsoft.com/en-gb/library/ms742522.aspx#hosting_a_wpf_page" rel="nofollow noreferrer">HwndSource class</a> to wrap the WPF window? If so, you may be able to <a href="http://msdn.microsoft.com/en-us/library/ms633541(VS.85).aspx" rel="nofollow noref... | 34,423 |
<p>Problem is described and demonstrated on the following links:</p>
<ul>
<li><a href="https://web.archive.org/web/20081123055336/http://paulstovell.com/blog/wpf-why-is-my-text-so-blurry" rel="noreferrer">Paul Stovell WPF: Blurry Text Rendering </a></li>
<li><a href="http://www.gamedev.net/community/forums/topic.asp... | <h3>Technical background</h3>
<p>There is a in-depth article about WPF Text rendering from one of the WPF Text Program Managers on windowsclient.net: <a href="http://windowsclient.net/wpf/white-papers/wpftextclarity.aspx" rel="noreferrer">Text Clarity in WPF</a>.</p>
<p>The problem boils down to WPF needing a linearl... | <p>If you prefer to use a C# base class to customizing windows for your app (or now have a reason to), here's how you set can set the text formatting to use the appealing Display mode:</p>
<pre><code>public class SnappyWindow : Window
{
public SnappyWindow()
{
SetValue(TextOptions.TextFormattingModePro... | 23,098 |
<p>Is it possible to install the x86 Remote Debugger as a Service on a 64bit machine? I need to attach a debugger to managed code in a Session 0 process. The process runs 32bit but the debugger service that gets installed is 64bit and wont attach to the 32bit process. </p>
<p>I tried creating the Service using the ... | <p>This works on my machine(TM) after installing rdbgsetup_x64.exe and going through the configuration wizard:</p>
<pre><code>sc stop msvsmon90
sc config msvsmon90 binPath= "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86\msvsmon.exe /service msvsmon90"
sc start msvsmon90
</code></pre>
| <p>Worked for me without installing additional software. I just copied the <code>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger</code> folder on the VM and started the <code>msvsmon.exe</code> from the <code>x86</code> folder. Both my guest and host are <code>x64</code>.</p>
| 10,255 |
<p>The following code:</p>
<pre><code>template <typename S, typename T>
struct foo {
void bar();
};
template <typename T>
void foo <int, T>::bar() {
}
</code></pre>
<p>gives me the error</p>
<pre><code>invalid use of incomplete type 'struct foo<int, T>'
declaration of 'struct foo<int, ... | <p>You can't partially specialize a function. If you wish to do so on a member function, you must partially specialize the entire template (yes, it's irritating). On a large templated class, to partially specialize a function, you would need a workaround. Perhaps a templated member struct (e.g. <code>template <typen... | <p>In C++ 17, I use "if constexpr" to avoid specialize (and rewrite) my method. For example :</p>
<pre><code>template <size_t TSize>
struct A
{
void recursiveMethod();
};
template <size_t TSize>
void A<TSize>::recursiveMethod()
{
if constexpr (TSize == 1)
{
//[...] imple... | 19,955 |
<p>I often want to trigger a certain function just once, but I need to trigger it from within another function that gets repeatedly called. For instance, taking a snapshot of something for later use. I usually do it by setting a global boolean.</p>
<p>I'm wondering whether the way I do it is actually best way? </p>
<... | <p>When you call a function it should do what you expect it to do with the arguments you give it. If you call a function twice in exactly the same way you should expect that function to give you the same results or do the same thing.</p>
<p>It is probably better to move this call-once dependency to the logic that call... | <p>I see nothing wrong with your approach here. Keep in mind there isn't always the "Right" thing...there are definetly wrong things but what is right can be subjective, and can also depend dramatically based on the requirements of the system.</p>
| 46,189 |
<p>How do I name a result group in a Regex? (.Net)</p>
| <pre><code>(?<NameOfGroup>[a-z]*)
</code></pre>
<p>Use the ? syntax like in the sample above.</p>
| <pre><code>(?<first>group)(?'second'group).
</code></pre>
<p><a href="http://www.regular-expressions.info/named.html" rel="nofollow noreferrer">http://www.regular-expressions.info/named.html</a></p>
| 13,679 |
<p>I am creating a <code>gridView</code> that allows adding new rows by adding the controls necessary for the insert into the <code>FooterTemplate</code>, but when the <code>ObjectDataSource</code> has no records, I add a dummy row as the <code>FooterTemplate</code> is only displayed when there is data.</p>
<p>How can... | <p>You could handle the gridview's databound event and hide the dummy row. (Don't forget to assign the event property in the aspx code):</p>
<pre><code>protected void GridView1_DataBound(object sender, EventArgs e)
{
if (GridView1.Rows.Count == 1)
GridView1.Rows[0].Visible = false;
}
</code... | <p>It can easily be done by SQL </p>
<pre><code>USE YourdatabaseName select * from TableName where Column_Name <> ''
</code></pre>
| 13,981 |
<p>For personal usage, indoor, I'm doing some experiments with following lamp (v0.1):</p>
<p><a href="https://i.stack.imgur.com/SrEhy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SrEhy.jpg" alt="enter image description here"></a></p>
<p>Lamp is a led bulb enclosed in a methacrylate tube and with... | <p><a href="https://3dprinting.stackexchange.com/a/4488/5740">EvilTeach's</a> answer is correct, ABS is a more reliable plastic for any kind of work which may get above what feels "hot to the touch." </p>
<p>Just to elaborate on the why: the property you're looking for in the thermoplastic (which will determine the co... | <p>I had a PLA print that would weaken and deform when sitting in the car on a hot day. I think you should try it with ABS.</p>
| 666 |
<p>for example this code</p>
<pre><code>var html = "<p>This text is <a href=#> good</a></p>";
var newNode = Builder.node('div',{className: 'test'},[html]);
$('placeholder').update(newNode);
</code></pre>
<p>casues the p and a tags to be shown, how do I prevent them from being escaped?</p>
| <p>The last parameter to Builder.node is "Array, List of other nodes to be appended as children" according to the <a href="http://github.com/madrobby/scriptaculous/wikis/builder" rel="nofollow noreferrer">Wiki</a>. So when you pass it a string it is treated like text.</p>
<p>You could use:</p>
<pre><code>var a = Buil... | <p>You can use this solution: <a href="http://sviudes.blogspot.com/2009/08/como-usar-etiquetas-html-con.html" rel="nofollow noreferrer">http://sviudes.blogspot.com/2009/08/como-usar-etiquetas-html-con.html</a></p>
| 9,679 |
<p>I have already read the posts <a href="https://stackoverflow.com/questions/203495/testing-rest-webservices" title="here">link text</a> and <a href="https://stackoverflow.com/questions/303911/rest-tools-support-for-development-and-testing" title="here">link text</a> but these are covering the use case of building a R... | <p>Depends on how your REST service will actually return the data. You should be able to abstract all the service calls and then mock JSON responses - randomly rotating the responses should be pretty straight forward. </p>
<p>The other thing you could do is put several result docs on the server (as above) and rotate... | <p>You could just create a result document and put it on a web server..
Then point the REST URL at the document.
No matter what your input the output is always the pre-formated result.</p>
| 47,961 |
<p>How can I create a scheduled task to run a PHP file?<br />
Yes, I filled out everything in the scheduled task, but it still doesn't work.</p>
<blockquote>
<p>Run: "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\WEB\4w_website\save.php"</p>
<p>Start in: "C:\Program Files\Apache Software F... | <p>The Run command should be</p>
<pre>
C:\Path\to\php.exe -f "C:\Path\to\file.php"
</pre>
<p>From the command line help of php.exe:</p>
<pre>
-f Parse and execute <file>.
</pre>
| <p>I think, you must execute your PHP script via URL.
you can write batch script for execute URL.
Why you don't write backend script in other language such as batch script, vbscript or etc.</p>
| 37,748 |
<p>MonoDevelop 1.0 doesn't appear to have a code-formatter like Eclipse does for Java. Is there a preferred shell script (or MonoDevelop add-in?) that you've found to work well?</p>
| <p>At the moment, source code formatting in MonoDevelop is marked as a future enhancement:
<a href="https://bugzilla.novell.com/show_bug.cgi?id=321946" rel="noreferrer">https://bugzilla.novell.com/show_bug.cgi?id=321946</a></p>
<p>In the meantime, you may want to check out Artistic Style for C# formatting:
<a href="ht... | <p>It's a nice programming exercise to write your own formatter . I wrote one for C++ , and it was a nice challenge . You could learn a lot by writing it :)</p>
| 11,069 |
<p>I'm having an issue with my very first printer, a Monoprice Select Mini V2. After doing about 20 successful prints on it, the Z axis is suddenly acting very odd.</p>
<p>When I 'home' the Z axis and move the nozzle on the X and Y, I can do the paper test on all four corners of the bed without issue - the leveling is... | <p>Check the Z-drive for any component looseness. Look at belts, gears, anything with screws. Wiggle things mercilessly checking for play. </p>
<p>At the start of a normal print run, the the print head typically rises up very high as the head warms up (depends on software) and then lowers to print. If your homing pape... | <p>I just had this issue with my Monoprice Select Mini V2. It seems there's some bug in the software if you already have the 3D printer at its lowest Z-elevation before starting the home calibration. To make sure it prints correctly, move the head up using the manual controls, then hit home. It should then go to the co... | 921 |
<p>A lot of programmers who are used Visual Studio have a hard time adjusting to the fact that in other source control systems, files do not need to be locked/checked out to one developer at any given time.</p>
<p>Proponents of merging say that allowing two people to work on the same file speeds up productivity since ... | <p>Having switched from locked model to merge model, I will make the following observations:</p>
<ul>
<li>Most merge users tend to stay fairly close to the "head" version of the branch they're developing on. This normally means that the dramatic merge problems are not very common.</li>
<li>In 10 or so years of merge m... | <p>Common complaint against locking VCSes is that you have a problem when somebody goes for a vacation or conference leaving some files locked :)</p>
| 35,895 |
<p>How does one prevent an inclusion cycle in C? ie. You shouldn't have a.h #include "b.h", which #include's "c.h" which #include's "a.h". I'm looking for a way of preventing this from happening using some sort of C directive.</p>
<p>I had originally thought this would've prevented this from happening:</p>
<p>Content... | <p>It does work allright: the files <strong>are</strong> repeatedly included, but the sections protected by #ifdndef/#define/#endif <strong>are not</strong> repeated, and that breaks the cycle.</p>
<p>Use your compiler to produce the preprocessed output and look at it for yourself. With GNU CC, you need to use "-E" o... | <p>This works.</p>
<p>Just to be sure, I actually compiled a test.c that included a.h with your 3 header files.</p>
<p>I verified this works for several versions of MSVC, Digital Mars and GCC.</p>
| 34,522 |
<p>How can I read the status of the battery on my MacBookPro from my own application?</p>
<p>Googling has so far only revealed APIs for device drivers to handle power events - there's nothing about user-land processes accessing this information.</p>
<p>thanks.</p>
| <p>You'll want to use IOKit for this, specifically the <a href="https://developer.apple.com/documentation/iokit/iopowersources.h" rel="nofollow noreferrer">IOPowerSources functions</a>. You can use <code>IOPSCopyPowerSourcesInfo()</code> to get a blob, and <code>IOPSCopyPowerSourcesList()</code> to then extract a CFAr... | <p>Look at the System Management Controller. I don't have my MBP handy, but I believe you need to look at smc.h</p>
| 34,311 |
<p>I couldn't really find this in Rails documentation but it seems like <strong>'mattr_accessor'</strong> is the <strong>Module</strong> corollary for <strong>'attr_accessor'</strong> (getter & setter) in a normal Ruby <strong>class</strong>.</p>
<p>Eg. in a class</p>
<pre><code>class User
attr_accessor :name
... | <p>Rails extends Ruby with both <code>mattr_accessor</code> (Module accessor) and <code>cattr_accessor</code> (as well as _<code>reader</code>/<code>_writer</code> versions). As Ruby's <code>attr_accessor</code> generates getter/setter methods for <em>instances</em>, <code>cattr/mattr_accessor</code> provide getter/se... | <p><a href="http://github.com/rails/rails/tree/2-1-stable/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb" rel="noreferrer">Here's the source for <code>cattr_accessor</code></a></p>
<p>And </p>
<p><a href="http://github.com/rails/rails/tree/2-1-stable/activesupport/lib/active_support/core_ext/m... | 22,447 |
<p>If I have something like a loop or a set of if/else statements, and I want to return a value from within the nest (see below), is the best way of doing this to assign the value to a field or property and return that?</p>
<p>See below:</p>
<pre><code>bool b;
public bool ifelse(int i)
{
if(i == 5)
{
b = true;
}
el... | <p>what about</p>
<pre><code>return i == 5;
</code></pre>
| <p>I would say if you should generally only return from a method in two places - near the beginning (as in guard conditions) and near the end; If the method has any length to it, you should use a temporary variable as you mentioned, otherwise people reading the code may have a harder time following it.</p>
| 44,055 |
<p>I need a tool to measure a website's performance that's free and does not require any changes to be made to the code (jsp asp pages). All help is appreciated.</p>
| <p>For performance measurement I recommend you <a href="http://developer.yahoo.com/yslow/" rel="nofollow noreferrer">YSlow</a>, it's a Firefox add-on integrated with <a href="http://getfirebug.com" rel="nofollow noreferrer">Firebug</a>, it analyzes your web pages and tells you why they're slow based on the <a href="htt... | <p>You could also use <a href="http://www.fiddlertool.com/fiddler/" rel="nofollow noreferrer">Fiddler</a> which will work for browsers other than Firefox. (But will not profile javascript code) </p>
<p>See <a href="http://msdn.microsoft.com/en-us/library/bb250442(VS.85).aspx" rel="nofollow noreferrer">this post</a></p... | 38,108 |
<p>I'm on a team maintaining a .Net web app with a SQL Server 2005 back end. The system's been running a little slow in places lately, so after doing all the tuning kind of stuff we could think of (adding indexes, cleaning up really badly written stored procedures, etc.) I ran a typical workload through the Tuning Adv... | <p>Sql Server does a good job of managing statistics if you have enabled auto-create and auto-update of statistics (you should), so ignore the statistics recommendations. Take the indexes and analyze them to make sure you can handle the extra space requirements, and also make sure they aren't duplicating some other in... | <p>Like all advice take it with a grain of salt and use it to reach your own conclusion.</p>
| 17,022 |
<p>I have a view which contains a form, the form posts and the data gets processed etc, then I want to return the view Index, so return view("Index");</p>
<p>however this will then complain about my ViewData not existing, I get the feeling that the controller code under Index() isn't being processed which adds the lis... | <p>I think you should have two actions: one that processes the form submission, and another one that collects data for the view.
Once the form has been processed, you call <code>return RedirectToAction("Index")</code> and you are done.
I hope I understood what you meant by this.</p>
| <p>If your Index method on the controller does a <code>return View("Index");</code> then just call the Index method with any parameters it requires. Then the method will populate the ViewData reuired by the Index View.</p>
| 41,026 |
<p>i've populated a dropdownlist control with different text properties but each text properties had THE SAME value (text property was A, value properties is blah,text property was B, value properties is blahblah, etc... )</p>
<p>ASP.net only checks value properties on postback and because ALL values were the same (fo... | <p>Sounds like you are working on the wrong event. Try <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.onselectedindexchanged(VS.85).aspx" rel="noreferrer">SelectedIndexChanged</a>.</p>
<p>Ensure you also have the <code>AutoPostBack</code> property set to <code>True</code>.</p>
<h... | <p>The problem is that if the selected index doesn't change the postback won't fire. In the case where the user makes the same selection, the selected index does not change.</p>
<p>Sorry that this doesn't answer the question, but it does explain the behavior as far as I know.</p>
| 41,232 |
<p>I am supporting a system which sends an automatic populated email alert. I have rendered the page using a combination of CSS and html. The alert is sent from a system called Salesforce. My problem is, I have never owned a blackberry, and don't have access to one for testing purposes, but I know the alert looks like ... | <p>To start with, in order to see HTML rendered e-mail on a BlackBerry simulator, no matter the model, the simulator must run off of a BES connection (corporate BlackBerry server), as <strong>the included ESS</strong> (the software POP/SMTP proxy app that allows you to test BlackBerry e-mail services locally), <strong>... | <p>Only very very recently has RIM released firmware that supports HTML email. That firmware still needs to be customized by the carriers and updated by the consumers. Also, the BES server has to be upgraded to the latest version to support HTML email.</p>
<p>My guess is that there will not be many Blackberry users ... | 46,751 |
<p>I have a form like this:</p>
<pre><code><form name="mine">
<input type=text name=one>
<input type=text name=two>
<input type=text name=three>
</form>
</code></pre>
<p>When user types a value in 'one', I sometimes want to skip the field 'two', depending on what he typed. Fo... | <p>Try to attach tabindex attribute to your elements and then programmaticaly (in javaScript change it):</p>
<pre><code><INPUT tabindex="3" type="submit" name="mySubmit">
</code></pre>
| <pre><code><form name="mine">
<input type="text" name="one" onkeypress="if (mine.one.value == '123') mine.three.focus();" />
<input type="text" name="two">
<input type="text" name="three">
</form>
</code></pre>
| 10,465 |
<p>I'm using Excel VBA to a write a UDF. I would like to overload my own UDF with a couple of different versions so that different arguments will call different functions. </p>
<p>As VBA doesn't seem to support this, could anyone suggest a good, non-messy way of achieving the same goal? Should I be using Optional argu... | <p>Declare your arguments as <code>Optional Variants</code>, then you can test to see if they're missing using <code>IsMissing()</code> or check their type using <code>TypeName()</code>, as shown in the following example:</p>
<pre><code>Public Function Foo(Optional v As Variant) As Variant
If IsMissing(v) Then
... | <p>VBA is messy. I'm not sure there is an easy way to do fake overloads:</p>
<p>In the past I've either used lots of Optionals, or used varied functions. For instance </p>
<pre><code>Foo_DescriptiveName1()
Foo_DescriptiveName2()
</code></pre>
<p>I'd say go with Optional arguments that have sensible defaults unless ... | 8,999 |
<p>I wonder if it is possible to create an executable module from a Python script. I need to have the most performance and the flexibility of Python script, without needing to run in the Python environment. I would use this code to load on demand user modules to customize my application.</p>
| <ul>
<li>There's <a href="http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/" rel="nofollow noreferrer">pyrex</a> that compiles python like source to python extension modules </li>
<li><a href="https://rpython.readthedocs.io/en/latest/" rel="nofollow noreferrer">rpython</a> which allows you to compile python wit... | <p>I think you can use jython to compile python to Java bytecode, and then compile that with GCJ.</p>
| 25,116 |
<p>I´ve tried tunning printer settings with different Nozzle(190-210 ºC)/ Bed(0-60 ºC) Temperatures, Fan Speeds (0-100 %), Cura and Slicer adjustemens but nothing worked. I still get the same bubbles in the first 3 mm of every print.
I also tried a glass bed and the magnetic bed that comes with End... | <p>It seems like your bed might be too close to the nozzle, hence the large elephants foot (bulge on the first layer). You can try using babystep Z to increase the distance between the nozzle and the bed and see how that works out. I think you might need to reduce the flow multiplier (extrusion multiplier) a little too... | <p>It seems like your bed might be too close to the nozzle, hence the large elephants foot (bulge on the first layer). You can try using babystep Z to increase the distance between the nozzle and the bed and see how that works out. I think you might need to reduce the flow multiplier (extrusion multiplier) a little too... | 1,637 |
<p>In the past I have used nexo.com to share documents with sales, marketing, PR, and technical people for a small startup. But I wonder if there is a better solution to allow different types of geo-graphically dispersed workers to get to a variety of uploaded documents. I don't want to have to build or host this mysel... | <p>I haven't used this myself just yet, but I've heard great things about it <a href="http://docs.google.com" rel="nofollow noreferrer">google docs</a></p>
| <p>We use a combination of:</p>
<ul>
<li>Backpack</li>
<li>SVN</li>
<li>JungleDisk</li>
</ul>
| 38,366 |
<p>I want to pose a question such as:</p>
<blockquote>
<p>What is your name? Joe</p>
</blockquote>
<p>How would I accomplish this using <code>Console.WriteLine</code> to also wait for the response on that same line instead of it being broken into:</p>
<blockquote>
<p>What is your name?</p>
<p>Joe</p>
</blockquote>
| <p>Use <a href="https://learn.microsoft.com/en-us/dotnet/api/system.console.write?view=net-5.0" rel="nofollow noreferrer"><code>Console.Write</code></a> instead, so there's no newline written:</p>
<pre><code>Console.Write("What is your name? ");
var name = Console.ReadLine();
</code></pre>
| <p>As Matt has said, use <code>Console.Write</code>. I would also recommend explicitly flushing the output, however - I believe <code>WriteLine</code> does this automatically, but I'd seen oddities when just using <code>Console.Write</code> and then waiting. So Matt's code becomes:</p>
<pre><code>Console.Write("What i... | 40,878 |
<p>I am trying to fix some bugs in a product I inherited, and I have this snippet of javascript that is supposed to hilight a couple of boxes and pop up a confirm box. What currently happens is I see the boxes change color and there is a 5 or so second delay, then it's as if the missing confirm just accepts itself. D... | <p>The only thing I can think of is if one of the lines before the confirm is throwing an exception and you're never actually getting to the confirm.</p>
<p>If you're using IE, make sure script debugging is enabled. If you're using Firefox, install the Firebug add-on and enable it for your website.</p>
<p>Or, for ve... | <p>I do not like accesing objects directly by</p>
<pre><code>document.getElementById("ctl00_ContentPlaceHolderMain_INDet_lblFreight").style.background = "yellow";
</code></pre>
<p>If the object is not returned JavaScript will error out. I prefer the method of</p>
<pre><code>var obj = document.getElementById("ctl00... | 21,552 |
<p>Has anyone able to assign multiple users to a sharepoint workflow task using the CreateTask activity?</p>
| <p>Sharepoint task allow the use of groups. Assign the task to a group and trigger the work flow when a task has been assigned.</p>
| <p>What version? WSS V3 or MOSS?</p>
<p>Is the "Create Task" bound to the Task List? If so then only one person at a time. Unless you have an AD group with a bunch of people or you modify the list to include SharePoint groups in the assigned to field.</p>
| 37,562 |
<p>I need a quick algorithm to select 5 random elements from a generic list. For example, I'd like to get 5 random elements from a <code>List<string></code>.</p>
| <p>Iterate through and for each element make the probability of selection = (number needed)/(number left)</p>
<p>So if you had 40 items, the first would have a 5/40 chance of being selected. If it is, the next has a 4/39 chance, otherwise it has a 5/39 chance. By the time you get to the end you will have your 5 items, ... | <p>When N is very large, the normal method that randomly shuffles the N numbers and selects, say, first k numbers, can be prohibitive because of space complexity. The following algorithm requires only O(k) for both time and space complexities.</p>
<p><a href="http://arxiv.org/abs/1512.00501" rel="nofollow">http://arxi... | 7,044 |
<p>I have a solution that contains a good deal of projects, </p>
<p>I would like to remove the source control bindings completely, how can I do this?</p>
<p><strong>Update:</strong>
What I really want to do is move one solution and its projects from TFS 2005 -> 2008. Thats why I am removing the bindings, is there a b... | <p>File -> Source Control -> Advanced -> Change Source Control and then unbind and/or disconnect all projects and the solution.</p>
<p>This should remove all bindings from the solution and project files. (After this you can switch the SCC provider in Tools -> Options -> Source Control -> Plug-in Selection).</p>
<p>Th... | <p><a href="http://blog.instance-factory.com/?p=565" rel="nofollow">Here you can find another tool</a> (including source code) to remove both SCC footprint from the solution and project files and the .vssscc and .vspscc files. In addition, it removes the output and other configurable directories.</p>
<p>Hth</p>
<p>St... | 46,808 |
<p>Is there an ascii value I can put into a char in C++, that represents nothing? I tried 0 but it ends up screwing up my file so I can't read it.</p>
| <p>ASCII 0 is null. Other than that, there are no "nothing" characters in traditional ASCII. If appropriate, you could use a control character like SOH (start of heading), STX (start of text), or ETX (end of text). Their ASCII values are 1, 2, and 3 respectively.</p>
<p>For the full list of ASCII codes that I used for... | <p>it would depend on what kind of file it is and who is parsing it.</p>
| 35,310 |
<p>If two users are accessing same database table, how do we prevent users from overwriting each other’s data?</p>
| <p>Look at <a href="https://stackoverflow.com/questions/129329/optimistic-vs-pessimistic-locking#129397">This discussion</a> for a review of different strategies or techniques for database locking in an application.</p>
| <p>This is a big question with no easy answer. It call comes down to how willing are you to block one user while another user is working on it, and how do you prevent deadlocks and lousy performance while it's happening. Also, are you trying to prevent one user from updating the same row as the other, or just updatin... | 20,202 |
<p>This is a follow-up to a <a href="https://stackoverflow.com/questions/347109/how-do-i-concisely-implement-multiple-similar-unit-tests-in-the-python-unittest">previous question</a> of mine.</p>
<p>In the previous question, methods were explored to implement what was essentially the same test over an entire family of... | <p>Nose has a "test generator" feature for stuff like this. You write a generator function that yields each "test case" function you want it to run, along with its args. Following your previous example, this could check each of the functions in a separate test:</p>
<pre><code>import unittest
import numpy
from somew... | <p>You could try to generate the testcase classes with type()</p>
<pre><code>class UnderTest_MixIn(object):
def f1(self, i):
return i + 1
def f2(self, i):
return i + 2
SomeDynamicTestcase = type(
"SomeDynamicTestcase",
(UnderTest_MixIn, unittest.TestCase),
{"even_more_dynamic":... | 45,232 |
<p>What is a good way to edit a Web.config file programmatically?</p>
<p>I looked into System.Xml but couldn't find any obvious answers.</p>
| <p><a href="http://www.dotnetspider.com/resources/17562-Edit-Delete-Create-Encrypt-sections.aspx" rel="noreferrer">This fellow</a> shows sample code if you still want to do it after all the caveats:</p>
<pre><code>protected void EditConfigButton(object sender, EventArgs e)
{
Configuration objConfig = System.Web.Con... | <p>Yes I agree with Josh. I have tried this before and I've had two negative effects:</p>
<ol>
<li>Slow loading if the current page after postback because ASP.NET is loading the web.config and all related resources</li>
<li>If you change the web.config early enough in the load cycle (e.g. global.asax events) the site... | 33,963 |
<p>I have a bunch of classes I want to rename. Some of them have names that are small and that name is reused in other class names, where I don't want that name changed. Most of this lives in Python code, but we also have some XML code that references class names.</p>
<p>Simple search and replace only gets me so far... | <p>In the meantime, I've tried it two tools that have some sort of integration with vim.</p>
<p>The first is <a href="https://github.com/python-rope/rope" rel="noreferrer">Rope</a>, a python refactoring library that comes with a Vim (and emacs) plug-in. I tried it for a few renames, and that definitely worked as expe... | <p>You can use sed to perform this. The trick is to recall that regular expressions can recognize word boundaries. This works on all platforms provided you get the tools, which on Windows is Cygwin, Mac OS may require installing the dev tools, I'm not sure, and Linux has this out of the box. So grep, xargs, and sed sho... | 4,842 |
<p>Recently, I noticed some people mentioning that <code>std::list::size()</code> has a linear complexity.<br>
According to <a href="http://www.cplusplus.com/reference/stl/list/size.html" rel="noreferrer">some</a> <a href="http://bytes.com/forum/thread60248.html" rel="noreferrer">sources</a>, this is in fact implementa... | <h2>Pre-C++11 answer</h2>
<p>You are correct that the standard does not state what the complexity of <code>list::size()</code> must be - however, it does recommend that it "should have constant complexity" (Note A in Table 65).</p>
<p><a href="http://howardhinnant.github.io/On_list_size.html" rel="nofollow noreferrer... | <p>If you are correctly using lists you aren't probably noticing any difference.</p>
<p>Lists are good with big data structures that you want to rearrange without copying, of for data you want to keep valid pointers after insertion.</p>
<p>In the first case it makes no difference, in the second i would prefer the old... | 28,329 |
<p>The large network (of small world graph type) I wish to deal with is dynamic in nature, new nodes are added and subtracted frequently. Presumably using D* over A* would be a better way to detect paths in this dynamic environment?</p>
<p>How solid is D*? has it had any real world experience? like a cryptographic alg... | <p>As I understand, the first time you run D* it finds the same path as A* with nearly the same runtime. However, when a node changes it's edge value or nodes are added A* recomputes ALL of the path while D* simply recomputes the inconsistent nodes the second time around rather than the whole thing.</p>
<p>Anthony St... | <p>I have implemented both D* and A* algorithm. So, I advice you that, if your map has no dynamic obstacles, you should implement A*. Else, implement D*. For the main reason is:
At the first search, D* calculates all nodes in the map, then shows you the shortest path, while A* only calculates a limited area around goa... | 28,251 |
<p>I know there is no "right" heap size, but which heap size do you use in your applications (application type, jdk, os)?</p>
<p>The JVM Options <code>-Xms</code> (initial/minimum) and <code>-Xmx</code> (maximum) allow for controlling the heap size. What settings make sense under which circumstances? When are the defa... | <p>You have to try your application and see how it performs. for example, I used to always run IDEA out of the box until I've got this new job where I work on this huge monolithic project. IDEA was running very slow and regularly throwing out of memory errors when compiling the full project. </p>
<p>first thing I did ... | <p>Typically i try not to use heaps which are larger than 1GB.
It will cost you on major garbage collections.</p>
<p>Sometime it is better to split your application to a few JVM on the same machine and not you large heap sizes.</p>
<p>Major collection with a large heap size can take >10 mintues (on unoptimized GC app... | 10,888 |
<p>I need a quick easy way to get a string from a file in standard C++. I can write my own, but just want to know if there is already a standard way, in C++.</p>
<p>Equivalent of this if you know Cocoa:</p>
<pre><code>NSString *string = [NSString stringWithContentsOfFile:file];
</code></pre>
| <p>We can do it but it's a long line :</p>
<pre><code>#include<fstream>
#include<iostream>
#include<iterator>
#include<string>
using namespace std;
int main()
{
// The one-liner
string fileContents(istreambuf_iterator<char>(ifstream("filename.txt")), istreambuf_iterator<char&... | <p>If you do it like the following (but properly wrapped up nicely unlike below), you can read in the file without worrying about a 0x1A byte in the file (for example) cutting the reading of the file short. The previously suggested methods will choke on a 0x1A (for example) in a file.</p>
<pre><code>
#include <iost... | 16,541 |
<p>I am getting the following error when I put class files in subfolders of my App_Code folder:</p>
<p>errorCS0246: The type or namespace name 'MyClassName' could not be found (are you missing a using directive or an assembly reference?)</p>
<p>This class is not in a namespace at all. Any ideas?</p>
| <p>You need to add codeSubDirectories to your compilation element in web.config</p>
<pre><code><configuration>
<system.web>
<compilation>
<codeSubDirectories>
<add directoryName="View"/>
</codeSubDirectories>
</compilation>
</... | <p>As you add folders to your app_code, they are getting separated by different namespaces, if I recall correctly, using the default namespace as the root, then adding for each folder.</p>
| 18,754 |
<p>I have an XML document with several <code><person></code> elements, each of which contains the <code><name></code> of the person, and several <code><preferred-number></code> elements inside a grouping <code><preferred-numbers></code> element. </p>
<p>I already found that to obtain the greate... | <p>One can use the "maximum" template as provided by <a href="http://fxsl.sf.net" rel="nofollow noreferrer"><strong>FXSL -- the Functional Programming Library for XSLT</strong></a>. FXSL is written entirely in XSLT itself.</p>
<p>Here is an example of using the "maximum" template:</p>
<p>When this transformation:</p>... | <p>When it comes to sorting stuff in XSLT 1.0 you have to use a slightly roundabout approach as I recall. If you haven't already you'll want to look into <a href="http://www.jenitennison.com/xslt/grouping/muenchian.html" rel="nofollow noreferrer">Muenchian grouping</a> to give you some ideas to start with.</p>
<p>I've... | 42,246 |
<p>What is better as far as performance goes?</p>
| <p>There is only one way to know: Time it.</p>
<p>In general, I think a single join enables the database to do a lot of optimizations, as it can see all the tables it needs to scan, overhead is reduced, and it can build up the result set locally.</p>
<p>Recently, I had about 100 select-statements which I changed int... | <p>If you are using SQL Server (I am not sure if this is available with other RDBMSs) I would suggest that you bundle an execution plan with you query results. This will give you the ability to see exactly how your query(s) are being executed and what is causing any bottlenecks.</p>
<p>Until you know what SQL Server ... | 49,469 |
<p>Within c#, I need to be able to</p>
<ul>
<li>Connect to a remote system, specifying username/password as appropriate</li>
<li>List the members of a localgroup on that system</li>
<li>Fetch the results back to the executing computer</li>
</ul>
<p>So for example I would connect to \SOMESYSTEM with appropriate creds,... | <p>This should be easy to do using WMI. Here you have a pointer to some docs:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa394507.aspx" rel="nofollow noreferrer">WMI Documentation for Win32_UserAccount</a></p>
<p>Even if you have no previous experience with WMI, it should be quite easy to turn that VB Sc... | <p>You should be able to do this with System.DirectoryServices.DirectoryEntry. If you are having trouble running it remotely, maybe you could install something on the remote machines to give you your data via some sort of RPC, like remoting or a web service. But I think what you're trying should be possible remotely ... | 4,167 |
<p>I have learned so much from <a href="http://www.summerofnhibernate.com/" rel="nofollow noreferrer">http://www.summerofnhibernate.com/</a> nhibernate screen casts that i wonder why they are given as free!. Did you know about other such .net screen casts? </p>
| <p>Rob Conery's <a href="http://blog.wekeroad.com/mvc-storefront/" rel="nofollow noreferrer">MVC Storefront</a> series has been excellent. It has covered a lot of ground, not limited to ASP.NET MVC.</p>
| <p>I learned a lot with the <a href="http://www.asp.net/LEARN/" rel="nofollow noreferrer">ASP .NET Videos</a></p>
<p>There are some other good videos <a href="http://www.learnvisualstudio.net/Browse.aspx" rel="nofollow noreferrer">here</a> also.</p>
| 39,672 |
<p>Recently I got IE7 crashed on Vista on jar loading (presumably) with the following error:</p>
<pre><code>Problem signature:
Problem Event Name: BEX
Application Name: iexplore.exe
Application Version: 7.0.6001.18000
Application Timestamp: 47918f11
Fault Module Name: ntdll.... | <p>BEX=Buffer overflow exception. See <a href="http://technet.microsoft.com/en-us/library/cc738483.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/library/cc738483.aspx</a> for details. However, c000000d is STATUS_INVALID_PARAMETER; the technet article talks primarily about status c0000005 or c000040... | <p>Most likely there is an addon that is messing with IE.</p>
<p>You can try this.
1. Open IE
2. Switch to the Advanced tab.
3. Click the Reset Internet Explorer Settings button.
4. Click Reset to confirm the operation.
5. Click Close when the resetting process finished.
6. Uncheck Enable... | 7,491 |
<p>I'm trying to display a loading icon while my iPhone app downloads a network resource, but I can't figure out how to make it show up correctly.</p>
<p>I searched around and found some details on the <code>UIActivityView</code> class, but the available example source code didn't work, and the documentation is kind o... | <p>Assuming you've got a view controller set up, and would like to add a <code>UIActivityIndicator</code> to it, here's how you could do it:</p>
<p>(assume you've got a member variable called <code>indicator</code>, which you can use later to clean up)</p>
<p><strong>For your interface (.h file):</strong></p>
<pre><... | <p>Ben answer looks pretty similar to what I'm doing - your guess about the thread is probably accurate. Are you using <code>NSURLConnection</code> to handle your downloading? If so, are you using the synchronous or asynchronous version? If it's the synchronous version and you're simply starting and stopping the animat... | 26,080 |
<p>I want to set some attributes just before the object is serialized, but as it can be serialized from several locations, is there a way to do this using the OnSerializing method (or similar) for Xml serialization - my class is largely like this - but the On... methods are not being called...:</p>
<pre><code>[Seriali... | <p>No, <code>XmlSerializer</code> does not support this. If you're using .NET 3.0 or later, take a look at the <code>DataContractSerializer</code>.</p>
| <p>I have tried to break some ice. Please have a look.
Create a class with the name <code>MyXMLSerializer</code> like this:</p>
<pre><code>public class MyXMLSerializer
{
delegate void del_xmlSerializing();
del_xmlSerializing ds;
delegate void del_xmlSerialized(System.IO.Stream stream, object o);
... | 24,442 |
<p>What's the simplest way to connect and query a database for a set of records in C#?</p>
| <p>@Goyuix -- that's excellent for something written from memory.
tested it here -- found the connection wasn't opened. Otherwise very nice.</p>
<pre><code>using System.Data.OleDb;
...
using (OleDbConnection conn = new OleDbConnection())
{
conn.ConnectionString = "Provider=sqloledb;Data Source=yourServername\\you... | <p>Charge the libraries</p>
<pre><code>using MySql.Data.MySqlClient;
</code></pre>
<p>This is the connection:</p>
<pre class="lang-cs prettyprint-override"><code>public static MySqlConnection obtenerconexion()
{
string server = "Server";
string database = "Name_Database";
string Uid = "User";
string ... | 2,335 |
<p>I was trying to understand something with pointers, so I wrote this code:</p>
<pre><code>#include <stdio.h>
int main(void)
{
char s[] = "asd";
char **p = &s;
printf("The value of s is: %p\n", s);
printf("The direction of s is: %p\n", &s);
printf("The value of p is: %p\n", p);
... | <p>"s" is not a "char*", it's a "char[4]". And so, "&s" is not a "char**", but actually "a pointer to an array of 4 characater". Your compiler may treat "&s" as if you had written "&s[0]", which is roughly the same thing, but is a "char*".</p>
<p>When you write "char** p = &s;" you are trying to say "I w... | <p>You have used:</p>
<pre><code>char s[] = "asd";
</code></pre>
<p>Here s actually points to the bytes "asd". The address of s, would also point to this location.</p>
<p>If you used:</p>
<pre><code>char *s = "asd";
</code></pre>
<p>the value of s and &s would be different, as s would actually be a pointer to... | 24,066 |
<p>I have an Anet A8 with the Anet 1.7 board, Skynet3d v2.3.2, and the stock sensor. I originally had this configuration with the stock extruder, but recently purchased an E3D v6 clone with a Bowden extruder. After installing a new bracket I had printed (<a href="https://www.thingiverse.com/thing:2099577" rel="nofollow... | <p>If you have done major revisions to the printhead by changing to another carriage, it could be that the nozzle in the carriage is not at the exact position as in the previous carriage.</p>
<p>So, have you made sure that the new carriage has the appropriate values so that the nozzle is at (0, 0) when commanded to th... | <p>Do you have eeprom enabled? Because if you do, you can change configuration.h all you want but it's always gonna use the values from eeprom. I advise you to install repetier and change the eeprom values with that. Or maybe you can use the display if you have one.</p>
| 1,517 |
<p>It is common knowledge that built-in enums in C++ are not typesafe.
I was wondering which classes implementing typesafe enums are used out there...
I myself use the following "bicycle", but it is somewhat verbose and limited:</p>
<p>typesafeenum.h:</p>
<pre><code>struct TypesafeEnum
{
// Construction:
public:
... | <p>I'm currently playing around with the Boost.Enum proposal from the <a href="https://github.com/boost-vault/Miscellaneous" rel="noreferrer">Boost Vault</a> (filename <code>enum_rev4.6.zip</code>). Although it was never officially submitted for inclusion into Boost, it's useable as-is. (Documentation is lacking but ... | <p>Not sure if this post is too late, but there's an article on GameDev.net which satisfies all but the 5th point (ability to iterate over enumerators):
<a href="http://www.gamedev.net/reference/snippets/features/cppstringizing/" rel="nofollow noreferrer">http://www.gamedev.net/reference/snippets/features/cppstringizin... | 26,735 |
<p>I am running a script on a solaris Box. specifically SunOS 5.7. I am not root. I am trying to execute a script similar to the following:</p>
<blockquote>
<blockquote>
<p>newgrp thegroup <<
FOO<br>
source .login_stuff<br>
echo "hello world"<br>
FOO</p>
</blockquote>
</blockquote>
<p>Th... | <p>The <code>newgrp</code> command can only meaningfully be used from an interactive shell, AFAICT. In fact, I gave up on it about ... well, let's say long enough ago that the replacement I wrote is now eligible to vote in both the UK and the USA.</p>
<p>Note that <code>newgrp</code> is a special command 'built into'... | <p>Maybe </p>
<pre><code>exec $SHELL
</code></pre>
<p>would do the trick?</p>
| 38,412 |
<p>I'm using KML and the GGeoXml object to overlay some shapes on an embedded Google map. The placemarks in the KML file have some custom descriptive information that shows up in the balloons.</p>
<pre><code><Placemark>
<name />
<description>
<![CDATA[
<div class=&quo... | <p>As suggested I've gone in with Firebug to see what's going on. It looks like Google is doing two obnoxious things:</p>
<ol>
<li>It's stripping out all class attributes from my HTML.</li>
<li>It's throwing all kinds of hard-coded styles around. </li>
</ol>
<p>Here's my HTML along with the first couple of wrappers i... | <p>My first guess is that you're running into an issue with CSS specificity. There is a good article on it at <a href="http://www.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/" rel="nofollow noreferrer">http://www.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/</a>, so ... | 24,898 |
<p>Imagine the following type:</p>
<pre><code>public struct Account
{
public int Id;
public double Amount;
}
</code></pre>
<p>What is the best algorithm to synchronize two <code>IList<Account></code> in C# 2.0 ? (No linq) ?</p>
<p>The first list (L1) is the reference list, the second (L2) is the one to... | <p>For a start I'd get rid of the mutable struct. Mutable value types are a fundamentally bad thing. (As are public fields, IMO.)</p>
<p>It's probably worth building a Dictionary so you can easily compare the contents of the two lists. Once you've got that easy way of checking for presence/absence, the rest should be ... | <p>In addition to Jon Skeet's comment make your Account struct a class and override the Equals() and GetHashCode() method to get nice equality checking.</p>
| 19,511 |
<p>I've seen a few attempted SQL injection attacks on one of my web sites. It comes in the form of a query string that includes the "cast" keyword and a bunch of hex characters which when "decoded" are an injection of banner adverts into the DB.</p>
<p>My solution is to scan the full URL (and params) and search for th... | <p>I don't.</p>
<p>Instead, I use parametrized SQL Queries and rely on the database to clean my input.</p>
<p>I know, this is a novel concept to PHP developers and MySQL users, but people using real databases have been doing it this way for years.</p>
<p>For Example (Using C#)</p>
<pre><code>// Bad!
SqlCommand foo ... | <p>Thanks for the answers and links. Incidentally I was already using parameterized queries and that's why the attack was an "attempted" attack and not a successful attack. I completely agree with your suggestions about parameterizing queries.</p>
<p>The MSDN posted link mentions "constraining the input" as part of th... | 6,380 |
<p>Is there a free DayView Calendar for WPF like this one?</p>
<p><a href="http://www.codeproject.com/KB/selection/Calendardayview.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/selection/Calendardayview.aspx</a></p>
<p>Thanks in advance! Cheers from Argentina!</p>
| <p>Have a look at these articles on Code Project</p>
<ul>
<li><a href="http://www.codeproject.com/Articles/30329/Creating-an-Outlook-Calendar-using-WPF-Part-1" rel="nofollow noreferrer">Creating an Outlook Calendar Using WPF (Part 1)</a></li>
<li><a href="http://www.codeproject.com/Articles/30881/Creating-an-Outlook-C... | <p>Datepickers are a sore point among WPF users still. There's no official standard date picker in the framework yet, and definitely not something like you're looking for.</p>
<p>That said, it's certainly possible to implement using ListView or a DataGrid with some heavy template customization. If you're interested in... | 25,926 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.