instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm trying to build a Java regular expression to match "<code>.jar!</code>"</p> <p>The catch is that I don't want the matcher to consume the exclamation mark. I tried using <code>Pattern.compile("\\.jar(?=!)")</code> but that failed. As did escaping the exclamation mark.</p> <p>Can anyone get this to work or is th...
<p>Using your regex works for me (using Sun JDK 1.6.0_02 for Linux):</p> <pre><code>import java.util.regex.*; public class Regex { private static final String text = ".jar!"; private static final String regex = "\\.jar(?=!)"; public static void main(String[] args) { Pattern p...
<p>Additionally, you could try boxing it </p> <pre><code>Pattern.compile("\\.jar(?=[!])") </code></pre> <p><sub>Java must be broken: Perl</p> <pre><code>use strict; use warnings; my @data = qw( .jar .jar! .jarx .jarx! ); my @patterns = ( "\\.jar(?=!)", "\\.jar(?=\\!)", "\\.jar(?=[!])", ); for my $pat ( @...
37,401
<p>Is there a way to unlock Windows files without downloading a utility?</p> <p>I have a few files on my Windows XP C: drive that are very old and very useless. When I try to delete these files I get the following message:</p> <pre> Cannot delete FILENAME.zip: It is being used by another person or program Close any...
<p>I've successfully used Process Explorer to find out which process has the file open. It saves a reboot that may not fix the problem anyway.</p> <p>In process explorer: Find &gt; Handle or DLL... then search for the name of the folder/file, then double click one of the search results. It'll select a handle in the mai...
<p>You don't need any utility. Just use Win32 api to unlock them (simply close the handle)</p>
28,451
<p>Unfortunately, I need to do this. I'm using ELMAH for my error log. Before I route to my error.aspx view, I have to grab the default ELMAH error log so I can log the exception. You used to be able to use </p> <pre><code>Elmah.ErrorLog.Default </code></pre> <p>However, this is now marked as obsolete. The compil...
<p>Try <code>System.Web.HttpContext.Current</code>. It should do the trick.</p> <p>Gets HTTP-specific information about an individual HTTP request.</p> <p><a href="https://msdn.microsoft.com/en-us/library/system.web.httpcontext.current%28v=vs.110%29.aspx" rel="noreferrer">MSDN</a></p>
<pre><code>this.HttpContext.ApplicationInstance.Context </code></pre>
18,550
<p>I have this table in an Oracle DB which has a primary key defined on 3 of the data columns. I want to drop the primary key constraint to allow rows with duplicate data for those columns, and create a new column, 'id', to contain an auto-incrementing integer ID for these rows. I know how to create a sequence and trig...
<p>Once you have created the sequence:</p> <pre><code>update mytable set id = mysequence.nextval; </code></pre>
<p>First you should check your PCTFREE... is there enough room for every row to get longer?</p> <p>If you chose a very small PCTFREE or your data has lots of lenght-increasing updates, you might begin chaining every row to do this as an update.</p> <p>You almost certainly better to do this as a CTAS.</p> <p>Create t...
30,204
<p>Which built in (if any) tool can I use to determine the allocation unit size of a certain NTFS partition ?</p>
<p>Open an administrator command prompt, and do this command:</p> <pre><code>fsutil fsinfo ntfsinfo [your drive] </code></pre> <p>The Bytes Per Cluster is the equivalent of the allocation unit. </p>
<p>start > run > MSINFO32 </p> <p>goto components </p> <p>goto storage</p> <p>goto disk</p> <p>on the right look for Bytes/Sector</p>
10,681
<p>I'm looking for a <code>PHP</code> library that will allow me to create a print-ready <code>PDF</code>. The imposition should include 1-up, 4-up, 24-up, etc. layouts, and crop marks.</p> <p><code>FPDF</code>, <code>TCPDF</code> and <code>PHP's</code> included <code>PDF</code> libraries allow me to create an image ...
<p>We used DOMPDF <a href="http://www.digitaljunkies.ca/dompdf/" rel="nofollow noreferrer">http://www.digitaljunkies.ca/dompdf/</a> successfully - just define what you want printed in regular HTML format, then pass the doc to DOMPDF, and it'll create a PDF from it. </p> <p>Much more convenient than working with vector...
<p>I've had a lot of success with <a href="http://www.pdflib.com/" rel="nofollow noreferrer">PDFLib</a> it's a very powerful library with PHP (and C, C#, Perl etc) bindings.</p>
11,450
<p>Image i have a view that is cached with the OutputCache attribute but i still need to increment a counter that records that the page has been viewed, how could i do it?</p> <p>I thought about creating my own Custom ActionFilterAttribute, and using Action Filter Order of Execution to record this .. but i'm not sure ...
<p>Well, you have a few options. </p> <h2>Donut caching</h2> <p>One server-side option is 'Donut caching'. <strong>Donut caching</strong> allows most of the page to be cached, and portions of the page to be not cached (the hole in the middle of the donut). Donut caching <a href="http://haacked.com/archive/2008/11/...
<p>I don't know about the MVC side but if I was doing this in WebForms this sounds like it would be a candidate for <a href="http://tinyurl.com/donutcaching" rel="nofollow noreferrer">output cache substitution</a> aka donut caching. </p>
46,437
<p>Take the following html</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Basic Layout&lt;/title&gt; &lt;style type="text/css"&gt; html,body,div{font-family:Verdana} #Head{...
<p>It is unlikely that you will find a library to read that file for C# - there aren't that many Unix users who also use C#.</p> <p>What I would do would be either to:</p> <ol> <li>Read the Python code, and then port it to C#</li> <li>Find the description of the mbox format online. As it is a Unix system, chances are...
<p>Most standard Unix mail files delimit entries with a line starting "From "</p> <p>So if you read in the mail file as a text file and switch to a new mail entry every time you see the string "From " at the start of a line it should work - Any strings elsewhere should already have been delimited by the email program<...
41,600
<p>What is, or should I ask, is there, an equivalent to DllMain when creating a DLL using C++/CLI?</p> <p>Are there any restrictions on what cannot be called from this initialization code?</p>
<p>Dan: With respect to the loader lock, C++/CLI's delay load of the CLR and proper initialization for a mixed mode binary, I just posted yesterday on <a href="https://stackoverflow.com/questions/647310/c-to-c-cli-to-c-dll-system-io-filenotfoundexception/881110#881110">the subject here</a>.</p> <p>More or less, if you...
<p>One giant advantage of .Net dlls is that they avoid the loader lock. One side effect is that there's no DllMain.</p>
43,476
<p>I read an interesting DailyWTF post today, <a href="http://thedailywtf.com/Articles/Out-of-All-the-Possible-Answers.aspx" rel="noreferrer">"Out of All The Possible Answers..."</a> and it interested me enough to dig up the original <a href="http://forums.thedailywtf.com/forums/t/10030.aspx" rel="noreferrer">forum pos...
<p>This problem is interesting because it doesn't require you to find the LCM of an arbitrary set of numbers, you're given a consecutive range. You can use a variation of the <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" rel="nofollow noreferrer">Sieve of Eratosthenes</a> to find the answer.</p> <pre><...
<p>In expanding on @Alexander's comment, I'd point out that if you can factor the numbers to their primes, remove duplicates, then multiply-out, you'll have your answer.</p> <p>For example, 1-5 have the prime factors of 2,3,2,2,5. Remove the duplicated '2' from the factor list of the '4', and you have 2,2,3,5. Multipl...
22,475
<p>Maybe my understanding of agile development isn't as good as it should be, but I'm curious how an agile developer would potentially use off-the-shelf (OTS) software when the requirements and knowledge of what the final system should be are changing as rapidly as I understand them to (often after each iteration of de...
<h2>Scenario1:</h2> <p>This can occur regardless off the OTS nature of the component. Agile does not mean near-sighted.. you'd need to know the big chunks.. the framework bits and spend thinking time on it beforehand. That said, you can only build to what you know .. Delay only till the last responsible moment.Then yo...
<p>I think I read somewhere that if during an iteration you discover that you have more than 20% more work that you initially thought then you should abandon the sprint and start planning a new one taking into account the additional work.</p> <p>So this would mean replanning with the business to see if they still want...
7,481
<p>I'm new to both Web Services and RMI and I wonder which is the better way to do remoting between different web applications, when these applications are all written in Java, that is when different programming languages don't matter (which would be the advantage of WS).</p> <p>While on the one hand I would guess tha...
<p>The web services do allow a loosely coupled architecture. With RMI, you have to make sure that the class definitions stay in sync in all application instances, which means that you always have to deploy all of them at the same time even if only one of them is changed (not necessarily, but it is required quite often...
<p>For Spring Remoting (I guessed you mean HTTP Invoker), both side should use Spring, if it is the case it can be discussed.</p> <p>For a Java to Java application RMI is a good solutionö, JAX-RPC or JAX-WS for Java-to-Java communication should be avoided if the clients are not under your control or might move to anot...
12,630
<p>I'd like to use the ADO.NET Entity Framework for data access, extend its objects for my business logic, and bind those objects to controls in my UI.</p> <p>As explained in <a href="https://stackoverflow.com/questions/260233/how-do-i-extend-adonet-entity-framework-objects-with-partial-classes">the answers to another...
<p>You can architect your solution using (Plain Old C# Objects) POCO's and Managers.</p> <p>That way you separate the business logic from the value objects.</p> <p>To make it "look pretty", you can mark your methods with the (this) modifier on the parameters so you can then use those methods as extension methods.</p>...
<p>I also use entity framework and tried first to extend the classed but I soon found that was not a good solution so I ended up making new classes (in a new class library) which I prefixed with a B. I did not extend the entity classes. </p> <p>If I have a class named NewsPost the business class is named BNewsPost and...
32,827
<p>If I'm adding a column to a table in Microsoft SQL Server, can I control where the column is displayed logically in queries?</p> <p>I don't want to mess with the physical layout of columns on disk, but I would like to logically group columns together when possible so that tools like SQL Server Management Studio lis...
<p>You can not do this programatically (in a safe way that is) without creating a new table. </p> <p>What Enterprise Manager does when you commit a reordering is to create a new table, move the data and then delete the old table and rename the new table to the existing name. </p> <p>If you want your columns in a p...
<p>It can be done using SQL, by modifying the system tables directly. For example, look here:</p> <p><a href="http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=58912" rel="nofollow noreferrer">Alter table - Add new column in between</a></p> <p>However, I would not recommend playing with system tables, unless it's abso...
2,394
<p>How to add a click event listener to my custom control made with wxWidgets? The custom control uses wxWindow as the base. On the event list I see </p> <pre><code>wxEVT_LEFT_DOWN wxEVT_LEFT_UP wxEVT_LEFT_DCLICK wxEVT_MIDDLE_DOWN wxEVT_MIDDLE_UP wxEVT_MIDDLE_DCLICK wxEVT_RIGHT_DOWN wxEVT_RIGHT_UP wxEVT_RIGHT_DCLI...
<p>Typically, there is no "click" event (and in the case of <a href="http://www.wxwidgets.org/" rel="nofollow noreferrer">wxWidgets</a> - <a href="http://docs.wxwidgets.org/stable/wx_wxmouseevent.html#wxmouseevent" rel="nofollow noreferrer">there isn't</a> ). The action of clicking is broken into its two parts: Mouse D...
<p>In the first instance I recommend inheriting from wxControl not wxWindow, wxControl is designed for that exact purpose and you are less likely to find yourself fighting the system. When I look at a control I am building in my own wxWidgets app, I see that my click handler is attached to wxEVT_LEFT_DOWN. Looking in m...
12,424
<p>I have a ASP.Net page using ADO to query MS access database and as a learning exercise i would like to incorporate LINQ. I have one simple table called Quotes.</p> <p>The fields are: QuoteID, QuoteDescription, QuoteAuthor, QuoteDate. I would like to run simple queries like, "Give me all quotes after 1995". </p> ...
<p>LINQ to SQL doesn't support Access (that is, there's no Access/Jet provider for LINQ), but you can query a DataSet with LINQ. This means that you fill your DataSet with any possible data from your database that you might need in your results, and then you filter on the client side. After you have a typed DataSet, ...
<p>I don't <em>think</em> LINQ to SQL supports Access. However, if your table is sufficiently small to fit into memory, LINQ to DataSet will let you query datatables etc pretty easily - especially strongly typed datasets.</p>
23,640
<p>Note: Using MySQL 4.0, which means no subqueries (at present).</p> <p>I have 2 tables:</p> <ul> <li>A "user_details" table</li> <li>A "skills" table, which has the user_id and a "skill_id", which maps to a predefined set of skills defined elsewhere.</li> </ul> <p>The current query allows an admin to search for us...
<p>You don't need a subquery or a join.</p> <pre><code>SELECT user_id FROM skills WHERE skill_id IN (51, 52, 53, 54, 55) GROUP BY user_id HAVING COUNT(*) = 5; </code></pre>
<p>If you wanted the user details included in the same query you could simply do the following:</p> <pre><code>SELECT * FROM user_details JOIN skills USING (user_id) WHERE skill_id IN (51, 52, 53, 54, 55) GROUP BY user_id HAVING COUNT(*) = 5 </code></pre>
47,174
<p>I'm looking for a simple Python script that can minify CSS as part of a web-site deployment process. (Python is the only scripting language supported on the server and full-blown parsers like <a href="http://cthedot.de/cssutils/" rel="noreferrer">CSS Utils</a> are overkill for this project).</p> <p>Basically I'd li...
<p>This seemed like a good task for me to get into python, which has been pending for a while. I hereby present my first ever python script:</p> <pre><code>import sys, re with open( sys.argv[1] , 'r' ) as f: css = f.read() # remove comments - this will break a lot of hacks :-P css = re.sub( r'\s*/\*\s*\*/', "$$H...
<p>I don't know of any ready made python css minifiers, but like you said css utils has the option. After checking and verifying that the license allows for it, you could go through the source code and snip out the portions that do the minifying yourself. Then stick this in a single script and voila! There you go.</p> ...
27,464
<p>I just had to add a checkbox to an application that was written before I got here, and it was way more difficult than it had to be because the app uses some third-party LayoutManager that attempts to do pseudo-absolute, gridlike positioning. The API was terrible, it takes position-designating strings that are comma...
<p>This situation is getting a lot better. I would say the three most common non-standard layout managers are:</p> <ul> <li>JGoodies FormLayout</li> <li>TableLayout</li> <li>MigLayout</li> </ul> <p>The last two are pretty similar, but MigLayout came slightly later, and will be part of the JDK in future. I'd say any o...
<p>In addition to the 3 abovementioned 3rd party layout managers, you might want to give a try to DesignGridLayout which, although not as powerful as MigLayout, is much easier to use and makes it difficult to design bad forms.</p> <p>Disclaimer: I am one of the authors of DesignGridLayout, but I really believe this is...
41,215
<p>I do more and more exercise with Lambda but I do not figure out why sometime example use <code>.AsQueryable();</code> that use the IQueryable and sometime it omit the <code>.AsQueryable();</code> and use the IEnumerable.</p> <p>I have read the <a href="http://msdn.microsoft.com/en-us/library/bb351562.aspx" rel="nof...
<p>IQueryable implements IEnumerable, so right off the bat, with IQueryable, you can do everything that you can do with IEnumerable. IQueryables deal with converting some lambda expression into query on the underlying data source - this could be a SQL database, or an object set. </p> <p>Basically, you should usually n...
<p>I agree with Arne Claassen, there are cases when you need to think about the underlying implmentatoin provided by the data sources. For example check this <a href="http://jonkruger.com/blog/2007/10/19/iqueryable-vs-ienumerable-in-linq-to-sql-queries/" rel="nofollow noreferrer">blog post</a> which shows how the SQL g...
30,434
<p>I want to build a toolchain from gnuarm.org from sources. I don't want to use binary version because i'm running x64 linux. Can you point me to some kind of tutorial?</p>
<p>Here are the default commands/parameters used to build the binary packages. Download the sources, unpack and issue them:</p> <ol> <li>cd [binutils-build]</li> <li>[binutils-source]/configure --target=arm-elf --prefix=[toolchain-prefix] --enable-interwork --enable-multilib --with-float=soft</li> <li>make all install...
<ol> <li>Download the sources available under "Files"</li> <li>Unpack them </li> <li><p>Go to each unpacked directory and type:</p> <p>./configure --help</p> <p>to get the available options, then run</p> <p>./configure [options]</p> <p>make</p> <p>make check</p> <p>make install</p></li> </ol>
43,950
<p>What is the content type for MHT files?</p>
<p>Microsoft, who co-authored the spec for MHT, seem to think that it should be '<code>message/rfc822</code>' on <a href="http://support.microsoft.com/kb/937912" rel="nofollow noreferrer">this support page</a>.</p> <p>No specific MIME type seems to be given in the spec though: <a href="https://www.rfc-editor.org/rfc/rf...
<p>application/octet-stream</p> <p>You can stream the contents of a .eml file to a browser with this content type and .mht as the extension, and the email will be rendered similar to the way it is rendered in an email client.</p>
5,117
<p>I have an articles table and a categories table. I want to fetch 7 articles for each category. Currently I have this but it's terrible slow on large tables so it's not really a solution:</p> <pre><code>SELECT id, title, categories_id, body, DATE_FORMAT(pubdate, "%d/%m/%y %H:%i") as p...
<p>Here's how I'd solve this problem:</p> <pre><code>SELECT a1.id, a1.title, a1.categories_id, a1.body, DATE_FORMAT(a1.pubdate, "%d/%m/%y %H:%i") as pubdate FROM articles AS a1 LEFT OUTER JOIN articles AS a2 ON (a1.categories_id = a2.categories_id AND (a1.pubdate &lt; a2.pub...
<p>You have several options - some might result in performance issues but it depends on many factors.</p> <p>You could split it into several queries. One query to read out all the categories:</p> <pre><code>SELECT categories_id FROM Categories </code></pre> <p>Then for each category, read out the top seven articles:...
47,893
<p>Do you know a simple script to count NLOCs (netto lines of code). The script should count lines of C Code. It should not count empty lines or lines with just braces. But it doesn't need to be overly exact either.</p>
<p>I would do that using <strong>awk</strong> &amp; <strong>cpp</strong> (preprocessor) &amp; <strong>wc</strong> . awk removes all braces and blanks, the preprocessor removes all comments and wc counts the lines:</p> <pre><code>find . -name \*.cpp -o -name \*.h | xargs -n1 cpp -fpreprocessed -P | awk '!/^[{[:spa...
<p>I have a program called <code>scc</code> that strips C comments (and C++ comments, though with C99 they're the same). Apply that plus a filter to remove blank lines and, if so desired, lines containing just open and close braces, to generate the line counts. I've used that on internal projects - not needed to dis...
41,865
<p>What the best way to get up to speed on MathML and its usage in the world?</p> <p>In particular I mean:</p> <ul> <li>What do you use for rendering/editing it</li> <li>Is it used in any commercial/open source applications that you can point me to</li> <li>Is it popular and used a lot?</li> <li>Are there any viewers...
<p>The <a href="http://www.w3.org/Math/" rel="nofollow noreferrer">W3C's MathML homepage</a> is of course a good place to start. They have a list of software using MathML. There are two portions to the MathML specification: the presentation set, which will tell a rendering engine how to typeset the equation (for instan...
<p>Likely not what you wanted to hear, but after trying MathML I went back to TeX, as it's far more readable and compact than the XML representation. TeX also has a large user base and a number of stable, open WYSIWYG editors.</p> <p>Also, <a href="http://www.mozilla.org/projects/mathml/" rel="nofollow noreferrer">Moz...
26,516
<p>I'm trying to chart the number of registrations per day in our registration system. I have an Attendee table in sql server that has a smalldatetime field A_DT, which is the date and time the person registered.</p> <p>I started with this:</p> <pre><code>var dailyCountList = (from a in showDC.Attendee let ju...
<p>O(n) with 2 enumerations. It's very good to pull the items into memory before trying this. Database has enough to do without thinking about this stuff.</p> <pre><code> if (!dailyCountList.Any()) return; //make a dictionary to provide O(1) lookups for later Dictionary&lt;DateTime, RegistrationCount&gt...
<p>Does this syntax for left outer joins no longer work as well after SP1, then?</p> <p>Usually, you should able to do the following, but you'd need a calendar table of sorts in your SQL database joined to your date key in the registrations table (w/a foreign key on the date id field), and then try:</p> <pre><code>va...
18,105
<p>I had a discussion with a developer earlier today re identifying TCP packets going out on a particular interface with the same payload. He told me that the probability of finding a TCP packet that has an equal payload (even if the same data is sent out several times) is very low due to the way TCP packets are constr...
<p>EDIT: Sorry, my original idea was ridiculous. </p> <p>You got me interested so I googled a little bit and found <a href="http://monkey.org/~jose/software/flowgrep/" rel="nofollow noreferrer">this</a>. If you wanted to write your own tool you would probably have to inspect each payload, the easiest way would probabl...
<p>Sending the same PAYLOAD is probably fairly common (particularly if you're running some sort of network service). If you mean sending out the same tcp segment (header and all) or the whole network packet (ip and up), then the probability is substantially reduced.</p>
10,719
<p>I'm wondering how you'd implement the following use-case in REST. Is it even possible to do without compromising the conceptual model?</p> <p>Read or update multiple resources within the scope of a single transaction. For example, transfer $100 from Bob's bank account into John's account.</p> <p>As far as I can te...
<p>Consider a RESTful shopping basket scenario. The shopping basket is conceptually your transaction wrapper. In the same way that you can add multiple items to a shopping basket and then submit that basket to process the order, you can add Bob's account entry to the transaction wrapper and then Bill's account entry...
<p>I guess you could include the TAN in the URL/resource:</p> <ol> <li>PUT /transaction to get the ID (e.g. "1")</li> <li>[PUT, GET, POST, whatever] /1/account/bob</li> <li>[PUT, GET, POST, whatever] /1/account/bill</li> <li>DELETE /transaction with ID 1</li> </ol> <p>Just an idea.</p>
17,724
<p>I cloned a Git master and made a lot of changes on the clone. I have since committed these changes on the clone and now want the master to be a carbon copy of what is on the clone.</p> <p>I've tried Git push on the clone to push the changes to the master - but nothing I do updates the master.</p> <p>How can I make...
<p>There are 2 kinds of git repository, bare and non-bare. A non bare repository is any repository which has a 'working copy' i.e. some part of the repository currently checked out.</p> <p>You <em>can</em> push into a non-bare repository, but it won't update the checked out working copy even if the checked out branch ...
<p>I like Gareth's and Greg's answers. I'd simply add that I find it really handy to use a bare repository to synchronize work with others. That lets anyone push/pull their changes (including branches) to the bare repository and then others can fetch/pull/merge as they see fit. It's not the same as having a single, ...
36,502
<p>Before anybody asks, I am not doing any kind of screenscraping.</p> <p>I'm trying to parse an html string to find a div with a certain id. I cannot for the life of me get this to work. The following expression worked in one instance, but not in another. I'm not sure if it has to do with extra elements in the htm...
<p>In .NET you can do this:</p> <pre><code>(?&lt;text&gt; (&lt;div\s*?id=(\"|&amp;quot;|&amp;\#34;)content(\"|&amp;quot;|&amp;\#34;).*?&gt;) (?&gt; .*?&lt;/div&gt; | .*?&lt;div (?&gt;depth) | .*?&lt;/div&gt; (?&gt;-depth) )*) (?(depth)(?!)) .*?&lt;/div&gt; </code></pre> <p>You must us...
<p>What programming language? If it's .Net and you're sure the html is well-formed you can load it into an XmlDocument or XDocument object and do an xpath query on it.</p>
36,349
<p>So, I've been living with my cvs repositories for some time. Though there is a thing I miss - if i rename a file that is already in repository, I need to delete the one with old name from there and add the new one. Hence, I loose all my change-history. And sometimes there's a need to rename a file in alredy existing...
<p>Subversion can do this, but you have to do it with </p> <pre><code>svn move &lt;oldfile&gt; &lt;newfile&gt; </code></pre> <p>Edit: And in this decade, we do <code>git mv &lt;oldfile&gt; &lt;newfile&gt;</code>, or just use <code>mv</code> and git usually figures it out on its own.</p>
<p>Subversion has rename capability.</p>
19,706
<p>I am having trouble grabbing the values from the form once processed. I need your help.</p> <pre><code>function updateUser($table, $id) { if($_POST) { processUpdate($table, $id); } else { updateForm($table, $id); } } function processUpdate($table, $id) { print $table; //testing ...
<p>Is the method attribute of the form set to post?</p> <pre><code>&lt;form method = "post" action = "..."&gt; </code></pre> <p>And are all of the input's name attribute set right?</p> <p>Have you looked at the html output to make sure that there were no syntax errors? Also, try using</p> <p><code>$_POST</code></p>...
<p>Please make sure that you use an up-to-date tutorial for one of the latest versions of PHP5. NOT some PHP 3.x tut full of deprecated functions ;-)</p> <p>That will make your life (and ours) a whole lot easier :P</p> <p>By the way one more tip that will prevent you from having major SQL injections in this script: ...
23,064
<p>I have seen continuations in Jetty 6.0 that addresses scaling for comet/reverse-ajax applications. </p> <p>Are there any other libraries/frameworks to be used with Tomcat 5.5? </p>
<p>I would check out DWR(Direct Web Remoting). It has fairly decent documentation and a respectable user base.</p> <p><a href="http://directwebremoting.org/" rel="nofollow noreferrer">DWR</a></p>
<p><a href="https://atmosphere.dev.java.net/" rel="nofollow noreferrer">Atmosphere</a> is the kind of thing I was looking for.</p>
23,958
<p>I have been working for a while to create an iPhone app. Today when my battery was low, I was working and constantly saving my source files then the power went out...</p> <p>Now when I plugged my computer back in and it is getting good power I try to open my project file and I get an error:</p> <blockquote> <p>Unab...
<p>I came across this problem and my senior told me about a solution i.e:</p> <p>Right click on your <code>projectname.xcodeproj</code> file here <code>projectname</code> will be the name of your project. Now after right clicked select <em>Show Packages Contents</em>. After that open your <code>projectname.pbxproj</co...
<p>subversion will corrupt my project file after a svn up on an almost weekly basis. I'm trying to figure out why it does this right now and came across this problem. </p>
47,219
<p>This is a weird problem I have started having recently. My team is developing a COTS application and we have a few people with their hands in the code. A few weeks ago, I received an error message when trying to debug (and run the compiled EXE):</p> <blockquote> <p>"Windows cannot access the specified device, p...
<p>You say that you have several developers working on the project, so I wonder whether they experience this problem as well. </p> <p>If it is only happening on your machine than I would not go searching for a problem inside the code (the refactoring that you did seems quite unrelated to the error so I guess the reaso...
<p>I most commonly encounter that error message when I pull a binary off the net/some untrusted location. Windows will be "helpful" and block access to it.</p> <p>Right click the file and choose properties, then 'unblock'</p> <p>It's strange that the error manifests itself differently elsewhere, so this may be totall...
41,087
<p>I know this isn't strictly speaking a programming question but something I always hear from pseudo-techies is that having a lot of entries in your registry slows down your Windows-based PC. I think this notion comes from people who are trying to troubleshoot their PC and why it's running so slow and they open up the...
<p>In short, not really. </p> <p>In the old days when machines were slower the answer was yes; but having a modern processor rip through even a 60MB registry is not a problem.</p> <p>Typically, the real reason a modern machine starts running slow is due to everything from malware to virus scanners: Mcafee, Norton's,...
<p>any problems occur on the registry could also make your computer much slower.the fix registry problems you need to install a <a href="http://www.windows7-slow.com/computer-running-extremely-slow/" rel="nofollow">registry cleaner</a> as this will fix the errors and make your pc back to its normal state.</p>
7,317
<p>I want to compute for month difference of 2 dates which will return a float value.</p> <p>example:</p> <p>date1='4/23/2008' date2='12/31/2008'</p> <p>that will be 7.y months. I want to find the y value. can someone give me the formula to make this in sql codes? tnx..</p>
<p>There's no standard sql to handle this universally. It depends on what database you're using. Basically, you need to convert the two date strings to the date format your database engine uses internally and subtract the two dates, what the result of the subtraction means will, again, depend. In Oracle, you'd use <cod...
<p>An approximately result for Sql Server;</p> <pre><code>select cast(datediff(dd, date1, date2) as float) / 30 </code></pre>
31,015
<p>I made a rotating image fader using Javascript and CSS to show images and unload them. I wanted to use transparent PNG's, I didn't expect or care if they looked good in IE 6, but IE 7 and 8 treated them with the same disrespect. Firefox and other modern browsers looked great. <br>Every picture with <code>image.fi...
<p>I like <a href="http://www.gtk.org/" rel="nofollow noreferrer">GTK+</a> personally but that or any of the ones you mentioned should be OK. I don't know which is the best in terms of least RAM usage.</p>
<p>I think you should try Html Application.It is something like web page it contain DHTML,java script,ActiveX but it is execute like .exe .</p> <p><strong>Edit:</strong> Sorry for advice you html application.I just know it can run on windows only.</p>
13,829
<p>I am looking for a little bit of JQuery or JS that allows me to produce a horizontally scrolling "news ticker" list.</p> <p>The produced HTML needs to be standards compliant as well.</p> <p>I have tried <a href="http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html" rel...
<p>Smooth Div Scroll can also be used as a news ticker/stock ticker. It can pause on mouse over or mouse down and it can loop endlessly if you want it to.</p> <p>Here's <a href="http://www.maaki.com/" rel="nofollow noreferrer">the example</a> with a running ticker.</p>
<p>An Alternative solution would also be the <a href="http://jonmifsud.com/web-tools/jquery-webticker/" rel="nofollow">jQuery webTicker</a>; its very similar to liscroll however resolves the problem with the ticker stopping after the whole list completes; whilst also adding some new fancy features like; direction of mo...
6,231
<p>Where I'm at the developers have been updated to Excel 2007, but most of the users haven't. I'm building a spreadsheet template (*.xlt) for a user that's gonna need some vba code included, and I'm wondering what issues I'm likely to run into building this in 2007 instead of 2003? I don't have access to a machine w...
<p>The VBA language hasn't changed, but there are additional objects in Office 2007 that are not in Office 2003. Naturally, this will cause a runtime error when you try to access these items in a 2003 environment. What's stopping you from setting about a virtual machine with Excel 2003 to develop under?</p>
<p>i used to develop a lot of macros under 2003, what a POTA,, things like Find, Dir and some others are not available or something change. therefore some erros can be expected, i used to count from 65000 row to the first non empty row to count the rows to work on.... now more rows means more work to do </p>
24,145
<p>The MSDN documentation on <a href="http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx" rel="noreferrer">Object.GetHashCode()</a> describes 3 contradicting rules for how the method should work. </p> <ol> <li>If two objects of the same type represent the same value, the hash function must return ...
<blockquote> <p>Rules 1 &amp; 3 are contradictory to me.</p> </blockquote> <p>To a certain extent, they are. The reason is simple: if an object is stored in a hash table and, by changing its value, you change its hash then the hash table has lost the value and you can't find it again by querying the hash table. It i...
<p>By default it does it based on the reference to the object, but that means that it's the exact same object, so both would return the same hash. But a hash should be based on the value, like in the case of the string class. "a" and "b" would have a different hash, but "a" and "a" would return the same hash.</p>
5,475
<p>Below is an example class hierarchy and code. What I'm looking for is a way to determine if 'ChildClass1' or 'ChildClass2' had the static method whoAmI() called on it without re-implementing it in each child class.</p> <pre><code>&lt;?php abstract class ParentClass { public static function whoAmI () { ...
<p>I believe what you're referring to is a known php bug. Php 5.3 is aiming to address this issue with a new Late Static Binding feature. </p> <p><a href="http://www.colder.ch/news/08-24-2007/28/late-static-bindings-expl.html" rel="nofollow noreferrer">http://www.colder.ch/news/08-24-2007/28/late-static-bindings-expl....
<p>No. Wait for PHP 5.3.</p>
10,943
<p>Is there a better way to do this?</p> <pre><code>string[] s = {"zero", "one", "two", "three", "four", "five"}; var x = s .Select((a,i) =&gt; new {Value = a, Index = i}) .Where(b =&gt; b.Value.StartsWith("t")) .Select(c =&gt; c.Index); </code></pre> <p>i.e. I'm looking for a more efficient or more elegant way to ...
<p>You could easily add your own extension method:</p> <pre><code>public static IEnumerable&lt;int&gt; IndexesWhere&lt;T&gt;(this IEnumerable&lt;T&gt; source, Func&lt;T, bool&gt; predicate) { int index=0; foreach (T element in source) { if (predicate(element)) { yield return ind...
<p>I discussed this interesting problem with a colleague and at first I thought JonSkeet's solution was great, but my colleague pointed out one problem, namely that if the function is an extension to <code>IEnumerable&lt;T&gt;</code>, then it can be used where a collection implements it.</p> <p>With an array, it's saf...
29,382
<p>I'm looking for an online solution for generating .ICO files. I'd like the ICO files to have the ability to have transparency as well.</p> <p>What software or web site do you use to create them?</p> <p>[Update]</p> <p>To clarify, I have an existing image in PNG format, 32 x 32 pixels. I want to generate the ico...
<p>I have found the application <a href="http://icofx.ro/" rel="nofollow noreferrer">IcoFx</a> useful, you can import pretty much any image type to use for icon creation, including PNG's.</p>
<p>I can't imagine drawing icons online. Nowadays icons are usually <em>drawn</em> as vectors, and I'm not aware of any online vector packages.</p> <p>In case you decide to draw off-line instead, I use Xara (www.xara.com) to draw all my computer artwork, and I use Gif Movie Gear to create .ico files. The former is ...
2,974
<p>I have a problem which requires me to parse several log files from a remote machine. There are a few complications: 1) The file may be in use 2) The files can be quite large (100mb+) 3) Each entry may be multi-line</p> <p>To solve the in-use issue, I need to copy it first. I'm currently copying it directly from the...
<p>If you are reading a sequential file you want to read it in line by line over the network. You need a transfer method capable of streaming. You'll need to review your IO streaming technology to figure this out.</p> <p>Large IO operations like this won't benefit much by multithreading since you can probably proces...
<p>I've used <a href="http://www.icsharpcode.net/OpenSource/SharpZipLib" rel="nofollow noreferrer">SharpZipLib</a> to compress large files before transferring them over the Internet. So that's one option.</p> <p>Another idea for 1) would be to create an assembly that runs on the remote machine and does the parsing the...
16,579
<p>I would like to create dynamic urls that route to controller actions with an Id value. I've created the following route using a catch-all parameter</p> <pre><code>routes.MapRoute( "RouteName", "{id}/{*Url}", new { controller = "Con...
<p>That's a really difficult one, for me anyway.</p> <p>Given the following route:</p> <pre><code>routes.MapRoute("Default", "{*token}", new { controller = "Home", action = "Index", token = 0 }); </code></pre> <p>Your controller and supporting classes would be something like this:</p> <pre><code>[HandleError] ...
<p>I would suggest overriding of DefaultControllerFactory</p> <pre><code>&gt; public class CustomControllerFactory : DefaultControllerFactory &gt; { &gt; public override IController &gt; CreateController(System.Web.Routing.RequestContext &gt; requestContext, string controllerName) &gt; { &gt; try...
37,890
<p>I'm using PHP 5.2. I'd like to find a way to output a unique id for every object, so it's easy when looking over logs to see which objects are the same.</p> <p>In Ruby, I'd just say object.object_id to get Ruby's internal identifier for the object. There doesn't seem to be an obvious way to do this in PHP.</p> <p>...
<p>Use <a href="http://php.net/manual/en/function.spl-object-hash.php" rel="noreferrer"><code>spl_object_hash()</code></a> for that.</p> <p>It returns an unique identifier for each object instance, and not the name of the class, so it seems more suitable for you.</p> <p><strong>Edit:</strong></p> <p>For PHP &lt; 5.2...
<p>I know this is old topic, but i think i've found a solution.</p> <p>The trick is in storing reference to each object in array with assigned key. You can then get object id by searching through that array and returning found key.</p> <pre><code>&lt;?php class objectMarker { private $storage; function add(...
39,679
<p>I have client application that uses WCF service to insert some data to backend database. Client application is going to call service on per event basis (it can be every hour or every second).</p> <p>I'm wondering what's the best way of calling that service. </p> <p>Should I create communication channel and keep it...
<p>The first question is whether your server needs to maintain any state about the client directly (i.e. are you doing session-like transactions?) If you are, you will need to be able to manage how the server holds the information between communications.</p> <p>My initial feeling of your question is that if there is ...
<p>I would think you probably wanna implement a <a href="http://en.wikipedia.org/wiki/Keepalive" rel="nofollow noreferrer">Keep Alive pattern</a>, with a configurable duration to inform your underlying mechanism to close the connection if past beyond the Keep-alive duration with zero communication activity.</p>
30,616
<p>I'm looking to write a programming language for fun, however most of the resource I have seen are for writing a context free language, however I wish to write a language that, like python, uses indentation, which to my understanding means it can't be context free.</p>
<p>A context-free grammar is, simply, one that doesn't require a symbol table in order to correctly parse the code. A context-sensitive grammar does.</p> <p>The D programming language is an example of a context free grammar. C++ is a context sensitive one. (For example, is T*x declaring x to be pointer to T, or is it ...
<p>Just because a language uses significant indentation doesn't mean that it is inherently context-sensitive. As an example, Haskell makes use of significant indentation, and (to my knowledge) its grammar is context-free.</p> <p>An example of source requiring a context-sensitive grammar could be this snippet from Rub...
9,374
<p>Is there any way to check if a drag and drop is in progress? Some method or win32 api which can be checked? I know I can set AllowDrop and use events but it doesn't work in this case. Basically i want to check, with code, if <strong>any</strong> drag&amp;drop is in progress.</p>
<p>I had a similar question which I answered myself (after some hours messing about) See - <a href="https://stackoverflow.com/questions/480156/how-do-i-tell-if-a-drag-drop-has-ended-in-winforms">How do I tell if a Drag Drop has ended in Winforms?</a>.</p> <p>Basically if you do as earwicker suggests you need to set th...
<p>Assuming it's in the context of just your own code, you could identify all the places in your code where a drag/drop happens, and set a global boolean flag to true for the duration of the operation, then back to false after it finishes.</p> <p>So the next question is, how are drag/drop operations being started in y...
48,888
<p>My HTML is all marked up, ready to make it rain CSS. The problem is that I have to go back and find out what all my id and class names are so I can get started. What I need is a tool that parses my HTML and spits out a stylesheet with all the possible elements ready to be styled (maybe even with some defaults). D...
<p>I have a poor man's version of this I have used in the past... this requires jquery and firebug...</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $('*[@id]').each(function() { console.log('#' + this.id + ' {}'); }); $('*[@class]').each(fu...
<p>I've made a generator which makes the html and css for you = <a href="https://www.andy-howard.com/css-skeleton-screen-generator/" rel="nofollow noreferrer">https://www.andy-howard.com/css-skeleton-screen-generator/</a></p> <p>Not much else to say really, it utilises the :empty selector in css.</p>
3,761
<p>I have a user who gets an error from ajax calls on our site.</p> <p>The error is pasted below. </p> <p>They get the error in FF3 Windows, but not IE.</p> <p>Based on some searching it seems this issue is often caused by the client protocol squid (you'll notice at the end of the error, squid is mentioned).</p> <p...
<p>Save yourself some time and use <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a>. It has an abstraction for ajax, which works in all browsers and not just Internet Explorer, and maybe FF. ;-) I am assuming that the code up there is old and didn't get an update in a long while.</p> <p>A simple ajax ...
<p>You should sit together with your user and put the <a href="http://www.fiddlertool.com/fiddler/" rel="nofollow noreferrer">Fiddler</a> HTTP tracing tool in between. Then you can easily compare the request being sent by IE and FF3.</p> <p>This way it should become visible where the differences are and why they're ca...
35,973
<p>What is the approved way to convert from char* to System::string and back in C++/CLI? I found a few references to marshal_to&lt;> templated functions on Google, but it appears that this feature never made the cut for Visual Studio 2005 (and isn't in Visual Studio 2008 either, AFAIK). I have also seen some code on <a...
<p>System::String has a constructor that takes a char*:</p> <pre><code> using namespace system; const char* charstr = "Hello, world!"; String^ clistr = gcnew String(charstr); Console::WriteLine(clistr); </code></pre> <p>Getting a char* back is a bit harder, but not too bad:</p> <pre><code> IntPtr p = Marshal::Str...
<p>One additional link to a summary of possible ways:</p> <p><a href="http://support.microsoft.com/?kbid=311259" rel="nofollow">http://support.microsoft.com/?kbid=311259</a></p>
8,052
<p>I've got a small piece of code that is parsing an index value to determine a cell input into Excel. It's got me thinking...</p> <p>What's the difference between </p> <pre><code>xlsSheet.Write("C" + rowIndex.ToString(), null, title); </code></pre> <p>and</p> <pre><code>xlsSheet.Write(string.Format("C{0}", rowInd...
<p><strong>Before C# 6</strong></p> <p>To be honest, I think the first version is simpler - although I'd simplify it to:</p> <pre><code>xlsSheet.Write("C" + rowIndex, null, title); </code></pre> <p>I suspect other answers <em>may</em> talk about the performance hit, but to be honest it'll be minimal <em>if present a...
<p>String concatenation takes more memory compared to String.Format. So best way to concatenate strings is using String.Format or System.Text.StringBuilder Object.</p> <p>Let's take first case: "C" + rowIndex.ToString() Let's assume rowIndex is a value type so ToString() method has to Box to convert the value to Stri...
37,984
<p>Can you recommend a minimalistic python webserver that I can embedded in my Desktop Application.</p>
<p>How minimalistic and for what purpose? </p> <p><a href="https://docs.python.org/2/library/simplehttpserver.html" rel="nofollow noreferrer">SimpleHTTPServer</a> comes free as part of the standard Python libraries.</p> <p>If you need more features, look into <a href="http://cherrypy.org/" rel="nofollow noreferrer">...
<p>I made this one. <a href="http://www.blendedtechnologies.com/python-trick-really-little-http-server/220" rel="nofollow noreferrer">It just enhances Python's SimpleHTTPServer a bit to let you define custom actions depending on the request.</a></p>
38,869
<p>I have a custom class that implements <code>ICollection</code>, and this class is readonly, ie. <code>IsReadOnly</code> returns true (as opposed to using the <code>readonly</code> keyword), and all functions that would normally modify the data in the collection throw <code>InvalidOperationException</code>'s.</p> <p...
<p>Yes this is an issue in some cases. Even though the collection is read only and cannot be changed, the objects the collection references are not read only. Thus if the clients use the SyncRoot to perform locking they will not be thread safe when modifying the objects referenced by the collection.</p> <p>I would rec...
<p>I guess the issue would be if clients used your sync root to achieve locking of not only your collection, but something else. Supposed they cached the size of the collection - or maybe "what subset of this collection matches a predicate" - they would reasonably assume that they could use your SyncRoot to guard both ...
25,983
<p>I've been struggling with this for quite awhile and haven't been able to find a solution. I need a user to be able to view multiple top level domains with a single login.</p> <p>My understanding is that this needs to be set in <code>environment.rb</code> and called with <code>before_dispatch</code>. This is what I'...
<p>This one is a bit tricky. Since cookies can only be assigned to (and retrieved from) the current domain ("forms.example.com", say) and parent domains (".example.com", but not ".com"), but NOT to other domains ("othersite.com"), you'll have to find yourself another solution. This has nothing to do with Rails, but wit...
<p>Your question is not really precise enough IMHO. Do you want a single cookie for all Rails apps you have or is it within the context of a single one? If the former, you want to look at solutions using database-backed sessions or something along the line of <a href="http://code.google.com/p/rubycas-client/" rel="no...
49,383
<p>When developing an app that will listen on a TCP/IP port, how should one go about selecting a default port? Assume that this app will be installed on many computers, and that avoiding port conflicts is desired.</p>
<p>Go <a href="http://www.iana.org/assignments/port-numbers" rel="noreferrer">here</a> and pick a port with the description <code>Unassigned</code></p>
<p>Well, you can reference some commonly used port numbers <a href="http://www.iana.org/assignments/port-numbers" rel="nofollow noreferrer">here</a> and try not to use anyone else's.</p> <p>If by "open to the public at large" you mean you're opening ports on your own systems, I'd have a chat with your system administr...
16,196
<p>Very odd problem as this is working perfectly on our old Classic ASP site. We are basically querying the database and exporting around 2200 lines of text to a Text File through Response.Write to be output to a dialog box and allows the user to save the file.</p> <p>Response.Clear() Response.ClearContent() ...
<p>Attach a remote debugger and find where its hanging?</p> <p>You need to figure out if its the string writer loop, or the actual query code (which is not provided here).</p>
<p>Sounds like maybe you're overflowing the output buffer. Perhaps add a counter in there to flush every few hundred lines.</p> <p>Also, the Response object basically does most of the work for a StringWriter for you. Using the StringWriter as an intermediary is probably redundant.</p>
36,598
<p>Is there any way to create an Access / Jet database from within Linux?</p> <p>I'm trying to feed data from a linux application server (mysql backend) and have not found any tools that let me do this - it seems there should be something.</p> <p>If I can't create a database, is there a way to insert into an existing...
<p>There is a java library called <a href="http://jackcess.sourceforge.net/" rel="nofollow">jackcess</a> that can write to Access mdb files from any platform that can run a jvm.</p>
<ol> <li><p>If you want to create an access database (mdb file) from scratch, you'll need some Microsoft Office dll, so I think you can forget it.</p></li> <li><p>If your idea is to insert/manipulate data in an Access mdb file, you'll need a specific driver for the kind of connexion you want to use. I think your choice...
32,003
<p>I'm trying to find a way to get the execution time of a section of code in C. I've already tried both time() and clock() from time.h, but it seems that time() returns seconds and clock() seems to give me milliseconds (or centiseconds?) I would like something more precise though. Is there a way I can grab the time w...
<p>You referred to <code>clock()</code> and <code>time()</code> - were you looking for <code>gettimeofday()</code>? That will fill in a <code>struct timeval</code>, which contains seconds and microseconds.</p> <p>Of course the actual resolution is up to the hardware.</p>
<p>If you are developing on x86 or x64 why not use the Time Stamp Counter: <a href="http://en.wikipedia.org/wiki/RDTSC" rel="nofollow noreferrer">RDTSC</a>.</p> <p>It will be more reliable then Ansi C functions like time() or clock() as RDTSC is an atomic function. Using C functions for this purpose can introduce prob...
20,896
<p>After the last project I've done using WebForms, I've decided to pass on using that framework in the future. It's great for getting your basic features out there...not so great when you have more complex UI logic.</p> <p>I'm looking at ASP.NET MVC, and like what I see so far. Of course the issue is that you lose th...
<p>I have written an ASP.NET MVC application and I incorporated jQuery into it. I found that jQuery helped me manipulate things that would have overcomplicated my View... such as adding alternating styles to my grids, etc...</p> <p>There are many plugins for jQuery that fill in a lot of the gaps that other libraries m...
<p>This site (stackoverflow) uses ASP.NET MVC and jQuery, if that's any influence.</p> <p>Also, ASP.NET MVC is now shipping with jQuery</p> <p><a href="http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisualStudio.aspx" rel="nofollow noreferrer">http://www.hanselman.com/blog/jQueryToShipWithASPNETMVCAndVisua...
17,453
<p>Given the following idioms:</p> <p>1)</p> <p><pre><code>variable = value1 if condition variable = value2</code></pre></p> <p>2)</p> <p><pre><code>variable = value2 if not condition variable = value1</pre></code></p> <p>3)</p> <p><pre><code>if condition variable = value2 else variable = value1</pre></co...
<p>In theory, I prefer #3 as it avoids having to assign a value to the variable twice. In the real world though I use any of the four above that would be more readable or would express more clearly my intention.</p>
<p><code>switch</code> statement also works. If it's simple and more than 2 or 3 options, that's what I use.</p>
18,389
<p>I have a HTML application, partially HTML, partially VBscript, disguised as a form. What it does is it opens a few local files, runs a DOS box containing GAWK and presents a text file as its result. I wish to expand upon it by letting it create a bitmap image with the results in a stacked bar graph, for instance as ...
<p>Is javascript an option? That would be a lot easier than creating an image file. </p> <p>I have used this jquery plugin <a href="http://code.google.com/p/flot/" rel="nofollow noreferrer">http://code.google.com/p/flot/</a> a few times and works well. </p> <p>I have not used VBScript for a few years now, think you...
<p>Graphics are beyond the capabilities of VBScript alone. You can try if you find an ActiveX/COM component that can do it for you. Looking into Google, my guess is that most of them come as dumbed-down trial versions of quite expensive commercial products. Maybe someone else here knows one that is for free.</p> <p>As...
41,841
<p>This concept is a new one for me -- I first came across it at the <a href="http://developer.yahoo.com/yui/articles/hosting/#configure" rel="nofollow noreferrer">YUI dependency configurator</a>. Basically, instead of having multiple requests for many files, the files are chained into one http request to cut down on p...
<p>There are various ways, the two most obvious would be:</p> <ol> <li>Build a tool like YUI which builds a bespoke, unique version based on the components you ticked as required so that you can still serve the file as static. MooTools and jQuery UI all provide package-builders like this when you download their packag...
<p>Capistrano is a fairly popular Ruby-based web deployment tool. If you're considering it or already using it, there's a great gem that will figure out CSS and Javascript dependencies, merge, and minify the files.</p> <p><code>gem install juicer</code></p> <p>From the <a href="https://github.com/cjohansen/juicer" re...
12,740
<p>This is a php example, but an algorithm for any language would do. What I specifically want to do is bubble up the United States and Canada to the top of the list. Here is an example of the array shortened for brevity. </p> <pre><code>array( 0 =&gt; '-- SELECT --', 1 =&gt; 'Afghanistan', 2 =&gt; 'Albania', ...
<p>What I usually do in these situations is to add a separate field called DisplayOrder or something similar. Everything defaults to, say, 1... You then sort by DisplayOrder and then the Name. If you want something higher or lower on the list, you can tweak the display order accordingly while keeping your normal IDs...
<p>You can not change the order of elements within the same array by "moving" an item around. What you can do it to build a new array that first has your favourite items and then adds anything else from the original countries array at the end:</p> <pre><code>$countries = array( 0 =&gt; '-- SELECT --', 1 =&gt; 'Afg...
6,600
<p>I'm aware that I can grab the CPU identifier and the volume serial number for a physical drive by querying WMI, but WMI usually takes its sweet time. What other speedier options, if any, are available to retrieve this information? Are there Win32 APIs that would accomplish this?</p> <p><strong>Edit:</strong> Allow ...
<p>Just keep in mind that ID of the CPU is not always available. </p> <p>By the way, what are you trying to accomplish? If you want to generate a unique key for a computer instance, check the <a href="http://www.codeproject.com/KB/cs/GenerateUniqueKey.aspx" rel="nofollow noreferrer">Generating Unique Key (Finger Print...
<p>I like <a href="http://msdn.microsoft.com/en-us/library/ms724381(VS.85).aspx" rel="nofollow noreferrer">GetSystemInfo</a> but that doesn't cover physical drives..</p>
30,850
<p>I have a large Java app that is split up into multiple projects. Each project has its own folder in a Subversion repository like so:</p> <p>AccountingCore</p> <ul> <li>trunk</li> <li>branches</li> <li>tags</li> </ul> <p>Common</p> <ul> <li>trunk</li> <li>branches</li> <li>tags</li> </ul> <p>WebCommon</p> <ul>...
<p>If you have a shell, you could enter</p> <p><code>for DIR in AccountingCore Common WebCommon; do mkdir $DIR; cd $DIR; git init; git svn init -s svn://host/path/$DIR; git svn fetch; cd ..; done</code></p> <p>That is, if I made no mistakes.</p>
<p>Yes. just checkout at the root path. If your repo is hosted here:</p> <p>svn://host/path/AccountingCore svn://host/path/Common svn://host/path/WebCommon</p> <p>Then do your <code>git svn</code> command on <code>svn://host/path</code>.</p>
35,257
<p>How is it done? What steps do I need to take and what pitfalls and gotchas are there to consider?</p>
<p>I've gotten this to work, thanks to some inside help over at the <a href="https://devforums.apple.com/" rel="noreferrer">Apple Devforums</a>, you should sign up if you're a dedicated IPhone developer.</p> <p>First thing's first, it's <em>__asm__()</em>, not plain <em>asm()</em>.</p> <p>Secondly, by default, XCode ...
<h1>Background</h1> <ul> <li>Now is 2021 year -&gt; other answer seems is too old?</li> <li>the most iOS device(iPhone etc.) is ARM 64bit: <code>arm64</code></li> </ul> <h1>Inline assembly on the iPhone</h1> <h2>asm keyword</h2> <ul> <li>GNU/GCC compiler <ul> <li>standard C (compile flag: <code>-ansi</code> / <code>-st...
29,444
<p>I am trying to add a "title" element but am getting a NO_MODIFICATION_ALLOWED_ERR error...</p> <pre><code>private static void saveDoc(String f) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(f)...
<p>Not sure if that's the reason, but check if your DOM implementation validates all the changes to the DOM. Because in you code,</p> <pre><code>nextNode.appendChild(doc.createTextNode("title")); </code></pre> <p>will attempt to create a text node as the child of <code>map</code> element and DITA Map doesn't allow th...
<p>For some reason, the parent node seems to be read-only. Clone the document by using:</p> <pre><code>Document newDoc = doc.cloneNode(true); </code></pre> <p>Set it to read-write by:</p> <pre><code>newDoc.setReadOnly(false,true); // ^^^^ also sets children </code></pre> <p>Then do your stuff....
32,505
<p>How do large server farms handle gracefully shutting down all or part of the farm? I'm thinking of planed and unplanned cases like:</p> <ul> <li>"We need to shutdown Rack 42" </li> <li>"We need to do work on the power feeds to the whole block" </li> <li>"Blackout! UPS's running out of Juice! Aahh!"</li> <li>"AC is ...
<p>Computers can use a lot more power coming back online than they do running, since they have to get all of the platters and fans spinning, typically have heavy CPU activity starting all of the applications, and so on. Most shops will have a set sequence that staggers the startups, so they don't max out the circuit a...
<p>One method is to mirror the live machines on temporary hot-swaps and, assuming access is via network, cut over by reconfiguring the router to divert traffic to the mirrors. This process can be automated for unplanned outages.</p> <p>For planned maintenance, some simply notify their users that the system will be un...
36,262
<p>Say I have a class named Frog, it looks like:</p> <pre><code>public class Frog { public int Location { get; set; } public int JumpCount { get; set; } public void OnJump() { JumpCount++; } } </code></pre> <p>I need help with 2 things:</p> <ol> <li>I want to create an event name...
<pre><code>public event EventHandler Jump; public void OnJump() { EventHandler handler = Jump; if (null != handler) handler(this, EventArgs.Empty); } </code></pre> <p>then</p> <pre><code>Frog frog = new Frog(); frog.Jump += new EventHandler(yourMethod); private void yourMethod(object s, EventArgs e) { C...
<p>Here is a sample of how to use a normal EventHandler, or a custom delegate. Note that <code>?.</code> is used instead of <code>.</code> to insure that if the event is null, it will fail cleanly (return null)</p> <pre><code>public delegate void MyAwesomeEventHandler(int rawr); public event MyAwesomeEventHandler Awes...
11,068
<p>In .Net, I found this great library, <a href="http://www.codeplex.com/htmlagilitypack" rel="noreferrer">HtmlAgilityPack</a> that allows you to easily parse non-well-formed HTML using XPath. I've used this for a couple years in my .Net sites, but I've had to settle for more painful libraries for my Python, Ruby and...
<p>I'm surprised there isn't a single mention of lxml. It's blazingly fast and will work in any environment that allows CPython libraries.</p> <p>Here's how <a href="http://codespeak.net/lxml/xpathxslt.html" rel="noreferrer">you can parse HTML via XPATH using lxml</a>.</p> <pre><code>&gt;&gt;&gt; from lxml import etr...
<p>There is a free C implementation for XML called libxml2 which has some api bits for XPath which I have used with great success which you can specify HTML as the document being loaded. This had worked for me for some less than perfect HTML documents.. </p> <p>For the most part, XPath is most useful when the inboun...
36,327
<p>I'm looking into using <a href="http://lucene.apache.org/java/docs/" rel="nofollow noreferrer">Lucene</a> and/or <a href="http://lucene.apache.org/solr/" rel="nofollow noreferrer">Solr</a> to provide search in an RDBMS-powered web application. Unfortunately for me, all the documentation I've skimmed deals with how t...
<p>Will multiple applications be writing to the database? If so, it's a bit tricky; you have to have some mechanism to identify new records to feed to the Lucene indexer.</p> <p>Another point to consider is do you want one index that covers all of your tables, or one index per table. In general, I recommend one index,...
<p>As introduction:</p> <p>Brian McCallister wrote a nice blog post: <a href="http://kasparov.skife.org/blog/2004/09/11/" rel="nofollow noreferrer"><strong>Using Lucene with OJB</strong></a>. </p>
37,896
<p>I need to recover form an error case where a file gets left in a locked state. How can I in c# tell this file to reset it's locks? I need to add to this the file is opened by a 3rd party dll and I don't actually have access to the file handle.</p>
<p>Locking a file is the responsibility of the Operating System (on behalf of the program that opens it). If a file is left in a locked state, its really up to the OS to unlock. This typically happens automatically when the process that opened the file exits.</p> <p>There is, however, a really cool utility that I ca...
<p>You have to close the file using .Close(). You need to make sure you still have a way of accessing the file object.</p> <p>You usually can avoid this error by writing a try{} ... finally {} construct after the code that does your file I/O. In the finally {} block, you'd call the Close method of your file object, ...
28,255
<p>For a in-house hardware monitoring utility, I need to use gauges and charts to help visualize various metrics. Is there any good open source or free charting and gauge library available for .NET? I am not interested in purchasing any components (which excludes components such as Dundas Charts &amp; Graph, which I kn...
<p>I know this isn't open source, but it's worth noting that Microsoft just released a free charting pack for ASP.NET and WinForms. More details <a href="http://blogs.msdn.com/sqlrsteamblog/archive/2008/10/25/microsoft-chart-controls-for-net-framework-35.aspx" rel="nofollow noreferrer">here</a>.</p>
<p>I'm having a look at NPlot, but it looks a bit impenetrable at first glance.</p>
29,908
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/2246772/whats-the-difference-between-not-exists-vs-not-in-vs-left-join-where-is-null">What&#39;s the difference between NOT EXISTS vs. NOT IN vs. LEFT JOIN WHERE IS NULL?</a> </p> </blockquote> <p>I need to wit...
<pre><code>SELECT * FROM A WHERE ID NOT IN (SELECT ID FROM B) </code></pre>
<p>Assuming: TableA's Id = Id TableB's Id = Id</p> <pre><code>select * from TableA ta where ta.Id not in (select Id from TableB) </code></pre>
35,513
<p>I got a core that looks very different from the ones I usually get - most of the threads are in __kernel_vsyscall() :</p> <pre><code> 9 process 11334 0xffffe410 in __kernel_vsyscall () 8 process 11453 0xffffe410 in __kernel_vsyscall () 7 process 11454 0xffffe410 in __kernel_vsyscall () 6 process 11455 0x...
<p><code>__kernel_vsyscal</code> is the method used by linux-gate.so (a part of the Linux kernel) to make a system call using the fastest available method, preferably the <code>sysenter</code> instruction. The thing is properly explained by <a href="http://www.trilithium.com/johan/2005/08/linux-gate" rel="noreferrer">J...
<p>As Adam said, the main reason is performance. See this link for some old numbers <a href="http://lkml.org/lkml/2002/12/9/13" rel="nofollow noreferrer">http://lkml.org/lkml/2002/12/9/13</a>.</p> <p>If you have a vDSO enabled kernel, you're not using interrupts to run syscalls, as Stefan said, actually was because in...
44,861
<p>I have found a video about Invisalign. I saw a 3D printer in the video but I did not understand its type. Can you help me? Do you share a brief piece of information about its type?</p> <p>Below is the video on YouTube.</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src=...
<p>In the video, there is this still from <a href="https://youtu.be/bKsGNrEKx9M?t=32" rel="nofollow noreferrer">0:32</a>:</p> <p><a href="https://youtu.be/bKsGNrEKx9M?t=32" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jf2F8.png" alt="enter image description here" /></a></p> <p>The labeling is iPro 8000...
<p>If you look at the video at 37 seconds, it appears to be SLA or DLP.</p> <p>Further reading: <a href="https://www.solidprint3d.co.uk/wp-content/uploads/2019/04/SLA_vs_DLP.pdf" rel="nofollow noreferrer">https://www.solidprint3d.co.uk/wp-content/uploads/2019/04/SLA_vs_DLP.pdf</a></p>
1,876
<p>Wikipedia says SQL Server Express Edition is limited to "one processor, 1 GB memory and 4 GB database files". Does anyone have practical experience with how well this scales?</p>
<p>It's a regular sql server, it just has a limit. SharePoint by default uses the sql server express if that gives you any idea. We have our entire office (80+) people running on that instance.</p>
<p>It really comes down to the nature of your database and application. What kind of application(s) are hitting SQL Server? In my experience, it only handles 5-10 users with a heavy read/write application.</p>
5,610
<p>I want to sprintf() an unsigned long long value in visual C++ 6.0 (plain C).</p> <pre><code>char buf[1000]; //bad coding unsigned __int64 l = 12345678; char t1[6] = "test1"; char t2[6] = "test2"; sprintf(buf, "%lli, %s, %s", l, t1, t2); </code></pre> <p>gives the result</p> <pre><code>12345678, (null), test1 ...
<p>To print an <code>unsigned __int64</code> value in Visual C++ 6.0 you should use <code>%I64u</code>, not <code>%lli</code> (refer to <a href="http://msdn.microsoft.com/en-us/library/aa272936%28VS.60%29.aspx" rel="nofollow noreferrer">this page</a> on MSDN). <code>%lli</code> is only supported in Visual Studio 2005 a...
<p>Apparently, you did not assign <code>additionaltext</code> to the necessary <code>char *</code> (string). Note that the <code>long int</code> was processed, the comma was copied and only the <code>%s</code> generated <code>(null)</code>.</p>
24,488
<p>If you create a simple "Hello World" VSTO2SE add-in targeting Microsoft Office Excel 2003, it takes 15 seconds to load on a cold startup. During that time, Excel is completely unresponsive. </p> <p>The cold-startup time is always poor in Excel 2003. I have seen one test machine where the startup time is instant ...
<p>You're going to take a hit on cold start up because it has to load all of the assemblies for the first time.</p> <p>If warm start up are significantly faster, then the only real options you have are</p> <p>1) Have a separate program load when windows starts and load all of the assemblies for you r addin in the bac...
<p>Have you verified what the actual holdup is? If you put a Debug.Write() statement as the first line in your VSTO addin, does it take 15 seconds to show up in the debug window?</p> <p>We're working with VSTO and whenever we have holdups, it's usually something other than the actual runtime that's causing the slowdo...
30,870
<p>What is Windows' best I/O event notification facility? </p> <p>By best I mean something that ...</p> <ol> <li>doesn't have a limit on number of input file descriptors</li> <li>works on all file descriptors (disk files, sockets, ...)</li> <li>provides various notification modes (edge triggered, limit triggered)</li...
<p>In Windows, async operations are done by file operation, not by descriptor. There are several ways to wait on file operations to complete asynchronously.</p> <p>For example, if you want to know when data is available on a network socket, issue an async read request on the socket and when it completes, the data was ...
<p>select() function is POSIX and usable on windows including "winsock.h" or "winsock2.h". </p>
9,266
<p>I have a couple search forms, 1 with ~50 fields and the other with ~100. Typically, as the HTML spec says, I do searches using the GET method as no data is changed. I haven't run into this problem yet, but I'm wondering if I will run out of URL space soon?</p> <p>The limit of <a href="http://support.microsoft.com/k...
<p>Are your users actually going to be using all 50-100 fields to do their searches? If they're only using a few, why not POST the search to an "in between" page which header()-redirects them to the results page with only the user-changed fields in the URL? The results page would then use the default values for the fie...
<p>Use post and if the user bookmarks the search, save it in a database and give it a unique token, then redirect to the search page using <code>GET</code> and passing the token as parameter.</p> <p>TinyURL is a nice example: You give it a very long URL, it saves it to a DB, gives you a unique identifier for that URL ...
38,065
<p>Can someone explain why how the result for the following unpack is computed?</p> <pre><code>"aaa".unpack('h2H2') #=&gt; ["16", "61"] </code></pre> <p>In binary, 'a' = 0110 0001. I'm not sure how the 'h2' can become 16 (0001 0000) or 'H2' can become 61 (0011 1101).</p>
<p>Not 16 - it is showing 1 and then 6. h is giving the hex value of each nibble, so you get 0110 (6), then 0001 (1), depending on whether its the high or low bit you're looking at. Use the high nibble first and you get 61, which is hex for 97 - the value of 'a'</p>
<p>The hex code of char <code>a</code> is 61.</p> <p>Template <code>h2</code> is a hex string (low nybble first), <code>H2</code> is the same with high nibble first.</p> <p>Also see the <a href="http://perldoc.perl.org/functions/pack.html" rel="nofollow noreferrer">perl documentation</a>.</p>
15,990
<p>A coworker of mine has this problem, apparently after installing Re#, which seems totally irrelevant. But perhaps it isn't.</p> <p>Could not load file or assembly "SqlManagerUi, Version=9.0.242.0..." or one of its dependencies. The module was expected to contain an assembly manifest. (mscorlib).</p> <p>Why is this...
<p>I was with a similar problem, i could not open my SQL Server Management Studio. This steps works for me:</p> <p>In file <code>C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe.config</code>, erase the item <code>&lt;NgenBind_OptimizeNonGac enabled="1" /&gt;</code>.</p> <p>Exampl...
<p>was there any installing/uninstalling of VS involved? Don't get me started on SQL 2005 and VS intall conficts. </p>
15,511
<p>this should be simple...could someone provide me a simple code sample that has an aspx page hosting both a silverlight app (consisting of, say a button) and an iframe (pointing to, say stackoverflow.com). The silverlight app and iframe could be in separate div's, the same div, whatever. </p> <p>Everything I've trie...
<p>Hmm, sound a bit odd, a quick google gave me <a href="http://silverlight.net/forums/p/21584/75457.aspx" rel="nofollow noreferrer">this top result</a> which talks about using an Iframe and Silverlight on the same page, without problems.</p> <p>Also a quick test with the following code:</p> <pre><code>&lt;%@ Page La...
<p>What does your XAML look like? </p> <p>It could be something along the lines of the size set on the usercontrol in XAML, doesn't match the size set on the plugin on the aspx page. In that case, your button might be there but just not in the viewable area... Try checking the size of things, make sure they match.</p>...
11,852
<p>I am working on an application that is about 250,000 lines of code. I'm currently the only developer working on this application that was originally built in .NET 1.1. Pervasive throughout is a class that inherits from CollectionBase. All database collections inherit from this class. I am considering refactoring...
<p>Don't. Unless you have a really good business justification for putting your code base through this exercise. What is the cost savings or revenue generated by your refactor? If I were your manager I would probably advise against it. Sorry. </p>
<p>I agree with Thomas.</p> <p>I feel the question you should always ask yourself when refactoring is "What do I gain by doing this vs doing something else with my time?" The answer can be many things, from increasing maintainability to better performance, but it will always come at the expense of something else.</p>...
12,382
<p>I added a text file to a testapp's solution and I want to read said file. I don't remember how to do this, I know it has to do with reflections but I need a push in the right direction.</p>
<p>If you add the text file to a .ResX file, you can have all the benefits (dynamic updating, for instance) AND not need to worry about interacting with an actual file. VB will automatically create a class to access the file - suppose you have Resources.resx. You can access it with My.Resources.MyFile - it will retur...
<p>I was going to write some code, but instead found a better explanation <a href="http://www.homeandlearn.co.uk/NET/nets8p2.html" rel="nofollow noreferrer">here</a></p> <p>In your case, you'll need to use your application path instead of "C:\".</p>
42,990
<p>I personally use <a href="http://php.net/var_dump" rel="nofollow noreferrer"><code>var_dump</code></a>, but lots of people like <a href="http://php.net/print_r" rel="nofollow noreferrer"><code>print_r</code></a>. </p> <p>What does everyone use? Pros and Cons?</p> <p>Does someone have a special home brew function o...
<p>I use <code>print_r()</code> because I like the pretty array structure... but <code>var_dump</code> does give you a bit more information (like types)</p> <pre><code>$obj = (object) array(1, 2, 3); // output of var_dump: object(stdClass)#1 (3) { [0]=&gt; int(1) [1]=&gt; int(2) [2]=&gt; int(3) } // outp...
<p>print_r() usually, but var_dump() provides better information for primitives.</p> <p>That being said, I do most of my <em>actual</em> debugging with the Zend Server Debugger.</p>
17,103
<p>We've looked in Silverlight 2 recently and found no way to edit formatted text there. Is this really true, and are there any (maybe commercial) external rich text editors available?</p>
<p>Vectorlight has a <a href="http://www.vectorlight.net/silverlight_rich_textbox_demo.aspx" rel="nofollow noreferrer">rich text box</a>.</p>
<p>I haven't tried it myself yet but this is one I know of.</p> <p><a href="http://www.codeplex.com/richtextedit" rel="nofollow noreferrer">http://www.codeplex.com/richtextedit</a></p>
15,611
<p>Stack exchange isn't a good platform for product recommendations in general, but a few sites allow it with a tight focus and control. Some that have allowed it in the past have decided to discontinue it for a variety of reasons.</p> <p>I expect at the start we are going to get a lot of "What specific machine shoul...
<p>I agree with Jeff's blog post: <a href="https://blog.stackoverflow.com/2010/11/qa-is-hard-lets-go-shopping/">https://blog.stackoverflow.com/2010/11/qa-is-hard-lets-go-shopping/</a></p> <blockquote> <p>don't ask us what you should buy -- ask us <em>what you need to learn</em> to tell what you should buy.</p> </blo...
<p>I think that hardware recommendations are ok, but in a <strong>limited</strong> and <strong>specific</strong> scope:</p> <p>Bad:</p> <blockquote> <p>Can you recommend a cheap printer with a heated bed that's at least 8&quot;*8&quot;*8&quot;.</p> <p>Which is better? Printer X or printer Y?</p> </blockquote> <p>Good:<...
2
<p>It seems like Groovy was forgotten in this thread so I'll just ask the same question for Groovy.</p> <ul> <li>Try to limit answers to Groovy core</li> <li>One feature per answer</li> <li>Give an example and short description of the feature, not just a link to documentation</li> <li>Label the feature using bold titl...
<p><strong>Using the spread-dot operator</strong></p> <pre><code>def animals = ['ant', 'buffalo', 'canary', 'dog'] assert animals.size() == 4 assert animals*.size() == [3, 7, 6, 3] </code></pre> <p>This is a shortcut for <code>animals.collect { it.size() }</code>.</p>
<h2><strong>Elvis operator</strong></h2> <p><strong>"Elvis operator"</strong> is a shortening of the ternary operator. One instance of where this is handy is for returning a 'sensible default' value if an expression resolves to false(as in Groovy truth). A simple example might look like this:</p> <p>with the ternary ...
38,996
<p>So I have a daemon running on a Linux system, and I want to have a record of its activities: a log. The question is, what is the "best" way to accomplish this?</p> <p>My first idea is to simply open a file and write to it.</p> <pre><code>FILE* log = fopen("logfile.log", "w"); /* daemon works...needs to write to lo...
<p>Unix has had for a long while a special logging framework called <a href="http://en.wikipedia.org/wiki/Syslog" rel="noreferrer">syslog</a>. Type in your shell </p> <pre><code>man 3 syslog </code></pre> <p>and you'll get the help for the C interface to it.</p> <p><a href="http://www.codeproject.com/KB/IP/syslog_cl...
<p>There are a lot of potential issues: for example, if the disk is full, do you want your daemon to fail? Also, you will be overwriting your file every time. Often a circular file is used so that you have space allocated on the machine for your file, but you can keep enough history to be useful without taking up too...
19,162
<p>I like the flexibility of Dynamic SQL and I like the security + improved performance of Prepared Statements. So what I really want is Dynamic Prepared Statements, which is troublesome to make because bind_param and bind_result accept "fixed" number of arguments. So I made use of an eval() statement to get around t...
<p>I think it is dangerous to use <code>eval()</code> here.</p> <p>Try this:</p> <ul> <li>iterate the params array to build the SQL string with question marks <code>"SELECT * FROM t1 WHERE p1 = ? AND p2 = ?"</code></li> <li>call <code>prepare()</code> on that </li> <li>use <code>call_user_func_array()</code> to make ...
<p>You don't really need prepared statements and bound arguments, because you can always use mysql_real_escape_string(). And you're right; dynamically generated SQL is far more flexible and valuable. </p> <p>Here's a simple example using the regular mysql_* interface:</p> <pre><code>// Array of WHERE conditions $cond...
24,599
<p>How do I make the XDocument object save an attribute value of a element with single quotes?</p>
<p>I'm not sure that any of the formatting options for LINQ to XML allow you to specify that. Why do you need to? It's a pretty poor kind of XML handler which is going to care about it...</p>
<p>I'm not sure that any of the formatting options for LINQ to XML allow you to specify that. Why do you need to? It's a pretty poor kind of XML handler which is going to care about it...</p>
27,496
<p>any thoughts on this would be appreciated:</p> <pre><code>std::string s1 = "hello"; std::string s2 = std::string(s1); </code></pre> <p>I'd now expect these two strings to be independent, i.e. I could append ", world" to s2 and s1 would still read "hello". This is what I find on windows and linux but running the co...
<p>Although I could not reproduce the exact bug of the OP, I came across a similar bug in the HP-UX aCC compilers. I posted about it on the <a href="http://forums12.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1223649583692+28353475&amp;threadId=1108413" rel="noreferrer">HP boards</a>, and eventually go...
<p>That sure sounds like a bug to me. Can anyone else who has access to HP/UX repro this?</p> <p>You're saying that this program displays the same text on both lines?</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string&gt; int main () { std::string s1 = "hello"; std::string s2 = std::string(s1); ...
22,988
<p>I would like create a web service in ASP.Net 2.0 that will supports JSON. Is there a way to do this without WCF and .Net 3.5? Can anyone point me to a good article or sample code? </p> <p><strong>Clarification</strong></p> <p>I need direction on what is the best method, using the .Net 2.0 framework, to communic...
<p>use JayRock!</p> <p>JayRock will work with .net 2.0</p> <p><a href="http://jayrock.berlios.de/" rel="nofollow noreferrer">http://jayrock.berlios.de/</a></p>
<p>You can utilize WCF for your website, The WCF JSON endpoint can even generate javascript client proxy for the service.</p> <p>Check out this post</p> <p><a href="https://stackoverflow.com/questions/186631/rest-soap-endpoints-for-a-wcf-service#186695">REST / SOAP endpoints for a WCF service</a></p> <p>A download s...
29,945
<p>Suppose <code>a</code> and <code>b</code> are both of type <code>int</code>, and <code>b</code> is nonzero. Consider the result of performing <code>a/b</code> in the following cases:</p> <ol> <li><code>a</code> and <code>b</code> are both nonnegative.</li> <li><code>a</code> and <code>b</code> are both negative.</...
<p>According to the May 2008 revision,</p> <p>You're right:</p> <blockquote> <p>The binary / operator yields the quotient, and the binary % operator yields the remainder from the division of the first expression by the second. If the second operand of / or % is zero the behavior is undefined; otherwise (a/b)*b + a%...
<p>Sometimes we need to take a step back, and look just at the mathematics of it:</p> <p>Given int x, int y</p> <p>if int i1 = x/y and int i2 = x%y</p> <p>then y * i1 + i2 must be x</p> <p>So this is not so much about the standard, but there is only one way this can possibly be. If any standards allows it to b...
41,366
<p>So I'm using python to do some parsing of web pages and I want to split the full web address into two parts. Say I have the address <a href="http://www.stackoverflow.com/questions/ask">http://www.stackoverflow.com/questions/ask</a>. I would need the protocol and domain (e.g. <a href="http://www.stackoverflow.com">ht...
<p>Dan is right: urlparse is your friend:</p> <pre><code>&gt;&gt;&gt; from urlparse import urlparse &gt;&gt;&gt; &gt;&gt;&gt; parts = urlparse("http://www.stackoverflow.com/questions/ask") &gt;&gt;&gt; parts.scheme + "://" + parts.netloc 'http://www.stackoverflow.com' &gt;&gt;&gt; parts.path '/questions/ask' </code></...
<pre><code>import re url = "http://stackoverflow.com/questions/ask" protocol, domain = re.match(r"(http://[^/]*)(.*)", url).groups() </code></pre>
36,357