instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Visual Studio randomly crashes when adding/removing references and projects. Any thoughts why? Will installing Sp1 help?</p> <p>EDIT: I do not work with any addons except SourceSafe. I do most of my development in connected mode.<br></p> <p>Developing using:<br> Visual Studio 2008 <br> WinXp Terminal Service -> Win2k3 Sp2 (64bit)<br> VSS 8.0, 32bit<br></p>
<p>Try deleting your .user and .suo files - these are the user options files that VS creates. You get a .user file for each project and a .suo file for your solution. When they get corrupted, odd things happen. Deleting them will make you lose little things like which project is selected as the startup project when you start debugging, but it usually clears up odd behavior like this.</p> <p>You may also want to clear out any temporary file locations, like the Temporary ASP.NET Files folders (if you're working in ASP.NET) just in case something odd is being cached somewhere.</p>
<p>Search for and delete any .ncb files associated with your solution. In past versions these (debugging) files used to get corrupt and deleting them would fix the problem (Visual Studio will regenerate them automatically).</p>
12,230
<p>I'm adding windows event logging functionality to an existing Java application and I'd like to utilize event ids(our admin is using them already). Is there a way to specify the event ID when logging with NTEventLogAppender?</p>
<p>From my research so far it seems like there's no way to modify the event ID from the default 4096.</p>
<p>Check out <a href="http://log4jna.codeplex.com" rel="nofollow">log4jna</a>. It's a replacement for log4j NTEventLogAppender. It doesn't do what you want right now, but it's "this close". If you still need this, we can work on implementing it.</p>
24,829
<p>For the project I'm working on I noticed that file transfer* speed is really bad if I'm using IIS FTP and HTTP services. I know that the last thing I should think is "it's a Windows bug", but the fact that simply by using IIS on Windows Server or by changing IIS on that Windows XP machine to FileZilla and LightHTTPd, my file transfer speeds go up twice from the original configuration, makes me go "hmmm".</p> <p>Are there any limitation on IIS running on Windows XP? Any file transfer throttling or something like that?</p> <p><strong>File transfer is being done using one connection to one file. My file transfer client is the only one client connecting to the PC.</strong></p> <p>Thanks.</p>
<p>As other people have said, by default there is a 10 simultaneous connection limit for IIS 5 in Win XP. This can be increased to a maximum of 40 via the metabase variable setting script.</p> <pre><code> cd \inetpub\adminscripts cscript adsutil.vbs set w3svc/MaxConnections 40 iisreset </code></pre> <p>The first command changes directory to the IIS adminscripts folder. The second command runs a script that sets the MaxConnections value in the IIS metabase to 40 (the maximum allowed). The third command (iisreset) shuts down and then restarts IIS.</p>
<p>There is also a limit to one site. Note that a site != to a Virtual Diretory/Application, so it's rarely an issue for a programmer.</p>
38,244
<p>In a LotusScript Agent that is being run via WebQueryOpen, how do you get the name of the current server?</p>
<pre><code>Set s = New NotesSession Set db = s.CurrentDatabase If db.Server &lt;&gt; "" Then Set sName = New NotesName(db.Server) Else Set sName = New NotesName(s.Username) End If </code></pre>
<pre><code>'initialize event of a WebQueryOpen agent Dim s As New notessession Dim servername As String servername = s.UserName </code></pre>
8,436
<p>What is the difference between publishing a website with visual studio and just copying the files over to the server? Is the only difference that the publish files are pre-compiled?</p>
<p>There is not much difference between "publish", and copying the files. Publish appears in a webapplication. The only difference really is publishing gives you the option to only include html and dll's, where as copying you would need to parse out source code manually. There is no full precompiling in the publish option, as Fully precompiled means no HTML at all; The aspx files are just placeholders; All html is in the compiled binaries.</p>
<p>I believe you are correct in your assumption. It has been my experience that the only difference is that published files are compiled. <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&amp;displaylang=en" rel="nofollow noreferrer">Visual Studio® 2008 Web Deployment Projects</a> is a nice enhancement for customizing your build scripts for both your Websites and Web Applications.</p>
10,428
<p>I also want to save the font size in my <code>.emacs</code> file.</p>
<pre class="lang-lisp prettyprint-override"><code>(set-face-attribute 'default nil :height 100) </code></pre> <p>The value is in 1/10pt, so 100 will give you 10pt, etc. </p>
<p>In NTEmacs 23.1, the Options menu has a "Set default font..." option.</p>
37,615
<p>I have a small calculator that I am creating in C# (Sharp Develop). The user enters two values and the code returns the third. I am having trouble rounding the third value once it is returned. I have been through a couple of forums and the msdn site and I understand the code that is posted there, but I cant seem to make it work in my situation. Can anyone provide a little help? Reference the code below.</p> <pre><code>int y; decimal x, z; x = int.Parse(tb2_fla.Text); y = int.Parse(tb2_e.Text); z = (x * y * 1.732050808m) / 1000; tb2_kva.Text = z.ToString(); </code></pre> <p>I welcome both assistance and criticism<br> Greg</p>
<p>Use <a href="http://msdn.microsoft.com/en-us/library/system.math.round.aspx" rel="nofollow noreferrer">Math.Round</a>. Or, since you're going into a string, you could use either the <a href="http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx" rel="nofollow noreferrer">Standard Numeric Format Strings</a>, or the <a href="http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx" rel="nofollow noreferrer">Custom ones</a>.</p> <pre><code>Math.Round(z, 2).ToString(); z.ToString("0.00"); </code></pre>
<p>Could Math.Round(z, nrofdecimals) be the answer to your problem?</p>
46,655
<p>My Outlook add-in handles NewInspector event of the Inspector object, in order to display a custom form for the mail item.</p> <p>I can get EntryID of the CurrentItem of the Inspector object which is passed as a parameter of the event. But, the problem is that the EntryID of the current mail item is shorter than it should be, and is unknown. I know every EntryID of every mail item that was created, and I can see that specific mail item has a wrong EntryID.</p> <p>What is wrong?</p>
<p>The idea is to remember every EntryID of the MailItem that was created by an add-in, so that it can be treated differently later. Problem was that EntryID of the item opened by an Inspector was the short one, and not in the list of remembered ids, although it should be.</p> <p>Few lines of code where I was creating mail item were:</p> <pre><code>item.Save(); item.Move(some_folder); items_list.Add(item.EntryID); </code></pre> <p>Folder 'some_folder' is inside of external non-default PST, so mail item gets new EntryID. I changed those lines to:</p> <pre><code>item.Save(); item = (Outlook.MailItem)item.Move(some_folder); items_list.Add(item.EntryID); </code></pre> <p>Now, item has a new EntryID, which can be found later.</p>
<p>Just in case this helps anyone, all I needed to do is to call <code>MailItem.Save()</code> before fetching <code>EntryID</code>. A newly created <code>MailItem</code> doesn't have any <code>EntryID</code> till it is saved (in <code>Drafts</code> folder in my case).</p>
19,598
<p>Has anyone used the new Java 1.6 JDK tool, <a href="http://web.archive.org/web/20070724060100/https://visualvm.dev.java.net/" rel="nofollow noreferrer">VisualVM</a>, to profile a production application and how does the application perform while being profiled?</p> <p>The documentation say that it is designed for both Production and Development use, but based on previous profiling experience, with other profiling tools, I am hesitant.</p>
<p>While i haven't personally used VisualVM, I saw this <a href="http://blog.xebia.com/loitering-objects-make-web-company-lose-money/" rel="nofollow noreferrer">blog post</a> just today that might have some useful information for you. He talks about profiling a production app using it.</p>
<p>It is possible to remote connect to your server from a different computer using VisualVM. You just need to right click on the "Remote" node and say "Add Remote Host." </p> <p>This would at least eliminate the VisualVM overhead (if there is any) from impacting performance while it is running.</p> <p>This may not eliminate all performance concerns, especially in Production environments, but it will help a little.</p>
10,166
<p>What's the best way to get an array of all elements in an html document with a specific CSS class using javascript?</p> <p>No javascript frameworks like jQuery allowed here right now, and I could loop all the elements and check them manually myself. I'm hoping for something a little more elegant.</p>
<p>The below answer is now pushing four years old, so it's worth noting that native browser support for <a href="https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByClassName" rel="noreferrer"><code>getElementsByClassName()</code></a> has gotten a <em>lot</em> better. But if you must support older browsers, then...</p> <p>Use one that's already been written. Most major JS libraries include one in some form or another, but if you aren't using one of them then i can recommend Robert Nyman's excellent implementation:</p> <p><a href="http://code.google.com/p/getelementsbyclassname/" rel="noreferrer">http://code.google.com/p/getelementsbyclassname/</a><br> <a href="http://www.robertnyman.com/2008/05/27/the-ultimate-getelementsbyclassname-anno-2008/" rel="noreferrer">http://www.robertnyman.com/2008/05/27/the-ultimate-getelementsbyclassname-anno-2008/</a></p> <p>There are just too many ways to make this (conceptually-simple) routine <em>slow and buggy</em> to justify writing your own implementation at this point.</p>
<p>There is no such thing as a CSS class. CSS has rule-sets and selectors (including the class selector).</p> <p>Do you mean an HTML class? The usual way is to loop over every element in the document (<code>using document.getElementsByTagName('*')</code> (for efficiency, use a specific tag name if you know the class will only be applied to elements of a certain type) and test the <code>className</code> property of each (noting that the property contains a space separated list of class names, not a single class name).</p> <p>A number of libraries (such as <a href="http://docs.jquery.com/Selectors/" rel="nofollow noreferrer">jQuery</a> or <a href="http://developer.yahoo.com/yui/docs/YAHOO.util.Dom.html#method_getElementsByClassName" rel="nofollow noreferrer">YUI</a>) have functions to simply this.</p> <p>Do you mean a CSS selector? This gets more complex, and turning to a library is almost certainly the right thing to do here. Again, jQuery or <a href="http://developer.yahoo.com/yui/selector/" rel="nofollow noreferrer">YUI</a> are decent choices.</p>
25,821
<p>I know that cursors are frowned upon and I try to avoid their use as much as possible, but there may be some legitimate reasons to use them. I have one and I am trying to use a pair of cursors: one for the primary table and one for the secondary table. The primary table cursor iterates through the primary table in an outer loop. the secondary table cursor iterates through the secondary table in the inner loop. The problem is, that the primary table cursor though apparently proceeding and saving the primary key column value [Fname] into a local variable @Fname, but it does not get the row for the corresponding foreign key column in the secondary table. For the secondary table it always returns the rows whose foreign key column value matches the primary key column value of the <strong>first row</strong> of the primary table. </p> <p>Following is a very simplified example for what I want to do in the real stored procedure. Names is the primary table</p> <pre><code>SET NOCOUNT ON DECLARE @Fname varchar(50) -- to hold the fname column value from outer cursor loop ,@FK_Fname varchar(50) -- to hold the fname column value from inner cursor loop ,@score int ; --prepare primary table to be iterated in the outer loop DECLARE @Names AS Table (Fname varchar(50)) INSERT @Names SELECT 'Jim' UNION SELECT 'Bob' UNION SELECT 'Sam' UNION SELECT 'Jo' --prepare secondary/detail table to be iterated in the inner loop DECLARE @Scores AS Table (Fname varchar(50), Score int) INSERT @Scores SELECT 'Jo',1 UNION SELECT 'Jo',5 UNION SELECT 'Jim',4 UNION SELECT 'Bob',10 UNION SELECT 'Bob',15 --cursor to iterate on the primary table in the outer loop DECLARE curNames CURSOR FOR SELECT Fname FROM @Names OPEN curNames FETCH NEXT FROM curNames INTO @Fname --cursor to iterate on the secondary table in the inner loop DECLARE curScores CURSOR FOR SELECT FName,Score FROM @Scores WHERE Fname = @Fname --*** NOTE: Using the primary table's column value @Fname from the outer loop WHILE @@FETCH_STATUS = 0 BEGIN PRINT 'Outer loop @Fname = ' + @Fname OPEN curScores FETCH NEXT FROM curScores INTO @FK_Fname, @Score WHILE @@FETCH_STATUS = 0 BEGIN PRINT ' FK_Fname=' + @FK_Fname + '. Score=' + STR(@Score) FETCH NEXT FROM curScores INTO @FK_Fname, @Score END CLOSE curScores FETCH NEXT FROM curNames INTO @Fname END DEALLOCATE curScores CLOSE curNames DEALLOCATE curNames </code></pre> <p>Here is what I get for the result. Please note that for the outer loop it DOES show the up-to-date Fname, but when that Fname is used as @Fname to fetch the relevant row from the secondary table for the succeeding iterations, it still get the rows that match the first row (Bob) of the primary table.</p> <pre><code>Outer loop @Fname = Bob FK_Fname=Bob. Score=10 FK_Fname=Bob. Score=15 Outer loop @Fname = Jim FK_Fname=Bob. Score=10 FK_Fname=Bob. Score=15 Outer loop @Fname = Jo FK_Fname=Bob. Score=10 FK_Fname=Bob. Score=15 Outer loop @Fname = Sam FK_Fname=Bob. Score=10 FK_Fname=Bob. Score=15 </code></pre> <p>Please let me know what am I do wrong. Thanks in advance!</p>
<p>The value of @fName is evaluated at :DECLARE curScores CURSOR and not in the primary loop. You must Declare and then deallocate the secon cursor in the primary loop.</p>
<p>I'd try placing the</p> <pre><code>DECLARE curScores CURSOR FOR SELECT FName,Score FROM @Scores WHERE Fname = @Fname </code></pre> <p>inside the first while, beacuse you're declaring the cursor only for the first name value</p>
30,243
<p>I want to point a file dialog at a particular folder in the current user's Local Settings folder on Windows. What is the shortcut to get this path?</p>
<p>How about this, for example:</p> <pre><code>String appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); </code></pre> <p>I don't see an enum for just the Local Settings folder.</p> <p><a href="http://web.archive.org/web/20080303235606/http://dotnetjunkies.com/WebLog/nenoloje/archive/2007/07/07/259223.aspx" rel="noreferrer">http://web.archive.org/web/20080303235606/http://dotnetjunkies.com/WebLog/nenoloje/archive/2007/07/07/259223.aspx</a> has a list with examples.</p>
<p>Environment.GetFolderPath( Environment.SpecialFolders.LocalApplicationData);?</p> <p>I can't remember if there is a "Local Settings" folder on Windows XP anymore, it seems vaguely familiar.</p>
8,154
<p>Every time I turn on my company-owned development machine, I have to kill 10+ processes using the Task Manager or any other process management app just to get decent performance out of my IDE. Yes, these are processes from programs that my company installs on my machine for security and compliance. What I'd like to do is have a .bat file or script of some kind with which I can kill the processes in question. </p> <p>Does anybody know how to do this?</p>
<p>You can do this with '<strong>taskkill</strong>'. With the /IM parameter, you can specify image names. </p> <p>Example:</p> <pre><code>taskkill /im somecorporateprocess.exe </code></pre> <p>You can also do this to '<strong>force</strong>' kill:</p> <p>Example:</p> <pre><code>taskkill /f /im somecorporateprocess.exe </code></pre> <p>Just add one line per process you want to kill, save it as a .bat file, and add in your startup directory. Problem solved!</p> <p>If this is a legacy system, <a href="http://technet.microsoft.com/en-us/sysinternals/bb896683.aspx" rel="noreferrer">PsKill</a> will do the same.</p>
<p>Use Powershell! Built in cmdlets for managing processes. <a href="http://blogs.msdn.com/powershell/archive/2007/01/16/managing-processes-in-powershell.aspx" rel="nofollow noreferrer">Examples here</a> (hard way), <a href="http://www.computerperformance.co.uk/powershell/powershell_process.htm" rel="nofollow noreferrer">here</a>(built in) and <a href="http://www.computerperformance.co.uk/powershell/powershell_process_stop.htm" rel="nofollow noreferrer">here</a> (more).</p>
5,392
<p>To present user specific data, where do I store the userID of the user currently logged in? the Session?</p>
<p>Yes, the session would be an appropriate place for that information. Assuming you are using the authentication features baked into the ASP.NET framework, you will either be loading the user ID from HttpContext.Current.User.Identity.Name or looking it up from that value.</p>
<p>yes. sesssion is used for storing user specific data.</p>
32,550
<p>I need to export multiple data tables to Excel on the clients machine, each to their own sheet. If it was just one sheet, I'd use the Excel/csv content type, but I've heard something about an XML format that can represent an entire workbook. I don't want to go down the Packaging and .xlsx route, so I need standard .xls.</p> <p>Our bug tracker, Gemini, used to have an export function that produced an XML file that Excel automatically opened as a multi-sheet workbook, but I can't find it. Is there still such a mechanism, and where can I find that schema?</p>
<p>You can use for example <a href="http://www.carlosag.net/Tools/ExcelXmlWriter/" rel="nofollow noreferrer">this library</a>, if you don't want to create your own Excel XML writer library.</p>
<p>In Excel you can save a workbook in XML format. (in Excel 2007 it is called XML Spreadsheet 2003). </p> <p>That might get you started.</p>
25,509
<p>I came across <a href="http://www.alistapart.com/articles/progressiveenhancementwithcss" rel="nofollow noreferrer">this article</a> on "A List Apart" that suggests spliting css information in (at least) three separate files, one for typography, one for layout and one for color information. Color seems pretty obvious, but how would you explain to your average programmer (that would be me) what's type and what's layout?</p>
<p>typography is typefaces (fonts), their sizes, spacing, kerning, etc.</p> <p>layout is the positioning, spacing, etc. of elements (div, span, etc.).</p>
<p>typography is typefaces (fonts), their sizes, spacing, kerning, etc.</p> <p>layout is the positioning, spacing, etc. of elements (div, span, etc.).</p>
49,980
<p>Below is my table, a User could have multiple profiles in certain languages, non-English profiles have a higher priority.</p> <pre> +----------+--------+----------------+----------------+ |ProfileID |UserID |ProfileLanguage |ProfilePriority | +----------+--------+----------------+----------------+ |1 |1 |en-US |2 | +----------+--------+----------------+----------------+ |2 |1 |es-MX |1 | +----------+--------+----------------+----------------+ |3 |1 |ja-JP |1 | +----------+--------+----------------+----------------+ |4 |2 |es-MX |1 | +----------+--------+----------------+----------------+ |5 |2 |ja-JP |2 | +----------+--------+----------------+----------------+ |6 |2 |de-DE |1 | +----------+--------+----------------+----------------+ |7 |3 |en-US |2 | +----------+--------+----------------+----------------+ </pre> <p><br />For example: When a Spanish-speaking visitor requests my site (where ProfileLanguage = 'es-MX' or ProfilePriority = 2), I want the records like below:</p> <pre> +----------+--------+----------------+----------------+ |ProfileID |UserID |ProfileLanguage |ProfilePriority | +----------+--------+----------------+----------------+ |2 |1 |es-MX |1 | +----------+--------+----------------+----------------+ |5 |2 |ja-JP |2 | +----------+--------+----------------+----------------+ |7 |3 |en-US |2 | +----------+--------+----------------+----------------+ </pre> <p><br /> Below, is the basic SQL to get the users:</p> <pre><code>SELECT UserID, MIN(ProfilePriority) AS ProfilePriority FROM Profile WHERE ProfileLanguage = 'es-MX' OR ProfilePriority = 2 GROUP BY UserID </code></pre> <p>But as you know, I can only get the UserID, but I also need other column information, like ProfileID etc.. So I hope experts here could tell me the correct SQL expression to get the right records.</p>
<p>This may work, if profilepriority and userid could be a composite unique key;</p> <pre><code>select p.* from Profile p join (SELECT UserID, MIN(ProfilePriority) AS ProfilePriority FROM Profile WHERE ProfileLanguage = 'en-US' OR ProfilePriority = 2 GROUP BY UserID) tt on p.userID = tt.UserID and p.ProfilePriority = tt.ProfilePriority </code></pre>
<p>It seems to me, though it is not clear without your table and maybe some sample data, that your problem is solved by just extending your grouping as follows:</p> <pre><code>SELECT UserID, ProfileID, MIN(ProfilePriority) AS ProfilePriority FROM Profile WHERE ProfileLanguage = 'en-US' OR ProfilePriority = 2 GROUP BY UserID, ProfileID </code></pre>
49,384
<p>I love the ease that the ASP.NET Ajax control Toolkit provides to ASP.NET developers. However, I've not found it to be a scalable solution at all. I have a page with 2 date input fields. By putting a TextBox and an CalendarExtendar control attached to it for each date field, I get several (11, in fact) external Javascript calls to /ScriptResource.axd?d=xxxx</p> <p>Is there any way to control this? Why does it suck so much? What's a better Ajax toolkit for .NET that can provide equal (or better) set of functionality that is more scalable, straight forward and completely customizable? NOT looking to reinvent the wheel here.</p>
<p>I always preferred to write my Ajax calls in javascript using JQuery or Prototype. ASP.NET Ajax Toolkit does make things easier, but it never seems to do so elegantly.</p> <p>I personally would make a new Calendar Controller. This way you can control the AJAX (using JQuery/Prototype) calls that are being made.</p>
<p>ASP.NET AJAX allows you to register web services with the ScriptManager which will create JavaScript proxies for you to call. See <a href="http://msdn.microsoft.com/en-us/library/bb515101.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb515101.aspx</a>.</p>
3,660
<p>Nikhil Kothari's <a href="http://projects.nikhilk.net/ScriptSharp/" rel="nofollow noreferrer">Script#</a> is quite possibly one of the most amazing concepts I've seen in the JavaScript arena for quite some time. This question isn't about JavaScript, but rather about language compilation in the .NET runtime.</p> <p>I've been rather interested in how, using the .NET platform, one can write a compiler for a language that already has a compiler (like C#) that will generate separate output from the original compiler while allowing the original compiler to generate output for the same source during the same build operation, all the while referencing/using the output of the other compiler as well.</p> <p>I'm not entirely sure I even understand the process well enough to ask the question with the right details, but this is the way I currently see the process, as per diagrams in the Script# docs. I've thought about many things involving complex language design and compilation that may be able to take advantage of concepts like this and I'm interested in what other people think about the concepts.</p> <p>--</p> <p>Edit: Thanks for commenting,so far; your information is, in it's own right, very intriguing and I should like to research it more, but my question is actually about how I would be able to write my own compiler/s that can be run on the same source at the same time producing multiple different types of (potentially) interdependent output using the CLR. Script# serves as an example since it generates JavaScript and an Assembly using the same C# source, all the while making the compiled Assembly cooperate with the JavaScript. I'm curious what the various approaches and theoretical concepts are in designing something of this nature.</p>
<p>It's important to realize that all a compiler does is take a source language (C# in this case), parse it so the compiler has a representation that makes sense to it and not humans (this is the abstract syntax tree), and then does a naive code generation to the target language (msil is the target for languages that run on the .NET runtime).</p> <p>Now if the script# code is turned into an assembly and interacts with other .NET code, that means this compiler must be generating msil. script# is using csc.exe for this, which is just the standard c# comiler. Now to generate the javascript, it must take either c# or msil, parse it, and generate javascript to send to the browser. The docs says it has a custom c# -> js compiler called ssc.exe. </p> <p>To make things interact consistently on both the client side and the server side it has a set of reference assemblies that are written in .NET but are also compiled to javascript. This is not a compiler specific issue though, those reference assemblies are the script# runtime. The runtime is probably responsible for a lot of the script# magic you're perceiving though.</p>
<p>So let's say you want to compile C# into Javascript. You are asking whether you can take advantage of the existing C# compilers, so instead of compiling C# into Javascript directly you actually convert the MSIL generated by the C# compiler into Javascript?</p> <p>Sure, you can do that. Once you have the MSIL binary you can do whatever you want to it.</p>
10,089
<p>I have a windows service that runs various system monitoring operations. However, when running <code>SNMP</code> related checks, I always get a <code>NullReference exception</code>. </p> <p>The code runs fine when run through the user interface (under my username and password), but always errors running as the service. </p> <p>I've tried running the service as different user accounts (including mine), with no luck. I've tried replacing the <code>SNMP</code> monitoring code with calling the <code>PowerShell cmdlet get-snmp</code> (from the <code>/n NetCmdlets</code>), but that yields the same error.</p> <p>The application I'm working with is <a href="http://codeplex.com/polymon" rel="nofollow noreferrer">PolyMon</a>. </p> <p>Any ideas?</p>
<p>Some ways to debug:</p> <ul> <li>Is there any additional information in the Windows events log?</li> <li>I believe you should be able to listen to some kind of global-exception event like Application_Exception in windows services. I can't remember the exact name but you can atelast dump stack trace from there.</li> <li>You should be able to start debugging the project in service mode.</li> </ul> <p>Some code snippets/stack trace/information will definitely help.</p>
<p>A couple of things we've seen - more about differences between interactive vs services, but might help...</p> <p>One thing we've seen that does not seem relevant is the difference with what is on the user vs system path. </p> <p>Another thing we've seen relates to temporary files - the service we had was creating lots in the windows\temp directory - we tracked this down when it had created something like 65000 of these files and thus hit the limit of what a directory can hold...</p> <p>Regards, Chris</p>
7,106
<p>For an interview in a few, I'm not at all familiar with Flash development. </p> <p>What would you ask?</p>
<p>Honestly, if you yourself aren't a flash developer, I'd caution against interviewing a potential Flash developer, unless you're only doing it to get a sense of their character (as opposed to their skill level). Experience in working with the technology is going to give you a much more realistic perspective - blindly asking questions that other people told you are good ones to ask will get you into trouble.</p> <p>That said, if you can find someone you know to sit in on the interview with you and provide evaluation from a technical standpoint, here's a few things I'd remind them to ask:</p> <ul> <li>object oriented programming</li> <li>loading external media</li> <li>audio &amp; video playback (also maybe volume control / mixing)</li> <li>event listeners</li> <li>transitions / animation</li> <li>filter / sort algorithms</li> <li>common UI elements: scrollbar, form elements, drop-down menu, rollover states, drag-and-drop, etc.</li> </ul> <p>Those are sort of generally useful areas of knowlege, but the true test of profficiency is a practical test - "write a class that meets these requirements", or "this code isn't working, find out why and fix it" are good ways to immediately gain insight into the candidate's work (and thought) process.</p> <p><strong>Most importantly:</strong> even if the interviewee is short on specific knowlege or experience of the subjects you settle on, it's better to get someone who is a fast learner and will easily comprehend new concepts then to get someone who might know a lot now, but will resist learning new stuff.</p>
<p>Do you know Object Oriented?</p> <p>What do you like in ActionScript3 that ActionScript 2 haven't?</p>
16,358
<p>I'm trying to monitor the states of a group of threads in a Microsoft.NET application written in C#. I'd like to be able to also monitor any child threads spawned by the original threads.</p> <p>In Java, you can assign threads to a thread group, and their children will also belong to the group. Is there an equivalent in .NET?</p> <p>I briefly looked at ExecutionContext and LogicalCallContext, but I can't see how to find all the threads that are in a context. Raymond Chen has an article about a <a href="http://blogs.msdn.com/oldnewthing/archive/2006/02/23/537856.aspx" rel="nofollow noreferrer">Win32 API method</a> for enumerating threads, but I hope I don't have to go that low.</p>
<p>You can enumerate the threads in your process using the <a href="http://msdn.microsoft.com/de-de/library/system.diagnostics.process.threads(VS.80).aspx" rel="nofollow noreferrer">Threads</a> property of System.Diagnostics.Process.</p> <p>Note however, that the objects you get here are not of the same type as those you create to start threads yourself (i.e. are not System.Threading.Thread objects).</p> <p>A concept of thread groups does not exist however, AFAIK.</p>
<p>Make it simple:</p> <p>Create your ThreadGroup class with a method wrapping the thread creation process.</p> <p>When this method is called, it adds the created thread to a Collection and there is your group.</p>
18,609
<p>Having an issue with some images using IE7 - work fine in 6 and in all versions of Firefox.</p> <p>Has anyone run across this before? I know I've had it happen in the past (and I googled a fix, but darned if I can find the fix again... note to self, document things like this for future ;) )</p> <pre><code>&lt;div class="contextBlock"&gt; &lt;p class="cntImg"&gt;&lt;a href="files/image.jsp" title="Image"&gt;&lt;img src="files/images/image.jpg" alt="Image" width="171" height="96" border="0"&gt;Image&lt;/a&gt;&lt;/p&gt; &lt;p class="cntImg"&gt;&lt;a href="files/image2.jsp" title="image2"&gt;&lt;img src="files/images/image2.jpg" alt="Image2" width="171" height="96" border="0"&gt;Image2 &lt;/a&gt;&lt;/p&gt; &lt;p class="comment"&gt;Click to enlarge&lt;/p&gt; &lt;div class="clr"&gt;&lt;/div&gt; </code></pre> <p></p>
<p>I've come across this type of problem before when images uploaded to our site were JPEGs in <a href="http://en.wikipedia.org/wiki/CMYK_color_model" rel="noreferrer">CMYK</a> format - Internet explorer would show them as a small red x, but Firefox would show them OK (definitely as of version 3, not sure about earlier releases).</p> <p>Could you post the css rules for <code>contextBlock</code>, <code>cntImg</code> and <code>clr</code>? Another "funny" IE thing I've come across in the past is images disappearing behind a text block which has a css style that IE doesn't like, so I'm wondering if this might be applicable in your case.</p>
<p>I have had similar issues in the past running the page locally on my machine with IE7. That could be the issue.</p>
25,900
<p>How do you debug <a href="http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String)" rel="noreferrer">getResource</a>-style methods that are failing, returning null?</p> <p>I am sure the file it's looking for is there, but it's returning NULL. How do I know what it is looking for to try to spot any mismatch?</p>
<p>Since <code>getResource()</code> searches the classpath (as others have mentioned), it might be helpful to dump the actual classpath being searched before your problemsome <code>getResource()</code> call:</p> <pre><code>log.debug("classpath is: " + System.getProperty("java.class.path")); //the line that is returning null ... = Thread.currentThread().getContextClassLoader().getResource("foobar"); </code></pre> <p>What is probably happening is that the files/directories you think are on the classpath are actually not (perhaps an invalid path is being set somewhere along the way).</p>
<p>I've usually experience this whenever the ClassLoader changes.</p> <p>Depending on the exact context that an app is running ClassLoaders have different rules about when a resource file exists. For example in netbeans getResource is case insensitive, but in Sun's JRE it is.</p> <p>Although not directly answering your question, I thought you should know this (if you didn't already).</p>
31,544
<p>I need to copy the content of a window (BitBlt) which is hidden, to another window. The problem is that once I hide the source window, the device context I got isn't painted anymore.</p>
<p>What you need is the <a href="http://msdn.microsoft.com/en-us/library/ms535695.aspx" rel="noreferrer">PrintWindow</a> function that's available in Win32 API since Windows XP. If you need it to work with older versions of Windows, you can try <a href="http://msdn.microsoft.com/en-us/library/ms534856(VS.85).aspx" rel="noreferrer">WM_PRINT</a>, although I've never been able to make it work.</p> <p>There's a nice article <a href="http://msdn.microsoft.com/en-us/library/ms997649.aspx" rel="noreferrer">here</a> that shows how to use PrintWindow, and here's the relevant code snippet from that article:</p> <pre><code>// Takes a snapshot of the window hwnd, stored in the memory device context hdcMem HDC hdc = GetWindowDC(hwnd); if (hdc) { HDC hdcMem = CreateCompatibleDC(hdc); if (hdcMem) { RECT rc; GetWindowRect(hwnd, &amp;rc); HBITMAP hbitmap = CreateCompatibleBitmap(hdc, RECTWIDTH(rc), RECTHEIGHT(rc)); if (hbitmap) { SelectObject(hdcMem, hbitmap); PrintWindow(hwnd, hdcMem, 0); DeleteObject(hbitmap); } DeleteObject(hdcMem); } ReleaseDC(hwnd, hdc); } </code></pre> <p>I should have some Python code that uses wxPython to achieve the same thing. Drop me a note if you want it.</p>
<p>Maybe you can trigger a redraw operation on the window with InvalidateRect?</p>
30,025
<p>I came across a c library for opening files given a Unicode filename. Before opening the file, it first converts the filename to a path by prepending "\\?\". Is there any reason to do this other than to increase the maximum number of characters allowed in the path, per <a href="http://msdn.microsoft.com/en-us/library/aa365247.aspx" rel="noreferrer">this msdn article</a>? </p> <p>It looks like these "\\?\" paths require the Unicode versions of the Windows API and standard library.</p>
<p>Yes, it's just for that purpose. However, you will likely see compatibility problems if you decide to creating paths over MAX_PATH length. For example, the explorer shell and the command prompt (at least on XP, I don't know about Vista) can't handle paths over that length and will return errors.</p>
<p>I've been writing Windows code since 1995, and although I'm aware of that prefix, I've never found any reason to use it. Increasing the path length beyond <code>MAX_PATH</code> seems to be the only reason for it, and neither I nor any of my programs' customers have ever done so, to my knowledge.</p>
44,397
<p>I'm trying to write a greasemonkey script, and it would be preferable for it to be able to work with images (specifically, find the darkest pixel in an image). Is there a way to do this or must I embed flash?</p>
<p>Since it's Firefox specific, you can use a canvas element. I've never written a greasemonkey script, so I don't know exactly how you would do it, but the idea is, you create a new canvas element and draw the image onto the canvas. Then, you can get the pixel values from the canvas.</p> <pre><code>// Create the canvas element var canvas = document.createElement("canvas"); canvas.width = image.width; canvas.height = image.height; // Draw the image onto the canvas var ctx = canvas.getContext("2d"); ctx.drawImage(image, 0, 0); // Get the pixel data var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); // Loop through imageData.data - an array with 4 values per pixel: red, green, blue, and alpha for (int x = 0; x &lt; imageData.width; x++) { for (int y = 0; y &lt; imageData.height; y++) { var index = 4 * (y * imageData.width + x); var r = imageData.data[index]; var g = imageData.data[index + 1]; var b = imageData.data[index + 2]; var a = imageData.data[index + 3]; // Do whatever you need to do with the rgba values } } </code></pre>
<p>Scrap the</p> <pre><code>var r = imageData.data[index]; var g = imageData.data[index + 1]; var b = imageData.data[index + 2]; var a = imageData.data[index + 3]; </code></pre> <p>part, Javascript doesn't pass by reference.</p>
47,793
<p>I have a form that displays file information in a TabControl, and I'd like the pages to have the file's icon in their tab. How do I get the icon associated with a file type?</p> <p>I'd prefer solutions that don't involve looking things up in the registry, but if that's the only way then so be it.</p>
<p><a href="http://www.codeproject.com/KB/dotnet/System_File_Association.aspx" rel="nofollow noreferrer">CodeProject</a> has some classes you can download.</p> <p>First get the <code>FileAssociationInfo</code>, and from that get the <code>ProgramAssociationInfo</code>. The <code>pai</code> object can give you the icon.</p> <pre><code>FileAssociationInfo fai = new FileAssociationInfo(".bob"); ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID); ProgramIcon icon = pai.DefaultIcon; </code></pre>
<p><a href="http://msdn.microsoft.com/en-us/library/system.drawing.icon.extractassociatedicon.aspx" rel="noreferrer">System.Drawing.Icon.ExtractAssociatedIcon(string filePath)</a></p>
34,237
<p>Anyone know where to find a reference that describes how to output color on the Windows CLI interfaces using API and/or stdout?</p>
<p>The Win32 <a href="http://msdn.microsoft.com/en-us/library/ms682010.aspx" rel="nofollow noreferrer">console API</a> has a function, <a href="http://msdn.microsoft.com/en-us/library/ms686047.aspx" rel="nofollow noreferrer">SetConsoleTextAttribute</a>, that can be used to set the text foreground and background colours. Sample code is <a href="http://msdn.microsoft.com/en-us/library/ms686974.aspx" rel="nofollow noreferrer">here</a>.</p>
<p>in powershell write-host takes -backgroundcolor and -foregroundcolor parameters</p>
31,345
<p>I know the standard way of using the <a href="https://en.wikipedia.org/wiki/Null_coalescing_operator" rel="noreferrer">null coalescing operator</a> in C# is to set default values.</p> <pre><code>string nobody = null; string somebody = &quot;Bob Saget&quot;; string anybody = &quot;&quot;; anybody = nobody ?? &quot;Mr. T&quot;; // Returns Mr. T anybody = somebody ?? &quot;Mr. T&quot;; // Returns &quot;Bob Saget&quot; </code></pre> <p>But what else can <code>??</code> be used for? It doesn't seem as useful as the <a href="https://en.wikipedia.org/wiki/%3F:" rel="noreferrer">ternary operator</a>, apart from being more concise and easier to read than:</p> <pre><code>nobody = null; anybody = nobody == null ? &quot;Bob Saget&quot; : nobody; // Returns Bob Saget </code></pre> <p>So given that fewer even know about null coalescing operator...</p> <ul> <li><p>Have you used <code>??</code> for something else?</p> </li> <li><p>Is <code>??</code> necessary, or should you just use the ternary operator (that most are familiar with)</p> </li> </ul>
<p>Well, first of all, it's much easier to chain than the standard ternary operator:</p> <pre><code>string anybody = parm1 ?? localDefault ?? globalDefault; </code></pre> <p>vs.</p> <pre><code>string anyboby = (parm1 != null) ? parm1 : ((localDefault != null) ? localDefault : globalDefault); </code></pre> <p>It also works well if a null-possible object isn't a variable:</p> <pre><code>string anybody = Parameters[&quot;Name&quot;] ?? Settings[&quot;Name&quot;] ?? GlobalSetting[&quot;Name&quot;]; </code></pre> <p>vs.</p> <pre><code>string anybody = (Parameters[&quot;Name&quot;] != null ? Parameters[&quot;Name&quot;] : (Settings[&quot;Name&quot;] != null) ? Settings[&quot;Name&quot;] : GlobalSetting[&quot;Name&quot;]; </code></pre>
<p>I have used it like this:</p> <pre><code>for (int i = 0; i &lt; result.Count; i++) { object[] atom = result[i]; atom[3] = atom[3] ?? 0; atom[4] = atom[4] != null ? &quot;Test&quot; : string.Empty; atom[5] = atom[5] ?? &quot;&quot;; atom[6] = atom[6] ?? &quot;&quot;; atom[7] = atom[7] ?? &quot;&quot;; atom[8] = atom[8] ?? &quot;&quot;; atom[9] = atom[9] ?? &quot;&quot;; atom[10] = atom[10] ?? &quot;&quot;; atom[12] = atom[12] ?? false; } </code></pre>
35,195
<p>How can I ignore accents (like ´, `, ~) in queries made to a SQL Server database using LINQ to SQL?</p> <p><strong>UPDATE:</strong></p> <p>Still haven't figured out how to do it in LINQ (or even if it's possible) but I managed to change the database to solve this issue. Just had to change the collation on the fields I wanted to search on. The collation I had was:</p> <pre><code>SQL_Latin1_General_CP1_CI_AS </code></pre> <p>The CI stans for "Case Insensitive" and AS for "Accent Sensitive". Just had to change the AS to AI to make it "Accent Insensitive". The SQL statement is this:</p> <pre><code>ALTER TABLE table_name ALTER COLUMN column_name column_type COLLATE collation_type </code></pre>
<p>In SQL queries (Sql Server 2000+, as I recall), you do this by doing something like select MyString, MyId from MyTable where MyString collate Latin1_General_CI_AI ='aaaa'.</p> <p>I'm not sure if this is possible in Linq, but someone more cozy with Linq can probably translate.</p> <p>If you are ok with sorting and select/where queries ALWAYS ignoring accents, you can alter the table to specify the same collation on the field(s) with which you are concerned.</p>
<p>A solution could be create an SQL Function to remove the diacritics, by applying to the input string the collation SQL_Latin1_General_CP1253_CI_AI, like so:</p> <pre><code>CREATE FUNCTION [dbo].[RemoveDiacritics] ( @input varchar(max) ) RETURNS varchar(max) AS BEGIN DECLARE @result VARCHAR(max); select @result = @input collate SQL_Latin1_General_CP1253_CI_AI return @result END </code></pre> <p>Then you could add it in the DB context (in this case ApplicationDbContext) by mapping it with the attribute DbFunction:</p> <pre><code>public class ApplicationDbContext : IdentityDbContext&lt;CustomIdentityUser&gt; { [DbFunction(&quot;RemoveDiacritics&quot;, &quot;dbo&quot;)] public static string RemoveDiacritics(string input) { throw new NotImplementedException(&quot;This method can only be used with LINQ.&quot;); } public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options) : base(options) { } } </code></pre> <p>And finally use it in LINQ query, for example (linq-to-entities):</p> <pre><code>var query = await db.Users.Where(a =&gt; ApplicationDbContext.RemoveDiacritics(a.Name).Contains(ApplicationDbContext.RemoveDiacritics(filter))).tolListAsync(); </code></pre>
41,737
<p>This is a followup to <a href="https://stackoverflow.com/questions/284428/avoiding-property-itis-ie-overuse-of-properties-when-are-they-appropriate">Avoiding @property-itis</a>.</p> <p>UIWebView has the following property declarations:</p> <pre><code>@property(nonatomic,readonly,getter=canGoBack) BOOL canGoBack; @property(nonatomic,readonly,getter=canGoForward) BOOL canGoForward; </code></pre> <p>UIScrollView has these:</p> <pre><code>@property(nonatomic) BOOL canCancelContentTouches; </code></pre> <p>Yet, UIResponder has </p> <pre><code>- (BOOL)isFirstResponder; - (BOOL)canBecomeFirstResponder; - (BOOL)canResignFirstResponder; </code></pre> <p>Is the UIResponder case one where they should have been declared as properties, but, for whatever reason, were not?</p> <p>Or is it a case where declaring them as properties was inappropriate? If inappropriate, why?</p>
<p>My best guess is that UIResponder is meant to match NSResponder, which of course was designed before Objective-C 2.0 introduced properties. Why UIWebView doesn't do the same with regard to WebView, I don't know. I'd expect properties in Cocoa to be a little schizophrenic in this way for some time, and I wouldn't think into it too much when considering your own code.</p>
<p>A property should map, intuitively if not exactly, to some storage mechanism of your class - be it an ivar declared in your <code>@interface</code> or something synthesized by the runtime. The act of calling a method such as <code>canBecomeFirstResponder</code> need not necessarily query the class for a storage mechanism which holds a trivial <code>BOOL</code> but rather causes some chain of events to fire off that queries the responder tree. That is to say that there is no <code>firstResponder</code> ivar as the value of any of those methods cannot be stored in a cache and must be determined at the time of their execution.</p>
38,845
<p>Ever since I first wrote</p> <pre><code>if ($a = 5) { # do something with $a, e.g. print "$a"; } </code></pre> <p>and went through the normal puzzling session of </p> <ul> <li>why is the result always true</li> <li>why is $a always 5</li> </ul> <p>until I realized, I'd assigned 5 to $a, instead of performing a comparison.</p> <p>So I decided to write that kind of condition above as </p> <pre><code> if (5 == $a) </code></pre> <p>in other words: </p> <p><strong>always place the constant value to the left side of the comparison operator, resulting in a compilation error, should you forget to add the second "=" sign.</strong></p> <p>I tend to call this <strong>defensive coding</strong> and tend to believe it's <strong>a cousin to defensive-programming</strong>, not on the algorithmic scale, but keyword by keyword. </p> <p>What defensive coding practices have you developed? </p> <hr> <p><strong>One Week Later:</strong> </p> <p>A big "thank you" to all who answered or might add another answer in the future. </p> <p>Unfortunately (or rather fortunately!) there is no single correct answer. For that my question was to broad, asking more for opinions or learnings of experience, rather than facts. </p>
<p>This is a simple and obvious one, but I NEVER EVER NEVER repeat the same string constant twice in my code, cause I KNOW that if I do I will be spelling one of them wrong :) Use constants, people! </p>
<p>Installed Resharper ;) Then I don't need to write "5 == a" to get warned if I did something wrong :)</p>
33,587
<p>how do i implement an eval script in a sever side control?</p> <p>eg. <code>&lt;a runat="server" href="?id=&lt;%= Eval("Id") %&gt;"&gt;hello world&lt;/a&gt;</code></p>
<p>If the server-side control is within a databound control (ListView, GridView, FormView, DetailsView), then the syntax is: <code>&lt;%# Eval("Id") %&gt;</code>.</p> <p>If the server-side control is not within a databound control, you will have to access it via the code-behind and set your attribute there.</p>
<p>as far as I know, its &lt;%# instead of &lt;%=</p>
16,127
<p>I'm working in a web application using VB.NET. There is also VisualBasic code mixed in it, in particular the Date variable and the Month function of VB.</p> <p>The problem is this part:</p> <pre><code>Month("10/01/2008") </code></pre> <p>On the servers, I get 10 (October) as the month (which is supposed to be correct). On my machine, I get 1 (January) (which is supposed to be wrong).</p> <p>Two of my colleagues (on their own machines) get different answers, one got 1, the other got 10.</p> <p><strong>The question is, why is this so?</strong></p> <p>On my end, I can solve the problem by using .NET's DateTime's Parse (or ParseExact) function to force everything to be "dd/MM/yyyy" format. This works. I'm just wondering why there's an inconsistency.</p> <p>Extra info: I know the parameter for Month function is supposed to be a Date variable. The code used a string as parameter, and Option Strict was off, and the developers mainly let VB do its own conversion thing. (Legacy code maintenance has a lot of inertia...)</p> <p>If it helps, the version of Microsoft.VisualBasic.dll on the servers is 7.10.6310.4 (under the Framework folder v1.1.4322). The version on mine (and my 2 colleagues') machine is 7.10.6001.4.</p> <p>Edit: Regional settings for all machines already set to dd/MM/yyyy format (short date format).</p>
<p>This normally has to do with the regional settings, and more specifically the date/time formats. If you set these formats so that they are all the same on the machines you're testing on, the results should be consistent. </p> <p>Your idea of using ParseExact is definitely the better solution to go with, IMHO.</p>
<p>This is because the runtime has to convert your given value "10/01/2008" which is indeed a string implicitly to the DateTime datatype.</p> <p>When converting strings to dates and the other way round, the string format depends on the locale settings of windows.</p> <p>See <a href="http://msdn.microsoft.com/en-us/library/aa292073.aspx" rel="nofollow noreferrer">this link</a> on msdn.</p> <p>In <a href="http://msdn.microsoft.com/en-us/library/3eaydw6e(VS.80).aspx" rel="nofollow noreferrer">this article</a> a way to specify a date literal which is independent of your locale settings:</p> <p>Just enclose the date with the sign # and specify it in the form mm/dd/yyyy:</p> <p>So the code </p> <pre><code>Month(#10/01/2008#) </code></pre> <p>should give you the answer 10 on any machine.</p> <p>Ther a two more worarounds given in that msdn article:</p> <p><strong>1. Use the Format Function with predifned Date/Time Format</strong></p> <blockquote> <p>To convert a Date literal to the format of your locale, or to a custom format, supply the literal to the Format Function, specifying either Predefined Date/Time Formats (Format Function) or User-Defined Date/Time Formats (Format Function). The following example demonstrates this.</p> <p>MsgBox("The formatted date is " &amp; Format(#5/31/1993#, "dddd, d MMM yyyy"))</p> </blockquote> <p><strong>2. Use the DateTime-Class Constructor to construt the right DateTime value</strong></p> <blockquote> <p>Alternatively, you can use one of the overloaded constructors of the DateTime structure to assemble a date and time value. The following example creates a value to represent May 31, 1993 at 12:14 in the afternoon.</p> <p>Dim dateInMay As New System.DateTime(1993, 5, 31, 12, 14, 0)</p> </blockquote>
21,957
<p>I have a block of code intended to pull text descriptions from a database table and save them to a text file. It looks like this (C# .NET):</p> <pre><code> OdbcCommand getItemsCommand = new OdbcCommand("SELECT ID FROM ITEMS", databaseConnection); OdbcDataReader getItemsReader = getItemsCommand.ExecuteReader(); OdbcCommand getDescriptionCommand = new OdbcCommand("SELECT ITEMDESCRIPTION FROM ITEMS WHERE ID = ?", databaseConnection); getDescriptionCommand.Prepare(); while (getItemsReader.Read()) { long id = getItemsReader.GetInt64(0); String outputPath = "c:\\text\\" + id + ".txt"; if (!File.Exists(outputPath)) { getDescriptionCommand.Parameters.Clear(); getDescriptionCommand.Parameters.AddWithValue("id", id); String description = (String)getDescriptionCommand.ExecuteScalar(); StreamWriter outputWriter = new StreamWriter(outputPath); outputWriter.Write(description); outputWriter.Close(); } } getItemsReader.Close(); </code></pre> <p>This code has successfully saved a portion of the data to .txt files, but for many rows, an AccessViolationException is thrown on the following line:</p> <pre><code> String description = (String)getDescriptionCommand.ExecuteScalar(); </code></pre> <p>The Exception text is "Attempted to read or write protected memory. This is often an indication that other memory is corrupt".</p> <p>The program will usually throw the exception on the same rows of the table, but it doesn't appear to be 100% consistent. Sometimes data that had thrown the exception in the past will suddenly work.</p> <p>Some people are undoubtedly wondering why I didn't just SELECT ID, ITEMDESCRIPTION FROM ITEMS in the getItemsCommand and skip the second query. Actually, I did it that way initially, and I was encountering the same error with getItemsCommand.GetString(). I was afraid that perhaps the dataset was taking up too much memory and maybe that was causing the error. So I decided to try this method to see if it would help. It didn't. Does anyone know why this might be happening?</p> <p>By the way, ID is an INT and ITEMDESCRIPTION is a VARCHAR(32000) column. If it makes any difference, the database is Borland Interbase 6.0 (Ick!)</p> <p>EDIT: I gave the wrong line when describing where the exception was being thrown!! ARGH!! Fixed now. Also, I've tried the things suggested so far, but they didn't help. However, I found that only very old records in the database were causing this error, which is strange. If I change the query to only pull records inserted in the last 5 years, there are no problems. Someone suggested to me this might be an encoding conversion problem or something like that?</p> <p><b>Update:</b> Solved it. The problem turned out to be a bug in the ODBC driver for our not-very-reliable database software. A workaround with other drivers fixed the problem.</p>
<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 Stentz's D* algorithm (original whitepaper <a href="http://www.frc.ri.cmu.edu/~axs/doc/icra94.pdf" rel="noreferrer">here</a>) has largely been deprecated by derivatives of his work. D* Lite and LPA* are the most commonly found and are much easier to code/implement.</p> <p>As far as real world experience, Joseph Carsten and Art Rankin from NASA's Jet Propulsion Laboratory installed a version of Field D* using elements of D* Lite on the mars rovers "Spirit" and "Opportunity" (slideshow of rovers using D* <a href="http://www.ceng.metu.edu.tr/~erogul/ceng585/13_DEC_2007_Presentation/d-star-hidden-slides-deleted.ppt" rel="noreferrer">here</a>). In Feburary 2007 it was used to fully navigate the mars rover autonomously. </p> <p><a href="http://asm.arc.nasa.gov/Gallery/images/generic/rover.jpg" rel="noreferrer">alt text http://asm.arc.nasa.gov/Gallery/images/generic/rover.jpg</a></p> <p>Apparently D* is really useful in the robotics domain because the robots on-board sensors are constantly re-evaluating edge values. That would make it pretty "battle tested" in my own opinion. </p> <p>Similarly, I found another <a href="http://www.stes.fi/scai2006/proceedings/176-182.pdf" rel="noreferrer">whitepaper</a> that mentions the use of the D* Lite algorithm in Mobile Gaming.</p> <p>I'll end this answer by stating that I've never implemented D* before, only A*. Because of the significant increase in complexity I would say that D* (or D* Lite) should only be used in cases where there is a significant and frequent changes in the graph. You described your situation as being similar to that so I would say definately go for D* Lite. If NASA uses it you could safely bet it has been thoroughly investigated.</p>
<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 goal and start points in the map. So, it is much faster than D*. In dynamic environment, D* is faster and more efficient than A*. Because on the way robot goes, if it detects a new obstacle, it only updates a few nodes around the unexpected obstacle. While, A* will calculates again all things. </p>
28,252
<p>Spending thousand of hours in front of my computer, ergonomics became quickly a main issue.</p> <p>For the monitor or the keyboard, technical solutions exist. But for the mouse, I never get used to the trackball and putting a little pillow under my wrist made me feel uncomfortable.</p> <p>So I started to swap the hand that holds the mouse. It's great, one can rest while he other is working. At the beginning it was hard, but now I don't really see the difference unless I try to kick an ass at Quake III ;-)</p> <p>Anyway, a lot of people would not be comfortable with this idea, do not have the time, and above all, can not afford the mental switch that comes with the use of the other hand. Indeed, using the other hand make you use the other side of you brain (logical &lt;=> creative), making very hard to concentrate the first times.</p> <p>I am happy about it but can understand that many people would not. Do you have a better idea ?</p>
<p>Yeah I had that problem too for a while. The first thing I did was modify my chair so I had a flat area where I could put a mouse and rest my arm on the padded arm wrest. Now I have an L shaped desk, and can rest my whole arm on the desk ( from elbow to hand anyway ). I found that it makes a big difference over just wresting my wrist. I still use my modified chair to hold a flight stick for gaming though ;)</p>
<p>I tried a <a href="http://www.google.com/search?q=vertical+mouse" rel="nofollow noreferrer">vertical mouse</a> but found it to be more uncomfortable because you lose the wrist support afforded by resting your hand <em>on</em> the mouse.</p> <p>It was a waste of money for me, but your mileage may vary.</p>
21,404
<p>I am looking for easy steps that are simple and effective in making a web application more secure.</p> <p>What are your top tips for secure web applications, and what kind of attack will they stop?</p>
<p>Microsoft Technet has en excellent article:</p> <p><a href="http://technet.microsoft.com/en-us/library/cc512638.aspx" rel="nofollow noreferrer">Ten Tips for Designing, Building, and Deploying More Secure Web Applications</a></p> <p>Here are the topics for the tips answered in that article:</p> <ol> <li>Never Directly Trust User Input</li> <li>Services Should Have Neither System nor Administrator Access</li> <li>Follow SQL Server Best Practices</li> <li>Protect the Assets</li> <li>Include Auditing, Logging, and Reporting Features</li> <li>Analyze the Source Code</li> <li>Deploy Components Using Defense in Depth</li> <li>Turn Off In-Depth Error Messages for End Users</li> <li>Know the <a href="http://technet.microsoft.com/nb-no/library/cc722488(en-us).aspx" rel="nofollow noreferrer">10 Laws of Security Administration</a></li> <li>Have a Security Incident Response Plan</li> </ol>
<p>Set the secure flag on cookies for SSL applications. Otherwise there is always a highjacking attack that is <em>much</em> easier to conduct than breaking the crypto. This is the essence of CVE-2002-1152.</p>
6,953
<p>I would like to be able to fusion an <code>IEnumerable&lt;IEnumerable&lt;T&gt;&gt;</code> into <code>IEnumerable&lt;T&gt;</code> (i.e. merge all individual collections into one). The <code>Union</code> operators only applies to two collections. Any idea?</p>
<p>Try </p> <pre><code>var it = GetTheNestedCase(); return it.SelectMany(x =&gt; x); </code></pre> <p>SelectMany is a LINQ transformation which essentially says "For Each Item in a collection return the elements of a collection". It will turn one element into many (hence SelectMany). It's great for breaking down collections of collections into a flat list. </p>
<pre><code>var lists = GetTheNestedCase(); return from list in lists from element in list select element; </code></pre> <p>is another way of doing this using C# 3.0 query expression syntax.</p>
41,571
<p>I'm in the process of building a 3D printer and have all the stepper motors wired up and the controller connected to the computer running pronterface.</p> <p>I can move each axis and also send g-code to the printer.</p> <p>Now <strong>how can I define the current position to be the 0/0/0 position?</strong> I'd like to move the printer into a position where I think should be the zero position and define it as such in pronterface somehow.</p>
<blockquote> <p>G92 X0 Y0 Z0</p> </blockquote> <p>tells the printer that the current position is (0,0,0).</p>
<p>There's a handy list of G0-codes at <a href="http://reprap.org/wiki/G-code" rel="nofollow">http://reprap.org/wiki/G-code</a> -- though the list is too big to be convenient for finding a code if you're not already sure what it's called... :(</p>
158
<p>Right now I'm trying to add a button to a webpage that when pressed will start playing a .wav file by dynamically adding an embed tag to the DOM. The text switches to "Stop" while the sound plays, and I'd like to be able to switch it back automatically to "Play" once the file has finished playing.</p> <p>How would I be able to execute some Javascript automatically when the file is finished?</p> <p>Thanks.</p>
<p>I would wrap the sound in a very simple flash movie, and use actionscript to trigger a javascript function at the end. </p> <p>Here is a list of open-source flash ide : <a href="http://osflash.org/open_source_flash_projects" rel="nofollow noreferrer">http://osflash.org/open_source_flash_projects</a></p> <p>(That's how google did it in gmail)</p>
<p>If you are embedding a player to play the file (as opposed to just allowing the browser to try to figure what to use on its own (QT, WMP etc.)) then the player should have its own events you can hook into. That depends on the player you use.</p>
42,328
<p>When downloading both Firefox and Chrome, I've noticed that the default version I got was in my native tongue of Hebrew. I personally don't like my applications in Hebrew, since I'm used to the English UI conventions embedded in me since long ago by:</p> <ol> <li><strong>The lack of choice:</strong> Most programs don't offer interfaces in multiple languages and when they do, those languages are usually English and the developer's native tongue.</li> <li><strong>Programming languages</strong> which are almost completely bound to the English language.</li> </ol> <p>My question then is this:</p> <ol> <li>If you translate your applications, would you limit the UI to the user's native tongue or give them the choice by enabling more than one language pack by default?</li> <li>Which language would your application default to (which is interesting mostly if you only install one language pack with your application)?</li> </ol> <p>And also generally I'd like to know how much value do you put into translating your applications on a whole.</p>
<p>I've helped develop an application that was used by Dutch, English, Spanish and Portuguese speaking users. Because the application installed from CD we just added all the language packs. Mostly because it saved us a lot of work not having to maintain 4 different versions.</p> <p>If your application distributed from a website and you have to support more than only 4 languages I can imagine you don't want to let everyone download every language pack. But only distributing the native languages of people downloading the application seems a bit restrictive. Most people I know actually like their software in english. So at least adding the english language to all the versions makes sense.</p>
<p>I've never written an application for use by a large number of people, and never for anyone that didn't use English as their language, but if I did, I would probably take a route that installs all available language packs at install (unless the user did a custom install, where I would allow them to choose language packs) and then switch between languages as an option inside the program. If I had to only choose one language, I would choose English if I was doing all of the work, or the native language of the users if I had a translator.</p>
8,419
<p>I am trying to programatically set the dpi metadata of an jpeg image in Java. The source of the image is a scanner, so I get the horizontal/vertical resolution from TWAIN, along with the image raw data. I'd like to save this info for better print results.</p> <p>Here's the code I have so far. It saves the raw image (byteArray) to a JPEG file, but it ignores the X/Ydensity information I specify via IIOMetadata. Any advice what I'm doing wrong? </p> <p>Any other solution (third-party library, etc) would be welcome too. </p> <pre><code>import java.awt.image.BufferedImage; import java.awt.image.WritableRaster; import java.io.File; import javax.imageio.IIOImage; import javax.imageio.ImageIO; import javax.imageio.ImageTypeSpecifier; import javax.imageio.metadata.IIOMetadata; import javax.imageio.plugins.jpeg.JPEGImageWriteParam; import javax.imageio.stream.ImageOutputStream import org.w3c.dom.Element; import com.sun.imageio.plugins.jpeg.JPEGImageWriter; public boolean saveJpeg(int[] byteArray, int width, int height, int dpi, String file) { BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); WritableRaster wr = bufferedImage.getRaster(); wr.setPixels(0, 0, width, height, byteArray); try { // Image writer JPEGImageWriter imageWriter = (JPEGImageWriter) ImageIO.getImageWritersBySuffix("jpeg").next(); ImageOutputStream ios = ImageIO.createImageOutputStream(new File(file)); imageWriter.setOutput(ios); // Compression JPEGImageWriteParam jpegParams = (JPEGImageWriteParam) imageWriter.getDefaultWriteParam(); jpegParams.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT); jpegParams.setCompressionQuality(0.85f); // Metadata (dpi) IIOMetadata data = imageWriter.getDefaultImageMetadata(new ImageTypeSpecifier(bufferedImage), jpegParams); Element tree = (Element)data.getAsTree("javax_imageio_jpeg_image_1.0"); Element jfif = (Element)tree.getElementsByTagName("app0JFIF").item(0); jfif.setAttribute("Xdensity", Integer.toString(dpi)); jfif.setAttribute("Ydensity", Integer.toString(dpi)); jfif.setAttribute("resUnits", "1"); // density is dots per inch // Write and clean up imageWriter.write(data, new IIOImage(bufferedImage, null, null), jpegParams); ios.close(); imageWriter.dispose(); } catch (Exception e) { return false; } return true; } </code></pre> <p>Thanks!</p>
<p>Some issues that were not considered here:</p> <ol> <li><p>The tree is not directly mapped to the IOMetaData. To apply data from tree, add following call after setting the densities and raster parameters:</p> <pre><code>data.setFromTree("javax_imageio_jpeg_image_1.0", tree); </code></pre></li> <li><p>don't use the meta data as first parameter in the write call. See <code>JPEGImageWriter#write(IIOMetaData, IIOImage, ImageWriteParam)</code>. If streamMetaData is not NULL, a warning (WARNING_STREAM_METADATA_IGNORED) will be generated.</p></li> <li><p>set the meta data as <code>IOMetadata</code> of the <code>IOImage</code>. These meta data are used by JPEGImageWriter. The correct write call then is</p> <pre><code>imageWriter.write(null, new IIOImage(F_scaledImg, null, data), jpegParams); </code></pre></li> </ol>
<p>I would seem this could be a bug. </p> <p>I found this post <a href="http://www.velocityreviews.com/forums/t360709-imageio-iiometadatasetfromtree-cripples-data.html" rel="nofollow noreferrer">from a few google searches</a></p> <p>Apparently there are alot more that point to a bug as well.</p> <p>The post above talks about using JMagick as a third party work around. </p>
28,905
<p>I have a record set that includes a date field, and want to determine how many unique dates are represented in the record set.</p> <p>Something like:</p> <pre><code>Record.find(:all).date.unique.count </code></pre> <p>but of course, that doesn't seem to work.</p>
<p>What you're going for is the following SQL:</p> <pre><code>SELECT COUNT(DISTINCT date) FROM records </code></pre> <p>ActiveRecord has this built in:</p> <pre><code>Record.count('date', :distinct =&gt; true) </code></pre>
<p>Also, make sure you have an index on the field in your db, or else that query will quickly become sloooow.</p> <p>(It's much better to do this in SQL, otherwise you pull the entire db table into memory just to answer the count.)</p>
5,722
<p>Can I use a query in MSSQL to get the .mdf and .ldf filename/location for a specific database?</p>
<p>SELECT * FROM <a href="http://msdn.microsoft.com/en-us/library/ms174397(SQL.90).aspx" rel="noreferrer">sys.database_files</a> (SQL 2005+)</p> <p>SELECT * FROM dbo.sysfiles (SQL 2000)</p>
<pre><code>SELECT * FROM sys.master_files </code></pre> <p>...will give you a basic view of where your database lives. It might not cope too well with filegroups, etc.</p>
46,085
<p>I have a Monoprice architect which is a barebones clone of the FlashForge Creator Pro, or Replicator 1 Dual. I have upgraded the power supply and added a heated bed and, after getting fed up with MakerBot software, I've started using Cura to slice then post process with GPX.</p> <p>I did a lot of searching and finally found someone who posted their start and end G-code for this particular printer. The only catch is that his code only works on version 15.04.</p> <p>Don't get me wrong, 15.04 is a huge upgrade compared to MakerWare. But, I would really like to start using a newer version like 2.5 or anything relatively new.</p> <p>Here is the start code I found. I have tried it in 2.5 with error in post processing. Any help is appreciated!!</p> <pre><code>; -- START GCODE -- M136 ; start build M73 P0 G90 ; absolute coordinates ; ; set temperatures and assert Vref M140 S{print_bed_temperature} M104 S{print_temperature} T0 G130 X118 Y118 A118 B118 ; set stepper motor Vref to defaults ; let the Z stepper vref stay at eeprom level (probably 40) ; ; home and recall eeprom home position T0 ; home on the right nozzle G28 X Y Z ; home all axes at homing speed G92 X0 Y0 Z0 A0 B0 ; set all coords to 0 for now G1 Z5 F500 ; move Z 5mm away so we can carefully hit the limit switch G161 Z F100 ; home Z slowly M132 X Y Z ; recall stored home offsets for XYZ axes ; ; wait for heat up G1 X110 Y-72 Z30 F3300 ; move to waiting position M116 ; wait for temps ; ; purge and wipe G92 E0 ; set current extruder position as 0 so that E15 below makes sense G1 X110 Y-70 Z0.2 F2400.0 ; move to just on the bed G1 X110 Y70 E15 F1200.000 ; extrude a line of filament along the right edge of the bed G92 E0 ; set E to 0 again because the slicer's next extrusion is relative to this 0 ; ; Sliced at: {day} {date} {time} ; Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density} ; Print time: {print_time} ; Filament used: {filament_amount}m {filament_weight}g ; Filament cost: {filament_cost} ; -- end of START GCODE -- </code></pre>
<p>Yes, with the proper equipment.</p> <p>Printing wax filament (at 51 seconds): <a href="https://youtu.be/tibkVZB_n9c?t=51s" rel="noreferrer">https://youtu.be/tibkVZB_n9c?t=51s</a></p> <p>There are also options for melting wax, filling a heated reservoir head, and printing with that. I recommend doing this with a cold ambient temperature, so that the wax solidifies quickly. There's no point in just printing a puddle. :)</p>
<p>Just make a silicone mold of any of your prints and pour you wax in the silicone,you silicone putty is pretty cheap so is wax ,no need to break the bank as printers have become less expensive and can do a pretty good job </p>
631
<p>I had an unusual problem yesterday where I was suddenly unable to insert records into a table with an identity column.</p> <p>A simple insert like this: INSERT INTO MyTable (Column1, Column2) VALUES ('text', 236764)</p> <p>Started throwing a primary key constraint violation. </p> <p>I ran DBCC CHECKIDENT on the table, and realized that SQL Server had stopped updating the last used value, so that when it was inserting it was incrementing using the old value and the new identity value usually already existed in the table, hence the violation errors.</p> <p>Resolving the problem wasn't an issue, I just reseeded the table for the next highest sequence number, but I've never seen this happen before!</p> <p>Does anyone have any idea what might cause SQL Server to stop updating identity properties, and where I might look for evidence? There is no replication or any triggers involved, it's just a plain old table.</p> <p>EDIT: SQL Log Rescue would have been ideal, but it only works on SQL Server 2000. Is there a similar tool out there for SQL 2005 logs?</p>
<p>Taken from its home page:</p> <p>The <a href="http://trac-hacks.org/wiki/AccountManagerPlugin" rel="noreferrer">Account Manager plugin</a> offers several features for managing user accounts: </p> <ul> <li>allow users to register new accounts </li> <li>login via an HTML form instead of using HTTP authentication </li> <li>allow existing users to change their passwords or delete their accounts</li> </ul>
<p>I second antispam on the Account Manager plugin. Also, if your trac needs to be web facing, you may be interested in the auth required plugin. Just be aware that it hasn't been upgraded for 0.11 and I suspect that there are some minor compatibility problems. It does do the job though.</p>
29,554
<p>I am a newcomer to ASP, and would like to experiment with it by writing a website for a club at my school using .net 2008 and the mySql database available from the school's apache server. What is the best way to set this up, since I see a lot of options to connect the web app to SQL Server or Oracle databases, but I'm nervous that it won't work correctly with mySql.</p> <p>Also, will I still be able to use LINQ queries?</p>
<p>Get a hold of the <a href="http://dev.mysql.com/downloads/connector/net/5.2.html" rel="noreferrer">MySQL Connector</a> for ASP.NET and start coding as usual for MySQL. the connector gives you all the advantages of data adapters, data readers, etc. in the typical ADO.NET structure you are used to for SQL or Oracle. That way if you do swap things out on the back end in the future, you won't have to worry about swapping out all your connect/query code.</p>
<p>Check out this url: <a href="http://dev.mysql.com/tech-resources/articles/dotnet/index.html" rel="nofollow noreferrer">http://dev.mysql.com/tech-resources/articles/dotnet/index.html</a></p>
36,613
<p>We're using Infragistics grid (most probably, we'll have 8.2 version at the end) and we want to configure row/cells appearances "on-demand" in order to be able to provide sort of "dynamic appearance".</p> <p>For example, I want some cell to be red or green, depending on its value. We might want to tweak other characteristics as well (font, size, image, etc).</p> <p>A perfect place to do it would be some event, that happen before a cell gets repainted... But it seems there is no such event in Infragistics...</p> <p>Or am I wrong? Any help?</p> <p><strong>Clarification:</strong> I'm talking about WinForms Infragistics UltraGrid</p>
<p>I had to do exactly this with the IG WebGrid a few years back, and it was ... shall we say ... painful. However, the WebGrid had the advantage of a single render point -- once the HTML was emitted, we were set!</p> <p>For dealing with this in WinGrid, I tried a variety of different events, both on the grid and the datasource, and met with abject failure every step of the way. The only event I got to work was <code>Paint</code>, which will likely create a performance issue.</p> <p>For <code>Paint</code>, here's what I hacked together. I'm not proud of this code, and I likely wouldn't put it in production, but here it is anyway (C#):</p> <pre><code>private void UltraGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { foreach (UltraGridRow r in UltraGrid1.Rows) { foreach (UltraGridCell c in r.Cells) { if (c.Text == "foo") c.Appearance.BackColor = Color.Green; } } } </code></pre> <p>and VB:</p> <pre><code>Private Sub UltraGrid1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles UltraGrid1.Paint For Each r As UltraGridRow In UltraGrid1.Rows For Each c As UltraGridCell In r.Cells If c.Text = "foo" Then c.Appearance.BackColor = Color.Green End If Next Next End Sub </code></pre>
<p>There is an event. I don't remember exactly what it's called, but it's got to be something like 'DataRowBound' or 'ItemDataBinding', etc..</p> <p>Also, <a href="http://weblogs.asp.net/tonylombardo/archive/2008/01/29/demystifying-infragistics-webgrid-databinding.aspx" rel="nofollow noreferrer">this article</a> might help.</p> <p>Not that this has anything to do with your question, but I'd stay away from heavy use of Infragistics controls - they're very heavy and will slow down the page rendering process considerably. Just my $0.02.</p>
36,067
<p>Examples could be Infragistics or DevExpress.</p> <p>But I'm also looking for your opinions on other frameworks. It could even be WPF if that is your favorite.</p>
<p>Infragistics is very good. I think they have a better product for windows than the web. However, I get very upset using their products sometimes. I just want to find some hidden property, and it is impossible to find. They have way to many properties. Sure, you can do anything with their grid, but it should be easier. All of these vendors are leap frogging each other. You really have to compare all of them every year or two. I am currently using Infragistics on most web and windows project. If I could switch today, I would go to DevExpress for Web and Windows. Everything that Mark Miller and the guys at DevExpress produce is beautiful, and thoughtful. On a side point, you should check out CodeRush and Refacter. I may sound like a salesman, but I am not. I just could no longer code without CodeRush. It would feel like coding with one hand. If you are going to spend $1000 or more on a framework, you should also get CodeRush.</p>
<p>What frameworks are you looking for? I currently use Janus Grids for grids on the winform side, but DevExpress has an awesome web grid that is amazing.</p>
21,726
<p>I am trying to capture output from an install script (that uses scp) and log it. However, I am not getting everything that scp is printing out, namely, the progress bar. </p> <p>screen output:</p> <blockquote> <p>Copying /user2/cdb/builds/tmp/uat/myfiles/* to server /users/myfiles as cdb</p> <p>cdb@server's password: myfile 100% |*****************************| 2503 00:00</p> </blockquote> <p>log output:</p> <blockquote> <p>Copying /user2/cdb/builds/tmp/uat/myfiles/* to server /users/myfiles as cdb</p> </blockquote> <p>I'd really like to know that my file got there. Here's what I am trying now to no avail:</p> <blockquote> <p>myscript.sh 2>&amp;1 | tee mylogfile.log</p> </blockquote> <p>Does anyone have a good way to capture scp output and log it? </p> <p>Thanks.</p>
<p>scp prints its progress bar to the terminal using control codes. It will detect if you redirect output and thus omit the progress bar.</p> <p>You can get around that by tricking scp into thinking it runs in a terminal using the "script" command which is installed on most distros by default:</p> <pre><code>script -q -c "scp server:/file /tmp/" &gt; /tmp/test.txt </code></pre> <p>The content of test.txt will be:</p> <pre><code>file 0% 0 0.0KB/s --:-- ETA file 18% 11MB 11.2MB/s 00:04 ETA file 36% 22MB 11.2MB/s 00:03 ETA file 54% 34MB 11.2MB/s 00:02 ETA file 73% 45MB 11.2MB/s 00:01 ETA file 91% 56MB 11.2MB/s 00:00 ETA file 100% 61MB 10.2MB/s 00:06 </code></pre> <p>...which is probably what you want.</p> <p>I stumbled over this problem while redirecting the output of an interactive script into a log file. Not having the results in the log wasn't a problem as you can always evaluate exit codes. But I really wanted the interactive user to see the progress bar. This answer solves both problems.</p>
<p>Try: </p> <pre><code>scp server:/file /tmp/ &gt; /dev/tty </code></pre>
24,751
<p>I have a problem with a ClickOnce deployment of a <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel="nofollow noreferrer">Windows Forms</a> application. When I built the new setup, and tried to export it overwriting as usual the previous setup, Visual Studio came up stating that my certificate is expired.</p> <p>This behaviour is described in <em><a href="http://support.microsoft.com/?scid=kb%3Ben-us%3B925521&amp;x=6&amp;y=10" rel="nofollow noreferrer">You receive an error message when you try to update a Visual Studio 2005 ClickOnce application after the certificate that was used to sign the installation expires</a></em> and there is a workaround in <em><a href="http://may.be/renewcert/" rel="nofollow noreferrer">RenewCert - Working Version</a></em>. But these solutions are not applicable in my situation.</p> <p>Another workaround involves taking back the system date of the deployment server to a date before the certificate expiry date (during the deployment operations) - but I see this as a very "last chance".</p> <p>How can I fix this problem? Is there another workaround I can try?</p>
<p>I found a blog entry, <em><a href="http://www.jamesharte.com/blog/?p=11" rel="nofollow noreferrer">ClickOnce and Expiring Code Signing Certificates</a></em> by James Harte, that describes a method to have your application remove itself and launch the new ClickOnce install. It worked for me.</p>
<p>I ran into this problem almost two years ago. There is really no good workaround if RenewCert won't work for you. I even emailed the ClickOnce authority, Brian Noyes, and got confirmation that there were no good workarounds.</p> <p>We ended up buying a 3 year cert and telling our users to uninstall. However, if I remember correctly, the users only got error messages when launching the app from the start menu. If they went to the web page, it installed the app and ran fine. Of course the client then had 2 versions of the app on their machines :). I can't remember what happened to the start menu shortcuts in that scenario.</p>
14,745
<p>Is it possible to change the <code>RowCount</code> of a <code>DataGrid</code> in flash after it has been created on the stage?</p> <p>I am loading an XML file externally that contains the number of rows the <code>DataGrid</code> should have, but the problem is that because this file is not loaded at runtime, it just picks the default 3 items. Maybe I have to reload the <code>DataGrid</code> on the stage, or loop until it is defined.</p> <p>Does anyone have experience with this?</p>
<p>RichTextBox has an AppendText method that is fast. And it can handle large text well.<br> I believe it is the best for what you need.</p>
<p>set the selectedindex of the listbox to the last element to make it scroll to the bottom</p> <p>also, limit the number of items in the listbox to something reasonable (delete from the top, keep the later items) so you don't chew up all of your memory</p>
31,443
<p>I use Visual C++ 2008 in Visual Studio 2008. I frequently use the following command to diff an open file against its most recent checked-in version:</p> <pre><code>File | Source Control | Compare... </code></pre> <p>I can also do the same thing by clicking on an icon in the Source Control toolbar.</p> <p>I'm not certain, but I believe this command is the same for any source control plugin (I happen to use the Perforce plugin.)</p> <p>I'd like to assign a keyboard shortcut to execute this command but I can't seem to find it listed anywhere in dialog where such assignments are normally made:</p> <pre><code>Tools | Customize... | Commands </code></pre> <p>Did I just not see the command in the customize dialog? Is there another method to assign such a keyboard shortcut?</p>
<p>Tools -> Options -> Keyboard -> Commands Containing "Compare"</p>
<p>Nescio's <a href="https://stackoverflow.com/questions/188225/how-to-assign-keyboard-shortcut-to-source-control-commands-in-visual-studio-2008#188256">answer</a> is on the money. Here's a little more info:</p> <ul> <li>The shortcut assignment can be made at <code>Tools | Options | Environment | Keyboard</code></li> <li>The command is called <code>File.Compare</code></li> </ul>
22,814
<p>During software development, there may be bugs in the codebase which are known issues. These bugs will cause the regression/unit tests to fail, if the tests have been written well.</p> <p>There is constant debate in our teams about how failing tests should be managed:</p> <ol> <li><p>Comment out failing test cases with a REVISIT or TODO comment.</p> <ul> <li><strong>Advantage</strong>: We will always know when a <em>new</em> defect has been introduced, and not one we are already aware of.</li> <li><strong>Disadvantage</strong>: May forget to REVISIT the commented-out test case, meaning that the defect could slip through the cracks.</li> </ul></li> <li><p>Leave the test cases failing.</p> <ul> <li><strong>Advantage</strong>: Will not forget to fix the defects, as the script failures will constantly reminding you that a defect is present.</li> <li><strong>Disadvantage</strong>: Difficult to detect when a <em>new</em> defect is introduced, due to failure noise.</li> </ul></li> </ol> <p>I'd like to explore what the best practices are in this regard. Personally, I think a tri-state solution is the best for determining whether a script is passing. For example when you run a script, you could see the following:</p> <ul> <li>Percentage passed: 75%</li> <li>Percentage failed (expected): 20%</li> <li>Percentage failed (unexpected): 5%</li> </ul> <p>You would basically mark any test cases which you <em>expect</em> to fail (due to some defect) with some metadata. This ensures you still see the failure result at the end of the test, but immediately know if there is a <em>new</em> failure which you weren't expecting. This appears to take the best parts of the 2 proposals above.</p> <p>Does anyone have any best practices for managing this?</p>
<p>I would leave your test cases in. In my experience, commenting out code with something like</p> <pre><code>// TODO: fix test case </code></pre> <p>is akin to doing:</p> <pre><code>// HAHA: you'll never revisit me </code></pre> <p>In all seriousness, as you get closer to shipping, the desire to revisit TODO's in code tends to fade, especially with things like unit tests because you are concentrating on fixing other parts of the code.</p> <p>Leave the tests in perhaps with your "tri-state" solution. Howeveer, I would strongly encourage fixing those cases ASAP. My problem with constant reminders is that after people see them, they tend to gloss over them and say "oh yeah, we get those errors all the time..."</p> <p>Case in point -- in some of our code, we have introduced the idea of "skippable asserts" -- asserts which are there to let you know there is a problem, but allow our testers to move past them on into the rest of the code. We've come to find out that QA started saying things like "oh yeah, we get that assert all the time and we were told it was skippable" and bugs didn't get reported.</p> <p>I guess what I'm suggesting is that there is another alternative, which is to fix the bugs that your test cases find immediately. There may be practical reasons not to do so, but getting in that habit now could be more beneficial in the long run.</p>
<p>I think you need a TODO watcher that produces the "TODO" comments from the code base. The TODO <em>is</em> your test metadata. It's one line in front of the known failure message and very easy to correlate.</p> <p>TODO's are good. Use them. Actively management them by actually putting them into the backlog on a regular basis.</p>
18,860
<p>I am working on a project converting a "spreadsheet application" to a database solution. A macro was written that takes screen shots of each page and pastes them into a PowerPoint presentation. Because of the nice formatting options in Excel, the presentation looks very pretty.</p> <p>The problem I'm having is that I haven't ever seen an Access report that would be pretty enough to display to upper management. I think the output still has to be a PowerPoint presentation. It needs to look as close as possible to the original output.</p> <p>I am currently trying to write some code to use a .pot (presentation template) and fill in the data programmatically. Putting the data into a PowerPoint table has been tricky because the tables are not easy to manipulate. For example, if a particular description is too long, I need to break into the next cell down (word-wrap isn't allowed because I can only have <em>n</em> lines per page).</p> <p>Is there a way to make an Access report pretty, am I headed down the right path, or should I just try to programmatically fill in the Excel spreadsheet and use the code that already exists there to produce the presentation? (I'd still need to figure out how to know when to break a line when using a non-monospaced font, as the users are currently doing that manually when they enter the data in the spreadsheet)</p> <p>Jason Z: If I set it to wrap, and I already have <em>n</em> lines, it would make <em>n</em>+1 or 2 lines on the slide, which is unacceptable.</p> <p>Dennis: That article looks very good, I should be able to glean something from it. Thanks!</p>
<p>Access has the capability to create downright beautiful reports. The problem is that it can't make a spreadsheet look better than Excel. You have to know when to use each tool.</p> <p>Use Excel when you have spreadsheet-like formatting, need a lot of boxes and lines, or want to draw charts.</p> <p>Use Access when you will output a report as a PDF. It's very useful for one-record-per-page detail reports, formatting where you need to position things very precisely, and where you need to embed subreports with related or unrelated data. </p> <p>Think about the reports that would be nasty in Excel because you'd have to merge cells all over the place and do funny things with the placement and the layout would never work. That's where Access shines.</p>
<p>I personally would not try to re-invent the wheel here. If you already have an Excel sheet that has the formatting you want, just export the data from Access into Excel for the report. Now, if you didn't have the original Excel sheet to begin with, that would be a completely different story.</p> <p>As for breaking lines with non-monospaced fonts, have you tried setting the cell format to wrap?</p>
6,532
<p>We have a web application that can be deployed on many application servers, including Oracle 10g. On that platform, however, we are having classpath issues. The webapp uses JAXB 2, but Oracle 10g ships with JAXB 1, and this was causing errors. To get around those we configured Oracle to prefer classes in our webapp, but now we are getting the above error when attempting to instantiate a JAXB context.</p> <p>Looking up the "loader constraints violated" exception - it seems to be thrown when a class that has been loaded with one classloader attempts to access something that is package private in the same package but loaded by a different classloader. I have tried removing any jars in our webapp that include javax.xml.namespace.QName, and have verified that it is the instance included in Oracle that is being picked up, but the error still occurs. Any ideas?</p> <p>(This is a follow-on from an <a href="https://stackoverflow.com/questions/132409/jaxb-2-in-an-oracle-10g-webapp">earlier question</a> regarding 10g and JAXB 2.)</p>
<p>This class is in half the WS Java libraries out there. It's really easy to load it from multiple classloaders and later compare them, causing a LinkageError.</p> <p>One effective (but sledgehammer) technique to tracking this down is to modify Classloader from the Java source to dump which jar this particular class is loading from at load time, then prepend your bootclasspath with your modified version:</p> <p>-Xbootclasspath/p:/path/to/hackedBin</p>
<p>May be it's completely unrelated, but I remember a problem Weblogic had with the very same class. The reason for the problem was the changed serial id of the class (Sun changed it accidentally). The workaround was to provide a -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0 to the JVM.</p> <p>Could it be the same problem, just misreported? Try it.</p> <p>See here: <a href="http://forums.bea.com/thread.jspa?threadID=600014563" rel="nofollow noreferrer">http://forums.bea.com/thread.jspa?threadID=600014563</a> </p>
16,218
<p>I am trying to manipulate a string using Jython, I have included below an example string:</p> <p>This would be a title for a website :: SiteName<br /> This would be a title for a website :: SiteName :: SiteName</p> <p>How to remove all instances of ":: Sitename" or ":: SiteName :: SiteName"?</p>
<p>No different from regular Python:</p> <pre><code>&gt;&gt;&gt; str="This would be a title for a website :: SiteName" &gt;&gt;&gt; str.replace(":: SiteName","") 'This would be a title for a website ' &gt;&gt;&gt; str="This would be a title for a website :: SiteName :: SiteName" &gt;&gt;&gt; str.replace(":: SiteName","") 'This would be a title for a website ' </code></pre>
<p>For such simple example it is unnecessary but in general you could use <code>re</code> module.</p> <pre><code>import re sitename = "sitename" #NOTE: case-insensitive for s in ("This would be a title for a website :: SiteName :: SiteName", "This would be a title for a website :: SiteName"): print(re.sub(r"(?i)\s*::\s*%s\s*" % sitename, "", s)) </code></pre>
28,486
<p>I am trying to figure out how to add a custom control to the iPhone MoviePlayer. For an example of what I am trying to do see the following image.</p> <p><img src="https://i.stack.imgur.com/Zt5MG.jpg" alt="alt text"></p> <p>I am trying to add something like the controls on the right and left of the basic movie controls.</p> <p>I had done this in the Open SDK by adding a subclass to the playerview, but now in the official SDK and Apple moving to MPMoviePlayerController I am not sure how to do it.</p> <p>Also with my old 1.x firmware way it required me to capture touch events and hide/show the control myself. I am hoping there is a way that would do this with the standard controls, but if not, that is fine.</p> <p>Thanks in advance.</p>
<p>I found the BEST way to do this!</p> <p>You create your movie player like normal and then do the following:</p> <pre><code>id vvController = [theMovie videoViewController]; [[vvController _overlayView] addSubview:mainView]; </code></pre> <p>Where 'mainView' is your custom overlay. Doing this makes it so your custom overlay will show and hide with the normal overlays as they are now one in the same!</p> <p><em>Please note that this is still using the standard frameworks, but it is undocumented in the frameworks. So it should be 100% appstore safe, but "could" change without notice from Apple in later frameworks.</em></p>
<p>I recommend VideoPlayerKit. Supports streaming, fullscreen, AirPlay. </p> <p><a href="https://github.com/ign/VideoPlayerKit" rel="nofollow">https://github.com/ign/VideoPlayerKit</a></p>
23,116
<p>I usually create my SQL tables and stored procedures by writing a script inside Visual Studio. This works really well for me except for one simple annoyance: VS puts blue boxes around all the SQL queries and data-manipulation commands. The purpose of these boxes is to draw undue attention to the fact that VS thinks the query can be edited in “Query Builder.”</p> <p>I don’t want to use Query Builder. I just want a nice, clean script that reflects my fantastic vision of what the DB engine should do. Blast it, Jim, I’m a programmer not a Microsoft Access hobbyist!</p> <p>I do, however, like the syntax highlighting and source-control integration that VS provides.</p> <p>So my question is this: How do I turn off the annoying blue boxes?</p>
<p>Open Visual Studio Tools --> options --> Database Tools --> General. Uncheck "Enable DML Markers"</p>
<p>Set the color of the SQL query outline to the same color as the background.</p>
33,933
<p>I am digging into LINQ--trying to understand basic models (it seems pretty cool to me). The code below is the code to perform before committing an update. </p> <pre><code> Linq01.Account acc = context.Accounts.Single( pc =&gt; pc.AccountID == AccountID ); acc.Name = textboxAccountNameRead.Text.Trim(); context.SubmitChanges(); </code></pre> <p>So far, so good. But what do you do if the Single() method failed--if the account ID wasn't found? </p> <p>Thank you!</p>
<p>You should use <code>SingleOrDefault</code>, if the query does not return a value you can check it against null:</p> <pre><code>var acc = context.Accounts.SingleOrDefault(pc =&gt; pc.AccountId == AccountId); if(acc != null) { acc.Name = textboxAccountNameRead.Text.Trim(); context.SubmitChanges(); } </code></pre>
<p>To add to Slace's answer, if you call Single and then account ID wasn't found, it will throw an exception. In <em>some</em> cases that's more appropriate than returning null and explicitly handling it.</p>
29,983
<p>I have a number of child tables that have a foreign key to a parent table.</p> <p>How do I add an entry in the parent table and get the primary key of that entry, so that I can then enter rows in the child tables that point to the entry in the parent table?</p> <p>I'm doing this in a MS Access Database from a C# application.</p>
<p>Microsoft Access 2000 or later does support the @@IDENTITY property to retrieve the value of an Autonumber field after an INSERT. (<a href="http://msdn.microsoft.com/en-us/library/ks9f57t0(VS.71).aspx" rel="nofollow noreferrer">msdn</a>)</p> <p>Edit: <a href="http://msdn.microsoft.com/en-us/library/ks9f57t0.aspx" rel="nofollow noreferrer">This</a> is the link to a similar article for .NET 3.5</p>
<p>Should be able to SELECT @@IDENTITY even though you will have to use a second query to do so. I don't think MS Access will allow it to be combined into one query.</p>
21,746
<p>This is a real issue that applies on tagging items in general (and yes, this applies to StackOverflow too, and no, it is not a question about StackOverflow).</p> <p>The whole tagging issue helps cluster similar items, whatever items they may be (jokes, blog posts, so questions etc). However, there (usually but not strictly) is a hierarchy of tags, meaning that some tags <em>imply</em> other tags too. To use a familiar example, the "c#" so tag implies also ".net"; another example, in a jokes database, a "blondes" tag implies the "derisive" tag, similarly to "irish" or "belge" or "canadian" etc depending on the joke's country origin.</p> <p>How have you handled this, if you have, in your projects? I will supply an answer describing two different methods I have used in two separate cases (actually, the same mechanism but implemented in two different environments), but I am also interested not only on similar mechanisms, but also on your opinion on the hierarchy issue.</p>
<p>This is a tough question. The two extremes are an ontology (everything is hierarchical) and a folksonomy (tags have no hierarchy). I have <a href="http://wiki.answers.com/Q/What_is_the_best_way_to_integrate_Taxonomy_with_Folksonomy_with_respect_to_creating_a_database_of_skills_that_can_be_tagged_but_also_searched_for_by_classified_criteria" rel="noreferrer">answered this on WikiAnswers</a>, with a reference to Clay Shirky's "Ontology is Overrated" article which claims you should set no hierarchy.</p>
<p>The mechanism I have implemented was to not use the tags given themselves, but an indirect lookup table (not strictly DBMS terms) which links a tag to many implied tags (obviously, a tag is linked with itself for this to work).</p> <p>In a python project, the lookup table is a dictionary keyed on tags, with values sets of tags (where tags are plain strings).</p> <p>In a database project (indifferent which RDBMS engine it was), there were the following tables:</p> <pre><code>[Tags] tagID integer primary key tagName text [TagRelations] tagID integer # first part of two-field key tagID_parent integer # second part of key trlValue float </code></pre> <p>where the trlValue was a value in the (0, 1] space, used to give a gravity for the each linked tag; a self-to-self tag relation always carries 1.0 in the trlValue, while the rest are algorithmically calculated (it's not important how exactly). Think the example jokes database I gave; a ['blonde', 'derisive', 0.5] record would correlate to a ['pondian', 'derisive', 0.5] and therefore suggest all derisive jokes given another.</p>
14,669
<p>This might be a similar problem to my earlier two questions - see <a href="https://stackoverflow.com/questions/169934/any-scrubyt-command-that-clicks-a-link-returns-a-403-forbidden-error">here</a> and <a href="https://stackoverflow.com/questions/168868/how-to-get-next-page-link-with-scrubyt">here</a> but I'm trying to use the _detail command to automatically click the link so I can scrape the details page for each individual event.</p> <p>The code I'm using is:</p> <pre><code>require 'rubygems' require 'scrubyt' nuffield_data = Scrubyt::Extractor.define do fetch 'http://www.nuffieldtheatre.co.uk/cn/events/event_listings.php' event do title 'The Coast of Mayo' link_url event_detail do dates "1-4 October" times "7:30pm" end end next_page "Next Page", :limit =&gt; 20 end nuffield_data.to_xml.write($stdout,1) </code></pre> <p>Is there any way to print out the URL that using the event_detail is trying to access? The error doesn't seem to give me the URL that gave the 404.</p> <p><strong>Update:</strong> I think the link may be a relative link - could this be causing problems? Any ideas how to deal with that?</p>
<p>I had the same issue with relative links and fixed it like this... you have to set the :resolve param to the correct base url</p> <pre><code> event do title 'The Coast of Mayo' link_url event_detail :resolve =&gt; 'http://www.nuffieldtheatre.co.uk/cn/events' do dates "1-4 October" times "7:30pm" end end </code></pre>
<p>Sorry I have no idea why this would be nil - every time I have run this it returns a url - the method self.fetch requires a URL which you should be able to access as the local variable doc_url. If this returns nil also may you should post the code where you have included the debugger call.</p>
20,559
<p>I need to serve up a few .asp pages from within my ASP.NET site.</p> <p>This ASP.NET site has a handler that allows us to serve up pages out of the database instead of finding them on disk (where the .asp files are located).</p> <p>The problem appears to be that the .NET isapi (C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll) is catching my request... at that point, it is going to the database and not finding the file.</p> <p>My question: why is ASP.NET catching my request? I would think it should come in and use the proper extension mapping for .asp (C:\WINDOWS\system32\inetsrv\asp.dll). </p> <p>Is there a way to tell ASP.NET to leave the .asp files alone?</p>
<p>one alternative is to set up a virtual directory which only can execute .asp and without asp.net support.</p>
<p>It sounds like you have a wild card script mapping in your application configuration forwarding all requests into the aspnet_isapi.dll. Is the a .asp mapping to asp.dll?</p>
47,372
<p>With a view to avoiding the construction of further barriers to migration whilst enhancing an existing vb6 program. Is there a way to achieve the same functionality as control arrays in vb6 without using them?</p>
<p>In .NET you have a tag property. You can also have the same delegate handle events raised by multiple controls. Set the Tag property of the new control to the Index. </p> <pre><code>Private Sub MyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click,Button2.Click Dim Btn As Button = CType(sender, Button) Dim Index As Integer = CType(Btn.Tag, Integer) ' Do whatever you were doing in VB6 with the Index property End Sub </code></pre> <p>You also should look at the classes that inherit from BaseControlArray in the VB6.Compatibility which automates some of the work. I find the use of Tag to be less error prone in the conversion process than relying on the control name. However don't thank this as an absolute. You will have to decide whether the control name approach is best or the tag as index approach.</p> <p>In either case you can easily setup .NET to funnel the events raised by multiple controls into one handler. </p>
<p>Well, you could always create your own array of controls in code :) Perhaps a better container, though, is a Collection or Dictionary object. Depending on what you want to do, you could perhaps create a wrapper class for the control with a custom collection class... but creating an object model is far nicer using generics in .NET so probably best to keep it simple in VB6 for now.</p> <p>VBA Userforms lack support for control arrays, so why not Google for suggestions on how to mimic control arrays with VBA, Userforms, Excel, etc.</p> <p>BTW have you tried migrating control arrays from VB6 to VB.NET? Just a guess but considering they are commonly used in VB I imagine they are handled quite well.</p>
22,967
<p>I would like to know and understand the steps involved in fetching mail from pop3 server using plain c language </p>
<p>Steps:</p> <ol> <li>Connect to the server's port (usually 995) using <a href="http://www.openssl.org/docs/ssl/ssl.html" rel="nofollow noreferrer">OpenSSL</a></li> <li>Verify the certificate</li> <li>Send regular pop3 commands over the SSL socket you just opened. (LIST, RETR and so on)</li> <li>Retrieve the responses</li> <li>Close the socket</li> </ol> <p>Or use a library that does all of the above for you</p>
<p>Use one of the thousands of libraries that already exist such as <a href="http://brouits.free.fr/libspopc/" rel="nofollow noreferrer">libspopc</a>.</p>
16,660
<p>We have a large MS Access project that requires GUI functionality that is difficult / impossible to do in the VBA / access forms environment. </p> <p>Over time, we wish to re-write / migrate to a managed C# environment with WPF as the presentation layer.</p> <p>The only practical way for us to do this is over a longer period of time - converting some of the VBA forms first (that would give the best productivity benefit), and then over the course of 12-24 months convert the entire system.</p> <p>What do you believe is the best approach. Can MS Access host the WPF forms as we convert them? </p>
<p>What if you look into Visual Studio Tools for Office (VSTO) ? You can write managed .NET addins for Office in C#, that will integrate as ribbons with office.</p> <p>Now, the problem is that Access add-ins are not supported in VSTO AFAIK. But, take a look <a href="http://blogs.msdn.com/andreww/archive/2008/02/19/vsto-add-ins-for-access.aspx" rel="nofollow noreferrer">here</a>, it seems to be not that impossible.</p> <p>So, if you happen to be lucky, you could </p> <ul> <li>Write a C# ribbon for Access which would have all the advanced GUI you need</li> <li>Write services in C# that could be accessed from Access to encapsulate important business logic for instance, so that you could gradually move not only GUI, but build proper domain object model in C#.</li> </ul> <p>If you decide to try it out, let me know how it turned out :) Good luck anyway.</p> <p>PS something else which maybe is helpful? <a href="http://msdn.microsoft.com/en-us/office/bb229700.aspx" rel="nofollow noreferrer">Access 2007 Developer Extensions (ADE)</a> </p>
<p>Thank you badbadboy - I will certainly experiment with this (using VSTO).</p> <p>The <a href="http://blogs.msdn.com/andreww/archive/2008/02/19/vsto-add-ins-for-access.aspx" rel="nofollow noreferrer">solution</a> you suggested to allow VSTO to work with ms access, does seem slight hackery - not that I mind this, but I am nervous about using this work-around in production if it isn't solid i.e there would be no support from MS. </p> <p>From <a href="http://blogs.msdn.com/andreww/archive/2007/08/15/wpf-in-vsto.aspx" rel="nofollow noreferrer">what I can see</a> this will allow me to host a <em>winforms</em> control, that in-turn hosts a WPF control.</p> <p>Anybody gone down this path with a production system - any caveats?</p> <p>Note there is a <a href="http://www.codeplex.com/VSTO" rel="nofollow noreferrer">VSTO access project template</a> on codeplex that makes the process a little easier.</p>
40,373
<p>I get the following error when building my Windows Forms solution: </p> <blockquote> <p>"LC.exe" exited with code -1</p> </blockquote> <p>I use two commercial Windows Forms Libraries: Infragistics and the Gantt-Control from plexityhide.com, that's why I have licenses.licx files in my WinForms Projects. We also use Visual Sourcesafe as our Source Control.</p> <p>When the licenses.licx files are in the Projects I cannot build without the above error. However, when I exclude them from my projects the build works fine. But I need the licenses.licx files when I want to work with the commercial controls in the designer.</p> <p>This is a brand new developer machine with Windows XP SP3 (German) and Visual Studio 2005 Team Edition for Software Developers (German) with SP1. </p> <p>It's Windows XP 32-Bit by the way.</p> <p>Any suggestions?</p>
<p>Problem mainly arises due to license file. Exclude the file <code>licenses.licx</code> from your project</p>
<p>There should be a <code>license.licx</code> file in the properties folder when you use commercial components. It is often corrupted. If you clean its contents, the <code>"LC.EXE" exited with code -1</code> disappears.</p>
5,446
<p>I've modified the Agile task template in TFS to include a new 'In Progress' state. When work is started on an item the 'assigned user' will set the task from 'Active' to 'In Progress'. This helps me to know which tasks have been started.</p> <p>I was, however, thinking that I might be able to use this new state to figure out how long things take. Is there a way I could get the difference between the 'State Change Date' for 'In Progess' and 'Closed' states?</p> <p>The out-of-the-box TFS queries seem to be limited.</p>
<p>I don't have access to TFS so I am not sure if this is already built can't confirm, but one option you have is to add two new fields to the workitem, for the start and stop dates. You can have the worflow set those variables when you transition into and outof a state.</p>
<p>I am curious as to the answer as well.</p> <p>One thing to take into account, though, is that if a task runs over a weekend, you would not want those days to be taken into account if you are looking for a measure of "developer days". Taking it a step further, it would be nice to be able to somehow define days that work would not happen on (such as when the office is closed) to get a more accurate reflection of the time spent.</p>
49,978
<p>Does anyone know if the Infragistics UltraGrid control provides functionality similar to that of DataGridView.HitTestInfo?</p>
<p>Check <a href="http://www.abstraction-systems.com/ttf/HTML/TTFactory_TaskBasedTutorials_UltraWinGrid.htm" rel="nofollow noreferrer">this</a> out.</p> <p>They don't convert the coordinates, but they use a special Infragistics grid event (<a href="http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/Infragistics2.Win.v8.2~Infragistics.Win.UltraComponentControlManagerBase~MouseEnterElement_EV.html" rel="nofollow noreferrer">MouseEnterElement</a>) to get the element, which the mouse currently hovers over.</p> <p>Maybe it helps.</p>
<p>There's a <code>.MousePosition</code> property which returns <code>System.Drawing.Point</code> and "Gets the position of the mouse cursor in screen coordinates" but I'm using an older version of their UltraWinGrid (2003).</p> <p>They have a <a href="http://www.infragistics.com/downloads/default.aspx" rel="nofollow noreferrer">free trial download</a>, so you could see if they've added it to their latest and greatest :o)</p>
9,739
<p>Is there any way to use inheritance in database (Specifically in SQL Server 2005)?</p> <p>Suppose I have few field like <strong>CreatedOn</strong>, <strong>CreatedBy</strong> which I want to add on all of my entities. I looking for an alternative way instead of adding these fields to every table.</p>
<p>There is no such thing as inheritance between tables in SQL Server 2005, and as noted by the others, you can get as far as getting help adding the necessary columns to the tables when you create them, but it won't be inheritance as you know it.</p> <p>Think of it more like a template for your source code files.</p> <p>As GateKiller mentions, you can create a table containing the shared data and reference it with a foreign key, but you'll either have to have audit hooks, triggers, or do the update manually.</p> <p>Bottom line: Manual work.</p>
<p>You could create a template in the template pane in Management Studio. And then use that template every time you want to create a new table.</p> <p>Failing that, you could store the CreatedOn and CreatedBy fields in an Audit trail table referencing the original table and id.</p> <p>Failing that, do it manually.</p>
2,764
<p>I am looking for a LaTeX package that does syntax highlighting on code. For example, right now I use the verbatim block to write code:</p> <pre><code>\begin{verbatim} &lt;html&gt; &lt;head&gt; &lt;title&gt;Hello&lt;/title&gt; &lt;/head&gt; &lt;body&gt;Hello&lt;/body&gt; &lt;/html&gt; \end{verbatim} </code></pre> <p>And this works fine to display the code on my document. But, suppose I wanted to highlight the HTML markup the way an IDE would in the output document? <strong>Is there a package that could help?</strong></p> <p>I would like to do the same for various languages such as Java, C#, HTML, CSS and so on.</p>
<p>You can use the <a href="http://www.ctan.org/tex-archive/macros/latex/contrib/listings/" rel="noreferrer">listings</a> package. It supports many different languages and there are lots of options for customising the output.</p> <pre><code>\documentclass{article} \usepackage{listings} \begin{document} \begin{lstlisting}[language=html] &lt;html&gt; &lt;head&gt; &lt;title&gt;Hello&lt;/title&gt; &lt;/head&gt; &lt;body&gt;Hello&lt;/body&gt; &lt;/html&gt; \end{lstlisting} \end{document} </code></pre>
<p>I would suggest defining your own package based on the following tex code; this gives you complete freedom. <a href="http://ubuntuforums.org/archive/index.php/t-331602.html" rel="nofollow noreferrer">http://ubuntuforums.org/archive/index.php/t-331602.html</a></p>
38,527
<p>Just wondering if there is anything built-in to Javascript that can take a Form and return the query parameters, eg: <code>"var1=value&amp;var2=value2&amp;arr[]=foo&amp;arr[]=bar..."</code></p> <p>I've been wondering this for years.</p>
<p>2k20 update: use <a href="https://stackoverflow.com/a/49701878/2750743">Josh's</a> solution with <a href="https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/toString" rel="noreferrer">URLSearchParams.toString()</a>.</p> <p>Old answer:</p> <hr> <p>Without jQuery</p> <pre><code>var params = { parameter1: 'value_1', parameter2: 'value 2', parameter3: 'value&amp;3' }; var esc = encodeURIComponent; var query = Object.keys(params) .map(k =&gt; esc(k) + '=' + esc(params[k])) .join('&amp;'); </code></pre> <p>For browsers that don't support arrow function syntax which requires ES5, change the <code>.map...</code> line to</p> <pre><code> .map(function(k) {return esc(k) + '=' + esc(params[k]);}) </code></pre>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var params = { width:1680, height:1050 }; var str = jQuery.param( params ); console.log(str)</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </p>
40,905
<p>I've been trying to find a solution to a problem I've been having recently whereby the bottom layers of my print (1.2&nbsp;mm; 12 layers) are either being compressed. over extruded or both. The problem results in the nozzle being dragged through previously extruded filament leaving deep groove marks and the bottom layers being risen/wavy, thus causing (I believe) the print layers to expand horizontally outwards </p> <p>Settings are:</p> <ul> <li>Anycubic Chiron </li> <li>0.1&nbsp;mm layer height</li> <li>200&nbsp;&deg;C hotends temperature</li> <li>55&nbsp;&deg;C bed temperature</li> <li>40&nbsp;mm/s print speed</li> <li>eSun black 1.75&nbsp;mm PLA</li> <li>Cura 4.4.1</li> </ul> <p>It's less noticeable on less intrinsic prints but for my <a href="https://forums.eagle.ru/showthread.php?t=260512" rel="nofollow noreferrer">latest project</a>, its becoming a real issue. The problem is that for the square holes for the buttons (of which there are a lot), the bottom layers are extruding (essentially elephants foot-ing) which is impacting the tolerances of the build (holes should be 13&nbsp;mm to accept 12.5&nbsp;mm square buttons but are coming out at ~12.7&nbsp;mm only on the bottom layer, I've measured the walls of the square holes and they're coming out perfectly).</p> <p>I've tried almost everything I can think of/find on Google: </p> <ol> <li>Levelling the bed (multiple times)</li> <li>Tried print temps from 190&nbsp;&deg;C to 210&nbsp;&deg;C (even printed a temp tower which confirmed printing at ~200&nbsp;&deg;C is correct for my filament (eSun black PLA)</li> <li>Calibrated the extruder</li> <li>Calibrated the Z-axis </li> <li>Set different horizontal expansion settings in Cura</li> <li>Reduced entire print flow rates (have tried 90&nbsp;%, 85&nbsp;% and 80&nbsp;%); this somewhat worked but produced problems elsewhere in the print due to lack of material (skin overlap etc.)</li> <li>Used the 'modify settings for overlap' mesh setting to reduce infill flow &amp; inner wall flow to 45&nbsp;% and 55&nbsp;% respectively for the bottom layers (up to 1.2&nbsp;mm). </li> </ol> <p>The last point in that list is where I've had the most success but it does leave a slight indentation around the outer wall until the full flow rate kicks in (i.e. >1.2&nbsp;mm) and I'm thinking there may be other things at play that are causing the issue and I shouldn't have to do this reduce bottom layer flow so much if at all.</p> <p>Has anyone seen this before?</p>
<p>The first thing that comes to mind is that, even though you have levelled the bed, the print nozzle may be too close causing too much "squish" on the first layer. Squish isn't bad as it promotes adhesion, but in your case, as you are looking for finer tolerances on the holes, it may be a problem. I use a feeler gauge and aim for 0.15&nbsp;mm gap when printing at 0.2&nbsp;mm layer height.</p> <p>Next thing to consider is ensuring you have calibrated your flow rate/extrusion multiplier. <a href="https://e3d-online.dozuki.com/Guide/Flow+rate+(Extrusion+multiplier)+calibration+guide./89" rel="nofollow noreferrer">See here for detailed procedure</a></p> <p>Assuming flow rate is calibrated I can think of some settings in Cura that could affect your print.</p> <ul> <li>Initial Layer Flow</li> <li>Flow Rate Compensation Factor</li> <li>Combing Mode / Avoid Printed Parts</li> </ul> <p><em>Initial Layer Flow</em> enable the use of a higher/lower flow rate in you first layer. Typically I set this to a value larger that my flow rate, 120&nbsp;%, as I want good adhesion and am less worried about the elephant's foot effect. However, you could reduce it to less than your flow rate although that may compromise adhesion unless you use a brim.</p> <p><em>Flow Rate Compensation Factor</em> For most circumstances this should be 100&nbsp;% which indicates that your flow rate should be used as set and not compensated for. I would check that this value has not been altered cause over-extrusion.</p> <p>Lastly, there are two travel settings. <em>Combing Mode</em> and <em>Avoid Printed Parts</em> work in combination to reducing the impact of travels in the finished print. I would ensure you have combing turned on (e.g. Not in Skin) and that you have enabled Avoid Printed Parts. More details on these settings can be found <a href="https://ultimaker.com/en/resources/52838-travel" rel="nofollow noreferrer">here</a> </p>
<p>I had similar issues during the past few days. My first 3~5 layers overlapped. I ended up with figuring out it was the screws to mount Z stepper became loose and the stepper shifted itself downwards instead shifting up the nozzle for the first several layers, until the stepper had nowhere to go.</p>
1,595
<p>MTOM is the W3C Message Transmission Optimization Mechanism, a method of efficiently sending binary data to and from web services.</p> <p>How does it work in general?</p>
<p>If you put <a href="http://www.wireshark.org/" rel="noreferrer">Wireshark</a> (or enabled <a href="http://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspx" rel="noreferrer">System.Net Logging</a>) on the non-MTOM enabled service, you should see the SOAP requests with the binary data encoded as BASE64. Sending it as BASE64 increases the size of the binary data but (I assume) makes it more interoperable.</p> <p>With MTOM, the SOAP messages are sent as MIME messages with the BASE64 encoding being replaced with a placeholder. The binary data is then placed between delimiters (which happens for each piece of binary data), and then placed at the end of the SOAP request. The binary data is then sent unencoded. IIRC, MTOM also determines whether sending it as a MIME message will increase the size of the SOAP call and if doesn't provide a saving, it will send it as a normal SOAP message.</p> <p><a href="http://axis.apache.org/axis2/java/core/docs/mtom-guide.html#MTOM_Backward_Compatibility_with_SwA" rel="noreferrer">This</a> provides an example of what the message sent over the wire looks like.</p>
<p>There are a few factors that other answers don't mention. One might think why MTOM is not used as default since it's <em>"faster"</em> than Text message encoding (Base64). It's because MTOM is not faster always. MTOM should only be used on large message transfers because it comes with an overhead. For small size of messages, MTOM's performance will be worse than Text message encoding (Base64).</p> <p>If MTOM is used for large messages, it's faster than Base64 since it uses raw binary for data transfer. To understand that, one should understand how Base64 works. </p> <p>Base64 uses <strong>6 bits (log2(64))</strong> to represent <strong>1 character</strong> which means that base64 uses <strong>4 characters</strong> to represent 24 bits (<strong>3 bytes</strong>). So if the message size is <strong>n bytes</strong>, base64 will use <strong>4*(n/3) bytes</strong> to represent your data which means it will be <strong>slower by 1/3</strong> than MTOM.</p>
26,518
<p>Is there a way to define a macro that contains a <code>#include</code> directive in its body?</p> <p>If I just put the "<code>#include</code>", it gives the error</p> <pre><code>C2162: "expected macro formal parameter" </code></pre> <p>since here I am not using <code>#</code> to concatenate strings.<br> If I use "<code>\# include</code>", then I receive the following two errors:</p> <pre><code>error C2017: illegal escape sequence error C2121: '#' : invalid character : possibly the result of a macro expansion </code></pre> <p>Any help?</p>
<p>So like the others say, no, you can't have #include statements inside a macro, since the preprocessor only does one pass. However, you can make the preprocessor do basically the same thing with a gnarly trick I found myself using recently.</p> <p>Realise that preprocessor directives won't do anything inside a macro, however they WILL do something in a file. So, you can stick a block of code you want to mutate into a file, thinking of it like a macro definition (with pieces that can be altered by other macros), and then #include this pseudo-macro file in various places (make sure it has no include guards!). It doesn't behave exactly like a macro would, but it can achieve some pretty macro-like results, since #include basically just dumps the contents of one file into another.</p> <p>For example, consider including lots of similarly named headers that come in groups. It is tedious to write them all out, or perhaps even they are auto-generated. You can partially automate their inclusion by doing something like this:</p> <p>Helper macros header:</p> <pre><code>/* tools.hpp */ #ifndef __TOOLS_HPP__ #def __TOOLS_HPP__ // Macro for adding quotes #define STRINGIFY(X) STRINGIFY2(X) #define STRINGIFY2(X) #X // Macros for concatenating tokens #define CAT(X,Y) CAT2(X,Y) #define CAT2(X,Y) X##Y #define CAT_2 CAT #define CAT_3(X,Y,Z) CAT(X,CAT(Y,Z)) #define CAT_4(A,X,Y,Z) CAT(A,CAT_3(X,Y,Z)) // etc... #endif </code></pre> <p>Pseudo-macro file</p> <pre><code>/* pseudomacro.hpp */ #include "tools.hpp" // NO INCLUDE GUARD ON PURPOSE // Note especially FOO, which we can #define before #include-ing this file, // in order to alter which files it will in turn #include. // FOO fulfils the role of "parameter" in this pseudo-macro. #define INCLUDE_FILE(HEAD,TAIL) STRINGIFY( CAT_3(HEAD,FOO,TAIL) ) #include INCLUDE_FILE(head1,tail1.hpp) // expands to #head1FOOtail1.hpp #include INCLUDE_FILE(head2,tail2.hpp) #include INCLUDE_FILE(head3,tail3.hpp) #include INCLUDE_FILE(head4,tail4.hpp) // etc.. #undef INCLUDE_FILE </code></pre> <p>Source file</p> <pre><code>/* mainfile.cpp */ // Here we automate the including of groups of similarly named files #define FOO _groupA_ #include "pseudomacro.hpp" // "expands" to: // #include "head1_groupA_tail1.hpp" // #include "head2_groupA_tail2.hpp" // #include "head3_groupA_tail3.hpp" // #include "head4_groupA_tail4.hpp" #undef FOO #define FOO _groupB_ #include "pseudomacro.hpp" // "expands" to: // #include "head1_groupB_tail1.hpp" // #include "head2_groupB_tail2.hpp" // #include "head3_groupB_tail3.hpp" // #include "head4_groupB_tail4.hpp" #undef FOO #define FOO _groupC_ #include "pseudomacro.hpp" #undef FOO // etc. </code></pre> <p>These includes could even be in the middle of codes blocks you want to repeat (with FOO altered), as the answer by Bing Jian requests: <a href="https://stackoverflow.com/questions/266501/macro-definition-containing-include-directive/266647#266647">macro definition containing #include directive</a></p> <p>I haven't used this trick extensively, but it gets my job done. It can obviously be extended to have as many "parameters" as needed, and you can run whatever preprocessor commands you like in there, plus generate actual code. You just can't use the stuff it creates as the input into another macro, like you can with normal macros, since you can't stick the include inside a macro. But it can go inside another pseudo-macro :).</p> <p>Others might have some comments on other limitations, and what could go wrong :). </p>
<p>Contagious is right -- if you're doing:</p> <p>myFile.c:</p> <pre><code>#include "standardAppDefs.h" #myStandardIncludeMacro </code></pre> <p>standardAppDefs.h:</p> <pre><code>#define myStandardIncludeMacro #include &lt;foo.h&gt; </code></pre> <p>Why not just say:</p> <p>myFile.c:</p> <pre><code>#include "standardAppDefs.h" </code></pre> <p>standardAppDefs.h:</p> <pre><code>#include &lt;foo.h&gt; </code></pre> <p>And forget the macros?</p>
33,412
<p>We've been having some issues with a SharePoint instance in a test environment. Thankfully this is not production ;) The problems started when the disk with the SQL Server databases and search index ran out of space. Following this, the search service would not run and search settings in the SSP were not accessible. Reclaiming the disk space did not resolve the issue. So rather than restoring the VM, we decided to try to fix the issue.</p> <p>We created a new SSP and changed the association of all services to the new SSP. The old SSP and it's databases were then deleted. Search results for PDF files are no longer appearing, but the search works fine otherwise. MySites also works OK.</p> <p>Following the implementation of this change, these problems occur:</p> <blockquote> <p>1) An audit failure message started appearing in the application event log, for 'DOMAIN\SPMOSSSvc' which is the MOSS farm account.</p> </blockquote> <pre><code>Event Type: Failure Audit Event Source: MSSQLSERVER Event Category: (4) Event ID: 18456 Date: 8/5/2008 Time: 3:55:19 PM User: DOMAIN\SPMOSSSvc Computer: dastest01 Description: Login failed for user 'DOMAIN\SPMOSSSvc'. [CLIENT: &lt;local machine&gt;] </code></pre> <blockquote> <p>2) SQL Server profiler is showing queries from SharePoint that reference the old (deleted) SSP database.</p> </blockquote> <p>So...</p> <ul> <li>Where would these references to DOMAIN\SPMOSSSvc and the old SSP database exist?</li> <li>Is there a way to 'completely' remove the SSP from the server, and re-create? The option to delete was not available (greyed out) when a single SSP is in place.</li> </ul>
<p>As Daniel McPherson said, this is caused when SSPs are deleted but the associated job are not and attempt to communicate with the deleted database.<br><br>If the SSP database has been deleted or a problem occurred when deleting an SSP, the job may not be deleted. When the job attempts to run, it will fail since the database no longer exists.</p> <p>Follow the steps Daniel mentioned:<br> 1. Go to SQL Server Management Studio <br> 2. Disable the job called SSPNAME_JobDeleteExpiredSessions, right click and choose Disable Job.</p>
<p>Have you tried removing the SSP using the command line? I found this worked once when we had a broken an SSP and just wanted to get rid of it.</p> <p>The command is:</p> <pre><code>stsadm.exe -o deletessp -title &lt;sspname&gt; [-deletedatabases] </code></pre> <p>The <code>deletedatbases</code> switch is optional.</p> <hr> <p>Also, check in Central Administration under Job Definitions and Job Schedules to ensure no SSP related jobs are still running</p>
2,675
<p>From time to time am I working in a completely disconnected environment with a Macbook Pro. For testing purposes I need to run a local DNS server in a VMWare session. I've configured the lookup system to use the DNS server (/etc/resolve.conf and through the network configuration panel, which is using configd underneath), and commands like "dig" and "nslookup" work. For example, my DNS server is configured to resolve www.example.com to 127.0.0.1, this is the output of "dig www.example.com":</p> <pre><code>; &lt;&lt;&gt;&gt; DiG 9.3.5-P1 &lt;&lt;&gt;&gt; www.example.com ;; global options: printcmd ;; Got answer: ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 64859 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.example.com. IN A ;; ANSWER SECTION: www.example.com. 86400 IN A 127.0.0.1 ;; Query time: 2 msec ;; SERVER: 172.16.35.131#53(172.16.35.131) ;; WHEN: Mon Sep 15 21:13:15 2008 ;; MSG SIZE rcvd: 49 </code></pre> <p>Unfortunately, if I try to ping or setup a connection in a browser, the DNS name is not resolved. This is the output of "ping www.example.com":</p> <pre><code>ping: cannot resolve www.example.com: Unknown host </code></pre> <p>It seems that those tools, that are more integrated within Mac OS X 10.4 (and up), are not using the "/etc/resolv.conf" system anymore. Configuring them through scutil is no help, because it seems that if the wireless or the buildin ethernet interface is <strong>inactive</strong>, basic network functions don't seem to work.</p> <p>In Linux (for example Ubuntu), it is possible to turn off the wireless adapter, without turning of the network capabilities. So in Linux it seems that I can work completely disconnected.</p> <p>A solution could be using an ethernet loopback connector, but I would rather like a software solution, as both Windows and Linux don't have this problem.</p>
<p>On OS X starting in 10.4, <code>/etc/resolv.conf</code> is no longer the canonical location for DNS IP addresses. Some Unix tools such as <code>dig</code> and <code>nslookup</code> will use it directly, but anything that uses Unix or Mac APIs to do DNS lookups will not. Instead, configd maintains a database which provides many more options, like using different nameservers for different domains. (A subset of this information is mirrored to <code>/etc/resolv.conf</code> for compatibility.)</p> <p>You can edit the nameserver info from code with <code>SCDynamicStore</code>, or use <code>scutil</code> interactively or from a script. I posted some links to sample scripts for both methods <a href="http://njr.sabi.net/2005/11/07/alternate-openvpn-os-x-dns-updating-script/" rel="nofollow noreferrer">here</a>. <a href="http://lists.apple.com/archives/Macnetworkprog/2005/Jun/msg00011.html" rel="nofollow noreferrer">This thread</a> from when I was trying to figure this stuff out may also be of some use. </p>
<p>I run into this from time to time on different notebooks, and I have found the simplest is a low-tech, non software solution - create an ethernet loopback connecter. You can do it in 2 minutes with an old network cable, just cut the end off and join the send and receive pair just above the RJ45 connector. (obviously your interface needs a static IP)</p> <p>Old school, but completely software independent and good for working in a dev environment on long flights... :)</p> <p>there is a simple diagram <a href="http://www.juniper.net/techpubs/software/nog/nog-interfaces/html/fe-ge-loopback25.html" rel="nofollow noreferrer">here</a></p>
9,155
<p>Is there a way to cast a user control as a specific user control so I have access to it's public properties? Basicly I'm foreaching through a placeholder's controls collection and I'm trying to access the user control's public properties.</p> <pre><code>foreach(UserControl uc in plhMediaBuys.Controls) { uc.PulblicPropertyIWantAccessTo; } </code></pre>
<pre><code>foreach(UserControl uc in plhMediaBuys.Controls) { MyControl c = uc as MyControl; if (c != null) { c.PublicPropertyIWantAccessTo; } } </code></pre>
<h2>Casting</h2> <p>I prefer to use:</p> <pre><code>foreach(UserControl uc in plhMediaBuys.Controls) { ParticularUCType myControl = uc as ParticularUCType; if (myControl != null) { // do stuff with myControl.PulblicPropertyIWantAccessTo; } } </code></pre> <p>Mainly because using the is keyword causes two (quasi-expensive) casts:</p> <pre><code>if( uc is ParticularUCType ) // one cast to test if it is the type { ParticularUCType myControl = (ParticularUCType)uc; // second cast ParticularUCType myControl = uc as ParticularUCType; // same deal this way // do stuff with myControl.PulblicPropertyIWantAccessTo; } </code></pre> <h2>References</h2> <ul> <li><a href="http://rusek.org/stefan/default.aspx/2008/10/22/the-3-cast-operators-in-c/73/" rel="nofollow noreferrer">The 3 Cast Operators in C#</a></li> <li><a href="http://www.codeproject.com/KB/cs/csharpcasts.aspx" rel="nofollow noreferrer">Type Casting Impact over Execution Performance in C#</a></li> </ul>
28,101
<p>I downloaded Hex Workshop, and I was told to read a .dbc file.</p> <blockquote> <p>It should contain 28,315 if you read offset 0x04 and 0x05</p> </blockquote> <p>I am unsure how to do this? What does 0x04 mean?</p>
<p>0x04 is hex for 4 (the 0x is just a common prefix convention for base 16 representation of numbers - since many people think in decimal), and that would be the fourth byte (since they are saying offset, they probably count the first byte as byte 0, so offset 0x04 would be the 5th byte).</p> <p>I guess they are saying that the 4th and 5th byte together would be 28315, but did they say if this is little-endian or big-endian?</p> <p>28315 (decimal) is 0x6E9B in hexadecimal notation, probably in the file in order 0x9B 0x6E if it's little-endian.</p> <p>Note: Little-endian and big-endian refer to the order bytes are written. Humans typical write decimal notation and hexadecimal in a big-endian way, so:</p> <p>256 would be written as 0x0100 (digits on the left are the biggest scale)</p> <p>But that takes two bytes and little-endian systems will write the low byte first: 0x00 0x01. Big-endian systems will write the high-byte first: 0x01 0x00.</p> <p>Typically Intel systems are little-endian and other systems vary.</p>
<p>Start <a href="http://en.wikipedia.org/wiki/Hexadecimal" rel="nofollow noreferrer">here</a>. Once you learn how to read hexadecimal values, you'll be in much better shape to actually solve your problem.</p>
17,063
<p>This came to my mind after I learned the following from <a href="http://www.stackoverflow.com/questions/8941/generic-type-checking">this question</a>:</p> <pre><code>where T : struct </code></pre> <p>We, C# developers, all know the basics of C#. I mean declarations, conditionals, loops, operators, etc.</p> <p>Some of us even mastered the stuff like <a href="http://msdn.microsoft.com/en-us/library/512aeb7t.aspx" rel="nofollow noreferrer">Generics</a>, <a href="http://msdn.microsoft.com/en-us/library/bb397696.aspx" rel="nofollow noreferrer">anonymous types</a>, <a href="http://msdn.microsoft.com/en-us/library/bb397687.aspx" rel="nofollow noreferrer">lambdas</a>, <a href="http://msdn.microsoft.com/en-us/library/bb397676.aspx" rel="nofollow noreferrer">LINQ</a>, ...</p> <p>But what are the most hidden features or tricks of C# that even C# fans, addicts, experts barely know?</p> <h1>Here are the revealed features so far:</h1> <p><br /></p> <h2>Keywords</h2> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx" rel="nofollow noreferrer"><code>yield</code></a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9035#9035">Michael Stum</a></li> <li><code>var</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9035#9035">Michael Stum</a></li> <li><code>using()</code> statement by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9036#9036">kokos</a></li> <li><code>readonly</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9036#9036">kokos</a></li> <li><code>as</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9041#9041">Mike Stone</a></li> <li><code>as</code> / <code>is</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9070#9070">Ed Swangren</a></li> <li><code>as</code> / <code>is</code> (improved) by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9092#9092">Rocketpants</a></li> <li><code>default</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9639#9639">deathofrats</a></li> <li><code>global::</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/12152#12152">pzycoman</a></li> <li><code>using()</code> blocks by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/12316#12316">AlexCuse</a></li> <li><code>volatile</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/59691#59691">Jakub Šturc</a></li> <li><code>extern alias</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/37926#37926">Jakub Šturc</a></li> </ul> <h2>Attributes</h2> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.defaultvalueattribute.aspx" rel="nofollow noreferrer"><code>DefaultValueAttribute</code></a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9035#9035">Michael Stum</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/system.obsoleteattribute.aspx" rel="nofollow noreferrer"><code>ObsoleteAttribute</code></a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9037#9037">DannySmurf</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggerdisplayattribute.aspx" rel="nofollow noreferrer"><code>DebuggerDisplayAttribute</code></a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9048#9048">Stu</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggerbrowsableattribute.aspx" rel="nofollow noreferrer"><code>DebuggerBrowsable</code></a> and <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggerstepthroughattribute.aspx" rel="nofollow noreferrer"><code>DebuggerStepThrough</code></a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/33474#33474">bdukes</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/system.threadstaticattribute(VS.71).aspx" rel="nofollow noreferrer"><code>ThreadStaticAttribute</code></a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/13932#13932">marxidad</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/system.flagsattribute.aspx" rel="nofollow noreferrer"><code>FlagsAttribute</code></a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/21752#21752">Martin Clarke</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/4xssyw96.aspx" rel="nofollow noreferrer"><code>ConditionalAttribute</code></a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/35342#35342">AndrewBurns</a></li> </ul> <h2>Syntax</h2> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/ms173224.aspx" rel="nofollow noreferrer"><code>??</code></a> (coalesce nulls) operator by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9036#9036">kokos</a></li> <li>Number flaggings by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9038#9038">Nick Berardi</a></li> <li><code>where T:new</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9067#9067">Lars Mæhlum</a></li> <li>Implicit generics by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9099#9099">Keith</a></li> <li>One-parameter lambdas by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9099#9099">Keith</a></li> <li>Auto properties by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9099#9099">Keith</a></li> <li>Namespace aliases by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9099#9099">Keith</a></li> <li>Verbatim string literals with @ by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9114#9114">Patrick</a></li> <li><code>enum</code> values by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/11738#11738">lfoust</a></li> <li>@variablenames by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/14088#14088">marxidad</a></li> <li><code>event</code> operators by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/14277#14277">marxidad</a></li> <li>Format string brackets by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/15321#15321">Portman</a></li> <li>Property accessor accessibility modifiers by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/15715#15715">xanadont</a></li> <li>Conditional (ternary) operator (<code>?:</code>) by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/16450#16450">JasonS</a></li> <li><code>checked</code> and <code>unchecked</code> operators by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/355991#355991">Binoj Antony</a></li> <li><code>implicit and explicit</code> operators by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/121470#121470">Flory</a></li> </ul> <h2>Language Features</h2> <ul> <li>Nullable types by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9055#9055">Brad Barker</a></li> <li>Anonymous types by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9099#9099">Keith</a></li> <li><code>__makeref __reftype __refvalue</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9125#9125">Judah Himango</a></li> <li>Object initializers by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9547#9547">lomaxx</a></li> <li>Format strings by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/10207#10207">David in Dakota</a></li> <li>Extension Methods by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/13932#13932">marxidad</a></li> <li><code>partial</code> methods by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/16395#16395">Jon Erickson</a></li> <li>Preprocessor directives by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/16482#16482">John Asbeck</a></li> <li><code>DEBUG</code> pre-processor directive by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/29081#29081">Robert Durgin</a></li> <li>Operator overloading by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/24914#24914">SefBkn</a></li> <li>Type inferrence by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/28811#28811">chakrit</a></li> <li>Boolean operators <a href="http://www.java2s.com/Tutorial/CSharp/0160__Operator-Overload/truefalseoperatorforComplex.htm" rel="nofollow noreferrer">taken to next level</a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/32148#32148">Rob Gough</a></li> <li>Pass value-type variable as interface without boxing by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/1820538#1820538">Roman Boiko</a></li> <li>Programmatically determine declared variable type by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/1789985#1789985">Roman Boiko</a></li> <li>Static Constructors by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/100321#100321">Chris</a></li> <li>Easier-on-the-eyes / condensed ORM-mapping using LINQ by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/2026781#2026781">roosteronacid</a></li> <li><code>__arglist</code> by <a href="https://stackoverflow.com/a/1836944/171819">Zac Bowling</a></li> </ul> <h2>Visual Studio Features</h2> <ul> <li>Select block of text in editor by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/1699477#1699477" title="block text selecting with alt key">Himadri</a></li> <li>Snippets by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9037#9037">DannySmurf</a> </li> </ul> <h2>Framework</h2> <ul> <li><code>TransactionScope</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9042#9042">KiwiBastard</a></li> <li><code>DependantTransaction</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9042#9042">KiwiBastard</a></li> <li><code>Nullable&lt;T&gt;</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9118#9118">IainMH</a></li> <li><code>Mutex</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9181#9181">Diago</a></li> <li><code>System.IO.Path</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9401#9401">ageektrapped</a></li> <li><code>WeakReference</code> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/14723#14723">Juan Manuel</a></li> </ul> <h2>Methods and Properties</h2> <ul> <li><code>String.IsNullOrEmpty()</code> method by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9042#9042">KiwiBastard</a></li> <li><code>List.ForEach()</code> method by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9042#9042">KiwiBastard</a></li> <li><code>BeginInvoke()</code>, <code>EndInvoke()</code> methods by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9581#9581">Will Dean</a></li> <li><code>Nullable&lt;T&gt;.HasValue</code> and <code>Nullable&lt;T&gt;.Value</code> properties by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/15393#15393">Rismo</a></li> <li><code>GetValueOrDefault</code> method by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/18158#18158">John Sheehan</a></li> </ul> <h2>Tips &amp; Tricks</h2> <ul> <li>Nice method for event handlers by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9282#9282">Andreas H.R. Nilsson</a></li> <li>Uppercase comparisons by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/12137#12137">John</a></li> <li>Access anonymous types without reflection by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/13441#13441">dp</a></li> <li>A quick way to lazily instantiate collection properties by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/58945#58945">Will</a></li> <li>JavaScript-like anonymous inline-functions by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/1399130#1399130">roosteronacid</a></li> </ul> <h2>Other</h2> <ul> <li>netmodules by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/9036#9036">kokos</a> </li> <li><a href="http://www.albahari.com/nutshell/linqbridge.html" rel="nofollow noreferrer">LINQBridge</a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/10886#10886">Duncan Smart</a> </li> <li><a href="http://msdn.microsoft.com/en-us/concurrency/default.aspx" rel="nofollow noreferrer">Parallel Extensions</a> by <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c/31293#31293">Joel Coehoorn</a></li> </ul>
<p>This isn't C# per se, but I haven't seen anyone who really uses <code>System.IO.Path.Combine()</code> to the extent that they should. In fact, the whole Path class is really useful, but <strong>no one uses it!</strong></p> <p>I'm willing to bet that every production app has the following code, even though it shouldn't:</p> <pre><code>string path = dir + "\\" + fileName; </code></pre>
<p>I don't know if this is a hidden feature (""). Any string function.</p>
3,052
<p>Consider:</p> <pre><code>List&lt;String&gt; someList = new ArrayList&lt;String&gt;(); // add "monkey", "donkey", "skeleton key" to someList </code></pre> <pre><code>for (String item : someList) { System.out.println(item); } </code></pre> <p>What would the equivalent <code>for</code> loop look like without using the <em>for each</em> syntax?</p>
<pre><code>for (Iterator&lt;String&gt; i = someIterable.iterator(); i.hasNext();) { String item = i.next(); System.out.println(item); } </code></pre> <p>Note that if you need to use <code>i.remove();</code> in your loop, or access the actual iterator in some way, you cannot use the <code>for ( : )</code> idiom, since the actual iterator is merely inferred.</p> <p>As was noted by Denis Bueno, this code works for any object that implements the <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html" rel="noreferrer"><code>Iterable</code> interface</a>.</p> <p>Also, if the right-hand side of the <code>for (:)</code> idiom is an <code>array</code> rather than an <code>Iterable</code> object, the internal code uses an int index counter and checks against <code>array.length</code> instead. See the <a href="http://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.14.2" rel="noreferrer">Java Language Specification</a>.</p>
<p>Using <em>forEach</em>:</p> <pre class="lang-java prettyprint-override"><code>int[] numbers = {1,2,3,4,5}; Arrays.stream(numbers).forEach(System.out::println); </code></pre> <p>Response:</p> <pre class="lang-none prettyprint-override"><code>1 2 3 4 5 The process finished with exit code 0 </code></pre> <p>PS: You need a Array (<code>int[] numbers</code>), and <code>import java.util.Arrays;</code></p>
11,078
<p>So the SMEs at my current place of employment want to try and disable the back button for certain pages. We have a page where the user makes some selections and submits them to be processed. In some instances they have to enter a comment on another page. </p> <p>What the users have figured out is that they don't have to enter a comment if they submit the information and go to the page with the comment and then hit the back button to return to the previous page. </p> <p>I know there are several different solutions to this (and many of them are far more elegant then disabling the back button), but this is what I'm left with. Is it possible to prevent someone from going back to the previous page through altering the behavior of the back button. (like a submit -> return false sorta thing). </p> <p>Due to double posting information I can't have it return to the previous page and then move to the current one. I can only have it not direct away from the current page. I Googled it, but I only saw posts saying that it will always return to the previous page. I was hoping that someone has some mad kung foo js skills that can make this possible.</p> <p>I understand that everyone says this is a bad idea, and I agree, but sometimes you just have to do what you're told.</p>
<p>Don't do this, just don't. It's bad interface design and forces the user's browser to behave in a way that they don't expect.</p> <p>I would regard any script that successfully stopped my back button from working to be a hack, and I would expect the IE team to release a security-fix for it.</p> <p>The back button is part of their program interface, not your website.</p> <p>In your specific case I think the best bet is to add an unload event to the page that warns the user if they haven't completed the form. The back button would be unaffected and the user would be warned of their action.</p>
<p>There simply is no reliable way to do this. You cannot guarantee that 100% of the time you can stop the user from doing this.</p> <p>With that in mind, is it worth going to extremely exotic solutions to disable "most" of the time? That's for you to decide.</p> <p>Good luck.</p>
7,815
<p>My project uses Java libraries that have their own dependencies (Hadoop, Jetty for example). I end up with different versions of the same dependencies, like ant 1.4.5, 1.4.6. My project may want to use ant 1.4.7. This is a small example, can get more complicated with larger dependencies like HTTP Commons.</p> <p>How do I get all the libraries and dependencies to play nice? Is there a way to isolate each library (Hadoop, Jetty) so they only use their dependencies?</p>
<p>You may choose to manage all of these with a depenency management framework - like OSGI. Take a look at the spring framework dynamic modules <a href="http://www.springsource.org/osgi" rel="nofollow noreferrer">http://www.springsource.org/osgi</a></p> <p>You can also take a look at the part of the framework where Eclipse implements OSGI. Take a look here <a href="http://www.eclipse.org/osgi/" rel="nofollow noreferrer">http://www.eclipse.org/osgi/</a></p> <p>The short answer is just to go for the lowest common denominator. Remember that the 'endorsed' directory is your friend - when it comes to managing conflicting dependencies. </p>
<p>J G mentioned OSGi which was even my first thought when reading this question.</p> <p>Having multiple versions of the same library is a strong point in OSGi. If we have some third party products already mentioned i think its fair to mention the specification behind it as well. </p> <p>You can get it from the official osgi site <a href="http://osgi.org" rel="nofollow noreferrer">http://osgi.org</a></p>
34,556
<p>I run a rather complex project with several independent applications. These use however a couple of shared components. So I have a source tree looking something like the below.</p> <ul> <li>My Project <ul> <li>Application A</li> <li>Shared1</li> <li>Shared2 </li> <li>Application B </li> <li>Application C</li> </ul></li> </ul> <p>All applications have their own MSBuild script that builds the project and all the shared resources it needs. I also run these builds on a CruiseControl controlled continuous integration build server. </p> <p>When the applications are deployed they are deployed on several servers to distribute load. This means that it’s <em>extremely</em> important to keep track of what build/revision is deployed on each of the different servers (we need to have the current version in the DLL version, for example “1.0.0.68”). </p> <p>It’s equally important to be able to recreate a revision/build that been built to be able to roll back if something didn’t work out as intended (o yes, that happends ...). Today we’re using SourceSafe for source control but that possible to change if we could present good reasons for that (SS it’s actually working ok for us <em>so</em> far). </p> <p>Another principle that we try to follow is that it’s only code that been build and tested by the integration server that we deploy further. </p> <h2>"CrusieControl Build Labels" solution</h2> <p>We had several ideas on solving the above. The first was to have the continuous integration server build and locally deploy the project and test it (it does that now). As you probably know a successful build in CruiseControl generates a build label and I guess we somehow could use that to set the DLL version of our executables (so build label 35 would create a DLL like “1.0.0.35” )? The idea was also to use this build label to label the <strong>complete</strong> source tree. Then we probably could check out by that label and recreate the build later on. </p> <p>The reason for labeling the complete tree is to include not only the actual application code (that’s in one place in the source tree) but also all the shared items (that’s in different places in the tree). So a successful build of “Application A” would label to whole tree with label “ApplicationA35” for example. </p> <p>There might however be an issue when trying to recreate this build and setting the DLL version before deploying as we then don’t have access to the CruiseControl generated build label anymore. If all CrusieControl build labels were unique for all the projects we could use only the number for labeling but that’s not the case (both application A and B could at the same time be on build 35) so we have to include the application name in the label. Hence SourceSafe label “Application35”. <strong>How can I then recreate build 34 and set 1.0.0.34 to the DLL version numbers once we built build 35?</strong></p> <h2>"Revision number" solution</h2> <p>Someone told me that Subversion for example creates a revision number for the entire source tree on every check in – <strong>is this the case? Has SourceSafe something similar?</strong> If this is correct the idea is then to grab that revision number when getting latest and build on the CruiseControl server. The revision number could then be used to set the DLL version number (to for example “1.0.0.5678”). I guess we could then get this specific revision for the Subversion if needed and that then would include that application and all the shared items to be able to recreate a specific version from the past. <strong>Would that work and could this also be achived using SourceSafe?</strong></p> <h2>Summarize</h2> <p>So the two main requirements are:</p> <ol> <li>Be able to <strong>track build/revision number of the build and deployed DLL.</strong></li> <li>Be able to <strong>rebuild a past revision/build, set the old build/revision number on the executables of that build</strong> (to comply with requirement 1).</li> </ol> <p><strong>So how would you solve this?</strong> What would be your preferred approach and <strong>how</strong> would you solve it (or do you have a totally different idea?)? **Pleased give detailed answers. **</p> <p><em>Bonus question</em> What are the difference between a revision number and a build number and when would one really need both?</p>
<p>Your scheme is sound and achievable in VSS (although I would suggest you consider an alternative, VSS is really an outdated product).</p> <p>For your "CI" Build - you would do the Versioning take a look at <a href="http://msbuildtasks.tigris.org/" rel="nofollow noreferrer">MSBuild Community Tasks Project</a> which has a "Version" tasks. Typically you will have a "Version.txt" in your source tree and the MSBuild task will increment the "Release" number while the developers control the Major.Minor.Release.Revision numbers (that's how a client of mine wanted it). You can use revision if you prefer.</p> <p>You then would have a "FileUpdate" tasks to edit the AssemblyInfo.cs file with that version, and your EXE's and "DLL's" will have the desired version.</p> <p>Finally the VSSLabel task will label all your files appropriately.</p> <p>For your "Rebuild" Build - you would modify your "Get" to get files from that Label, obviously not execute the "Version" task (as you are SELECTING a version to build) and then the FileUpdate tasks would use that version number.</p> <p>Bonus question:</p> <p>These are all "how you want to use them" - I would use build number for, well the build number, that is what I'd increment. If you are using CI you'll have very many builds - the vast majority with no intention of ever deploying anywhere.</p> <p>The major and minor are self evident - but revision I've always used for a "Hotfix" indicator. I intend to have a "1.3" release - which would in reality be a product with say 1.3.1234.0 version. While working on 1.4 - I find a bug - and need a hot fix as 1.3.2400.1. Then when 1.4 is ready - it would be say 1.4.3500.0</p>
<p>UppercuT can do all of this with a custom packaging task to split the applications up. And to get the version number of the source, you might think about Subversion.</p> <p>It's also insanely easy to get started.</p> <p><a href="http://code.google.com/p/uppercut/" rel="nofollow noreferrer">http://code.google.com/p/uppercut/</a></p> <p>Some good explanations here: <a href="http://ferventcoder.com/category/uppercut.aspx" rel="nofollow noreferrer">UppercuT</a></p>
8,209
<p>What problems does MEF (Managed Extensibility Framework) solves that cannot be solved by existing IoC/DI containers?</p>
<p>The principle purpose of MEF is extensibility; to serve as a 'plug-in' framework for when the author of the application and the author of the plug-in (<em>extension</em>) are different and have no particular knowledge of each other beyond a published interface (<em>contract</em>) library. </p> <p>Another problem space MEF addresses that's different from the usual IoC suspects, and one of MEFs strengths, is [extension] discovery. It has a lot of, well, extensible discovery mechanisms that operate on metadata you can associate with extensions. From the MEF CodePlex site:</p> <p><em>"MEF allows tagging extensions with additonal metadata which facilitates rich querying and filtering"</em></p> <p>Combined with an ability to delay-load tagged extensions, being able to interrogate extension metadata <em>prior</em> to loading opens the door to a slew of interesting scenarios and substantially enables capabilities such as [plug-in] versioning. </p> <p>MEF also has 'Contract Adapters' which allow extensions to be 'adapted' or 'transformed' (<em>from type > to type</em>) with complete control over the details of those transforms. Contract Adapters open up another creative front relative to just what 'discovery' means and entails.</p> <p>Again, MEFs 'intent' is tightly focused on anonymous plug-in extensibility, something that very much differentiates it from other IoC containers. So while MEF can be used for composition, that's merely a small intersection of its capabilities relative to other IoCs, with which I suspect we'll be seeing a lot of incestuous interplay going forward.</p>
<p>Scott Hanselman and I covered this topic in more detail in the recent hanselminutes.</p> <p><a href="http://www.hanselminutes.com/default.aspx?showID=166" rel="noreferrer">http://www.hanselminutes.com/default.aspx?showID=166</a> </p>
13,352
<p>I come across this problem when i am writing an event handler in SharePoint. My event handler has a web reference. When i create this web reference, the URL of the web service will be added in the .config file of the assembly. If i have to change the web reference URL i just have to change the link in the config file. </p> <p>Problem comes when I try to GAC the dll. When i GAC the DLL, the config file cannot be GACed along with the dll, and hence, there is no way for me to update the web reference. </p> <p>One workaround i have found is to modify the constructor method Reference.cs class which is autogenerated by visual studio when i add a reference, so that the constructor reads the web service url from some other location, say a registry or an XML file in some predetermined location. But this poses a problem sometimes, as when i update the web referenc using visual studio, this Reference.cs file gets regenerated, and all my modifications would be lost.</p> <p>Is there a better way to solve this problem?</p>
<p>If you have Visual Studio 2008, use a Service Reference instead of a Web Reference, which will generate partial classes that you can use to override functionality without your code overwritten by the generator.</p> <p>For Visual Studio 2005, you could just add the <em>partial</em> keyword to the class in Reference.cs and keep a separate file with your own partial class:</p> <pre><code>public partial class WebServiceReference { public WebServiceReference(ExampleConfigurationClass config) { /* ... */ } } WebServiceReference svc = new WebServiceReference(myConfig); </code></pre>
<p>You could try this: Rather than using the dynamic web reference make it a static reference so that the code in Reference.cs won't go looking for a value in the .config file for the url. Then sub-class the generated web service client code and in that derived class, add your own logic to set the .Url property. Then VS.NET can re-gen Reference.cs all it likes, and your url setting code will remain. Of course, you have to update any downstream code to use your derived class, but that should be a simple global replace.</p>
15,238
<p>I subscribe to a newsletter from www.sqlservercentral.com that I like because each day I get an email digest with some interesting headlines &amp; summaries of SQL Server articles that are already out there on the web. It's a great way to learn something new a bit at a time.</p> <p>Is there something like this for C#? </p> <p>(If your favorite one is already listed, can you vote for it so I can see what's most popular? Thanks!)</p>
<p>In addition to <a href="http://www.codeproject.com/" rel="noreferrer">codeproject</a>, I believe there are other sites like <a href="http://www.c-sharpcorner.com/" rel="noreferrer">C# Corner</a>, <a href="http://www.csharphelp.com/" rel="noreferrer">C# help</a> which does the same..</p> <p>Couple more I found useful (Not specific to C#):</p> <p><a href="http://visualstudiomagazine.com/" rel="noreferrer">visualstudiomagazine</a></p> <p><a href="http://www.ddj.com/newsletters/" rel="noreferrer">Dr. Dobb's</a></p>
<p>check out <a href="http://wwww.codeproject.com" rel="nofollow noreferrer" title="wwww.codeproject.com">wwww.codeproject.com</a> they have a lot of articles and various newsletters.</p>
23,699
<p>I have a DataGrid, populated with objects in an ArrayCollection. After updating one of the objects' fields, I want the screen to update. The data source is not bindable, because I'm constructing it at runtime (and I don't understand how to make it bindable on the fly yet -- that's another question).</p> <p>In this situation, if I call InvalidateDisplayList() on the grid nothing seems to happen. But if I call invalidateList(), the updates happen. (And it's very smooth too -- no flicker like I would expect from invalidating a window in WIN32.)</p> <p>So the question: what is the difference between InvalidateList and InvalidateDisplayList? From the documentation it seems like either one should work.</p>
<p>invalidateList tells the component that the data has changed, and it needs to reload it and re-render it.</p> <p>invalidateDisplayList tells the component that it needs to redraw itself (but not necessarily reload its data).</p>
<p>invalidateDisplayList() merely sets a flag so that updateDisplayList() can be called later during a screen update. invalidateList() is what you want. </p> <p><a href="http://livedocs.adobe.com/flex/2/langref/mx/core/UIComponent.html#invalidateDisplayList()" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/2/langref/mx/core/UIComponent.html#invalidateDisplayList()</a></p>
9,995
<p>What are the key use cases for the use of virtualization -- that is, running one or more "virtual PCs" using software such as <a href="http://www.vmware.com/" rel="nofollow noreferrer">VMWare</a> and <a href="http://www.microsoft.com/windows/products/winfamily/virtualpc/default.mspx" rel="nofollow noreferrer">Microsoft Virtual PC</a> -- for software development?</p> <p>Also -- are there other instances/uses of virtualization that aren't covered by my definition above (use of a tool like MS Virtual PC or VMWare), and that are useful to developers?</p> <p>My impetus for asking is this <a href="https://stackoverflow.com/questions/171946/computer-upgrade-cycle#171978">StackOverflow comment</a> by <a href="https://stackoverflow.com/users/9664/metro-smurf">Metro Smurf</a> asserting "You'll wonder how you ever developed without it!", regarding use of virtualization.</p> <p>(Please include just one use case per response. Thanks!)</p>
<p>Application testing in multiple environments is one obvious use of virtualization that I'm aware of. Testing your application on other operating systems (without requiring additional physical computers to do so), as well as testing that involves software that generally only allows you to install a single version on a given machine (such as the Internet Explorer browser; running both IE6 and IE7 on the same machine is not an officially supported configuration), are good candidates for virtual machine usage.</p>
<p>Some server applications can use VMs too. When one vm is not used much, the server can locate the resources to other vms.</p>
25,205
<p>Say I have a table called "xml" that stores XML files in a single column "data". How would I write a MySQL query that run an XPath and return only rows matching that XPath?</p>
<pre><code>SELECT * FROM xml WHERE EXTRACTVALUE(data, '&lt;xpath-expr&gt;') != ''; </code></pre> <p>You should note, however, that there are limitations to MySQL's support of XPath.</p> <ul> <li><code>EXTRACTVALUE()</code> returns only CDATA.</li> <li>Not all XPath constructions are supported. Details under the heading "XPath limitations" on the doc <a href="http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html#function_extractvalue" rel="noreferrer">page</a> mentioned in abatishchev's answer.</li> </ul>
<p>I just got the answer from a colleague, it seems trimming the xml often helps:</p> <pre><code>select * from xml where trim(both '\r\n' from ExtractValue(xml, '/some/xpath')) = 'value'; </code></pre>
45,470
<p>It seems that programming ON a mobile device (instead of FOR a mobile device) could be easier if a lisp existed that run on J2ME. </p> <p>Do you know any (preferably opensource) lisp/smalltalk apps? I searched the web and I couldn't find a working J2ME lisp. Is it so difficult to port it to J2ME?</p> <p>Thanks</p>
<p>I managed myself to make <a href="http://norvig.com/jscheme.html" rel="nofollow noreferrer">http://norvig.com/jscheme.html</a> work in j2me, by removing all UI related classes...It worked, but my cellphone is TOO small and I dont have the time... I've only tested it with some (fac n)... but lisp is not for me, I'm not that smart.</p>
<p>You could try <a href="http://www.gnu.org/software/kawa/" rel="nofollow noreferrer">Kawa</a>, but I am not certain it will run.</p>
42,889
<p>Are there any statistics regarding how many units each manufacturer has sold, e.g. in 2019?</p> <p><a href="https://3dprinterchat.com/top-selling-3d-printers/" rel="nofollow noreferrer">An article</a> from 2016 claims Monoprice to have led the market back then - but all of the printers in that article have become obsolete since then. Some manufacturers also claim theirs to be "one of the most popular" - but that likely doesn't translate to sales, at least for the more overpriced ones.</p>
<p>Getting this data is not easy. Many companies that make 3D printers are either private companies that do not report results or are larger companies where 3D printers are one of many products they manufacture. Some companies study this information through mining public sources and surveying users for their opinions and experience. The result of some of these studies are available for a fee.</p> <p>Occasionally, a trade publication will survey data sources and produce an article. In other cases, a trade pub will publish an article generously offered by a commercial contributor.</p> <p>It is always difficult to know what is true when abstracting information from obscured, noisy, and biased information sources.</p> <p>Your question itself includes a bias. You use a words that include a value judgement: "but that likely doesn't translate to sales, at least for the more overpriced ones."</p> <p>The article you reference is not a deeply researched investigative piece. It is simply some product details for the five printers in 2016 which sold the most on Amazon.com. It doesn't include printers which were not sold on Amazon, so it leaves out any printers which use a different distribution channel. Also, the article include an link, probably which generate revenue back to the magazine, to each of the five printers sold through Amazon.</p> <p>To summarize, it is very difficult to aggregate this kind of information. Those who try to do so like to be compensated. A list of the top five devices on Amazon is a biased list.</p>
<p>For sales figures of the smaller companies; it is very difficult because they don't publish (esp the Chinese brands). For the larger organizations there is </p> <p>The Wholler's Report <a href="https://wohlersassociates.com/2019report.htm" rel="nofollow noreferrer">https://wohlersassociates.com/2019report.htm</a></p> <p>An article on <a href="https://www.forbes.com/sites/tjmccue/2018/06/04/wohlers-report-2018-3d-printer-industry-rises-21-percent-to-over-7-billion/#af651352d1a4" rel="nofollow noreferrer">Forbes</a> gave a quote about the 2018 Wholers Report:</p> <blockquote> <p>The 2018 report has the estimated number of desktop systems sold at nearly double the 2015 data (reported in the 2016 report). In just over two years, an astonishing <strong>528,952</strong> desktop 3D printers (or systems) are believed to have been sold.</p> </blockquote> <p>For 24 Years (basically the start) they have been tracking the 3D printing industry, providing the most reliable source of market share and growth. It costs a bit to purchase and you can't share the contents with anyone else, but if you're really interested then; grab a copy.</p> <p>Further, there are the statistics of 3DHubs.com. They used to be a distributed 3d printing service (I guess they still are). They keep track of the most popular printers of all types:</p> <p><a href="https://www.3dhubs.com/get/trends/" rel="nofollow noreferrer">https://www.3dhubs.com/get/trends/</a></p>
1,557
<p>Can someone suggest a small webserver implementation that will illustrate the concepts of what a webserver does? It should be in a language that is easily read, and understood, and should implement security and cgi, maybe javascript? </p>
<p><a href="http://www.acme.com/software/thttpd/" rel="nofollow noreferrer">thttpd</a>, a tiny/turbo/throttling http server.</p> <p>It is written in C. If by "a language that is easily read" you meant "not C," then nevermind.</p>
<p><a href="http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=webserver.r" rel="nofollow noreferrer">http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=webserver.r</a></p> <p>A web server written in a few lines - easily understood.</p> <p>or, this one, with CGI</p> <p><a href="http://www.rebol.org/view-script.r?script=webserv.r" rel="nofollow noreferrer">http://www.rebol.org/view-script.r?script=webserv.r</a></p> <p>What do you mean by security? Javascript is normally just page content.</p>
35,679
<p>When authoring a library in a particular namespace, it's often convenient to provide overloaded operators for the classes in that namespace. It seems (at least with g++) that the overloaded operators can be implemented either in the library's namespace:</p> <pre><code>namespace Lib { class A { }; A operator+(const A&amp;, const A&amp;); } // namespace Lib </code></pre> <p>or the global namespace</p> <pre><code>namespace Lib { class A { }; } // namespace Lib Lib::A operator+(const Lib::A&amp;, const Lib::A&amp;); </code></pre> <p>From my testing, they both seem to work fine. Is there any practical difference between these two options? Is either approach better?</p>
<p>You should define them in the library namespace. The compiler will find them anyway through argument dependant lookup.</p> <p>No need to pollute the global namespace.</p>
<p>You should define it in the namespace, both because the syntax will be less verbose and not to clutter the global namespace.</p> <p>Actually, if you define your overloads in your class definition, this becomes a moot question:</p> <pre><code>namespace Lib { class A { public: A operator+(const A&amp;); }; } // namespace Lib </code></pre>
20,720
<p>Within a spring webflow, i need to implement a navigation bar that will allow to "step back" or resume the flow to one of the previous view.</p> <p>For example :</p> <ul> <li>View 1 = login</li> <li>View 2 = My informations</li> <li>View 3 = My messages</li> <li>View 4 = Close session</li> </ul> <p>For this example, i would like to return back to view 2 from the view 4 page.</p>
<p>It depends how you're going about doing this. If you're doing this within a single flow, you'll have something like this:</p> <pre><code>&lt;view-state id="loginView" view="login.jsp"&gt; &lt;action-state bean="someBean" method="login" /&gt; &lt;transition on="success" to="informationView" /&gt; &lt;/view-state&gt; &lt;view-state id="informationView" view="information.jsp"&gt; &lt;render-actions&gt; &lt;action-state bean="someBean" method="retrieveInformation" /&gt; &lt;/render-actions&gt; &lt;transition on="forward" to="messageView" /&gt; &lt;transition on="back" to="loginView" /&gt; &lt;/view-state&gt; &lt;view-state id="messageView" view="message.jsp"&gt; &lt;render-actions&gt; &lt;action-state bean="someBean" method="retrieveMessage" /&gt; &lt;/render-actions&gt; &lt;transition on="forward" to="closeView" /&gt; &lt;transition on="back" to="informationView" /&gt; &lt;/view-state&gt; &lt;view-state id="closeView" view="logout.jsp"&gt; &lt;transition on="jumpBack" to="informationView" /&gt; &lt;/view-state&gt; </code></pre> <p>The "jumpBack" transition on "closeView" will jump you back to view state #2, which is your information view.</p> <p>With sub-flows it is tricky. You'd need to chain it: call a subflow, and if an event is signaled that states you need to end your flow with a specific state, immediately do so.</p> <p>For example, say that your flow chain is login->information->message->close.</p> <p>On the close flow, the end-state would be "returnToInformation".</p> <p>The message flow has a transition on="returnToInformation" to="returnToInformation".</p> <p>"returnToInformation" is also an end-state in the message flow.</p> <p>Then, the information flow has a transition on="returnToInformation" to="displayInformationPage", which would then re-display the information page.</p>
<p>I did this by defining some global flow that represented the tabs. I then defined an object that represented the tabs on the flows and indicated if the current tab was active. When the user moved through the tabs I updated the tab object as appropriate.</p> <p>When the user went to click on one of the tabs it used the global flows to allow them to move between the tabs (for my implementation I found it easier to call actions rather than view states because you may find the views may change depending on the user interaction to get there so you may need to recalculate them).</p> <p>For the tab bar itself, I put it in a single JSP that I then placed at the top of each form, this made updating it easier.</p> <p>Its not the nicest solution, but it does work.</p> <p>Good luck.</p>
21,014
<p>Is the following safe?</p> <p>I am new to threading and I want to delegate a time consuming process to a separate thread in my C++ program. Using the boost libraries I have written code something like this:</p> <p>thrd = new boost::thread(boost::bind(&amp;myclass::mymethod, this, &amp;finished_flag);</p> <p>Where finished_flag is a boolean member of my class. When the thread is finished it sets the value and the main loop of my program checks for a change in that value. I assume that this is okay because I only ever start one thread, and that thread is the only thing that changes the value (except for when it is initialised before I start the thread) So is this okay, or am I missing something, and need to use locks and mutexes, etc</p>
<p>You never mentioned the type of finished_flag...</p> <p>If it's a straight <strong>bool</strong>, then it might work, but it's certainly bad practice, for several reasons. First, some compilers will cache the reads of the <em>finished_flag</em> variable, since the compiler doesn't always pick up the fact that it's being written to by another thread. You can get around this by declaring the <strong>bool</strong> <strong>volatile</strong>, but that's taking us in the wrong direction. Even if reads and writes are happening as you'd expect, there's nothing to stop the OS scheduler from interleaving the two threads half way through a read / write. That might not be such a problem here where you have one read and one write op in separate threads, but it's a good idea to start as you mean to carry on.</p> <p>If, on the other hand it's a thread-safe type, like a <a href="http://msdn.microsoft.com/en-us/library/efk30beh(VS.71).aspx" rel="nofollow noreferrer">CEvent in MFC</a> (or <a href="http://www.boost.org/doc/libs/1_36_0/doc/html/thread/synchronization.html#thread.synchronization.condvar_ref" rel="nofollow noreferrer">equivilent in boost</a>) then you should be fine. This is the best approach: use thread-safe synchronization objects for inter-thread communication, even for simple flags.</p>
<p>Having the thread set a flag (or signal an event) before it exits is a race condition. The thread has not necessarily returned to the OS yet, and may still be executing. </p> <p>For example, consider a program that loads a dynamic library (pseudocode):</p> <pre><code>lib = loadLibrary("someLibrary"); fun = getFunction("someFunction"); fun(); unloadLibrary(lib); </code></pre> <p>And let's suppose that this library uses your thread:</p> <pre><code>void someFunction() { volatile bool finished_flag = false; thrd = new boost::thread(boost::bind(&amp;myclass::mymethod, this, &amp;finished_flag); while(!finished_flag) { // ignore the polling loop, it's besides the point sleep(); } delete thrd; } void myclass::mymethod() { // do stuff finished_flag = true; } </code></pre> <p>When <code>myclass::mymethod()</code> sets <code>finished_flag</code> to <code>true</code>, <code>myclass::mymethod()</code> hasn't returned yet. At the very least, it still has to execute a "return" instruction of some sort (if not much more: destructors, exception handler management, etc.). If the thread executing <code>myclass::mymethod()</code> gets pre-empted before that point, <code>someFunction()</code> will return to the calling program, and the calling program will unload the library. When the thread executing <code>myclass::mymethod()</code> gets scheduled to run again, the address containing the "return" instruction is no longer valid, and the program crashes.</p> <p>The solution would be for <code>someFunction()</code> to call <code>thrd-&gt;join()</code> before returning. This would ensure that the thread has returned to the OS and is no longer executing.</p>
5,433
<p>My team works on a project in cvs containing about 20,000 Java files. Because of the number of files, it takes a while to do a cvs update. I typically keep about 5 copies of the entire tree checked out, to make it easy to check in different requests without worrying about which files were modified for each. It's a real pain to keep all 5 trees up to date and in sync with each other.</p> <p>I've read that it's fairly easy to use git locally with a remote cvs server, and that git is fast. Will git significantly speed up the updating of my local trees?</p> <p>I realize the lower bound is the time to do one cvs update. But I'm thinking that once the first tree is up to date, it might possible to quickly sync the other 4 with the first, rather than to do 4 more cvs update commands. Do I understand git correctly?</p>
<p>I use Git as a Subversion client on a large project (on the order of 10k files). Git is fast, really fast. It's so fast that I only keep <em>one</em> working clone, and switch between feature branches within that same clone. Like you, when I used Subversion I would have two or three similar checkouts and would switch between them regularly as I had multiple things in progress simultaneously. It got to be pretty confusing sometimes. With Git's features like lightweight branches, the stash, and "git add -p", I find that I no longer need multiple checkouts. I can do everything in one directory, and not worry as much about losing changes that I either forgot about or accidentally overwrote.</p> <p>I haven't used Git with CVS, but if its integration is anything like git-svn then it's going to be no problem.</p>
<p>We do something similar at work. We basically use the <code>master</code> branch in git as a single, updated CVS version of the code; we don't do any development there, just CVS updates. Then, all of our development projects happen on feature branches that we rebase. When we do CVS updates on the <code>master</code> branch we commit those changes to <code>master</code> and then rebase our other development branches against <code>master</code>. </p> <p>It's not ideal -- it makes sharing branches with other people difficult. But, we can manage several development projects at once and do branches, merges, and diffs against them easily. And, we only interact with CVS on the one <code>master</code> branch, as needed.</p>
41,565
<p>Is there any alternative to stored procedures, secure and fast as well as stored procs. i know only Hibernate. Is there any other technologies like that?</p>
<p>Stored procedures are a place to put code (SQL) which executes on the database, so I understand the question to mean </p> <p><strong>"is there any other way to package up the code which runs on the database?"</strong></p> <p>There are several answers: </p> <ul> <li>There is nothing else that is <em>quite</em> the same as a stored procedure, but there are alternatives which you might consider. </li> <li>You could write all your SQL as strings inside your client code (java or whatever) <ul> <li>This has various problems (loss of encapsulation, tight coupling -> harder maintenance), however, and is not a good idea. </li> </ul></li> <li>You could use an ORM such as NHibernate, which inserts a layer between your client logic and the database. The ORM generates SQL to execute on the database. With an ORM, it is harder to express complex business logic than in a stored procedure (sweeping generalisation!). </li> <li>A kind of halfway house is to define your own data access layer (DAL) in java (or watever you're using) and keep it separate from the main body of client code (separate classes / namespaces / etc.), so that your client makes calls to the DAL, and the DAL interprets these and sends SQL to the database, returning the results from the database back to the client. </li> </ul>
<p>Hmm, seems to me that the obvious alternative to stored procedures is to write application code. Instead of, say, writing a store procedure to post a debit every time a credit is posted, you could write application code that writes both.</p> <p>Maybe I'm being too simplistic here or missing the point of the question.</p>
21,136