input
stringlengths
51
42.3k
output
stringlengths
18
55k
When can't an object be converted to a reference? <p>I want to compile the following line of code from <a href="http://code.google.com/p/enhsim">http://code.google.com/p/enhsim</a>:</p> <pre><code>enh::eout &lt;&lt; enh::setw(26); </code></pre> <p>gcc gives the following error:</p> <pre><code>error: no match for 'op...
<p>The value <code>enh::setw(26);</code> is an <em>rvalue</em> . Actually, temporaries like that are rvalues. Rvalues have special properties. One of them is that their address can't be taken (<code>&amp;enh::setw(26);</code> is illegal), and they can't generally bind to references to non-const (some temporaries <em>ca...
Is using a while block to do nothing a bad thing? <p>I'm currently working through the excercises in 'The C Programming Language'. Here's one of my solutions: </p> <pre><code>int c; while ((c=getchar()) != EOF) { if (c == ' ') { while ((c = getchar()) == ' ') {} // do nothing? putchar(' '); } putch...
<p>Not at all - I believe you'll find do-nothing loops like these in K&amp;R, so that's about as official as it gets.</p> <p>It's a matter of personal preference, but I prefer my do-nothing loops like this:</p> <pre><code>while(something()); </code></pre> <p>Others prefer the semicolon to go on a separate line, to r...
How to keep code base and database schema in synch? <p>So recently on a project I'm working on, we've been struggling to keep a solution's code base and the associated database schema in synch (Database = SQL Server 2008). </p> <p>Database changes occur fairly regularly (adding columns, constraints, relationships, et...
<p>We try to work forward from the creation scripts.</p> <p>i.e a change to the database is not authorised unless the script has been tested and checked into source control.</p> <p>But this assumes that the database team is integrated with your app team which is usually not the case in a large project...</p> <p>(I w...
jQuery form submit() is not working in IE6? <p>I want to submit a with using jquery as below;</p> <pre><code>$("#formid").submit(); </code></pre> <p>Its working perfect in all browsers except IE6.</p> <p>How to make it work in IE6 ??</p>
<p>You probably have an <code>&lt;input name="submit" /&gt;</code> somewhere in your form, which overwrites the function "submit" of the form in IE.</p> <p><strong>Edit:</strong> </p> <p>I have tested in some other browsers. The latest versions of all major browsers seem to be affected by this issue.</p> <ul> <li>IE...
Create regex from glob expression <p>i write program that parse text with regular expression. Regular expression should be obtained from user. I deside to use glob syntax for user input, and convert glob string to the regular expression internally. For example: </p> <pre><code>"foo.? bar*" </code></pre> <p>should be ...
<p>no need for incomplete or unreliable hacks. there's a function included with python for this</p> <pre><code>&gt;&gt;&gt; import fnmatch &gt;&gt;&gt; fnmatch.translate( '*.foo' ) '.*\\.foo$' &gt;&gt;&gt; fnmatch.translate( '[a-z]*.txt' ) '[a-z].*\\.txt$' </code></pre>
Is SQL the assembly for databases? <p>Talking about hibernate and others ORMs, the ORMs evangelists talk about SQL like the assembly language for Databases.</p> <p>I think is soon to assert this, but I guess can be true on a near future, not sure.</p> <p><strong>UPDATE:</strong> The analogy I was referring means <em>...
<p>Absolutely not. </p> <p>Assembly language is a very low level language where you instruct the processor exactly what to do, including what registers you want to use etc. </p> <p>SQL is a very high level language where you describe the semantics of what you want, and then a query optimiser decides how to execute it...
Is there an easy way to send SCSI passthrough on OSX using native python <p>On Windows I am able to sent SCSI passthrough to devices using win32file.DeviceIOControl(..), on UN*X I can do it using fnctl.ioctl(...).</p> <p>I have been searching for something equivalent in OSX that would allow me to send the IOCTL comman...
<p>I saw <a href="http://wagerlabs.com/blog/2008/02/04/writing-a-mac-osx-usb-device-driver-that-implements-scsi-pass-through/" rel="nofollow">this blog post</a> recently talking about using SCSI passthrough under OS X. Looks like it isn't as easy as Windows or Unix</p>
Why is Long.valueOf(0).equals(Integer.valueOf(0)) false? <p>This questions is prompted by <a href="http://stackoverflow.com/questions/444638/strange-hashmap-put-behaviour#444757">http://stackoverflow.com/questions/444638/strange-hashmap-put-behaviour#444757</a></p> <p>I think I understand why <code>Map&lt;K,V&gt;.put<...
<p>Here is the source from Long.java</p> <pre><code>public boolean equals(Object obj) { if (obj instanceof Long) { return value == ((Long)obj).longValue(); } return false; } </code></pre> <p>I.e. it needs to be a Long type to be equal. I think the key difference between:</p> <pre><code>long l = ...
Resizing a Webbrowser control hosted by an Explorer Bar in IE <p>I am very new to windows programming so bare with me.</p> <p>I have a custom explorer bar (a band object) that hosts a webbrowser control. I can initialize the WebBrowser control properly and have it display web pages.</p> <p>However, I've noticed that ...
<p>Typically, when a container hosting an OLE control is resized, it queries the embedded object for its IOleInPlaceObject interface, and uses the SetObjectRects() on that interface to tell the control its new size.</p>
CSS two divs next to each other <p>I want to put two <code>&lt;div&gt;</code>s next to each other. The right <code>&lt;div&gt;</code> is about 200px; and the left <code>&lt;div&gt;</code> must fill up the rest of the screen width? How can I do this?</p>
<p>You can use <strong><a href="https://devdocs.io/css/css_flexible_box_layout">flexbox</a></strong> to lay out your items:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>#parent { display: flex; } #narro...
Moving an arbitrary setting to a toolbar in Visual Studio <p>I want to be able to modify a certain setting of Visual Studio right from the toolbar. Specifically, the number of parallel builds (Tools | Options | Projects and Solutions | Build and Run | maximum number of parallel project builds). It can be either an edi...
<p>Write macros which will modify the two settings, then put macro on toolbar using "Cusomtize"</p>
multiple description coding <p>How can I encode an h264 video to be MDC (multiple description coding)</p>
<h1>You can't (but...)</h1> <p>It is not possible today to just check a box on existing software, stream video encoded as <a href="http://en.wikipedia.org/wiki/H264" rel="nofollow">h264</a> MDC, decode it and play it back in a browser. There is no h264 MDC profile. (Without more details of your intent, I am assuming...
C# compiler and caching of local variables <p><strong>EDIT:</strong> Oops - as rightly pointed out, there'd be no way to know whether the constructor for the class in question is sensitive to when or how many times it is called, or whether the object's state is changed during the method, so it would have to be created ...
<p>How should the C# compiler know that it's "the same" dictionary every time? You explicitly create a new dictionary every time. C# does not support static local variables, so you have to use a field. There's nothing wrong with that, even if no other method uses the field.</p> <p>It would be bad if the C# compiler di...
What is the best way to add summary tags to a generated webservice proxy class? <p>Aloha</p> <p>I'm referencing an external webservice in my .NET 2.0 application. Adding a service reference generated a nice proxy class for me. I'd like to add <code>///&lt;summary&gt;</code> style documentation to this. If the service ...
<p>You could create a wrapper class around the generated proxy class, and document the methods there. Then instead of using the generated proxy directly, you always use your wrapper class. E.g:</p> <pre><code>public class MyWebServiceWrapper { private MyWebService _service = null; public MyWebServiceWrapper() {...
How do I replace the contents of an existing XML file in C#.NET? <p>When trying to replace the content of an XML file in C#.NET with a snippet like this:</p> <pre><code>string file = Path.GetTempFileName(); // pretend this is a real file string tmpFile = Path.GetTempFileName(); using (var writer = XmlWriter.Create(Fi...
<p>For some reason the XmlWriter class evidently does not dispose the underlying stream for the temporary file. Putting the stream in a "using" clause of its own makes sure the stream is closed correctly. Changing the code to</p> <pre><code>string file = Path.GetTempFileName(); // pretend this is a real file string tm...
How to detect IIS version using C#? <p>How to detect IIS version using C#?</p> <p>Update: I meant from a winapp (actually the scenario is developing a custom installer that wants to check the version of the installed IIS to call the appropriate api's)</p>
<p>Found the answer here: <a href="http://forums.iis.net/p/1162404/1923867.aspx#1923867">link text</a> The fileVersion method dosesn't work on Windows 2008, the inetserv exe is somewhere else I guess.</p> <pre><code>public Version GetIisVersion() { using (RegistryKey componentsKey = Registry.LocalMachine.OpenSubKe...
DataGridViewComboBoxColumn <p>I have two <code>DataGridViewComboBoxColumn</code> that I add at run time. I need the items of the first <code>DataGridViewComboBoxColumn</code> to stay the same in all the rows of the <code>GridView</code> but I want the items of the second <code>DataGridViewComboBoxColumn</code> to be d...
<p>Recap of your problem:</p> <p>You have a collection of data and want to filter on it.</p> <p>This is a question with the <a href="http://stackoverflow.com/questions/13147049/how-to-apply-a-filter-on-linqtosql-results/13184592#13184592">same problem</a> that extends on this subject a bit more. (To be specific, filt...
Is it possible to define <configSections> in a dependent dll's application config <p>I have a custom .NET addin for an application and I am trying to create configSections for the addin's config file. The trouble is I am not able to read that section If load the configuration using the OpenMapperExeConfiguration/OpenEx...
<p>Configuration settings apply at application (app.config located in the application's root for .EXE, Web root for Web applications) and machine(machine.config located in [System Root]\Microsoft.NET\Framework[CLR Version]\CONFIG) level. </p> <p>The only other config file used is the policy config file which is used t...
How to populate each DataGridViewComboBoxCell with different data? <p>i have two DataGridViewComboBoxColumn that i add at run time i need the items of the first DataGridViewComboBoxColumn to stay the same in all the rows of the gridview but i want the items of the second DataGridViewComboBoxColumn to be different from ...
<p>One option is to change the datasource at cell level for sublocations.</p> <p>Supposing the grid is named <code>grid</code> and the two grid columns were named <code>locationsColumn</code> respectively <code>subLocationsColumn</code>:</p> <pre><code>private void Form1_Load(object sender, EventArgs e) { locatio...
Good way to make a repeating template for data in asp.net <p>I'm building a webpage on which I display the <em>n</em> newest newsposts on the front page, and this is the method that gets the posts and returns them to the .aspx-file. I use a asp:substitution-control to insert the string into the webpage.</p> <p>I think...
<p>If it were me, I would create a user control dedicated to creating a single entry in the listing. The user control would only need one parameter (the post number it's responsible for). The page itself need only maintain an array (or list or whatever structure you would prefer) of these user controls and add them to ...
Is there any defined atom syndication xml schema? <p>Is there any defined atom syndication xml schema?</p>
<p><a href="https://web.archive.org/web/20150307045002/http://www.kbcafe.com/rss/atom.xsd.xml" rel="nofollow">http://www.kbcafe.com/rss/atom.xsd.xml</a> (A Web Archive version since the original is no longer available)</p>
Having to set objectives for developers, even though objectives don't work <p>It is <a href="http://www.joelonsoftware.com/news/20020715.html">generally accepted</a> that <a href="http://www.inc.com/magazine/20081001/how-hard-could-it-be-sins-of-commissions.html">setting measurable objectives</a> for software developer...
<blockquote> <p>what approach has worked best for you?</p> </blockquote> <p>Only one objective: <strong>pass a code inspection/peer review, with me as the reviewer, without me finding any bugs or having any other criticism, that has me asking you to redo something.</strong></p> <p>Notes:</p> <ul> <li>I wasn't meas...
How to submit multiple models on rails using flex? <p>I am trying to submit a create and update request to rails using flex with multiple models. For example, imagine that we have a blog post and multiple comments.</p> <p>The user comes and update the post and some comments, when he clicks on submit I want to send all...
<p>Actually I have it. Forget using those parameters objects and use only XML, its easier than those parameters objects and you can have a single way to serialize your flex objects.</p> <p>Using XML you just need to build it with the objects nested (like rails does for you).</p> <p>The only issue is that you cannot u...
Dealing with variable category hierarchies <p>The issue I have is as follows: My company's supplier gives us an Access database (which I import into SQL Server) containing their product information (the alternative is to use XML), and I'm trying to massage this into a more usable format for use in an e-commerce websit...
<p>If you don't mind using recursive functions to traverse a self-referencing category table, definitely redesign the database to go that route. One would think a recursive function in SQL might be performance suicide, but with proper indexes set up it can complete extremely fast.</p> <p>As for the data set your are w...
best way to show several images on a winform in c# <p>best way to show several images on a winform in c#? Datagrid? </p>
<p>Several <code>PictureBox</code>es :-)</p>
sql server bcp xml data <p>Hi I have a table which has a column which is of type xml. I have to extract data from this table and load the data into another environment. i am using bcp to extract and laod the target table but there are some special characters that is causing some issues when i bcp them into the target t...
<p>A custom CLR-SP provided me with the best solution. Now I can write XML-typed data directly to a file from TSQL, provided the SQL service account has permission to the file. This allows the simple syntax:</p> <pre><code>exec dbo.clr_xml2file @xml, @path, @bool_overwrite </code></pre> <p>The SP:</p> <pre><code>C...
Matching exact string with JavaScript <p>How can I test if a RegEx matches a string <em>exactly</em>?</p> <pre><code>var r = /a/; r.test("a"); // returns true r.test("ba"); // returns true testExact(r, "ba"); // should return false testExact(r, "a"); // should return true </code></pre>
<p>either</p> <pre><code>var r = /^a$/ </code></pre> <p>or</p> <pre><code>function matchExact(r, str) { var match = str.match(r); return match != null &amp;&amp; str == match[0]; } </code></pre>
VB6 ListBox Click and DblClick <p>I have a need to run different code when a user clicks or double-clicks an item in a VB6 ListBox control. When I click on the control, the Click event handler executes. However, I am finding that when I double-click on the control, both the Click and DblClick event handlers execute.</p...
<p>A slight hack, but you could use a Timer control and a boolean variable:</p> <ul> <li>Start the timer on the Click event, set the boolean variable to false</li> <li>Set the boolean variable to true on the DoubleClick event</li> <li>When the timer Tick event fires, check the boolean variable to see if the user did a...
Can I change the input behaviour of a DateTimePicker control? <p>The default input behaviour of the DateTimePicker when entering a date is like this:</p> <p>YYYY(Right Arrow)MM(Right Arrow)DD</p> <p>The user want to enter the date like this:</p> <p>YYYYMMDD</p> <p>Is there any simple way of modifying the input beha...
<p>I don't know how you use the DateTimePicker but what about using a simple editbox? (and validate date when a date is entered)</p> <p>DateTimePicker is mostly used to choose a date without entering any number.</p>
PHP If Date Is >13 Days Ago <p>I'm pulling a row from a database and there is a date field (y-m-d). I need to create an if statement so that I can do something IF that date is longer then 13 days ago. I've already found out how to display all results which are longer then 13 days ago if it is any help.</p> <pre><code>...
<p>In php you can use:</p> <pre><code>$date = '2008-11-05'; if (strtotime("now") &gt; strtotime("+13 days", strtotime($date))) { //Do something } </code></pre>
Rather difficult mySQL problem <p>A friend of mine is having an problem with an big mySQL database and quite a big number of repeating columns over multiple tables.</p> <p>To describe the problem better, the database serves multiple services like FTP, Postfix, webmail, pretty much all the common services you would be...
<p>What you are looking for is called a <a href="http://dev.mysql.com/doc/refman/5.0/en/create-view.html" rel="nofollow">VIEW</a>.</p> <p>That way you can have a central table with all the information an one view per app with the right structure.</p>
How can I modify multicast TCP/IP packets' TTL? <p>I'm supporting a 3rd party app that sends multicast packets with a TTL of 1. We cannot modify the app, but need a higher TTL to route the packets to another customer's network. Is there a network appliance or windows (server 2003) app that will let me modify this? </...
<p>It is doable on the sending host (e.g. using ipfw and divert on FreeBSD; I don't know the equivalent for MS-Windows) but may be more effort than it is worth.</p> <p>An easy option might be to use a VPN (virtual private network) to make it appear to the application layer that the sending and receiving hosts are on t...
What's the recommended workaround if numeric_limits<double>::has_infinity is false? <p>I need to check a double value for infinity in a C++ app on Linux. On most platforms this works by comparing with <code>std::numeric_limits&lt;double&gt;::infinity()</code>. However, on some old platforms (RedHat 9 for example, with ...
<p>If you're using IEEE 754 arithmetic, as you almost certainly are, infinities are well defined values and have defined outcomes for all arithmetic operations. In particular,</p> <pre><code>infinity - infinity = NaN </code></pre> <p>Positive and negative infinity and <code>NaN</code> values are the only values for ...
How can I find all tables cells which only contain a non breaking space with jQuery? <p>I need to only find the cells in the table which contain <code>&amp;nbsp;</code> using jQuery. </p> <pre><code> &lt;table&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;Something&lt;/td&gt; ...
<p>Quick guess, maybe a better way</p> <p>updated - thanks to Tomalak</p> <pre><code>var x = $('table tr td').filter( function(){ return $(this).text() == String.fromCharCode(160); }) </code></pre>
PHP Mail Encodes Subject Line <p>When I try to send a HTML encoded email from PHP, if the subject line contains special chars like <code>"Here's the information you requested"</code>, PHP encodes it to read <code>"Here&amp;#039;s the information you requested."</code></p> <p>How do I fix this?</p> <hr> <p>Here's wha...
<p>Try this:</p> <pre><code> $newsubject='=?UTF-8?B?'.base64_encode($subject).'?='; </code></pre> <p>This way you don't rely on PHP or the MTA's encoding, you do the job, and the mail client should understand it. No special characters will be present in your new subject, so no problems should arise while delivering t...
decrypting pdf protected by aes-256bit using the right password <p>Is there any way to decrypting a pdf protected by an aes-256 bit key?</p> <p>I have the correct password and I need a command-line tool (or library - perhaps in python :P ) for decrypting the file and then doing some operation over it.</p> <p>The best...
<pre><code>import pyPdf pdf = pyPdf.PdfFileReader(open("file.pdf")) pdf.decrypt("password") </code></pre> <p>You can then do whatever you want with the contents. This will work with either the user or owner passwords.</p>
PHP best design practices <p>Ok, have a bunch of questions that I have been thinking about the past few days. Currently I have a site that is just a bunch of PHP files with MySQL statements mixed in with PHP, HTML and CSS, basically a huge mess. I have been tasked with cleaning up the site and have made for myself, the...
<p>Here's an article about how to organize your PHP project, from Rasmus Lerdorf, the architect who created the language:</p> <p><a href="http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html" rel="nofollow">http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html</a></p> <p>D...
Posting contents of a file using HttpClient? <p>I want to send the contents of a file as part of a http request using Apache HttpClient and I could not figure out how to pass on the file contents in the request body.</p>
<p>You didn't specify the format....</p> <p>Most likely, you want to send a POST request, the contents will be <em>multipart/form-data</em> MIME type. This emulates what a browser sends from an &lt;INPUT type="file" ...&gt; form element. This requires some pretty sophisticated parsing on the server side to extract the...
How do I check the exit code in Test::More? <p>According to Test::More <a href="http://search.cpan.org/~mschwern/Test-Simple-0.86/lib/Test/More.pm#EXIT_CODES" rel="nofollow">documentation</a>, it will exit with certain exit codes depending on the out come of your tests. My question is, how do I check these exit codes?<...
<p>Any decent harness program (such as <a href="http://search.cpan.org/~andya/Test-Harness-3.14/bin/prove" rel="nofollow">prove</a>) will do that for you, there is absolutely no reason for you to do that yourself.</p>
Debug multiple copies of a program from one VS instance <p>I have a pre-alpha GUI program that I'm <a href="http://en.wikipedia.org/wiki/Eat_one%27s_own_dog_food">dogfooding</a> and want to run under the debugger (for when things go wrong <code>;)</code> but I don't want to have to launch a new copy of VS for each inst...
<p>You can start an instance of the same, or different projects multiple times in one instance of visual studio. Here is how: Right click on any project in Solution Explorer, go to <strong>Debug</strong> context menu item, and click <strong>Start New Instance</strong>.</p> <p>You can view and manipulate all your runni...
Is there a log4j equivalent for VBScript? <p>I need to instrument a series of .wsf and .vbs files with debug statements; before I go off and roll my own, does something like log4j exist for WSF/VBScript?</p>
<p>Not comparable to log4j, but something you could use to begin with:</p> <p><a href="http://www.naterice.com/blog/template_permalink.asp?id=43" rel="nofollow"><strong>Reusable Logging in VBScript - LogToFile.vbs</strong></a></p> <blockquote> <p>Anywhere you'd like to log a message within the script you'd simply...
Filtering models with ReferenceProperties <p>I'm using google app engine, and am having trouble writing querys to filter ReferenceProperties.</p> <p>eg.</p> <pre><code>class Group(db.Model): name = db.StringProperty(required=True) creator = db.ReferenceProperty(User) class GroupMember(db.Model): group = ...
<p>If your groups are uniquely named, then your "group.name" is a unique identifier of a Group entity.</p> <p>That means you can write:</p> <pre><code> members = models.GroupMember.all().filter( "group =",model.Group.gql("WHERE name=:1", group_name).get() ) </code></pre> <p>though you only need to do that i...
How to Get a List of Assemblies in C#? <p>I need to get a list of assemblies in a directory. Is there another way than this?</p> <pre><code>System.IO.Directory.GetFiles(directory, "*.dll") </code></pre>
<p>Managed assemblies can also be EXEs. And your code just gets files with the extension "dll". Ntive DLLs, which are not assemblies, would also be returned.</p> <p>In the few occasions I needed to do this, I simply got a list of all files (similar to what you've done), and then used Assemby.LoadFrom to attempt to lo...
Represent a query string in JSON <p>I have this Javascript data:</p> <pre><code>[{id:123,type:"test"},{id:154,type:"another"}] </code></pre> <p>How would you transform that into something so that I can pass it as a HTTP post request?</p> <pre><code>menu[0][id] = 123 menu[0][type] = test menu[1][id] = 154 menu[1][typ...
<pre><code>var data = [{id:123,type:"test"},{id:154,type:"another"}]; var params = new Array(); for(var x = 0; x &lt; data.length; x++) { params.push("id=[" + x + "]=" + escape(data[x].id)); params.push("type=[" + x + "]=" + escape(data[x].type)); } alert(params.join("&amp;")); // output: id=[0]=123&amp;type=[0...
Good asp.net documentation tool? <p>Anyone know of a good asp.net website documentation tool? There are a ton of them out there for classes, assembly's, dependencies, etc... but seemingly nothing decent for interface and control documentation</p>
<p>Take a look at <a href="http://www.innovasys.com/products/dx2008/overview.aspx" rel="nofollow">DocumentX</a>. It may offer what you're looking for.</p>
ASP .NET and IIS <p>Most of the developers i work with test their web apps by running them from visual studio, and use the built in web server of VS to display the pages. My question is when these apps are deployed to a IIS server would they behave any differently?</p>
<p>One area where your app may behave differently is in the area of security. Because the built in web server is effectively running under your identity (i.e. you could be running as an admin user), when you deploy into a production environment life for your app may be very different.</p> <p>See this article by <a hre...
How do I append a newline character for all lines except the last one? <p>I'm iterating through a HashMap (see <a href="http://stackoverflow.com/questions/448122/how-do-i-use-a-foreach-loop-in-java-to-loop-through-the-values-in-a-hashmap">my earlier question</a> for more detail) and building a string consisting of the ...
<p>Change your thought process from "append a line break all but the last time" to "prepend a line break all but the first time":</p> <pre><code>boolean first = true; StringBuilder builder = new StringBuilder(); for (Map.Entry&lt;MyClass.Key,String&gt; entry : data.entrySet()) { if (first) { first = false...
Are there any good examples on how to use Haskell monad functions? <p>Haskell monad functions are not easy to understand, where can I find usage examples?</p>
<p>You mean the functions with names like <code>fooM</code> and <code>fooM_</code>? You can understand them better possibly by reading their source code, or when you write a <code>do</code>-expression, you could think if that can be expressed with a relevant <code>fooM</code>-function.</p> <p>You could also take a loo...
Valid binding root for VSS? <p>I'm trying to fix up my Visual Source Safe bindings for a project I have and when I select the location I believe a project should be bound to, i get a dialog that says:</p> <p><code> The folder you chose is not a valid binding root for the projects you have selected. You attempted to re...
<p>I think I figured this one out. I opened my vcproj file and searched for ..\..\.. and found a couple of references to files 5 directories "higher". I removed those references (the files weren't really there) and reopened the project. After doing this, I could rebind the project to SourceSafe.</p>
Generic Exception over webservices <p>I am integrating with MS Dynamics GP WebServices from C# and I am not sure how to handle exception.</p> <p>If I do a GetCustomer with a inexistant ID, the web services return me a "generic" SoapException and the message is "Business object not found." So the only way I see to be s...
<p>Unfortunately both the eConnect API and the GP Web Services both return generic errors, just be glad you don't have to parse the eConnect ones.</p> <p>Good things is, the errors are generally static, so you can build parsers for them. Creating custom exceptions is definitely a good way to do it with this type of we...
Wordpress Category ID vs Eval Issue <p>Ok this is a little complex. I am creating a plugin, and want to find the category ID from the Post page.</p> <p>That's the easy part.</p> <p>What makes it complex is I am doing it within an ob_start (started in a 'template_redirect' action) as I want to edit the full page befor...
<p>Im not partial to eval, but this seems to work, with or without the output buffering at the end ...</p> <pre><code>function tui_findPostThumbIMG() { echo "hey hey\n"; } ob_start(); $categoryID = 10; $tui_cifp_insertvalue = "&lt;?php tui_findPostThumbIMG([categoryID],100,100,'categoryintro-thumbnail','','',''); ?&...
How to Handle Cancelled Recurring Payments <p>I'm using Paypal to handle automated recurring payments for my website. Users pay to subscribe to my website so they can get periodic newsletters.</p> <p>So let's say a customer cancels their membership a few months later. They do this by logging into Paypal and cancels ...
<p>If I understand correctly, Paypal's servers will update yours automatically when the status of a subscription changes, if you have this configured. This is called IPN (Instant Payment Notification) and does indeed include cancellation notification. Here's the <a href="https://cms.paypal.com/us/cgi-bin/?cmd=_render-c...
C# - Locking issues with Mutex <p>I've got a web application that controls which web applications get served traffic from our load balancer. The web application runs on each individual server.</p> <p>It keeps track of the "in or out" state for each application in an object in the ASP.NET application state, and the obj...
<p>You should only be using Mutexes if you need <a href="http://msdn.microsoft.com/en-us/library/ms173179(vs.80).aspx">cross-process synchronization</a>.</p> <blockquote> <p>Although a mutex can be used for intra-process thread synchronization, using Monitor is generally preferred, because monitors were design...
Interpreting assembly code <p>Any assembly interpreters out there?</p> <p>What I'm looking for:</p> <ul> <li>I have some assembly firmware code I want to run, but not on the actual hardware. </li> <li>I would like to run the code and see what it is doing. </li> </ul> <p>So, is there some sort of free and easy to use...
<p>You should look into some processor emulator only that way you can "interpret" assembly, for example: <a href="http://bellard.org/qemu/" rel="nofollow">Qemu</a> or <a href="http://bochs.sourceforge.net/" rel="nofollow">Bochs</a></p>
Keep indentation of wrapped lines in Visual Studio 2008 <p>In Visual Studio 2008, is there a way to keep the indentation of automatically wrapped long lines? (Only need it for C#.)</p> <p>When word wrap is turned on, it looks like this:</p> <pre> var a = SomeFunctionOrWhateverWithSuperLongName(parameter1, par...
<p>Generally, code formatting settings can be changed at <code>Tools -&gt; Options -&gt; Text Editor -&gt; [Your Language] -&gt; Formatting</code>.</p> <p>I believe it's not supported under plain VS. However, some addins might provide this feature.</p>
Highlighting search terms in an MS Word document <p>We have a project where we need to provide search over a collection of Word documents through a web-based interface. The client would like for the search terms to be highlighted when a user opens a document.</p> <p>Is there a way to do this directly in Word when open...
<p>You could do that using Word's Highlight feature. However, to use the feature you will have to use Word automation on either server-side or client-side. </p> <p>A script in VBA for highlighting a search term could look like this:</p> <pre><code>Sub Highlight(oDoc As Word.Document, term As String) With oDoc.Ra...
Using Linq for ObjectDataSource: How to transform datetime using ToShortTimeString? <p>I am accessing a business class using an ObjectDataSource and trying to produce output that makes sense to the user. The return values describe a Class (as in Classroom and teaching, not software). I would like to show the time of ...
<p>The reason is the query is being used in LINQ to SQL. LINQ to SQL treats queries as expression trees. It has mappings defined for some methods (for instance, <code>Contains</code>) but since it doesn't really execute them, it can't work on arbitrary methods. It parses the query and submits it to SQL server. The equi...
Makefile variable assignment <p>Can anybody give a clear explanation of how variable assignment really works in Makefiles. </p> <p>What is the difference between :</p> <pre><code> VARIABLE = value VARIABLE ?= value VARIABLE := value VARIABLE += value </code></pre> <p>I have read the <a href="http://www.gnu.org/so...
<h3>Lazy Set</h3> <pre><code>VARIABLE = value </code></pre> <p>Normal setting of a variable - values within it are recursively expanded when the variable is used, not when it's declared</p> <h3>Immediate Set</h3> <pre><code>VARIABLE := value </code></pre> <p>Setting of a variable with simple expansion of the value...
Winform Checklistbox Headers/Columns <p>Is there a way to implement a new column with a header in a checklistbox in vb.net? I've done a bit of searching, but didn't find much on the topic. Should I just abandon the quest and use a listview or some other control?</p> <p>Thanks for any/all help! JFV</p>
<p>I would suggest using a ListView with a checkbox column. You'll have better luck.</p>
How should a list be represented in XML? <p>In XML, how should a list be represented?</p> <p>With an enclosing list entity:</p> <pre><code>&lt;person&gt; &lt;firstname&gt;Joe&lt;/firstname&gt; &lt;lastname&gt;Bloggs&lt;/lastname&gt; &lt;children&gt; &lt;child .../&gt; &lt;child .../&gt; ...
<p>I would enclose it in an entity to distinguish it from the other elements.</p>
Reference generated primary key in SQL script <p>I'm trying to create a bunch of entries in a database with a single script and the problem I'm encountering is how to reference the generated primary key of the previous entry I created.</p> <p>For example if I created a customer, then tried to create an order for that ...
<p>Like so:</p> <pre><code>DECLARE @customerid int; INSERT INTO customers(name) VALUES('Spencer'); SET @customerid = @@IDENTITY; </code></pre> <p><strong>EDIT:</strong></p> <p>Apparently it needs to be SCOPE_IDENTITY() in order to function as expected with triggers.</p> <pre><code>DECLARE @customerid int; INSERT IN...
How do I project lines dynamically on to 3D terrain? <p>I'm working on a game in XNA for Xbox 360. The game has 3D terrain with a collection of static objects that are connected by a graph of links. I want to draw the links connecting the objects as lines projected on to the terrain. I also want to be able to change...
<p>Your 1) is a fairly good solution. You can reduce the jagginess by filtering -- first, make sure to use bilinear sampling when using the overlay. Then, try blurring the overlay after drawing it but before using it; if you choose a proper filter, it will remove the aliasing.</p> <p>If it's taking too much time to ...
Is it "better" to have an update field or COUNT query? <p>In a Django App I'm working on I've got this going on:</p> <pre><code>class Parent(models.Model): name = models.CharField(...) def num_children(self): return Children.objects.filter(parent=self).count() def avg_child_rating(self): ...
<p>Depends on the scale of the problem. If you anticipate a lot of write traffic, this might be an issue. It's much harder to scale writes than reads (replicate, caching etc.) That said, you can probably going a long way without this extra query causing you any problems.</p> <p>Depending on how up-to-date your stats m...
How to programmatically set every other column in a worksheet in Interop <p>Using Excel Interop (.NET) how can we set programmatically two different Excel formulas for every other column. For instance, </p> <pre><code>Range r = _sheet.get_Range(_sheet.Cells[1, 1], _sheet.Cells[I, J]) r.Formula = "=something1" </code...
<p>First, you create a function to define a range as every other column, a <a href="http://excel.bigresource.com/Track-excel-J1w0Pbug/" rel="nofollow">variant of this</a> (VBA):</p> <pre><code>Sub EveryOtherColumn() Dim rangeString As String Dim columnLetter As String Dim i As Long Dim firstCol, lastCol ...
CSS Copy and paste problem <p>I've developed a system in my application where emails are picked up with a regex, and then reversed in the source (to thwart bots). I then add the span class 'obfuscate email'. I then use CSS to reverse the the text back to be displayed and Javascript make sure that <code>mailto:</code> l...
<p>You can use the same Javascript to reverse the text as well as the mailto links. If the user doesn't have Javascript, then you can either settle for this problem or use an image.</p>
Most Efficient way to access schema with ODBC and OleDB <p>I am making a DAL template with C# and I am wondering what is the most efficient way to access schema information with ODBC and OleDB. I need the columns, column types, and primary key information.</p> <p>thanks</p>
<p>For OleDb, there is an OleDbConnection.GetoleDbSchemaTable() method. I've used it with Access.</p> <p>I have an example in this code on GitHub: <a href="http://github.com/rally25rs/storm/blob/053947d25ab5d789bf3f33302cf3e4aaf4ea08bf/StormOleDbSupport/DataBinders/OleDb/Validation/SchemaValidator.cs" rel="nofollow">S...
Programmatically binding List to ListBox <p>Lets say for instance i have the following extremely simple window:</p> <pre><code>&lt;Window x:Class="CalendarGenerator.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Windo...
<p>First you'd need to give your ListBox a name so that it's accessible from your code behind (<em>edit</em> I note you've already done this, so I'll change my example ListBox's name to reflect yours):</p> <pre><code>&lt;ListBox x:Name="eventList" ... /&gt; </code></pre> <p>Then it's as simple as setting the ListBox'...
variable button vb.net <p>i declared a global variable button:</p> <p>Dim button1 As New Button()</p> <p>Now, i dont know how to add a click event in this button since it is a variable. Do you have any idea how do i do it?</p>
<p><code>AddHandler button1.click, AddressOf MyClickEventHandler</code> (<a href="http://msdn.microsoft.com/en-us/library/6yyk8z93(VS.71).aspx" rel="nofollow">MSDN Documentation</a>)</p> <p>You have to make sure <code>MyClickEventHandler</code> is defined with the same signature as any other Click event handler (i.e. ...
How do I determine the size of an object in Python? <p>In C, we can find the size of an <code>int</code>, <code>char</code>, etc. I want to know how to get size of objects like a string, integer, etc. in Python.</p> <p>Related question: <a href="http://stackoverflow.com/questions/135664/how-many-bytes-per-element-are-...
<p>Just use the <a href="http://docs.python.org/library/sys.html#sys.getsizeof">sys.getsizeof</a> function defined in the <code>sys</code> module.</p> <blockquote> <p><code>sys.getsizeof(object[, default])</code>:</p> <p>Return the size of an object in bytes. The object can be any type of object. All built-...
Webbased MySQL interface better that phpMyAdmin <p>Is there any webbased interface for MySQL better than phpMyAdmin? I use phpMyAdmin a lot but it is becoming a pain, especially it is slow sometimes. </p> <p>I'd like to have deep export functionality like phpMyAdmin but more design features</p>
<p>Why don't you just use a client? They are a lot nicer in my opinion.</p> <p>I love <a href="http://www.webyog.com" rel="nofollow">SQLyog</a> because it supports a lot of MySQL features (stored procedures) but I used to use HeidiSQL and it was nice as well.</p> <p>As for web based clients, I haven't got any suggest...
What is the difference between DoS and Brute Force attacks? <p>I was reading about DoS attacks on Apache servers but the "Brute Force" word pops up sometimes I know DoS attacks but "Brute Force" seems to be similar, is there a difference or it is just another word of DoS?</p>
<p><strong>Brute force</strong> attacks use a technique of attempting to try every combination of passwords/keys to gain access to a particular system. What the hacker does when they gain entry to the system depends on the motivation of the hacker.</p> <p><strong>DoS (Denial of Service)</strong> attacks describe case...
How can I monkey-patch an instance method in Perl? <p>I'm trying to monkey-patch (duck-punch :-) a <code>LWP::UserAgent</code> instance, like so:</p> <pre><code>sub _user_agent_get_basic_credentials_patch { return ($username, $password); } my $agent = LWP::UserAgent-&gt;new(); $agent-&gt;get_basic_credentials = _us...
<p>As answered by <a href="http://stackoverflow.com/users/55276/fayland-lam">Fayland Lam</a>, the correct syntax is:</p> <pre><code> local *LWP::UserAgent::get_basic_credentials = sub { return ( $username, $password ); }; </code></pre> <p>But this is patching (dynamically scoped) the whole class and no...
Error: The object cannot be deleted because it was not found in the ObjectStateManager <p>Trying to get a handle on Entity Framework here and I am hitting some speed bumps... I have a Get() method that works fine and has been tested, but my Delete method is not working:</p> <pre><code> public static void Delete(stri...
<p>Each EF object is tightly associated to the manager (for want of a better word) that created it. or to which it has been associated. Since you don't pass <code>db</code> to your <code>Get</code> method, I assume that <code>Get</code> has either used it's own <code>J1Entities</code>, or the object has been created st...
Dividing workload on several threads <p>I was wondering if anyone knows about a good article which describes dividing workload on to several Threads? Preferebly it would be written for C# but it's really the concept I'm after, so it's not an issue if it's written for a different, similar, language.</p> <p>I have a pro...
<p>You should look at Parallel FX (PFX), you can find the blog <a href="http://blogs.msdn.com/pfxteam/" rel="nofollow">here</a> and the download link <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=348F73FD-593D-4B3C-B055-694C50D2B0F3" rel="nofollow">here</a> (Thanks Marc).</p> <p>Unfortunately I don...
About mobile game porting <p>I would like to ask a few questions regarding mobile game porting...</p> <p>Let say if I have a simple 2D C++ game engine and have a PC game based on that engine and I want to port it to different mobile platforms BREW, J2ME, iPhone, Android, Symbian, etc..</p> <p>Do I need to re-code the...
<p>There are several ways of attacking mobile game porting. First of all, until very recently it was mostly BREW and J2ME. The iPhone, Android and BlackBerry are changing this landscape and making the impossible task of mobile game porting even more impossible. I worked in 3rd party mobile game development for man...
Recommended JavaScript HTML template library for JQuery? <p>Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time.</p>
<p>Well, to be frank, client-side templating is very hot nowadays, but quite a jungle.</p> <p>the most popular are, I believe: </p> <ul> <li><a href="http://beebole.com/pure/">pure</a>: It use only js, not his own "syntax"</li> <li><a href="http://mustache.github.com/">mustache</a>: quite stable and nice I heard.</li...
How do i combine a list and a form in the same page using django? <p>Am building a Q&amp;A page, sort of stackoverflow kinda page! Am having a bit of a problem trying to render the form. Am pasing 3 objects to the template that renders the page i.e. Question object, Answers related to the question and Answer form objec...
<p>Tricky to answer without seeing some code, but I suspect it's something to do with the way you are using {{ extends }} and inheriting/over-riding {{ block }} sections.</p> <p>I would check the names of all your {{ block }} sections, and that you are over-riding the blocks that you think you are. It may be that you ...
Communicating with the web through a C# app? <p>Although i can grasp the concepts of the .Net framework and windows apps, i want to create an app that will involve me simulating website clicks and getting data/response times from that page. I have not had any experience with web yet as im only a junior, could someone e...
<p>what do you want to do?</p> <p>send a request and grab the response in a String so you can process?</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx">HttpWebRequest</a> and <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.aspx">HttpWebResponse</a> wi...
Is there already some std::vector based set/map implementation? <p>For small sets or maps, it's usually much faster to just use a sorted vector, instead of the tree-based <code>set</code>/<code>map</code> - especially for something like 5-10 elements. LLVM has some classes <a href="http://llvm.org/docs/ProgrammersManua...
<p>I just stumbled upon your question, hope its not too late.</p> <p>I recommend a great (open source) library named <a href="http://loki-lib.sourceforge.net/" rel="nofollow">Loki</a>. It has a vector based implementation of an associative container that is a drop-in replacement for std::map, called <a href="https://g...
Running Cruise Control .NET as a Service <p>I've been configuring and testing CCNet for a little while now using Virtual PC to host it. Everything went well and it was decided to transfer the configuration to a server location - which went as well as could be expected. A few tweaks and kicks and i had it running as bef...
<p>Hmmm - I may have answered my own question here (or not, only time will tell).</p> <p>For some reason CCNet does not appear to be using the credential in the config file (don't know why). When it calls SVN it waits for a password to be entered, even if the user cannot see it, and then times out when it doesn't get ...
How to copy a recursive directory structure in TFS Team Build? <p>Is it possible to copy a directory in a team build target?</p>
<pre><code>&lt;Copy SourceFiles="@(SourceItemGroup)" DestinationFolder="$(YourDir\SubDir\%(RecursiveDir)" /&gt; </code></pre>
How do you achieve field level security in ASP.Net? <p>I have an .aspx form with 20 fields that must be disable based on a users role and a status of a order record. Currently the application has 5 roles and 3 status, so I have 300 different possible conditions that I have to account for. </p> <p>My first thought is ...
<p>I'd probably store the details of each field, and then the roles and status that can edit them, and do it that way.</p> <p>What are the rules for the system? Basically, are there really 300 possible conditions? Or is that really certain fields are only editable for certain status, and then only certain roles can ed...
A priority queue which allows efficient priority update? <p><strong>UPDATE</strong>: Here's <a href="http://tinyurl.com/7zgwb4">my implementation of Hashed Timing Wheels</a>. Please let me know if you have an idea to improve the performance and concurrency. (20-Jan-2009)</p> <pre><code>// Sample usage: public static ...
<p>How about trying to separate the handing of the normal case where things complete quickly from the error cases?</p> <p>Use both a hash table and a priority queue. When a task is started it gets put in the hash table and if it finishes quickly it gets removed in O(1) time.</p> <p>Every one second you scan the hash...
How to check if a file can be created inside given directory on MS XP/Vista? <p>I have a code that creates file(s) in user-specified directory. User can point to a directory in which he can't create files, but he can rename it.</p> <p>I have created directory for test purposes, let's call it <code>C:\foo</code>. </p>...
<p>I wouldn't waste time and LOCs on checking for permissions. Ultimate test of file creation in Windows is the creation itself. Other factors may come into play (such as existing files (or worse, folders) with the same name, disk space, background processes. These conditions can even change between the time you make t...
Python Path <p>I am installing active python, django. I really dont know how to set the python path in vista environment system. first of all will it work in vista.</p>
<h1>Temporary Change</h1> <p>To change the python path temporarily (i.e., for one interactive session), just append to <code>sys.path</code> like this:</p> <pre><code>&gt;&gt;&gt; import sys &gt;&gt;&gt; sys.path ['', 'C:\\Program Files\\PyScripter\\Lib\\rpyc.zip', 'C:\\Windows\\system32\\python27.zip', 'C:\\Pytho...
How to unit-test a file writing method with Visual Studio's built-in automated tests? <ol> <li><p>I use Visual Studio 2008 Professional automated tests. I have a function that writes to a file. I want to unit test the file writing function. I have read somewhere that I would have to mock a file somehow. I don't know ho...
<p>If the method has to open the file stream itself, then that's hard to mock. However, if you can pass a stream into the method, and make it write to that, then you can pass in a MemoryStream instead. An alternative overload can take fewer parameters, open the file and pass a FileStream to the other method.</p> <p>Th...
Login to the page with HttpWebRequest <p>How can I login to the this page <a href="http://www.bhmobile.ba/portal/index">http://www.bhmobile.ba/portal/index</a> by using HttpWebRequest? </p> <p>Login button is "Pošalji" (upper left corner).</p> <h3>HTML source of login page:</h3> <pre><code>&lt;table id="maintable" ...
<p>Make a new default.aspx, and put this in the code behind: I cant test any further based on your current question, because you didn't include a valid username/password.</p> <pre><code> using System; using System.Web; using System.Net; using System.IO; using System.Web.UI; using System.Web.UI...
Why is modulus different in different programming languages? <p>Perl</p> <pre><code>print 2 % -18; </code></pre> <p>--></p> <pre><code>-16 </code></pre> <p>Tcl</p> <pre><code>puts [expr {2 % -18}] </code></pre> <p>--></p> <pre><code>-16 </code></pre> <p>but VBScript</p> <pre><code>wscript.echo 2 mod -18 </code...
<p>The <a href="http://en.wikipedia.org/wiki/Modulo_operation">wikipedia answer</a> is fairly helpful here.</p> <p>A short summary is that any integer can be defined as </p> <p>a = qn + r </p> <p>where all of these letters are integers, and </p> <p>0 &lt;= |r| &lt; |n|. </p> <p>Almost every programming language wi...
Best way to build a search function <p>I have a website that has over 400,000 items. Some similar, some vastly different. We want to provide a way to search these items the best way possible. After being delivered the website it was using full text indexing. The solution is basic at best, woefully inadequate at wor...
<p>Look at <a href="http://lucenenet.apache.org/" rel="nofollow">Lucene.NET</a>. I think it's a vast improvement over full-text search in SQL Server.</p>
What do < and > mean such as implements Comparable<BigInteger>? <p>In Java 1.4.2, class <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html" rel="nofollow">java.math.BigInteger</a> implements interfaces Comparable, Serializable.</p> <p>In Java 1.5.0, class <a href="http://java.sun.com/j2se/1.5.0...
<p>Read the <a href="http://java.sun.com/docs/books/tutorial/java/generics/index.html" rel="nofollow">Java Generics Tutorial</a>. The thing between the angle brackets is a type parameter - Comparable is a generic class, and in this case the angle brackets mean that the class is comparable to other BigIntegers.</p> <p...
Only create a TFS work item on a new failed build <p>I've seen the post about disabling work item creation on all failed builds, but I'd like to have TFS only create a work item on the first failure. We have a very complicated legacy system that involves VB6 COM components and frequently have build failures on the bui...
<p>How would you determine that the second failed build was related to the first one, since there's an additional check-in involved? What happens if the next check-in is actually additional code committed by another developer - you'd want them to know their code broke the build, or that it's still broken, even though a...
Change the ruby process name in top <p>I would like to change the name of the ruby process that gets displayed in the linux/unix top command. I have tried the </p> <pre><code>$0='miname' </code></pre> <p>approach but it only works with the ps command and in top the process keeps getting displayed as "ruby"</p>
<p>Dave Thomas had an interesting <a href="http://pragdave.blogs.pragprog.com/pragdave/2008/11/trivial-request-logging-for-rails.html">post</a> on doing this in rails. There's nothing rails specific about the actual process name change code. He uses the <code>$0='name'</code> approach. When I followed his steps the ...
Visual C++ 2005 hangs during qt builds <p>At my shop, the main product app is a mongrel built on MFC, QT and other random things devs have thrown in over the years. In the current stack, Qt toolkit is on the way out, but still features heavily.</p> <p>If I have SQL 2005 Management studio open and have to do a full bui...
<p>In my experience, some of these tools are capable of looping forever (qt4: lupdate/lrelease for sure).</p>
ASP.NET MVC Standard Link/Href As Save Button And Model IS NUll <p>Okay so, i am totally new to MVC and I'm trying to wrap my head around a few of the concepts. I've created a small application...</p> <p>This application has a view for creating a new Individual record. The view is bound to a model <strong>ViewPage</st...
<p>Your New controller method doesn't need to create an individual, you probably just want it to set the title and return the view, although you may need to do some authorization processing. Here's an example from one of my projects:</p> <pre><code> [AcceptVerbs( HttpVerbs.Get )] [Authorization( Roles = "Super...
Can the DllMain of an .exe be called? <p>My question is not exactly the same as <a href="http://stackoverflow.com/questions/186502/dllmain-in-an-exe">this one</a> (it's not theoretical, there is only a main thread without message loop, InitInstance and ExitInstance are no fitting calls).</p> <p>I'm using a console app...
<p>The most obvious condition is that the process calling LoadLibrary() explicitly gets GetProcAddress("DllMain") and then calls it.</p>
PHP Get Source and Search for Word <p>I need help i want to code a program that search for a word inside the source code. </p> <p>Here a Example in Python: </p> <pre><code>import urllib2, re site = "http://stackoverflow.com/" tosearch = "Questions" source = urllib2.urlopen(site).read() if re.search(tosearch,source):...
<pre><code>&lt;?php $site = "http://stackoverflow.com/"; $tosearch = "Questions"; $source = file_get_contents($site); if(preg_match("/{$tosearch}/", $source)): // fixed, thanks meouw echo "Found the the word {$tosearch}"; endif; ?&gt; </code></pre>
C#: Generic sorted container that can return the sorted position of a newly added object? <p>I need a generic container that keeps its elements sorted and can be asked where (at which position) it would insert a new element, without actually inserting it.</p> <p>Does such a container exist in the .NET libraries? The b...
<p>If you sort a <a href="http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx" rel="nofollow"><code>List&lt;T&gt;</code></a> and then use <a href="http://msdn.microsoft.com/en-us/library/3f90y839.aspx" rel="nofollow"><code>List&lt;T&gt;.BinarySearch</code></a> it will give you the index of the entry if it exists, or ...
Going beyond the iframe <p>Hey! I am trying to get an iframe B communicate with site A. I've searched and searched and every thing I read says it's impossible if they are of different domain (the iframe src is coming from a sub domain).</p> <p>I want to communicate because my company has ads on its page and it needs ...
<p>If you want the two iframes to communicate and you say one is on a different subdomain but the <strong>same top-level domain</strong>, you can do inter-frame scripting. See <a href="http://ajaxian.com/archives/how-to-make-xmlhttprequest-calls-to-another-server-in-your-domain" rel="nofollow">http://ajaxian.com/archiv...
SQL nvl equivalent - without if/case statements & isnull & coalesce <p>Are there any nvl() equivalent functions in SQL?</p> <p>Or something close enough to be used in the same way in certain scenarios?</p> <p><hr> UPDATE: <br>no if statements<br>no case statements<br>no isnull<br>no coalesce<hr><br></p> <pre><code>s...
<p><a href="http://msdn.microsoft.com/en-us/library/ms184325.aspx">ISNULL</a> (for a single replace)</p> <p>or</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms190349.aspx">COALESCE</a> (Returns the first nonnull expression among its arguments.)</p>
Can I fill in an encypted PDF with iTextSharp? <p>I have a fillable, saveable PDF file that has an owner password (that I don't have access to). I can fill it out in Adobe reader, export the FDF file, modify the FDF file, and then import it. </p> <p>Then I tried to do it with iText(Sharp). I can't create a PdfStamper ...
<p>[I found this question several months after it was posted and I'm posting this solution now for anyone who comes across this question in a search.]</p> <p>I was in the exact same situation: my customer had a PDF with fillable fields that I needed to programmatically access. Unfortunately the PDF was password prote...