instruction
stringlengths 21
27.8k
| chosen
stringlengths 18
28.2k
| rejected
stringlengths 18
33.6k
| __index_level_0__
int64 0
50k
|
|---|---|---|---|
<p>From the Java 6 <a href="http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html" rel="noreferrer">Pattern</a> documentation:</p>
<blockquote>
<p>Special constructs (non-capturing)</p>
<p><code>(?:</code><i>X</i><code>)</code> <i>X</i>, as a non-capturing group</p>
<p>…</p>
<p><code>(?></code><i>X</i><code>)</code> <i>X</i>, as an independent, non-capturing group</p>
</blockquote>
<p>Between <code>(?:X)</code> and <code>(?>X)</code> what is the difference? What does the <strong>independent</strong> mean in this context?</p>
|
<p>It means that the grouping is <a href="http://www.regular-expressions.info/atomic.html" rel="noreferrer">atomic</a>, and it throws away backtracking information for a matched group. So, this expression is possessive; it won't back off even if doing so is the only way for the regex as a whole to succeed. It's "independent" in the sense that it doesn't cooperate, via backtracking, with other elements of the regex to ensure a match.</p>
|
<p><code>(?>X?)</code> equals <code>(?:X)?+</code>, <code>(?>X*)</code> equals <code>(?:X)*+</code>, <code>(?>X+)</code> equals <code>(?:X)++</code>.</p>
<p>Taking away the fact that X must be a non-capturing group, the preceding equivalence is:</p>
<p><code>(?>X?)</code> equals <code>X?+</code>, <code>(?>X*)</code> equals <code>X*+</code>, <code>(?>X+)</code> equals <code>X++</code>.</p>
| 7,329
|
<p>What is the thread pitch of the Ender 3's bed leveling screws? The diameter measures about 4mm. Are they M4 0.7 (coarse) pitch or 0.5 (fine) pitch? I'd like to develop rigorous formulas for the amount to turn the knobs by after measuring (or visually inspecting, since I can see an accurate 0.2 mm first layer decently well) leveling-test patterns in the corners rather than using a closed-loop tune-and-retry approach.</p>
|
<p>I measured mine with a thread gauge and it says the pitch is <strong>0.7 mm</strong>.</p>
<p>So, as the stock adjustment wheels have 14 bumps around their circumference, turning by one of those is an adjustment of exactly 0.05 mm (assuming no backlash).</p>
<p>I can't speak for anyone else's, but due to the availability of replacement height adjustment wheels which don't specify alternative thread pitches, I <em>guess</em> that's the only one in use. I encourage you to verify my finding before relying on it.</p>
|
<p>I don't know what the value is, but there are a few ways to find out. It is very hard to measure this with a caliper, but it can be done, mark the upper and bottom of e.g. 10 windings and measure this with a caliper. Alternatively measure how much the screw drops after 10 full turns. </p>
<p>There are special tools that give you the answer directly, they cost a few Euros/bucks but can be very handy; a thread gauge, just place the 0.5 mm and the 0.7 mm beside the screw and you will instantly see which is the correct one.</p>
<p><a href="https://i.stack.imgur.com/UYqFm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UYqFm.jpg" alt="enter image description here"></a></p>
<p><em>I bought mine at a typical Chinese vendor site.</em></p>
| 1,570
|
<p>I've always been intrigued by Map Routing, but I've never found any good introductory (or even advanced!) level tutorials on it. Does anybody have any pointers, hints, etc?</p>
<p><strong>Update:</strong> I'm primarily looking for pointers as to how a map system is implemented (data structures, algorithms, etc).</p>
|
<p>Take a look at the <a href="http://www.openstreetmap.org/" rel="noreferrer">open street map project</a> to see how this sort of thing is being tackled in a truely free software project using only user supplied and licensed data and have a <a href="http://wiki.openstreetmap.org/index.php/Main_Page" rel="noreferrer">wiki containing stuff you might find interesting</a>.</p>
<p>A few years back the guys involved where pretty easy going and answered lots of questions I had so I see no reason why they still aren't a nice bunch.</p>
|
<p>Another thought occurs to me regarding the cost of each traversal, but would increase the time and processing power required to compute. </p>
<p><strong>Example:</strong> There are 3 ways I can take (where I live) to go from point A to B, according to the GoogleMaps. Garmin units offer each of these 3 paths in the <code>Quickest</code> route calculation. After traversing each of these routes many times and averaging (obviously there will be errors depending on the time of day, amount of caffeine etc.), I feel the algorithms could take into account the number of bends in the road for high level of accuracy, <strong>e.g.</strong> <em>straight road of 1 mile will be quicker than a 1 mile road with sharp bends in it</em>.
Not a practical suggestion but certainly one I use to improve the result set of my daily commute.</p>
| 2,493
|
<p>I need to diff two log files but ignore the time stamp part of each line (the first 12 characters to be exact). Is there a good tool, or a clever awk command, that could help me out?</p>
|
<p>Depending on the shell you are using, you can turn the approach <a href="https://stackoverflow.com/questions/44019/an-easy-way-to-diff-log-files-ignoring-the-time-stamps#44028">@Blair</a> suggested into a 1-liner</p>
<pre><code>diff <(cut -b13- file1) <(cut -b13- file2)
</code></pre>
<p>(+1 to <a href="https://stackoverflow.com/questions/44019/an-easy-way-to-diff-log-files-ignoring-the-time-stamps#44028">@Blair</a> for the original suggestion :-)</p>
|
<p>I want to propose a solution for Visual Studio Code:</p>
<ol>
<li>Install this extension - <a href="https://marketplace.visualstudio.com/items?itemName=ryu1kn.partial-diff" rel="nofollow noreferrer">https://marketplace.visualstudio.com/items?itemName=ryu1kn.partial-diff</a></li>
<li>Configure it like this - <a href="https://github.com/ryu1kn/vscode-partial-diff/issues/49#issuecomment-608299085" rel="nofollow noreferrer">https://github.com/ryu1kn/vscode-partial-diff/issues/49#issuecomment-608299085</a></li>
<li>Run extension command "Toggle Pre-Comparison Text Normalization Rules" and enable rule added on step #2</li>
<li>Use the extension (here is an explanation of it's UI quirk - <a href="https://github.com/ryu1kn/vscode-partial-diff/issues/11" rel="nofollow noreferrer">https://github.com/ryu1kn/vscode-partial-diff/issues/11</a>)</li>
</ol>
| 6,565
|
<p>A similar question was asked <a href="https://stackoverflow.com/questions/198931/how-do-i-tell-if-net-35-sp1-is-installed">here</a>, but it was specific to .NET 3.5. Specifically, I'm looking for the following:</p>
<ol>
<li>What is the correct way to determine which .NET Framework versions and service packs are installed?</li>
<li>Is there a list of registry keys that can be used?</li>
<li>Are there any dependencies between Framework versions?</li>
</ol>
|
<p>The registry is <a href="https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed" rel="noreferrer">the official way</a> to detect if a specific version of the Framework is installed. </p>
<p><img src="https://i.stack.imgur.com/hiLch.png" alt="enter image description here"></p>
<p>Which registry keys are needed change depending on the Framework version you are looking for:</p>
<pre>
Framework Version Registry Key
------------------------------------------------------------------------------------------
1.0 HKLM\Software\Microsoft\.NETFramework\Policy\v1.0\3705
1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322\Install
2.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Install
3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\InstallSuccess
3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\Install
4.0 Client Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client\Install
4.0 Full Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full\Install
</pre>
<p>Generally you are looking for:</p>
<pre><code>"Install"=dword:00000001
</code></pre>
<p>except for .NET 1.0, where the value is a string (<code>REG_SZ</code>) rather than a number (<code>REG_DWORD</code>).</p>
<p>Determining the service pack level follows a similar pattern:</p>
<pre>
Framework Version Registry Key
------------------------------------------------------------------------------------------
1.0 HKLM\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}\Version
1.0[1] HKLM\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}\Version
1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322\SP
2.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\SP
3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\SP
3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\SP
4.0 Client Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client\Servicing
4.0 Full Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full\Servicing
[1] Windows Media Center or Windows XP Tablet Edition
</pre>
<p>As you can see, determining the SP level for .NET 1.0 changes if you are running on Windows Media Center or Windows XP Tablet Edition. Again, .NET 1.0 uses a string value while all of the others use a DWORD.</p>
<p>For .NET 1.0 the string value at either of these keys has a format of #,#,####,#. The last # is the Service Pack level.</p>
<p>While I didn't explicitly ask for this, if you want to know the exact version number of the Framework you would use these registry keys:</p>
<pre>
Framework Version Registry Key
------------------------------------------------------------------------------------------
1.0 HKLM\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}\Version
1.0[1] HKLM\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}\Version
1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322
2.0[2] HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Version
2.0[3] HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Increment
3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Version
3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\Version
4.0 Client Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Version
4.0 Full Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Version
[1] Windows Media Center or Windows XP Tablet Edition
[2] .NET 2.0 SP1
[3] .NET 2.0 Original Release (RTM)
</pre>
<p>Again, .NET 1.0 uses a string value while all of the others use a DWORD.</p>
<h2>Additional Notes</h2>
<ul>
<li><p>for .NET 1.0 the string value at either of these keys has a format of <code>#,#,####,#</code>. The <code>#,#,####</code> portion of the string is the Framework version.</p></li>
<li><p>for .NET 1.1, we use the name of the registry key itself, which represents the version number.</p></li>
<li><p>Finally, if you look at dependencies, .NET 3.0 adds additional functionality to .NET 2.0 so both .NET 2.0 and .NET 3.0 must both evaulate as being installed to correctly say that .NET 3.0 is installed. Likewise, .NET 3.5 adds additional functionality to .NET 2.0 and .NET 3.0, so .NET 2.0, .NET 3.0, and .NET 3. should all evaluate to being installed to correctly say that .NET 3.5 is installed.</p></li>
<li><p>.NET 4.0 installs a new version of the CLR (CLR version 4.0) which can run side-by-side with CLR 2.0.</p></li>
</ul>
<h2>Update for .NET 4.5</h2>
<p>There won't be a <code>v4.5</code> key in the registry if .NET 4.5 is installed. Instead you have to check if the <code>HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full</code> key contains a value called <code>Release</code>. If this value is present, .NET 4.5 is installed, otherwise it is not. More details can be found <a href="https://stackoverflow.com/a/15227828/270591">here</a> and <a href="https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed" rel="noreferrer">here</a>.</p>
|
<p>See <em><a href="http://msdn.microsoft.com/en-us/library/hh925568.aspx" rel="nofollow">How to: Determine Which .NET Framework Versions Are Installed</a></em> (MSDN).</p>
<p>MSDN proposes one function example that seems to do the job for version 1-4. According to the article, the method output is:</p>
<pre><code>v2.0.50727 2.0.50727.4016 SP2
v3.0 3.0.30729.4037 SP2
v3.5 3.5.30729.01 SP1
v4
Client 4.0.30319
Full 4.0.30319
</code></pre>
<p>Note that for "versions 4.5 and later" there is another function.</p>
| 24,267
|
<pre><code>public void PublicMethod(FooBar fooBar)
{
if (fooBar == null)
throw new ArgumentNullException("fooBar", "fooBar cannot be null");
// log the call [added: Thanks S.Lott]
_logger.Log("PublicMethod called with fooBar class " + fooBar.Classification);
int action = DetermineAction();
PrivateMethod(fooBar, action);
}
private void PrivateMethod(FooBar fooBar, int action)
{
if (fooBar == null)
throw new ArgumentNullException("fooBar", "fooBar cannot be null"); // Is this line superfluous?
/*
Do something
*/
}
</code></pre>
<p>Is it OK to skip this kind of error checking in private methods if the input is already checked on the public interface? Usually there's some sort of rule-of-thumb one can go by...</p>
<p>Edit:</p>
<p>Maybe ArgumentNullException isn't such a good example because the argument can be made that you should check at both levels but return different error messages.</p>
|
<p>I would say no.</p>
<p>While it certainly holds true that you in <em>this</em> case knows that it has already been checked for nullability, in two months time the youngest intern will come along and write
PublicMethod2 that also calls PrivateMethod, but lo and behold he forgot to check for null.</p>
|
<p>At least put a comment that PrivateMethod must have a non-null FooBar and that PublicMethod checks this.</p>
| 22,143
|
<p>When I load a HTML page with a .MOV embedded video on my App using a UIWebview it appears a broken icon, any idea? The same HTML page on Iphone Safari works fine and the media player is started without problem...</p>
|
<p>Where is the webpage? Is it embedded in your app? If you not giving the UIWebView a URL to load it from the server where it is make sure you set the baseURL properly so that the webview knows how to handle handle relative URLs.</p>
|
<p>When using the app sandbox, apple stops WebKit from accessing it's com.apple.security.WebKit.PluginAgent.</p>
<p>You must enable these in the entitlements file with the appropriate entitlement of </p>
<p>Add this line to the entitlements file as an ARRAY:
com.apple.security.temporary-exception.mach-lookup.global-name</p>
<p>in this array add the value : com.apple.security.WebKit.PluginAgent</p>
<p>and you should get your app to give sandbox permission so the app can access the quicktime movie plugins.</p>
<p>Hope this helps, if this doesn't solve the problem maybe the movies are missing... ;)</p>
| 34,866
|
<p>I have the age-old problem of a <code>div</code> wrapping a two-column layout. My sidebar is floated, so my container <code>div</code> fails to wrap the content and sidebar.</p>
<pre class="lang-html prettyprint-override"><code><div id="container">
<div id="content"></div>
<div id="sidebar"></div>
</div>
</code></pre>
<p>There seem to be numerous methods of fixing the clear bug in Firefox:</p>
<ul>
<li><code><br clear="all"/></code></li>
<li><code>overflow:auto</code></li>
<li><code>overflow:hidden</code></li>
</ul>
<p>In my situation, the only one that seems to work correctly is the <code><br clear="all"/></code> solution, which is a little bit scruffy. <code>overflow:auto</code> gives me nasty scrollbars, and <code>overflow:hidden</code> must surely have side effects.
Also, IE7 apparently shouldn't suffer from this problem due to its incorrect behaviour, but in my situation it's suffering the same as Firefox.</p>
<p>Which method currently available to us is the most robust?</p>
|
<p>Depending upon the design being produced, each of the below clearfix CSS solutions has its own benefits.</p>
<p>The clearfix does have useful applications but it has also been used as a hack. Before you use a clearfix perhaps these modern css solutions can be useful:</p>
<ul>
<li><a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/" rel="noreferrer">css flexbox</a></li>
<li><a href="https://css-tricks.com/snippets/css/complete-guide-grid/" rel="noreferrer">css grid</a></li>
</ul>
<hr>
<h1>Modern Clearfix Solutions</h1>
<hr>
<h2>Container with <code>overflow: auto;</code></h2>
<p>The simplest way to clear floated elements is using the style <code>overflow: auto</code> on the containing element. This solution works in every modern browsers.</p>
<pre class="lang-html prettyprint-override"><code><div style="overflow: auto;">
<img
style="float: right;"
src="path/to/floated-element.png"
width="500"
height="500"
>
<p>Your content here…</p>
</div>
</code></pre>
<p>One downside, using certain combinations of margin and padding on the external element can cause scrollbars to appear but this can be solved by placing the margin and padding on another parent containing element.</p>
<p>Using ‘overflow: hidden’ is also a clearfix solution, but will not have scrollbars, however using <code>hidden</code> will crop any content positioned outside of the containing element.</p>
<p><em>Note:</em> The floated element is an <code>img</code> tag in this example, but could be any html element.</p>
<hr>
<h2>Clearfix Reloaded</h2>
<p>Thierry Koblentz on CSSMojo wrote: <a href="http://cssmojo.com/the-very-latest-clearfix-reloaded/" rel="noreferrer">The very latest clearfix reloaded</a>. He noted that by dropping support for oldIE, the solution can be simplified to one css statement. Additionally, using <code>display: block</code> (instead of <code>display: table</code>) allows margins to collapse properly when elements with clearfix are siblings.</p>
<pre class="lang-css prettyprint-override"><code>.container::after {
content: "";
display: block;
clear: both;
}
</code></pre>
<p>This is the most modern version of the clearfix.</p>
<hr>
<p>⋮</p>
<p>⋮</p>
<h1>Older Clearfix Solutions</h1>
<p>The below solutions are not necessary for modern browsers, but may be useful for targeting older browsers.</p>
<p>Note that these solutions rely upon browser bugs and therefore should be used only if none of the above solutions work for you.</p>
<p>They are listed roughly in chronological order.</p>
<hr>
<h2>"Beat That ClearFix", a clearfix for modern browsers</h2>
<p>Thierry Koblentz' of <a href="http://www.cssmojo.com/latest_new_clearfix_so_far/" rel="noreferrer">CSS Mojo</a> has pointed out that when targeting modern browsers, we can now drop the <code>zoom</code> and <code>::before</code> property/values and simply use:</p>
<pre class="lang-css prettyprint-override"><code>.container::after {
content: "";
display: table;
clear: both;
}
</code></pre>
<p><em>This solution does not support for IE 6/7 …on purpose!</em></p>
<p>Thierry also offers: "<a href="http://www.cssmojo.com/latest_new_clearfix_so_far/#why-is-that" rel="noreferrer">A word of caution</a>: if you start a new project from scratch, go for it, but don’t swap this technique with the one you have now, because even though you do not support oldIE, your existing rules prevent collapsing margins."</p>
<hr>
<h2>Micro Clearfix</h2>
<p>The most recent and globally adopted clearfix solution, the <a href="http://nicolasgallagher.com/micro-clearfix-hack/" rel="noreferrer">Micro Clearfix by Nicolas Gallagher</a>.</p>
<p><em>Known support: Firefox 3.5+, Safari 4+, Chrome, Opera 9+, IE 6+</em></p>
<pre class="lang-css prettyprint-override"><code>.container::before, .container::after {
content: "";
display: table;
}
.container::after {
clear: both;
}
.container {
zoom: 1;
}
</code></pre>
<hr>
<h2>Overflow Property</h2>
<p>This basic method is preferred for the usual case, when positioned content will not show outside the bounds of the container.</p>
<p><a href="http://www.quirksmode.org/css/clearing.html" rel="noreferrer">http://www.quirksmode.org/css/clearing.html</a>
- <em>explains how to resolve common issues related to this technique, namely, setting <code>width: 100%</code> on the container.</em></p>
<pre class="lang-css prettyprint-override"><code>.container {
overflow: hidden;
display: inline-block;
display: block;
}
</code></pre>
<p>Rather than using the <code>display</code> property to set "hasLayout" for IE, other properties can be used for <a href="http://www.satzansatz.de/cssd/onhavinglayout.html" rel="noreferrer">triggering "hasLayout" for an element</a>.</p>
<pre class="lang-css prettyprint-override"><code>.container {
overflow: hidden;
zoom: 1;
display: block;
}
</code></pre>
<p>Another way to clear floats using the <code>overflow</code> property is to use the <a href="http://wellstyled.com/css-underscore-hack.html" rel="noreferrer">underscore hack</a>. IE will apply the values prefixed with the underscore, other browsers will not. The <code>zoom</code> property triggers <a href="http://www.satzansatz.de/cssd/onhavinglayout.html" rel="noreferrer">hasLayout</a> in IE:</p>
<pre class="lang-css prettyprint-override"><code>.container {
overflow: hidden;
_overflow: visible; /* for IE */
_zoom: 1; /* for IE */
}
</code></pre>
<p>While this works... it is not ideal to use hacks.</p>
<hr>
<h2>PIE: Easy Clearing Method</h2>
<p>This older "Easy Clearing" method has the advantage of allowing positioned elements to hang outside the bounds of the container, at the expense of more tricky CSS.</p>
<p>This solution is quite old, but you can learn all about Easy Clearing on Position Is Everything: <a href="http://www.positioniseverything.net/easyclearing.html" rel="noreferrer">http://www.positioniseverything.net/easyclearing.html</a></p>
<hr>
<h2>Element using "clear" property</h2>
<p>The quick and dirty solution (with some drawbacks) for when you’re quickly slapping something together:</p>
<pre><code><br style="clear: both" /> <!-- So dirty! -->
</code></pre>
<h3>Drawbacks</h3>
<ul>
<li>It's not responsive and thus may not provide the desired effect if layout styles change based upon media queries. A solution in pure CSS is more ideal.</li>
<li>It adds html markup without necessarily adding any semantic value.</li>
<li>It requires a inline definition and solution for each instance rather than a class reference to a single solution of a “clearfix” in the css and class references to it in the html.</li>
<li>It makes code difficult to work with for others as they may have to write more hacks to work around it.</li>
<li>In the future when you need/want to use another clearfix solution, you won't have to go back and remove every <code><br style="clear: both" /></code> tag littered around the markup.</li>
</ul>
|
<p>Have you tried this:</p>
<pre><code><div style="clear:both;"/>
</code></pre>
<p>I haven't had any problems with this method.</p>
| 25,975
|
<p>Really strange observation with my MP Select Mini V2 printing PLA. I've printed a dual-fan shroud so I can have a dedicated part-cooling fan. I've noticed that when I turn it on, the extruder starts stringing everywhere. Little tiny spider-web wisps. No amount of temperature change will make them go away (printing at 200 °C). But if I simply turn off the part-cooling fan, I get a perfect print. This doesn't make sense to me - isn't the part-cooling fan supposed to reduce stringing by cooling the filament faster?</p>
<p>More info: Using Ultimaker Cura 3.4.1, retraction enabled at 3.5 mm and 40 mm/s, which works great when the part-cooling fan is OFF. But when I turn it on without changing any other settings, I get stringing everywhere.</p>
<p>Please see picture below. The part on the left was printed using the part-cooling fan and the one on the right was printed without the part-cooling fan. No other changes. The part-cooling fan is pictured in upper left (bottom fan).</p>
<p><img src="https://i.stack.imgur.com/dB744.jpg" alt="Two printed fan shrouds" title="Two printed fan shrouds"></p>
<p>Why does my part-cooling fan cause stringing?</p>
<p>Note that I print at 0.175 mm layer height, or "Normal" for the MP Mini. The cooling fan can be controlled but if I turn it completely off then the cold end part of the nozzle won't get actively cooled. Using Cura I can slowly increase the fan over the first several levels as well, but I'm worried that if the cold end doesn't stay cold it will get clogged up with melted filament. I will try some different fan speed settings and report back - currently running at 100 % all the time.</p>
<hr>
<p><em>I went back to the stock shroud with single fan to remove variables. The stock shroud has a small vent at the bottom where air blows over the part, but not much. I had the same problem - I had to put a piece of tape over the blow hole to get the part to print without strings. I also couldn't get the PLA to stick to the bed easily when the blow hole was open. I'm not using the heated bed in any cases - I've found I can print most PLA without heating the bed at all. I'm beginning to think maybe this PLA is just extremely temperature sensitive. The brand is 3D Solutech Printer Filament Real Black.</em></p>
|
<p>Prior to a move the print cooling fan causes the filament to cool on the outside while the nozzle is still hot, when it then moves it causes a strings to form that will be cooled instantly. This means that the cooling you have is too much and should be reduced.</p>
<p>This printer has a single fan to cool the cold-end and the print through a slot with the same fan. As this fan can be scheduled, it would be recommended to create a dual fan on the carriage where you have a dedicated fan cooling the cold end at a fixed voltage, while the print is cooled by a separate fan that can be scheduled through slicer settings.</p>
|
<p>The fans are allowing the strings to harden instead of break. Maybe you should use more retraction or wipe before crossing perimeters to reduce material ooze during moves.</p>
| 1,035
|
<p>I have a flowlayout panel and on a resize event, I resize all the controls inside the flowlayout panel so they fit the width of the (flowlayoutpanel - padding - scroll bar width). On some resizes, the scroll bar is not shown, hiding most of the controls outside the area of the flowlayoutpanel while on other resizes the scroll bar is shown.I have set the AutoScroll property on the flowlayoutpanel to true. This is all done using C#, but I have also encountered this problem in VB.net. </p>
<p>Is there a way to force the flowlayoutpanel to recalculate how the controls are laid out after I resize the controls in the resize event or some other way to fix this problem?</p>
|
<p>Try the <code>.PerformLayout()</code> method, see if that helps.</p>
|
<p>By using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.refresh.aspx" rel="nofollow noreferrer">Refresh</a> method (inherited from Control) you can force the control to invalidate and redraw itself and its children.</p>
<p>Edit: Curiously, are you doing this resize to get the effect of top-bottom stacking?</p>
| 19,971
|
<p>I'm currently trying to pass a mono threaded program to multithread. This software do heavy usage of "refCounted" objects, which lead to some issues in multithread. I'm looking for some design pattern or something that might solve my problem.</p>
<p>The main problem is object deletion between thread, normally deletion only decrement the reference counting, and when refcount is equal to zero, then the object is deleted. This work well in monothread program, and allow some great performance improvement with copy of big object.</p>
<p>However, in multithread, two threads might want to delete the same object concurrently, as the object is protected by a mutex, only one thread delete the object and block the other one. But when it releases the mutex, then the other thread continue its execution with invalid (freed object), which lead to memory corruption.</p>
<p>Here is an example with this class RefCountedObject</p>
<pre><code>class RefCountedObject
{
public:
RefCountedObject()
: _refCount( new U32(1) )
{}
RefCountedObject( const RefCountedObject& obj )
: _refCount( obj._refCount )
{
ACE_Guard< ACE_Mutex > guard( _refCountMutex );
++(*_refCount);
}
~RefCountedObject()
{
Destroy();
}
RefCountedObject& operator=( const RefCountedObject& obj )
{
if( this != &obj )
{
Destroy();
ACE_Guard< ACE_Mutex > guard( _refCountMutex );
_refCount = obj._refCount;
++(*_refCount);
}
return *this;
}
private:
void Destroy()
{
ACE_Guard< ACE_Mutex > guard( _refCountMutex ); // thread2 are waiting here
--(*_refCount); // This cause a free memory write by the thread2
if( 0 == *_refCount )
delete _refCount;
}
private:
mutable U32* _refCount;
mutable ACE_Mutex _refCountMutex; // BAD: this mutex only protect the refCount pointer, not the refCount itself
};
</code></pre>
<p>Suppose that two threads want to delete the same RefCountedObject, both are in ~RefCountedObject and call Destroy(), the first thread has locked the mutex and the other one is waiting. After the deletion of the object by the first thread, the second will continue its execution and cause a free memory write.</p>
<p>Anyone has experience with a similar problem and found a solution ?</p>
<hr>
<p>Thanks all for your help, I realize my mistake:
The mutex is only protecting refCount pointer, not the refCount itself! I've created a RefCount class which is mutex protected. The mutex is now shared between all refCounted object.</p>
<p>Now all works fine.</p>
|
<p>If the count is part of the object then you have an inherent problem if one thread can be trying to <em>increase</em> the reference count whilst another is trying to remove the <em>last</em> reference. There needs to be an extra value on the ref count for each globally accessible pointer to the object, so you can always safely increase the ref count if you've got a pointer.</p>
<p>One option would be to use <code>boost::shared_ptr</code> <a href="http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/shared_ptr.htm" rel="nofollow noreferrer">(see the docs)</a>. You can use the free functions <code>atomic_load</code>, <code>atomic_store</code>, <code>atomic_exchange</code> and <code>atomic_compare_exchange</code> (which are conspicuously absent from the docs) to ensure suitable protection when accessing global pointers to shared objects. Once your thread has got a <code>shared_ptr</code> referring to a particular object you can use the normal non-atomic functions to access it.</p>
<p>Another option is to use Joe Seigh's atomic ref-counted pointer from his <a href="http://atomic-ptr-plus.sourceforge.net/" rel="nofollow noreferrer">atomic_ptr_plus project</a></p>
|
<p>Any object that you are sharing between threads should be protected with a mutex, and the same applies to refcount <em>handles</em> ! That means you will never be deleting the last one handle to an object from two threads. You might be concurrently deleting two distinct handles that happen to point to one object. </p>
<p>In Windows, you could use InterlockedDecrement. This ensures that precisely one of the two decrements will return 0. Only that thread will delete the refcounted object.</p>
<p>Any other thread cannot have been copying one of the two handles either. By common MT rules one thread may not delete an object still used by another thread, and this extends to refcount handles too. </p>
| 20,060
|
<p>I have seen <a href="https://stackoverflow.com/questions/295579/fastest-way-to-determine-if-an-integers-square-root-is-an-integer">this topic here</a> about John Carmack's magical way to calculate square root, which refers to this article: <a href="http://www.codemaestro.com/reviews/9" rel="nofollow noreferrer">http://www.codemaestro.com/reviews/9</a>. This surprised me a lot, I just didn't ever realized that calculating sqrt could be so faster. </p>
<p>I was just wondering what other examples of "magic" exist out there that computer games use to run faster.</p>
<p><strong>UPDATE</strong>:
John Carmack is not the author of the magic code. <a href="http://www.beyond3d.com/content/articles/8/" rel="nofollow noreferrer">This article</a> tells more. Thanks @moocha.</p>
|
<p>There is a book which gathers many of those 'magic tricks' and that may be interesting for you: <a href="https://rads.stackoverflow.com/amzn/click/com/0201914654" rel="nofollow noreferrer" rel="nofollow noreferrer">The Hacker's Delight</a>.</p>
<p>You have for example many tricks like bit twiddling hacks etc... (you have several square root algorithms for example that you can see on the google books version)</p>
|
<p>I'm a big fan of Bresenham Line, but man the <a href="http://www.andraka.com/cordic.htm" rel="nofollow noreferrer">CORDIC rotator</a> enabled all kinds of pixel chicanery for me when CPUs were slower.</p>
| 42,861
|
<p>Does anyone have an example using the table object in YUI library. More specifically, I'd like to dynamically load it from JSON or SQL?</p>
<p><a href="http://www.grails.org/YUI+Plugin" rel="nofollow noreferrer">http://www.grails.org/YUI+Plugin</a></p>
|
<p>I just found this example. Will be trying it out this weekend. Looks like exactly what I was looking for.</p>
<p><a href="http://marceloverdijk.blogspot.com/2008/06/grails-yui-datatable-example.html" rel="nofollow noreferrer">http://marceloverdijk.blogspot.com/2008/06/grails-yui-datatable-example.html</a></p>
|
<p>From the YUI documentation: <a href="http://developer.yahoo.com/yui/examples/datatable/index.html" rel="nofollow noreferrer">DataTable examples</a>. In particular, here's <a href="http://developer.yahoo.com/yui/examples/datatable/dt_xhrjson.html" rel="nofollow noreferrer">an example using JSON and XmlHttpRequest</a>.</p>
| 15,153
|
<p>I'm trying to print a cylinder with Flashprint. Problem is, that the .stl file i created (with OpenSCAD) is totally ruined once loaded into Flashprint. With ruined I mean the round outline is now with spikes and steps everywhere. And by loaded I mean directly after loading, not even creating the .gx files. The output of OpenSCAD looks fine, also in other stl viewers I tried.</p>
<p>I figured out the problem occurs more when using certain number of fragments ($fn). If its very small, loading works better. But for numbers that make it acutally look like a round circle (eg 50), Flashprint is unable to load them correctly it seems.</p>
<p>It's obvious that its no slicing or printing problem, but simply a loading one, since the shown object (which does not look any round) also prints the way it is shown in flashprint before slicing.</p>
<p>Does someone know a way to load a cylinder with flashprint correctly, or do I have to switch to different software? I already installed some but am unfamiliar with the printer settings which I do not know in detail. I really though a cylinder should'nt be too complex for any 3D software.</p>
<p>Here is the OpenSCAD Code for Cylinder, just create .stl and load into Flashprint to reproduce the Error:</p>
<pre><code>rotate_extrude($fn=70)
translate([0, 0])
square([20,2]);
</code></pre>
<p>See also this image (tried native cylinder code, problem remains the same however):
<a href="https://i.stack.imgur.com/v6qkG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v6qkG.png" alt=""></a></p>
|
<p>From an electrical standpoint, a two-phase stepper motors (what most 3D printers use) works the same backwards and forwards, the phase just reverses. If you are stalling on only one direction, I would look to see if you have a mechanical bind in that direction. Generally a wiring issue will cause the motor to either not run at all or to run in the wrong direction.</p>
<p>A few things you can check:</p>
<ol>
<li>Decouple the motors from their mechanical load and confirm that they all run correctly when they aren't driving a load. If you can't do that, disconnect them all then connect a spare motor to each cable one-at-a-time.</li>
<li>Turn each of the axis with your hand and make sure it turns smoothly throughout the entire range in both directions. Note: Some times a binding issue is acceleration related - a loose frame or coupling can cause this.</li>
<li>Monitor the supply voltage to make sure that one of the motors is not pulling the supply down causing all the others to stall.</li>
</ol>
|
<p>Sounds like you are configured for NC switches but are using NO switches, causing them to invert their reported state. Issue a <strong>M119</strong> command and see if the endstop statuses are correct when none are triggered.</p>
| 775
|
<p>Jeff actually posted about this in <a href="http://refactormycode.com/codes/333-sanitize-html" rel="noreferrer">Sanitize HTML</a>. But his example is in C# and I'm actually more interested in a Java version. Does anyone have a better version for Java? Is his example good enough to just convert directly from C# to Java?</p>
<p>[Update] I have put a bounty on this question because SO wasn't as popular when I asked the question as it is today (*). As for anything related to security, the more people look into it, the better it is!</p>
<p>(*) In fact, I think it was still in closed beta</p>
|
<p>Don't do this with regular expressions. Remember, you're not protecting just against valid HTML; you're protecting against the DOM that web browsers create. Browsers can be tricked into producing valid DOM from invalid HTML quite easily. </p>
<p>For example, see this list of <a href="http://ha.ckers.org/xss.html" rel="noreferrer">obfuscated XSS attacks</a>. Are you prepared to tailor a regex to prevent this real world attack on <a href="http://www.greymagic.com/security/advisories/gm005-mc/" rel="noreferrer">Yahoo and Hotmail</a> on IE6/7/8?</p>
<pre><code><HTML><BODY>
<?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time">
<?import namespace="t" implementation="#default#time2">
<t:set attributeName="innerHTML" to="XSS&lt;SCRIPT DEFER&gt;alert(&quot;XSS&quot;)&lt;/SCRIPT&gt;">
</BODY></HTML>
</code></pre>
<p>How about this attack that works on IE6? </p>
<pre><code><TABLE BACKGROUND="javascript:alert('XSS')">
</code></pre>
<p>How about attacks that are not listed on this site? The problem with Jeff's approach is that it's not a whitelist, as claimed. As someone on <a href="http://refactormycode.com/codes/333-sanitize-html#refactor_13642" rel="noreferrer">that page</a> adeptly notes:</p>
<blockquote>
<p>The problem with it, is that the html
must be clean. There are cases where
you can pass in hacked html, and it
won't match it, in which case it'll
return the hacked html string as it
won't match anything to replace. This
isn't strictly whitelisting.</p>
</blockquote>
<p>I would suggest a purpose built tool like <a href="http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project" rel="noreferrer">AntiSamy</a>. It works by actually parsing the HTML, and then traversing the DOM and removing anything that's not in the <em>configurable</em> whitelist. The major difference is the ability to gracefully handle malformed HTML. </p>
<p>The best part is that it actually unit tests for all the XSS attacks on the above site. Besides, what could be easier than this API call:</p>
<pre><code>public String toSafeHtml(String html) throws ScanException, PolicyException {
Policy policy = Policy.getInstance(POLICY_FILE);
AntiSamy antiSamy = new AntiSamy();
CleanResults cleanResults = antiSamy.scan(html, policy);
return cleanResults.getCleanHTML().trim();
}
</code></pre>
|
<p>The biggest problem by using jeffs code is the @ which currently isnt available. </p>
<p>I would probably just take the "raw" regexp from jeffs code if i needed it and paste it into </p>
<p><a href="http://www.cis.upenn.edu/~matuszek/General/RegexTester/regex-tester.html" rel="nofollow noreferrer">http://www.cis.upenn.edu/~matuszek/General/RegexTester/regex-tester.html</a> </p>
<p>and see the things needing escape get escaped and then use it.</p>
<hr>
<p>Taking the usage of this regex in mind I would personally make sure I understood exactly what I was doing, why and what consequences would be if I didnt succeed, before copy/pasting anything, like the other answers try to help you with.</p>
<p><em>(Thats propbably pretty sound advice for any copy/paste)</em></p>
| 4,437
|
<p>I've got two collections (generic Lists), let's call them ListA and ListB.</p>
<p>In ListA I've got a few items of type A. In ListB I've got some items of type B that have the SAME ID (but not same type) as the items in ListA, plus many more. I want to remove all the items from ListB that have the same ID as the ones in ListA. What's the best way of doing this? Is Linq to objects a nice fit? What algorithm would you use?</p>
<p>Example</p>
<p>ListA: ItemWithID1, ItemWithID2¨</p>
<p>ListB: ItemWithID1, ItemWithID2, ItemWithID3, ItemWithID4</p>
<p>EDIT: I forgot to mention in my original question that ListA and ListB doesn't contain the same types. So the only way to compare them is through the .Id property. Which invalidates the answers I've gotten so far.</p>
|
<p>Here are two options. Not sure which one is faster.</p>
<pre><code>listB.RemoveAll(listA.Contains);
foreach (string str in listA.Intersect(listB))
listB.Remove(str);
</code></pre>
|
<p>simple loop:</p>
<pre><code>for (item i: LISTA) {
removeItem(i, LISTB);
}
method removeItem(Item, List) {
for (Item i: List) {
if (Item == i)
List.removeItem(i);
}
}
</code></pre>
| 30,308
|
<p>Using Ruby and Thin as a web service. Apache is also loaded. Can't access the web service because listing ports, such as <code>:3000</code> or <code>:6600</code>, in the GET url is not allowed. How is the port requirement removed?</p>
|
<p>Use Apache ProxyPass.</p>
<p>cd /etc/apache2/sites-enabled/
sudo vi 000-default</p>
<p>Edit Lines:
ServerAdmin webmaster@localhost
ProxyPass /breakfast <a href="http://localhost:4567/breakfast" rel="nofollow noreferrer">http://localhost:4567/breakfast</a>
DocumentRoot /var/www</p>
<p>sudo /etc/init.d/apache2 restart</p>
|
<p>If you're talking about Apache HTTPD, either leave off the port, or specify "80" for the port.</p>
<p>If you're talking about Apache Tomcat, you'll need to set up an HTTP Connector with port=80, but Tomcat will need to be launched as root.</p>
| 16,674
|
<p>Partial template specialization is one of the most important concepts for generic programming in C++. For example: to implement a generic swap function:</p>
<pre><code>template <typename T>
void swap(T &x, T &y) {
const T tmp = x;
y = x;
x = tmp;
}
</code></pre>
<p>To specialize it for a vector to support O(1) swap:</p>
<pre><code>template <typename T, class Alloc>
void swap(vector<T, Alloc> &x, vector<T, Alloc> &y) { x.swap(y); }
</code></pre>
<p>So you can always get optimal performance when you call swap(x, y) in a generic function;</p>
<p>Much appreciated, if you can post the equivalent (or the canonical example of partial specialization of the language if the language doesn't support the swap concept) in alternative languages.</p>
<p><strong>EDIT</strong>: so it looks like many people who answered/commented really don't known what partial specialization is, and that the generic swap example seems to get in the way of understanding by some people. A more general example would be:</p>
<pre><code>template <typename T>
void foo(T x) { generic_foo(x); }
</code></pre>
<p>A partial specialization would be:</p>
<pre><code>template <typename T>
void foo(vector<T> x) { partially_specialized_algo_for_vector(x); }
</code></pre>
<p>A complete specialization would be:</p>
<pre><code>void foo(vector<bool> bitmap) { special_algo_for_bitmap(bitmap); }
</code></pre>
<p>Why this is important? because you can call foo(anything) in a generic function:</p>
<pre><code>template <typename T>
void bar(T x) {
// stuff...
foo(x);
// more stuff...
}
</code></pre>
<p>and get the most appropriate implementation at compile time. This is one way for C++ to achieve abstraction w/ minimal performance penalty.</p>
<p>Hope it helps clearing up the concept of "partial specialization". In a way, this is how C++ do type pattern matching without needing the explicit pattern matching syntax (say the match keyword in Ocaml/F#), which sometimes gets in the way for generic programming. </p>
|
<p><a href="http://www.digitalmars.com/d/1.0" rel="nofollow noreferrer">D</a> supports partial specialization:</p>
<ul>
<li><a href="http://www.digitalmars.com/d/2.0/overview.html" rel="nofollow noreferrer">Language overview</a></li>
<li><a href="http://www.digitalmars.com/d/2.0/template-comparison.html" rel="nofollow noreferrer">Template feature comparison</a> (with C++ 98 and 0x).</li>
</ul>
<p>(scan for "partial" in the above links).</p>
<p>The second link in particular will give you a <em>very</em> detailed breakdown of what you can do with template specialization, not only in D but in C++ as well.</p>
<p>Here's a D specific example of <code>swap</code>. It should print out the message for the swap specialized for the <code>Thing</code> class.</p>
<pre><code>import std.stdio; // for writefln
// Class with swap method
class Thing(T)
{
public:
this(T thing)
{
this.thing = thing;
}
// Implementation is the same as generic swap, but it will be called instead.
void swap(Thing that)
{
const T tmp = this.thing;
this.thing = that.thing;
that.thing = tmp;
}
public:
T thing;
}
// Swap generic function
void swap(T)(ref T lhs, ref T rhs)
{
writefln("Generic swap.");
const T tmp = lhs;
lhs = rhs;
rhs = tmp;
}
void swap(T : Thing!(U))(ref T lhs, ref T rhs)
{
writefln("Specialized swap method for Things.");
lhs.swap(rhs);
}
// Test case
int main()
{
auto v1 = new Thing!(int)(10);
auto v2 = new Thing!(int)(20);
assert (v1.thing == 10);
assert (v2.thing == 20);
swap(v1, v2);
assert (v1.thing == 20);
assert (v2.thing == 10);
return 0;
}
</code></pre>
|
<p>Java has generics, which allow you to do similar sorts of things.</p>
| 49,376
|
<p>I recently read a discussion regarding whether managed languages are slower (or faster) than native languages (specifically C# vs C++). One person that contributed to the discussion said that the JIT compilers of managed languages would be able to make optimizations regarding references that simply isn't possible in languages that use pointers.</p>
<p>What I'd like to know is what kind of optimizations that are possible on references and not on pointers?</p>
<p>Note that the discussion was about execution speed, not memory usage.</p>
|
<p>There are some benefits of <a href="http://en.wikipedia.org/wiki/Just-in-time_compilation" rel="nofollow noreferrer">JIT compilation</a> mentioned in Wikipedia:</p>
<blockquote>
<p>JIT code generally offers far better performance than interpreters. In addition, it can in some or many cases offer better performance than static compilation, as many optimizations are only feasible at run-time:</p>
<ol>
<li>The compilation can be optimized to the targeted CPU and the operating system model where the application runs. For example JIT can choose SSE2 CPU instructions when it detects that the CPU supports them. With a static compiler one must write two versions of the code, possibly using inline assembly.</li>
<li>The system is able to collect statistics about how the program is actually running in the environment it is in, and it can rearrange and recompile for optimum performance. However, some static compilers can also take profile information as input.</li>
<li>The system can do global code optimizations (e.g. inlining of library functions) without losing the advantages of dynamic linking and without the overheads inherent to static compilers and linkers. Specifically, when doing global inline substitutions, a static compiler must insert run-time checks and ensure that a virtual call would occur if the actual class of the object overrides the inlined method.</li>
<li>Although this is possible with statically compiled garbage collected languages, a bytecode system can more easily rearrange memory for better cache utilization.</li>
</ol>
</blockquote>
<p>I can't think of something related directly to the use of references instead of pointers.</p>
|
<p>An object reference in a managed framework is very different from a passed reference in C++. To understand what makes them special, imagine how the following scenario would be handled, at the machine level, without garbage-collected object references: Method "Foo" returns a string, which is stored into various collections and passed to different pieces of code. Once nothing needs the string any more, it should be possible to reclaim all memory used in storing it, but it's unclear what piece of code will be the last one to use the string.</p>
<p>In a non-GC system, every collection either needs to have its own copy of the string, or else needs to hold something containing a pointer to a shared object which holds the characters in the string. In the latter situation, the shared object needs to somehow know when the last pointer to it gets eliminated. There are a variety of ways this can be handled, but an essential common aspect of all of them is that shared objects need to be notified when pointers to them are copied or destroyed. Such notification requires work.</p>
<p>In a GC system by contrast, programs are decorated with metadata to say which registers or parts of a stack frame will be used at any given time to hold rooted object references. When a garbage collection cycle occurs, the garbage collector will have to parse this data, identify and preserve all live objects, and nuke everything else. At all other times, however, the processor can copy, replace, shuffle, or destroy references in any pattern or sequence it likes, without having to notify any of the objects involved. Note that when using pointer-use notifications in a multi-processor system, if different threads might copy or destroy references to the same object, synchronization code will be required to make the necessary notification thread-safe. By contrast, in a GC system, each processor may change reference variables at any time without having to synchronize its actions with any other processor.</p>
| 49,437
|
<p>I'm currently using Wordpress to run my website. However, with each new release I become more concerned with software bloat and the convoluted table structures used to store my data. Maybe this is a fruitless pursuit. Features are always added to blogging software until it claims to be a CMS--and at that point your data is probably stuck.</p>
|
<p>You do have the option of sticking with the 2.0 branch. This will be maintained with just bug fixes until 2010. Take a look at <a href="http://wordpress.org/download/legacy/" rel="nofollow noreferrer">http://wordpress.org/download/legacy/</a></p>
|
<p>None of the previous answers have really addressed the title of this question.</p>
<p>How should the tables be constructed for a blog? That entirely depends on what you want to do with it, honestly.</p>
<p>One approach could be to have a posts table and a comments table. The posts table could have the title, content, date, and a post id. The comments table could have a post id, comment id, commenter note, and content.</p>
<p>But that's really only relevant if you're building it yourself. None of the blogging tools I have ever seen are very inefficient in terms of space usage, and all of them provide import tools from "standard" formats (from blogger, wordpress, moveabletype, etc to any where else). And don't forget that they will all publish posts and comments via RSS, which makes them eminently portable.</p>
<p>WordPress in particular is still only 1.2 MB as a tar.gz. If that's big enough to be concerned about bloat, I'd strongly suggest building one yourself, or moving to a hosted blogging platform :)</p>
| 13,061
|
<p>We are migrating a web applicatin from vs05 to vs08. This application is using Telerik web controls. After I converted the project, and run, I get the exception: "A control is already associated with the element". I traced it down to a use control that has Telerik RadCombo box on it. However, I don't see anything out of place. Researching it, hasn't gotten me any results. I would appreciate any pointers.</p>
<p>Thanks!</p>
|
<p>Search for the ID of the problematic combo box in your solution and see where it is used. If you have not set an ID attribute for the control - do so and make sure it is unique.</p>
<p>If you are using AJAX requests make sure that you are updating all controls that need to be updated after AJAX. </p>
|
<p>Not sure if this helps, but we started getting this exception when we moved from 2.0 to 4.0. We were already disposing of the control but the fix was to also set it to undefined.</p>
<pre><code>child.control.dispose();
child.control = undefined;
</code></pre>
| 27,342
|
<p>When I build a site, I'd like to have at least one browser I can show it off in without any hacks or workarounds, and yet still retain maximum functionality. Knowing that none of the browsers have perfect standards adherence, which one comes closest?</p>
<p>Also, are there any standards areas in which a single browser seems to specialize? Opera, for instance, seems to be bent on adhering to all voice-related CSS standards.</p>
|
<p>The way most people I know work is to run Firefox(with Firebug) and develop in that. Firebug is an invaluable tool for debugging. They will usually take what the get there and try to squeak it into IE and other browsers. Not exactly the answer to your question (Its not 100% compliant but its close), but hopefully it helps.</p>
|
<p>Try Google Chrome it uses the WebKit which is feature complete for the latest standards. </p>
| 14,194
|
<p>I want to combine these:</p>
<pre class="lang-py prettyprint-override"><code>keys = ['name', 'age', 'food']
values = ['Monty', 42, 'spam']
</code></pre>
<p>Into a single dictionary:</p>
<pre class="lang-py prettyprint-override"><code>{'name': 'Monty', 'age': 42, 'food': 'spam'}
</code></pre>
|
<p>Like this:</p>
<pre><code>keys = ['a', 'b', 'c']
values = [1, 2, 3]
dictionary = dict(zip(keys, values))
print(dictionary) # {'a': 1, 'b': 2, 'c': 3}
</code></pre>
<p>Voila :-) The pairwise <a href="https://docs.python.org/3/library/functions.html#func-dict" rel="noreferrer"><code>dict</code></a> constructor and <a href="https://docs.python.org/3/library/functions.html#zip" rel="noreferrer"><code>zip</code></a> function are awesomely useful.</p>
|
<p>method without zip function</p>
<pre><code>l1 = [1,2,3,4,5]
l2 = ['a','b','c','d','e']
d1 = {}
for l1_ in l1:
for l2_ in l2:
d1[l1_] = l2_
l2.remove(l2_)
break
print (d1)
{1: 'd', 2: 'b', 3: 'e', 4: 'a', 5: 'c'}
</code></pre>
| 25,759
|
<p>By default the MVC Preview 5 web project comes with a HomeController.vb class. This sets the web URL to <a href="http://www.mywebsite.com/home/" rel="nofollow noreferrer">http://www.mywebsite.com/home/</a> by default. If I just wanted this to be <a href="http://www.mywebsite.com/" rel="nofollow noreferrer">http://www.mywebsite.com/</a> by default, how would I accomplish that?</p>
|
<p>Answered already so I'm just going to direct you to <a href="https://stackoverflow.com/questions/15470/how-do-i-get-rid-of-home-in-aspnet-mvc">How do I get rid of Home in ASP.Net MVC?</a>. </p>
<p><sup>Users with 10k+ rep can also refer to <a href="https://stackoverflow.com/questions/33861/aspnet-mvc-routing-basics-root-route">https://stackoverflow.com/questions/33861/aspnet-mvc-routing-basics-root-route</a> (deleted)</sup></p>
|
<p>I'm not sure I understand your question, if what you want is to go to <a href="http://www.mywebsite.com/" rel="nofollow noreferrer">http://www.mywebsite.com/</a> and not have it be trailed by /home, that is the behavior you will get.</p>
<p>Is there something else you were looking for?</p>
| 15,906
|
<p>I am looking to parse a URL to obtain a collection of the querystring parameters in Java. To be clear, I need to parse a given URL(or string value of a URL object), not the URL from a servlet request. </p>
<p>It looks as if the <code>javax.servlet.http.HttpUtils.parseQueryString</code> method would be the obvious choice, but it has been deprecated.</p>
<p>Is there an alternative method that I am missing, or has it just been deprecated without an equivalent replacement/enhanced function?</p>
|
<p>I think the idea is to use the HttpServletRequest instead. There is the getParameterMap(), getParameterNames() and getParameterValues() methods to start.</p>
<p>There is also the getParameter(String paramname) method to get the value of a specific method.</p>
<p>These make no distinction between querystring parameters and form parameters though so if your intention was to look for a querystring in aparticular then I guess this wouldn't help.</p>
|
<p>As far as I know, there isn't one.</p>
<p>It shouldn't be too difficult to write one yourself though. The hardest part, I imagine, would be decoding the URL name/values (which really isn't that hard, if you think about it), and you can use <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLDecoder.html#decode(java.lang.String,%20java.lang.String)" rel="nofollow noreferrer"><code>java.net.URLDecoder#decodeURL(String,String)</code></a> for that.</p>
| 30,936
|
<p>I saw the following interesting usage of tar in a co-worker's Bash scripts:</p>
<pre><code>`tar cf - * | (cd <dest> ; tar xf - )`
</code></pre>
<p>Apparently it works much like rsync -av does, but faster. The question arises, how?</p>
<p>-m</p>
<hr>
<p><strong>EDIT</strong>: Can anyone explain <em>why</em> should this solution be preferable over the following? </p>
<pre><code>cp -rfp * dest
</code></pre>
<p>Is the former faster?</p>
|
<p>It writes the archive to standard output, then pipes it to a subprocess -- wrapped by the parentheses -- that changes to a different directory and reads/extracts from standard input. That's what the dash character after the <code>f</code> argument means. It's basically copying all the visible files and subdirectories of the current directory to another directory.</p>
|
<pre><code>tar cf - *
</code></pre>
<p>This uses tar to send * to stdout</p>
<pre><code>|
</code></pre>
<p>This does the obvious redirect of stdout to...</p>
<pre><code>(cd <dest> ; tar xf - )
</code></pre>
<p>This, which changes PWD to the appropriate location and then extracts from stdin</p>
<p>I do not know why this would be faster than rsync, as there is no compression involved.</p>
| 40,809
|
<p>New version of Management Studio (i.e. the one that ships with SQL Server 2008) finally has a Transact-SQL IntelliSense feature. However, out-of-the-box it only works with SQL Server 2008 instances.</p>
<p>Is there some workaround for this?</p>
|
<p>There's no known trick 'in the wild' for getting around this, other than using CTP-6 of SQL Server 2008 (in favour of the RTM).</p>
<p>the reasons for removing backward compatability (and a lot more discussion besides) are provided at the <a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=341872" rel="noreferrer">relevant feedback in microsoft connect</a>.</p>
<p>edit: sorry i don't know where this ctp is available, if at all</p>
|
<p>Has anyone tried either patching SSMS not to check the version (perhaps try looking at the binary differences between CTP 6 and RTM?), or patching SS 2005 to pretend to be 2008?</p>
<p>Unclean, I know, but I don't see any other way.</p>
| 2,649
|
<p>A quick search gives me <a href="http://www.tawbaware.com/wc.htm" rel="noreferrer">tawbaware wc</a>, but it does not accept stdout as input stream, meaning I can not use pipe within a <em>DOS</em> session.</p>
<p><em>Note:</em> </p>
<p>I can not install cygwin or use powershell (which would have allowed a '<code>|foreach-object {(get-content $_).count}</code>')</p>
<p><a href="http://unxutils.sourceforge.net" rel="noreferrer">unxutils</a> and and <a href="http://gnuwin32.sourceforge.net/" rel="noreferrer">gnuwin32</a> Packages might have this feature...</p>
|
<p>You can use the original "wc", built for windows: it is part of the <a href="http://gnuwin32.sourceforge.net/packages/coreutils.htm" rel="noreferrer">coreutils</a> package. Get the <a href="http://gnuwin32.sourceforge.net/downlinks/coreutils.php" rel="noreferrer">most recent coreutils exe</a>.</p>
|
<p><a href="http://sourceforge.net/project/showfiles.php?group_id=163416" rel="nofollow noreferrer">getgnuwin32</a> facilitates downloading and installing of gnuwin32 (which certainly has wc utility).</p>
| 30,707
|
<p>I am trying to create a multi dimensional array using this syntax:</p>
<pre><code>$x[1] = 'parent';
$x[1][] = 'child';
</code></pre>
<p>I get the error: <code>[] operator not supported for strings</code> because it is evaluating the <code>$x[1]</code> as a string as opposed to returning the array so I can append to it.</p>
<p>What is the correct syntax for doing it this way? The overall goal is to create this multidimensional array in an iteration that will append elements to a known index.</p>
<p>The syntax <code>${$x[1]}[]</code> does not work either.</p>
|
<p>The parent has to be an array!</p>
<pre><code>$x[1] = array();
$x[1][] = 'child';
</code></pre>
|
<p>I think what you want to do is to use $x['parent'] in the end, isn't it ?</p>
<p>So it's not exactly $x = array() but more something like :</p>
<pre><code>$x = array('parent' => array());
$x['parent'][] = 'child';
</code></pre>
| 26,103
|
<p>I wonder if anyone uses commercial/free java obfuscators on his own commercial product. I know only about one project that actually had an obfuscating step in the ant build step for releases.</p>
<p>Do you obfuscate? And if so, why do you obfuscate?</p>
<p>Is it really a way to protect the code or is it just a better feeling for the developers/managers?</p>
<p><strong>edit:</strong> Ok, I to be exact about my point: Do you obfuscate to protect your IP (your algorithms, the work you've put into your product)? I won't obfuscate for security reasons, that doesn't feel right. So I'm only talking about protecting your applications code against competitors.</p>
<p><a href="https://stackoverflow.com/users/988/staffan">@staffan</a> has a good point:</p>
<blockquote>
<p>The reason to stay away from chaining code flow is that some of those changes makes it impossible for the JVM to efficiently optimize the code. In effect it will actually degrade the performance of your application.</p>
</blockquote>
|
<p>If you do obfuscate, stay away from obfuscators that modify the code by changing code flow and/or adding exception blocks and such to make it hard to disassemble it. To make the code unreadable it is usually enough to just change all names of methods, fields and classes.</p>
<p>The reason to stay away from changing code flow is that some of those changes makes it impossible for the JVM to efficiently optimize the code. In effect it will actually degrade the performance of your application. </p>
|
<p>I guess it really comes down to <em>what</em> your Java code is for, how it's distributed and who your clients are. We don't obfuscate anything, as we've never found one that was particularly good and it tends to be more trouble than it's worth. If someone has access to our JAR files and has the knowledge to be able to sniff around inside them, then there's far more worrying things that they can do than rip off our source code.</p>
| 3,317
|
<p>I am trying to make an Outlook 2003 add-in using Visual Studio 2008 on Windows XP SP3 and Internet Explorer 7.</p>
<p>My add-in is using custom Folder Home Page which displays my custom form, which wraps Outlook View Control.</p>
<p>I get COM Exception with 'Exception from HRESULT: 0xXXXXXXXX' description every time when I try to set Folder property of the OVC. Error code is a random number, every time is different. It is not the first access to control's properties, before that, View and ViewXML properties are set already. Control is marked as Safe for Scripting.</p>
<p>I am using value of the CurrentFolder.FolderPath property of the active explorer, which seems to be a right one:</p>
<pre><code>Outlook.Explorer currentExplorer = app.ActiveExplorer();
if (currentExplorer != null)
{
ovcWrapper.Folder = currentExplorer.CurrentFolder.FolderPath;
}
</code></pre>
<p>This is top of the stack trace:</p>
<pre><code>System.Runtime.InteropServices.COMException (0xXXXXXXXX): Exception from HRESULT: 0xXXXXXXXX
at Microsoft.Office.Interop.OutlookViewCtl.ViewCtlClass.set_Folder(String pVal)
at AxMicrosoft.Office.Interop.OutlookViewCtl.AxViewCtl.set_Folder(String value)..
</code></pre>
<p>This is happening only if the folder is located in non-default PST file. Changing to folder inside default PST file will produce no exception.</p>
<p>I must underline that everything worked just fine before I went to holiday :). It seems that Windows XP installed some updates which changed default security of Internet Explorer or Outlook 2003 while I was absent.</p>
<p>On the other (virtual machine) with Office 2007 and Internet Explorer 6, without any updates, everything is working just fine.</p>
|
<p>After a while, I finally find out what is the solution: change a name of the external storage to something new.</p>
<p>During startup of the addin, it loads the non-default PST file, and changes its name (not the name of the pst file, but the name of the root folder) to "Documents".</p>
<p>This is code:</p>
<pre><code>session.AddStore("C:\\test.pst"); // loads existing or creates a new one, if there is none.
storage = session.Folders.GetLast(); // grabs root folder of the new fileStorage.
if (storage.Name != storageName) // if fileStorage is brand new, it has default name.
{
storage.Name = "Documents";
session.RemoveStore(storage); // to apply new fileStorage name, it have to be removed and added again.
session.AddStore(storagePath);
}
</code></pre>
<p>Solution is not to use 'Documents' as a name any more, but something new. Problem is not related to specific name.</p>
|
<p>Dobri Dan, nency :)<br><br>I don't know if I can really offer a "silver bullet" solution given the information here...but here are a few ideas/notes to try out:<br><br>Having worked with Outlook on a few projects in the past, I can tell you that it is a funny bird sometimes when it comes to giving/granting access to outside users/processes. It sometimes requires the user to manually confirm access or log in...so make certain that you have</p>
<pre><code>app.Session.Logon()
</code></pre>
<p>taken care of somewhere.<br><br>The other thing I notice is the use of <code>app.ActiveExplorer()</code> Make certain that this function is returning exactly what you think it is; It takes the <em>topmost</em> window on the user's desktop...which is usualyy <em>but not always</em> the window you are trying to work with, so just doublecheck.</p>
| 16,123
|
<p>Using Vim, I'm trying to pipe text selected in visual mode to a UNIX command and have the output appended to the end of the current file. For example, say we have a SQL command such as:</p>
<pre><code>SELECT * FROM mytable;
</code></pre>
<p>I want to do something like the following:</p>
<pre><code><ESC>
V " select text
:'<,'>!mysql -uuser -ppass mydb
</code></pre>
<p>But instead of having the output overwrite the currently selected text, I would like to have the output appended to the end of the file. You probably see where this is going. I'm working on using Vim as a simple SQL editor. That way, I don't have to leave Vim to edit, tweak, test SQL code.</p>
|
<p>How about copying the selected text to the end of the file, select the copy and run the command? If you do not want to repeat the same commands over and over again, you can record the sequence by using <code>q</code> or add a new command. I have tried the latter as follows:</p>
<pre><code>:com -range C <line1>,<line2>yank | $ | put | .,$ !rev
</code></pre>
<p>With it you can select some lines and then type <code>:C</code>. This will first yank the selection, then go to the end of the file, paste the yanked text and run the command (<code>rev</code> in this case) over the new text.</p>
|
<p>Try</p>
<pre><code>:r | YourCommand
</code></pre>
<p>For example:</p>
<pre><code>:r ! echo foo
</code></pre>
<p>adds <code>foo</code> to your buffer.</p>
| 28,505
|
<p>I was wondering if anyone that has experience in both this stuff can shed some light on the <em>significant</em> difference between the two if any?</p>
<p>Any specific strength of each that makes it suitable for any specific case?</p>
|
<p>This question is quite dated but as it is still getting traffic and answers I though I state my point here again even so I already did it on some other (newer) questions.</p>
<p>I'm <em><strong>really really</strong></em> baffled that SimpleTest <strong>still</strong> is considered an alternative to phpunit. Maybe i'm just misinformed but as far as I've seen:</p>
<ul>
<li>PHPUnit is the standard; most frameworks use it (like Zend Framework (1&2), Cake, Agavi, even Symfony is dropping their own Framework in Symfony 2 for phpunit).</li>
<li>PHPUnit is integrated in every PHP IDE (Eclipse, Netbeans, Zend Stuide, PHPStorm) and works nicely.</li>
<li>Simpletest has an eclipse extension for PHP 5.1 (a.k.a. old) and nothing else.</li>
<li>PHPUnit works fine with every continuous integration server since it outputs all standard log files for code coverage and test reports.</li>
<li>Simpletest does not. While this is not a big problem to start with it will bite you big time once you stop "just testing" and start developing software (Yes that statement is provocative :) Don't take it too seriously).</li>
<li>PHPUnit is actively maintained, stable and works great for every codebase, every scenario and every way you want to write your tests.</li>
<li>(Subjective) <a href="http://www.phpunit.de/manual/3.6/en/code-coverage-analysis.html" rel="noreferrer">PHPUnit provides much nicer</a> code coverage reports <a href="http://www.simpletest.org/en/reporter_documentation.html" rel="noreferrer">than Simpletest</a></li>
<li>With PHPUnit you also get these reports inside your IDE (<a href="http://netbeans.org/kb/docs/php/phpunit.htm%60" rel="noreferrer">Netbeans</a>, Eclipse, ...)</li>
<li>Also there are a couple of suggestings for a <a href="https://stackoverflow.com/questions/2424457/web-interface-to-phpunit-tests"><strong><code>web interface to phpunit tests</code></strong></a>.</li>
</ul>
<p>I've yet to see any argument in favor of SimpleTest. It's not even simpler to install since PHPUnit is available via pear:</p>
<pre><code>pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit
</code></pre>
<p>and the "first test" looks pretty much the same.</p>
<p>As of <code>PHPUnit 3.7</code> it's <strong>even easier to install</strong> it by just using the <a href="http://www.phpunit.de/manual/current/en/installation.html#installation.phar" rel="noreferrer"><strong><code>PHAR Archive</code></strong></a></p>
<pre><code>wget http://pear.phpunit.de/get/phpunit.phar
chmod +x phpunit-3.7.6.phar
</code></pre>
<p>or for windows just <a href="http://pear.phpunit.de/get/phpunit.phar" rel="noreferrer">downloading</a> the phar and running:</p>
<pre><code>php phpunit-.phar
</code></pre>
<p>or when using the <a href="http://www.phpunit.de/manual/current/en/installation.html#installation.composer" rel="noreferrer">supported composer install</a> ways like</p>
<pre><code>"require-dev": {
"phpunit/phpunit": "3.7.*"
}
</code></pre>
<p>to your composer.json.</p>
<hr />
<p>For everything you want to test PHPUnit will have a solution and you will be able to find help pretty much anywhere (SO, #phpunit irc channel on freenode, pretty much every php developer ;) )</p>
<p>Please correct me if I've stated something wrong or forgot something :)</p>
<h1>Overview of PHP Testing tools</h1>
<p>Video: <a href="http://conference.phpnw.org.uk/phpnw11/schedule/sebastian-bergmann/" rel="noreferrer">http://conference.phpnw.org.uk/phpnw11/schedule/sebastian-bergmann/</a></p>
<p>Slides: <a href="http://www.slideshare.net/sebastian_bergmann/the-php-testers-toolbox-osi-days-2011" rel="noreferrer">http://www.slideshare.net/sebastian_bergmann/the-php-testers-toolbox-osi-days-2011</a></p>
<p>It mentions stuff like <a href="https://github.com/mageekguy/atoum" rel="noreferrer">Atoum</a> which calls its self: "A simple, modern and intuitive unit testing framework for PHP!"</p>
<hr />
<h3>Full disclosure</h3>
<p>I've originally written this answer Jan. 2011 where I had no affiliation with any PHP Testing project. Since then I became a contributor to PHPUnit.</p>
|
<p>when there are thousands functions to test at one go, phpunit is way to go, simple test is falling short as it web based. </p>
<p>I am still using simple web to for small scale test . </p>
<p>But both are good</p>
| 5,452
|
<p>Has anyone found a way to get gcc to build/install on SCO6? With 2.95 and 4.3 I get to the point where it needs to use (2.95) or find (4.3) the assembler and that's where it fails.</p>
<p>If anyone has figured this out I would appreciate the info!</p>
<p>Thanks</p>
|
<p>I have came across to the same error message. After digging for a while, found out that one can supply xsd files in addition to wsdl file. So included/imported .xsd files in addition to .wsdl at the end of the wsdl command as follows:</p>
<blockquote>
<p>wsdl.exe myWebService.wsdl myXsd1.xsd myType1.xsd myXsd2.xsd ...</p>
</blockquote>
<p>Wsdl gave some warnings but it did create an ok service interface.</p>
|
<p>In case someone hits this wall, here is what caused the error in my case:</p>
<p>I have an operation:</p>
<pre><code><wsdl:operation name="FormatReport">
<wsdl:documentation>Runs a report, which is returned as the response</wsdl:documentation>
<wsdl:input message="FormatReportRequest" />
<wsdl:output message="FormatReportResponse" />
</wsdl:operation>
</code></pre>
<p>which takes an input:</p>
<pre><code><wsdl:message name="FormatReportRequest">
<wsdl:part name="parameters" element="reporting:FormatReportInput" />
</wsdl:message>
</code></pre>
<p>and another operation:</p>
<pre><code><wsdl:operation name="FormatReportAsync">
<wsdl:documentation>Creates and submits an Async Report Job to be executed asynchronously by the Async Report Windows Service.</wsdl:documentation>
<wsdl:input message="FormatReportAsyncRequest" />
<wsdl:output message="FormatReportAsyncResponse" />
</wsdl:operation>
</code></pre>
<p>taking an input:</p>
<pre><code> <wsdl:message name="FormatReportAsyncRequest">
<wsdl:part name="parameters" element="reporting:FormatReportInputAsync" />
</wsdl:message>
</code></pre>
<p>And the input elements are instances of two types:</p>
<pre><code><xsd:element name="FormatReportInput" type="reporting:FormatReportInputType"/>
<xsd:element name="FormatReportInputAsync" type="reporting:FormatReportAsyncInputType"/>
</code></pre>
<p>Here is the catch - the <code>reporting:FormatReportAsyncInputType</code> type extends (derives from) the <code>reporting:FormatReportInputType</code> type. That's what seems to confuse the tool and cause the "These members may not be derived." error. You can go around that following teh suggestion in the accepted answer.</p>
| 10,304
|
<p>I'm trying to use <strong>NIS</strong> for authentication on a st of machines. I had to change one of the user ID numbers for a user account on the NIS server (I changed the userid for <code>username</code> from 500 to 509 to avoid a conflict with a local user account with id 500 on the clients). The problem is that it has not updated properly on the client. </p>
<p>In particular, if I do <code>ypcat passwd | grep username</code>, I get the up-to-date info:</p>
<pre><code>username:*hidden*:509:509:User Name:/home/username:/bin/bash
</code></pre>
<p>But if I do, <code>ypmatch username passwd</code>, it says:</p>
<pre><code>username:*hidden*:500:500:User Name:/home/username:/bin/bash
</code></pre>
<p>This means that when the user logs onto one of the clients, it has the wrong userid, which causes all sorts of problems. I've done <code>"cd /var/yp; make"</code> on the server, and <code>"service ypbind restart"</code> on the client, but that hasn't fixed the problem. Does anybody know what would be causing this and how I can somehow force a refresh on the client? (I'm running Fedora 8 on both client and server).</p>
|
<p>John O pointed me in the right direction. </p>
<p>He is right. If you set "files: 0" in /etc/ypserv.conf, you can get ypserv to not cache files. If you have to restart ypserv after each make, this is the problem.</p>
<p>The real solution is to look in /var/log/messages for this error: </p>
<pre><code>ypserv[]: refused connect from 127.0.0.1 to procedure ypproc_clear (,;0)
</code></pre>
<p>makedbm -c means: send YPPROC_CLEAR to the local ypserv. The error message in the log means that CLEAR message is getting denied. You need to add 127.0.0.1 to /var/yp/securenets. </p>
|
<p>hmm, you're not supposed to have to restart the ypserver to have updates take effect; the <em>make</em> in /var/yp ought to do the trick. you might want to check the Makefile in /var/yp to be sure it's triggering on the right conditions (namely, passwd.by* should check the timestamp on /etc/passwd in some fashion, versus its current table. the process used to go through a passwd.time rule on the NIS server i ran, back in the dark ages). killing and restarting your nis server can have funky effects on (particularly non-linux) clients, so be careful doing it willy-nilly.</p>
| 5,268
|
<p>We have been using the Client Access ODBC drivers when accessing AS/400 data from our .net applications and SQL DTS/SSIS packages. Are there third party drivers that provide better performance or functionality?</p>
|
<p>Our company is using the same Client Access drivers. As far as we know there are no other ones available. One issue we ran into last year was that there were no 64-bit drivers available so our servers that have applications connecting to the AS/400 must be 32-bit.</p>
|
<p>I'm not sure if it's better performance but a quick google turns up <a href="http://www.hitsw.com/products_services/sql400/odbc400/odbc400.html" rel="nofollow noreferrer">Hit ODBC/400</a>.</p>
| 38,014
|
<p>I have a HTML table that's generated in a JSP by the displaytag tag library. I would like to suppress any zeros that appear in the table, i.e. they should be replaced by a blank cell. Is there any straightforward way to achieve this?</p>
|
<p>I discovered that this can be achieved using a custom implementation of ColumnDecorator.</p>
<pre><code>public class SuppressZeroDecorator implements DisplaytagColumnDecorator {
/* (non-Javadoc)
* @see org.displaytag.decorator.DisplaytagColumnDecorator#decorate(java.lang.Object, javax.servlet.jsp.PageContext, org.displaytag.properties.MediaTypeEnum)
*/
public Object decorate(Object rowObject, PageContext pageContext, MediaTypeEnum mediaType) {
if (rowObject != null && rowObject.toString().trim().equals("0")) {
return null;
}
return rowObject;
}
}
</code></pre>
<p>The decorator should be declared for each column in the JSP like this:</p>
<pre><code><display:column property="age" title="Age" decorator="com.example.ZeroColumnDecorator" />
</code></pre>
|
<p>To my knowledge there isn't an "straightforward" way of handling this. The only data-related config property is whether to display nulls or not. </p>
<p>You're better off handling this before the data gets to to the displaytag tag. Perhaps in the servlet that provides the data or a view helper class.</p>
| 41,181
|
<p>Basically what I want to do it this: a pdb file contains a location of source files (e.g. <code>C:\dev\proj1\helloworld.cs</code>). Is it possible to modify that pdb file so that it contains a different location (e.g. <code>\more\differenter\location\proj1\helloworld.cs</code>)?</p>
|
<p>You can use the source indexing feature of the Debugging Tools for Windows, which will save references to the appropriate revisions of the files in your source repository as an alternate stream in the PDB file.</p>
|
<p>It is certainly possible, as On Freund has already pointed out.
But if it is only so that the sources can be located and loaded during debugging, then a better way would be to set the source path correspondingly. Once set in a debugger, it will preemt all hard coded paths inside PDBs.</p>
<p>
In windbg (for instance):
<blockquote>
.srcpath+ path_to_source_root
</blockquote>
or this (in case you're debugging remotely):
<blockquote>
.lsrcpath+ path_to_source_root
</blockquote>
</p>
| 4,763
|
<p>I usually hate posting these types of questions as normally I find that the best way to really learn is to figure out the answer yourself. </p>
<p>However, I need an answer to this question really quickly as I have a client who can't run her business due to this problem.</p>
<p>Yesterday my ASP.NET host provider moved my application from a server running .NET 1.1 to one running .NET 1.1 and 2.0. My problem is that when I test the move the main site page (Default.aspx) will not load </p>
<p><strong>"Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.</strong> </p>
<p><strong>Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."</strong></p>
<p><strong>[SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +59
System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint) +147
System.Net.HttpRequestCreator.Create(Uri Uri) +26
System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) +298
System.Net.WebRequest.Create(Uri requestUri) +28
System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri uri) +30
System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest(Uri uri) +12
System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri uri) +4
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +52
PilatesPlusDublin.PilatesPlusDublinws.PilatesPlus.InsertException(String sModuleName, String sException, Int32 iUserID) +97
PilatesPlusDublin.MainDefault.Page_Load(Object sender, EventArgs e) +144
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.maindefault_aspx.ProcessRequest(HttpContext context) +4
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64"</strong></p>
<p>If WebPermission isn't available at the hosting site, how do I configure my site to allow access to the page? Is there some tags that need to be put into the web.config? Note - we have no access to machine.config or any other IIS settings. </p>
<p>I understand that people hate reading and answering these types of question but any help on what I, or my hosting site need to do to fix this would be appreciated enormously </p>
|
<p>Not sure if this will help, but I once had a client with the same type of problem. Their webhosting company made some changes, resulting in their website throwing similar kinds of errors. Managed to get things working again by adding the following just inside the System.Web section in web.config:</p>
<pre><code><trust level="Full" />
</code></pre>
<p>If this doesn't solve your problem and the webhosting can't fix things on their until the new year, I'd seriously consider switching hosting providers.</p>
|
<p>Is your web application calling a web service or accessing external web sites? If so, you might need to talk with your hosting provider and ask for the URI to be added to the list of allowed connection endpoints.</p>
| 30,500
|
<p>I'm writing a small tool in C# which will need to send and receive data to/from a website using POST and json formatting. I've never done anything like this before in C# (or any language really) so I'm struggling to find some useful information to get me started.</p>
<p>I've found some information on the WebRequest class in C# (specifically from <a href="http://msdn.microsoft.com/en-us/library/debx8sh9.aspx" rel="noreferrer">here</a>) but before I start diving into it, I wondered if this was the right tool for the job.</p>
<p>I've found plenty of tools to convert data into the json format but not much else, so any information would be really helpful here in case I end up down a dead end.</p>
|
<p>WebRequest and more specifically the HttpWebRequest class is a good starting point for what you want to achieve. To create the request you will use the WebRequest.Create and cast the created request to an HttpWebRequest to actually use it. You will then create your post data and send it to the stream like:</p>
<pre><code>HttpWebRequest req = (HttpWebRequest)
WebRequest.Create("http://mysite.com/index.php");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
string postData = "var=value1&var2=value2";
req.ContentLength = postData.Length;
StreamWriter stOut = new
StreamWriter(req.GetRequestStream(),
System.Text.Encoding.ASCII);
stOut.Write(postData);
stOut.Close();
</code></pre>
<p>Similarly you can read the response back by using the GetResponse method which will allow you to read the resultant response stream and do whatever else you need to do. You can find more info on the class at:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx</a></p>
|
<p>in 3.5 there is a built-in jsonserializer. The webrequest is the right class your looking for.</p>
<p>A few examples:</p>
<ul>
<li><a href="https://web.archive.org/web/20200925065333/http://geekswithblogs.net/JuanDoNeblo/archive/2007/10/24/json_in_aspnetajax_part2.aspx" rel="nofollow noreferrer">Link</a></li>
<li><a href="http://dev.aol.com/blog/markdeveloper/ShareFileWithNETFramework" rel="nofollow noreferrer">http://dev.aol.com/blog/markdeveloper/ShareFileWithNETFramework</a></li>
<li><a href="https://web.archive.org/web/20200919002259/http://geekswithblogs.net/JuanDoNeblo/archive/2007/10.aspx" rel="nofollow noreferrer">Link</a></li>
</ul>
| 11,667
|
<p>I've got some code that resizes an image so I can get a scaled chunk of the center of the image - I use this to take a <code>UIImage</code> and return a small, square representation of an image, similar to what's seen in the album view of the Photos app. (I know I could use a <code>UIImageView</code> and adjust the crop mode to achieve the same results, but these images are sometimes displayed in <code>UIWebViews</code>).</p>
<p>I've started to notice some crashes in this code and I'm a bit stumped. I've got two different theories and I'm wondering if either is on-base.</p>
<p>Theory 1) I achieve the cropping by drawing into an offscreen image context of my target size. Since I want the center portion of the image, I set the <code>CGRect</code> argument passed to <code>drawInRect</code> to something that's larger than the bounds of my image context. I was hoping this was Kosher, but am I instead attempting to draw over other memory that I shouldn't be touching?</p>
<p>Theory 2) I'm doing all of this in a background thread. I know there are portions of UIKit that are restricted to the main thread. I was assuming / hoping that drawing to an offscreen view wasn't one of these. Am I wrong?</p>
<p>(Oh, how I miss <code>NSImage's drawInRect:fromRect:operation:fraction:</code> method.)</p>
|
<p>Update 2014-05-28: I wrote this when iOS 3 or so was the hot new thing, I'm certain there are better ways to do this by now, possibly built-in. As many people have mentioned, this method doesn't take rotation into account; read some additional answers and spread some upvote love around to keep the responses to this question helpful for everyone.</p>
<p>Original response:</p>
<p>I'm going to copy/paste my response to the same question elsewhere:</p>
<p>There isn't a simple class method to do this, but there is a function that you can use to get the desired results: <code>CGImageCreateWithImageInRect(CGImageRef, CGRect)</code> will help you out.</p>
<p>Here's a short example using it:</p>
<pre><code>CGImageRef imageRef = CGImageCreateWithImageInRect([largeImage CGImage], cropRect);
// or use the UIImage wherever you like
[UIImageView setImage:[UIImage imageWithCGImage:imageRef]];
CGImageRelease(imageRef);
</code></pre>
|
<p>I wasn't satisfied with other solutions because they either draw several time (using more power than necessary) or have problems with orientation. Here is what I used for a scaled square croppedImage from a UIImage * image.</p>
<pre><code>CGFloat minimumSide = fminf(image.size.width, image.size.height);
CGFloat finalSquareSize = 600.;
//create new drawing context for right size
CGRect rect = CGRectMake(0, 0, finalSquareSize, finalSquareSize);
CGFloat scalingRatio = 640.0/minimumSide;
UIGraphicsBeginImageContext(rect.size);
//draw
[image drawInRect:CGRectMake((minimumSide - photo.size.width)*scalingRatio/2., (minimumSide - photo.size.height)*scalingRatio/2., photo.size.width*scalingRatio, photo.size.height*scalingRatio)];
UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
</code></pre>
| 19,225
|
<p>For example, if I have:</p>
<p><div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur urna felis, convallis quis, placerat in, elementum quis, libero. Nam quis lacus. Vivamus rhoncus quam et metus. Praesent et velit eget sem vestibulum volutpat. Integer sed risus. Integer quis libero id diam bibendum luctus. Donec eleifend. Curabitur ut sem. Praesent at est ac sem rhoncus interdum. Etiam arcu nulla, molestie dictum, mollis sed, imperdiet sit amet, neque. Fusce at nibh sit amet mi eleifend aliquam. Nunc tristique scelerisque risus. Praesent et velit id magna volutpat volutpat.</div></p>
<p>...and then it's loaded in the browser and I'm hovering my mouse over various words, is there any reasonable way to detect which word is being hovered over? Any unreasonable way?</p>
|
<p>The unreasonable way involves calculating from the x,y coordinates of the mouse and then counting in an internal map of the paragraph. This will of course break when the next user uses a different font/size.</p>
<p>Look up those annoying intellitag ad popups that come when you rollover a keyword. You will notice that they are added after the page has loaded by a javascript that reads across every word and replaces important ones with surrounded spans.</p>
|
<p>I don't think it's possible. You'd have to surround each word in some kind of identifiable tag like a span. </p>
| 42,545
|
<p>I want to make some prints of pressure resistants. I am currently trying to print a simple cylinder to find the best parameters to make my prints airtight (by airtight I mean, it needs to resist to 10 bar).</p>
<p>Here is the test model that I have made for this:</p>
<p><a href="https://i.stack.imgur.com/IQyNO.png" rel="nofollow noreferrer" title="Screenshot of a model for a pressure resistant"><img src="https://i.stack.imgur.com/IQyNO.png" alt="Screenshot of a model for a pressure resistant" title="Screenshot of a model for a pressure resistant" /></a></p>
<p>Here are the parameters that I have changed in Cura:</p>
<ul>
<li>layer height: 0.1 mm</li>
<li>infill : 100 %</li>
<li>print temp: 250 °C (high temp to make the layers stick between them)</li>
<li>wall line count: 5</li>
<li>infill overlap: 40 %</li>
<li>flow: 115 %</li>
</ul>
<p>But all these changes in Cura don't give good results for ABS. It's not even airtight at 2.5 bar:</p>
<p><a href="https://i.stack.imgur.com/rt0B8.jpg" rel="nofollow noreferrer" title="Photo of pressure resistant under water producing bubbles; not airtight"><img src="https://i.stack.imgur.com/rt0B8.jpg" alt="Photo of pressure resistant under water producing bubbles; not airtight" title="Photo of pressure resistant under water producing bubbles; not airtight" /></a></p>
<p>And here is a mid-cut of the print :</p>
<p><a href="https://i.stack.imgur.com/EkNP6.jpg" rel="nofollow noreferrer" title="Photo of pressure resistant cut in two to show internal structure"><img src="https://i.stack.imgur.com/EkNP6.jpg" alt="Photo of pressure resistant cut in two to show internal structure" title="Photo of pressure resistant cut in two to show internal structure" /></a></p>
<p>Do you have any ideas/suggestions to have better results? Can it be from the ABS itself? There is a sort of white powder between the layers, is this normal for ABS? Should I try using PETG? What could I change in my parameters?</p>
|
<p>This is going to be hard. Even holding a vacuum is hard (I've tried it and not succeeded). I'm not sure what the mechanism of air molecules getting thru the print is - whether it's defects in inter-layer bonding, defects at seams, imperfect mating with the fitting, or even permeability of the plastic itself. It might not actually be existing flaws in the print, but rather the high pressure being a stronger force than the bonded layers can withstand, essentially ripping the layers apart from the weakest point until the pressure can discharge through the opening produced.</p>
<p>If using ABS, you might try an acetone bath followed by a long period of trying or use of vacuum chamber to quickly remove the solvent, if you can stand some possible part deformation. This would tend to fill any gaps. Coating with low-viscosity CA glue (Loctite 420 or equivalent) might be a better version of this approach, as the solvent will both attack the ABS and deliver fill material.</p>
<p>In principle PET (maybe also PETG, but PET is preferable anyway if you can get it) should be a suitable material for pressure vessels, as it's what's used for soda bottles at comparable pressure, but those are blown from a single piece, not fused together with seams.</p>
<p>At some point I will attempt this again, and will update my answer if I have any findings that contribute to your question.</p>
|
<h2>Not without postprocessing</h2>
<p>FDM is pretty much welding plastic to plastic. Many many layers. Each of them is a potential breaking point, a corner for stress to arise and break the print.</p>
<h2>Easy with a hollow body</h2>
<p>Printing a hollow item that can be filled with resin is comparatively easy. Once filled with a monolithic curing resin (epoxy), that will take the pressure much better and seal it fully.</p>
| 2,198
|
<p>Assume my objects are in perfect working order (i.e. TDD makes me think they work).</p>
<p>I have a list that I create like this (except indented properly):</p>
<pre><code>var result = from v in vendors
from p in v.Products
orderby p.Name
select p;
</code></pre>
<p>This works - I get all products from all vendors.</p>
<p>Now I have a list of conditions, built up at runtime by the user. Let's apply them:</p>
<pre><code>foreach (Attribute a in requiredAttributes)
{
result = result.Where(p => p.Attributes.Contains(a));
}
</code></pre>
<p>This may be primitive, but I thought it'd work. However, after this foreach loop is finished, when you enumerate "result" it will contain all products that has the LAST Attribute of the requiredAttributes collection in it's Attributes property (also a collection).</p>
<p>To me, this smells like "a" is overwritten somewhere with each trip trough the loop, and only the last one applies.</p>
<p>Short of somehow writing an extension method to IEnumerable called ContainsAll(IEnumerable) or something to that effect, how can I achieve what I want, which is basically a logical AND, giving me only those products that has ALL the required attributes?</p>
|
<p>(Edited for clarity.)</p>
<p>The problem is the foreach loop, and the fact that the "a" variable is being captured and then changed each time. Here's a modification which will work, by effectively introducing a "new" variable for each iteration of the loop, and capturing that new variable.</p>
<pre><code>foreach (Attribute a in requiredAttributes)
{
Attribute copy = a;
result = result.Where(p => p.Attributes.Contains(copy));
}
</code></pre>
<p>Omer's solution is a cleaner one if you can use it, but this may help if your real code is actually more complicated :)</p>
<p>EDIT: There's more about the issue in <a href="http://csharpindepth.com/Articles/Chapter5/Closures.aspx" rel="noreferrer">this closures article</a> - scroll down to "Comparing capture strategies: complexity vs power".</p>
|
<pre><code>var result = from v in vendors
from p in v.Products
where requiredAttributes.All(a => p.Attributes.Contains(a))
orderby p.Name
select p;
</code></pre>
<p>HTH.</p>
| 23,081
|
<p>I've seen a few examples on how to do build deployment, however I have something unique that I'd like to do:</p>
<ol>
<li>Deploy the build to a folder that has the build number (eg. Project\Builds\8423)</li>
<li>Alter the version number in the .NET AssmblyInfo.cs to match the build number</li>
</ol>
<p>Has anyone done this before with .NET projects using NAnt + CruiseControl.net?</p>
|
<p>Deploying a build to a folder with the build number is pretty straightforward. <a href="http://confluence.public.thoughtworks.org/display/CCNET/NAnt+Task" rel="nofollow noreferrer">CruiseControl.NET's NAnt task</a> automatically passes a number of properties to your NAnt script. The <em>CCNetLabel</em> property is the one you'd use to create your deployment directory. There's actually a slightly out of date example NAnt script in the CruiseControl.NET documentation that does just that. Here's a nicer version of it:</p>
<pre><code><target name="publish">
<if test="${not property::exists('CCNetLabel')}">
<fail message="CCNetLabel property not set, so can't create labelled distribution files" />
</if>
<property name="publishDirectory" value="D:\Public\Project\Builds\${CCNetLabel}" />
<mkdir dir="${publishDirectory}" />
<copy todir="${publishDirectory}">
<fileset basedir="${buildDirectory}\bin">
<include name="*.dll" />
</fileset>
</copy>
</target>
</code></pre>
<p>As far as versioning your binaries goes, I find the following approach much cleaner and easier than trying to alter your AssemblyInfo.cs files. Basically I create a CommonAssemblyInfo.cs file that lives outside of any projects, in the same directory as your solution file. This file includes things that are common to all assemblies I'm building, like company name, copyright info, and of course - version. This file is <a href="http://dotnettipoftheday.org/tips/linking_file_in_visual_studio.aspx" rel="nofollow noreferrer">linked</a> in each project in Visual Studio, so each project includes this info (along with a much smaller AssemblyInfo.cs file that includes assembly-specific info like assembly title).</p>
<p>When projects are built locally, either through Visual Studio or NAnt, that CommonAssemblyInfo.cs file is used. However, when projects are built by CruiseControl.NET, I use NAnt to replace that file via the <a href="http://nant.sourceforge.net/release/latest/help/tasks/asminfo.html" rel="nofollow noreferrer"><code><asminfo></code></a> task. Here's what the NAnt script looks like:</p>
<pre><code><target name="version">
<property name="commonAssemblyInfo" value="${buildDirectory}\CommonAssemblyInfo.cs" />
<!-- If build is initiated manually, copy standard CommonAssemblyInfo.cs file. -->
<if test="${not property::exists('CCNetLabel')}">
<copy file=".\src\CommonAssemblyInfo.cs" tofile="${commonAssemblyInfo}" />
</if>
<!-- If build is initiated by CC.NET, create a custom CommonAssemblyInfo.cs file. -->
<if test="${property::exists('CCNetLabel')}">
<asminfo output="${commonAssemblyInfo}" language="CSharp">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
</imports>
<attributes>
<attribute type="AssemblyCompanyAttribute" value="My Company" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © 2008 My Company" />
<attribute type="AssemblyProductAttribute" value="My Product" />
<attribute type="AssemblyVersionAttribute" value="1.0.0.${CCNetLabel}" />
<attribute type="AssemblyInformationalVersionAttribute" value="1.0.0.${CCNetLabel}" />
</attributes>
<references>
<include name="System.dll" />
</references>
</asminfo>
</if>
</target>
<target name="build-my-project" depends="version">
<csc target="library" output="${buildDirectory}\bin\MyProject.dll">
<sources>
<include name=".\src\MyProject\*.cs"/>
<include name=".\src\MyProject\**\*.cs"/>
<include name="${commonAssemblyInfo}"/>
</sources>
</csc>
</target>
</code></pre>
<p>Note where the <em>AssemblyVersionAttribute</em> and <em>AssemblyInformationalVersionAttribute</em> values are set in the <em>version</em> target. The <em>CCNetLabel</em> property is inserted into the version numbers. For added benefit, you could use a CruiseControl.NET plugin like the previously mentioned <a href="http://code.google.com/p/svnrevisionlabeller/" rel="nofollow noreferrer">SvnRevisionLabeller</a>. Using that, we get builds with labels like "2.1.8239.0", where the "8239" corresponds to the Subversion revision number we're building from. We dump this build number directly into our <em>AssemblyVersionAttribute</em> and <em>AssemblyInformationalVersionAttributes</em>, and our build numbers and the version numbers on our assemblies can all be easily traced back to a specific revision in our version control system.</p>
|
<p>I agree with BumperBox, a separate assembly to do the heavy(?) lifting of incrementing the build number is the route I took a couple of years ago, too. It has the advantage of being able to cope with other external factors, too. For example, you might want to increment the release or build numbers if a certain criteria exists within a config file.</p>
| 18,946
|
<p>Is it possible to check out subdirectories of a repository in Git?</p>
<p>Imagine I am setting up a new WordPress installation. I will create two new directories for my plugin and theme customization:</p>
<ul>
<li><code>wordpress/wp-content/plugins/myplugins/</code> </li>
<li><code>wordpress/wp-content/themes/mytheme/</code></li>
</ul>
<p>I want to maintain these directories via Git. In Subversion, I would accomplish this by having <code>trunk/myplugins/</code> and <code>trunk/mytheme/</code> directories and checking out subdirectories. Does Git have a way to accomplish the same task using a single repository?</p>
<p>I could just be missing the boat on some Git paradigm, as a long time SVN user with little exposure to Git.</p>
<p><strong>Edit:</strong> <a href="https://stackoverflow.com/questions/466303/git-branches-with-completely-different-content">Multiple branches</a> storing different content is an interesting way to handle this.</p>
|
<p><a href="http://schacon.github.io/git/git-read-tree.html#_sparse_checkout" rel="noreferrer">Sparse checkouts</a> are <a href="http://schacon.github.io/git/RelNotes/1.7.0.txt" rel="noreferrer">now in Git 1.7</a>.</p>
<p>Also see the question “<a href="https://stackoverflow.com/q/4114887/578288">Is it possible to do a sparse checkout without checking out the whole repository first?</a>”.</p>
<p>Note that sparse checkouts still require you to <em>download</em> the whole repository, even though some of the files Git downloads won't end up in your working tree.</p>
|
<p><strong>There is an inspiration here. Just utilize <code>shell regex</code> or <code>git regex</code>.</strong></p>
<pre><code>git checkout commit_id */*.bat # *.bat in 1-depth subdir exclude current dir, shell regex
git checkout commit_id '*.bat' # *.bat in all subdir include current dir, git regex
</code></pre>
<p><strong>Use quotation to escape shell regex interpretation and pass wildcards to git.</strong></p>
<p>The first one is not recursive, only files in 1-depth <code>subdir</code>. But the second one is recursive.</p>
<p><strong>As for your situation, the following may be enough.</strong></p>
<pre><code>git checkout master */*/wp-content/*/*
git checkout master '*/wp-content/*'
</code></pre>
<p>Just hack the lines as required.</p>
| 21,723
|
<p>I have been working with hibernate/JPA on JBoss for some months now and have one question that I can't find an answer or solution for.</p>
<p>It seems like when creating new entity beans I'm not able to do a query before I at least have called EntityManager.persist(entityBean), or else I get the following error:</p>
<p><code>TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing</code></p>
<p>An example:</p>
<pre><code>Job job = new Job();
Collection<Task> tasks = job.getTasks();
//entityManager.persist(job);
ActionPlan actionPlan = (ActionPlan) entityManager.createNamedQuery("ActionPlan.findByCommand").
setParameter("type", RunOperation.Install).getSingleResult();
Task task = Task.getTask(actionPlan);
task.setActionPlan(actionPlan);
tasks.add(task);
task.setJob(job);
</code></pre>
<p>My problem is that I can't call createNamedQuery without first persisting 'job' (the line that is commented out). ActionPlan has a relation to Job, but the NamedQuery (findByCommand) does not join on Job. What bothers me is that I need to persist Job in order to query the database, when the new created Job is not even interesting in this context.<br>
Moving the call to persist() to the end of the snippet yields the above mentioned error.</p>
<p>I'm aware that the object I'm working on is not persisted, but persisting makes it impossible to rollback if an error occurs.</p>
<p>I believe there is a solution for this, so if someone has the answer I would be very thankful. What am I missing?</p>
|
<p>It seems logical that you cannot query for something which is not in the database yet, no? What you can do is to start using transactions. In a simple case your session will have one transaction which will be open until you close your session. At that moment transaction will be commited and all your changes will be persisted. All you need is to rollback your transaction in case of error.</p>
<p>P.S. <a href="http://docs.jboss.org/hibernate/core/3.6/javadocs/org/hibernate/Session.html" rel="nofollow noreferrer">Here at the bottom</a> you can find "A typical transaction should use the following idiom". </p>
<pre><code>Session sess = factory.openSession();
Transaction tx;
try {
tx = sess.beginTransaction();
//do some work
...
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
sess.close();
}
</code></pre>
|
<p>I am aware that I can't query what has not yet been persisted - and this is not the case either. What I want to find is other Entity beans. Not just the same type, but any type of the Entity beans that I have. And then I get the TransientObjectException.</p>
<p>Did I mention I use JBoss? I believe that using J2EE and JPA the server is in control of my transactions, and the last I want to do is interfere with it?! So for me, besides using requiresNew, etc. I don't mess with transactions - the server does.</p>
<p>Maybe I should move the hibernate tag, because actually I'm using JPA - JBoss uses hibernate. So please relate to that in any code examples.</p>
| 35,931
|
<p>When using <code>call_user_func_array()</code> I want to pass a parameter by reference. How would I do this. For example</p>
<pre><code>function toBeCalled( &$parameter ) {
//...Do Something...
}
$changingVar = 'passThis';
$parameters = array( $changingVar );
call_user_func_array( 'toBeCalled', $parameters );
</code></pre>
|
<p>To pass by reference using <code>call_user_func_array()</code>, the parameter in the array must be a reference - it does not depend on the function definition whether or not it is passed by reference. For example, this would work:</p>
<pre><code>function toBeCalled( &$parameter ) {
//...Do Something...
}
$changingVar = 'passThis';
$parameters = array( &$changingVar );
call_user_func_array( 'toBeCalled', $parameters );
</code></pre>
<p>See the notes on the <a href="http://au2.php.net/manual/en/function.call-user-func-array.php" rel="noreferrer"><code>call_user_func_array()</code> function documentation</a> for more information.</p>
|
<p>Except you are using deprecated functionality here. You'll generate a warning in PHP5 making it less than perfect.</p>
<blockquote>
<p>Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of runtime function name. If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in ...</p>
</blockquote>
<p>Unfortunately, there doesn't appear to be any other option as far as I can discover.</p>
| 37,674
|
<p>I know I can specify one for each form, or for the root form and then it'll cascade through to all of the children forms, but I'd like to have a way of overriding the default Java Coffee Cup for all forms even those I might forget.</p>
<p>Any suggestions?</p>
|
<p>You can make the root form (by which I assume you mean <code>JFrame</code>) be your own subclass of <code>JFrame</code>, and put standard functionality in its constructor, such as:</p>
<pre><code>this.setIconImage(STANDARD_ICON);
</code></pre>
<p>You can bundle other standard stuff in here too, such as memorizing the frame's window metrics as a user preference, managing splash panes, etc.</p>
<p>Any new frames spawned by this one would also be instances of this <code>JFrame</code> subclass. The only thing you have to remember is to instantiate your subclass, instead of <code>JFrame</code>. I don't think there's any substitute for remembering to do this, but at least now it's a matter of remembering a subclass instead of a <code>setIconImage</code> call (among possibly other features).</p>
|
<p>Extend the JDialog class (for example name it MyDialog) and set the icon in constructor. Then all dialogs should extend your implementation (MyDialog).</p>
| 12,876
|
<p>How to convert last 3 digits of number into 0</p>
<p>example 3444678 to 3444000</p>
<p>I can do like </p>
<p>(int)(3444678/1000) * 1000= 3444000</p>
<p>But division and multiplication could be costly...</p>
<p>Any other solution????</p>
|
<p>You could try</p>
<pre><code>n - (n % 1000)
</code></pre>
<p>but the modulus operator might be as costly as a division. In any case, this sounds an awful lot like a micro-optimization. Is this really your bottleneck?</p>
|
<pre><code>int takeAway(int num)
{
for (int i = 1; i =< 3; i++)
{
num = num/10;
}
return num;
}
int addZeroes(int num)
{
for (int i = 1; i =< 3; i++)
{
num = num*10;
}
return num;
}
</code></pre>
<p>Then you just call takeAway then addZeroes. Couldn't be simpler!</p>
<p>I was tempted to add in an <strong>int temp = num</strong> and then use that but figured that would be too much, even for this code.</p>
| 36,784
|
<p>I have created a site, which parses XML files and display its content on the appropriate page. Is my site a dynamic web page or static web page?</p>
<p>How do dynamic and static web pages differ?</p>
<p>I feel it's dynamic, because I parse the content from xml files; initially i don't have any content in my main page..</p>
<p>What do you think about this, please explain it..</p>
|
<p>I would describe your pages as dynamic. "Static" usually means that the file sitting on the web server is delivered as-is to the user; since you're assembling the pages from data files, I'd call them dynamic even if you're not building in any dynamically-changing data.</p>
<p>I don't think this is a hard and fast definition though. If someone feels the page is static because it's assembled from static pages, that's another way to look at it.</p>
|
<p>Static web pages would be plain HTML content that are delivered. If you are processing any type of XML files at the server side and generating content accordingly, this is a dynamic page. Static pages change content when the page is actually edited & modified.</p>
<p>First result on Google if you had searched for it explains it. <a href="http://websiteowner.info/articles/pages/pagetypes.asp" rel="nofollow noreferrer">http://websiteowner.info/articles/pages/pagetypes.asp</a></p>
<p>Also, stating that static websites are not updated regularly is not correct. The web and HTML was around even before we started writing stuff in Perl & PHP. There are/were sites that had heavy traffic and were being modified manually.</p>
| 35,433
|
<p>I am using ASP.NET to transmit a .jar file. This code works perfectly on IE. However on Firefox the file downloads, corrupt. What is the best way to fix it? Below is the code I am using.</p>
<pre><code>private void TransferFile()
{
try
{
string filePath = Server.MapPath("SomeJarFIle.jar");
FileInfo file = new FileInfo(filePath);
if (file.Exists)
{
// Clear the content of the response
//Response.ClearContent();
Response.Clear();
// LINE1: Add the file name and attachment, which will force the open/cance/save dialog to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
// Add the file size into the response header
Response.AddHeader("Content-Length", file.Length.ToString());
// Set the ContentType
Response.ContentType = ReturnExtension(file.Extension.ToLower());
// Write the file into the response
//Response.TransmitFile(file.FullName);
Response.WriteFile(file.FullName);
// End the response
Response.End();
}
else
{
this.Response.Write("Error in finding file. Please try again.");
this.Response.Flush();
}
}
catch (Exception ex)
{
this.Response.Write(string.Format("Error: {0}", ex.Message));
}
}
private string ReturnExtension(string fileExtension)
{
switch (fileExtension)
{
case ".htm":
case ".html":
case ".log":
return "text/HTML";
case ".txt":
return "text/plain";
case ".doc":
return "application/ms-word";
case ".tiff":
case ".tif":
return "image/tiff";
case ".asf":
return "video/x-ms-asf";
case ".avi":
return "video/avi";
case ".zip":
return "application/zip";
case ".xls":
case ".csv":
return "application/vnd.ms-excel";
case ".gif":
return "image/gif";
case ".jpg":
case "jpeg":
return "image/jpeg";
case ".bmp":
return "image/bmp";
case ".wav":
return "audio/wav";
case ".mp3":
return "audio/mpeg3";
case ".mpg":
case "mpeg":
return "video/mpeg";
case ".rtf":
return "application/rtf";
case ".asp":
return "text/asp";
case ".pdf":
return "application/pdf";
case ".fdf":
return "application/vnd.fdf";
case ".ppt":
return "application/mspowerpoint";
case ".dwg":
return "image/vnd.dwg";
case ".msg":
return "application/msoutlook";
case ".xml":
case ".sdxl":
return "application/xml";
case ".xdp":
return "application/vnd.adobe.xdp+xml";
case ".jar":
return "application/java-archive";
default:
return "application/octet-stream";
}
}
</code></pre>
<p>UPDATE:</p>
<p>I added the type </p>
<pre><code>case ".jar":
return "application/java-archive";
</code></pre>
<p>And that did not fix the problem. If I zipped up the .jar file it was able to be transmitted fine.</p>
<p>I did notice when I tested againist my localhost the file was downloaded with no issues. However when I push it up to the web server is when I get the problem.</p>
|
<p>I don't see a case for ".jar" in the ReturnExtension() function (which I think might be better off named "ReturnMimetype"). Could that be the problem, or did you just forget to paste it in?</p>
<p>The mimetype for .jar is supposed to be <strong>application/java-archive</strong>. Details here: <a href="http://en.wikipedia.org/wiki/Jar-file" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Jar-file</a></p>
<p>I think this is the issue. I remember having the same type of problem when I transmitted a .docx file (which is actually a zip file with a different extension, as a .jar files). The download worked fine in IE, but Firefox corrupted it. The solution was to send the correct mimetype.</p>
|
<p>I only see two things, it doesn't appear you have a mime type for the .jar file extension.</p>
<p>Two I personally use writefile rather than transmit, but I'm not sure of the difference.</p>
| 25,317
|
<p>Does anybody know, if closures will be in Java 7? </p>
|
<p>At Devoxx 2008, <a href="http://java.dzone.com/articles/java-7-update-mark-reinhold-de" rel="nofollow noreferrer">Mark Reinhold made it clear</a> that closures <em>will not</em> be included in Java 7.</p>
<hr>
<p>Wait! Closures <em>will</em> be included in Java 7. Mark Reinhold <a href="http://blogs.oracle.com/mr/entry/closures" rel="nofollow noreferrer">announced this reversal</a> at Devoxx 2009.</p>
<hr>
<p>Belay that! Closures (<i>lambda expressions</i>) have been deferred until Java 8. Follow <a href="http://openjdk.java.net/projects/lambda/" rel="nofollow noreferrer">Project Lambda (JSR 335)</a> for more information.</p>
|
<p>Closure won't definitively be present in Java 7, but if you are looking for a lighter solution to have closure in java right now check out how they have been implemented in the lambdaj library:</p>
<p><a href="http://code.google.com/p/lambdaj/wiki/Closures" rel="nofollow noreferrer">http://code.google.com/p/lambdaj/wiki/Closures</a></p>
| 14,235
|
<p>I recently upgraded from Delphi 4 to Delphi 2009. With Delphi 4 I had been using <a href="http://web.archive.org/web/20001205122400/http://www.eccentrica.org/gabr/gpprofile/gpprofile.htm" rel="noreferrer">GpProfile by Primoz Gabrijelcic</a> as a profiler and <a href="http://web.archive.org/web/20031204135824/http://www.turbopower.com/products/sleuth/" rel="noreferrer">Memory Sleuth by Turbo Power</a> for memory analysis and leak debugging. Both worked well for me. But I now need new tools that will work with Delphi 2009. </p>
<p>The leader in Profiling/Analysis tools for Delphi by a wide margin is obviously <a href="http://www.automatedqa.com/products/aqtime/index.asp" rel="noreferrer">AQTime by AutomatedQA</a>. They recently even gobbled up <a href="http://www.scip.be/index.php?Page=ArticlesDelphi07&Lang=EN" rel="noreferrer">Memproof by Atanas Soyanov</a>, which I understood was an excellent and free memory analysis tool, and incorporated its functionality into AQTime. But AQTime is very expensive for an individual programmer. It actually costs more than the upgrade to Delphi 2009 cost!</p>
<p>So my question is: Are there other less expensive options to do profiling and memory analysis in current versions of Delphi that you are happy with and recommend, or should I bite the bullet and pay the big bucks for AQTime?</p>
<hr>
<p>Addenum: It seems the early answerers are indicating that the FastMM manager already included in Delphi is very good for finding memory leaks.</p>
<p>So then, are there any good alternatives for source code profiling? </p>
<p>One I'm curious about is <a href="http://www.prodelphi.de/indexpd.htm" rel="noreferrer">ProDelphi by Michael Adolph</a> which is less than one sixth the cost of AQTime. Do you use it? Is AQTime worth paying six times as much?</p>
<hr>
<p>Addenum 2: I downloaded trial versions of both AQTime and ProDelphi.</p>
<p>AQTime was a bit overwhelming and a little confusing at first. It took a few hours to find some of the tricks needed to hook it up. </p>
<p>ProDelphi was very much like the GpProfile that I was used to. But its windows are cluttered and confusing and it's not quite as nice as GpProfile.</p>
<p>To me the big differences seem to be:</p>
<ol>
<li><p>ProDelphi changes your code. AQTime does not. Changing code may corrupt your data if something goes wrong, but my experience with GpProfile was that it never happened to me. Plus one for AQTime.</p></li>
<li><p>ProDelphi requires you turn optimization off. But what you want to profile is your program with optimization on, the way it will be run. Plus one for AQTime.</p></li>
<li><p>ProDelphi only can profile down to the function or procedure. AQTime can go down to individual lines. Plus 2 for AQTime.</p></li>
<li><p>ProDelphi has a free version that will profile 20 routines, and its pro version costs less than $100 USD. AQTime is $600 USD. Plus 4 for ProDelphi.</p></li>
</ol>
<p>The score is now 4-4. What do you think?</p>
<hr>
<p>Addenum 3: Primoz Gabrijelcic is planning to get GpProfile working again. See his comments on some of the responses below. He on StackOverflow as <a href="https://stackoverflow.com/users/4997/gabr">Gabr</a>.</p>
<hr>
<p>Addenum 4: It seems like there may be a profiler solution after all. See <a href="https://stackoverflow.com/questions/291631/profiler-and-memory-analysis-tools-for-delphi/672554#672554">Andre's open source asmprofiler, described below</a>.</p>
|
<p>For the price, you cannot beat FastMM4 as a memory tracker. It's simple to use yet powerful and well integrated with Delphi.<br>
I guess that you know that, without downloading, installing or changing anything else, just putting this line</p>
<pre><code>ReportMemoryLeaksOnShutDown := True;
</code></pre>
<p>anywhere in your code, will enable basic reporting of memory leaks.<br>
If you need more like crash information, EurekaLog is a very good product that we use. MadExcept also has a good reputation... </p>
<p>For profiling specifically, we have AQTime. </p>
<p>As for gpProfile, you can try and bug <a href="https://stackoverflow.com/users/4997/gabr">gabr</a> on SO for an update... or go and <a href="http://gp.17slon.com/gpprofile/index.htm" rel="nofollow noreferrer">update gpProfile yourself as it is open source</a>. ;-)</p>
|
<p>The FastMM4 memory manager <a href="https://stackoverflow.com/questions/1701671/how-to-monitor-or-visualize-memory-fragmentation-of-a-delphi-application/1701917#1701917">mentioned in this older answer</a> ("<strong>How to monitor or visualize memory fragmentation of a delphi application</strong>") keeps a list of all allocations which can be queried at run time (and displayed in a grid using the included demo application). It does not exactly show which object leaks, as the statistics are per block size. But it can be useful for long-time monitoring of applications in production, for example servers or services. I am currently integrating it in a (commercial) web application server framework as the 'VisualMM' add-on.</p>
| 37,200
|
<p>My company unwittingly switched from cvs to subversion and now we're all wishing we had cvs back.
I know there's tools to migrate history and changes from cvs to svn and there's no equivalent to do the reverse.
Any suggestions or ideas on how to do this?</p>
|
<p>I originally added this as a comment to someone else's answer, but then realized that it was an answer, of sorts. I have done these sorts of transitions before, where there was no existing way to convert from one SCM system to another.</p>
<p>It's not rocket science to write a script that takes the list of commits from your SVN repository, and iterates through them one at a time, merging them into a newly-created CVS repository. Getting all the branches and tags exactly correct might be a bit more work, but if you want to just save revision history for a few branches, it should be pretty easy.</p>
<p>I'm also of the opinion that you won't really gain anything by switching back to CVS, but if you want to do so, then you'll likely be writing your own script. The "svn export" command will undoubtedly be useful in this endeavor.</p>
|
<p>the only 2 drawbacks of subversion I can think of users coming from CVS are</p>
<ul>
<li>the speed of checkouts over http(s)</li>
<li>the lack of modulaliases</li>
</ul>
<p>the first one can be solved by using svn(+ssh) which is the more comparable format as CVS uses its own protocol as well.
the second one is a little trickier, but can be emulated by svn:externals (which have their own nasty sideeffects)
If you encountered any other additional drawbacks, I am all ear..</p>
| 19,342
|
<p>I am working on a WPF application that opens and displays XPS documents. When the application closes, the specification is the application should delete the opened XPS document for clean up. However, when opening a certain XPS document, the application throws an exception that the file is still in use when it tries to delete it. It is a little weird because it only happens when opening a particular XPS document and only when you have moved beyond the first page. </p>
<p>Some of the codes I used are shown below:</p>
<p>For opening the XPS Document:</p>
<pre><code>DocumentViewer m_documentViewer = new DocumentViewer();
XpsDocument m_xpsDocument = new XpsDocument(xpsfilename, fileaccess);
m_documentViewer.Document = m_xpsDocument.GetFixedDocumentSequence();
m_xpsDocument.Close();
</code></pre>
<p>For navigating the XPS document:</p>
<pre><code>m_documentViewer.FirstPage();
m_documentViewer.LastPage();
m_documentViewer.PreviousPage();
m_documentViewer.NextPage();
</code></pre>
<p>For closing the DocumentViewer object and deleting the file:</p>
<pre><code>m_documentViewer.Document = null;
m_documentViewer = null;
File.Delete(xpsfilename);
</code></pre>
<p>It's all pretty basic and it works with the other documents that we tested. But with the particular XPS document, an exception pops up saying that the file to be deleted is still being used. </p>
<p>Is there something wrong or missing from my code? </p>
<p>Thanks!</p>
|
<p>Make the xpsDocument a member, then don't call close() on it :)</p>
|
<p><a href="http://blogs.msdn.com/junfeng/archive/2008/04/21/use-htrace-to-debug-handle-leak.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/junfeng/archive/2008/04/21/use-htrace-to-debug-handle-leak.aspx</a></p>
<p>You can figure out who holds the handle and the unmanaged stack using WinDbg</p>
<p>EDIT: And of course, you can also get the managed stack trace and poke around via the SOS extension (<a href="http://msdn.microsoft.com/en-us/library/bb190764.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb190764.aspx</a>)</p>
| 35,860
|
<p>I am looking for a good way to transfer non-trivial (10G > x >10MB) amounts of data from one machine to another, potentially over multiple sessions.</p>
<p>I have looked briefly at</p>
<ul>
<li>*ftp (sftp, tftp, ftp)</li>
<li>http</li>
<li>torrents (out because I will not have a seed network in general)</li>
<li>rsync (not sure if I can really adapt this to what I need)</li>
</ul>
<p>Are there any other protocols out there that might fit the bill a little better? Most of the above are not very fault tolerant in and of themselves, but rather rely on client/server apps to pick up the slack. At this stage I care much more about the protocol itself, rather than a particular client/server implementation that works well.</p>
<p>(And yea I know I can write my own over udp, but I'd prefer <em>almost anything else</em>!!) </p>
|
<p>I use rsync (over SSH) to transfer anything that I think might take more than a minute. </p>
<p>It's easy to rate-limit, suspend/resume and get progress reports. You can automate it with SSH keys. It's (usually) already installed (on *nix boxes, anyway).</p>
<p>Depending on what you need, rsync can probably adapt. If you're distributing to a lot of users, FTP/HTTP might be better for firewall concerns; but rsync is great for one-to-one or one-to-a-few transfers.</p>
|
<p>Well, HTTP is a good option, in that it supports restarting partial transfers by using <a href="http://en.wikipedia.org/wiki/Byte_serving" rel="nofollow noreferrer">byte ranges</a>. FTP or TFTP are good because you can get server software that's extremely simple to configure, rather than having to lock down something like an HTTP server.</p>
| 28,100
|
<p>Just could not get this one and googling did not help much either.. </p>
<p>First something that I know: Given a string and a regex, how to replace all the occurrences of strings that matches this regular expression by a replacement string ? Use the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#replaceAll(java.lang.String,%20java.lang.String)" rel="nofollow noreferrer">replaceAll()</a> method in the String class.</p>
<p>Now something that I am unable to do. The regex I have in my code now is [^a-zA-Z] and I know for sure that this regex is definitely going to have a range. Only some more characters might be added to the list. What I <em>need</em> as output in the code below is <strong>Worksheet+blah</strong> but what I get using replaceAll() is <strong>Worksheet++++blah</strong></p>
<blockquote>
<pre><code>String homeworkTitle = "Worksheet%#5_blah";
String unwantedCharactersRegex = "[^a-zA-Z]";
String replacementString = "+";
homeworkTitle = homeworkTitle.replaceAll(unwantedCharactersRegex,replacementString);
System.out.println(homeworkTitle);
</code></pre>
</blockquote>
<p>What is the way to achieve the output that I wish for? Are there any Java methods that I am missing here? </p>
|
<pre><code>[^a-zA-Z]+
</code></pre>
<p>Will do it nicely.</p>
<p>You just need a <a href="http://www.regular-expressions.info/repeat.html" rel="nofollow noreferrer">greedy quantifier</a> in order to match as many non-alphabetical characters you can, and replace the all match by one '+' (a - by default - greedy quantifier)</p>
<p>Note: <code>[^a-zA-Z]+?</code> would make the '+' quantifier lazy, and would have give you the same result than <code>[^a-zA-Z]</code>, since it would only have matched only one non-alphabetical character at a time.</p>
|
<pre><code>String unwantedCharactersRegex = "[^a-zA-Z]"
</code></pre>
<p>This matches a single non-letter. So each single non-letter is replaced by a +. You need to say "one or more", so try</p>
<pre><code>String unwantedCharactersRegex = "[^a-zA-Z]+"
</code></pre>
| 40,119
|
<p>I was writing some <strong>ASP.NET</strong> control when I came to the scenario where I needed to remove items from a list, only when they matched a certain condition.</p>
<p>The <code>RemoveAll</code> method of the generic <code>List</code> class does a good job, but removes <em>all</em> items that match the condition, specified by the predicate.</p>
<p>What if I want to only remove a certain number of items specifying the condition? What do you think is the best way to do this?</p>
|
<p>If you want to specify both a limit for number of items to remove and a condition to select the items to remove, you can use this approach:</p>
<pre><code>int limit = 30; // Suppose you want to remove 30 items at most
list.RemoveAll(item => ShouldIRemoveThis(item) && limit-- > 0);
</code></pre>
|
<p>Can you use LINQ? If so, you can just use the .Take() method and specify how many records you want (maybe as total - N).</p>
| 3,719
|
<p>I have a repair part that I need to print with ABS and I know that I have warping problems with ABS.</p>
<p>I'm now trying to mitigate this by printing a circle around my object and use more brim. You can consider this as a manually designed skirt, but I want the brim to be on both sides of the skirt.</p>
<p>However, when slicing the repair part with the ring, I get brim only outside the "skirt", not inside of it.
How would I get brim also in the area marked here?</p>
<p><a href="https://i.stack.imgur.com/TQiOx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TQiOx.png" alt="Add brim here" /></a></p>
|
<p>When there's a cut in the outer ring (the manual skirt), Slic3r will fill the area as expected:</p>
<p><a href="https://i.stack.imgur.com/Lb2np.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lb2np.png" alt="Brim in the gap" /></a></p>
|
<p><a href="https://i.stack.imgur.com/t2WwV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t2WwV.png" alt="enter image description here" /></a></p>
<p>Prusa Slicer 2.2.0 in print settings
skirt and brim, set distance from object to zero</p>
<p>Other slicers should have same capability. As long as you have two parts on the bed that are not distinctly separated, you'll get only one brim.</p>
| 1,697
|
<p>Trying to install the RMagick gem is failing with an error about being unable to find ImageMagick libraries, even though I'm sure they are installed.</p>
<p>The pertinent output from gem install rmagick is:</p>
<pre><code>checking for InitializeMagick() in -lMagick... no
checking for InitializeMagick() in -lMagickCore... no
checking for InitializeMagick() in -lMagick++... no
Can't install RMagick 2.6.0. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information.
*** extconf.rb failed ***
</code></pre>
<p>And looking in mkmf.log reveals:</p>
<pre><code>have_library: checking for InitializeMagick() in -lMagick... -------------------- no
"/usr/local/bin/gcc -o conftest -I.
-I/usr/local/lib/ruby/1.8/i386-solaris2.10 -I. -I/usr/local/include/ImageMagick -I/usr/local/include/ImageMagick conftest.c -L. - L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -L/usr/local/lib -R/usr/local/lib -lfreetype -lz -L/usr/local/lib -L/usr/local/lib -lMagickCore -lruby-static - lMagick -ldl -lcrypt -lm -lc"
ld: fatal: library -lMagick: not found
ld: fatal: File processing errors. No output written to conftest
</code></pre>
<p>This is on Solaris 10 x86 with ImageMagick version 6.4.3 and RMagick version 2.6.0</p>
<p>If I need to add something to LDFLAGS, its not clear to me what that would be. I installed ImageMagick from source and it should be in the usual places. ie,</p>
<pre><code># ls -l /usr/local/lib/ | grep -i magick
drwxr-xr-x 5 root root 512 Sep 24 23:09 ImageMagick-6.4.3/
-rw-r--r-- 1 root root 10808764 Sep 25 02:09 libMagickCore.a
-rwxr-xr-x 1 root root 1440 Sep 25 02:09 libMagickCore.la*
-rw-r--r-- 1 root root 2327072 Sep 25 02:09 libMagickWand.a
-rwxr-xr-x 1 root root 1472 Sep 25 02:09 libMagickWand.la*
</code></pre>
<p>ImageMagick-6.4.3/ contains nothing interesting and I can't find any other files that I might be able to point gem install at.</p>
<p>Any advice would be much appreciated!!
googling hasn't been too helpful.</p>
<p>thanks -</p>
|
<p>problem solved.</p>
<p>RMagick was unable to find ImageMagick because I neglected to build the shared objects (there were no .so files installed as you can see from the "ls" in the original question). The solution was to add <code>--with-shared</code> to my configure options.</p>
<p>This however caused other problems. Most notably, <code>make</code> failing with "undefined symbol" messages for libiconv. This was solved by setting CFLAGS to point to libiconv:</p>
<pre><code>export CFLAGS="-liconv"
</code></pre>
<p>Ultimately, my successful configure command was:</p>
<pre><code>./configure --disable-static --with-modules --without-perl --with-quantum-depth=8 --with-bzlib=no --with-libiconv
</code></pre>
<p>and after that, <code>make</code>, <code>make install</code>, and <code>gem install rmagick</code> all worked smoothly.</p>
<p>thanks,</p>
<p>R</p>
|
<p>The linker cannot find libMagick in the standard places. Maybe you installed ImageMagick in a non standard place you have to specify via LDFLAGS?</p>
| 15,931
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/8127/pre-build-task-deleting-the-working-copy-in-cruisecontrol-net">Pre-build task - deleting the working copy in CruiseControl.NET</a> </p>
</blockquote>
<p>I would like to delete my working directory during the cruisecontrol build process...I'm sure this is easy, but I have been unable to find an example of it...</p>
<p>If you know how to create a directory, that would be useful as well.</p>
<p>Thanks.</p>
|
<p>One of two ways.</p>
<ol>
<li>If you're already using an MSBuild file or something similar, add the action to the MSBuild file.</li>
<li>Instead of directly executing some command, create a batch file that executes that command and then deletes the directory, and have CCnet call that batch file instead.</li>
</ol>
|
<p>My guess is that you want to delete the working directory <em>before</em> CruiseControl.NET gets the latest code from source control. If this is the case, then the only way to accomplish this is to write a custom source control provider for CruiseControl.NET that first deletes the working directory and then gets the latest code. Have a look at CruiseControl.NET's source code for examples of how to write a source control provider.</p>
<p>If you want to delete the working directory <em>after</em> the latest code is retrieved from source control, then you can use CruiseControl.NET's <a href="http://confluence.public.thoughtworks.org/display/CCNET/Executable+Task" rel="nofollow noreferrer">executable task</a> by running "cmd /c del directoryname".</p>
| 4,659
|
<p>I am using the following jquery code:</p>
<pre><code>$("#top ul li.corner").mouseover(function(){
$("span.left-corner").addClass("left-corner-hover");
$("span.right-corner").addClass("right-corner-hover");
$("span.content").addClass("content-hover");
}).mouseout(function(){
$("span.left-corner").removeClass("left-corner-hover");
$("span.right-corner").removeClass("right-corner-hover");
$("span.content").removeClass("content-hover");
});
</code></pre>
<p>But as you see in the selector that is going to do every li.corner that the mouse is over. i am trying to get it to do only the one the mouse is over, how would I achieve that?</p>
|
<pre><code>py> data = "0010011010011101"
py> data = [data[8*i:8*(i+1)] for i in range(len(data)/8)]
py> data
['00100110', '10011101']
py> data = [int(i, 2) for i in data]
py> data
[38, 157]
py> data = ''.join(chr(i) for i in data)
py> data
'&\x9d'
</code></pre>
|
<h1>Python 3 and number.to_bytes</h1>
<p>With Python 3 you can convert numbers to bytes natively with <a href="https://docs.python.org/3/library/stdtypes.html#int.to_bytes" rel="nofollow noreferrer">number.to_bytes</a>. The byte array can be written directly to a file.</p>
<pre><code>>>> import math,sys
>>> s='0010011010011101'
>>> int(s,2).to_bytes(math.ceil(len(s)/8),sys.byteorder)
b'\x9d&'
>>> with open('/tmp/blah', 'wb') as f:
... f.write(int(s,2).to_bytes(math.ceil(len(s)/8),sys.byteorder))
...
2
>>> quit()
</code></pre>
<h2>file contents</h2>
<pre><code>[root@localhost prbs]# od -x /tmp/blah
0000000 269d
0000002
</code></pre>
| 42,315
|
<p>I've built a nice website system that caters to the needs of a small niche market. I've been selling these websites over the last year by deploying copies of the software using Capistrano to my web server.</p>
<p>It occurs to me that the only difference in these websites is the database, the CSS file, and a small set of images used for the individual client's graphic design. </p>
<p>Everything else is exactly the same, or should be... Now that I have about 20 of these sites deployed, it is getting to be a hassle to keep them all updated with the same code. And this problem will only get worse.</p>
<p>I am thinking that I should refactor this system, so that I can use one set of deployed ruby code, dynamically selecting the correct database, etc, by the URL of the incoming request.</p>
<p>It seems that there are two ways of handling the database:</p>
<ul>
<li>using multiple databases, one for each client </li>
<li>using one database, with a client_id field in each table, and an extra 'client' table</li>
</ul>
<p>The multiple database approach would be the simplest for me at the moment, since I wouldn't have to refactor every model in my application to add the client_id field to all CRUD operations. </p>
<p>However, it would be a hassle to have to run 'rake db:migrate' for tens or hundreds of different databases, every time I want to migrate the database(s). Obviously this could be done by a script, but it doesn't smell very good.</p>
<p>On the other hand, every client will have 20K-50K items in an 'items' table. I am worried about the speed of fulltext searches when the items table has a half million or million items in it. Even with an index on the client_id field, I suspect that searches would be faster if the items were separated into different client databases.</p>
<p>If anyone has an informed opinion on the best way to approach this problem, I would very much like to hear it. Thanks much in advance...</p>
<p>-- John</p>
|
<p>There are advantages to using separate DBs (including those you already listed):</p>
<ul>
<li>Fulltext searches will become slow (depending on your server's capabilities) when you have millions of large text blobs to search.</li>
<li>Separating the DBs will keep your table indexing speed quicker for each client. In particular, it might upset some of your earlier adopting clients if you take on a new, large client. Suddenly their applications will suffer for (to them) no apparent reason. Again, if you stay under your hardware's capacity, this might not be an issue.</li>
<li>If you ever drop a client, it'd be marginally cleaner to just pack up their DB than to remove all of their associated rows by client_id. And equally clean to restore them if they change their minds later.</li>
<li>If any clients ask for additional functionality that they are willing to pay for, you can fork their DB structure without modifying anyone else's.</li>
<li>For the pessimists: Less chance that you accidentally destroy all client data by a mistake rather than just one client's data. ;)</li>
</ul>
<p>All that being said, the single DB solution is probably better given:</p>
<ul>
<li>Your DB server's capabilities makes the large single table a non-issue.</li>
<li>Your client's databases are guaranteed to remain identical.</li>
<li>You aren't worried about being able to keep everyone's data compartmentalized for purposes of archiving/restoring or in case of disaster.</li>
</ul>
|
<p>I would go for a single database, using client IDs - you should be able to make the refactoring less painful by using some form of base model, and a named scope to scope any actions to that client's ID.</p>
<p>You could use an indexing library, such as Ferret, or something along those lines, to deal with the issue of full-text searches becoming slow. That's going to be an issue anyway once a single client's database becomes to big, so you may need to implement that either way.</p>
| 45,511
|
<p>When parsing HTML for certain web pages (most notably, any windows live page) I encounter a lot of URL’s in the following format.</p>
<p>http\x3a\x2f\x2fjs.wlxrs.com\x2fjt6xQREgnzkhGufPqwcJjg\x2fempty.htm</p>
<p>These appear to be partially UTF8 escaped strings (\x2f = /, \x3a=:, etc …). Is there a .Net API that can be used to transform these strings into a System.Uri? Seems easy enough to parse but I’m trying to avoid building a new wheel today. </p>
|
<p>What you posted is not valid HTTP. As such, of course <code>HttpUtility.UrlDecode()</code> won't work. But irrespective of that, you can turn this back into normal text like this:</p>
<pre><code>string input = @"http\x3a\x2f\x2fjs.wlxrs.com\x2fjt6xQREgnzkhGufPqwcJjg\x2fempty.htm";
string output = Regex.Replace(input, @"\\x([0-9a-f][0-9a-f])",
m => ((char) int.Parse(m.Groups[1].Value, NumberStyles.HexNumber)).ToString());
</code></pre>
<p>But notice that this assumes that the encoding is Latin-1 rather than UTF-8. The input you provided is inconclusive in that respect. If you need UTF-8 to work, you need a slightly longer route; you'll have to convert the string to bytes and replace the escape sequences with the relevant bytes in the process (probably needs a while loop), and then use <code>Encoding.UTF8.GetString()</code> on the resulting byte array.</p>
|
<p>Did you try <a href="http://msdn.microsoft.com/en-us/library/system.web.httputility.urldecode.aspx" rel="nofollow noreferrer">HttpUtility.UrlDecode</a>?</p>
| 46,974
|
<p>Starting with the following LINQ query:</p>
<pre><code>from a in things
where a.Id == b.Id &&
a.Name == b.Name &&
a.Value1 == b.Value1 &&
a.Value2 == b.Value2 &&
a.Value3 == b.Value3
select a;
</code></pre>
<p>How can I remove (at runtime) one or more of the conditions in the where clause in order to obtain queries similar to the following ones:</p>
<pre><code>from a in things
where a.Id == b.Id &&
a.Name == b.Name &&
a.Value2 == b.Value2 &&
a.Value3 == b.Value3
select a;
</code></pre>
<p>Or</p>
<pre><code>from a in things
where
a.Name == b.Name &&
a.Value3 == b.Value3
select a;
</code></pre>
|
<p>Rather than try to change existing where clauses, I'd refactor it to this:</p>
<pre><code>from a in things
where a.Id == b.Id
where a.Name == b.Name
where a.Value1 == b.Value1
where a.Value2 == b.Value2
where a.Value3 == b.Value3
select a;
</code></pre>
<p>That then becomes:</p>
<pre><code>things.Where(a => a.Id == b.Id)
.Where(a => a.Name == b.Name)
.Where(a => a.Value1 == b.Value1)
.Where(a => a.Value2 == b.Value2)
.Where(a => a.Value1 == b.Value3);
</code></pre>
<p>Now it should be reasonably clear how to proceed - conditionalise the calls to Where:</p>
<pre><code>IQueryable<Whatever> query = things;
if (useId) {
query = query.Where(a => a.Id == b.Id);
}
query = query.Where(a => a.Name == b.Name);
if (checkValue1) {
query = query.Where(a => a.Value1 == b.Value1);
}
// etc
</code></pre>
|
<p>Try to separate things. First isolate the where condition from the rest of your query then process it and use standard query methods instead of the built in syntactic sugar. Eg.:</p>
<pre><code> IQueryable<MyClass> things = null;
MyClass b = new MyClass();
Expression<Func<MyClass, bool>> whereExp = a => a.Id == b.Id && a.Name == b.Name;
// process where expression here. it's just an expression tree. traverse it and
// remove nodes as desired.
var result = things.Where(whereExp).Select(a => a);
</code></pre>
<p>Another easier mode to achieve this would be not to start with a full expression and removing things but instead compose one from parts. Eg.:</p>
<pre><code>IQueryable<MyClass> things = null;
MyClass b = new MyClass();
Expression<Func<MyClass, bool>> whereExp;
Expression<Func<MyClass, bool>> exp1 = a => a.Id == b.Id;
Expression<Func<MyClass, bool>> exp2 = a => a.Name == b.Name;
whereExp = Expression.Lambda<Func<MyClass, bool>>(Expression.And(exp1, exp2), Expression.Parameter(typeof(MyClass), "a"));
var result = things.Where(whereExp).Select(a => a);
</code></pre>
| 42,193
|
<p>I know that codeIgniter turns off GET parameters by default. </p>
<p>But by having everything done in POST, don't you get annoyed by the re-send data requests if ever you press back after a form submission?</p>
<p>It annoys me, but I'm not sure if I want to allow GET purely for this reason.</p>
<p>Is it such a big security issue to allow GET parameters too?</p>
|
<p>When I first started working with CodeIgniter, not using GET really threw me off as well. But then I realized that you can simulate GET parameters by manipulating the URI using the built-in <a href="http://codeigniter.com/user_guide/libraries/uri.html" rel="noreferrer">URI Class</a>. It's fantastic and it makes your URLs look better.</p>
<p>Or if you really need GETs working you can put this into your controller:</p>
<pre><code>parse_str($_SERVER['QUERY_STRING'], $_GET);
</code></pre>
<p>Which will put the variables back into the GET array. </p>
|
<p>GET parameters are cached by the web browser, POST is not. So with a POST you don't have to worry about caching, so that is why it is usually prefered. </p>
| 43,403
|
<p>I was just shopping for filament, and saw some glowing claims about PETG being as easy to work with as PLA, but as strong as ABS, and less brittle. Anyone know if that's actually true, or what the tradeoffs are?</p>
|
<p>PETG is great stuff to work with. It is stronger than ABS also. It prints slower than ABS and PLA. The formulas vary quite a bit from vendor to vendor. I have used 3 brands, and each of their properties vary. </p>
<p>From my experience you do have to be careful with moisture. You'll be able to tell you have moisture in your filament if you start hearing a slight hissing and popping and an increased number of structural zits on the object. Moisture will also increase the problem listed in Mark's post below regarding the accumulation of filament on the nozzle.</p>
|
<p>I love PETG. When I first started I always used ABS because I thought it was the best and didn't see the point in using PLA. However, after a few years of playing around I no longer use ABS. I use PLA for when I am testing and PETG when I want to print something that will be used, ike parts or models. </p>
<p>PETG is a little more expensive, however worth it, as it is strong and easy to use. I normally print at 220°C on the nozzle and 80°C for the bed.</p>
<p>PETG has more flex to it so when you are printing parts it is less likely to break under pressure like ABS. </p>
| 160
|
<p>What do I put in my order by?? I want to order by Name. I have moved the orderby after the distinct because I read that it needs to be done last.</p>
<pre><code> var result = (from r in db.RecordDocs
where r.RecordID == recordID
select new
{
DocTypeID = r.Document.DocType.DocTypeID,
Name = r.Document.DocType.Name,
Number = r.Document.DocType.Number
}
).Distinct().OrderBy( );
</code></pre>
|
<p>Just do</p>
<pre><code>.OrderBy(doc => doc.Name)
</code></pre>
|
<p>Another option, if you really prefer the query expression syntax would be to chain your query construction across multiple statements:</p>
<pre><code>var query = from r in db.RecordDocs
where r.RecordID == recordID
select new
{
DocTypeID = r.Document.DocType.DocTypeID,
Name = r.Document.DocType.Name,
Number = r.Document.DocType.Number
};
query = query.Disctinct();
query = from doc in query orderby doc.Name select doc;
</code></pre>
<p>Since all of these methods are deferred, this will result in the exact same execution performance.</p>
| 31,756
|
<p>I need a WiX 3 script to display to display only 2 dialogs: Welcome & Completed. Thats it no need for EULA, folder selection etc. All help appreciated.</p>
|
<p>All you need to do is add this in your WIX script, it will give you the WelcomeDlg before the installation and show the Installation progress, then the Exit Dialog. Don't forget to add the WixUIExtension.dll to your references.</p>
<pre><code><UI Id="UserInterface">
<Property Id="WIXUI_INSTALLDIR" Value="TARGETDIR" />
<Property Id="WixUI_Mode" Value="Custom" />
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="9" Bold="yes" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="FatalError" />
<DialogRef Id="UserExit" />
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="EndDialog" Value="Return" Order="2"></Publish>
</UI>
<UIRef Id="WixUI_Common" />
</code></pre>
|
<p>If you are using Visual Studio and Wix 3.8 then you could create Wix Setup project and use text below as content of Product.wxs. In my case I needed to copy python and text file into destination dir. Thanks again for original masterpiece, comrade CheGueVerra:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="testwixsetup" Language="1033" Version="2.1.3.0" Manufacturer="ttt" UpgradeCode="PUT-GUID-HERE">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="testwixsetup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<UI Id="UserInterface">
<Property Id="WIXUI_INSTALLDIR" Value="TARGETDIR" />
<Property Id="WixUI_Mode" Value="Custom" />
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="9" Bold="yes" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="FatalError" />
<DialogRef Id="UserExit" />
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="EndDialog" Value="Return" Order="2"></Publish>
</UI>
<UIRef Id="WixUI_Common" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="COMPANYFOLDER" Name="test-wixinstall">
<Directory Id="INSTALLFOLDER" Name="testwixsetup" />
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="ProductComponent" Guid="*">
<File Name="test.py"/>
<File Name="test.txt"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
</code></pre>
| 24,498
|
<p>I'm getting the error: wintypes.dcu not found several times a day in the Delphi 2009 IDE, after this error code completion stops working, also I can't open any unit's source code with Ctrl + Click, then I have to reopen the IDE to fix it.</p>
<p>Anyone has a clue about what can be causing this?</p>
<p>The only IDE extension I have installed is GExperts.</p>
|
<p>wintypes.pas and winprocs.pas has been replaced with windows.pas (since a long time). You should use Unit Aliases to replace all wintypes with windows.</p>
|
<p>Why wintypes.dcu cannot be found any longer, I do not know. But the other two are obvious follow up errors: if Delphi cannot compile the code due to syntax errors (and a missing file is considered a syntax error), it stops code completion and cannot locate source code any longer using Ctrl + Click.</p>
| 36,039
|
<p>I am developing on a LAMP(erl) stack and know of several ways to store obscured passwords. I'd like to hear from those who feel they have a best practice, given MySQL 4.1.1 and Perl 5.8, and the reasons why it's the best.</p>
<p>One option I have read about, using the MySQL ENCODE() and DECODE() functions, sounds pretty good to me... your thoughts?</p>
|
<p>I think a salted hash with a proper hash function like <a href="http://search.cpan.org/~dido/SHA256-0.01b/SHA256.pod" rel="nofollow noreferrer">SHA-256</a> is the best. Passwords that are reversible are not as safe as those who cannot be reversed. Without an external Perl module, you can use instead the built in SHA1() function, not as good as SHA256, but better than ENCODE/DECODE.</p>
<p>Additionally, you have to consider the path from your code to the database, which can be sniffed. You can avoid that risk by hashing in the code or by encrypting the database connection. Better to do it in code, because even when encrypting the connection there is still the risk about query logs being configured thus storing plaintext on a log file somewhere.</p>
|
<p>If you can decrypt a password, your security is flawed. You should always hash the password with a salt, MD5 is popular but there are superior hashing such as SHA and SHA-256.</p>
| 41,081
|
<p>I have got this error when using Enterprise Library 3.1 May 2007 version. We are developing a product and have a common lib directory beneath the Subversion Trunk directory</p>
<p><>\Trunk\Lib\ into which we put all the third party DLLs. Inside this we have Microsoft\EnterpriseLibrary\v3.1 in which we have copied all the dlls from \Program Files\Microsoft Enterprise Library May2007\bin. Everything was working properly until one of the developers installed the source code on this machine. There were some dlls copied at the end of the source code installation and once that was done, he is not able to run the project anymore. He always gets this error</p>
<p><strong>'Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'</strong></p>
<p>What is the problem here? I thought that when the source code was installed it was just supposed to build everything and copy in the bin directory within the source code parent directory. Also we have copied the Dlls from Microsoft Enterprise Library May 2007\bin directory into our product development directory and references into our project with a copylocal flag set to true. </p>
<p>Can anyone help me out here</p>
<p>RK</p>
|
<p>I used to get that when I developed against the signed version of the dll and deployed where only the unsigned version was available.</p>
<p>Also, <a href="http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx" rel="noreferrer">fuslogvw.exe</a>. EVERY. TIME.</p>
|
<p>maybe you should check the Assembly- and FileVersion of the dll. if they do not match this exception can occur.</p>
| 45,871
|
<p>I have a visual studio solution with the following projects:</p>
<ol>
<li>UI</li>
<li>DataAccess</li>
<li>BusiessLogic</li>
<li>BusinessObjects</li>
</ol>
<p>I now have a bunch of code that generates reports that are sent out via email or saved as csv files.</p>
<p>These ReportGenerators classes take in business objects and output either files or strings.</p>
<p>which project would you put them in? I am leaning toward an answer but wanted to see what others thought?</p>
|
<p>I would create a separate reporting project. It doesn't belong in the UI (I assume they run in the background) - it is effectively a 'reporting logic' layer. </p>
<p>If you think about how you might want to support reportng, you may want a backend service but you might want to expose the data via a web service as well in the future. If you need to provide users a front-end reporting facility you plug into the reporting logic as you would a normal UI -> Logic -> Data Access architecture. </p>
<p>Also, if you separate your reporting code out you are then free to extract it to a dedicated reporting tier in the future.</p>
|
<p>A agree with manwood's post - you should build them as reports (put a sproc behind the reports if necessary) for the following reasons:</p>
<ul>
<li><p>You can run the reports and display
them through the ReportViewer
control. This is fairly
straightforward to do.</p></li>
<li><p>You (and more importantly other people
supporting the application) can
extend the application with more
reports without having to release
another build of the application. This is quite a useful feature if you don't want to be tied to supporting the application.</p></li>
<li><p>You can publish the reports through
reporting services as well.</p></li>
<li><p>You get all the data export options
of reporting services (Excel, csv,
pdf etc.) with the Reporting
Services framework.</p></li>
</ul>
| 37,532
|
<p>Is there a way to Invoke an overloaded method using reflection in .NET (2.0). I have an application that dynamically instantiates classes that have been derived from a common base class. For compatibility purposes, this base class contains 2 methods of the same name, one with parameters, and one without. I need to call the parameterless method via the Invoke method. Right now, all I get is an error telling me that I'm trying to call an ambiguous method.</p>
<p>Yes, I <em>could</em> just cast the object as an instance of my base class and call the method I need. Eventually that <em>will</em> happen, but right now, internal complications will not allow it.</p>
<p>Any help would be great! Thanks.</p>
|
<p>You have to specify which method you want: </p>
<pre><code>class SomeType
{
void Foo(int size, string bar) { }
void Foo() { }
}
SomeType obj = new SomeType();
// call with int and string arguments
obj.GetType()
.GetMethod("Foo", new Type[] { typeof(int), typeof(string) })
.Invoke(obj, new object[] { 42, "Hello" });
// call without arguments
obj.GetType()
.GetMethod("Foo", new Type[0])
.Invoke(obj, new object[0]);
</code></pre>
|
<p>Use the GetMethod overload that takes a System.Type[], and pass an empty Type[];</p>
<pre><code>typeof ( Class ).GetMethod ( "Method", new Type [ 0 ] { } ).Invoke ( instance, null );
</code></pre>
| 27,598
|
<p>I am using ActiveReports with ASP.NET but I think answer for any similar reporting component will do.</p>
<p>I have two resultset to merge and show in a single report, like:</p>
<pre><code>Table 1:
Name Job Start End
Jack Some service 1992 1997
Jack Some Sales Exp 1998 2007
Jane Some programming 2000 2003
Table 2:
Name Training
Jack Shiny French Certificate
Jane Crappy database certificate
Jane Some courses in management
</code></pre>
<p>And the report should look like:</p>
<pre><code>Jack
Job History:
Some Corp, 1992-1997
Some Sales Exp, 1998-2007
Training History:
Shiny French Certificate
Jane
Job History:
Some programming, 2000-2003
Training History:
Crappy database certificate
Some courses in management
</code></pre>
<p>How should I merge the two tables and how should I design the layout to achieve the report in the given example?</p>
<p>Update:</p>
<p>As you may notice, I am not trying to do this with a single select. I have two datatables as source and I can merge them by hand to get a single data source. I am trying to use grouping but I need two kind of groups for each employee. One for the jobs, and one for the trainings. How can I use groups or sub-reports feature to bind this kind of data (and how should I process the data if necessary)?</p>
|
<p>Use subreports... Create a main report that will have two subreports. One subreport for job history and one subreport for training history. The main report will need a query that will return a list of people. Then for each Person in the detail of the main report, set a parameter on each of the child subreports that will refine the query in those two to list the Job History or Training History for only the current person being displayed in the parent report.</p>
<p>A detailed walkthrough that explains how to do this step by step is on the Data Dynamics website <a href="http://www.datadynamics.com/Help/ARNET/ParameterswithSubreports.html" rel="nofollow noreferrer">here</a>. Some overview information is also <a href="http://www.datadynamics.com/forums/539/ShowPost.aspx" rel="nofollow noreferrer">here</a></p>
|
<p>You should select this two tables with "left-join", create a "GroupHeader/Footer" section in report and set "DataField" on "GroupHeader" section to field, which should be used as grouping.</p>
<p>Look at the samples from ActiveReports, they surely has a sample for grouping.</p>
| 35,112
|
<p>In order to improve my open source project, I need testers. I have created my project independently, so up to now I have been the sole coder and tester. I have tested the thing to death, but as we all know it is dangerous as a developer to test your own code. I'm looking for ideas on how I can get some other eyes to exercise it.</p>
<hr>
<p>To clarify, I have released it on sourceforge and posted it on freshmeat, dzone, reddit, etc. </p>
|
<p>Are you looking for "testers" or "users"? There's a world of difference.</p>
<p>A tester uses <em>his</em> time and energy to find <em>your</em> bugs. How many people are willing to do that? At a rough guess, I'd say zero.</p>
<p>A user uses <em>your</em> software to solve <em>his</em> problems. He reports bugs to you because he thinks that you might fix them for him. So you've got to find people with a problem, and convince them that your software will fix it.</p>
<p>One thing you'll need is lots of documentation. A 1-minute screencast, in-depth API, and everything in between. You need to persuade someone that, "If I use tox, I will totally <strong>rock</strong>!"</p>
<p>That's your tester.</p>
|
<p>Release an early version, announce it on <a href="http://freshmeat.net/" rel="nofollow noreferrer">freshmeat</a>, and wait for the world to beat a path to your door?</p>
| 18,210
|
<p>I've been 3D printing for a while and I've noticed that, when printing small parts, my colored plastics (PLA, PLA+ and ABS) have better layer adhesion than black ones.</p>
<p>Did you notice this?</p>
<p>What could be the cause?</p>
|
<p>Not inherently.</p>
<p>There are two things at work that might cause one color to test weaker than others even as its properties otherwise are functionally identical:</p>
<ol>
<li>A bad print among good ones.</li>
<li>A bad roll among good ones.</li>
</ol>
<p>Let's take a look at both, then do a little excursus into plastics and color.</p>
<h2>A bad print</h2>
<p>There are probably thousands of reasons a print might fail, but bad layer bonding and squish-ability under torsion strongly hint to under extrusion. Now, under extrusion itself can be caused by a plethora of reasons: a clogged nozzle is equally as possible as too thinner diameter as is just a bad temperature. The last one is, in my opinion, the most likely culprit: filaments may look the same and feel the same and bond the same, but in different colors, they sometimes demand different print settings.</p>
<p>As an example, I print most of my Kaisertech PLAs at 200°C, as that offers a quite good result for all of them. Yet when I started I had a white China PLA and a crystal clear PLA from the same manufacturer, both came from the same warehouse in the same shipment. The clear one is quite more brittle on the roll, but their starting-to-print temperature differs by 5°C - the white started to extrude at 180°C decently and printed ok at 195°C-200°C, while the clear needed only 175°C to start to be extrudeable and was really printable at 190°C. Yet recently I tried the same roll again to achieve fully clear prints, and with 210°C and lots of overextrusion, I managed to go almost solid-clear. Because of such experience, I suggest tweaking the settings.</p>
<h2>A Bad Filament</h2>
<p>There are several reasons why one roll might resulting in bad prints, but the most prominent are that the roll has <em>gone</em> bad over bad storage. It might be stored too hot or too humid, making it brittle or bubble in the hotend. Aging under UV plays a role (it degrades PLA). And dimensional accuracy plays a role because it affects the whole roll of filament. This is why tests should always be performed with equally treated and measured samples to achieve comparability.</p>
<h2>Excursus: Plastics and color</h2>
<p>What gives a plastic its color? Pigments added to it. Now, pigments can be of varied kinds. Usually, they are embedded in the plastic (=not bonded to the carrier plastic), and the plastic polymer is often either inherently transparent(ish) or white. Let's take some examples to look at...</p>
<ul>
<li><strong>Yellow</strong>. Yellow can be made from a lot of stuff but many yellow pigments react to UV light by decay more than other colors, leading to yellow to fade quickly in comparison to other colors. It has varied chemical compositions, often they can become quite complex.</li>
<li><strong>Black</strong>. Black pigment is typically the most simplistic coloration to achieve: pure powdered carbon is one of our most potent black pigments, and also one of the cheapest, making black plastic one of the most common plastics. In contrast to other colors, carbon can't fade. But the plastic around it decomposes and turns white, fading the color this way.</li>
</ul>
<p>Now, most colorings are - in physical terms - sizeable. Some few to a couple dozen atoms, making them range in the <em>Angström</em> (~Atom diameter) to <em>few nanometer</em> area overall. However, even something as complex as <span class="math-container">$C_{22}H_{20}O_{13}$</span> (Carmine) is relatively small compared to the <span class="math-container">$(C_3H_4O_2)_n$</span> of <strong>Poly</strong>LacticAcid, aka PLA. Poly tells us that n is at least 100, because shorter chains are <em>oligo</em>mers, not <em>poly</em>mers. In comparison, our red carmine pigment is more dense, much more compact in fact. As a result, a 100-chain of PLA is not just in the <em>Angstöm</em> area but in the <em>dozen nanometer</em> to <em>micrometer</em> range - a magnitude of at least 2 larger. Unless we have a huge excess of pigment or a pigment that reacts with the plastic under heat, then the impact of it on the strength should be neglectible to the other fillers often used.</p>
|
<p>Not inherently.</p>
<p>There are two things at work that might cause one color to test weaker than others even as its properties otherwise are functionally identical:</p>
<ol>
<li>A bad print among good ones.</li>
<li>A bad roll among good ones.</li>
</ol>
<p>Let's take a look at both, then do a little excursus into plastics and color.</p>
<h2>A bad print</h2>
<p>There are probably thousands of reasons a print might fail, but bad layer bonding and squish-ability under torsion strongly hint to under extrusion. Now, under extrusion itself can be caused by a plethora of reasons: a clogged nozzle is equally as possible as too thinner diameter as is just a bad temperature. The last one is, in my opinion, the most likely culprit: filaments may look the same and feel the same and bond the same, but in different colors, they sometimes demand different print settings.</p>
<p>As an example, I print most of my Kaisertech PLAs at 200°C, as that offers a quite good result for all of them. Yet when I started I had a white China PLA and a crystal clear PLA from the same manufacturer, both came from the same warehouse in the same shipment. The clear one is quite more brittle on the roll, but their starting-to-print temperature differs by 5°C - the white started to extrude at 180°C decently and printed ok at 195°C-200°C, while the clear needed only 175°C to start to be extrudeable and was really printable at 190°C. Yet recently I tried the same roll again to achieve fully clear prints, and with 210°C and lots of overextrusion, I managed to go almost solid-clear. Because of such experience, I suggest tweaking the settings.</p>
<h2>A Bad Filament</h2>
<p>There are several reasons why one roll might resulting in bad prints, but the most prominent are that the roll has <em>gone</em> bad over bad storage. It might be stored too hot or too humid, making it brittle or bubble in the hotend. Aging under UV plays a role (it degrades PLA). And dimensional accuracy plays a role because it affects the whole roll of filament. This is why tests should always be performed with equally treated and measured samples to achieve comparability.</p>
<h2>Excursus: Plastics and color</h2>
<p>What gives a plastic its color? Pigments added to it. Now, pigments can be of varied kinds. Usually, they are embedded in the plastic (=not bonded to the carrier plastic), and the plastic polymer is often either inherently transparent(ish) or white. Let's take some examples to look at...</p>
<ul>
<li><strong>Yellow</strong>. Yellow can be made from a lot of stuff but many yellow pigments react to UV light by decay more than other colors, leading to yellow to fade quickly in comparison to other colors. It has varied chemical compositions, often they can become quite complex.</li>
<li><strong>Black</strong>. Black pigment is typically the most simplistic coloration to achieve: pure powdered carbon is one of our most potent black pigments, and also one of the cheapest, making black plastic one of the most common plastics. In contrast to other colors, carbon can't fade. But the plastic around it decomposes and turns white, fading the color this way.</li>
</ul>
<p>Now, most colorings are - in physical terms - sizeable. Some few to a couple dozen atoms, making them range in the <em>Angström</em> (~Atom diameter) to <em>few nanometer</em> area overall. However, even something as complex as <span class="math-container">$C_{22}H_{20}O_{13}$</span> (Carmine) is relatively small compared to the <span class="math-container">$(C_3H_4O_2)_n$</span> of <strong>Poly</strong>LacticAcid, aka PLA. Poly tells us that n is at least 100, because shorter chains are <em>oligo</em>mers, not <em>poly</em>mers. In comparison, our red carmine pigment is more dense, much more compact in fact. As a result, a 100-chain of PLA is not just in the <em>Angstöm</em> area but in the <em>dozen nanometer</em> to <em>micrometer</em> range - a magnitude of at least 2 larger. Unless we have a huge excess of pigment or a pigment that reacts with the plastic under heat, then the impact of it on the strength should be neglectible to the other fillers often used.</p>
| 1,184
|
<p>Is it possible (in Vb.Net 2005), without manually parsing the dataset table properties, to create the table and add it to the database?</p>
<p>We have old versions of our program on some machines, which obviously has our old database, and we are looking for a way to detect if there is a missing table and then generate the table based on the current status of the table in the dataset. We were re-scripting the table every time we released a new version (if new columns were added) but we would like to avoid this step if possible.</p>
|
<p>See this MSDN Forum Post: <a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/4929a0a8-0137-45f6-86e8-d11e220048c3/" rel="nofollow noreferrer">Creating a new Table in SQL Server from ADO.net DataTable</a>. </p>
<p>Here the poster seems to be trying to do the same thing as you, and provides code that generates a Create Table statement using the schema contained in a DataTable. </p>
<p>Assuming this works as it should, you could then take that code, and submit it to the database through <code>SqlCommand.ExecuteNonQuery()</code> in order to create your table.</p>
|
<p>Here is the code: </p>
<pre class="lang-cs prettyprint-override"><code>SqlConnection con = new SqlConnection("Data Source=.;uid=sa;pwd=sa123;database=Example1");
con.Open();
string sql = "Create Table abcd (";
foreach (DataColumn column in dt.Columns)
{
sql += "[" + column.ColumnName + "] " + "nvarchar(50)" + ",";
}
sql = sql.TrimEnd(new char[] { ',' }) + ")";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.ExecuteNonQuery();
using (var adapter = new SqlDataAdapter("SELECT * FROM abcd", con))
using(var builder = new SqlCommandBuilder(adapter))
{
adapter.InsertCommand = builder.GetInsertCommand();
adapter.Update(dt);
}
con.Close();
</code></pre>
<p>I hope you got the problem solved.<br>
Here <code>dt</code> is the name of the DataTable.<br>
Alternatively you can replace: </p>
<pre class="lang-cs prettyprint-override"><code>adapter.update(dt);
</code></pre>
<p>with</p>
<pre class="lang-cs prettyprint-override"><code>//if you have a DataSet
adapter.Update(ds.Tables[0]);
</code></pre>
| 3,715
|
<p>When setting up a rollover effect in HTML, are there any benefits (or pitfalls) to doing it in CSS vs. JavaScript? Are there any performance or code maintainability issues I should be aware of with either approach?</p>
|
<p>CSS is fine for rollovers. They're implemented basically using the <code>:hover</code> pseudo-selector. Here's a really simple implementation:</p>
<pre><code>a{
background-image: url(non-hovered-state.png);
}
a:hover{
background-image: url(hovered-state.png);
}
</code></pre>
<p>There are a few things you need to be aware of though:</p>
<ul>
<li>IE6 only supports <code>:hover</code> on <code><a></code> tags</li>
<li>Images specified in CSS but not used on the page won't be loaded immediately (meaning the rollover state can take a second to appear first time)</li>
</ul>
<p>The <code><a></code>-tags-only restriction is usually no problem, as you tend to want rollovers clickable. The latter however is a bit more of an issue. There is a technique called <a href="http://alistapart.com/articles/sprites/" rel="nofollow noreferrer">CSS Sprites</a> that can prevent this problem, you can find an example of the technique in use to make <a href="http://www.wellstyled.com/css-nopreload-rollovers.html" rel="nofollow noreferrer">no-preload rollovers</a>. </p>
<p>It's pretty simple, the core principle is that you create an image larger than the element, set the image as a background image, and position it using <code>background-position</code> so only the bit you want is visible. This means that to show the hovered state, you just need to reposition the background - no extra files need to be loaded at all. Here's a quick-and-dirty example (this example assumes you have an element 20px high, and a background image containing both the hovered and non-hovered states - one on top of the other (so the image is 40px high)):</p>
<pre><code>a{
background-image: url(rollover-sprites.png);
background-position: 0 0; /* Added for clarity */
height: 20px;
}
a:hover{
background-position: 0 -20px; /* move the image up 20px to show the hovered state below */
}
</code></pre>
<p>Note that using this 'sprites' technique means that you will be unable to use alpha-transparent PNGs with IE6 (as the only way IE6 has to render alpha-transparent PNGs properly uses a special image filter which don't support <code>background-position</code>)</p>
|
<p>I'd stay on the CSS side of the house, but I've done very little Javascript.</p>
<p>CSS seems to be easier to standardize across browsers than Javascript, though that may be changing with the advent of Chrome's V8 and Firefox's upcoming new rendering tool.</p>
| 21,144
|
<p>The IntelliJ IDEA short-cut to reformat source code is <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>L</kbd>. This happens to lock the screen in KDE (Gnome too?). How can I disable this so IntelliJ receives the key sequence?</p>
|
<p>Under the K menu, go to the Control Center.</p>
<p>Regional & Accessibility |
Keyboard Shortcuts |
Shortcut Schemes tab,
Global Shortcuts tab.</p>
<p>In the search box, type "lock", which should narrow the visible shortcuts and show the <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>L</kbd> one ("Lock Session").</p>
<p>Underneath, click None.</p>
<p>Click the Apply button.</p>
<hr>
<p>On KDE Plasma 5 go to System Settings | Desktop Behaviour | Screen Locking</p>
<p>Here you will find a "Keyboard Shortcut" option. Change it to something else or set to none</p>
|
<p>Another option is to change the Idea keymap to use Default for KDE.
You can go to <em>File -> settings -> keymap</em> and then select the <strong>Default for KDE</strong> option from the drop down </p>
| 25,918
|
<p>.Net Compact Framework</p>
<p>Scenario: User is on a screen. Device can't finds a printer and asks the user if they want to try again. If they click "No", the current screen is closed and they are returned to the parent menu screen. If they click the "No" button multiple times, the first click will be used by the No button and the next click will take effect once the screen has completed redrawing. (In effect clicking a menu item which then takes the user to another screen.)</p>
<p>I don't see a good place to put a wait cursor...there isn't much happening when the user clicks "No" except a form closing. But the CF framework is slow to redraw the screen.</p>
<p>Any ideas?</p>
|
<p>Random thoughts:</p>
<ul>
<li>Disable the some of the controls on the parent dialog while a modal dialog is up. I do not believe that you can disable the entire form since it is the parent of the modal dialog.</li>
<li>Alternatively I would suggest using a Transparent control to catch the clicks but transparency is not supported on CF.</li>
<li>How many controls are on the parent dialog? I have not found CF.Net that slow in updating. Is there any chance that the dialog is overloaded and could be custom drawn faster that with sub controls?</li>
<li>override the DialogResult property and the Dispose method of the class to handle adding/remvoing a wait cursor.</li>
</ul>
|
<p>you can skip pending clicks by clearing the windows message queue with
Application.DoEvents();</p>
<p>We use the following custom Event class to solve your problem (preventing multiple clicks and showing a wait cursor if necessary):</p>
<pre><code>using System;
using System.Windows.Forms;
public sealed class Event {
bool forwarding;
public event EventHandler Action;
void Forward (object o, EventArgs a) {
if ((Action != null) && (!forwarding)) {
forwarding = true;
Cursor cursor = Cursor.Current;
try {
Cursor.Current = Cursors.WaitCursor;
Action(o, a);
} finally {
Cursor.Current = cursor;
Application.DoEvents();
forwarding = false;
}
}
}
public EventHandler Handler {
get {
return new EventHandler(Forward);
}
}
}
</code></pre>
<p>You can verify that it works with the following example (Console outputs click only if HandleClick has terminated):</p>
<pre><code>using System;
using System.Threading;
using System.Windows.Forms;
class Program {
static void HandleClick (object o, EventArgs a) {
Console.WriteLine("Click");
Thread.Sleep(1000);
}
static void Main () {
Form f = new Form();
Button b = new Button();
//b.Click += new EventHandler(HandleClick);
Event e = new Event();
e.Action += new EventHandler(HandleClick);
b.Click += e.Handler;
f.Controls.Add(b);
Application.Run(f);
}
}
</code></pre>
<p>To reproduce your problem change the above code as follows (Console outputs all clicks, with a delay):</p>
<pre><code> b.Click += new EventHandler(HandleClick);
//Event e = new Event();
//e.Action += new EventHandler(HandleClick);
//b.Click += e.Handler;
</code></pre>
<p>The Event class can be used for every control exposing EventHandler events (Button, MenuItem, ListView, ...).</p>
<p>Regards,
tamberg</p>
| 18,532
|
<p>I hit this error while my web application was trying to execute a SELECT INTO on a MSSQL 2005 database. I really have two questions:</p>
<ol>
<li>What does this error mean and how does this happen?</li>
<li>Is there a way to prevent these errors by coding in a different way?</li>
</ol>
|
<p>Besides the obvious, that somebody changed the table while the code was executing, it could be a naming conflict with temp tables created in the SQL. It could be that there are two temp tables with different schemas, but they have the same name.</p>
|
<p>You have to specify dbo. as the schema for the first table.</p>
| 19,620
|
<p>Does anyone use "space saver" style vacuum storage bags to keep fillament dry? I picked up some Ziploc space bags, but they are larger than ideal. Would probably fit 2.5 spools. I would love a smaller version just big enough for one spool.</p>
|
<p>I've read people are using them, makes sense, the less air you contain, the less moisture would be in the bag. Myself, I'm using IKEA ziplock bags (and moisture absorbing sachets), they come in many sizes.</p>
|
<p>I have a commercially available product known as a foodsaver (TM) which removes the air from the bag and really squeezes tightly around the spool. The width of the bags I use barely takes the typical spool but it does fit with a little elbow grease.</p>
<p>I include a bag of desiccant in each bag to pull any residual moisture.</p>
<p>It's a good idea to use the cut-to-length bags on a roll, which allows you to add excess length, as you have to cut and toss away the previous seal each time you use the spool.</p>
<p>I too purchased the big honking bags and never built the structure I planned to use with it.</p>
<p>So many compromises regardless of the method used. I've since switched to Sealtite Storage Bins from Target. They have a gasket around the lid and I've increased the bag of desiccant in each one. They stack well too.</p>
| 1,369
|
<p>I have a winform app that calls a web service to check for updates. This works in dev and it also works everywhere else I've tried it, just not on the installed copy on my machine (which happens to be the same in dev).</p>
<p>The error is:</p>
<p>Cannot execute a program. The command being executed was "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /noconfig /fullpaths @"C:\Documents and Settings\Giovanni.DOUBLE-AFSSZ043\Local Settings\Temp\squ8oock.cmdline".</p>
<p>The firewall is disabled and I've looked for "C:\Documents and Settings\Giovanni.DOUBLE-AFSSZ043\Local Settings\Temp\squ8oock.cmdline" and it is not there. Note that every time I try to use the web service the ".cmdline" file is different, for example the second time I ran it it was "dae8rgen.cmdline." No matter what name it has, I can never find the file.</p>
<p>Any suggestions?</p>
|
<p>The ".cmdline" file is an autogenerated file produced by the .NET framework. The application is attempting to real-time compile an XML Serializer used to parse the data from the web service.</p>
<p>Have you verified that you can execute "csc.exe" from a command-line window? Even just typing "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe /?" should get you a list of compiler options (or should give you an error if you don't have permissions to execute it).</p>
<p>What user account are you running this under, and does it have permissions to execute .exe files in the windows directory? Similarly, I know you said this happens with the installed copy on your machine, but is it possible it's executing off a network share and receiving limited Code Access Security permissions which would prevent it from running local executables?</p>
<p>For reference, here is a KB article showing a similar error that can occur in ASP.NET when the user account doesn't have enough permissions.
<a href="http://support.microsoft.com/kb/315904" rel="nofollow noreferrer">http://support.microsoft.com/kb/315904</a></p>
|
<p>If AppLocker is enforced, please allow below (add as path exception) </p>
<p><code>c:\windows\MICROSOFT.NET\FRAMEWORK\V2.0.50727\CSC.EXE</code>
<code>c:\windows\MICROSOFT.NET\FRAMEWORK\V2.0.50727\CVTRES.EXE</code></p>
| 8,764
|
<p>Does Geronimo provides a standalone transaction manager?
And if it does, is it possible to use it in Tomcat?</p>
|
<p><a href="http://openejb.apache.org/" rel="nofollow noreferrer">Apache OpenEJB</a> is embedded implementation of Geronimo EJB container that includes Transaction Manager. OpenEJB can be embedded into Tomcat which is one of its intended usages.</p>
|
<p>AFAIK, Geronimo uses <a href="http://jencks.codehaus.org/Transaction+Manager" rel="nofollow noreferrer">Jencks</a> that can be used standalone. But I can't say it's heavily documented. I'd rather consider using <a href="http://www.atomikos.com/" rel="nofollow noreferrer">Atomikos</a> or <a href="http://www.jboss.org/jbosstm/" rel="nofollow noreferrer">JBossTM</a>.</p>
<h3>Related answer</h3>
<ul>
<li><a href="https://stackoverflow.com/questions/2978207/atomikos-vs-jotm-vs-bitronix-vs/2978402#2978402">Atomikos vs JOTM vs Bitronix vs ????</a></li>
</ul>
| 24,632
|
<p>I have a class file that contains all the classes that are needed for a certain web application. Currently I'm at line 7269 and it contains numerous classes. I'm not particularly worried but I've started to notice that when working on this file Visual Studio responds slower. I'm thinking that this may be caused by the size of the file and Visual Studio's re-compile after every enter key press.</p>
<p>Has anyone got any recommendations for limits to lines per file of classes per file or perhaps guidelines as to how/why I should move classes into separate files?</p>
<p>I found this regarding Java but I'm specifically concerned with VB and Visual Studio 2005</p>
<p><a href="https://stackoverflow.com/questions/107855/is-there-any-no-of-lines-code-limit-for-a-java-class">Maximum lines of code permitted in a Java class?</a></p>
<p>Thanks</p>
<p>EDIT
There are about 50+ classes in the file, some tiny, some large!</p>
|
<p>Egad.</p>
<p>It's highly recommended by just about everyone that classes are contained in a file per class.</p>
<p>Lines isn't very relevant directly, but it can be a symptom that you're creating an overly complex god class and need to break the logic up. Unit test driven development forces this when done correctly.</p>
<p><strong>edit (noticed the "why?"):</strong> </p>
<p>from the fact you're asking it should be obvious :) </p>
<p>A few (of many reasons):</p>
<ul>
<li><p>it's very hard to visualise the actual code layout in large files</p></li>
<li><p>most IDEs are default set-up to show multiple files at a time, but not multiple views of the same file</p></li>
<li><p>source control over a single file can be a problem: "can you please check in {godfile} so I can work on the project?"</p></li>
<li><p>fragmenting code into namespaces/packages/branches is a problem</p></li>
</ul>
|
<p>1 class, 1 File, annakata is absolutely right.</p>
<p>In some cases really big classes you might consider using partial classes to split them in different files.</p>
<p>With only one really big file... that must be a nightmare to work in a team, how do you guys do it? I am guessing no source control and every change you need to make you must copy it to a deployment copy of the project.</p>
<p>That is a disaster just waiting to happen. Imagine if by any chance that one file got corrupted?</p>
| 48,943
|
<p>VB 6: How can I execute a .bat file but wait until its done running before moving on?</p>
|
<p>You will need to use Win32 API calls to <a href="http://msdn.microsoft.com/en-us/library/bb762154(VS.85).aspx" rel="noreferrer">ShellExecuteEx</a> and WaitForSingleObject on the process handle returned from ShellExecuteEx in the SHELLEXECUTEINFO structure. This is old code which I've pulled out of a project. It was working 100% but I may not have included all dependencies. You should be able to edit to your requirements:</p>
<pre><code> Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
' Optional fields'
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Public Declare Function ShellExecuteEx Lib "shell32.dll"
(lpExecInfo As SHELLEXECUTEINFO) As Long
Public Declare Function apiShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long
Declare Function WaitForSingleObject Lib "kernel32"
(ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Const SEE_MASK_NOCLOSEPROCESS As Long = &H40
Public Const SEE_MASK_FLAG_DDEWAIT As Long = &H100
'***App Window Constants***'
Public Const WIN_NORMAL = 1 'Open Normal'
Public Const WIN_MAX = 2 'Open Maximized'
Public Const WIN_MIN = 3 'Open Minimized'
'***Error Codes***'
Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
' Returns 'True' if file was opened ...'
Public Function fHandleFile(ByVal stFile As String, _
ByVal lShowHow As Long, _
ByRef stRet As String, _
Optional ByVal bWaitForClose As Boolean = False) As Boolean
On Error GoTo err_Handler
Dim lRet As Long
Dim ret As Long
Dim lngProcessHandle As Long
Dim varTaskID As Variant
Dim shInfo As SHELLEXECUTEINFO
Dim retval As Long
'First try ShellExecute'
With shInfo
.cbSize = LenB(shInfo)
.lpFile = stFile
.nShow = lShowHow
If bWaitForClose Then
.fMask = SEE_MASK_FLAG_DDEWAIT + SEE_MASK_NOCLOSEPROCESS
End If
.lpVerb = "open"
End With
Call ShellExecuteEx(shInfo)
lRet = shInfo.hInstApp
If lRet > ERROR_SUCCESS And bWaitForClose = True Then
lngProcessHandle = shInfo.hProcess
Do
retval = WaitForSingleObject(lngProcessHandle, 0)
DoEvents
Loop Until retval <> 258
ret = CloseHandle(lngProcessHandle)
End If
fHandleFile = (lRet > 0)
exit_handler:
Exit Function
err_Handler:
RaiseError Err.Number, Err.Source, Err.Description
End Function
</code></pre>
|
<p>Similarly, using the intrinsic Shell() function:</p>
<pre><code>Private Const INFINITE = &HFFFF
Private Const SYNCHRONIZE = &H100000
Private Const PROCESS_QUERY_INFORMATION = &H400
Private Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" ( _
ByVal hProcess As Long, _
lpExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" ( _
ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" ( _
ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Function SyncShell( _
ByVal PathName As String, _
ByVal WindowStyle As VbAppWinStyle) As Long
'Shell and wait. Return exit code result, raise an
'exception on any error.
Dim lngPid As Long
Dim lngHandle As Long
Dim lngExitCode As Long
lngPid = Shell(PathName, WindowStyle)
If lngPid <> 0 Then
lngHandle = OpenProcess(SYNCHRONIZE _
Or PROCESS_QUERY_INFORMATION, 0, lngPid)
If lngHandle <> 0 Then
WaitForSingleObject lngHandle, INFINITE
If GetExitCodeProcess(lngHandle, lngExitCode) <> 0 Then
SyncShell = lngExitCode
CloseHandle lngHandle
Else
CloseHandle lngHandle
Err.Raise &H8004AA00, "SyncShell", _
"Failed to retrieve exit code, error " _
& CStr(Err.LastDllError)
End If
Else
Err.Raise &H8004AA01, "SyncShell", _
"Failed to open child process"
End If
Else
Err.Raise &H8004AA02, "SyncShell", _
"Failed to Shell child process"
End If
End Function
</code></pre>
| 37,269
|
<p>Is there a way to attach an event to a foreign / separate window from an .NET process that when the foreign window is closed or is about to close my application can be notified?</p>
<p>I found this <a href="http://msdn.microsoft.com/en-us/library/ms229658.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms229658.aspx</a></p>
<p>But that seems to only be for the .NET compact framework. I am looking for something using the .NET 2.0 framework.</p>
|
<p>There's an article on <a href="http://www.codeproject.com/KB/system/WilsonSystemGlobalHooks.aspx" rel="nofollow noreferrer">CodeProject</a> that looks at using global hooks to receive windows messages from other applications.</p>
<p>Can you <a href="http://support.microsoft.com/kb/305369" rel="nofollow noreferrer">wait for the process to exit</a>? </p>
<p>Or are you stuck needing to poll and check that you can still <a href="http://msdn.microsoft.com/en-us/library/ms633499(VS.85).aspx" rel="nofollow noreferrer">Find</a> the window?</p>
|
<p>Look into SetWindowsHookEx with the WH_CBT parameter. There will be a HCBT_DESTROYWND entry.</p>
| 20,461
|
<p>Everyone (at least everyone who uses a compiled language) has faced compilation errors but how many times do you get to actually crash the compiler? </p>
<p>I've had my fair share of <strong>"internal compiler errors"</strong> but most went away just by re-compiling. Do you have a (minimal) piece of code that crashes the compiler?</p>
|
<p>I write the compiler we use, so it crashes sometimes.</p>
|
<p>VC++ has crashed on me when compiling C++ if template usage is messed up (e.g., missing out on a closing ">").</p>
| 23,629
|
<p>I do remember seeing someone ask something along these lines a while ago but I did a search and couldn't find anything. </p>
<p>I'm trying to come up with the cleanest way to clear all the controls on a form back to their defaults (e.g., clear textboxes, uncheck checkboxes).</p>
<p>How would you go about this?</p>
|
<p>What I have come up with so far is something like this:</p>
<pre><code>public static class extenstions
{
private static Dictionary<Type, Action<Control>> controldefaults = new Dictionary<Type, Action<Control>>() {
{typeof(TextBox), c => ((TextBox)c).Clear()},
{typeof(CheckBox), c => ((CheckBox)c).Checked = false},
{typeof(ListBox), c => ((ListBox)c).Items.Clear()},
{typeof(RadioButton), c => ((RadioButton)c).Checked = false},
{typeof(GroupBox), c => ((GroupBox)c).Controls.ClearControls()},
{typeof(Panel), c => ((Panel)c).Controls.ClearControls()}
};
private static void FindAndInvoke(Type type, Control control)
{
if (controldefaults.ContainsKey(type)) {
controldefaults[type].Invoke(control);
}
}
public static void ClearControls(this Control.ControlCollection controls)
{
foreach (Control control in controls)
{
FindAndInvoke(control.GetType(), control);
}
}
public static void ClearControls<T>(this Control.ControlCollection controls) where T : class
{
if (!controldefaults.ContainsKey(typeof(T))) return;
foreach (Control control in controls)
{
if (control.GetType().Equals(typeof(T)))
{
FindAndInvoke(typeof(T), control);
}
}
}
}
</code></pre>
<p>Now you can just call the extension method ClearControls like this:</p>
<pre><code> private void button1_Click(object sender, EventArgs e)
{
this.Controls.ClearControls();
}
</code></pre>
<p>EDIT: I have just added a generic ClearControls method that will clear all the controls of that type, which can be called like this:</p>
<pre><code>this.Controls.ClearControls<TextBox>();
</code></pre>
<p>At the moment it will only handle top level controls and won't dig down through groupboxes and panels.</p>
|
<p>Below are methods I use to clear text from a <strong>type</strong> of control that implements ITextBox.</p>
<p>I noticed in the example default boolean values are set. I'm sure you can modify it to set default values of boolean components.</p>
<p>Pass the Clear method a control type (TextBox, Label... etc) and a control collection, and it will clear all text from controls that implement ITextBox.</p>
<p>Something like this:</p>
<pre><code>//Clears the textboxes
WebControlUtilities.ClearControls<TextBox>(myPanel.Controls);
</code></pre>
<p>The Clear method is meant for a Page or Masterpage. The control collection type may vary. ie. Form, ContentPlaceHolder.. etc</p>
<pre><code> /// <summary>
/// Clears Text from Controls...ie TextBox, Label, anything that implements ITextBox
/// </summary>
/// <typeparam name="T">Collection Type, ie. ContentPlaceHolder..</typeparam>
/// <typeparam name="C">ie TextBox, Label, anything that implements ITextBox</typeparam>
/// <param name="controls"></param>
public static void Clear<T, C>(ControlCollection controls)
where C : ITextControl
where T : Control
{
IEnumerable<T> placeHolders = controls.OfType<T>();
List<T> holders = placeHolders.ToList();
foreach (T holder in holders)
{
IEnumerable<C> enumBoxes = holder.Controls.OfType<C>();
List<C> boxes = enumBoxes.ToList();
foreach (C box in boxes)
{
box.Text = string.Empty;
}
}
}
/// <summary>
/// Clears the text from control.
/// </summary>
/// <typeparam name="C"></typeparam>
/// <param name="controls">The controls.</param>
public static void ClearControls<C>(ControlCollection controls) where C : ITextControl
{
IEnumerable<C> enumBoxes = controls.OfType<C>();
List<C> boxes = enumBoxes.ToList();
foreach (C box in boxes)
{
box.Text = string.Empty;
}
}
</code></pre>
| 38,075
|
<p>I very rarely meet any other programmers!</p>
<p>My thought when I first saw the token was "implies that" since that's what it would read it as in a mathematical proof but that clearly isn't its sense.</p>
<p>So how do I say or read "=>" as in:-</p>
<pre><code>IEnumerable<Person> Adults = people.Where(p => p.Age > 16)
</code></pre>
<p>Or is there even an agreed way of saying it?</p>
|
<p>I usually say 'such that' when reading that operator.</p>
<p>In your example, p => p.Age > 16 reads as "P, such that p.Age is greater than 16."</p>
<p>In fact, I asked this very question on the official linq pre-release forums, and Anders Hejlsberg responded by saying</p>
<blockquote>
<p>I usually read the => operator as "becomes" or "for which". For example,<br />
Func f = x => x * 2;<br />
Func test = c => c.City == "London";<br />
reads as "x becomes x * 2" and "c for which c.City equals London"</p>
</blockquote>
<p>As far as 'goes to' - that's never made sense to me. 'p' isn't going anywhere.</p>
<p>In the case of reading code to someone, say, over the phone, then as long as they're a fellow C# programmer, I'd just use the word 'lambda' - that is, "p lambda p dot age greater-than sixteen."</p>
<p>In comments Steve Jessop mentioned 'maps to' in the case of transformations - so taking Anders' example:</p>
<pre><code>x => x * 2;
</code></pre>
<p>would read</p>
<blockquote>
<p>x maps to x times 2.</p>
</blockquote>
<p>That does seem much closer to the actual intention of the code than 'becomes' for this case.</p>
|
<p>My two cents:</p>
<pre><code>s => s.Age > 12 && s.Age < 20
</code></pre>
<p>"Lambda Expression with parameter s is { <code>return s.Age > 12 && s.Age < 20;</code> }"</p>
<p>I like this because it reminds me of where lamdba expression comes from</p>
<pre><code>delegate(Student s) { return s.Age > 12 && s.Age < 20; };
</code></pre>
<p>=> is just a shortcut so you don't have to use the delegate keyword and include the type info since it can be inferred by the compiler.</p>
| 34,525
|
<p>So far I've found the following components for building ASP.NET MVC views:</p>
<ul>
<li><a href="http://developer.yahoo.com/yui/" rel="nofollow noreferrer">Yahoo UI (YUI)</a> </li>
<li><a href="http://extjs.com/products/extjs/" rel="nofollow noreferrer">Ext JS</a></li>
<li><a href="http://www.webplicity.net/flexigrid/" rel="nofollow noreferrer">Flexgrid</a> (grid only)</li>
</ul>
<p>What are the other options that are currently available which inlcude a nice grid component?</p>
|
<p>Check out <a href="http://bartreyserhove.blogspot.com/2008/08/aspnet-mvc-and-jqgrid.html" rel="nofollow noreferrer">JQGrid</a></p>
|
<ul>
<li><a href="http://www.urautoloads.com/ci/index.aspx" rel="nofollow noreferrer">JQuery</a> </li>
<li><a href="http://plugins.jquery.com/" rel="nofollow noreferrer">JQuery Pugins</a></li>
</ul>
<p>There are some grid plugins, which I have not used:</p>
<ul>
<li><a href="http://www.webplicity.net/flexigrid/" rel="nofollow noreferrer">FlexGrid</a> </li>
<li><a href="http://digitalbush.com/projects/jquery-grid-plugin/" rel="nofollow noreferrer">JQuery Grid plugin</a></li>
<li><a href="http://www.trirand.com/blog/?p=23" rel="nofollow noreferrer">Another JQuery Grid plugin</a></li>
</ul>
| 30,330
|
<p>I have just started playing with the ASP.Net MVC framework, and today I created a simple UserControl that uses some CSS. Since the CSS was declared in a separate file and included in the View that called the UserControl, and not in the UserControl itself, Visual Studio could not find any of the CSS classes used in the UserControl. This got me thinking about what would be the most appropriate way of dealing with CSS in UserControls.</p>
<p>Declaring the CSS in the View that is using the UserControl gives more flexibility if the same control is used in different contexts and needs to be able to adapt to the style of the calling View.</p>
<p>Having the UserControl supply its own CSS would lead to a more clear separation, and the Views would not need to know anything about the HTML/CSS generated by the UserControl, but at the cost of a fixed look of the control.</p>
<p>Since I am totally new to the framework, I'm guessing people have already come to some good conclusions about this.</p>
<p>So, would you have the UserControl handle its own CSS, should it depend on the CSS declared in the calling View, or is there another, better solution?</p>
|
<p>If you look at a skinable toolkit like Yahoo UI it documents the classes used by each control and then provides a single skin file for the entire toolkit. By swapping out the single skin file you can change looks for your entire site.</p>
<p>I would assume that 99.9% of the time you would want to custom skin your controls and not have them come predefined with a look and feel.</p>
<p>As an example <a href="http://developer.yahoo.com/yui/tabview/#cssref" rel="nofollow noreferrer">here</a> are the CSS defines for Yahoo's TabView control</p>
|
<p>A quick point... it's ok for your Views to be aware of HTML... that's what they are for. What I would recommend (if you want to be ubber cool), is to add a parameter to your "<a href="http://www.singingeels.com/Articles/Building_Custom_ASPNET_MVC_Controls.aspx" rel="nofollow noreferrer">MVC UserControl</a>" that specifies the class name. Example:</p>
<pre><code><%= MyHelperClass.Marquee("This text will scroll!!!", "important-text") %>
</code></pre>
<p>I'm of course pretending that "important-text" is the class name that I want to add to my control.</p>
<p>I am assuming that when you say "UserControl", you're referring to an example like in that link above.</p>
| 44,931
|
<p>I am trying to format a date with: </p>
<pre><code><fmt:formatDate value="${newsletter.createdOn}" pattern="MM/dd/yyyy"/>
</code></pre>
<p>newsletter is an object with a <code>createdOn</code> property which is <code>java.util.Date</code>.</p>
<p>When I invoke the previous sentence I get: </p>
<p>According to the TLD, the attribute value does not accept expressions. </p>
<p>I am importing fmt with </p>
<pre><code><%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
</code></pre>
<p>Does anyone know how can I work around this problem?</p>
<p>I am using the jstl.jar coming with tomcat. </p>
<p>Under jstl.jar/META-INF/MANIFEST.MF stays: </p>
<pre><code>Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.3
Created-By: 1.4.2-b28 (Sun Microsystems Inc.)
Specification-Title: JavaServer Pages Standard Tag Library (JSTL)
Specification-Version: 1.1
Implementation-Title: JavaServer Pages Standard Tag Library API Refere
nce Implementation
Implementation-Version: 1.1.0-D13
Implementation-Vendor: Sun Microsystems, Inc.
Implementation-Vendor-Id: com.sun
Extension-Name: javax.servlet.jsp.jstl
</code></pre>
<p>I am using Apache Tomcat Version 6.0.14</p>
|
<p>Try </p>
<pre><code><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
</code></pre>
|
<p>Are you using the <code>fmt-1_0-rt.tld</code> or <code>fmt-1_0.tld</code> taglib.</p>
<p>The difference is the settings for <code>rtexprvalue</code></p>
<p>In one, this is false, in the other it is true.</p>
| 35,602
|
<p>Is there any way to change the background color of the Solution Explorer in Visual Studio using a Theme? - or any other way for that matter?</p>
<p>I can change it by changing windows-wide color settings, but obviously that affects too much.</p>
|
<p>Just created VS extension for that in under an hour, search extension manager for "SExColor". Enjoy ;)</p>
|
<p>Not by any means of configuration from Visual Studio itself.</p>
<p>You can however probably "hack" the window object from the Win32 API (look up "window enumeration"). Once you have the window handle, you can set all characterstics you want.</p>
<p>Regards</p>
<p>/Robert</p>
| 22,925
|
<p>I have two fields on my web page ie: BookAuthor and BookDescription.On submit,the page searches against lucene index using the given search criteria.</p>
<p>If the user does not type in anything in the two fields and submits the page, how do make Lucene.Net return all the books from my index irrespective of BookAuthor and BookDescription field values?</p>
<p>Thanks!</p>
|
<p>the correct way to do this is to use a MatchAllDocsQuery: </p>
<p><a href="http://lucene.apache.org/java/2_9_4/api/core/org/apache/lucene/search/MatchAllDocsQuery.html" rel="nofollow">http://lucene.apache.org/java/2_9_4/api/core/org/apache/lucene/search/MatchAllDocsQuery.html</a></p>
|
<p>I'm not sure if this is the correct way but you could add another non nullable term to the index (say BookIsPublished) with a default value and if no search term is entered by the user return all matching items on the BookIsPublished constant field.</p>
| 44,340
|
<p>Starting a new project and would like to use one of the MVC framworks. <a href="http://www.asp.net/mvc/" rel="nofollow noreferrer">ASP.NET MVC</a> is still in preview but <a href="http://springframework.net/" rel="nofollow noreferrer">Spring.net</a> is in production and has a history with Java. I'd like to know the general lowdown between the two.</p>
<p>Current questions..<br>
What are the major feature differences?<br>
What about deployment/hosting issues?<br>
Future support? Do you think Spring.net will fade once ASP.NET MVC is in production.<br>
Current Support? I saw the Jeff twitting about a breaking change in the next preview. </p>
<p>Thanks!</p>
|
<p>I am a little confused by the question. Spring.Net is a dependency injection framework that you can use in ASP.NET MVC. I kind of based my answer off what you are actually asking though. The difference between ASP.NET MVC and another MVC framework that runs in ASP.NET.</p>
<p>If you are worried about using ASP.NET MVC in production since it is not even in beta yet, then you may want to check out <a href="http://www.castleproject.org/MonoRail/" rel="nofollow noreferrer">MonoRail</a> as an alternate. There are some differences in features, but the two are pretty close in terminology and how MVC is implemented. To learn differences, <a href="https://stackoverflow.com/questions/24165/from-monorail-to-aspnet-mvc">here is a question</a> that was posted, that you might want to monitor. I think once ASP.NET hits release, that most Microsoft shops will switch to it. With ASP.NET MVC still being developed, you will run into breaking changes that you will have to change when you upgrade to the next release. That goes with the territory of living on the edge. You just need to read the release notes before jumping to the latest release.</p>
|
<p>I have an impression that Spring.NET never really took off, or at least not as much as <a href="http://www.castleproject.org/MonoRail/" rel="nofollow noreferrer">Castle Project Monorail</a>. </p>
<p>From what I understand, Spring.NET has also departed from Java Spring's implementation, so there will a steeper than expected learning curve if you are coming from Java. From <a href="http://springframework.net/overview.html" rel="nofollow noreferrer">Spring.NET's overview</a>:</p>
<blockquote>
<p>The design of Spring.NET is based on
the Java version of the Spring
Framework, which has shown real-world
benefits and is used in thousands of
enterprise applications world wide.
Spring .NET is not a quick port from
the Java version, but rather a
'spiritual port' based on following
proven architectural and design
patterns in that are not tied to a
particular platform.</p>
</blockquote>
<p>As for your other questions, the breadth of the topics make them a bit difficult to answer in one go, but I am hoping Phil Haack will see this question and respond. :)</p>
| 6,463
|
<p>How do you retain the indentation of numbered lists? I have a page where the numbers are pushed off the page. How can I prevent this?</p>
<pre><code><ol style="padding: 0">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
</code></pre>
|
<p>With a CSS rule like this:</p>
<pre><code>ol { margin-left: 30px; }
</code></pre>
<p>Here's some information about the <a href="http://redmelon.net/tstme/box_model/" rel="nofollow noreferrer">CSS box model</a>.</p>
|
<p>What about using:</p>
<pre><code>li { list-style-position: outside; }
</code></pre>
| 27,497
|
<p>Is it possible to suppress warnings in Eclipse for JDK1.4 project?</p>
<p>EDIT:
Longer version. There is a project which requires JDK1.4 (no annotations). Only way of suppressing warnings I know is using annotation @SuppressWarnings - no can do in JDK1.4. Is there any way to remove some warning notifications in some specific method/class (not whole project) ?</p>
|
<p>If you mean that you are writing Java 1.4 code, and you are getting warnings because you aren't using generics, set your Java Compiler settings to 1.4. You can do this on a per-project basis, or for the whole workspace.</p>
<p>Window->Preferences->Java->Compiler->Compiler Compliance Level = 1.4</p>
<p>To disable specific warnings, such as those regarding unnecessary casts, etc., you can tailor them under the Compiler->Errors/Warnings panel. Most of these warnings, however, are not version specific, and can be quite helpful if heeded.</p>
<p>Workspace settings can be overridden for a project, but I don't know of a way that gives you annotation-like control over a specific class or method.</p>
|
<p>Setting the compiler to 1.4 compliance in the properties of the project should do the trick. Just right click your project and select "Properties" at the bottom and then search for "Compiler".</p>
| 21,230
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.