instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Is it possible to impersonate a user without supplying user name/password? Basically, I'd like to get the <code>CSIDL_LOCAL_APPDATA</code> for a user (not the current one) using the <code>ShGetFolderPath()</code> function. All I currently have is a SID for that user.</p>
| <p>No, you have to call Win32 API <strong>LogonUser</strong> function to get windows account token back so you can then impersonate.</p>
| <p>You can impersonate a user without supplying password by calling ZwCreateToken.
See the CreatePureUserToken function in this article:
<a href="http://www.codeproject.com/KB/system/RunUser.aspx" rel="noreferrer" title="GUI-Based RunAsEx">GUI-Based RunAsEx</a>
You must be running as an admin (or LocalSystem) for this ... | 16,601 |
<p>I have an ASP.NET 2.0 application. The login page redirects twice when the login is successful. This works OK on all test environment and production servers except one. We can see with Fiddler that the login redirects to the second page and it redirects to the third. When getting to the third page the authentication... | <p>This is a longshot, but does the servername have an underscore in it? A while back, there was an IE bug where it couldn't save cookies from a servername/URL that had an underscore in it, so if I accessed the server by <a href="http://server_name" rel="nofollow noreferrer">http://server_name</a>, I couldn't save a co... | <p>This sounds like an IIS config problem. Have you tried to recreate the website on that server with defaults?</p>
| 41,271 |
<p>What interop signature would you use for the following COM method? I am interested particularly in the final two parameters, and whether to try to use <code>MarshalAs</code> with a <code>SizeParamIndex</code> or not.</p>
<pre><code>HRESULT GetOutputSetting(
DWORD dwOutputNum,
LPCWSTR pszName,
WMT_ATTR_DAT... | <p>You could try the <a href="http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120" rel="nofollow noreferrer" title="PInvoke Signature Toolkit">PInvoke Signature Toolkit</a>. It's rather useful for getting marshaling right when performing platform interops. It quite possibly won't cover your ... | <p>I would use the SizeParamIndex, because your scenario is exactly the one this feature is for: To specify the length of a variable sized array.</p>
<p>So the last to parameters would be in C# signature:</p>
<pre><code>byte[] pValue,
ref ushort pcbLength
</code></pre>
<p>The byte-Array is passed without <em>ref</em... | 27,403 |
<p>I am trying to learn how to use MSBuild so we can use it to build our project. There's what seems to be a very big hole in the documentation, and I find the hole everywhere I look, the hole being how do you name or otherwise designate the MSBuild project file? </p>
<p>For example, the tutorial on MSBuild that can... | <p>You can name the file as you see fit. From the help for MSBuild</p>
<pre><code>msbuild.exe /?
Microsoft (R) Build Engine Version 2.0.50727.3053
[Microsoft .NET Framework, Version 2.0.50727.3053]
Copyright (C) Microsoft Corporation 2005. All rights reserved.
Syntax: MSBuild.exe [options] [project fil... | <p>Or for the truly lazy, like me.</p>
<pre><code>msbuild.exe project-file-name.vcproj /t:Rebuild /p:Configuration=Release
</code></pre>
| 14,373 |
<p>I am using NUnit to test my C# code and have so far been keeping unit tests (fast running ones) and integration tests (longer running) separate, and in separate project files. I use NUnit for doing both the unit tests and the integration tests. I just noticed the <a href="http://www.nunit.org/index.php?p=category&am... | <p>if it is not too difficult to separate them, do so now</p>
<p>unit tests should be run early and often (e.g. every time you change something, before check-in, after check-in), and should complete in a short time-span.</p>
<p>integration tests should be run periodically (daily, for example) but may take significant... | <p>I would keep with whatever method you're currently using. It's more of an opinion thing, and you wouldn't want to have to re-tool your whole testing method.</p>
| 48,589 |
<p>I've worked on a variety of systems as a programmer, some with Oracle, some with MySQL. I keep hearing people say that Oracle is more stable, more robust, and more secure. Is this the case?</p>
<p>If so in what ways and why?</p>
<p>For the purposes of this question, consider a small-medium sized production DB, per... | <p>Yes. Oracle is enterprise grade software.</p>
<p>I'm not sure if its really any more stable that mysql, I haven't used mysql that much, but I dont ever remember having mysql crash on me. I've had oracle crash, but when it does, it gives me more information about why it crashed than I could possibly want, and Oracle... | <p>I'm using Oracle/SQL Server/MySql for different applications and site</p>
<p>No Database beat can Oracle in many different area, but it's the most database that require deep knowledge for the administration.</p>
<p>and if you found a problem with oracle, may spend few times to solve it even with good DBAs guys.</p... | 12,734 |
<p>I have a WinForms app with an input textbox, button, and a multiline output textbox.
A root path is entered in the textbox. Button click calls a function to recursively check all subdirectories for some proper directory naming validation check.
The results are output into the multiline textbox.</p>
<p>If the recu... | <p>You don't need to pass the TextBox ByRef. It's already a reference object. Passing it ByRef would only have an effect if you planned to assign a different or new TextBox to the reference.</p>
<p>If you're going to do the work in a separate class, it seems as simple as passing in the contents of the TextBox as a s... | <p>[not sure if this is the place for a follow up to the original question]</p>
<p>so, is it safe to say that a recursive business layer function will not be able to update a presentation level control at each recursive iteration?</p>
| 28,956 |
<p>What is the prefered method for creating a byte array from an input stream? </p>
<p>Here is my current solution with .NET 3.5. </p>
<pre><code>Stream s;
byte[] b;
using (BinaryReader br = new BinaryReader(s))
{
b = br.ReadBytes((int)s.Length);
}
</code></pre>
<p>Is it still a better idea to read and write ch... | <p>It really depends on whether or not you can trust <code>s.Length</code>. For many streams, you just don't know how much data there will be. In such cases - and before .NET 4 - I'd use code like this:</p>
<pre><code>public static byte[] ReadFully(Stream input)
{
byte[] buffer = new byte[16*1024];
using (Memo... | <p>i was able to make it work on a single line:</p>
<pre><code>byte [] byteArr= ((MemoryStream)localStream).ToArray();
</code></pre>
<p>as clarified by <a href="https://stackoverflow.com/users/2840103/johnnyrose">johnnyRose</a>, Above code will only work for MemoryStream</p>
| 27,364 |
<p>I'm working on a legacy application that has a C++ extended stored procedure. This xsproc uses ODBC to connect to the database, which means it requires a DSN to be configured.</p>
<p>I'm updating the installer (created using Visual Studio 2008 setup project), and want to have a custom action that can create the O... | <p>I actually solved this myself in the end by manipulating the registry. I've created a class to contain the functionality, the contents of which I've included here:</p>
<pre><code>///<summary>
/// Class to assist with creation and removal of ODBC DSN entries
///</summary>
public static class ODBCManager... | <p>Thanks for providing this code, I have used it myself. I had to change two things tough:</p>
<p>To get the <code>driverName</code> I had to use <code>OpenSubKey</code> instead of <code>CreateSubKey</code> to get the values:</p>
<pre><code>// Lookup driver path from driver name
var driverKey = Microsoft.Win32.Regis... | 43,440 |
<p>Looking for code samples to access a memory map file in C#</p>
| <p>Looks like C# 4.0 will have MemoryMappedFile support in the library</p>
| <p><a href="http://1code.codeplex.com/wikipage?title=IRPC" rel="nofollow">http://1code.codeplex.com/wikipage?title=IRPC</a></p>
<p>Search with </p>
<pre><code>CSFileMappingClient
CSFileMappingServer
</code></pre>
| 26,564 |
<p>I'm reading <em>The C++ Programming Language.</em> In it Stroustrup states that <code>sizeof(char) == 1</code> and <code>1 <= sizeof(bool)</code>. The specifics depend on the implementation. Why would such a simple value as a boolean take the same space as a char?</p>
| <p>In modern computer architectures, a byte is the smallest addressable unit of memory. To pack multiple bits into a byte requires applying extra bit-shift operations. At the compiler level, it's a trade off of memory vs. speed requirements (and in high-performance software, those extra bit-shift operations can add up ... | <p>Actually, in most implementation that I know of sizeof(bool) == sizeof(int). "int" is intended to be the data size that is most efficient for the CPU to work with. Hence things which do not have a specific size (like "char") are the same size as an int. If you had a large number of them per object, you may want to ... | 33,460 |
<p>I'm stuck with .Net 1.1 application (i.e. I can not use the generics goodies from 2.0 for now), and I was trying to optimize some parts of the code. As it deals a lot with runtime callable wrappers, which need to be released, I ended up to create a utility method which loops until all references are released. The si... | <p>Why is it better to call a method than to just set the variable to null? They're both single line calls, and the latter is a lot simpler.</p>
<p>It does sound very odd that you need to set them to null in the first place though. Are these static variables, or instance variables whose values need to be released earl... | <p>You should be calling <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.releasecomobject.aspx" rel="nofollow noreferrer"><code>Marshal.ReleaseComObject</code></a>, which AFAIK was available in 1.1.</p>
<p>You probably mean "ref":</p>
<pre><code>static void ReleaseObject(ref ob... | 30,364 |
<p>After cleaning a folder full of HTML files with TIDY, how can the tables content be extracted for further processing?</p>
| <p>I've used BeautifulSoup for such things in the past with great success.</p>
| <p>In .NET you could use <a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow noreferrer">HTMLAgilityPack</a>.</p>
<p>See this <a href="https://stackoverflow.com/questions/2861/options-for-html-scraping">previous question</a> on StackOverflow for more information.</p>
| 9,426 |
<p>I was chatting to someone the other day who suggested that Rails and PHP are the most suitable platforms for web applications, and to avoid Java. My background is mainly Java, and I know that it is considered by some to be too verbose and "heavyweight", but is used occasionally (e.g. by LinkedIn).</p>
<p>So I'm won... | <p>I would argue that there is no specific technology for Web 2.0. The main concept behind a Web 2.0 application is that much of the content is provided by it's users and not one specific person. If you can achieve this with Java, then that is fine. Many people are creating startup companies with technology that is fre... | <p>I build Web apps at work in Java and then I use PHP for my personal projects. While Java is certainly capable of all that you might require it to do, I've found it a little cumbersome at times and have wished I was using PHP (or another language, for that matter). It does depend on what type and size of application ... | 43,722 |
<p>I am exploring ASP.NET MVC and I wanted to add jQuery to make the site interactive. I used StringTemplate, ported to .Net, as my template engine to generate html and to send JSON. However, when I view the page, I could not see it. After debugging, I've realized that the $ is used by the StringTemplate to access prop... | <p>You can of course move your js logic into a .js file. But if you want it inline with your StringTemplate views, you can escape it using the \$ construct.</p>
<p>In addition, you can simply use the jQuery("selector"), instead of $("selector") construct if you want to avoid the escaping syntax.</p>
<p>Here's a good ... | <p>You could try <a href="http://jsrepeater.devprog.com/introduction.html" rel="nofollow noreferrer">jsRepeater</a>.</p>
| 20,864 |
<p>I think you can do GDI+ drawing in just about any window in a .net windows forms project, but what do you recommend as the best built-in control for containing custom drawing? I'm going to be drawing my own x-y plots, text and images. I could use a Panel, UserControl, etc. </p>
| <p>If you're just drawing the control and not hosting children, then derive from Control - VS will make you a suitable class (it calls this a 'Custom Control') with the OnDraw handler already stubbed in.</p>
<p>If you're hosting other controls within your control, then derive from UserControl, (VS calls this a 'User C... | <p>Do your GDI+ drawing in an offscreen bitmap surface, and then blit it to whatever control you need.</p>
<p>Your controls Paint method only needs to copy the surface to itself.</p>
| 31,808 |
<p>I want to detect users' screen size and pass this into a charting application (Chart Director by <a href="http://www.advsofteng.com" rel="nofollow noreferrer">http://www.advsofteng.com</a>) to control how big an image to display.</p>
<p>I have to use ASP, but I can only think to use JavaScript to detect screen-size... | <p>No, the server knows nothing about the client other than basic info like IP and browser version.
Screen resolution can easily be determined via javascript and passed to the server though, using ajax, or via form submission.</p>
| <p>No, this is not possible for desktop browsers. I suggest embedding an image that's appropriate for typical screen resolutions, then detecting the canvas size, and rewriting the image's <code>src</code> attribute to reflect that.</p>
<p>In any case, you <em>don't</em> want to look at the screen resolution, you want... | 14,830 |
<p>Inspired by another question and due to the fact that some of my filament will face the same problem when I will use them again, I wanted to know if there are proven recipies to get rid of water that has ben incorporated to PLA filament from humidity? One knows the filament had too much exposure to humidity when hea... | <p><strong>The easiest way to freshen up filament is hot air, although there are other options.</strong></p>
<p>There is an optimal melt processing <em>moisture level</em> for every plastic, typically in the range of 0.1-0.2% water content by weight. But the equilibrium moisture content of most plastics in humid air c... | <p>Keep in mind gas ovens produce water when the gas is burned, so it isn't as effective as an electric oven for drying.</p>
<p>Silica desiccant is excellent for drying filament, but you will want at least some of the desiccant beads to be "indicating" type. That is they show a color change when saturated with moistu... | 327 |
<p>Are there any IQueriable implementaions for linq-to-objects that perform better than the default O(n) linear search performance that you get when calling myEnumerable.AsQueriable()?</p>
<p>I've had a look at <a href="http://www.codeplex.com/i4o/" rel="nofollow noreferrer">http://www.codeplex.com/i4o/</a> which has ... | <p>you might want to have a look at plinq <a href="http://msdn.microsoft.com/en-us/magazine/cc163329.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc163329.aspx</a></p>
| <p>Another answer might be to back it by an in memory object database like: <a href="http://www.db4o.com/s/linqdb.aspx" rel="nofollow noreferrer">db4o</a></p>
| 11,799 |
<p>I never use Access 2007 - until today.</p>
<p>I want to connect to an existing SQL Server 2008 database. I have tried using:</p>
<ul>
<li>External Data ODBC option - but get DSN errror</li>
<li>Upsizing wizard with ODBC - get an error</li>
<li>Upsizing wizard with SNAC - get ODBC error. So that one seems a none st... | <p>The upsizing wizard in Access 2007 is not aware of SQL Server 2008 and therefore won't connect. You should use the <a href="http://www.microsoft.com/sqlserver/en/us/product-info/migration-tool.aspx#Access" rel="nofollow noreferrer">SQL Server migration assistant for Access</a> tool that is provided with SQL Server 2... | <p>What error do you get when trying to link to the ODBC connection?
Just to confirm, you are selecting ODBC Database from the Import part of the 'External Data' ribbon?
If you test your ODBC conneciton does it pass?</p>
| 34,220 |
<p>OpenID is a great idea in principle, but the UI and the explanation as to why it is good are currently not tailored for general use -- what do you think it would take to make OpenID work for the general public? Can this be solved with technology, or is the problem so intrinsically hard that we are stuck with diffic... | <p>It needs to be much simpler: involve less knowledge of the concepts, and require fewer steps - preferably zero. When the technology works with little or no assistance, it'll take off.</p>
<p>The mechanics of OpenID credentials, providers and suppliers shouldn't need to be exposed to the user. People talk about educ... | <p>Make it less open.</p>
<p>i do not want the same identity on multiple sites.
i do not want to have to create a flickr account before StackOverflow will let me post.
i do not have to have to create a new flickr account for each website that i want to register with.</p>
| 7,354 |
<p>It is really annoying.</p>
<pre><code>Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new mainForm()); <-- pausing visual studio breaks here.
</code></pre>
<p>Thanks guys.</p>
| <p>@sramey are you sure pausing always breaks on the said line? If I may hazard a guess here I think when you press the pause button you application is idle and the program is spending most of its time in the Win32 message loop abstracted by Application.Run(). Hence there is a high probability that VS breaks the execut... | <p>Taking into account the previous comments, you might want to set a Breakpoint where you want your application to stop.</p>
<p>I usually do this by going to where I want the debugger to stop, then pressing <code>F9</code>. You can also click in the left-hand margin. There are other ways.</p>
<p>You can also configu... | 39,814 |
<p>This is a new gmail labs feature that lets you specify an RSS feed to grab random quotes from to append to your email signature. I'd like to use that to generate signatures programmatically based on parameters I pass in, the current time, etc. (For example, I have a script in pine that appends the current probabil... | <p>The stream has a reference graph, so an object which is sent twice will not give two objects on the other end, you will only get one. And sending the same object twice separately will give you the same instance twice (each with the same data - which is what you're seeing).</p>
<p>See the reset() method if you want ... | <p>Max is correct, but you can also use:</p>
<pre><code>public void writeUnshared(Object obj);
</code></pre>
<p>See comment below for caveat</p>
| 17,202 |
<p>I have an executable module created by third party. I would like to "inject" my code (kind of watchdog running in separate thread) into this process. </p>
<p>So far there are two possible ways - one is to run my code as executable and dynamically load a proess on top of it (seems to be very hard and tricky) or to m... | <p>Sounds like you're looking for <a href="http://www.securiteam.com/tools/5EP0P157PG.html" rel="nofollow noreferrer">InjectSo</a>. There's a <a href="http://www.blackhat.com/presentations/bh-europe-01/shaun-clowes/bh-europe-01-clowes.ppt" rel="nofollow noreferrer">Powerpoint presentation</a> that explains how it works... | <p>Rob Kennedy told you about InjectSo - that's probably what you need.</p>
<p>Beware that the introduction of a thread into a non-threaded process would be fraught with synchronization issues. The problems are less serious if the application is already threaded, but even so, the application may object to a thread th... | 49,530 |
<p>I've personally always used some type of external application for my SCM work; these days, that means <a href="http://tortoisesvn.tigris.org" rel="nofollow noreferrer">tortoiseSVN</a> on windows and <a href="http://versionsapp.com" rel="nofollow noreferrer">versions.app</a> on the mac. However, I keep running up ag... | <p>I definitely prefer outside. That being said, my primary IDE is Visual Studio, and I haven't used eclipse or intellij (although I have used cvs-mode in emacs...), so your mileage may vary...</p>
<ul>
<li><p>Making changes and committing changes are separate tasks - having them both be easily available in the IDE me... | <p>It very much depends on the IDE/SCM combination. I'm currently using IntelliJ with SVN, and find that IntelliJ's SVN plugin is generally much more pleasant to use than Tortoise. Not that I have any particular complaints about Tortoise -- IntelliJ is just better.</p>
| 29,015 |
<p>I have a very large C project with many separate C files and headers and many dozens of contributors. Many contributors do not have a strong knowledge of makefiles and dependencies, resulting in the not uncommon problem where you almost always have to "make clean" before you can trust "make" to have produced correc... | <p>It might be easiest to switch from Make to a tool which automatically detects dependencies. For example, <a href="http://www.scons.org/" rel="nofollow noreferrer">SCons</a> doesn't make you list dependencies but instead automatically parses the files being compiled and looks for includes. You simply specify which ... | <p>We have the same problem at my workplace. The Trunk was always broken after merges or check-ins. </p>
<p>We set up a <a href="http://en.wikipedia.org/wiki/Continuous_Integration" rel="nofollow noreferrer">continuous integation</a> build machine that does a make clean in about 45 minutes compared to about 2 hours on... | 29,715 |
<p>Code I have:</p>
<pre><code>cell_val = CStr(Nz(fld.value, ""))
Dim iter As Long
For iter = 0 To Len(cell_val) - 1 Step 1
If Asc(Mid(cell_val, iter, 1)) > 127 Then
addlog "Export contains ascii character > 127"
End If
Next iter
</code></pre>
<p>This code doesn't work. Anyone know how to do thi... | <p>I believe your problem is that in VBA string indexes start at 1 and not at 0. Try the following:</p>
<pre><code>For iter = 1 To Len(cell_val)
If Asc(Mid(cell_val, iter, 1)) > 127 Then
addlog "Export contains ascii character > 127"
End If
Next
</code></pre>
| <p>Did you debug it? ;) Are you sure the cell_val is not empty? Also you don't need the 'Step 1' in the For loop since it's default. Also what do you expect to acomplish with your code? It logs if any ascii values are above 127? But that's it - there is no branching depending on the result?</p>
| 10,590 |
<p>I need to sum points on each level earned by a tree of users. Level 1 is the sum of users' points of the users 1 level below the user. Level 2 is the Level 1 points of the users 2 levels below the user, etc...</p>
<p>The calculation happens once a month on a non production server, no worries about performance.</p>
... | <p>If you were using Oracle DBMS that would be pretty straightforward since Oracle supports tree queries with the <strong>CONNECT BY/STARTS WITH</strong> syntax. For SQL Server I think you might find <a href="http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci1277481,00.html" rel="nofollow noreferrer">Comm... | <p>You have a couple of options:</p>
<ol>
<li>Use a cursor and a recursive user-defined function call (it's quite slow)</li>
<li>Create a cache table, update it on INSERT using a trigger (it's the fastest solution but could be problematic if you have lots of updates to the main table)</li>
<li>Do a client-side recursi... | 11,678 |
<p>What's the best way to unify several overlapping id systems into a unified one while maintaining the old id system.</p>
<p>I have several different ids on my website... (E.g /publisher/1234 and /designer/1234) I would like to unify the ids into a new system, but want to preserve the functionality of the older syste... | <p>You can try using <a href="http://msdn.microsoft.com/en-us/library/aa387764.aspx" rel="noreferrer">Microsoft's Sign Tool</a></p>
<p>You download it as part of the Windows SDK for Windows Server 2008 and .NET 3.5. Once downloaded you can use it from the command line like so:</p>
<blockquote>
<p>signtool sign /a M... | <p>And yet another option, if you're developing on Windows 10 but don't have Microsoft's signtool.exe installed, you can use Bash on Ubuntu on Windows to sign your app. Here is a run down:</p>
<p><a href="https://blog.synapp.nz/2017/06/16/code-signing-a-windows-application-on-linux-on-windows/" rel="noreferrer">https:... | 31,425 |
<p>I'm looking for a small C library to handle utf8 strings.</p>
<p>Specifically, splitting based on unicode delimiters for use with stemming algorithms.</p>
<p>Related posts have suggested:</p>
<p>ICU <a href="http://www.icu-project.org/" rel="noreferrer">http://www.icu-project.org/</a> (I found it too bulky for my... | <p>A nice, light, library which I use successfully is <a href="https://github.com/JuliaLang/utf8proc" rel="noreferrer">utf8proc</a>.</p>
| <p>UTF-8 is specially designed so that many byte-oriented string functions continue to work or only need minor modifications.</p>
<p>C's <strong><code>strstr</code></strong> function, for instance, will work perfectly as long as both its inputs are valid, null-terminated UTF-8 strings. <strong><code>strcpy</code></str... | 40,426 |
<p>I have been trying to make a case for using Python at my work. We use C# and ASP.NET for basically all of our development. 80% or more of our projects are web applications. It seems natural that we would look at some of the nice dynamic web languages (Ruby, Python, etc), and with things like <a href="http://en.wikip... | <p>"Can you guys help me think of something to finally convince my boss to really learn Python and start using it on projects?"</p>
<p>Nope.</p>
<p>Nothing succeeds like success. Use Python. Be successful. Make people jealous.</p>
<p>When asked why you're successful, you can talk about Python. Not before.... | <p>I am pretty sure (100%) that you don't need to use Python for MS Windows at least.</p>
<p>In cases of other platforms you can use any language you like.</p>
| 30,958 |
<p>Been having a "heated debate" with a colleague about his practice of wrapping most of his functions in a try/catch but the catch has JUST a "throw" in it e.g.</p>
<pre><code>Private sub foo()
try
'Do something'
catch
throw 'And nothing else!'
End Try
End Sub
</code></pre>
<p>My thought ... | <p>The reason you have a lone throw inside a catch rather than throwing a new exception is because this causes the original stack trace/exception data to be preserved. And one reason you might do this is because you can now set a break-point there for debugging.</p>
| <p>Since there is zero error handling, this catch is useless. If there was logging or some cleanup done sure, but in this situation I'd get rid of the try/catch.</p>
| 26,921 |
<p>Taking over some code from my predecessor and I found a query that uses the Like operator:</p>
<pre><code>SELECT * FROM suppliers
WHERE supplier_name like '%'+name+%';
</code></pre>
<p>Trying to avoid SQL Injection problem and parameterize this but I am not quite sure how this would be accomplished. Any suggestions ... | <p>try this: </p>
<pre><code>var query = "select * from foo where name like @searchterm";
using (var command = new SqlCommand(query, connection))
{
command.Parameters.AddWithValue("@searchterm", String.Format("%{0}%", searchTerm));
var result = command.ExecuteReader();
}
</code></pre>
<p>the framework will automa... | <p>Short Anwser:</p>
<p>1) name.Replace("'", "''").... Replace any escape characters that your database may have (single quotes being the most common)</p>
<p>2) if you are using a language like .net use Parameterized Queries</p>
<pre><code>sql="Insert into Employees (Firstname, Lastname, City, State, Zip, Phone, Ema... | 28,271 |
<p>I have two arrays. One contains <code>id=>count</code> and the other contains <code>id=>name</code>. I'm trying to produce a single array that is <code>name=>count</code>. Any suggestions on a straightforward way to do this?</p>
<p>I have looked at the <a href="http://us2.php.net/manual/en/ref.array.php" r... | <p>Something like:</p>
<pre><code>foreach($countA as $id => $count)
{
$newArray[$nameA[$id]] = $count;
}
</code></pre>
<p>This does assume that the keys are in correspondence between the two arrays, since your requirements are ambiguous otherwise.</p>
| <p>Use <a href="http://ca.php.net/manual/en/function.array-combine.php" rel="nofollow noreferrer">array_combine</a>...</p>
<pre><code>$countArray = array(0 => 1, 1 => 5);
$namesArray = array(0 => "Bob", 1 => "Alice");
$assocArray = array_combine($namesArray, $countArray);
</code></pre>
<p><strong>Edit:</... | 22,711 |
<p>I'm running a Django site using the fastcgi interface to nginx. However, some pages are being served truncated (i.e. the page source just stops, sometimes in the middle of a tag). How do I fix this (let me know what extra information is needed, and I'll post it)</p>
<p>Details:</p>
<p>I'm using flup, and spawning ... | <p>Check your error logs for "Permission denied" errors writing to <code>.../nginx/tmp/...</code> files. Nginx will work fine unless it needs temporary space, and that typically happens at 32K boundaries. If you find these errors, make sure the tmp directory is writable by the user nginx runs as.</p>
| <p>I'm running very similar configurations to this both on my webhost (Webfaction) and on a local Ubuntu dev server and I don't see any problems. I'm guessing it's a time-out or full buffer that's causing this.</p>
<p>Can you post the output of the nginx error log? Also what version of nginx are you using?</p>
<p>As ... | 19,298 |
<p>When I try the following lookup in my code:</p>
<pre><code>Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
return (DataSource) envCtx.lookup("jdbc/mydb");
</code></pre>
<p>I get the following exception:</p>
<pre><code>java.sql.SQLException: QueryResults: Unable... | <p>Thanks for the response toolkit.... yes, I can access my datasource by going directly to java:jdbc/mydb, but I'm using an existing code base that connects via the ENC. Here's some interesting info that I've found out ....</p>
<ol>
<li><p>The above code works with <strong>JBoss 4.2.2.GA</strong> and here's the JNDI... | <p>java:comp/env is known as the Enterprise Naming Context (ENC) and is not globally visible. See <a href="http://www.informit.com/articles/article.aspx?p=384904" rel="nofollow noreferrer">here</a> for more information. You will need to locate the global JNDI name which your datasource is regsitered at.</p>
<p>The eas... | 14,925 |
<p>There was no endpoint listening at http;//localhost:8080/xdxservice/xdsrepository that could accept the message. This is often caused by an incorrect address or SOAP action. </p>
| <p>Probably a typo in the question, but your URL is invalid. </p>
<pre><code>http;//localhost:8080/xdxservice/xdsrepository
</code></pre>
<p>should have a colon rather than a semi-colon</p>
<pre><code>http://localhost:8080/xdxservice/xdsrepository
</code></pre>
<p>This may well not be your problem, but I thought i... | <p>the url should have a .svc extention, no? (answered in comments)</p>
<p>Are you running the WCF in ASP.NET or the VS webserver?</p>
| 30,606 |
<p>When a process in jBPM forks into concurrent paths, each of these paths gets their own copy of the process variables, so that they run isolated from each other.</p>
<p>But what happens when the paths join again ?
Obviously there could be conflicting updates.
Does the context revert back to the state before the fork... | <p>I think that you have to configure the Task Controllers of your tasks. In some cases it is enough to set the <code>access</code> attribute in a way that does not result in conflicts (e.g. <code>read</code> access to the first path and <code>read,write</code> access to the second path). If this is not the case then y... | <p>I tried a little experiment:</p>
<pre><code><fork name="fork1" >
<transition to="right" />
<transition to="left" />
</fork>
<node name="left">
<event type="node-enter">
<script>
<expression >
left="left";
... | 13,873 |
<p>This question is the other side of the question asking, "<a href="https://stackoverflow.com/questions/11/how-do-i-calculate-relative-time">How do I calculate relative time?</a>".</p>
<p>Given some human input for a relative time, how can you parse it? By default you would offset from <code>DateTime.Now()</code>, b... | <p>That's building a DSL (Domain specific language) for date handling. I don't know if somebody has done one for .NET but the construction of a DSL is fairly straightforward:</p>
<ol>
<li>Define the language precisely, which input forms you will accept and what will you do with ambiguities</li>
<li>Construct the gramm... | <p>This: <a href="http://www.codeproject.com/KB/edit/dateparser.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/edit/dateparser.aspx</a>
Is fairly close to what you are trying to accomplish. Not the most elegant solution, but certainly might save you some work.</p>
| 7,919 |
<p>Many websites, including this one, add what are apparently called <em>slugs</em> - descriptive but as far as I can tell useless bits of text - to the end of URLs.</p>
<p>For example, the URL the site gives for this question is:</p>
<p><a href="https://stackoverflow.com/questions/47427/why-do-some-websites-add-slug... | <p>The slugs make the URL more user-friendly and you know what to expect when you click a link. Search engines such as Google, rank the pages higher if the searchword is in the URL.</p>
| <p>Ideally, the "slug" should be the only identifier needed. In practice, on dynamic sites such as this, you either have to have a unique numerical identifier or start appending/incrementing numbers to the "slug" like Digg does.</p>
| 6,966 |
<p>I am considering writing two limited precision alternatives to BigDecimal, namely DecimalInt and DecimalLong. These would be capable of dealing with numbers within the real bounds of int and long with an arbitrary number of decimal places, creatable in both mutable and immutable form. My plan is to make DecimalInt... | <p>I strongly suspect the reason why this has not been done is that the overhead of BigDecimal and BigInteger is not as relevant as you think, and avoiding it not worth the effort and the risk of getting it wrong in some subtle way.</p>
<p>To use your example: for any financial application, saving a few dozen bytes is... | <p>If your focus is for portable devices look at <a href="http://real-java.sourceforge.net/Real.html" rel="nofollow noreferrer">Real</a>. Real allows for the <a href="http://real-java.sourceforge.net/javadoc/index.html" rel="nofollow noreferrer">precision</a> of the number to be set from 0 to 16. It is designed for MID... | 46,117 |
<p>Trying to get this example working from <a href="http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx" rel="nofollow noreferrer">http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx</a></p>
<p>However, I can't seem to get the namespace or syntax right for ... | <p>Looks like the person who wrote the blog forgot to define their custom delegate called Process (a bit of an odd name for it).</p>
<pre><code>private delegate void Process();
</code></pre>
<p>It should compile now with it defined. </p>
<p>But I like these kind of names instead. </p>
<pre><code>private delegate ... | <p>Looks like the person who wrote the blog forgot to define their custom delegate called Process (a bit of an odd name for it).</p>
<pre><code>private delegate void Process();
</code></pre>
<p>It should compile now with it defined. </p>
<p>But I like these kind of names instead. </p>
<pre><code>private delegate ... | 44,813 |
<p>An idiom commonly used in OO languages like Python and Ruby is instantiating an object and chaining methods that return a reference to the object itself, such as:</p>
<pre><code>s = User.new.login.get_db_data.get_session_data
</code></pre>
<p>In PHP, it is possible to replicate this behavior like so:</p>
<pre><co... | <p>All of these proposed solutions complicate your code in order to bend PHP to accomplish some syntactic nicety. Wanting PHP to be something it's not (like good) is the path to madness.</p>
<p>I would just use:</p>
<pre><code>$u = new User();
$s = $u->login()->get_db_data()->get_session_data();
</code></pre... | <pre><code><?php
//PHP 5.4+ class member access on instantiation support.
$s = (new User())->login()->get_db_data()->get_session_data();
</code></pre>
| 23,053 |
<p>I flashed the TH3D unified firmware (R2.7) yesterday and so far everything works. I printed the 20 mm cube using the same G-code file I used for my very first print ever. However, with TH3D firmware I noticed that the print head was ridiculously fast compared to the previous firmware. The new cube has layer shi... | <p>I agree with @silver, but also wanted to point out that maybe the acceleration values on the old firmware you had were different from the default in TH3D R2.7.</p>
<p>The current settings can be retrieved using the M503 command, which should return the values from the eeprom:</p>
<pre><code>Maximum Acceleration (u... | <p>Yes, the limits are often subject to some "interpretation" in the limiting algorithms, even if they are totally unchanged values. Eg, your speed may remain higher around corners if the momentum calculations were optimized to take into account print head weight and extrusion instead of only per axis speed curves.</p>... | 1,182 |
<p>I want to load the flex framework as an RSL (SWZ, using player caching) but I need to monkey patch a couple of bug fixes in the framework.</p>
<p>A number of forums suggest this is not possible. Has anyone gotten this to work?</p>
| <p>Same thing as other answer to use frame1, but James Ward has some code to see: <a href="http://www.jamesward.com/blog/2009/03/10/flex-monkey-patching-and-framework-rsls/" rel="nofollow noreferrer">http://www.jamesward.com/blog/2009/03/10/flex-monkey-patching-and-framework-rsls/</a></p>
| <p>One of the guys on my team tried this about a month ago and said he had no problems. If your monkey-patched classes are part of your application project then it should work, since they are compiled into the SWF and basically "override" what's in the framework. You are not changing the Flex framework RSL, so it sho... | 26,312 |
<p>In MonoRail you can just CancelLayout() to not render the layout. In ASP.NET MVC, the only way to affect the layout seems to be to pass the layout name into the View() method like View("myview", "mylayout"); only it seems that passing null or an empty string doesn't do what I'd want. </p>
<p>I ended up creating an ... | <p>In MVC 3, you can remove the master layout code with:</p>
<pre><code> @{
Layout = "";
}
</code></pre>
| <p>You can create a custom ActionResult that does pretty much anything. The ActionResult controls what is sent back to the client as the response. It would be trivial to create a class that extends ActionResult that does nothing. </p>
| 27,131 |
<p>I use Virtual PC to create fresh environments for testing my installer. But I must be doing something wrong because a VPC image with Vista or XP inside is taking around 15GB of disk space (that includes VS2005/S2008 installed in them). </p>
<p>To create a new copy for testing I copy and paste the folder that has th... | <p>Use <a href="http://www.petri.co.il/virtual_creating_differencing_disks_with.htm" rel="nofollow noreferrer">differencing/undo disks</a>. This means when you shut down your VPC you'll be asked if you want to save changes, simply answer no and you'll be back to where you started.</p>
| <p>Also, you mentioned cut & paste, this is not the best way to be copying large amounts of data within windows. At least use xcopy, robocopy is even faster.</p>
| 10,761 |
<p>Is there a better <strong>free</strong> TreeView control that exists for Visual Studio 2008 / .NET 3.5?</p>
<p>I believe I need something a little more powerful than the out-of-the box version. I'm not exactly sure for what yet but I thought I'd ask quickly before I get too far in to my project.</p>
| <p><a href="http://treeviewadv.sourceforge.net/" rel="noreferrer">TreeViewAdv</a> seems to be pretty nice. It is described with the following features on SourceForge.net:</p>
<ul>
<li>Extensible advanced TreeView.</li>
<li>100% management C# code.</li>
<li>Features: Model/View architecture.
<ul>
<li>Multicolumns.</li... | <p>I would be wary with what you are going to use for a tree view control, make sure to test the amount of memory they consume vs speed of drawing.</p>
<p>We are having problems at work with the treeview control (made by Crownwood Software, called DotNetMagic) as it is causing memory leaks a lot, although its speed of... | 36,799 |
<p>Recently I have been getting some layer shifting starting at layer one. I have had layer shifting at higher layers due to various reasons but mainly for the belts being too loose. But now I am reading that layer shifting can also be caused by belts being too tight.</p>
<p>The <a href="https://reprap.org/wiki/Shifte... | <p>I think the RepRap wiki is using the word "binding", which translates to <em>"stick together or cause to stick together in a single mass"</em> (from Google dictionary), to indicate that some sort of friction is experienced (as you experience when things are sticking together).</p>
<p>When there is too much tension ... | <p>It is the bearings that are binding (dragging), due to lateral forces caused by over-tight belts. It may be the bearings in the stepper motors that are binding, but it is more likely to be the bearings in the idler pulleys.</p>
| 1,423 |
<p><img src="https://i.stack.imgur.com/xE1dA.gif" alt="enter image description here"></p>
<p>This is what is happening to my motor. Any suggestions would help.
1. I have tried adjusting the trimpot.
2. Rewire the connector to match the one on the motherboard.
3. Anything else I found on the internet.</p>
| <p>If the one in your question is your <em>complete</em> code, a possibility is that your computer is just buffering the output for the serial port, withholding it in memory. Try to add</p>
<pre><code>ser.flush()
</code></pre>
<p>after your last line. This command will... well... <em>flush</em> anything into the bu... | <p>Sorry for the late answer, but with Repetrel v3 and later, we have the option for you to configure a secondary COM port, and relay G- or M-Code commands from your other source through the Repetrel software to the printer. Please contact us for assistance.</p>
<p>Note: I work for Hyrel 3D.</p>
| 802 |
<p>I have an application which is a relatively old. Through some minor changes, it builds nearly perfectly with Visual C++ 2008. One thing that I've noticed is that my "debug console" isn't quite working right. Basically in the past, I've use <code>AllocConsole()</code> to create a console for my debug output to go to.... | <h2>Updated Feb 2018:</h2>
<p>Here is the latest version of a function which fixes this problem:</p>
<pre><code>void BindCrtHandlesToStdHandles(bool bindStdIn, bool bindStdOut, bool bindStdErr)
{
// Re-initialize the C runtime "FILE" handles with clean handles bound to "nul". We do this because it has been
//... | <p>I am not sure I understand the problem completely but if you want to be able to simply spit out data to console for diagnostic purpose.. why dont you try out System::Diagnostics::Process::Execute() method or some method in that namespace?? </p>
<p>Apologies in advance if it was irrelevant</p>
| 40,201 |
<p>I just started thinking about creating/customizing a web crawler today, and know very little about web crawler/robot etiquette. A majority of the writings on etiquette I've found seem old and awkward, so I'd like to get some current (and practical) insights from the web developer community.</p>
<p>I want to use a ... | <p>Obey robots.txt (and not too aggressive like has been said already).</p>
<p>You might want to think about your user-agent string - they're a good place to be up-front about what you're doing and how you can be contacted.</p>
| <p>I'd say that it is very important to consider how much load you are causing. For instance, if your crawler requests every object of a single site, more or less at once, it might cause load problems for that particular site.</p>
<p>In other words, make sure your crawler is not too aggressive.</p>
| 5,228 |
<p>How can I rotate the Apache Access and Error logs on a Window 2000 box?</p>
<p>I include my batch file below as an answer.</p>
<p>Is there a way of doing this directly via the Apache config file? I'm currently using the following customlog command to generate daily logs.</p>
<p>CustomLog '|" "*Apache-Path/bin/ro... | <p>Here's the DOS batch file, modified as annotated.
I run it weekly and it keeps 8 weeks of zipped backups.
You'll need to install 7 zip.</p>
<p>I haven't parametrised the paths, feel free to.</p>
<hr>
<pre><code>@echo off
:: Name - svrlogmng.bat
:: Description - Server Log File Manager
::
:: History
:: Date ... | <p>As stated I don't think this is strictly a programming question, but AFAIK there is no built-in functionality in Apache to support log rotation. There's a standard utility on unix systems called <code>logrotate</code>, so that functionality would be redundant on those systems.</p>
<p>If you rephrase your question ... | 46,369 |
<p>I have an SSIS package, which depending on a boolean variable, should either go to a Script Task or an Email task.(Note: the paths are coming <em>from</em> a Script Task)</p>
<p>I recall in the old dts designer there was a way to do this via code. What is the proper way to accomplish this in SSIS?</p>
| <blockquote>
<p>Isn't a Conditional Split a data flow
task, which takes a row of data and
pushes it in one of two directions
according to some property of the
data???</p>
</blockquote>
<p>Oops, that is correct. I found <a href="http://dichotic.wordpress.com/2006/11/01/ssis-test-for-data-files-existence/" rel... | <p>A Conditional Split task does what you want. Add the Conditional Split task, add in an additional output (a default output is provided), and set up the Condition for that output. Then just tie the outputs (default and new) to the Script and Email tasks as appropriate.</p>
| 15,528 |
<p>I'm running into a problem when modifying a WCF service.</p>
<p>The original service method looks like this:</p>
<pre><code>[OperationContract(IsOneWay = true, IsInitiating = true, IsTerminating = false)]
void Login(string userName, string password);
</code></pre>
<p>This method works.</p>
<p>The problem is that... | <p>Select street_name from tablex
order by udf_getStreetNumber(street_name)</p>
<p>in your udf_getStreetNumber - write your business rule for stripping out the number</p>
<p>EDIT</p>
<p>I think you can use regex functionality in SQL Server now. I'd just strip out all non-number characters from the input.</p>
| <p>Yes it's possible! But definitely of no interest! If you find somebody here ready to spend a few hours writing down and testing the SP that will split your streetNames into a streetName + streetNumber combination, give me his name: I will submit him a few problems where I thought I had to pay to get the work done.</... | 45,983 |
<p>What is a good Hash function? I saw a lot of hash function and applications in my data structures courses in college, but I mostly got that it's pretty hard to make a good hash function. As a rule of thumb to avoid collisions my professor said that:</p>
<pre><code>function Hash(key)
return key mod PrimeNumber
end... | <p>There's no such thing as a “good hash function” for universal hashes (ed. yes, I know there's such a thing as “universal hashing” but that's not what I meant). Depending on the context different criteria determine the quality of a hash. Two people already mentioned SHA. This is a cryptographic hash and it isn't at a... | <p>I highly recommend the SMhasher GitHub project <a href="https://github.com/rurban/smhasher" rel="nofollow noreferrer">https://github.com/rurban/smhasher</a> which is a test suite for hash functions. The fastest state-of-the-art non-cryptographic hash functions without known quality problems are listed here: <a href=... | 5,491 |
<p>I'm looking to implement the Observer pattern in VB.NET or C# or some other first-class .NET language. I've heard that delegates can be used for this, but can't figure out why they would be preferred over plain old interfaces implemented on observers. So,</p>
<ul>
<li>Why should I use delegates instead of defining ... | <p>You're an O/S, and I'm an application. I want to tell you to call one of my methods when you detect something happening. To do that, I pass you a delegate to the method of mine which I want you to call. I don't call that method of mine myself, because I want you to call it when you detect the something. You don't ca... | <p>i think it is more related to <strong>syntatic sugar</strong> and a way to organize your code, a good use would be to handle several methods related to a common context which ones belong to a object or a static class.</p>
<p>it is not that you are forced to use them, you can programme sth with and without them, but... | 38,899 |
<p>I want to read an XML file into a <code>char *buffer</code> using C.</p>
<p>What is the best way to do this?</p>
<p>How should I get started?</p>
| <p>And if you want to <em>parse</em> XML, not just reading it into a buffer (something which would not be XML-specific, see Christoph's and Baget's answers), you can use for instance <a href="http://xmlsoft.org/" rel="noreferrer">libxml2</a>:</p>
<pre><code>#include <stdio.h>
#include <string.h>
#include &... | <p>I believe that question was about XML parsing and not about file reading, however OP should really clarify this.<br>
Any way you got plenty example how to read file.<br>
Another option to xml parsing in additional to <a href="https://stackoverflow.com/questions/381300/how-can-i-read-an-xml-file-into-a-buffer-in-c#38... | 49,981 |
<p>I'm trying to foresee how big my database will be. Let's say I have only one table: </p>
<p>CREATE TABLE user (<br>
<strong>id</strong> INT UNSIGNED NOT NULL AUTO_INCREMENT,<br>
<strong>email</strong> VARCHAR(50),<br>
<strong>pass</strong> CHAR(40),<br>
<strong>url</strong> VARCHAR(1000),<br>
PRIMARY KEY(id));</p... | <p>Apart from the varchar issue you also need to be aware that most databases store the records in allocated blocks of storage (sometimes termed extents - although the precise terminology depends on the rdbms) which contain a certain amount of free space. The intention of this is to allow updates whilst minimizing tab... | <p>Actually a varchar field represents more than one char field. This is also true of other datatypes as well.</p>
<p>An easy way would be to add 100 records with random test data then look at how big the database file is in your file system. Then add another hundred and see how much larger it grew. </p>
| 33,437 |
<p>3D Printers (those who print, not the machine, dummy)!</p>
<p>I haven't been printing in a while, so when I returned to my Monoprice Select Mini VII, of course it had been sprung out of whack. Some of my first prints would not even come out of the extruder until I realized I had some pretty bad (and worse, unnotice... | <p>for sure the answer could be dissertation or even a book because there is no simple way to address "all" issues - it's just to wide area</p>
<p>but as the simple troubleshooting i would list it this way</p>
<ol>
<li>is your printer alive so is it
<ul>
<li>working at all (check power, cables)</li>
<li>communicate ... | <h1>The obvious ones first</h1>
<p>This is, well, obvious. It is, what a visual and smell inspection shows. Stuff like missing or ruptured cables, bent rails, ripped or very loose belts, burnt smell or hung up software that is easy to see that it is going on needs to be addressed first.</p>
<h1>The not so obvious next<... | 1,315 |
<p>I have a bunch of regression test data. Each test is just a list of messages (associative arrays), mapping message field names to values. There's a lot of repetition within this data.</p>
<p>For example</p>
<pre><code> test1 = [
{ sender => 'client', msg => '123', arg => '900', foo => 'bar'... | <p>The following papers describe algortithms for discovering functional dependencies:</p>
<blockquote>
<p>Y. Huhtala, J. Kärkkäinen, P. Porkka,
and H. Toivonen. TANE: An efficient
algorithm for discovering functional
and approximate dependencies. <em>The
Computer Journal</em>, 42(2):100–111,
1999, <a hr... | <p>This looks very similar to <a href="http://en.wikipedia.org/wiki/Database_normalization" rel="nofollow noreferrer">Database Normalization</a>.</p>
<p>You have a relation (your test data set), and some known functional dependencies ({sender} => arg, {} => foo and possibly {msg} => sender. If the order of tests is i... | 20,325 |
<p>As I am coding my unit tests, I tend to find that I insert the following lines:</p>
<pre><code>Console.WriteLine("Starting InteropApplication, with runInBackground set to true...");
try
{
InteropApplication application = new InteropApplication(true);
application.Start();
Console.WriteLine("Application s... | <p>I personally would recommend that you output only errors and a summary of the number of tests run and how many passed. This is a completely subjective view though. Display what suits your needs.</p>
| <p>Well, you should only know when a test failed and why it failed. It's no use to know what's going on, unless, for example, you have a loop and you want to know exactly where in the loop the test died.</p>
| 21,140 |
<p>I suppose there could be historical reasons for this naming and that other languages have similar feature, but it also seems to me that parameters always had a name in C#. Arguments are the unnamed ones. Or is there a particular reason why this terminology was chosen?</p>
| <p>Yes, you're absolutely right (to my mind, anyway). Ironically, although I'm usually picky about these terms, I still use "parameter passing" when I should probably talk about "argument passing". I suppose one could argue that prior to C# 4.0, if you're calling a method you don't care about the parameter names, where... | <p>I dont know if its worth adding it now, but MS calls it <em>named arguments</em> anyway. See <a href="http://msdn.microsoft.com/en-us/library/dd264739%28v=vs.100%29.aspx" rel="nofollow">named and optional arguments</a></p>
| 39,375 |
<p>What's the better way to insert cell comments in excel 2007 files programmatically using c# and .net 3.5?</p>
| <p>I just did exactly that but with MS Word (using Microsoft.Office.Interop.Word</p>
<p>range.Comments.Add ( range, ref _categoryMessage );</p>
<p>So, I would suggest using Microsoft.Office.Interop.Excel and the similar method.
Consider this from MSDN:</p>
<p><a href="https://learn.microsoft.com/en-us/dotnet/api/micros... | <p>Have you tried using VSTO ? You can easily load an Excel document and manipulate it. To add a comment to a cell, load the file, activate the worksheet, then select the cell as a range and set the comment.</p>
| 27,488 |
<p>I have a table with a "Date" column, and I would like to do a query that does the following:</p>
<p>If the date is a <strong>Monday</strong>, <strong>Tuesday</strong>, <strong>Wednesday</strong>, or <strong>Thursday</strong>, the displayed date should be shifted up by 1 day, as in <pre>DATEADD(day, 1, [Date])</pre>... | <p>Here is how I would do it. I do recommend a function like above if you will be using this in other places.</p>
<pre><code>CASE
WHEN
DATEPART(dw, [Date]) IN (2,3,4,5)
THEN
DATEADD(d, 1, [Date])
WHEN
DATEPART(dw, [Date]) = 6
THEN
DATEADD(d, 3, [Date])
ELSE
[Date]
END AS [ConvertedDate]
</code></pr... | <pre><code>create table #dates (dt datetime)
insert into #dates (dt) values ('1/1/2001')
insert into #dates (dt) values ('1/2/2001')
insert into #dates (dt) values ('1/3/2001')
insert into #dates (dt) values ('1/4/2001')
insert into #dates (dt) values ('1/5/2001')
select
dt, day(dt), dateadd(dd,1,dt)
f... | 12,992 |
<p>Looking at this LINQ demo:</p>
<p><a href="http://www.microsoft.com/emea/msdn/spotlight/sessionh.aspx?videoid=716" rel="nofollow noreferrer">LINQ Framework Overview</a></p>
<p>When going in debug mode, the output have colors in it. I'm using the same ObjectDumper class and I only have the black/white console windo... | <p>What about :</p>
<pre><code> Console.ForegroundColor = ConsoleColor.Yellow;
Console.BackgroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Test");
</code></pre>
| <p>You can set colors of the console text and/or background in the properties if that's what you're looking for...
Just right click the title bar, click Properties and choose desired colors.</p>
| 38,923 |
<p>I get the following error pretty regularly when compiling in Visual Studio and running my web application:</p>
<p>"Unable to start debugging on the web server. The web server did not respond in a timely manner. This may be because another debugger is already attached to the web server."</p>
<p>Normally this is af... | <p>I find that this happens if I'm debugging with Firefox as my browser. When I exit Firefox the VS2005/8 debug session doesn't terminate. I have not found a solution for this (yet).</p>
<p>If this is what's happening with you then a quicker solution than running iisreset is to hit Shift-F5 when in Visual Studio and t... | <p>I just solved this problem on my machine.
My problem is that I upgraded IE 9 To IE 10 and I got this error.
Solution : Remove IE 10 and downgrade to IE 9.
Go to "Programs and Features" --> "View recent updates" --> find IE 10---> Uninstall it-->reboot--->ie 9 is back--->debug--->works OK.</p>
| 2,463 |
<p>How do you redirect HTTPS to HTTP?. That is, the opposite of what (seemingly) everyone teaches.</p>
<p>I have a server on HTTPS for which I paid an SSL certification for and a mirror for which I haven't and keep around for just for emergencies so it doesn't merit getting a certification for.</p>
<p>On my client's ... | <p>This has not been tested but I think this should work using mod_rewrite</p>
<pre><code>RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
</code></pre>
| <p>As far as I'm aware of a simple meta refresh also works without causing errors:</p>
<pre><code><meta http-equiv="refresh" content="0;URL='http://www.yourdomain.com/path'">
</code></pre>
| 2,980 |
<p>Are all of these equal? Under what circumstances should I choose each over the others?</p>
<ul>
<li><p>var.ToString()</p></li>
<li><p>CStr(var)</p></li>
<li><p>CType(var, String)</p></li>
<li><p>DirectCast(var, String)</p></li>
</ul>
<hr>
<p><em>EDIT: Suggestion from <strong><a href="https://stackoverflow.com/us... | <p>Those are all slightly different, and generally have an acceptable usage.</p>
<ul>
<li><code>var.</code><a href="http://msdn.microsoft.com/en-us/library/system.object.tostring.aspx" rel="noreferrer"><code>ToString</code></a><code>()</code> is going to give you the string representation of an object, regardless of w... | <p>At one time, I remember seeing the MSDN library state to use CStr() because it was faster. I do not know if this is true though.</p>
| 6,203 |
<p>How do I handle the scenario where I making a synchronous request to the server using XMLHttpRequest and the server is not available?</p>
<pre><code>xmlhttp.open("POST","Page.aspx",false);
xmlhttp.send(null);
</code></pre>
<p>Right now this scenario results into a JavaScript error:
"The system cannot locate the re... | <p>Ok I resolved it by using try...catch around xmlhttprequest.send</p>
<p>:</p>
<pre><code>xmlhttp.open("POST","Page.aspx",false);
try
{
xmlhttp.send(null);
}
catch(e)
{
alert('there was a problem communicating with the server');
}
</c... | <p>You don't check for properly returned status. By the code you gave you are doing a GET request.
To properly check the status of your request, you must create an event handler for the onreadystatechange event and then inside it check if the readyState property is equal 4 and then inside the method if the status is 2... | 49,400 |
<p>How can I tell if an App is ASP.NET 2.0 or ASP.NET 1.1. This is in C#</p>
<p>I don't have the source code and I don't have access to IIS Manager. But I can ftp and check the ASPX files. Any Ideas?</p>
| <p>if you can get an error message to show it will tell you at the bottom of the page what version of the framework is in use.</p>
<p>or, if you could upload a file, you could upload an aspx page containing code to output the framework version:</p>
<pre><code><%@ Page Language="C#" EnableSessionState="False" Enabl... | <p>You can do this through your browser - just look in the response headers for "X-AspNet-Version" </p>
<p>In FireFox you can do this with the web developer toolbar... -> Information -> View Response Headers. </p>
<p>You can also check Response Headers with <a href="http://www.fiddlertool.com/fiddler/" rel="nofollo... | 25,554 |
<p>I am interested in doing development on Cura. Initially I want to start with the UI rather than the Engine. I have found the <a href="https://github.com/Ultimaker/Cura" rel="nofollow noreferrer">repository</a> and have cloned it to my PC. I have also looked over the <a href="https://github.com/Ultimaker/Cura/wiki... | <p>As you are an experienced developer, these links should help:</p>
<p>This is a related question, but for Ubuntu <a href="https://3dprinting.stackexchange.com/questions/1309/how-to-build-curaengine">How to build CuraEngine?</a></p>
<p>Wikipedia has an informative page on <a href="https://en.wikipedia.org/wiki/Cura_... | <p>As you are an experienced developer, these links should help:</p>
<p>This is a related question, but for Ubuntu <a href="https://3dprinting.stackexchange.com/questions/1309/how-to-build-curaengine">How to build CuraEngine?</a></p>
<p>Wikipedia has an informative page on <a href="https://en.wikipedia.org/wiki/Cura_... | 603 |
<p>I was asked a question in C last night and I did not know the answer since I have not used C much since college so I thought maybe I could find the answer here instead of just forgetting about it.</p>
<p>If a person has a define such as:</p>
<pre><code>#define count 1
</code></pre>
<p>Can that person find the var... | <p>The simple answer is no they can't. #Defines like that are dealt with by the preprocessor, and they only point in one direction. Of course the other problem is that even the compiler wouldn't know - as a "1" could point to anything - multiple variables can have the same value at the same time.</p>
| <p>What do you mean by "finding"?</p>
<p>The line </p>
<pre><code>#define count 1
</code></pre>
<p>defines a symbol "count" that has value 1.</p>
<p>The first step of the compilation process (called preprocessing) will replace every occurence of the symbol count with 1 so that if you have:</p>
<pre><code>if (x >... | 15,500 |
<p>I'm using C++ and accessing a UNC path across the network. This path is slightly greater than MAX_PATH. So I cannot obtain a file handle.</p>
<p>But if I run the program on the computer in question, the path is not greater than MAX_PATH. So I can get a file handle. If I rename the file to have less characters (m... | <p>I recall that there is some feature like using <code>\\?\</code> at the start of the path to get around the <code>MAX_PATH</code> limit. Here is a reference on MSDN:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa365247(VS.85)... | <p>You might be able to get a handle to the file if you try opening the file after converting the file name to a short (8.3) file name. Failing that can you map the dir the file is in as a drive and access the file that way?</p>
| 13,802 |
<p>I am currently having a hardtime understanding and implementing events in C# using delagates. I am used to the Java way of doing things:</p>
<ol>
<li>Define an interface for a listener type which would contain a number of method definitions</li>
<li>Define adapter class for that interface to make things easier if ... | <p>You'd create four events, and methods to raise them, along with a new EventArgs-based class to indicate the error:</p>
<pre><code>public class ExceptionEventArgs : EventArgs
{
private readonly Exception error;
public ExceptionEventArgs(Exception error)
{
this.error = error;
}
public E... | <p>The delegate declares a function signature, and when it's used as an event on a class it also acts as a collection of enlisted call targets. The += and -= syntax on an event is used to adding a target to the list.</p>
<p>Given the following delegates used as events:</p>
<pre><code>// arguments for events
public cl... | 21,899 |
<p>I need to get execution time in milliseconds.</p>
<blockquote>
<p>I originally asked this question back in 2008. The accepted answer then was to use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime" rel="noreferrer"><code>new Date().getTime()</code></a> However, ... | <h2>Using <a href="https://developer.mozilla.org/en-US/docs/Web/API/Performance.now" rel="noreferrer"><strong>performance.now()</strong></a>:</h2>
<pre class="lang-js prettyprint-override"><code>var startTime = performance.now()
doSomething() // <---- measured code goes between startTime and endTime
var end... | <p>As previously stated check for and use built in timer. But if you want or need to write your own here is my two cents:</p>
<pre><code>//=-=|Source|=-=//
/**
* JavaScript Timer Object
*
* var now=timer['elapsed']();
* timer['stop']();
* timer['start']();
* timer['reset']();
*
* @expose
... | 40,480 |
<p>How do you invoke a tkinter <code>event</code> from a separate object? </p>
<p>I'm looking for something like wxWidgets <code>wx.CallAfter</code>. For example, If I create an object, and pass to it my <code>Tk</code> root instance, and then try to call a method of that root window from my object, my app locks up.... | <p>To answer your specific question of "How do you invoke a TkInter event from a separate object", use the <code>event_generate</code> command. It allows you to inject events into the event queue of the root window. Combined with Tk's powerful virtual event mechanism it becomes a handy message passing mechanism. </p>
... | <p>Here below just some doc and link to better understand Bryan's answer above.</p>
<p>function description from <a href="https://web.archive.org/web/20190527174904/http://infohost.nmt.edu:80/tcc/help/pubs/tkinter/web/universal.html" rel="nofollow noreferrer">New Mexico Tech</a> :</p>
<p><code>w.event_generate(sequence... | 34,025 |
<p>i'm want to have a repeater generate a bunch of checkboxes, e.g.:</p>
<pre><code><tr><td><input type="checkbox" name="t" value="11cbf4deb87" /> <input type="checkbox" name="a" value="33cbf4deb87" />stackoverflow.com</td></tr>
<tr><td><input type="checkbox" name="t"... | <p>Use the server control instead of making an input control runat=server</p>
<pre><code> <asp:CheckBox id="whatever" runat="Server" />
</code></pre>
<p>When you set the value in your ItemDataBound, you use FindControl</p>
<pre><code>CheckBox checkBox = (CheckBox)e.Item.FindControl("whatever");
checkBox.Checke... | <p>I believe this KB gave me the best answer:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/1d04y8ss.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/1d04y8ss.aspx</a></p>
<p>to my own lack of luck, this seems to be available for the .net 4.0 version only (and I'm still stuck at 3.5 SP1... | 21,708 |
<p>I'm porting an application from Crystal Reports 8 to Crystal Reports XI in Delphi 5, using the RDC/ActiveX interface.</p>
<p>In Crystal Reports 8, I was able to bring up the crystal reports default report viewer window for a report like so:</p>
<pre><code>RptInvoicing.Destination := 0; // To: window
RptInvoicing.A... | <p>I recently had the same problem, and <a href="https://stackoverflow.com/questions/378089/how-can-i-display-crystal-xi-reports-inside-a-delphi-2007-application#378099">described the solution here</a>. I am using Delphi 2007, but since the code involves calls to an external ActiveX DLL, it should work for you too.</p... | <p>I can't say anything about Delphi, but in VB we are using CRViewer ActiveX Control. Using it is straightforward - you put viewer control on form and assign RDC object to it. This is covered in CR help somewhere. (I can't look at code ATM to provide working exmples.)</p>
| 25,969 |
<p>How does one choose the size of a buffer (bytes I read from or write to socket) for the maximum throughput when implementing a low-level HTTP and FTP transfer? My application should transfer data with HTTP or FTP on connections varying from 130 Kbps to 3 Mbps (I know the expected speed beforehand). Sometimes it's a ... | <p>Choose a buffer size over 8KB. 9000 is typically the largest MTU (maximum transmission unit) size used in even the fastest networks. </p>
<p>When you use a buffer larger than the MTU of the connection, the operating system will break it down in to MTU sized pieces as needed, and thus anything you use over the MTU... | <p>You can get buffer size: httpSocket.getReceiveBufferSize();
I highly recommend writing this buffer to RAM in the process of reading.
For example: ByteArrayOutputStream memoryFile.
and only after filling the buffer write it to disk.</p>
| 35,778 |
<p>I recently installed a SKR 1.3 Board with a 3DTouch-Probe on my Creality Ender 3 Pro.
The probe works, <code>G29</code> does its magic, but:</p>
<p>If i issue a plain <code>G28</code>, the hotend first homes X and Y like before the Z-probe.
The probe is now next to, not above, the bed.
As the next step, the print... | <p>You need to enable the constant <code>Z_SAFE_HOMING</code> (like: <code>#define Z_SAFE_HOMING</code>) in your <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configuration.h" rel="nofollow noreferrer">printer configuration file</a> (if you're using Marlin firmware that is). This will move the noz... | <p>Use <code>Z Safe Homing</code> to avoid homing with a Z probe outside the bed area</p>
<p>According to Marlin firmware with this feature enabled:</p>
<ul>
<li>Allow Z homing only after X and Y homing AND stepper drivers still
enabled.</li>
<li>If stepper drivers time out, it will need X and Y homing again before Z... | 1,479 |
<p>Take the following snippet:</p>
<pre><code>List<int> distances = new List<int>();
</code></pre>
<p>Was the redundancy intended by the language designers? If so, why?</p>
| <p>The reason the code appears to be redundant is because, to a novice programmer, it appears to be defining the same thing twice. But this is not what the code is doing. It is defining two separate things that just happen to be of the same type. It is defining the following:</p>
<ol>
<li>A variable named distances of... | <p>Because we're addicted to compilers and compiler errors.</p>
| 16,626 |
<p>I'm wanting to capture my search terms and pass them to a JavaScript variable, but I don't know how to handle quotes that might come through.</p>
<p>Here's what I have currently:</p>
<pre><code>var searchTerms = "<!--#echo var="terms"-->";
var pattern = / /g;
newSearchTerms = searchTerms.replace(/[^a-zA-Z 0-... | <p>If <code>terms</code> contains quotation marks, by the time you have done <code>var searchTerms = "<!--#echo var="terms"-->";</code> it is already too late to replace any quotation marks, your JavaScript will be invalid. For example, if <code>terms</code> contains <strong>These are the "terms"</strong> your Ja... | <p>i would add a javascript to the onchange event for the search textbox. capture the keystroke and ignore the quotes and any other special characters that might be entered. if the input is coming from the server side, then sanitize it before sending it to your script. </p>
| 49,627 |
<p>On Fedora Core 7, I'm writing some code that relies on <code>ARG_MAX</code>. However, even if I <code>#include <limits.h></code>, the constant is still not defined. My investigations show that it's present in <code><sys/linux/limits.h></code>, but this is supposed to be portable across Win32/Mac/Linux,... | <p>The reason it's not in limits.h is that it's not a quantity giving the limits of the value range of an integral type based on bit width on the current architecture. That's the role assigned to limits.h by the ISO standard.</p>
<p>The value in which you're interested is not hardware-bound in practice and can vary f... | <p>ARG_MAX is defined in /usr/include/linux/limits.h. My linux kernel version is 3.2.0-38.</p>
| 6,890 |
<p>On some websites or forums I usually go to, entries that I havn't read yet are marked as "new". I would like to implement this feature on a website I have developed (with news being posted from time to time) -- php/mySQL. How is this usually done ? Does it require using a cookie remembering the last visit date/time ... | <p>Cookies are just one possible way of identifying the user for the session, or between visits for those without authentication. Though a very common and useful way. (PHP can also use the sid or another parameter, though its not common anymore.)</p>
<p>You need to store either which threads/posts the user have read, ... | <p>Cookie is about the only reliable way to do this type of thing.</p>
<p>I'd use a cookie to store when a user last visited, but also have a reasonable default of say 1 week if the cookie doesn't exist.</p>
<p>Then show new against things newer than that date.</p>
| 40,969 |
<p>I like to use Emacs' shell mode, but it has a few deficiencies. One of those is that it's not smart enough to open a new buffer when a shell command tries to invoke an editor. For example with the environment variable <code>VISUAL</code> set to <code>vim</code> I get the following from <code>svn propedit</code>:</p>... | <p>You can attach to an Emacs session through <code>emacsclient</code>. First, start the emacs server with </p>
<pre><code>M-x server-start
</code></pre>
<p>or add <code>(server-start)</code> to your <code>.emacs</code>. Then,</p>
<pre><code>export VISUAL=emacsclient
</code></pre>
<p>Edit away.</p>
<p>Note:</p>
<... | <p>Not entirely true. <code>ansi-term</code> can run an emacs fine (although I usually run mg for commit logs, in the rare event I don't commit from emacs directly). <code>eshell</code> can also run an emacs if you start a <code>screen</code> first and run it from within there.</p>
| 14,197 |
<p>I have one java program that has to be compiled as 1.4, and another program that could be anything (so, 1.4 or 1.6), and the two need to pass serialized objects back and forth. If I define a serializable class in a place where both programs can see it, will java's serialization still work, or do I need 1.6-1.6 or 1.... | <p>Make sure the classes to be serialized define and assign a value to <code>static final long serialVersionUID</code> and you should be ok.</p>
<p>That said, normally I would not do this. My preference is to only use normal serialization either within a single process, or between two processes are on the same machin... | <p>If both sides uses the same jar file, it will work most of the times. However if you use different versions of the same package/module/framework ( for instance different weblogic jars or extended usage of some "rare" exceptions ) a lot of integration test is needed before it can be approved. </p>
| 41,197 |
<p>Using the instructions from <a href="http://blogs.msdn.com/pajohn/archive/2008/06/18/web-widgets-with-net-part-one.aspx" rel="nofollow noreferrer">Paul Johnson's Web Widgets</a> page I created my own custom widget. However because I was deploying to IIS 6.0 I utilized the <a href="http://blogs.msdn.com/pajohn/archiv... | <p>His instructions are incomplete. You will also need to add a script mapping in the application configuration for .jss to the aspnet_isapi.dll in windows\microsoft.NET\framework\vXXXX\ directory.</p>
<p>IIS6 doesn't do the intergrated pipeline that is intrinsic to Cassini and is default in IIS7.</p>
<p><strong>Ed... | <p>A couple of other changes I had to make...</p>
<p>Config change (handler should map to EventsWidget, not WidgetBase):</p>
<pre><code><system.web>
<httpHandlers>
<add verb="GET,HEAD" path="eventswidget.jss" type="Demo1.Handlers.EventsWidget, Demo1" validate="false" />
</httpHandlers>
</sy... | 45,609 |
<p>I have an object that can build itself from an XML string, and write itself out to an XML string. I'd like to write a unit test to test round tripping through XML, but I'm having trouble comparing the two XML versions. Whitespace and attribute order seem to be the issues. Any suggestions for how to do this? This is ... | <p>First normalize 2 XML, then you can compare them. I've used the following using lxml</p>
<pre><code>obj1 = objectify.fromstring(expect)
expect = etree.tostring(obj1)
obj2 = objectify.fromstring(xml)
result = etree.tostring(obj2)
self.assertEquals(expect, result)
</code></pre>
| <p>The Java component <code>dbUnit</code> does a lot of XML comparisons, so you might find it useful to look at their approach (especially to find any gotchas that they may have already addressed).</p>
| 41,653 |
<p>Is it possible to post a description/comment variable to the facebook sharer url? It's only possible for url and title as far as I can figure out.</p>
| <p>The parameters that you can pass to the actual <code>sharer.php</code> are "u" and "t" which are <code>url</code> and <code>title</code>. You can add <code>meta</code> tags to your page to get more info to appear in the sharer. To quote the <a href="http://www.facebook.com/share_partners.php" rel="nofollow norefer... | <p>Facebook sharer use the description <code>meta</code> tag to add a description in your post for the pictures. I don't really know how it works but I think it uses this tag in your header:</p>
<pre class="lang-html prettyprint-override"><code><link rel='image_src' href='http://www.yourwebsite/dir1/dir2/picture.jp... | 46,043 |
<p>I have a strange problem on a PeopleSoft application. It appears that integration broker messages are being processed out of order. There is another possibility, and that is that the commit is being fired asynchronously, allowing the transactions to complete out of order.</p>
<p>There are many inserts of detail... | <p>You don't mentioned whether you've set this or not, but you have a choice with Integration Broker. All messages flow through message channels, and a channel can either be ordered or unordered. If a channel is ordered then - if a message errors - all subsequent messages queue up behind it and will not be processed ... | <p>I heard from GSC. We had two domains on the sending end as well as two domains on the receiving end. All were active. According to them, it is possible when you have multiple domains for each of the servers to pick up some of the messages in the group, and therefore, process them asynchronously, rather than tr... | 12,781 |
<p>Is there a name meaning "not a singleton"?</p>
| <p>Castle Windsor uses the term "transient" to describe all non-Singleton objects.</p>
<p>I personally prefer the term "non-Singleton" though.</p>
| <p>Simply, a 'Single Instance of a Class.'</p>
| 28,851 |
<p>Hopefully this won't be taken as asking the same question twice...</p>
<p>So I'm working on a Flash website (in AS2) which has an outer index swf which loads sub swf files using <code>loadMovie("subfoo1.swf", placeToShowSwf)</code>. These in turn load an xml file which tells it what content to load. Everything work... | <p>If you're not using <code>ConfigurationManager</code> to manage your application and user settings, you should be. The configuration toolkit in the .NET Framework is remarkably well thought out, and the Visual Studio tools that interoperate with it are too. </p>
<p>The default behavior of <code>ConfigurationManage... | <p>I use the <strong>Isolation Storage</strong> for configuration. You can also use the <strong>Temp</strong> folder to store temporary information like log.</p>
| 33,916 |
<p>Does anyone know a way to convert from VB6 code to C#?</p>
<p>Is there a tool that can do this for me?</p>
<p>Is there any migration process that I can follow to do this?</p>
| <p>VisualStudio offers (or at least offered) a wizard to do a conversion from VB6 to VB.NET (which could then be converted to C# with a bit of work, possibly helped by #develop's VB.NET <-> C# converter), but when last I used it, for anything non-trivial there was a lot of manual work needing to be done so I suspect... | <p>At GreatMigrations, we do this by hand -- we use our hands to develop a VB6/COM compiler. The compiler reads a VBP (or group of related VBPs) and referenced COM libraries and constructs a "semantic model". This model is an extremely detailed set of symbol tables and opcode streams that fully and accurately describ... | 21,663 |
<p>If you were allowed to add another coding guideline to the 101 guidelines of the <a href="http://www.gotw.ca/publications/c++cs.htm" rel="noreferrer">"C++ coding standards" (Herb Sutter and Andrei Alexandrescu)</a>, which would you add?</p>
| <p>Write for a year later.</p>
| <p>Rule 102: Any change to expected functionality should result in a regression test that fails.</p>
| 26,483 |
<p>Clicking through to the download-page if see that the last version of the download is <strong>over one year old</strong> and it's also "just" a <strong>Release Candidate</strong> of version 1.0. There are really no news on any development.</p>
<p>Yes, you can find newer versions from the nightly builds, but that's ... | <p>I'd suggest PNG. Most software supports writing it, most libraries support reading it, it's lossless and supports alpha transparency. And it's a standard format.</p>
<p>And, maybe important for hobbyist 2D games, very small images also result in very small files (i.e. a 16x16 icon can be 1KB or less).</p>
| <p>PNG does NOT support alpha transparency, it has a translucency channel, which is different. This can lead to problems depending on how you are rendering sprites to the screen. TGA, hands down.</p>
| 17,576 |
<p>Say I want to copy the contents of a directory excluding files and folders whose names contain the word 'Music'.</p>
<pre><code>cp [exclude-matches] *Music* /target_directory
</code></pre>
<p>What should go in place of [exclude-matches] to accomplish this?</p>
| <p>In Bash you can do it by enabling the <code>extglob</code> option, like this (replace <code>ls</code> with <code>cp</code> and add the target directory, of course)</p>
<pre><code>~/foobar> shopt extglob
extglob off
~/foobar> ls
abar afoo bbar bfoo
~/foobar> ls !(b*)
-bash: !: event not found
~/fo... | <p>this would do it excluding exactly 'Music'</p>
<pre><code>cp -a ^'Music' /target
</code></pre>
<p>this and that for excluding things like Music?* or *?Music</p>
<pre><code>cp -a ^\*?'complete' /target
cp -a ^'complete'?\* /target
</code></pre>
| 26,676 |
<p>I'm trying to develop some SharePoint workflows for the company I work for, and I'm not too familiar with the ins and outs of the technology. Normally when I want to familiarize myself with something, I just play with it, look at the properties, find all the methods, etc. </p>
<p>When I fire up Visual Studio and ... | <p>If you want to create a Sharepoint workflow using the Sharepoint Templates, you need to have a Windows 2003 or 2008 Server running Sharepoint. Essentially, that is true for all Sharepoint development: For it to be really efficient, you <strong>need</strong> to run Visual Studio on a Sharepoint Server. This in turn m... | <p>While it's true you need SharePoint installed on your development computer for most SharePoint development, you can get away without it for workflow development. Follow these steps:</p>
<ul>
<li>Copy the SharePoint DLLs to your development computer (for workflow you'll need microsoft.sharepoint.WorkflowActions.dll)... | 38,465 |
<p>I created a Web site in VS2008. I'm wondering if I should have created it as a project instead and, if so, can it be converted? Any advantages/disadvantages to either approach?</p>
<p>TIA</p>
| <p>This may sound a bit obvious, but I think it's something that is misunderstood because VS2005 only shipped with the web site originally. If your project deals with a website that is fairly limited and doesn't have a lot of logical or physical separation, the website is fine. However if it is truly a web application ... | <p>There's some information on an old blog post of mine about the differences between the Web Site and Web Application project - <a href="http://www.aaron-powell.com/blog.aspx?id=1126" rel="nofollow noreferrer">http://www.aaron-powell.com/blog.aspx?id=1126</a></p>
<p>Personally i always use/ convert existing projects ... | 45,346 |
<p>I have an Eclipse RCP application that displays a lot (10k+) of small images next to each other, like a film strip. For each image, I am using a SWT <code>Image</code> object. This uses an excessive amount of memory and resources. I am looking for a more efficient way. I thought of taking all of these images and... | <p>You can draw directly on the GC (graphics context) of a new (big) image. Having one big Image should result in much less resource usage than thousands of smaller images (each image in SWT keeps some OS graphics object handle)</p>
<p>What you can try is something like this:</p>
<pre><code> final List<Imag... | <p>Presumably not every image is visible on screen at any one time? Perhaps a better solution would be to only load the images when they become (or are about to become) visible, disposing of them when they have been scrolled off the screen. Obviously you'd want to keep a few in memory on either side of the current vi... | 34,488 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.