instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>My site has a drop-down menu built in CSS and JavaScript that drops down over a Flash animation. In IE (6&amp;7) the drop-down menus drop over the Flash animation, however, in Firefox (2&amp;3) the menus appear underneath the Flash animation. Is there any way to get this dynamic menu to flow OVER the Flash in Fire...
<p>Try setting wmode to transparent - see <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15523" rel="noreferrer">here</a></p>
<p>Have you tried the iframe trick (i.e. floating an iframe behind the menu, thus putting hte flash layers behind.)</p>
8,269
<p>Does anyone know of a good example of how to expose a WCF service programatically without the use of a configuration file? I know the service object model is much richer now with WCF, so I know it's possible. I just have not seen an example of how to do so. Conversely, I would like to see how consuming without a con...
<p>Consuming a web service without a config file is very simple, as I've discovered. You simply need to create a binding object and address object and pass them either to the constructor of the client proxy or to a generic ChannelFactory instance. You can look at the default app.config to see what settings to use, then...
<p>All WCF configuration can be done programatically. So it's possible to create both servers and clients without a config file. </p> <p>I recommend the book "Programming WCF Services" by Juval Lowy, which contains many examples of programmatic configuration.</p>
7,820
<p>How can I determine all of the assemblies that my .NET desktop application has loaded? I'd like to put them in the about box so I can query customers over the phone to determine what version of XYZ they have on their PC.</p> <p>It would be nice to see both managed and unmanaged assemblies. I realize the list will...
<pre><code>using System; using System.Reflection; using System.Windows.Forms; public class MyAppDomain { public static void Main(string[] args) { AppDomain ad = AppDomain.CurrentDomain; Assembly[] loadedAssemblies = ad.GetAssemblies(); Console.WriteLine("Here are the assemblies loaded in this appdomai...
<p>Looks like <code>AppDomain.CurrentDomain.GetAssemblies();</code> will do the trick :)</p>
4,134
<p>I've been utilizing the <a href="http://en.wikipedia.org/wiki/Command_pattern" rel="nofollow noreferrer">command pattern</a> in my Flex projects, with asynchronous callback routes required between:</p> <ul> <li>whoever instantiated a given command object and the command object,</li> <li>the command object and the "...
<p>I'll try one more idea:</p> <p>Have your Data Access Object return their own AsyncTokens (or some other objects that encapsulate a pending call), instead of the AsyncToken that comes from the RPC call. So, in the DAO it would look something like this (this is very sketchy code):</p> <pre><code>public function dele...
<p>The AbstractCollection is the best way to deal with Persistent Objects in Flex / AIR. The GenericDAO provides the answer.</p> <p>DAO is the Object which manages to perform CRUD Operation and other Common Operations to be done over a ValueObject ( known as Pojo in Java ). GenericDAO is a reusable DAO class which can...
7,639
<p>Hello again ladies and gents!</p> <p>OK, following on from my other question on <a href="https://stackoverflow.com/questions/6681/aspnet-web-service-results-proxy-classes-and-type-conversion">ASP.NET Web Service Results, Proxy Classes and Type Conversion</a>. I've come to a part in my project where I need to get my ...
<p>The .Net XML (de)serialisation is pretty nicely implemented. At first thought, I don't think this is a bad idea at all.</p> <p>If the two applications import the same C# class(es) definition(s), then this is a relatively nice way of getting copy-constructor behaviour for free. If the class structure changes, then e...
<p>I had some great answers on a very similar topic yesterday that might be useful for you:</p> <p><a href="https://stackoverflow.com/questions/16529/communication-between-javascript-and-the-server">Communication between javascript and the server</a></p>
3,831
<p>I've always had trouble getting prints to stick directly on my bed, but had great reliability when use rafts. This didn't present a problem when I was using PLA, but I recently got a roll of PETG and it is very hard to remove rafts, so I am once again trying to figure out whats wrong.</p> <p>I am printing the same ...
<p>You could experiment with the 'cleaning' part of the startup gcode shown <a href="http://reprap.org/wiki/Start_GCode_routines" rel="nofollow noreferrer">here</a></p> <pre><code>G1 X100 Y0 F4000 ; move half way along the front edge G1 Z1 ; move nozzle close to bed M109 S200 ; heat nozzle to 200 degC and wait until r...
<p>You could experiment with the 'cleaning' part of the startup gcode shown <a href="http://reprap.org/wiki/Start_GCode_routines" rel="nofollow noreferrer">here</a></p> <pre><code>G1 X100 Y0 F4000 ; move half way along the front edge G1 Z1 ; move nozzle close to bed M109 S200 ; heat nozzle to 200 degC and wait until r...
617
<p>I've got a utility that outputs a list of files required by a game. How can I run that utility within a C program and grab its output so I can act on it within the same program?</p> <p>UPDATE: Good call on the lack of information. The utility spits out a series of strings, and this is supposed to be portable acros...
<p>For simple problems in Unix-ish environments try <a href="http://pubs.opengroup.org/onlinepubs/009696799/functions/popen.html" rel="noreferrer"><code>popen()</code></a>. </p> <p>From the man page:</p> <blockquote> <p>The popen() function opens a process by creating a pipe, forking and invoking the shell.</p> </b...
<pre><code>//execute external process and read exactly binary or text output //can read image from Zip file for example string run(const char* cmd){ FILE* pipe = popen(cmd, "r"); if (!pipe) return "ERROR"; char buffer[262144]; string data; string result; int dist=0; int size; //TIME_STAR...
6,471
<p>Sorry for the subject line sounding like an even nerdier Harry Potter title.</p> <p>I'm trying to use AS3's Socket class to write a simple FTP program to export as an AIR app in Flex Builder 3. I'm using an FTP server on my local network to test the program. I can successfully connect to the server (the easy part...
<p>The FTP protocol predates UTF encoding. Switch to ANSI/ASCII for better results. If you do opt for writeMultiByte instead of writeUTFBytes, be aware that it is buggy in linux. <a href="http://www.flexiblefactory.co.uk/flexible/?p=75" rel="nofollow noreferrer">Here's</a> one way around it.</p> <p>There's another ques...
<p>We will need more info to resolve this.. What you're saying here appears correct to me. You're using the Socket class to send data though, not ByteArray.</p> <p>Are you sure data is not being sent? How are you receiving the response? It may be that it's working fine but you're just not aware of it? As i said, tell ...
8,857
<p>How do I capture the output of "%windir%/system32/pnputil.exe -e"? (assume windows vista 32-bit)</p> <p>Bonus for technical explanation of why the app normally writes output to the cmd shell, but when stdout and/or stderr are redirected then the app writes nothing to the console or to stdout/stderr?</p> <pre> C:\W...
<p>Doesn't seem like there is an easy way at all. You would have to start hooking the call to WriteConsole and dumping the string buffers. See <a href="http://objectmix.com/tcl/366746-autoexpect-under-windows-later-mac-linux.html#post1359780" rel="nofollow noreferrer">this post</a> for a similar discussion.</p> <p>O...
<p>Some applications are written so that it works in piping scenarios well e.g.</p> <pre><code>svn status | find "? " </code></pre> <p>is a command that pipes output of <code>svn status</code> into <code>find "? "</code> so it would filter subversion output down to unknown files (marked with a question mark) in my re...
7,819
<p>You can embed the <a href="http://ipython.scipy.org/" rel="noreferrer">IPython</a> shell inside of your application so that it launches the shell in the foreground. Is there a way to embed a telnet server in a python app so that you can telnet to a certain port and launch a remote IPython shell? </p> <p>Any tips ...
<p>Python includes a <a href="http://www.python.org/doc/lib/module-telnetlib.html" rel="nofollow noreferrer">telnet client</a>, but not a telnet server. You can implement a telnet server using <a href="http://twistedmatrix.com" rel="nofollow noreferrer">Twisted</a>. <a href="http://twistedmatrix.com/pipermail/twisted...
<p>I think you should base your server class on the <a href="http://www.python.org/doc/lib/module-SocketServer.html" rel="nofollow noreferrer"><code>SocketServer</code></a> class from the standard library. You'll need to write a <code>RequestHandler</code> to read and echo input but a lot of the heavy lifting is alrea...
7,054
<p>How have you implemented Internationalization (i18n) in actual projects you've worked on?</p> <p>I took an interest in making software cross-cultural after I read the famous post by Joel, <a href="http://www.joelonsoftware.com/articles/Unicode.html" rel="noreferrer">The Absolute Minimum Every Software Developer Abs...
<p>It has been a while, so this is not comprehensive.</p> <p><strong>Character Sets</strong></p> <p>Unicode is great, but you can't get away with ignoring other character sets. The default character set on Windows XP (English) is Cp1252. On the web, you don't know what a browser will send you (though hopefully your c...
<p>One website I use has a translation method the owner calls "wiki + machine translation". This is a community based site so is obviously different to the needs of companies. </p> <p><a href="http://blog.bookmooch.com/2007/09/23/how-bookmooch-does-its-translations/" rel="nofollow noreferrer">http://blog.bookmooch.com...
2,333
<p>I have an application that sometimes causes a BSOD on a Win XP machine. Trying to find out more, I loaded up the resulting *.dmp file (from C:\Windows\Minidump), but get this message when in much of the readout when doing so:</p> <pre><code>********************************************************************* * Sy...
<p>Quick answer is to </p> <p>c:\> set _NT_SYMBOL_PATH=SRV*C:\WINDOWS\Symbols*http://msdl.microsoft.com/download/symbols</p> <p>before starting windbg.</p>
<p>As @Vaibhav noted, you actually need to download the symbols and configure windbg to use them.</p> <p>Also note the following: !sym noisy -- Activates noisy symbol loading lm v -- Use with "m" parameter to look at information for a loaded module. lme D sm - List all modules w/o symbols.</p>
3,313
<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 bet...
<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...
<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...
3,317
<p>Was considering the <code>System.Collections.ObjectModel ObservableCollection&lt;T&gt;</code> class. This one is strange because </p> <ul> <li>it has an Add Method which takes <strong>one</strong> item only. No AddRange or equivalent. </li> <li>the Notification event arguments has a NewItems property, which is a <...
<p>It seems that the <code>INotifyCollectionChanged</code> interface allows for updating when multiple items were added, so I'm not sure why <code>ObservableCollection&lt;T&gt;</code> doesn't have an <code>AddRange</code>. You could make an extension method for <code>AddRange</code>, but that would cause an event for ...
<p>Take a look at <a href="https://stackoverflow.com/questions/670577/observablecollection-doesnt-support-addrange-method-so-i-get-notified-for-each/670579#670579">Observable collection with AddRange, RemoveRange and Replace range methods</a> in both C# and VB.</p> <p>In VB: INotifyCollectionChanging implementation.</...
8,123
<p>In follow up to <a href="https://stackoverflow.com/questions/56820/round-in-python-doesnt-seem-to-be-rounding-properly">this question</a>, it appears that some numbers cannot be represented by floating point at all, and instead are approximated.</p> <p>How are floating point numbers stored?</p> <p>Is there a commo...
<p>As mentioned, the <a href="http://en.wikipedia.org/wiki/IEEE_754-1985" rel="noreferrer">Wikipedia article on IEEE 754</a> does a good job of showing how floating point numbers are stored on most systems.</p> <p>Now, here are some common gotchas:</p> <ul> <li>The biggest is that you almost never want to compare two...
<p>What I remember is a 32 bit floating point is stored using 24 bits for a actual number, and the remain 8 bits are used as a power of 10, determining where the decimal point is.</p> <p>I'm a bit rusty on the subject tho...</p>
8,111
<p>I want to print a structure that I can embed in a resin and later dissolve. I know that some fancy 3D printing systems have raft materials etc., that can be printed and later removed easily. </p> <p>Can any one suggest a 3D printing material that can be dissolved in say water or another readily available solvent?</...
<p>Wash-away filament used for support in PLA printing is typically PVA, which is completely water soluble and may serve your purpose. It is easily 3D printed as the primary filament and attaches well to the build plate.</p> <p>Many 3D printer filament suppliers will carry this type of support material. It is importan...
<p>ABS dissolves in acetone. Indeed actone can be used to clean up 3D prints, see <a href="https://3dprinting.stackexchange.com/questions/4235/whats-smoother-acetone-treated-pla-or-abs/">What&#39;s smoother? Acetone treated PLA or ABS</a>. PLA maybe not somuch as ABS, see the same post.</p> <p>PLA dissolves in any chl...
910
<p>I am looking for simple straightforward solution for accessing EXIF information of jpeg images in .Net. Does anybody has experience with this?</p>
<p>If you're willing to use an open-source library, may I humbly suggest one of my own creation?</p> <p>The <em>metadata-extractor</em> project has been alive and well since 2002 for Java, and is now available for .NET.</p> <ul> <li>Open source (Apache 2.0)</li> <li>Heavily tested and widely used</li> <li>Supports ma...
<p>Several years ago, I started a little JPEG EXIF app with Omar Shahine to work on JPEG EXIF files, called JpegHammer.</p> <p>He extracted from that project a library and called it PhotoLibrary, it was an easy .NET wrapper for the EXIF 2.2 tags. Unfortunately, the GotDotNet site is gone, CodePlex doesn't have it, Oma...
6,343
<p>I want my website to join some webcam recordings in FLV files (like this one). This needs to be done on Linux without user input. How do I do this? For simplicity's sake, I'll use the same flv as both inputs in hope of getting a flv that plays the same thing twice in a row.</p> <p>That should be easy enough, right?...
<p>I thought it would be a nice learning exercise to rewrite it in Ruby.</p> <p>It was.</p> <p>Six months later and three gems later, <a href="http://github.com/marcandre/flvedit" rel="nofollow noreferrer">here's the released product</a>.</p> <p>I'll still be working a bit on it, but it works.</p>
<p>dont know if this will actually work but try using this command : </p> <pre><code>cat yourVideos/*.flv &gt;&gt; big.flv </code></pre> <p>this will probably damage meta information so after executing that command use "flvtool" (ruby script you can find it with google) to fix it.</p>
9,324
<p>What are the differences between delegates and an events? Don't both hold references to functions that can be executed?</p>
<p>An <strong>Event</strong> declaration adds a layer of abstraction and protection on the <strong>delegate</strong> instance. This protection prevents clients of the delegate from resetting the delegate and its invocation list and only allows adding or removing targets from the invocation list.</p>
<p>An event in .net is a designated combination of an Add method and a Remove method, both of which expect some particular type of delegate. Both C# and vb.net can auto-generate code for the add and remove methods which will define a delegate to hold the event subscriptions, and add/remove the passed in delegagte to/f...
4,884
<p>So yesterday I got my power supply in the mail and I thought, let's check it out!</p> <p>I put all the wires in correctly (as shown in this YouTube video, <a href="https://www.youtube.com/watch?v=X8GhVKG2Nno" rel="nofollow noreferrer">Anet A8 power supply unit fuse blown</a>, I just searched really quickly, this per...
<p>You need to closely look at how to connect to the output connectors. In this case it appears that you have wired it correctly according to the stamped in markings above the connectors. You have chosen not to connect the earth, this is strongly advised.</p> <p>Did you check if the power switch matches the voltage of...
<h3>Unless you know what you're doing, do not remove the covers from a PSU. The components can store a lethal charge long after power is removed, even if the fuse is blown.</h3> <p>My guess is something loose (now vapourised) in the PSU. Electronics have a tendancy of failing either quite soon after manufacture, or las...
1,214
<p>I want to disable the selection of certain rows in a datagridview.</p> <p>It must be possible to remove the select property for one or more datagridview rows in a datagridview shown in a winform. The goal is that the user can't select certain rows. (depending on a condition)</p> <p>Thankx,</p>
<p>If SelectionMode is FullRowSelect, then you'll need to override SetSelectedRowCore for that DataGridView, and not call the base SetSelectedRowCore for rows you don't want selected.</p> <p>If SelectionMode is not FullRowSelect, you'll want to additionally override SetSelectedCellCore (and not call the base SetSelect...
<pre><code>Private Sub dgvSomeDataGridView_SelectionChanged(sender As Object, e As System.EventArgs) Handles dgvSomeDataGridView.SelectionChanged dgvSomeDataGridView.ClearSelection() End Sub </code></pre>
9,692
<p>I'd like to create a spring bean that holds the value of a double. Something like:</p> <pre><code>&lt;bean id="doubleValue" value="3.7"/&gt; </code></pre>
<p>Declare it like this:</p> <pre><code>&lt;bean id="doubleValue" class="java.lang.Double"&gt; &lt;constructor-arg index="0" value="3.7"/&gt; &lt;/bean&gt; </code></pre> <p>And use like this:</p> <pre><code>&lt;bean id="someOtherBean" ...&gt; &lt;property name="value" ref="doubleValue"/&gt; &lt;/bean&gt; </cod...
<p>Why don't you just use a <strong>Double</strong>? any reason?</p>
8,461
<p>I need to have a summary field in each page of the report and in page 2 and forward the same summary has to appear at the top of the page. Anyone know how to do this? Ex:</p> <pre><code>&gt; &gt; Page 1 &gt; &gt; Name Value &gt; a 1 &gt; b 3 &gt; Total 4 &gt; &gt; Page 2 &gt; Name Valu...
<p>Create a new Running Total Field called, for example "RTotal". In "Field to summarize" select "Value", in "Type of summary" select "sum", under "Evaluate" select "For each record". You can then drag this field into your report to use as the "Total" at the bottom of each page.</p> <p>You cannot use this running tota...
<p>I do not understand your question all the way.</p> <p>If you need an overall summary that is repeated, you would need a sub-report that have shown in the report multiple times.</p>
4,550
<p>I've come to love <a href="http://en.wikipedia.org/wiki/Amazon_Elastic_Compute_Cloud" rel="nofollow noreferrer">Amazon's EC2 service</a> and I'm looking for something similar that supports the ability to save a running Windows server image and start new instances from it.</p> <p>I contacted <a href="http://www.gogr...
<p>I have just received a message from Amazon to the effect that that they will be <a href="http://aws.amazon.com/windows/" rel="nofollow noreferrer">supporting Windows Server on EC2</a> this fall.</p> <p>Wahaay!!</p>
<p>Seems like dealing with licensing issues would be nightmarish for the host.</p>
4,248
<p>The Y-axis belt just broke on my Ender 3 v2. I believe that it was over tensioned from the factory. When I initially assembled the printer, I noticed that the Y-axis tensioner was tightened almost all the way. The belt itself felt very stiff. The X-axis belt, which I installed upon assembly, didn't require a lot of ...
<p>Generally, a timing belt is a complicated device and many things depend on its internal construction and materials (it may be damaged when bound in wrong direction, or when cut, and when overtighten of course, etc.). There is also physics and math applicable, based on <a href="https://en.wikipedia.org/wiki/Mersenne%...
<p>Mine came from the factory tight enough that it doesn't sag at all, but not so tight that it feels hard or stiff or difficult to deflect a bit with gentle pressure. With the bed pushed all the way to the back, I can push the y-axis belt to the side about 1/8&quot; with gentle pressure, and it feels like that's about...
1,822
<p>I was reading a book on programming skills wherein the author asks the interviewee, "How do you crash a JVM?" I thought that you could do so by writing an infinite for-loop that would eventually use up all the memory.</p> <p>Anybody has any idea?</p>
<p><a href="http://en.wikipedia.org/wiki/Java_Native_Interface" rel="noreferrer">JNI</a>. In fact, with JNI, crashing is the default mode of operation. You have to work extra hard to get it not to crash.</p>
<p>If a 'Crash' is anything that interrupts the jvm/program from normal termination, then an Un-handled exception could do this.</p> <pre><code>public static void main(String args[]){ int i = 1/0; System.out.print(i); // This part will not be executed due to above unhandled exception } </code></pre> <p>So, i...
9,097
<p>I installed VS SP1 and played around with Entity Framework.</p> <p>I created a schema from an existing database and tried some basic operations.</p> <p>Most of it went well, except the database schema update.</p> <p>I changed the database in every basic way:</p> <ul> <li>added a new table</li> <li>deleted a tabl...
<p>I would guess that possibly those don't happen because they would break the build for existing code, but that's just a guess on my part.</p> <p>Here's my logic:</p> <p>First, EF is supposed to be more than 1:1 table mapping, so it's quite possible that just because you are deleting a column from table A doesn't me...
<p>You need to delete the column by yourself from the designer or the XML file.</p>
3,324
<p>How do I create an rss feed in ASP.Net? Is there anything built in to support it? If not, what third-party tools are available?</p> <p>I'm thinking webforms, not MVC, though I suppose since this isn't a traditional page the difference may be minimal.</p>
<p>For built-in, there's nothing stopping you from using XmlDocument or XDocument (3.5) to build up the required XML for RSS. It's more work than it's worth though.</p> <p>I use the <a href="http://www.codeplex.com/Argotic" rel="nofollow noreferrer">Argotic Syndication Framework</a> and serve the feeds through Generic...
<p>Create an HTTP Handler to create a RSS feed</p>
8,149
<p>Ideally, I'm looking for a templated logical Set class. It would have all of the standard set operations such as Union, Intersection, Etc., and collapse duplicated items.</p> <p>I ended up creating my own set class based on the C# Dictionary&lt;>- just using the Keys.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb359438.aspx" rel="noreferrer"><code>HashSet&lt;T&gt;</code></a> is about the closest you'll get, I think.</p>
<p>Here's a simple implementation:</p> <pre><code>public sealed class MathSet&lt;T&gt; : HashSet&lt;T&gt;, IEquatable&lt;MathSet&lt;T&gt;&gt; { public override int GetHashCode() =&gt; this.Select(elt =&gt; elt.GetHashCode()).Sum().GetHashCode(); public bool Equals(MathSet&lt;T&gt; obj) =&gt; SetEquals(obj); ...
3,164
<p>I'm pretty green still when it comes to web programming, I've spent most of my time on client applications. So I'm curious about the common exploits I should fear/test for in my site.</p>
<p><a href="http://www.owasp.org/index.php/Main_Page" rel="noreferrer">OWASP</a> keeps a list of the <a href="http://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project" rel="noreferrer">Top 10</a> web attacks to watch our for, in addition to a ton of other useful security information for web development.</p>
<p>The most common are probably database injection attacks and cross-site scripting attacks; mainly because those are the easiest to accomplish (that's likely because those are the ones programmers are laziest about).</p>
4,310
<p>I'm aware of things like <code>onchange</code>, <code>onmousedown</code> and <code>onmouseup</code> but is there a good reference somewhere that lists all of them complete with possibly a list of the elements that they cover?</p>
<p>W3Schools seems to have a good Javascript events reference: <a href="http://www.w3schools.com/jsref/dom_obj_event.asp" rel="noreferrer">HTML DOM Events</a></p>
<p>Here is a pretty good JavaScript event reference with the elements they are for:<br> <a href="http://www.globalguideline.com/JavaScript_Guide/Java_Script_Events.php" rel="nofollow noreferrer">JavaScript Tutorial >> JavaScript Events</a></p>
2,840
<p>This might be on the "discussy" side, but I would really like to hear your view on this.</p> <p>Previously I have often written data access classes that handled both reading and writing, which often led to poor naming, like FooIoHandler etc. The rule of thumb that classes that are hard to name probably are poorly d...
<p>ORM might be your best solution.<br> Or use a repository type pattern, with a "thingContext" object that is responsible for state persistence.</p> <p>Personally, I use the activeRecord pattern, where save logic is baked into a base class, but I'm leaving it in favor of an nHibernate style repository pattern. The al...
<p>When given the choice I generally subclass the reader to create the writer. </p>
4,923
<p>How do I setup Public-Key Authentication for SSH?</p>
<p>If you have SSH installed, you should be able to run..</p> <pre><code>ssh-keygen </code></pre> <p>Then go through the steps, you'll have two files, <code>id_rsa</code> and <code>id_rsa.pub</code> (the first is your private key, the second is your public key - the one you copy to remote machines)</p> <p>Then, conn...
<p>For windows <a href="http://the.earth.li/~sgtatham/putty/0.53b/htmldoc/Chapter8.html" rel="noreferrer">this</a> is a good introduction and guide</p> <p>Here are some good ssh-agents for systems other than linux.</p> <ul> <li>Windows - <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" rel="n...
2,889
<p>Does anyone know if it is possible to display a prompt to a user/administrator when activating or installing a sharepoint feature? </p> <p>I am writing a custom webpart and it is connecting to a separate database, I would like to allow the administrator to select or type in a connection string when installing the ...
<p>Unfortunately there is no way to swap to a screen where you can get user via the feature activation process. Couple of comments for you:</p> <ol> <li>I'm assuming the connection string is going to be different for every installation, so there is no way you can include it directly in the Solution. </li> <li>I'm assu...
<p>Sounds good. I will look at these possible solutions.</p> <p>I do not think #1 will work since I am deploying multiple webparts inside a single solution which all use the same connectionString.</p> <p>#3 sounds like a very clean solution. I see the config items are cached so it looks like if I need to store a co...
3,033
<p>I’m looking at rewriting a portion of our application in C# (currently legacy VB6 code). The module I am starting with is responsible for importing data from a variety of systems into our database. About 5-6 times a year, a new client asks us to write a new import for the system that they use. Presently, this requi...
<p>I would recommend you take a look at the Managed Add-In Framework that shipped with .NET 3.5. The <a href="http://blogs.msdn.com/clraddins/" rel="nofollow noreferrer">Add-In team</a> has posted some samples and tools at <a href="http://www.codeplex.com/clraddins" rel="nofollow noreferrer">CodePlex site</a> as well.....
<p>.Net 3.5 has the system.Addin namespace.</p> <p>This thread also has some good information for older versions of the framework:<br> h<a href="http://forums.devshed.com/net-development-87/system-plugin-532149.html" rel="nofollow noreferrer">ttp://forums.devshed.com/net-development-87/system-plugin-532149.html</a></p...
6,838
<p>I have a rather classic UI situation - two ListBoxes named <code>SelectedItems</code> and <code>AvailableItems</code> - the idea being that the items you have already selected live in <code>SelectedItems</code>, while the items that are available for adding to <code>SelectedItems</code> (i.e. every item that isn't a...
<p>Here's your solution.</p> <pre><code>&lt;Button Name="btn1" &gt;click me &lt;Button.Style&gt; &lt;Style&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding ="{Binding ElementName=list1, Path=SelectedIndex}" ...
<p>Less code solution:</p> <pre><code>&lt;Button Name="button1" IsEnabled="{Binding ElementName=listBox1, Path=SelectedItems.Count}" /&gt; </code></pre> <p>If count is 0 that seems to map to false, > 0 to true.</p>
3,849
<p>Can anyone recommend any good <strong>add-ons</strong> or <strong>plugins</strong> for <code>Microsoft Visual Studio</code>?<br> Freebies are preferred, but if it is worth the cost then that's fine.</p>
<p><a href="http://weblogs.asp.net/alex_papadimoulis/archive/2004/05/25/Smart-Paster-1.1-Add-In---StringBuilder-and-Better-C_2300_-Handling.aspx" rel="noreferrer">SmartPaster</a> - (FREE) Copy/Paste code generator for strings</p> <p><a href="http://ankhsvn.open.collab.net/" rel="noreferrer">AnkhSvn</a> - (FREE) SVN So...
<ul> <li>Resharper (Agree it sucks you have to pay extra to get this, but well work the money)</li> <li><p>GhostDoc (Takes away any excuse for not having comments in your code)</p></li> <li><p>PowerCommands for VS 2008 (Forgot I even had this installed because it just adds a the little things that should have been ther...
2,487
<p>Often time I need to add a control to a dialog after the dialog has been generated via dialog template and CreateDialogIndirect. In these cases the tab order is set by the dialog template and there is no obvious way to change the tab order by including a newly created control.</p>
<p>I recently discovered that you can use SetWindowPos to accomplish this. Determine which control after which you want to insert the new control in the tab order then use SetWindowPos like this:</p> <pre><code>SetWindowPos(hNewControl, hOldControl, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); </code></pre> <p>This changes ...
<p>I know this is an old question but here is how to do it at compile time (which is preferable in the vast majority of cases): <a href="http://msdn.microsoft.com/en-us/library/7039hzb0(v=vs.80).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/7039hzb0(v=vs.80).aspx</a></p> <p>My favourite method:</p> <ol...
7,295
<p>Given a URL, what would be the most efficient code to download the contents of that web page? I am only considering the HTML, not associated images, JS and CSS.</p>
<pre><code>public static void DownloadFile(string remoteFilename, string localFilename) { WebClient client = new WebClient(); client.DownloadFile(remoteFilename, localFilename); } </code></pre>
<p>I think this is the fastest (download speed time with low latency) solution for download.</p> <pre><code>// WebClient vs HttpClient vs HttpWebRequest vs RestSharp // در نهایت به نظرم روش زیر سریعترین روشه HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(url); Request.AutomaticDecompression = Decompression...
4,584
<p><a href="http://twitter.com/codinghorror/statuses/901272685" rel="nofollow noreferrer">Source</a></p> <blockquote> <p>RegexOptions.IgnoreCase is more expensive than I would have thought (eg, should be barely measurable)</p> </blockquote> <p>Assuming that this applies to PHP, Python, Perl, Ruby etc as well as C# ...
<p>Yes, [A-Za-z] will be much faster than setting the <code>RegexOptions.IgnoreCase</code>, largely because of Unicode strings. But it's also much more limiting -- [A-Za-z] does <em>not</em> match accented international characters, it's literally the A-Za-z ASCII set and nothing more.</p> <p>I don't know if you saw Tim...
<p>If you're concerned about this, it may be worthwhile to set the case to all upper or all lower before you check.<br> For instance, in Perl:</p> <pre><code>$x = "abbCCDGBAdgfabv"; (lc $x) =~ /bad/; </code></pre> <p>May in some cases be better than</p> <pre><code>$x = "abbCCDGBAdgfabv"; $x =~ /bad/i; </code></pre>
5,195
<p>I'm looking for a multiline regex that will match occurrences after a blank line. For example, given a sample email below, I'd like to match "From: Alex". <code>^From:\s*(.*)$</code> works to match any From line, but I want it to be restricted to lines in the body (anything after the first blank line).</p> <pre> ...
<p>I'm not sure of the syntax of C# regular expressions but you should have a way to anchor to the beginning of the string (not the beginning of the line such as ^). I'll call that "\A" in my example:</p> <pre><code>\A.*?\r?\n\r?\n.*?^From:\s*([^\r\n]+)$ </code></pre> <p>Make sure you turn the multiline matching opti...
<p>Writing complicated regular expressions for such jobs is a bad idea IMO. It's better to combine several simple queries. For example, first search for "\r\n\r\n" to find the start of the body, then run the simple regex over the body.</p>
9,336
<p>About 6 months ago I rolled out a site where every request needed to be over https. The only way at the time I could find to ensure that every request to a page was over https was to check it in the page load event. If the request was not over http I would response.redirect("<a href="https://example.com" rel="nore...
<p>Please use <a href="https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security" rel="noreferrer">HSTS</a> (HTTP Strict Transport Security)</p> <p>from <a href="http://www.hanselman.com/blog/HowToEnableHTTPStrictTransportSecurityHSTSInIIS7.aspx" rel="noreferrer">http://www.hanselman.com/blog/HowToEnableHTTPStrictT...
<p>-> Simply ADD [RequireHttps] on top of the public class HomeController : Controller.</p> <p>-> And add GlobalFilters.Filters.Add(new RequireHttpsAttribute()); in 'protected void Application_Start()' method in Global.asax.cs file.</p> <p>Which forces your entire application to HTTPS.</p>
6,928
<p>I am using LightBurn to laser engrave on wood. I am just trying to print some letters. </p> <p>In the softwares preview the output looks correct. The black part is where the laser should burn and the red part are traversal/scan lines <a href="https://i.stack.imgur.com/nLs8P.png" rel="nofollow noreferrer"><img src="...
<p><code>M42</code> command is an immediate command. This means that it will run before the move GCode commands finish. This is exactly what I was facing. </p> <p>This video has the walk-through of solving the issue: <div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://ww...
<p>This is too long for a good comment but may fall short of being a true answer. If the mods prefer, I can recast it as a set of comments.</p> <p>There are several differences between using a GPIO pin as a binary data pin and using one as a PWM pin, and the behavior depends on several factors:</p> <ol> <li>Is the P...
1,321
<p>How do you test the usability of the user interfaces of your applications - be they web or desktop? Do you just throw it all together and then tweak it based on user experience once the application is live? Or do you pass it to a specific usability team for testing prior to release?</p> <p>We are a small software...
<p>I like <a href="http://friendfeed.com/paul" rel="noreferrer">Paul Buchheit's</a> answer on this from startup school. The short version of what he said listen to your users. Listen does not mean obey your users. Take in the data filter out all the bad advice and iteratively clean up the site. Lather, rinse, repeat. <...
<p>I'm a strong believer in what I call 3-martini usability testing. When designing a system, imagine that the person who will be using it has just had 3 martinis. </p> <p>Before handing over the system to colleagues (other programmers, quality assurance, tech support) or usability testers, an informal test with a cou...
3,880
<p>Given that my client code knows everything it needs to about the remoting object, what's the simplest way to connect to it?</p> <p>This is what I'm doing at the moment:</p> <pre><code>ChannelServices.RegisterChannel(new HttpChannel(), false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(IRemoteS...
<p>The first two lines are in the server-side code, for marshaling out the server object, yes?</p> <p>In that case, yes, the third line is the simplest you can get at client-side.</p> <p>In addition, you can serve out additional server-side objects from the <strong>MyServerObject</strong> instance, if you include pub...
<p>WCF. </p> <p>I have used IPC before there was a WCF, and believe me, IPC is a bear. And it isn't documented fully/correctly.</p> <p>What’s the simplest way to connect to a .NET remote server object? WCF.</p>
4,556
<p>Is it necessary to set large objects to <code>null</code> when implementing a <code>Dispose()</code> method?</p>
<p>Not usually.</p> <p>The garbage collector looks for rooted objects, and circular dependencies don't prevent collection if neither object is rooted.</p> <p>There is a caveat: if object A has a reference to object B, and object B is being disposed, you may want to clean up that relationship or else you could end up ...
<p>Think about the purpose of Disposable methods for a bit: it's usually because you're holding some resource that won't be released during garbage collection. This is usually something like a database connection or a file handle. Thus, once the Dispose method has been called, all those resources have been released....
7,257
<p>Hey so what I want to do is snag the content for the first paragraph. The string <code>$blog_post</code> contains a lot of paragraphs in the following format:</p> <pre><code>&lt;p&gt;Paragraph 1&lt;/p&gt;&lt;p&gt;Paragraph 2&lt;/p&gt;&lt;p&gt;Paragraph 3&lt;/p&gt; </code></pre> <p>The problem I'm running into is t...
<p>Well, sysrqb will let you match anything in the first paragraph assuming there's no other html in the paragraph. You might want something more like this</p> <pre><code>&lt;p&gt;.*?&lt;/p&gt; </code></pre> <p>Placing the <code>?</code> after your <code>*</code> makes it non-greedy, meaning it will only match as lit...
<p>Using Regular Expressions for html parsing is never the right solution. You should be using XPATH for this particular case:</p> <pre><code>$string = &lt;&lt;&lt;XML &lt;a&gt; &lt;b&gt; &lt;c&gt;texto&lt;/c&gt; &lt;c&gt;cosas&lt;/c&gt; &lt;/b&gt; &lt;d&gt; &lt;c&gt;código&lt;/c&gt; &lt;/d&gt; &lt;/a&gt; XM...
5,964
<p>What are all the possible ways in which we can get memory leaks in .NET?</p> <p>I know of two:</p> <ol> <li>Not properly un-registering <a href="http://diditwith.net/PermaLink,guid,fcf59145-3973-468a-ae66-aaa8df9161c7.aspx" rel="nofollow noreferrer">Event Handlers/Delegates</a>.</li> <li>Not disposing dynamic chil...
<p>There's no way to provide a comprehensive list... this is very much like asking "How can you get wet?"</p> <p>That said, make sure you're calling Dispose() on everything that implements IDisposable, and make sure you implement IDisposable on any types that consume unmanaged resources of any kind.</p> <p>Every now ...
<p>A lot of the things that can cause memory leaks in unmanaged languages can still cause memory leaks in managed languages. For example, <a href="http://blogs.msdn.com/oldnewthing/archive/2006/05/02/588350.aspx" rel="nofollow noreferrer">bad caching policies</a> can result in memory leaks.</p> <p>But as Greg and Dan...
4,075
<p>I am making a "fun button", with a dome-shaped top. The vertical sides, top center, and raised lettering seem fine, but the more sloped outer parts of the dome are very thin, with some gaps and the infill pattern is quite visible. It's almost like the slicer isn't recognizing the sloped part as an exterior shell. </...
<p>Slice with more solid top layers. I always use five with low-density infill.</p>
<p>You can either increase the shells, or you can increase the infill density. In addition different fill patterns will help. I would do 4 minimum for such a print.</p>
497
<p>I have a ASP.NET application that we've written our own logging module for.</p> <p>My question is, where is the standard place to write a log file to? I.e. the website will be running as the anonymous user identity (e.g. IUSR on IIS7) and I need a place where I know it'll have permission to write to.</p> <p>Cheers...
<p>App_Data folder on the root of the project. It isn't served to web requests; so other people can't snoop for it.</p>
<p>I'm not in a position to modify the permissions on folders (especially outside of the virtual directory home folder), and don't already have an App_Data folder, so am a bit hesitant to go with that. </p> <p>So for the moment I'm going with the CommonApplicationData Folder. </p> <ul> <li>On Vista/Server 2008 this i...
2,825
<p>I have tried to print <a href="https://www.thingiverse.com/thing:2014307" rel="nofollow noreferrer">Baby Groot</a> , but every time I print the head, there are always layer shifts like the photos below. I have printed three heads and the layer shifts happened all in the same place.</p> <p><a href="https://i.stack.im...
<p>Layer shifting has two basic causes: the partially printed part moves or flexes, or the bed or Y carriage (almost always -- they seem rather uncommon on the X axis) skips one or more steps in one direction or the other.</p> <p>Permanent layer shifts -- that is, where the entire print above the shift is and remains s...
<p>Zeiss Ikon's answer is good - but just in case that doesn't solve it, have you printed larger / longer prints before? There's a well known problem with the Ender 3's 4.2.2 motherboard that causes layer shifts as it overheats on longer prints. You can try elevating the printer and putting a fan underneath to see if t...
1,987
<p>In the web-application I'm developing I currently use a naive solution when connecting to the database:</p> <pre><code>Connection c = DriverManager.getConnection("url", "username", "password"); </code></pre> <p>This is pretty unsafe. If an attacker gains access to the sourcecode he also gains access to the databas...
<p>You can store the connection string in Web.config or App.config file and encrypt the section that holds it. Here's a very good article I used in a previous project to encrypt the connection string:</p> <p><a href="http://www.ondotnet.com/pub/a/dotnet/2005/02/15/encryptingconnstring.html" rel="noreferrer">http://www...
<p>I can recommend these techniques for .NET programmers: </p> <ul> <li>Encrypt password\connection string in config file</li> <li>Setup trusted connection between client and server (i.e. use windows auth, etc)</li> </ul> <p>Here is useful articles from CodeProject: </p> <ul> <li><a href="http://www.codeproject.co...
6,445
<p>I am writing my first serious wxWidgets program. I'd like to use the wxConfig facility to make the program's user options persistent. However I <em>don't</em> want wxConfigBase to automatically use the Windows registry. Even though I'm initially targeting Windows, I'd prefer to use a configuration (eg .ini) file. Do...
<p>Don't do it!</p> <p>Trying to create identifiers that are not valid in your language is not a good idea. If you really want to set variables like that, use attribute macros:</p> <pre><code>attr_writer :bar attr_reader :baz attr_accessor :foo </code></pre> <p>Okay, now that you have been warned, here's how to do i...
<p>If there's no hope of changing the canonical names, you could alias the getters and setters manually:</p> <pre><code>def variable_name send 'variable.name' end def variable_name=(value) send 'variable.name=', value end </code></pre>
7,174
<p>I am using Struts + Velocity in a Java application, but after I submit a form, the confirmation page (Velocity template) shows the variable names instead an empty label, like the Age in following example:</p> <blockquote> <p><strong>Name</strong>: Fernando</p> <p><strong>Age</strong>: {person.age}</p> <p><strong>Sex...
<p>You can mark variables as "<a href="https://velocity.apache.org/engine/1.5/user-guide.html#quietreferencenotation" rel="noreferrer">silent</a>" like this:</p> <pre><code>$!variable </code></pre> <p>If $variable is null, nothing will be rendered. If it is not null, its value will render as it normally would.</p>
<p>You will also need to be sure and use the proper syntax. Your example is missing the dollar before the variable. It should be $!{person.age}, not just {person.age}.</p>
4,367
<p>I have a function that gives me the following warning:</p> <blockquote> <p>[DCC Warning] filename.pas(6939): W1035 Return value of function 'function' might be undefined</p> </blockquote> <p>The function, however, is clean, small, and does have a known, expected, return value. The first statement in the function...
<p>Are you sure you have done everything to solve the warning? Maybe you could post the code for us to look at?</p> <p>You can turn off the warning locally this way:</p> <pre><code>{$WARN NO_RETVAL OFF} function func(...): string; begin ... end; {$WARN NO_RETVAL ON} </code></pre>
<p>There seems to be some sort of bug in Delphi. Read this post, the last comment links to other bug-reports that may be the one that you have got:</p> <p><a href="http://qc.codegear.com/wc/qcmain.aspx?d=8144" rel="nofollow noreferrer">http://qc.codegear.com/wc/qcmain.aspx?d=8144</a></p>
8,664
<p>Are there any handy general items you put in your .procmailrc file?</p>
<p>Many mailers prefix a mail's subject with "Re: " when replying, if that prefix isn't already there. German Outlook instead prefixes with "AW: " (for "AntWort") if that prefix isn't already there. Unfortunately, these two behaviours clash, resulting in mail subjects like "Re: AW: Re: AW: Re: AW: Re: AW: Lunch". So...
<p>To stop weird russian and chinese spams, I use this procmail configuration. </p> <pre><code>UNREADABLE='[^?"]*big5|iso-2022-jp|ISO-2022-KR|euc-kr|gb2312|ks_c_5601-1987' :0: * ^Content-Type:.*multipart * B ?? $ ^Content-Type:.*^?.*charset="?($UNREADABLE) spam-unreadable </code></pre>
2,993
<p>I am new to 3D printing and just purchased an Ender 3 V2 about two weeks ago. Since I've got it, I've been having trouble leveling the bed. I've tried watching videos, but they don't say how much friction on the paper is good or bad. I have even tried foil, playing cards, and a business card but still can't tell if ...
<p>Step 1: stop using paper and get some feeler gauges. The gauge should be able to just barely pass under the HEATED nozzle.</p> <p>Step 2: What are you using for bed adhesion? I use Elmer's white glue. After you think you've trammed (aka levelled) the bed, apply a generous layer of the glue in a coat on the bed. Let ...
<p>Don't worry too much about it. If you print with a first layer height of 0.3mm, bed levelling only needs to be approximate. If that doesn't work, and you cannot get good bed adhesion, try printing onto blue painter's tape (ScotchBlue). This makes a very forgiving build surface. You will need to clean it well with is...
1,801
<p>My boss found a bug in a query I created, and I don't understand the reasoning behind the bug, although the query results prove he's correct. Here's the query (simplified version) before the fix:</p> <pre><code>select PTNO,PTNM,CATCD from PARTS left join CATEGORIES on (CATEGORIES.CATCD=PARTS.CATCD); </code></pre>...
<blockquote> <p>Here's the query (simplified version) </p> </blockquote> <p>I think by simplifying the query you removed the real cause of the bug :-)</p> <p>What oracle version are you using? Oracle 10g ( 10.2.0.1.0 ) gives: </p> <pre><code>create table parts (ptno number , ptnm number , catcd number); create...
<p>It is generally advised to be specific and fully qualify all column names anyway, as it saves the optimizer a little work. Certainly in SQL Server.</p> <p>From what I can gleen from the <a href="http://www.oracle.com/technology/index.html" rel="nofollow noreferrer">Oracle docs</a>, it seems it will only throw if yo...
8,328
<p>I'll have an ASP.net page that creates some Excel Sheets and sends them to the user. The problem is, sometimes I get Http timeouts, presumably because the Request runs longer than executionTimeout (110 seconds per default).</p> <p>I just wonder what my options are to prevent this, without wanting to generally incre...
<p>If you want to increase the execution timeout for this one request you can set</p> <pre><code>HttpContext.Current.Server.ScriptTimeout</code></pre> <p>But you still may have the problem of the client timing out which you can't reliably solve directly from the server. To get around that you could implement a "proc...
<p>I've not really had to face this issue too much yet myself, so please keep that in mind.</p> <p>Is there not anyway you can run the process async and specify a callback method to occur once complete, and then keep the page in a "we are processing your request.." loop cycle. You could then open this up to add some n...
4,940
<p>After some months of good quality prints, since yesterday my heatbed does not heat anymore.</p> <p>I've a BQ Prusa i3 Hephestos with <a href="https://www.reprap.org/wiki/File:RRD-Mk2b-dual-power_blk.jpg" rel="nofollow noreferrer">this</a> heatbed, controlled by <a href="https://images-na.ssl-images-amazon.com/images...
<p>I see four points of error:</p> <ul> <li>The heatbed could be faulty.</li> <li>The lines could be faulty.</li> <li>The trigger signal could be faulty.</li> <li>The power supply could be faulty.</li> </ul> <p>So, how to check what it might be? We need to measure, but we need to measure in a setup of 12/24 V circuits ...
<p>Assuming you are using the correct voltage hot bed, what you have set up should be just fine.</p> <p>On the other hand, if it’s a 12 volt bed with a 24 volt power supply, you could have easily burned it out.</p> <p>If the voltages were matched properly, you may have just gotten unlucky.</p>
1,758
<p>I'm designing a database table and asking myself this question: <em>How long should the firstname field be?</em></p> <p>Does anyone have a list of reasonable lengths for the most common fields, such as first name, last name, and email address?</p>
<p>I just queried my database with millions of customers in the USA.</p> <ul> <li><p>The maximum <strong>first name</strong> length was 46. I go with 50. (Of course, only 500 of those were over 25, and they were all cases where data imports resulted in extra junk winding up in that field.)</p></li> <li><p><strong>Las...
<p>it is varchar right? So it then doesn't matter if you use 50 or 25, better be safe and use 50, that said I believe the longest I have seen is about 19 or so. Last names are longer</p>
4,133
<p>Those of you who have used <a href="http://research.microsoft.com/Pex/" rel="noreferrer">Pex</a>, what do you think its advantages and disadvantages are of Pex as a tool?</p> <p>Also, what do you think are the advantages and disadvantages of "Automated Exploratory Testing" in general, <strong>as a supplement to</st...
<p>I think Pex as an exploratory testing tool is really intriguing. In that regard, I see it as something I'd want to hand off to QA to use.</p> <p>As a TDD tool, it needs some work, as TDD is a design activity. However, I do like the direction that Peli is heading. There's something to be said for automated assisted ...
<p>Test-first development makes you structure your code for testability. In this respect, Pex finds clever and awkward paths thru your code, helping out beyond simple coverage metrics.</p> <p>Major forte of Pex with Moles is enabling of tracking side effects when doing Brownfield development: run Pex once and save ou...
8,397
<p>I am using <a href="http://www.simpletest.org/" rel="nofollow noreferrer">Simpletest</a> as my unit test framework for the PHP site I am currently working on. I like the fact that it is shipped with a simple HTML reporter, but I would like a bit more advanced reporter.</p> <p>I have read the reporter API documentat...
<p>If you are talking about the python interpreter or CMD.exe that is the 'parent' of your script then no, it isn't possible. In every POSIX-like system (now you're running Windows, it seems, and that might have some quirk I don't know about, YMMV) each process has three streams, standard input, standard output and sta...
<p>In which context are you asking?</p> <p>Are you trying to capture the output from a program you start on the command line?</p> <p>if so, then this is how to execute it:</p> <pre><code>somescript.py | your-capture-program-here </code></pre> <p>and to read the output, just read from standard input.</p> <p>If, on ...
4,458
<p>Can we have the database and transaction logs on the same drive? What will be its consequences if it is not recommended?</p>
<p>The only downside is that it causes more thrashing on the disk, so worse performance.</p> <p>A single write will require 2 seeks (between: write transaction log, write data, commit log). Having the transaction log on a separate disk means as few as zero seeks, because the drive heads can remain on the transaction l...
<p>In some scenarios you don't need transaction log at all. In that case you can switch database to <a href="http://msdn.microsoft.com/en-us/library/aa173563(SQL.80).aspx" rel="nofollow noreferrer">Simple Recovery Mode</a> and you gain performance and simpler administration benefits.</p>
6,486
<p>I'm having a lot of issues leveling my printer and one failed print came out like this. Is there something wrong with the surface that I need a new bed? This happens to me quite often and I literally can't get it off.</p> <p><a href="https://i.stack.imgur.com/vOVeZ.jpg" rel="nofollow noreferrer" title="Magnetic bed ...
<p>Presuming that you're talking about an 8 hour period, your printer should be designed to run for 8 hours continuous anyway, so nothing will happen regarding the bed or screen that wouldn't happen with a normal print.</p> <p>If the first few layers stick to the bed, it's likely that you're print will at least be part...
<p>There are software solutions like &quot;Spaghetti Detective&quot; (recently renamed to &quot;Obico&quot;) which can watch your print via a camera, and potentially stop the job if it looks bad.</p> <p>Most of the time my print failures come early, in the form of poor bed adhesion - watch the job start for a while be...
2,157
<p>I'd like to set up a cheap Linux box as a web server to host a variety of web technologies (PHP &amp; Java EE come to mind, but I'd like to experiment with Ruby or Python in the future as well). </p> <p>I'm fairly versed in setting up Tomcat to run on Linux for serving up Java EE applications, but I'd like to be ab...
<p>This article has some of the best ways to lock things down:</p> <p><a href="http://www.petefreitag.com/item/505.cfm" rel="noreferrer">http://www.petefreitag.com/item/505.cfm</a></p> <p>Some highlights:</p> <ul> <li>Make sure no one can browse the directories</li> <li>Make sure only root has write privileges to ev...
<p>There are plenty of ways to do this that will work just fine. I would usually jsut use a .htaccess file. Quick to set up and secure <em>enough</em> . Probably not the best option but it works for me. I wouldn't put my credit card numbers behind it but other than that I dont really care.</p>
2,706
<p>In cura one of the options under "build plate adhesion" is "skirt", which seems to simply print a loop around, but not touching, my print. How is this supposed to help my prints stick to the bed?</p>
<p>These skirts they don't contribute at all to help your product adhere better to the build plate other than priming your nozzle so that it is ready to lay down filament for your product. </p> <p>A skirt <strong>does</strong> give a good indication of the adhesion prior to printing your product, if the skirt does not...
<p>Skirts prime the nozzle- getting the filament to first adhere to the build platform is necessary for the entire print. Once the filament starts to stick it usually will continue to. </p> <p>Skirts can also help block any air drafts that might blow the filament away from adhering in the 1st layer of the print</p>
918
<p>Is there a redistributable .Net 3.5 installation package that is a silent installer? </p> <p>Or alternatively, is there a switch that can be passed to the main redistributable .Net 3.5 installer to make it silent?</p>
<p>dotnetfx35setup.exe /q /norestart</p> <p>see the .net deployment guide at:</p> <p><a href="http://msdn.microsoft.com/en-us/library/cc160716.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/cc160716.aspx</a></p>
<p>For Windows 10 you need to do following</p> <pre><code>DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:"Path\To\microsoft-windows-netfx3-ondemand-package" </code></pre> <p>You can find thoose packages under sources\sxs of a Windows DVD</p>
7,082
<p>C++ 0x has template aliases (sometimes referred to as template typedefs). See <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Alias_templates" rel="noreferrer">here</a>. Current spec of C++ does not. </p> <p>What do you like to use as work around ? Container objects or Macros ? Do you feel its worth it ?</p>
<blockquote> <p>What do you like to use as work around ? Container objects or Macros ? Do you feel its worth it ?</p> </blockquote> <p>The canonical way is to use a metafunction like thus:</p> <pre><code>template &lt;typename T&gt; struct my_string_map { typedef std::map&lt;std::string, T&gt; type; }; // Invok...
<p>Sometimes you can just explicitly write out the untemplated typedefs for all the necessary types. If the base class is templated on multiple template args with only one type desired to be typedefed you can inherit a specialized class with typedef effectively included in the inherited class name. This approach is les...
4,576
<p>In the past I've never been a fan of using triggers on database tables. To me they always represented some "magic" that was going to happen on the database side, far far away from the control of my application code. I also wanted to limit the amount of work the DB had to do, as it's generally a shared resource and I...
<p>Triggers are generally used incorrectly, introduce bugs and therefore should be avoided. Never design a trigger to do integrity constraint checking that crosses rows in a table (e.g "the average salary by dept cannot exceed X).</p> <p><a href="http://asktom.oracle.com" rel="noreferrer">Tom Kyte</a>, VP of Oracle h...
<p>I'm not a fan, personally. I'll use them, but only when I uncover a bottleneck in the code that can be cleared by moving actions into a trigger. Generally, I prefer simplicity and one way to keep things simple is to keep logic in one place - the application. I've also worked on jobs where access is very compartme...
3,490
<p>The company I work for is starting to have issues with their current branching model and I was wondering what different kinds of branching strategies the community has been exposed to?</p> <p>Are there any good ones for different situations? What does your company use? What are the advantages and disadvantages of...
<p>Here is the method I've used in the past with good success:</p> <p>/trunk - bleeding edge. Next major release of the code. May or may not work at any given time.</p> <p>/branches/1.0, 1.1, etc. Stable maintenance branches of the code. Used to fix bugs, stabilize new releases. If a maintenance branch, it shoul...
<p>For Subversion, I agree with Ryan Duffield's comment. The chapter he refers to provides a good analyses on which system to use.</p> <p>The reason I asked is that Perforce provides a completely different way to create branches from SVN or CVS. Plus, there are all the DVCSs that give it's own philosophy on branchin...
5,537
<p>I would like to be able to use the <kbd>Tab</kbd> key within a text box to tab over four spaces. The way it is now, the Tab key jumps my cursor to the next input.</p> <p>Is there some JavaScript that will capture the Tab key in the text box before it bubbles up to the UI?</p> <p>I understand some browsers (i.e. Fi...
<p>Even if you capture the <code>keydown</code>/<code>keyup</code> event, those are the only events that the tab key fires, you still need some way to prevent the default action, moving to the next item in the tab order, from occurring.</p> <p>In Firefox you can call the <code>preventDefault()</code> method on the eve...
<p>In Chrome on the Mac, alt-tab inserts a tab character into a <code>&lt;textarea&gt;</code> field.</p> <p>Here’s one: . Wee!</p>
2,550
<p>What would be the easiest way to be able to send and receive raw network packets. Do I have to write my own JNI wrapping of some c API, and in that case what API am I looking for?</p> <p>EDIT: I want to be able to do what wireshark does, i.e. record all incomming packets on an interface, and in addition be able to ...
<p>If you start with the idea that you need something <em>like</em> a packet sniffer, you'll want to look at <a href="http://netresearch.ics.uci.edu/kfujii/jpcap/doc/" rel="nofollow noreferrer">http://netresearch.ics.uci.edu/kfujii/jpcap/doc/</a>.</p>
<p><a href="http://www.maxim-ic.com/products/microcontrollers/tini/" rel="nofollow noreferrer">TINI</a> is a java ethernet controller, which may have libraries and classes for directly accessing data from ethernet frames to TCP streams. You may be able to find something in there that implements your needed classes. If ...
6,124
<p>I have Ramps 1.4 and would like to get answer on extrusion in Marlin firmware. I have NEMA 17 stepper motor 1.8 deg, set to 1/16 step. Mk7 direct drive. 38 teeth in extruder drive gear. I bought it from <a href="https://www.robotics.org.za/RDKIT-00?search=extru" rel="nofollow noreferrer">this website</a>.</p> <p>He...
<p>According to the description, the drive gear you have has a <code>10.8mm</code> diameter. This means that (in the ideal case) one full rotation of the drive gear will advance a length of filament equal to its circumference, which is <code>pi x 10.8mm</code> or approximately <code>33.93mm</code>.</p> <p>Your motor r...
<p>Simplest way to calculate your extrusion is:</p> <p>Set your number of perimeters walls 1 top and bottom layer 0 infill 0% and print simple 20x20x20 cube look at the wall thickness with caliper and compare your extrusion width value on your slicer software</p>
656
<p>I'm writing a small web server in Python, using BaseHTTPServer and a custom subclass of BaseHTTPServer.BaseHTTPRequestHandler. Is it possible to make this listen on more than one port?</p> <p>What I'm doing now:</p> <pre><code>class MyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): def doGET [...] clas...
<p>Sure; just start two different servers on two different ports in two different threads that each use the same handler. Here's a complete, working example that I just wrote and tested. If you run this code then you'll be able to get a Hello World webpage at both <a href="http://localhost:1111/" rel="noreferrer">htt...
<p>Not easily. You could have two ThreadingHTTPServer instances, write your own serve_forever() function (don't worry it's not a complicated function).</p> <p>The existing function:</p> <pre><code>def serve_forever(self, poll_interval=0.5): """Handle one request at a time until shutdown. Polls for shutdown e...
8,566
<p>Is the real benefit in <code>TDD</code> the actual testing of the application, or the benefits that writing a testable application brings to the table? I ask because I feel too often the conversation revolves so much around testing, and not the total benefits package.</p>
<p>TDD helps you design your software. The tests becomes the design. By writing the test first you think about your code from a consumer perspective, making a more user friendly and more compact software design.</p> <p>Also, by applying TDD you typically end up writing your code in a way where you can supply test mock...
<p>Automated testing keeps humans from doing a machine's job.</p> <p>Test-driven development maximizes the amount of automated testing.</p> <p>Beyond a certain point, of course, a human is still required. You reach diminishing returns when you try to apply TDD beyond that point.</p>
7,376
<p>How do you scan a directory for folders and files in C? It needs to be cross-platform.</p>
<p>The following POSIX program will print the names of the files in the current directory:</p> <pre><code>#define _XOPEN_SOURCE 700 #include &lt;stdio.h&gt; #include &lt;sys/types.h&gt; #include &lt;dirent.h&gt; int main (void) { DIR *dp; struct dirent *ep; dp = opendir (&quot;./&quot;); if (dp != NULL) ...
<p>You can find the sample code on the <a href="https://en.wikibooks.org/wiki/C_Programming/dirent.h" rel="nofollow noreferrer">wikibooks link</a></p> <pre><code>/************************************************************** * A simpler and shorter implementation of ls(1) * ls(1) is very similar to the DIR command ...
3,350
<p>I've never been completely happy with the way exception handling works, there's a lot exceptions and try/catch brings to the table (stack unwinding, etc.), but it seems to break a lot of the OO model in the process.</p> <p>Anyway, here's the problem:</p> <p>Let's say you have some class which wraps or includes net...
<p>This looks like an excellent opportunity to have a look at Aspect Oriented Programming. Here is a good article on <a href="https://learn.microsoft.com/en-us/archive/blogs/simonince/aspect-oriented-interception" rel="nofollow noreferrer">AOP in .NET</a>. The general idea is that you'd extract the cross-functional con...
<p>Just wondering, what do you feel your method leaves to be desired? You could replace the anonymous delegate with a.. named? delegate, something like</p> <pre><code> public delegate void IoOperation(params string[] parameters); public void FileDeleteOperation(params string[] fileName) { File.Del...
2,389
<p>When creating a setup/MSI with Visual Studio is it possible to make a setup for a simple application that doesn't require administrator permissions to install? If its not possible under Windows XP is it possible under Vista?</p> <p>For example a simple image manipulation application that allows you to paste photos ...
<p>ClickOnce is a good solution to this problem. If you go to Project Properties > Publish, you can setup settings for this. In particular, "Install Mode and Settings" is good to look at: </p> <ul> <li>The application is available online only -- this is effectively a "run once" application</li> <li>The application is ...
<p>Vista is <em>more</em> restrictive about this kind of thing, so if you can't do it for XP you can bet Vista won't let you either.</p> <p>You are right that installing to the program files folder using windows installer requires administrative permissions. In fact, <em>all write access</em> to that folder requires ...
9,897
<p>Will limiting a query to one result record, improve performance in a large(ish) MySQL table if the table only has one matching result?</p> <p>for example</p> <pre><code> select * from people where name = "Re0sless" limit 1 </code></pre> <p>if there is only one record with that name? and what about if <code>name</...
<p>If the column has </p> <p><strong>a unique index: no,</strong> it's no faster</p> <p><strong>a non-unique index: maybe,</strong> because it will prevent sending any additional rows beyond the first matched, if any exist</p> <p><strong>no index: sometimes</strong></p> <ul> <li>if 1 or more rows match the query, <...
<p>I believe the LIMIT is something done after the data set is found and the result set is being built up so I wouldn't expect it to make any difference at all. Making name the primary key will have a significant positive effect though as it will result in an index being made for the column.</p>
5,472
<p>We all know (or should!) that the repeatability of common spring-arm limit switches is crappy at best. I'm looking to build &amp; install one of the precision height adjusters for the Z-axis limit switch, and noticed a post on some forum suggesting removing the arm and triggering the switch button directly (e.g. wi...
<p>While I haven't seen this on a Z axis for a printer personally, there is no reason it wouldn't work, and would improve your repeatability in theory. Removing the arm on the switch is taking away the lever. Going back to simple machine mechanics, the lever gives you a larger range of motion in which the button could ...
<p>No. Buy a better switch if it's an issue (see below).</p> <p>You would need to have some very tight tolerances to hit that micro button with whatever your arm is. If you had a machine with good tolerances you would not be considering this modification. That alone is why I would say this is not the greatest idea.</p...
422
<p>I have an excel spreadsheet in a format similar to the following...</p> <pre><code>| NAME | CLUB | STATUS | SCORE | | Fred | a | Gent | 145 | | Bert | a | Gent | 150 | | Harry | a | Gent | 195 | | Jim | a | Gent | 150 | | Clare | a | Lady | 99 | | Simon | a | Junior | 130...
<pre><code>Public Function TopTen(Club As String, Scores As Range) Dim i As Long Dim vaScores As Variant Dim bLady As Boolean Dim lCnt As Long Dim lTotal As Long vaScores = FilterOnClub(Scores.Value, Club) vaScores = SortOnScore(vaScores) For i = LBound(vaScores, 2) To UBound(vaScores...
<p>Use a pivot table which will act as a database query on the data you have. Pivot so that the teams go down the columns and team members along with their status type go across the pivot table. I'm not sure for 2003, but Excel 2007 lets you then sort so the highest scores appear to the left. Then your first sum can...
8,239
<p>I got a Tronxy X5S-400, I assembled it and when I power it on, I see on the screen one of the below images and gets stuck there.</p> <p>Is the firmware broken? If yes, where can I get a <code>configuration.h</code> file?</p> <p>I verified that the two buses between the screen and the mainboard are not loose or inc...
<p>It looked like the firmware wasn't flashed correctly in the factory. What I did was to flash a bootloader using an Arduino compatible board and to flash the Marlin software e.g. according to <a href="https://www.youtube.com/watch?v=3gwWVFtdg-4" rel="nofollow noreferrer">videos from this guy</a>.</p> <p>Next, the me...
<p>If the controller is one of Tronxy's new Chitu boards, you will not have the option of recompiling the firmware, since they are locked down. Apart from checking that the PSU is delivering the correct voltage, your only option may be to request a new main board from the vendor.</p>
1,286
<p>When I try to run a .NET assembly (<code>boo.exe</code>) from a network share (mapped to a drive), it fails since it's only partially trusted:</p> <pre><code>Unhandled Exception: System.Security.SecurityException: That assembly does not allow partially trusted callers. at System.Security.CodeAccessSecurityEngine...
<p>With .NET 3.5 SP1, .NET assemblies running from UNC shares have full permissions. </p> <p>See Brad Abrams's <a href="http://blogs.msdn.com/brada/archive/2007/10/26/adhoc-poll-allowing-net-exes-to-run-off-a-network-share.aspx" rel="noreferrer">Allow .exes to be run off a network shares</a> for workaround and discuss...
<p>I think you want to add the <a href="http://msdn.microsoft.com/en-us/library/system.security.allowpartiallytrustedcallersattribute.aspx" rel="nofollow noreferrer">AllowPartiallyTrustedCallers</a> attribute to your assembly. The error message implies that something that's calling into your boo.exe assembly is not fu...
4,407
<p>Basically, I've written an API to www.thetvdb.com in Python. The current code can be found <a href="http://github.com/dbr/tvdb_api/tree/master/tvdb_api.py" rel="noreferrer">here</a>.</p> <p>It grabs data from the API as requested, and has to store the data somehow, and make it available by doing:</p> <pre><code>pr...
<p>OK, what you need is <code>classobj</code> from new module. That would allow you to construct exception classes dynamically (<code>classobj</code> takes a string as an argument for the class name). </p> <pre><code>import new myexc=new.classobj("ExcName",(Exception,),{}) i=myexc("This is the exc msg!") raise i </cod...
<p>I have done something similar in the past and used an in-memory XML document as a quick and dirty hierarchical database for storage. You can store each show/season/episode as an element (nested appropriately) and attributes of these things as xml attributes on the elements. Then you can use XQuery to get info back o...
2,783
<p>I have an inherited project that uses a build script (not make) to build and link the project with various libraries.</p> <p>When it performs a build I would like to parse the build output to determine what and where the actual static libraries being linked into the final executable are and where are they coming fr...
<p>You might try using the <code>nm</code> tool. Given the right options, it will look at a binary (archive or linked image) and tell you what objects were linked into it.</p> <p>Actually, here's a one-liner I use at work:</p> <pre><code>#!/bin/sh nm -Ag $* | sed 's/^.*\/\(.*\.a\):/\1/' | sort -k 3 | grep -v ' U ' ...
<p>Static libraries, that makes life more difficult in this regard. In case of dynamic libraries you could just have used ldd on the resulting executable and be done with it. The best bet would be some kind of configuration file. Alternatively you could try to look for -l arguments to gcc/ld. Those are used to specify ...
7,003
<p>What is the best way to verify/test that a text string is serialized to a byte array with a certain encoding?</p> <p>In my case, I want to verify that an XML structure is serialized to a byte array with the UTF-8 encoding which is of variable character length. As an example, my current ugly procedure is to inject a...
<p>Perhaps you could deserialise the byte array using a known encoding and ensure that (a) it doesn't throw any exceptions, and (b) deserialises to the original string. It seems that from your description of the scenario, you may not have the original string readily available. Might there be a way to create it?</p>
<p>That's good. You're right, I don't have the original string, since I'm testing a module that creates an XML document as a byte array. I didn't think about deserializing to a String with an expected encoding. That will do the trick.</p>
2,928
<p>So I've got a <code>JPanel</code> implementing <code>MouseListener</code> and <code>MouseMotionListener</code>:</p> <pre><code>import javax.swing.*; import java.awt.*; import java.awt.event.*; public class DisplayArea extends JPanel implements MouseListener, MouseMotionListener { public DisplayArea(Rectangle ...
<p>The <em>implements mouselistener, mousemotionlistener</em> just allows the displayArea class to listen to some, to be defined, Swing component's mouse events. You have to explicitly define what it should be listening at. So I suppose you could add something like this to the constructor:</p> <pre><code>this.addMouse...
<p>I don't see anywhere in the code where you call addMouseListener(this) or addMouseMotionListener(this) for the DisplayArea in order for it to subscribe to those events. </p>
5,377
<p>The RFC for a Java class is set of all methods that can be invoked in response to a message to an object of the class or by some method in the class. RFC = M + R where M = Number of methods in the class. R = Total number of other methods directly invoked from the M.</p> <p>Thinking C is the .class and J is the .j...
<p>You could use the <a href="http://jakarta.apache.org/bcel/index.html" rel="nofollow noreferrer">Byte Code Engineering Library</a> with binaries. You can use a <a href="http://jakarta.apache.org/bcel/apidocs/org/apache/bcel/classfile/DescendingVisitor.html" rel="nofollow noreferrer">DescendingVisitor</a> to visit a c...
<p>You should find your answer in the <a href="http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html" rel="nofollow noreferrer">Java language specification</a>.</p> <p>You have forgot static method call, method call inside parameters...</p>
4,029
<p>I will elaborate somewhat. Jsf is kind-of extremely painful for working with from designer's perspective, somewhat in the range of trying to draw a picture while having hands tied at your back, but it is good for chewing up forms and listing lots of data. So sites we are making in my company are jsf admin pages and ...
<p>have you looked into using facelets? It lets you get rid of the whole JSF / JSP differences (it's an alternate and superior view controller).</p> <p>It also supports great design-time semantics with the jsfc tag...</p> <pre><code>&lt;input type="text" jsfc="#{SomeBean.property}" class="foo" /&gt; </code></pre> <p...
<p>Create a custom JSP tag handler. You can then retrieve the bean from session scope and then initialize it on the fly. See this <a href="http://java.sun.com/products/jsp/tutorial/TagLibrariesTOC.html" rel="nofollow noreferrer">tutorial</a> for more details.</p>
6,443
<p>I would like to have a VM to look at how applications appear and to develop OS-specific applications, however, I want to keep all my code on my Windows machine so if I decide to nuke a VM or anything like that, it's all still there.</p> <p>If it matters, I'm using VirtualBox.</p>
<p>This is usually handled with network shares. Share your code folder from your host machine and access it from the VMs.</p>
<p>I do this all the time. I have a directory in a Windows drive that I mount in my host ubuntu 12.04. I run virtualbox ubuntu 13.04 as a guest. I want the guest to mount the Windows directory with full non-root permissions. I do almost all my work from a bash shell, so this method is natural for me.</p> <p>When searc...
6,830
<p>How do we create a search plugin for Safari? Like <a href="https://stackoverflow.com/questions/20830/firefox-users-here-is-your-stackoverflow-search-plugin">this post</a> </p>
<p><a href="http://pimpmysafari.com/plugins/keywurl" rel="nofollow noreferrer">Here</a> is a Safari plugin whereby you can customize it to search other sites. May work with Stack Overflow (I haven't tried it). Check out that site too for other Safari plugins.</p>
<p>AFAIK, Safari doesn't have a Search plugin capability. You could try <a href="http://www.inquisitorx.com/safari/index_en.php" rel="nofollow noreferrer">Inquisitor</a>; just add the URL <a href="https://stackoverflow.com/search?s=%@">https://stackoverflow.com/search?s=%@</a></p>
4,262
<p>I'm running some <a href="http://jakarta.apache.org/jmeter/" rel="noreferrer">JMeter</a> tests against a Java process to determine how responsive a web application is under load (500+ users). JMeter will give the response time for each web request, and I've written a script to ping the Tomcat Manager every X seconds...
<p>Use <code>top -b</code> (and other switches if you want different outputs). It will just dump to stdout instead of jumping into a curses window.</p>
<p>also use 1 as iteration count, so you will get current snapshot without waiting to get another one in $delay time.</p> <pre><code>top -b -n 1 </code></pre>
7,305
<p>I need to validate a date/time field on a webpage but want it to do it without reloading the page and would like 'instant' feedback for the users.</p> <p>What's the best/easiest solution. BTW: easiest scores 65% of total points</p> <p>Edit: What if best was 65% of total points?</p>
<p>Check out this <a href="http://www.expertsrt.com/scripts/Rod/validate_date.php" rel="nofollow noreferrer">javascript date validation</a> function.</p> <p>It uses javascript, regular expressions and the 'onblur' event of a text input.</p>
<p>A simple javascript method that reads what's in the input field on submit and validates it. If it's not valid, return false so that the form is not submitted to the server.</p> <pre><code>... onSubmit="return validateForm();" ... </code></pre> <p>Make sure you validate on the server side too, it's easy to bypass j...
3,179
<p>This is a bit hypothetical and grossly simplified but...</p> <p>Assume a program that will be calling functions written by third parties. These parties can be assumed to be non-hostile but can't be assumed to be "competent". Each function will take some arguments, have side effects and return a value. They have no ...
<p>You don't specify the operating system or environment, this answer assumes Linux, glibc, and C.</p> <p>You can set __malloc_hook, __free_hook, and __realloc_hook to point to functions which will be called from malloc(), realloc(), and free() respectively. There is a __malloc_hook manpage showing the prototypes. You...
<p>Since you're worried about memory leaks and talking about malloc/free, I assume you're in C. I'm also assuming based on your question that you do not have access to the source code of the third party library.</p> <p>The only thing I can think of is to examine memory consumption of your app before &amp; after the c...
7,366
<p>Given an integer typedef:</p> <pre><code>typedef unsigned int TYPE; </code></pre> <p>or</p> <pre><code>typedef unsigned long TYPE; </code></pre> <p>I have the following code to reverse the bits of an integer:</p> <pre><code>TYPE max_bit= (TYPE)-1; void reverse_int_setup() { TYPE bits= (TYPE)max_bit; w...
<pre><code>#include&lt;stdio.h&gt; #include&lt;limits.h&gt; #define TYPE_BITS sizeof(TYPE)*CHAR_BIT typedef unsigned long TYPE; TYPE reverser(TYPE n) { TYPE nrev = 0, i, bit1, bit2; int count; for(i = 0; i &lt; TYPE_BITS; i += 2) { /*In each iteration, we swap one bit on the 'right half' ...
<p>How about:</p> <pre><code>long temp = 0; int counter = 0; int number_of_bits = sizeof(value) * 8; // get the number of bits that represent value (assuming that it is aligned to a byte boundary) while(value &gt; 0) // loop until value is empty { temp &lt;&lt;= 1; // shift whatever was in ...
8,922
<p>I've recently bought myself a preassembled Prusa i3 MK3S printed and made my first projects. One of them was making a cup with my name on it. I want to use it to drink tea, water etc. I know, however, that I need to chose my filament wisely, as using the wrong one might be unsafe. I know that PLA for example is Poly...
<p>Answer was moved to this question: <a href="https://3dprinting.stackexchange.com/questions/147/which-are-the-food-safe-materials-and-how-do-i-recognize-them">Which are the food-safe materials and how do I recognize them?</a></p>
<p>I think this site will answer some questions about food safe 3D printing: <a href="https://all3dp.com/1/food-safe-3d-printing-abs-pla-food-safe-filament/" rel="nofollow noreferrer">12 Vital Facts About Food Safe 3D Printing</a></p> <p>PLA is not a good choice for hot substances because it will deform at hot water t...
1,361
<p>When creating a criteria in NHibernate I can use</p> <p>Restriction.In() or<br> Restriction.InG()</p> <p>What is the difference between them?</p>
<p>InG is the generic equivalent of In (for collections)</p> <p>The signatures of the methods are as follows (only the ICollection In overload is shown):</p> <pre><code>In(string propertyName, ICollection values) </code></pre> <p>vs.</p> <pre><code>InG&lt;T&gt;(string propertyName, ICollection&lt;T&gt; values) </co...
<p>Restriction.In definately creates a subquery with whatever criteria you pass to the .In() method, but not sure what InG() does. never seen it.</p>
5,137
<p>PHP's explode function returns an array of strings split on some provided substring. It will return empty strings when there are leading, trailing, or consecutive delimiters, like this:</p> <pre><code>var_dump(explode('/', '1/2//3/')); array(5) { [0]=&gt; string(1) &quot;1&quot; [1]=&gt; string(1) &quot;2&qu...
<p>Try <a href="http://php.net/preg_split" rel="nofollow noreferrer">preg_split</a>.</p> <p><code>$exploded = preg_split('@/@', '1/2//3/', -1, PREG_SPLIT_NO_EMPTY);</code></p>
<p>I usually wrap it in a call to <a href="http://uk.php.net/manual/en/function.array-filter.php" rel="nofollow noreferrer">array_filter</a>, e.g.</p> <pre><code>var_dump(array_filter(explode('/', '1/2//3/')) =&gt; array(3) { [0]=&gt; string(1) "1" [1]=&gt; string(1) "2" [3]=&gt; string(1) "3" } </code></p...
9,013
<p>Assuming String a and b:</p> <pre><code>a += b a = a.concat(b) </code></pre> <p>Under the hood, are they the same thing?</p> <p>Here is concat decompiled as reference. I'd like to be able to decompile the <code>+</code> operator as well to see what that does.</p> <pre><code>public String concat(String s) { ...
<p>No, not quite.</p> <p>Firstly, there's a slight difference in semantics. If <code>a</code> is <code>null</code>, then <code>a.concat(b)</code> throws a <code>NullPointerException</code> but <code>a+=b</code> will treat the original value of <code>a</code> as if it were <code>null</code>. Furthermore, the <code>conc...
<p>Note that <code>s.concat(&quot;hello&quot;);</code> would result in a <code>NullPointereException</code> when s is null. In Java, the behavior of the + operator is usually determined by the left operand:</p> <p><code>System.out.println(3 + 'a'); //100</code></p> <p>However, Strings are an exception. If either operan...
6,987