instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>GDI+ DrawLines function has a clipping bug that can be reproduced by running the following c# code. When running the code, two line paths appear, that should be identical, because both of them are inside the clipping region. But when the clipping region is set, one of the line segment is not drawn. </p> <pre><code...
<p>It appears that this is a known bug...</p> <p>The following code appears to function as you requested:</p> <pre><code>protected override void OnPaint(PaintEventArgs e) { PointF[] points = new PointF[] { new PointF(73.36f, 196), new PointF(75.44f, 32), new PointF(77.52f, 32), ...
<p>What appears to be the matter with the code?</p> <p>OK, the question should be... what should the code do that it doesn't already.</p> <p>When I run the code, I see 2 red 'spikes' am I not ment to?</p> <p>You appear to draw the first spike within the clipped rectangle region verified by adding the the following a...
3,628
<p>I've been testing an application using my machine as a server, and everything's going fine with it, but when I try to set it up to run on the test server, I get this error:</p> <blockquote> <p>Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154.</p> </b...
<p>First: Please check on your test server the registration of your com objects.</p> <pre><code>HKEY_CLASSES_ROOT\CLSID\{xxxx} </code></pre> <p>Check, if your dll or exe file is on the correct location on the hard drive.</p> <p>Second: This link may help: <a href="http://support.software602.com/kb/view.aspx?article...
<p>The error code translates to "class not registered".</p> <p>Registering is usually done with "regsvr32 " when it is a DLL or via " /RegServer".</p> <p>To avoid the described error message, please register on client and server.</p>
26,869
<p>I am having trouble integrating two products, one of which is mine and they appear not to be talking. So I want to make sure they are communicating correctly. I had a look around for network monitor and found TCP Spy. This works but only shows 1 side of the conversation at a time (it has to run locally) I would idea...
<p><a href="http://www.wireshark.org/" rel="noreferrer">Wireshark</a> is a really good and mature network sniffer. It's been around for years.</p> <ul> <li>Deep inspection of hundreds of protocols, with more being added all the time</li> <li>Live capture and offline analysis </li> <li>Decryption support for many proto...
<p>Strange that I did not see WireShark when I visited SourceForge. The top result of the 60 returned was a bizarre german thing.</p>
4,798
<p>Here's the situation: at my small office, because we like to keep mobile and occasionally work from home, instead of having a central file server, we have all the office documents in an SVN repository, and each person keeps a checkout on their own laptops. A checkout weighs in at about 3GB, and the repo with revisio...
<p>I don't know exactly what's in your repo, but unless you're changing all the files regularly, a DVCS should provide you a very desirable workflow.</p> <p>You could do an svn -> git conversion, stick the repo on a DVD and mail it out to all the satellite offices, and then let them fetch from the office as things cha...
<p>(It seems no one is answering this.) DVCS of course seems like it would work, but I have no experience with it. A centralized system like svn might also work if you are not expecting large changes daily. (to go up and back from the server) The initial get in that case would be the only real expensive issue. </p...
43,290
<p>I have a script that takes a command and executes it on a remote host. It works fine, for example:</p> <pre><code>$ rexec "ant build_all" </code></pre> <p>will execute the "ant build_all" command on the remote system (passing it through SSH, etc).</p> <p>Because I'm lazy, I want to set up an alias for this comma...
<p>For all arguments, this will work.</p> <pre><code>function rant () { rexec "ant $*" } </code></pre> <p>You may need to adjust the quoting, depending on what arguments you're passing.</p>
<p>You can do it as a function, not an alias:</p> <pre><code>function rant { rexec "ant $1"; } </code></pre> <p>You can call it at the command line like an alias</p>
36,980
<p>How can brackets be escaped in using <code>string.Format</code>?</p> <p>For example:</p> <pre><code>String val = &quot;1,2,3&quot; String.Format(&quot; foo {{0}}&quot;, val); </code></pre> <p>This example doesn't throw an exception, but it outputs the string <code>foo {0}</code>.</p> <p>Is there a way to escape the ...
<p>For you to output <code> foo {1, 2, 3}</code> you have to do something like:</p> <pre><code>string t = &quot;1, 2, 3&quot;; string v = String.Format(&quot; foo {{{0}}}&quot;, t); </code></pre> <p>To output a <code>{</code> you use <code>{{</code> and to output a <code>}</code> you use <code>}}</code>.</p> <p><strong...
<p><strong>Escaping Brackets: String Interpolation $(&quot;&quot;):</strong></p> <p>Now, you can also use C# string interpolation like this (feature available in C# 6.0):</p> <pre><code>var inVal = &quot;1, 2, 3&quot;; var outVal = $&quot; foo {{{inVal}}}&quot;; // The output will be: foo {1, 2, 3} </code></pre>
11,679
<p>I have this form in my view: </p> <pre><code>&lt;!-- Bug (extra 'i') right here-----------v --&gt; &lt;!-- was: &lt;form method="post" enctype="mulitipart/form-data" action="/Task/SaveFile"&gt; --&gt; &lt;form method="post" enctype="multipart/form-data" action="/Task/SaveFile"&gt; &lt;input type="file" id="FileBlo...
<p>I don't know what the policy is on posting profanity, but here's the problem: </p> <pre><code>enctype="mulitipart/form-data" </code></pre> <p>The extra <code>i</code> in there stopped the file from uploading. Had to run Fiddler to see that it was never sending the file in the first place. </p> <p>It should read:<...
<p>Good that you found your error.</p> <p>As a side note you'll want a try/catch around the file handling code so you'll know when file permissions etc. are not setup correctly.</p>
38,129
<p>I'm new to 3D printing and have bought an Ender 3. I have printed a few good prints but I'm noticing a worsening issue: </p> <p>When I select "autohome" the axes head towards their limit switches, but the y axis in particular seems to slam into the limit switch, bending it away, meaning that the platform bounces of...
<p>Personally, I have found that if you bend the arm of the limit switch out, it gets triggered earlier and solves this issue for good, (broke a switch clean off at the bend on the pins, soldered old switch back onto the pins in the board) bent the arm to a greater angle, so the striker triggers 3-5&nbsp;mm earlier, pr...
<p>The solution seems to be simply triggering the switch earlier, and making sure that it is triggered. The thin arm can end up bent over the actual button of the switch, meaning that the arm can be touching the switch without actually &quot;pressing&quot; the switch. For some, bending the arm seems to have worked, but...
1,620
<p>A few weeks ago I opened up a hole on my shared server and my friend uploaded the following PHP script:</p> <pre><code>&lt;?php if(isset($_REQUEST['cmd'])) { echo "&lt;pre&gt;"; $cmd = ($_REQUEST['cmd']); system($cmd); echo "&lt;/pre&gt;"; die; } ?&gt; &lt;?php if(isset($_REQUEST['upload'])) { ...
<p>One, kick off a "friend" that chooses to run scripts like this.</p> <p>Then worry about securing your server. Your system has a master php.ini somewhere (often /etc/php.ini, but if can be in several places, check php_info()). That file controls the default settings for your server. Also, you can block local sett...
<p>Are you sure? I wish I had your ISP. By default <em>some</em> ISPs will provide a local copy of the ini file in public_html to allow overrides. But cPanel usually only provides a reference of the server-wide defaults.</p>
26,360
<p>Does anyone have some guidelines or links to articles when designing a website that needs to be localized in 20+ languages?</p> <p>The initial translation isn't so much the problem, rather ongoing maintenance (i.e. when an update is made on the English site, how are people notified that new translations are required...
<p>Here are some web sites dedicated to internationalization and globalization:</p> <p><a href="http://www.i18nguy.com/" rel="nofollow noreferrer">http://www.i18nguy.com/</a> <a href="http://multilingual.com/guides.php" rel="nofollow noreferrer">http://multilingual.com/guides.php</a> (they heavily push vendors, but th...
<p>Many SCMs support triggers that can fire when committing changes and can take action if, e.g. a .pot file was changed, to send email to the appropriate parties.</p>
27,700
<p>Assume the following code:</p> <pre><code>using (SqlConnection conn = new SqlConnection(connectionString)) { ... using (SqlCommand comm = new SqlCommand(...)) { .. do stuff .. if(condition) Response.Redirect("somepage.aspx"); } } </code></pre> <p>Will the Response.Redirect() exit from the ...
<p>From <a href="http://msdn.microsoft.com/en-us/library/aa973248.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa973248.aspx</a></p> <blockquote> <p>Calling Response.Redirect WILL NOT execute the finally block. Therefore, before any redirection or transfer of processing can occur, yo...
<p>All using statements are scope based. So no matter how you exit the function everyone that was stack based at that point is cleaned up from the using. Exceptions, returns, etc. </p> <p>I don't know of any way to prevent one from firing even if you wanted to for some reason.</p>
22,665
<p>I know that just using <code>rand()</code> is predictable, if you know what you're doing, and have access to the server.</p> <p>I have a project that is <strong>highly</strong> dependent upon choosing a random number that is as unpredictable as possible. So I'm looking for suggestions, either other built-in functio...
<p>Adding, multiplying, or truncating a poor random source will give you a poor random result. See <a href="http://random.org/randomness/" rel="noreferrer">Introduction to Randomness and Random Numbers</a> for an explanation.</p> <p>You're right about PHP rand() function. See the second figure on <a href="http://rando...
<p>Variation on @KG, using the milliseconds since EPOCH as the seed for rand?</p>
2,748
<p>Is it possible to implement <a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" rel="noreferrer">RAII</a> in pure C? </p> <p>I assume it isn't possible in any sane way, but perhaps is it possible using some kind of dirty trick. Overloading the standard <code>free</code> function comes to m...
<p>This is inherent implementation dependent, since the Standard doesn't include such a possibility. For GCC, the <code>cleanup</code> attribute runs a function when a variable goes out of scope:</p> <pre><code>#include &lt;stdio.h&gt; void scoped(int * pvariable) { printf("variable (%d) goes out of scope\n", *pv...
<p>Check <a href="https://github.com/psevon/exceptions-and-raii-in-c" rel="nofollow">https://github.com/psevon/exceptions-and-raii-in-c</a> for a C implementation of unique and shared smartpointers and exceptions. This implementation relies on macro brackets BEGIN ... END replacing braces and detecting smartpointers go...
48,095
<p>I'm behind a firewall at work at the moment and I was testing something that I had deployed to my website, and the work proxy seems to be blocking it somewhat.</p> <p>Basically I am getting a message of:</p> <blockquote> <p>Operation is not valid due to the current state of the object</p> </blockquote> <p>I've ...
<p>Edit, I forgot to write this part in the answer: You may need to add the web reference url to the safe list for your proxy. I am not sure what proxy you are using or if you have control of it, but this should solve your problem. If you don't have access to change the proxy, then I put a quick work around right bel...
<p>Another option is to go to your application's web config or app config and add the following under the element:</p> <pre><code>&lt;system.net&gt; &lt;defaultProxy useDefaultCredentials="false"&gt; &lt;proxy usesystemdefault="true" proxyaddress="10.0.0.1" port="80" bypassonlocal="true" /&gt; &lt;/de...
6,460
<p>I've got some LINQ to SQL that sometimes throws a </p> <blockquote> <p>"Cannot insert duplicate key row in object 'dbo.Table' with unique index 'IX_Indexname'.The statement has been terminated."</p> </blockquote> <p>Is there some way I can turn on logging or at least debug into the datacontext to see what sql ...
<p>A simple way to do this is to use the <a href="http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.log.aspx" rel="noreferrer">DataContext.Log</a> property:</p> <pre><code>using (MyDataContext ctx = new MyDataContext()) { StringWriter sw = new StringWriter(); ctx.Log = sw; // execute so...
<p>I have to agree with Bradley Grainger using the <a href="http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.log.aspx" rel="nofollow noreferrer">DataContext.Log</a> property is the best way to see the executed sql.</p>
23,881
<p>I have a PHP client that requests an XML file over HTTP (i.e. loads an XML file via URL). As of now, the XML file is only several KB in size. A problem I can foresee is that the XML becomes several MBs or Gbs in size. I know that this is a huge question and that there are probably a myriad of solutions, but What ...
<p>based on your use case i'd definitely suggest zipping up the data first. in addition, you may want to md5 hash the file and compare it before initiating the download (no need to update if the file has no changes), this will help with point #2.</p> <p>also, would it be possible to just send a segment of XML that has...
<p>Gallery2, which allows you to upload photos over http, makes you set up a couple of php parameters, <code>post_max_size</code> and <code>upload_max_filesize</code>, to allow larger uploads. You might want to look into that.</p> <p>It seems to me that posting large files has problems with browser time-outs and the ...
30,801
<p>Hey, in the Programming Pearls book, there is a source code for setting, clearing and testing a bit of the given index in an array of ints that is actually a set representation.</p> <p>The code is the following:</p> <pre><code>#include&lt;stdio.h&gt; #define BITSPERWORD 32 #define SHIFT 5 #define MASK 0x1F #define...
<p>VonC posted a good answer about bitmasks in general. Here's some information that's more specific to the code you posted.</p> <p>Given an integer representing a bit, we work out which member of the array holds that bit. That is: Bits 0 to 31 live in <code>a[0]</code>, bits 32 to 63 live in <code>a[1]</code>, etc. A...
<p><a href="http://en.wikipedia.org/wiki/Bitwise_operation" rel="nofollow noreferrer">Bitwise operation</a> and the leading paragraphs of <a href="http://en.wikipedia.org/wiki/Mask_(computing)" rel="nofollow noreferrer">Mask</a> are a concise explanation, and contain some pointers for further study.</p> <p>Think of an...
33,596
<p>I am trying to use a third party DLL that wants an int** as one of the parameters to the method. It describes the parameter as the address of the pointer that will point to the memory allocation.</p> <p>Sorry for any confusion. The parameter is two-way I think. The DLL is for talking to an FPGA board and the met...
<p>Use a by-ref <a href="http://msdn.microsoft.com/en-us/library/system.intptr.aspx" rel="noreferrer"><code>System.IntPtr</code></a>.</p> <pre><code> [DllImport("thirdparty.dll")] static extern long ThirdPartyFunction(ref IntPtr arg); long f(int[] array) { long retval = 0; int size = Marshal.SizeOf(typeof(...
<p>An int** would be and array of IntPtr, from your description I think you might want to look into using C++/CLI to help you with the conversions e.g from an unmanaged int** to a managed array^>^</p>
25,682
<blockquote> <p>Possible duplicate <a href="https://stackoverflow.com/questions/90871/debug-vs-release-in-net">Debug Visual Studio Release in .NET</a></p> </blockquote> <p>What is the difference between Debug and Release in Visual Studio?</p>
<p>The most important thing is that in Debug mode there are no optimizations, while in Release mode there are optimizations. This is important because the compiler is very advanced and can do some pretty tricky low-level improving of your code. As a result some lines of your code might get left without any instructions...
<blockquote> <p>In debug configuration, your program compiles with full symbolic debug information and no optimization. Optimization complicates debugging, because the relationship between source code and generated instructions is more complex.</p> <p>The release configuration of your program has no symbolic debug info...
48,020
<p>On a question of just performance, how does Python 3 compare to Python 2.x?</p>
<p>3.0 is slower than 2.5 on official benchmarks. From <a href="http://docs.python.org/3.0/whatsnew/3.0.html#performance" rel="noreferrer">"What’s New in Python 3.0"</a>:</p> <blockquote> <p>The net result of the 3.0 generalizations is that Python 3.0 runs the pystone benchmark around 10% slower than Python 2....
<p>I don't if it faster now, but I have to expect that it eventually will be because that is where new performance work will happen and not all of that will be backported.</p>
20,561
<p>Using <a href="https://numpy.org/" rel="nofollow noreferrer">NumPy</a>, a matrix A has n rows and m columns, and I want add a guard ring to matrix A. That guard ring is all zero.</p> <p>What should I do? Use Reshape? But the element is not enough to make a n+1 m+1 matrix.</p> <p>Or etc.?</p> <p>Thanks in advance</p>...
<p>Following up on your <a href="https://stackoverflow.com/questions/362489/how-do-i-add-a-guard-ring-to-a-matrix-in-numpy#362576">comment</a>: </p> <pre><code>&gt;&gt;&gt; import numpy &gt;&gt;&gt; a = numpy.array(range(9)).reshape((3,3)) &gt;&gt;&gt; b = numpy.zeros(tuple(s+2 for s in a.shape), a.dtype) &gt;&gt;&gt...
<p>This question is ancient now, but I just want to alert people finding it that <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.pad.html" rel="nofollow noreferrer">numpy has a function <code>pad</code></a> that very easily accomplishes this now.</p> <pre><code>import numpy as np a = np.array(range...
47,313
<p>I wrote a C# application for a client a couple of years ago, but I no longer have the source code. All I have is the EXE that I deployed on the client's PC. Is there a way I can generate C# source code from the EXE?</p>
<p><a href="http://www.red-gate.com/products/reflector/index.htm" rel="noreferrer">Reflector</a> and its add-in <a href="http://www.denisbauer.com/Home/ReflectorFileDisassembler" rel="noreferrer">FileDisassembler</a>.</p> <p>Reflector will allow to see the source code. FileDisassembler will allow you to convert it int...
<p>I'm surprised no one has mentioned <a href="https://github.com/0xd4d/dnSpy" rel="noreferrer">dnSpy</a>. <strong>dnSpy</strong> is a debugger and .NET assembly editor. You can use it to edit and debug assemblies even if you don't have any source code available.</p> <p>Main features:</p> <ul> <li>Debug .NET and Unity ...
21,684
<p>In Silverlight how can I launch / navigate to another page?</p>
<pre><code>System.Windows.Browser.HtmlPage.Window.Navigate( new Uri( "http://www.google.com" ), "_blank" ); </code></pre> <p>You can leave out the target ("_blank") if you just want to navigate within your current browser window.</p>
<p>You all can also try this </p> <pre><code>this.content=new (place the page name which You want to navigate); but this code only works while navigate page having in same folder else You have to write like in given below manner </code></pre> <p>this.Content = new Views.(place the page name which You want...
29,116
<p>For example, if I were to write a calendar app on top of AIR, say with Flex, could this app pop up reminder windows for approaching appointments, just like Microsoft Outlook can?</p> <p>Clarification: Can those windows be actual dialogs where I can enter and save information?</p>
<p>See <a href="http://www.adobe.com/devnet/air/flex/quickstart/articles/creating_toast-style_windows.html" rel="nofollow noreferrer">Creating toast-style windows</a></p>
<p>Have a look at <a href="http://www.adobe.com/devnet/air/flash/quickstart/articles/creating_toast-style_windows.html" rel="nofollow noreferrer">this article</a> on the Adobe Website, for creating your own Toast Style Popups.</p> <p>(Credit for this goes to <a href="https://stackoverflow.com/users/1278/duncan-smart">...
19,860
<p>i'm a long-time newbie to c#, and this question may be too obvious, so please forgive if i'm "doing it wrong."</p> <p>Using Visual Studio 2005 Pro, C#, SQL Server 2000 EE SP3.</p> <p>I have a stored proc that takes one input param and returns several output params pertaining to that input. I am also calling it suc...
<pre><code>//set up the datatable DataTable dt = new DataTable("parms"); dt.Columns.Add("ParmName",typeof(string)); dt.Columns.Add("ParmValue",typeof(string)); //bind to a gui object myDataGridView.DataSource = dt; //do this after each sproc call foreach (SqlParameter parm in cmd.Parameters) { if (parm.Direction =...
<p>Steve's answer got me close. I'm not sure a DataGridView is the best solution, but it seems to be working.</p> <p>In Form(), after InitializeComponent(), i put the column setup code (since i want to keep adding rows periodically):</p> <pre><code>dgvOutput.Columns.Add("@col1", "Val 1"); dgvOutput.Columns.Add("@col2...
38,321
<p>I have a large number of TIFF images that I’d need to use in a WPF program (.NET 3.5 SP1 specifically and using C#). Half of the TIFF files contain color images encoded using JPEG compression and they don’t work with WPF. The “Microsoft Office Document Imaging” application handles the files fine. As Windows itself d...
<p>I believe you will need to change the overSkin, i think that would be the only way.</p>
<p>I believe you will need to change the overSkin, i think that would be the only way.</p>
38,126
<p>I am using Visual Assist X for C/C++ code in Visual Studio 2005 but I see that, sometime, when visual studio take focus, the processor is working too much and I cannot type code. If I am waiting somes seconds, it return the focus.</p>
<p>Try 'Rebuild' of the Symbol databases and a 'Clear' of the History, cache and temporary files from the 'Performance' tab of the Visual Assist X Options dialog. You can also turn other 'optimizations' off here that may be causing performance problems.</p>
<p>This usually occurs with large files and/or large number of open files and is due to parsing of those files.</p> <p>This is a known problem on the <a href="http://www.wholetomato.com/forum/default.asp" rel="nofollow noreferrer">Visual Assist forum</a>.</p>
27,925
<p>I'm looking for a regex that will allow me to validate whether or not a string is the reference to a website address, or a specific page in that website. </p> <p>So it would match:</p> <pre><code>http://google.com ftp://google.com http://google.com/ http://lots.of.subdomains.google.com </code></pre> <p>But not:</...
<p>Try this:</p> <pre><code>(http|ftp|https)://([a-zA-Z0-9\-\.]+)/? </code></pre>
<p>Great answer by Jeremy. Depending on which regex dialect you're using to match, you might want to wrap the whole expression with anchors (to avoid matching URLs like <code>http://example.com/bin/cgi?returnUrl=http://google.com</code>), and maybe generalize the valid protocol and domain name characters:</p> <pre><co...
23,037
<p>In SQL Server (in my case, 2005) how can I add the identity property to an existing table column using T-SQL?</p> <p>Something like:</p> <pre><code>alter table tblFoo alter column bar identity(1,1) </code></pre>
<p>I don't beleive you can do that. Your best bet is to create a new identity column and copy the data over using an identity insert command (if you indeed want to keep the old values).</p> <p>Here is a decent article describing the process in detail: <a href="http://www.mssqltips.com/tip.asp?tip=1397" rel="noreferrer...
<pre><code>alter table tablename alter column columnname add Identity(100,1) </code></pre>
36,684
<p>I have a type ahead text field, and when the user hits "Enter" I want to make an ajax call and not submit the form at the same time. My html looks like this:</p> <pre><code>&lt;input id="drug_name" class="drugs_field" type="text" size="30" onkeypress="handleKeyPress(event,this.form); return false;" name="drug[name]...
<p>You should add an event handler to the form itself which calls a function to decide what to do.</p> <pre><code>&lt;form onsubmit="return someFunction();"&gt; </code></pre> <p>And then make sure that your someFunction() returns false on success. If it returns true the form will submit normally (which is what you ar...
<p>You could use a regular button that submits the form on click instead of your submit button.</p> <p>If you want the enter key to work in other fields, just handle it there and submit the form.</p>
35,209
<p>When interviewing college coops/interns or recent graduates it helps to have a Java programming question that they can do on a white board in 15 minutes. Does anyone have examples of good questions like this? A C++ question I was once asked in an interview was to write a string to integer function which is along t...
<p>Some stuff that has showed up on SO:</p> <ul> <li>IsPalindrome(string s)</li> <li>ReverseWordsInString(string s): "I know java" --> "java know I"</li> </ul> <p>Other stuff that springs to mind:</p> <ul> <li>multiply a Vector with a Matrix (can this be done OO-Style?)</li> <li><code>echo</code> (yes, a simple clon...
<p>I agree with <a href="https://stackoverflow.com/questions/53808/good-15-minute-java-question-to-ask-recent-college-graduate#53847">Nicolas</a> in regards to separating the algorithmic questions from the actual language questions. </p> <p>One thing that you might want to consider is giving them a couple simple algor...
7,738
<p>Delphi sometimes adds {$R *.res} in front of the unit path in the .dpr file uses clauses, then I get a duplicated resources warning when trying to compile.</p> <p>Anyone knows why the hell Delphi does that? I'm using Delphi 2009 but this happens since Delphi 2007 (maybe 2006 too)</p>
<p>Perhaps posting your .dpr would help illustrate your problem. My project files look like this and give me no problem:</p> <pre><code>program Example; {$R *.res} uses Unit1 in 'Unit1.pas' {frmUnit1}; begin Application.Initialize; Application.CreateForm(TfrmUnit1, frmUnit1); Application.Run; end. </code><...
<p>the default {$R *.res} in .dpr should be between uses and var clauses.</p> <p>sometimes project files gets corrupted..<br> just delete any file in your source directory except *.dpr, *.pas, *.dfm<br> delphi will rebuild other files, included *.res</p> <p>thats'it</p>
41,085
<p>I'm looking for a spam filter that I can integrate into my ASP.NET application. I don't want any delegate services (e.g. Akismet) as I'm doing this for a high traffic website, any suggestions?</p> <p>Edit: I mean a post spam filter, it's a forum based website.</p> <p>Edit: Thanks for your answer but I'm not lookin...
<p>If you don't want to use CAPTCHA's, because they annoy people, and you already the site up and running, you could write your own parser to filter out spam. Most spam you see is extremely blatant. Posting hundreds of links in a post. Subject, Body, and Poster name are all exactly the same. Other stuff along those ...
<p>Although not widely used, since comments/forum posts are typically stored in a database, an insert trigger works remarkably well which looks for certain words in comments and auto triggers a delete. Again, this isn't an ideal solution, but it works for me. There is the possibility of deleting a legit post, but then ...
47,208
<p>I'm using VS2005 in a solution with a mix of VB and C# in different projects.</p> <p>I use this solution on several different computers and XML comments with both /// (c#) and ''' (VB) have been fine for months.</p> <p>all of a sudden, on my main development machine, they've stopped working in VB. They still work ...
<p>aha!</p> <p>in the 'compile' tab under properties, the 'generate documentation' checkbox was not ticked.</p> <p>looking at SVN it looks like someone checked in the VB projects with this unticked, for some reason.</p> <p>thanks for the help! it's my first time using this site. looks like the guys involved have don...
<p>The one reason this might be the case is that the XML file is no longer being created/updated. Make sure the XML Documentation file is set in the project property pages. Has your XML file been put under source control and if so is it checked out on a build. If not then it won't update.</p>
13,406
<p>I am wanting to use the Facebox plugin for JQuery but am having a few issues getting it running how I want. The div that houses the facebox content is created outside of the tag so even though I am loading up some web controls none of them are firing back to the server.</p> <p>Has anyone dealt with this that can ...
<p>poking around the facebox.js I came across this line in the function init(settings)...</p> <pre><code>$('body').append($.facebox.settings.faceboxHtml) </code></pre> <p>I changed that to ...</p> <pre><code>$('#aspnetForm').append($.facebox.settings.faceboxHtml) </code></pre> <p>and it loads up in the form tag, no...
<p>Even after the : $('#aspnetForm').append($.facebox.settings.faceboxHtml)</p> <p>change I found it problematic. When you look at the page source using firebug you see that all the html in the div assigned to be the facebox div is doubled up (repeated).</p> <p>So all of those controls with supposed unique id's are d...
19,626
<p>What is a good data structure for storing phone numbers in database fields? I'm looking for something that is flexible enough to handle international numbers, and also something that allows the various parts of the number to be queried efficiently.</p> <p><strong>Edit:</strong> Just to clarify the use case here: I...
<p>First, beyond the country code, there is no real standard. About the best you can do is recognize, by the country code, which nation a particular phone number belongs to and deal with the rest of the number according to that nation's format.</p> <p>Generally, however, phone equipment and such is standardized so you...
<p>I would go for a freetext field and a field that contains a purely numeric version of the phone number. I would leave the representation of the phone number to the user and use the normalized field specifically for phone number comparisons in TAPI-based applications or when trying to find double entries in a phone d...
6,332
<p>If so how? </p> <p>Did you roll your own with jQuery or use the Microsoft AJAX toolkit?</p> <p>Did you create a webservice or call an action?</p> <hr> <p><strong>EDIT</strong> : Please note that this question was asked before Microsoft announced that they were going to bundle jQuery in with VS/ASP.NET MVC. I t...
<p>jQuery, action, return JSON.</p> <p><a href="http://devlicio.us/blogs/mike_nichols/archive/2008/05/25/jquery-cascade-cascading-values-from-forms.aspx" rel="nofollow noreferrer">http://devlicio.us/blogs/mike_nichols/archive/2008/05/25/jquery-cascade-cascading-values-from-forms.aspx</a></p>
<p><a href="http://blog.noma.li/2010/03/autopostback-and-cascading-drop-downs-in-asp-net-mvc-and-jquery/" rel="nofollow noreferrer">http://blog.noma.li/2010/03/autopostback-and-cascading-drop-downs-in-asp-net-mvc-and-jquery/</a></p>
6,086
<p>Is there a way that I can do a select as such</p> <pre><code>select * from attributes where product_id = 500 </code></pre> <p>would return </p> <pre><code>id name description 1 wheel round and black 2 horn makes loud noise 3 window solid object you can see through </code></pre> <p>and the que...
<p>Even if it was possible, I doubt it would work. Both of those WHERE clauses expect one thing to be returned, therefore the code would probably just use the first row returned, not all of them.</p> <p>It would also give the database a behaviour that would make future developers pull their hair out trying to understa...
<p>As far out as this idea seems I'm always interested in crazy ways to do things. I think the best solution I could come up with is to use a view that uses the products table to get all the products then the attributes table to get the attributes, so every possible product is accounted for and all will get the same re...
43,996
<p>I am currently doing IE-hacks on a website I'm working on: <a href="http://www.timkjaerlange.com/wip/co2penhagen/" rel="nofollow noreferrer">http://www.timkjaerlange.com/wip/co2penhagen/</a></p> <p>I got a problem with this unordered list. IE seems to add extra top-margin for every li-element, making my navigation ...
<p>To get the behavior your looking for try &quot;display: inline&quot; instead of the &quot;float: left&quot;. Add both:</p> <blockquote> <p>ul#mainnav { display: inline }</p> <p>ul#mainnav li { display: inline }</p> </blockquote> <p>A great resource for info on customizing lists can be found on <a href="http://www.a...
<p>You're right. However margin-top doesn't solve the problem</p> <p>I use Eric Meyer's reset.css, it's bundled with 960gs that I use for prototyping the design.</p>
45,202
<p>I've been doing some simple rails Apps lately. I know ruby quite well, but when I started doing things "the rails way" I noticed that some things were done "just because" and It's hard for a (rails) newbie to know what does the code do.</p> <p>Has rails missed the point and turned into some kind of 4th generation l...
<p>I think it's a matter of perspective. From a broad perspective, the Rails community has held up the framework as something that <em>is</em> that easy. But the truth is, it is not. In fact, the more I work with Rails, the less of a fanboy I become. I don't think this is Rails' fault, but I think a lot of people have ...
<p>Pablo you might want to look into Django which is being developed by a group that has chosen to focus on providing top quality documentation as a priority.</p>
35,829
<p>I have a web page that uses a frameset.</p> <p>Due to scripting and object dependencies, I need to load the frames in a specific order.</p> <p>I have used this example as a template: <a href="http://javascript.internet.com/navigation/frames-load-order.html" rel="nofollow noreferrer">The JavaScript Source: Navigati...
<p>You mention this quite a lot in this post...</p> <blockquote> <p>This is a legacy system. The frameset is required.</p> </blockquote> <p>If you are working on a legacy system, then I think it is time you accepted how framesets behave in terms of the browser's back button. If it is truly a legacy system, you don'...
<p>Build the frames themselves using JavaScript:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function makeFrame(frameName) { var newFrame = document.createElement('frame'); newFrame.id=frameName; if(frameName=="B") { newFrame.onload=function() {makeFrame("C")}; newFrame.src = 'h...
36,933
<p>I have a C#/.NET program that can run both as a console application and as a service. Currently I give it a command-line option to start as a console application, but I would like to avoid that.</p> <p>Is it possible to programmatically detect whether my program is being started as a service? </p> <p>If it was pur...
<p><a href="http://msdn.microsoft.com/en-us/library/system.environment.userinteractive.aspx" rel="noreferrer">Environment.UserInteractive</a> will do the magic.</p>
<p>I ended up detecting whether or not I was in a console application by checking <a href="http://msdn.microsoft.com/en-us/library/system.console.iserrorredirected.aspx" rel="nofollow">Console.IsErrorRedirected</a>. It returned "false" for console apps, and "true" for the non-console apps I tested. I could have also ...
25,488
<p>When I do a ReadLinesFromFile on a file in MSBUILD and go to output that file again, I get all the text on one line. All the Carriage returns and LineFeeds are stripped out.</p> <pre><code>&lt;Project DefaultTargets = "Deploy" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" &gt; &lt;Import Project="$(M...
<p>The problem here is you are using the <code>ReadLinesFromFile</code> task in a manner it wasn't intended.</p> <blockquote> <p><strong>ReadLinesFromFile Task</strong><br> Reads a list of <em>items</em> from a text file.</p> </blockquote> <p>So it's not just reading all the text from a file, it's reading individ...
<p>You can use WriteLinesToFile combined with </p> <pre><code>$([System.IO.File]::ReadAllText($(SourceFilePath))): &lt; WriteLinesToFile File="$(DestinationFilePath)" Lines="$([System.IO.File]::ReadAllText($(SourceFilePath)))" Overwrite="true" /&gt; </code></pre> <p>This...
34,301
<p>Does anyone know of some good resources related to setting up heirarchical user account systems? I'm currently setting one up and am struggling with some of the more complex logic (especially with determining permissions). I was hoping I might be able to find some resources to help me along.</p> <p><strong>Some Bac...
<p>The manual for CakePHP has an excellent description of how Access Control Lists work.</p> <p><a href="http://book.cakephp.org/2.0/en/core-libraries/components/access-control-lists.html" rel="nofollow noreferrer">http://book.cakephp.org/2.0/en/core-libraries/components/access-control-lists.html</a></p>
<p>Look at the permissions in the <a href="http://en.wikipedia.org/wiki/Andrew_File_System" rel="nofollow noreferrer">Andrew File System</a>. It allows users to create and administer groups of their own, while selectively assigning admin rights and ACLs. You might find that many of the pesky details are already worke...
10,108
<p>When you print from Google Docs (using the "print" link, not File/Print) you end up printing a nicely formated PDF file instead of relying on the print engine of the browser. Same is true for some of the reports in Google Analytics . . . the printed reports as PDF's are beautiful. How do they do that? I can't ima...
<p>If you are specifically looking at how Google does it. If you look at the <a href="http://docs.google.com/Doc?id=dd8xj6nh_2q9zprkd6" rel="noreferrer" title="I&#39;ve embedded the image in a document here">PDF Properties</a> page, they use Prince 6.0 (see <a href="http://www.princexml.com/" rel="noreferrer">princexml...
<p>Rendering a PDF is hard, complex problem. However generating them, is not. Simply make up some entities, and generate. It's about same problem domain as generating HTML for webpage vs. displaying (rendering) it.</p>
6,998
<p>I'm working on an anti-spam project (<a href="http://centmail.net" rel="nofollow noreferrer">centmail</a>) that involves having the sender use a client plugin that adds a custom header (as well as a signature, but that part's <a href="https://stackoverflow.com/questions/142319">easier</a>). The general problem is t...
<p>You can do it in <a href="http://email.about.com/od/eudoratips/qt/et_extra_header.htm" rel="nofollow noreferrer">Eudora</a>.</p> <p>You can do it programmatically <a href="http://www.systemwebmail.com/faq/2.8.aspx" rel="nofollow noreferrer">in Outlook</a> with <a href="http://www.add-in-express.com/forum/read.php?F...
<p>For all mail clients that support using an external editor, you could have a script that add a specific header to the template that gets send to the editor. In <a href="http://www.mutt.org/" rel="nofollow noreferrer">mutt</a>, there is a configuration parameter called <a href="http://www.mutt.org/doc/manual/manual-...
37,925
<p>I have heard that the Liskov Substitution Principle (LSP) is a fundamental principle of object oriented design. What is it and what are some examples of its use?</p>
<p>A great example illustrating LSP (given by Uncle Bob in a podcast I heard recently) was how sometimes something that sounds right in natural language doesn't quite work in code.</p> <p>In mathematics, a <code>Square</code> is a <code>Rectangle</code>. Indeed it is a specialization of a rectangle. The &quot;is a&quot...
<p>Let me try, consider an interface: </p> <pre><code>interface Planet{ } </code></pre> <p>This is implemented by class:</p> <pre><code>class Earth implements Planet { public $radius; public function construct($radius) { $this-&gt;radius = $radius; } } </code></pre> <p>You will use Earth as:</p>...
8,097
<p>I recently came across this in some code - basically someone trying to create a large object, coping when there's not enough heap to create it:</p> <pre><code>try { // try to perform an operation using a huge in-memory array byte[] massiveArray = new byte[BIG_NUMBER]; } catch (OutOfMemoryError oome) { /...
<p>freeMemory isn't quite right. You'd also have to add maxMemory()-totalMemory(). e.g. assuming you start up the VM with max-memory=100M, the JVM may at the time of your method call only be using (from the OS) 50M. Of that, let's say 30M is actually in use by the JVM. That means you'll show 20M free (roughly, because ...
<p>I don't believe that there's a reasonable, generic approach to this that could safely be assumed to be 100% reliable. Even the Runtime.freeMemory approach is vulnerable to the fact that you may actually have enough memory after a garbage collection, but you wouldn't know that unless you force a gc. But then there'...
43,004
<p>What is a satellite assembly, and when should they be used?</p>
<p>A definition from MSDN says something like this: "A .NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place the resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user elects to view the ap...
<ol> <li><p>A satellite assembly is a compiled library (DLL) that contains “localizable” resources specific to a given culture such as strings, bitmaps, etc.</p></li> <li><p>You are likely to use satellite assemblies when creating a multilingual UI application. They are used to deploy applications in multiple cultures,...
47,726
<p>In Python one can get a dictionary of all local and global variables in the current scope with the built-in functions <code>locals()</code> and <code>globals()</code>. Is there some equivalent way of doing this in Javascript? For instance, I would like to do something like the following:</p> <pre><code>var foo = ...
<ul> <li><p>locals() - No. </p></li> <li><p>globals() - Yes.</p></li> </ul> <p><code>window</code> is a reference to the global scope, like <code>globals()</code> in python.</p> <pre><code>globals()["foo"] </code></pre> <p>is the same as:</p> <pre><code>window["foo"] </code></pre>
<p>AFAIK, no. If you just want to check the existence of a given variable, you can do it by testing for it, something like this:</p> <pre><code>if (foo) foo(); </code></pre>
6,115
<p>I have an old Solidoodle 2 that I bought broken from a garage sale that I am converting to use RAMPS 1.4 with Marlin Firmware. All the motors work correctly, I am just having issues getting the endstops to work.<br><br> </p> <p>I am using a regular limit switch with NC going to the signal pin and the other to groun...
<p>try uncommenting the following lines to enable endstop detection on all pins for troubleshooting.</p> <pre><code>//#define USE_XMAX_PLUG false //#define USE_YMAX_PLUG false //#define USE_ZMAX_PLUG false </code></pre> <p>This way the M119 will show any changes.</p> <p>The only thing I can think of is that either t...
<p>Yesterday I has same error with board MKS Robin Nano with Marlin 2.0.6.</p> <p>Try to find and uncomment this definition:</p> <pre><code>#define ENDSTOP_INTERRUPTS_FEATURE </code></pre> <p>Failure was in disabled endstop interrupts and broken part of code, which going to home and unchecks endstop status between step...
418
<p>For the life of me I can't figure out how I'm supposed to set the <code>UITextField</code> to display the text vertically (landscape mode) instead of horizontally (portrait mode). The keyboard shows up properly, but when the keys are pressed the text is entered in the wrong orientation.</p> <p>Here is the screensho...
<p>iPhone OS handles the orientation changes by applying a transform to the view. Are you applying your own transforms that might interfere?</p>
<p>We manually set the status bar orientation via setStatusBarOrientation when the app starts up.</p> <p>-jeremy</p>
48,696
<p>i want to create a number of databases in ms-access using a code or any option of ms-access, but i want delete databases also. Please help me</p>
<p>You could have an empty database named "db1.mdb", and then add this code inside a module <strong>in another</strong> Access database:</p> <pre><code> Set fso = CreateObject("scripting.filesystemobject") fso.CopyFile "c:\db.mdb", "c:\db_copy1.mdb", True fso.CopyFile "c:\db.mdb", "c:\db_copy2.mdb", True fso.Co...
<p>To create an <strong>Access</strong> database from Access interface:</p> <pre><code>createDatabase "myNewMDB.mdb", dbLangGeneral </code></pre> <p>To delete a database:</p> <pre><code>kill "myNewMDB.mdb" </code></pre> <p>It works without initial mdb file or extra dlls</p> <p>for multiple databases</p> <pre><cod...
41,379
<p>How do I copy a file in Python?</p>
<p><a href="http://docs.python.org/3/library/shutil.html" rel="noreferrer"><code>shutil</code></a> has many methods you can use. One of which is:</p> <pre><code>import shutil shutil.copyfile(src, dst) # 2nd option shutil.copy(src, dst) # dst can be a folder; use shutil.copy2() to preserve timestamp </code></pre> <ul...
<p>Python provides in-built functions for easily copying files using the Operating System Shell utilities.</p> <p>Following command is used to Copy File</p> <pre><code>shutil.copy(src,dst) </code></pre> <p>Following command is used to Copy File with MetaData Information</p> <pre><code>shutil.copystat(src,dst) </cod...
14,993
<p>I am new to jmock and trying to mock an HttpSession. I am getting:</p> <p>java.lang.AssertionError: unexpected invocation: httpServletRequest.getSession() no expectations specified: did you... - forget to start an expectation with a cardinality clause? - call a mocked method to specify the parameter of an expecta...
<p>You don't need to mock the request object. Since the method you're testing (<code>dwnLoadCel.doAuthorization()</code>) only depends on an <code>HttpSession</code> object, that is what you should mock. So your code would look like this:</p> <pre><code>public void testDoAuthorization(){ final HttpSession sessio...
<p>I think you need to tell the JMock context how many times you expect the method to be called before you actually go ahead and call it.</p> <pre><code>final HttpServletRequest request = context.mock(HttpServletRequest.class); context.checking(new Expectations(){{ one(request).getSession(true); will(returnValue(se...
28,522
<p>I'm printing a ring that's a replacement for the non-slip base of a mixing bowl. The ring is about 130mm in diameter, with a rectangular cross section, like this:</p> <p><a href="https://i.stack.imgur.com/9cx9Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9cx9Y.png" alt="rubber ring" /></a></p>...
<p>This is <a href="https://github.com/Ultimaker/Cura/issues/11568" rel="nofollow noreferrer">a known issue</a>. Cura's profile variable logic sets the number of bottom layers to 999999 if infill is set to 100%, overriding infill by replacing it with additional bottom layers. If you go find the setting for number of bo...
<blockquote> <p>Is this a problem with Cura?</p> </blockquote> <p>I don't know if the good folks at Ultimaker consider this a bug or a feature, but it appears that Cura uses the <code>Lines</code> option regardless of the <em>Infill Pattern</em> setting when <em>Infill Density</em> is set to <code>100%</code>. There ma...
2,185
<p>I have a public facing application deployed with Flex. I want to switch to using the cached framework (.swz) but need to know if for my user base this is an effective solution or not (most users will only visit the site once and its just not worth it).</p> <p>What I want to do is track whether or not a user has loa...
<p>My advice is to use the cached framework regardless of your user-base. The fact is, you won't be alone in doing so and it will only be a matter of time before it pays off (even if it is on return visits).</p>
<p>This is probably not the solution you want, but just to help you with the log parsing, you can use this to get counts for each from the logs (assuming you're on a linux server) :</p> <pre><code>grep -c \.swz web_log_dir/* grep -c \.swf web_log_dir/* </code></pre>
11,404
<p>just curious to know which CPU architectures support compare and swap atomic primitives? </p>
<p>Powerpc has more powerful primitives available: "lwarx" and "stwcx"</p> <p>lwarx loads a value from memory but remembers the location. Any other thread or cpu that touches that location will cause the "stwcx", a conditional store instruction, to fail.</p> <p>So the lwarx /stwcx combo allows you to implement atomic...
<p>Sparc v9 has a cas instruction. The SPARC v9 <A HREF="http://www.sparc.org/standards/SPARCV9.pdf" rel="nofollow noreferrer">architecture manual</A> discusses the use of the CAS instruction in Annex J, look specifically at examples J.11 and J.12.</p> <p>I believe the name of the instruction is actually "casa", becau...
18,296
<p>What are the major reasons for using <a href="http://en.wikipedia.org/wiki/WinDbg" rel="noreferrer">WinDbg</a> vs the Visual Studio debugger?</p> <p>And is it commonly used as a complete replacement for the Visual Studio debugger, or more for when the need arises.</p>
<p>If you are wondering why you should use windbg over Visual Studio, then you need to read <a href="https://rads.stackoverflow.com/amzn/click/com/0321374460" rel="noreferrer" rel="nofollow noreferrer">Advanced Windows Debugging</a>. Any time you need to debug a truly ugly problem windbg has better technology to do it...
<p>I always liked the watch and trace feature: 'wt' -> It prints to the output window all the function calls as they happen. That was pretty cool stuff!</p>
13,073
<p>I have an <code>IList&lt;T&gt;</code> that I need to sort, and I would rather not copy the list if possible. I've noticed that <code>ArrayList</code> has an <code>Adapter</code> static method that wraps the passed list without copying it, but this takes an <code>IList</code> and I have an <code>IList&lt;T&gt;</code...
<p>From the blog of Paul Fox, I recommend the post "How to sort an IList": <a href="http://foxsys.blogspot.com/2007/06/how-to-sort-generic-ilist.html" rel="nofollow noreferrer">http://foxsys.blogspot.com/2007/06/how-to-sort-generic-ilist.html</a></p> <p>Just in case that blog goes away in the future, I'll copy the pos...
<pre><code>IList&lt;object&gt; unsorted = ... IList&lt;object&gt; sortedList = unsorted.Orderby(x =&gt; x.Tostring()).Tolist(); </code></pre> <p>this will give the sorted list on the particular field of the object.</p>
28,082
<p>I'm working on a report in SSRS (SQL Server Reporting Services) right now, and I'm having a problem getting a rectanlge I draw on the page in the report designer to grow. Basically, I've got a rectangle drawn, and then I put a text field inside of it. The contents of this text field can be either very short or ver...
<p>The only way I can get a textbox to breach the border of a rectangle is if the textbox is not actually inside the rectangle, but instead is underneath it.</p> <p>When the textbox is inside the rectangle, and when the textbox property <strong><code>CanGrow = TRUE</code></strong> then the textbox and its rectangle bo...
<p>Maybe a little late - but it may help someone later.</p> <p>The rectangle can serve as a container. </p> <p>To turn the rectangle into a container, create the rectangle first. Just drop your other child-object elements (e.g. lists, tables, etc) into the container.</p> <p>However, you cannot create the container...
30,629
<p>I've already asked this question somewhere else but unfortunately I had little luck.</p> <p>So... my Ender 3 Pro extruder just started skipping steps, as in the gears (and the gear pinion) will rotate but the filament won't flow. It all started when I changed PLA filament to a new roll; I thought it might have been...
<p>So, after some day of yelling and disassembling, I figured out what was the issue. As many were suggesting, I indeed had an issue with the tubing lifting from the nozzle. it was lifting, so PLA was slowly infiltrating where it wasn't supposed to be to the point it created a blockage, resulting in skipping.</p> <p>H...
<p>I my case helps reducing printing speed, from 100% to 80%. Looks like the filament is cooling noozle to fast. In some large prints at the begining (on first layers) I'm reducing speed to 60%. This looks like the background temperature is not the same in the center and at the borders.</p>
1,631
<p>I have a VB6 application that needs to update it's self. For this purpose, the PM has recommended using a batch file that is to be launched from the application. The batch file should kill the process, download the new version from a local server, overwrite the old files and launch the application again.<br /> My pr...
<p>If the process is killed, then the exe will be freed up for the update. As an alternative to using taskkill, you can use pskill from sysinternals, but taskkill should work great with the /IM parameter.</p> <p>However, neither pskill or taskkill will not wait for the process to stop before returning control. So yo...
<p>Have a command line parameter like /Shutdown that the VB program will process.</p> <p>MyApp.exe /Shutdown</p> <p>/Shutdown parameter will find existing running instance of the app (using FindWindow API) and send a user message to the window requesting it to shutdown smoothly.</p>
24,949
<p>Is there a way to do this almost out-of-the-box?</p> <p>I could go and write a big method that would use the collected tokens to figure out which leaves should be put in which branches and in the end populate a TreeNode object, but since gppg already handled everything by using supplied regular expressions, I was w...
<p>See MGrammar and Oslo...</p> <p><a href="http://msdn.microsoft.com/oslo" rel="nofollow noreferrer">http://msdn.microsoft.com/oslo</a></p> <p><a href="http://channel9.msdn.com/pdc2008/TL31/" rel="nofollow noreferrer">http://channel9.msdn.com/pdc2008/TL31/</a></p>
<p>Take a look at <a href="http://antlr.org/" rel="nofollow noreferrer">ANTLR</a>, I did a simple .NET compiler written in C# with it few years back. </p>
37,069
<p>Currently IIS sends an expires http header of yesterday minus 1 hour on ASP.NET pages. How do I change this to 60 seconds in the further instead? </p>
<p>You can also add a content-expires page directive to your ASP.NET page (for different expire schedules):</p> <p>@Outputcache </p> <p>Or you can set the header inside your code (perhaps a base page class):</p> <p><code>Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));</code></p> <p>A good article on caching...
<p>Go to IIS administration -> -> Properties -> HTTP Headers tab -> click Enable Content Expiration, and set it to whatever you want.</p>
13,587
<p>I would like the value of the input text box to be highlighted when it gains focus, either by clicking it or tabbing to it.</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script&gt; function focusTest(el) { el.select(); } &lt;/script&gt; &lt;input type="text" value="one" OnFocus="focusTest(this); return false;" ...
<p>I noticed Safari is actually selecting the text then removing the selection quickly.</p> <p>So I tried this quick workaround that works in all browsers:</p> <pre><code>function focusTest(el) { setTimeout (function () {el.select();} , 50 ); } </code></pre> <p>Edit :<br> Upon further testing it turns out the OnMo...
<p>Not sure about a Safari-specific solution here, but an alternative would be to wrap the input element in a div and set the border properties of it via CSS. Then change border color, etc. when focused and unfocused.</p>
35,694
<p>I want to create a custom web part that has more than 1 filter web part and that can be connected to Report Viewer Web Part (Integrated Mode) at runtime/design time.</p> <p>I searched a lot for this, but could not find a way to have single web part that is a provider to more than 1 filters.</p> <p>Say for example ...
<p>Try setting binary mode in your FTP client. That will allow you to experiment with different line endings (dos2unix) on the client side, without worrying about them being translated during transfer.</p>
<p>Response to rebra: No frameworks are used, and I don't know what kind of server this is on. This is basically a one man project on a shared host which was pretty horribly maintained and I'm trying to clean house.</p> <p>Yeah that does make sense and I asked the server people about that, one of my first questions ac...
43,062
<p>I was looking at the API documentation for stl vector, and noticed there was no method on the vector class that allowed the removal of an element with a certain value. This seems like a common operation, and it seems odd that there's no built in way to do this.</p>
<p><code>std::remove</code> does not actually erase elements from the container: it moves the elements to be removed to the end of the container, and returns the new end iterator which can be passed to <code>container_type::erase</code> to do the actual removal of the extra elements that are now at the end of the conta...
<p>If you want to do it without any extra includes: </p> <pre><code>vector&lt;IComponent*&gt; myComponents; //assume it has items in it already. void RemoveComponent(IComponent* componentToRemove) { IComponent* juggler; if (componentToRemove != NULL) { for (int currComponentIndex = 0; currComponen...
6,108
<p>What are the technologies and programming decisions that make Google able to serve a query so fast? </p> <p>Every time I search something (one of the several times per day) it always amazes me how they serve the results in near or less than 1 second time. What sort of configuration and algorithms could they have in...
<p>Latency is killed by disk accesses. Hence it's reasonable to believe that all data used to answer queries is kept in memory. This implies thousands of servers, each replicating one of many shards. Therefore the critical path for search is unlikely to hit any of their flagship distributed systems technologies GFS, Ma...
<p>And <a href="http://research.google.com/pubs/papers.html" rel="nofollow noreferrer">algorithms</a> that can harness that hardware power. Like <a href="http://labs.google.com/papers/mapreduce.html" rel="nofollow noreferrer">mapreduce</a> for instance.</p>
16,050
<p>Where should I be logging exceptions? At the data service tier(ExecuteDataSet, etc.) and/or at the data access layer and/or at the business layer?</p>
<p>At a physical tier boundary.</p> <p>Also in the top-level exception handler in the client.</p> <p>I.e. if your business tier is running on a server, log exceptions before propagating to the client. This is easy if you're exposing your business tier as WCF web services, you can implement an error handler that does...
<p>If you are throwing the exception you should log it when it occurs and then bubble it up. Otherwise only the end user should log an exception (you may have lots of tracing on of course in which case it may get logged quite a bit).</p> <p>The end user may be a UI component or a Service or something...</p> <p>If y...
36,677
<p>I'm interested in using Office 2007 to convert between the pre-2007 binary formats (.doc, .xls, .ppt) and the new Office Open XML formats (.docx, .xlsx, .pptx)</p> <p>How would I do this? I'd like to write a simple command line app that takes in two filenames (input and output) and perhaps the source and/or destina...
<p>Microsoft has a page which gives several examples of writing scripts to "drive" MS Word. <a href="http://gallery.technet.microsoft.com/scriptcenter/3f1802f7-60da-4d5a-841a-12ae8a2f8a4b" rel="nofollow noreferrer">One such example</a> shows how to convert from a Word document to HTML. By changing the last parameter ...
<p>The easiest way would be to use Automation thru the Microsoft.Office.Interop. libraries. You can create an instance of a Word application, for example. There are methods attached to the Application object that will allow you to open and close documents, plus pretty much anything else you can accomplish in VBA by r...
5,618
<p>So far I've been using <code>public void run() {}</code> methods to execute my code in Java. When/why might one want to use <code>main()</code> or <code>init()</code> instead of <code>run()</code>?</p>
<p>This is a peculiar question because it's not supposed to be a matter of choice.</p> <p>When you launch the JVM, you specify a class to run, and it is the <code>main()</code> of this class where your program starts.</p> <p>By <code>init()</code>, I assume you mean the JApplet method. When an applet is launched in t...
<p>as a beginner, i import acm packages, and in this package, run() starts executing of a thread, init() initialize the Java Applet.</p>
32,688
<p>How do I duplicate a whole line in <strong>Vim</strong> in a similar way to <kbd>Ctrl</kbd>+<kbd>D</kbd> in IntelliJ IDEA/ Resharper or <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>&#8593;</kbd>/<kbd>&#8595;</kbd> in <strong>Eclipse</strong>?</p>
<p><kbd>y</kbd><kbd>y</kbd> or <kbd>Y</kbd> to copy the line (mnemonic: <strong><em>y</strong>ank</em>) <br />or <br /><kbd>d</kbd><kbd>d</kbd> to <strong><em>d</strong>elete</em> the line (Vim copies what you deleted into a clipboard-like "register", like a <em>cut</em> operation)</p> <p>then</p> <p><kbd>p</kbd> to ...
<p>I use this mapping, which is similar to vscode. I hope it is useful!!!.</p> <pre><code>nnoremap &lt;A-d&gt; :t. &lt;CR&gt;== inoremap &lt;A-d&gt; &lt;Esc&gt;:t. &lt;CR&gt;==gi vnoremap &lt;A-d&gt; :t$ &lt;CR&gt;gv=gv </code></pre>
9,900
<p>What would be the simplest way to create some graphical representations of the usage of electricity by month?</p>
<p>The best way is to use <a href="http://www.jfree.org/jfreechart/" rel="noreferrer">JFreeChart</a> to produce an image from your data, and then display the image in the jsp. </p>
<p>You can use the <a href="http://code.google.com/apis/chart/" rel="nofollow noreferrer">Google Chart API</a> or a Google Chart API Java wrapper. I wrote one: <a href="http://charts4j.googlecode.com/" rel="nofollow noreferrer">charts4j</a>.</p>
44,309
<p>For example, I have a pet table and a lost pets table. I want to get all of the pets that are NOT lost with 1 join and no sub-selects. Is that possible? A typical join only returns results that are in both tables.</p>
<p>You're describing an OUTER JOIN as compared to a standard INNER JOIN. Google or check your documentation - I'm sure you'll find lots of examples. :)</p> <p>SELECT * FROM pets AS p<br> LEFT OUTER JOIN lost-pets AS lp<br> ON p.name = lp.name<br> WHERE lp.id IS NULL </p>
<p>Why not do where not exists (select * from Lost ...)? Its a sub-select, but I don't see why thats a problem.</p>
48,309
<p>I asked a couple of coworkers about <a href="http://ankhsvn.open.collab.net" rel="nofollow noreferrer">AnkhSVN</a> and neither one of them was happy with it. One of them went as far as saying that AnkhSVN has messed up his devenv several times.</p> <p>What's your experience with AnkhSVN? I really miss having an IDE...
<p>Older AnkhSVN (pre 2.0) was very crappy and I was only using it for shiny icons in the solution explorer. I relied on Tortoise for everything except reverts.</p> <p>The newer Ankh is a complete rewrite (it is now using the Source Control API of the IDE) and looks &amp; works much better. Still, I haven't forced it t...
<p>I tried AnkhSVN (1.0.3, just 4 months ago), and it did not work the way I wanted it to (i.e. needed to select things in the browser window instead of based on active file). I ended up making some macros that utilize TortoiseSVN that work much more like what I expected.</p> <p>I've been very happy with using Tortois...
3,864
<p>I see <a href="http://www.is-research.de/info/vmlanguages/index.html" rel="noreferrer">here</a> that there are a load of languages aside from Java that run on the JVM. I'm a bit confused about the whole concept of other languages running in the JVM. So:</p> <p>What is the advantage in having other languages for the...
<p>To address your three questions separately:</p> <blockquote> <p>What is the advantage in having other languages for the JVM?</p> </blockquote> <p>There are two factors here. (1) Why have a language other than Java for the JVM, and (2) why have another language run on the JVM, instead of a different runtime? </p>...
<p>They do it to keep up with .Net. .Net allows C#, VB, J# (formerly), F#, Python, Ruby (coming soon), and c++. I'm probably missing some. Probably the big one in there is Python, for the scripting people.</p>
11,061
<p>I have this line of code for page load:</p> <pre><code>if ($("input").is(':checked')) { </code></pre> <p>and it works fine when the radio button input is checked. However, I want the opposite. Something along the lines of </p> <pre><code>if ($("input").not(.is(':checked'))) { </code></pre> <p>so that my if sta...
<pre><code>if ( ! $("input").is(':checked') ) </code></pre> <p>Doesn't work?</p> <p>You might also try iterating over the elements like so:</p> <pre><code>var iz_checked = true; $('input').each(function(){ iz_checked = iz_checked &amp;&amp; $(this).is(':checked'); }); if ( ! iz_checked ) </code></pre>
<p>This works too. It seems shortest working notation: <code>!$('#selector:checked')</code></p>
48,669
<p>How can I extract the whole line in a row, for example, row 3. These data are saved in my text editor in linux. Here's my data:</p> <pre><code>1,julz,kath,shiela,angel 2,may,ann,janice,aika 3,christal,justine,kim 4,kris,allan,jc,mine </code></pre> <p>I want output like:</p> <pre><code>3,christal,justine,kim </cod...
<p>The following snippet reads in the first three lines, prints only the third then exits to ensure that no unnecessary processing takes place.</p> <p>Without the exit, the script would continue to process the input file despite you knowing that you have no use for it.</p> <pre><code>perl -ne 'if ($. == 3) {print;exi...
<p>You can assign the diamond operator on your filehandle to a list, each element will be a line or row.</p> <pre><code>open $fh, "myfile.txt"; my @lines = &lt;$fh&gt;; </code></pre> <p><strong>EDIT:</strong> This solution grabs all the lines so that you can access any one you want, e.g. row 3 would be <code>$lines[2...
20,734
<p>In my ASP.Net application I have a requirement that when a user clicks on an UI element we generate a PDF for them which they can download. This is currently implemented by doing a form post to an ashx page. This page essentially inspects the form and then executes the correct server side page which either results i...
<p>The popup can have a client side timer which polls the server for task completion. The long running server task should update the progress in a database table or a server cache object which can be accessed by the polling service.</p> <p>Couple of old articles from MSDN magazine. You should be able to use the same c...
<p>You said:</p> <blockquote> <p>When its a PDF I don't change the target for the form and it remains on the current page.</p> </blockquote> <p>If that is the case then the original page will be gone when the PDF is opened. In that situation I would have a loading animated gif and open it using Javascript into ...
22,157
<p>We have a series of closed source applications and libraries, for which we think it would make sense opening up the source code.</p> <p>What has been blocking us, so far, is the effort needed to clean up the code base and documenting the source before opening up.</p> <p>We want to open up the source only if we hav...
<p>There are a several things which dominate the successfulness of code. All of these must be achieved for the slightest chance of adoption. </p> <ul> <li>Market - There must be a market for your open source project. If your project is a orange juicer in space, I doubt that you'll be very successful. You must make su...
<p>Really, I think the answer is 'how you run the project'.</p> <p>All of your examples matter, yes, but the key things are how the interaction between developers is managed, how patches etc are handled/accepted, who's 'in charge' and how they handle that responsibility, and so on and so forth.</p> <p>Compare and con...
10,657
<p>Sometimes I add a <code>\n</code> at the end, and the relevant number of <code>\t</code> the beginning, and sometimes not - what's the recommended way to do this? </p>
<p>It depends whether you want the HTML to be human readable or not. In most cases however, I would suggest that generated markup should always be human-readable, as it makes debugging a whole lot easier.</p>
<p>Though I do out of habit, there's no need to at all when you've got something like Firebug which shows you the HTML tree all nice and pretty. (Though it does show you the generated HTML, rather than the raw HTML...)</p>
23,824
<p>I have a PHP application which needs to output a python script, more specifically a bunch of variable assignment statements, eg.</p> <pre><code>subject_prefix = 'This String From User Input' msg_footer = """This one too.""" </code></pre> <p>The contents of subject_prefix et al need to be written to take user input...
<p><strong>Do not</strong> try write this function in PHP. You will inevitably get it wrong and your application will inevitably have an arbitrary remote execution exploit.</p> <p>First, consider what problem you are actually solving. I presume you are just trying to get data from PHP to Python. You might try to wr...
<p>I suggest writing a function that will take two arguments: the text to be escaped and the type of quotes the string is in. Then, for example, if the type of quotes are single quotes, the function will escape the single quotes in the string and any other characters that need to be escaped (backslash?).</p> <pre><cod...
23,910
<p>I have the following structure:</p> <pre><code> &lt;StructLayout(LayoutKind.Sequential)&gt; _ Public Structure _WTS_CLIENT_ADDRESS Public AddressFamily As Integer &lt;MarshalAs(UnmanagedType.ByValArray, SizeConst:=20)&gt; _ Public Address() As Byte End Structure </code></pre> <p>...
<p>You're almost there with your code. I agree with you, the MSDN is not quite explicit on what's inside that byte array, but here's what you can do :</p> <pre><code>IPAddress address = new IPAddress(_ClientIPAddress.Address.Skip(2).Take(4).ToArray()); </code></pre> <p>The first two bytes do not seem to be used, but ...
<p>The real answer can be found here. <a href="http://www.tech-archive.net/Archive/Windows/microsoft.public.windows.terminal_services/2007-03/msg00474.html" rel="nofollow noreferrer">http://www.tech-archive.net/Archive/Windows/microsoft.public.windows.terminal_services/2007-03/msg00474.html</a></p>
36,735
<p>I've just heard the term covered index in some database discussion - what does it mean?</p>
<p>A <em>covering index</em> is an index that contains all of, and possibly more, the columns you need for your query.</p> <p>For instance, this:</p> <pre><code>SELECT * FROM tablename WHERE criteria </code></pre> <p>will typically use indexes to speed up the resolution of which rows to retrieve using <em>criteria</...
<p>Covering indexes are indexes which "cover" all columns needed from a specific table, removing the need to access the physical table at all for a given query/ operation.</p> <p>Since the index contains the desired columns (or a superset of them), table access can be replaced with an index lookup or scan -- which is ...
8,749
<p>I want to load the data into session so that when the next button is clicked in crystal report viewer then in should load the data from the datatable instead retrieving the data again from the database. Here goes my code... </p> <pre><code> ReportDocument rpt = new ReportDocument(); DataTable resultSet = new ...
<p>I think you'd want to use the Cache object with a unique key for each user instead of Session here.</p> <p>Pseudo code:</p> <pre><code>var data = Cache["Record_999"] as DataTable; if (data == null) { // get from db // insert into cache } SetDataSource(data); </code></pre>
<p>The problem lies not in with using Session, it lies with the logic used to determine when to retrieve data. Session is the correct approach to use here as Cache is shared across requests - that is, User A would see the report User B just configured if User B was the first user to execute code that used Cache instea...
25,322
<p>Here's the XML code I'm working with:</p> <pre><code>&lt;inventory&gt; &lt;drink&gt; &lt;lemonade supplier="mother" id="1"&gt; &lt;price&gt;$2.50&lt;/price&gt; &lt;amount&gt;20&lt;/amount&gt; &lt;/lemonade&gt; &lt;lemonade supplier="mike" id="4"&gt; &l...
<p>Try this: </p> <pre><code>//lemonade[@id="1"]/price </code></pre> <p>or </p> <pre><code>//lemonade[@supplier="mother"]/price </code></pre> <p>Without the "@" it looks for child elements with that name instead of attributes.</p>
<p>you have to use the @ sign to indicate attribute within the predicate like so: <code>//lemonade[@supplier="mother"]/price</code>, that's all.</p>
28,544
<p>When I am creating a new database table, what factors should I take into account for selecting the primary key's data type?</p>
<p>Sorry to do that, but I found that the answers I gave to related questions (you can check <a href="https://stackoverflow.com/questions/159087/composite-primary-keys-versus-unique-object-id-field#164338">this</a> and <a href="https://stackoverflow.com/questions/224576/will-sql-server-2005-penalize-me-for-using-an-nva...
<p>Whenever possible, try to use a primary key that is a natural key. For instance, if I had a table where I logged one record every day, the logdate would be a good primary key. Otherwise, if there is no natural key, just use int. If you think you will use more than 2 billion rows, use a bigint. Some people like t...
28,519
<p>I'm writing a file that requires dates to be in decimal format:</p> <blockquote> <p><code>2007-04-24T13:18:09</code> becomes <code>39196.554270833331000</code> </p> </blockquote> <p>Does anyone have a time formatter that will do this (Decimal time is what VB/Office, etc. use)?</p> <p>Basic code goes like follo...
<p>You can create a formatter that outputs the decimal fraction of the day. You need to use <code>DateTimeFormatterBuilder</code> to build up the pattern manually. The fraction is added using <a href="http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormatterBuilder.html#appendFractionOfDay%28i...
<p>What's wrong with the <a href="https://docs.oracle.com/javase/1.5.0/docs/api/java/util/Date.html#getTime()" rel="nofollow noreferrer">getTime()</a> method?</p>
37,476
<p>In C++, I can't think of a case in which I would like to inherit private/protected from a base class:</p> <pre><code>class Base; class Derived1 : private Base; class Derived2 : protected Base; </code></pre> <p>Is it really useful?</p>
<p>It is useful when you want to have access to some members of the base class, but without exposing them in your class interface. Private inheritance can also be seen as some kind of composition: the <a href="http://www.parashift.com/c++-faq-lite/private-inheritance.html" rel="noreferrer">C++ faq-lite</a> gives the fo...
<p>I once implemented these data structures as classes:</p> <ul> <li>Linked list</li> <li>Generic array (abstract)</li> <li>Simple array (inherits from generic array)</li> <li>Big array (inherits from generic array)</li> </ul> <p>The big array's interface would make it look like an array, however, it was actually a l...
48,960
<p>Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as a data storage to RoR/Python LAMP-like application.</p> <p>What kind tools are there that are simple and robust enough for replication of the main database to a second machine?</p> <p>I looked through some packages (Slony-I and etc.) but it ...
<p>If you are not doing replication, Write ahead Logs are the simplest solution.</p>
<p>If you are not doing replication, Write ahead Logs are the simplest solution.</p>
10,705
<p>I place the following statements in the second row of my grid in the xaml:</p> <pre><code>&lt;ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1"&gt; &lt;ListView Name="listView" Margin="5" Grid.Row="1"&gt; &lt;ListView.View&gt; &lt;GridView AllowsColumnReorder="Tr...
<p>It works for me:</p> <pre><code>&lt;Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; ...
<p>No need of using <code>ScrollViewer</code>. Just remove the <code>ScrollViewer</code> and use only the <code>ListView</code> and try.</p> <pre><code>ListView listView = new ListView(); listView.SetValue(Grid.RowProperty, 1); listView.SetValue(Grid.ColumnProperty, 1); MainGrid.Children.Add(listView); </code></pre> ...
34,992
<p>Could someone please point me toward a cleaner method to generate a random enum member. This works but seems ugly.</p> <p>Thanks!</p> <pre><code>public T RandomEnum&lt;T&gt;() { string[] items = Enum.GetNames(typeof( T )); Random r = new Random(); string e = items[r.Next(0, items.Length - 1)]; return (T)En...
<pre><code>public T RandomEnum&lt;T&gt;() { T[] values = (T[]) Enum.GetValues(typeof(T)); return values[new Random().Next(0,values.Length)]; } </code></pre> <p><sub>Thanks to @[Marc Gravell] for ponting out that the max in Random.Next(min,max) is exclusive.</sub></p>
<p>I'm not sure about c# but other languages allow gaps in enum values. To account for that:</p> <pre><code>enum A {b=0,c=2,d=3,e=42}; switch(rand.Next(0,4)) { case 0: return A.b; case 1: return A.c; case 2: return A.d; case 3: return A.e; } </code></pre> <p>The major down side is keeping it up to date!<...
41,359
<p>In what situation would it be more appropriate for me to use a bitset (STL container) to manage a set of flags rather than having them declared as a number of separate (bool) variables?</p> <p>Will I get a significant performance gain if I used a bitset for 50 flags rather than using 50 separate bool variables?</p>...
<p>Well, 50 bools as a bitset will take 7 bytes, while 50 bools as bools will take 50 bytes. These days that's not really a big deal, so using bools is probably fine.</p> <p>However, one place a bitset might be useful is if you need to pass those bools around a lot, especially if you need to return the set from a fun...
<p>It depends what you mean by 'performance gain'. If you only need 50 of them, and you're not low on memory then separate bools is pretty much always a better choice than a bitset. They will take more memory, but the bools will be much faster. A bitset is usually implemented as an array of ints (the bools are packed i...
4,112
<p>I'm running into an issue with an ASP.NET 2.0 application. Our network folks just upped our security, and now I get the floowing error whenever I try to access the app:</p> <blockquote> <p>"This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms."</p> </blockquote> <p>I'v...
<p>Double check that you don't have <code>&lt;compilation debug="true" /&gt;</code> in your Web.config. When debug compilation is set, .NET uses an MD5 hash for some internal bookkeeping. MD5 is not FIPS compliant so you get this error.</p>
<p>We've tried the machineKey you suggest. It's helped with some web applications (when paired with ), which is great, but not <em>all</em> of them, which is frustrating.</p> <p>I'm missing something, but danged if I can tell what.</p>
48,554
<p>I would like to do something like this: a rotating cube on a form. I don't want to use any external library or dll, just pure .NET 3.5 (without directx). And a cube build with lines only. Could you please tell me how to do this?</p> <p>I don't want to use external libraries because I don't need > 100 MB library to ...
<p>This is how you go about making a Cube in GDI+</p> <p>C# 3D Drawing with GDI+ Euler Rotation</p> <p><a href="http://www.vcskicks.com/3d-graphics-improved.html" rel="nofollow noreferrer">http://www.vcskicks.com/3d-graphics-improved.html</a></p> <p>C# 3D-Drawing Cube with Shading</p> <p><a href="http://www.vcskick...
<p>Look into WPF in general, it will help you do this with a few measly lines of code. You can also host a WPF window in Forms.</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa970268.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa970268.aspx</a></p>
45,946
<p>How do you set a default value for a MySQL Datetime column?</p> <p>In SQL Server it's <code>getdate()</code>. What is the equivalant for MySQL? I'm using MySQL 5.x if that is a factor.</p>
<p><strong>IMPORTANT EDIT:</strong> It is now possible to achieve this with DATETIME fields since <strong>MySQL 5.6.5</strong>, take a look at the <a href="https://stackoverflow.com/a/10603198/24820">other post</a> below...</p> <p>Previous versions can't do that with DATETIME...</p> <p>But you can do it with TIMESTAMP:...
<p>You can resolve the default timestamp. First consider which character set you are using for example if u taken utf8 this character set support all languages and if u taken laten1 this character set support only for English. Next setp if you are working under any project you should know client time zone and select yo...
20,373
<p>I am working on a program that needs to create a multiple temporary folders for the application. These will not be seen by the user. The app is written in VB.net. I can think of a few ways to do it such as incremental folder name or random numbered folder names, but I was wondering, how other people solve this probl...
<p><strong>Update:</strong> Added File.Exists check per comment (2012-Jun-19)</p> <p>Here's what I've used in VB.NET. Essentially the same as presented, except I usually didn't want to create the folder immediately. </p> <p>The advantage to use <a href="http://msdn.microsoft.com/en-us/library/system.io.path.getran...
<p>The advantage to using System.IO.Path.GetTempFileName is that it will be a file in the user's local (i.e., non-roaming) path. This is exactly where you would want it for permissions and security reasons.</p>
3,737
<p>Recycling a Robin Nano board to build a 3D printer using an old computer PSU (300 W), it only boots on when I have no endstops pugged in at all or if I trigger all the ones I have plugged. At the moment I release them the screen goes off (but the fan of the PSU is still on). Does anyone have any clue about what's go...
<p>It ended up I had like super cheap endstops that were actually shorting VCC to GND, as suspected by r_ahlskog. Just bought other ones and now it's working fine.</p>
<p>It ended up I had like super cheap endstops that were actually shorting VCC to GND, as suspected by r_ahlskog. Just bought other ones and now it's working fine.</p>
1,492
<p>I want to have a reusable button which can be registered for one of many different callbacks, determined by an external source. When a new callback is set, I want to remove the old. I also want to be able to clear the callback externally at any time.</p> <pre><code>public function registerButtonCallback(function:Fu...
<p>I am presuming that you want only one callback function at any given time. If that's teh case then why not have a single callback function associated with the click event on the button which itself called a function and have that function be settable...</p> <pre><code>&lt;mx:Button click="doCallback()" .../&gt; p...
<pre><code>private function callFunction(function:Function):void { checkObject(); obj.addEventListener(MouseEvent.CLICK,function); } private function checkObject():void { if(obj.hasEventListener(MouseEvent.CLICK)) { //here remove that objects } } </code></pre>
22,266