input
stringlengths
51
42.3k
output
stringlengths
18
55k
How do I ORDER BY an arithmetic express in SQLAlchemy? <p>How do I translate something like this into SQLAlchemy?</p> <pre><code>SELECT (a * b) - (x + y) / z AS result FROM table ORDER BY result </code></pre>
<p>Just pass the label in as a string argument to <code>order_by</code>:</p> <pre><code>result_exp = sqlalchemy.sql.expression.label('result', ((test2_table.c.a * test2_table.c.b) - (test2_table.c.x + test2_table.c.y) / test2_table.c.z)) select([result_exp], from_obj=[test2_table], order_by="result") </code...
How to debug COM object in Visual Studio 6.0 that is created in an ASP page? <p>I have an old C++ COM component which has to stay in Visual Studio 6.0 format. I can't for the life of me figure out how to debug the code in the actual COM component.</p> <p>I'm able to build it in debug mode, add breakpoints and attach ...
<p>If it is a VB6 based COM component, you can open the project in VB6 and run it (a DLL project cannot be run). The project properties has some option whereby it can be asked to run so that it runs &amp; registers itself.</p> <p>Now, try hitting the ASP page, which makes a call to COM component. The breakpoints set i...
Java get JPanel Components <p>I have a JPanel full of JTextFields...</p> <pre><code>for (int i=0; i&lt;maxPoints; i++) { JTextField textField = new JTextField(); points.add(textField); } </code></pre> <p>How do I later get the JTextFields in that JPanel? Like if I want their values with </p> <pre><code>Text...
<p>Well bear in mind they didn't get there by them selves ( I think a read some questions about dynamically creating these panels at runtime ) </p> <p>In the answers posted there, someone said you should kept reference to those textfields in an array. That's exactly what you need here:</p> <pre><code>List&lt;JTextFie...
in SQL, or Django ORM, what's the conventional way to have an ordered one-to-many? <p>Say I wanted to have a project, and one-to-many with to-do items, and wanted to re-order the to-do items arbitrarily? </p> <p>In the past, I've added a numbered order field, and when someone wants to change the order, had to update a...
<p>I hate this problem ... and I run into it all the time.</p> <p>For my most recent Django site we had a Newsletter which contained N Articles and, of course, order was important. I assigned the default order as ascending Article.id, but this failed if Articles were entered in something other than "correct" order.</p...
HTTP 403 Error while accessing web service <p>Im trying to access a web service from a remote computer. I managed to access the web service from the browser. But Im getting HTTP 403 when I try to call the web service from the application.</p> <p>Any idea why?</p>
<p>A <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4" rel="nofollow">403</a> response indicates that the host or software you're connecting with isn't allowed to access the web service. Reasons for this might be:</p> <ul> <li>The remote host you are is being blocked by a firewall</li> <li>You...
Inheriting from ViewPage <p>Is it possible to inherit from both ViewPage and ViewPage&lt;T&gt;?? Or do I have to implement both. Currently this is what I have for ViewPage. Do i need to repeat myself and do the same for ViewPage&lt;T&gt;??</p> <pre><code> public class BaseViewPage : ViewPage { public bo...
<p>Create both versions:</p> <pre><code>public class BaseViewPage : ViewPage { // put your custom code here } public class BaseViewPage&lt;TModel&gt; : BaseViewPage where TModel : class { // code borrowed from MVC source private ViewDataDictionary&lt;TModel&gt; _viewData; [System.Diagnostics.CodeAn...
How to stop Gmail from marking mails sent by my web app as spam? <p>I have a simple web application that provides daily financial data. Users subscribe, and we send them an email every day. However, Gmail is marking all of our emails as spam. What should we be looking out for?</p>
<p>Chiefly, to avoid a spam engine classifying your messages as spam you should:</p> <ul> <li>Make sure they aren't spam (i.e. ensure that only users who have really opted in get mailed - make sure you keep an opt-in audit log)</li> <li>Make sure they don't look too much like spam - $$$ MAKE MONEY FAST is not a good s...
Differences between Python game libraries Pygame and Pyglet? <p>I've had some experience with Pygame, but there seems to be a lot of buzz around Pyglet these days.</p> <p>How do these two libraries compare? What would be the advantage of using one over the other, both in features and ease of use?</p> <p>Finally, woul...
<p><strong>Pygame: LGPL license</strong></p> <p><em>Pyglet: BSD license</em></p> <p><strong>Pygame relies on SDL libraries heavily</strong></p> <p><em>Pyglet is a pure python library with fewer dependencies, I think it requires better understanding of OpenGL</em></p> <p><strong>Pygame is around here for a long time...
Java 6 JVM Hang <p>Apologies for the long post, but I wonder if I could get some more eyeballs on this before I submit a bug report to Sun.</p> <p>JVM: 6u11<br> O/S: Windows XP SP3<br> Hardware: AMD Athlon 64 X2 4600+ @ 2.41GHz, with 3.25 GB RAM.</p> <p>I believe I have encountered a fault in the JVM where no thread ...
<p>The provided thread trace is complete with respect to the lock in question. Two other people I work with agree that a JVM fault is clearly indicated, as do the programmers at jProfiler (ej-technologies).</p>
Proper Memory allocation <p>I have the following construction:</p> <pre><code>typedef struct bucket { char *key; ENTRY *data; struct bucket *next; } bucket; typedef struct { size_t size; bucket **table; } hash_table; </code></pre> <p>But I have no idea how to allocate memory for that. I tried: </...
<p>It doesn't make sense to allocate all 101 (or however many) buckets upfront, you'd typically allocate them one at a time, when inserting new data into the table.</p> <p>It <em>does</em> make sense to pre-allocate the hash array, which will have a fixed size, but that is an <em>array of bucket pointers</em>, not an ...
Runtime error 1004: Application-defined or object-defined error <p>I've been having a major issue... well maybe not major, but I've been trying to figure this out since yesterday lunchtime.<br /> I have the following code:</p> <pre><code>Application.CutCopyMode = False ActiveWorkbook.PivotCaches.Add(SourceType:=xlData...
<p>Fixed it (earlier, Remou pointed out that posting the answer is a good thing).<br /> I messed up a bit.</p> <p>My data was dynamic, on every reload another set. In my testing set, everything went awesomely fine. Then, as I loaded a new set, values changed, labels were added, others were left out... one of my pivot ...
How do I programmatically check an item in a checkedlistbox in c# <p>I have a checkedlistbox and I want to automatically tick one of the items in it. </p> <p>The CheckedItems collection doesn't allow you to add things to it.</p> <p>Any suggestions?</p>
<p>You need to call <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.checkedlistbox.setitemchecked.aspx">SetItemChecked</a> with the relevant item.</p> <p>The <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.checkedlistbox.objectcollection.aspx">documentation for CheckedListBo...
JSON object for just an integer <p>Silly question, but I'm unable to figure out..</p> <p>I tried the following in Ruby:</p> <pre><code>irb(main):020:0&gt; JSON.load('[1,2,3]').class =&gt; Array </code></pre> <p>This seems to work. While neither</p> <pre><code>JSON.load('1').class </code></pre> <p>nor this </p> <p...
<p>I'd ask the guys who programmed the library. AFAIK, <code>1</code> isn't a valid JSON object, and neither is <code>{1}</code> but <code>1</code> is what the library itself generates for the fixnum 1.</p> <p>You'd need to do: <code>{"number" : 1}</code> to be valid json. The bug is that</p> <pre><code>a != JSON.par...
How load a PHP page in the same window in jQuery <p>I have a PHP file, Test.php, and it has two functions:</p> <pre><code>&lt;?php echo displayInfo(); echo displayDetails(); ?&gt; </code></pre> <p>JavaScript:</p> <pre><code>&lt;html&gt; ... &lt;script type="text/javascript"&gt; $.ajax({ ...
<p>If I understand correctly, you'd like for the <code>a</code> link to cancel navigation, but fire the AJAX function?</p> <p>In that case:</p> <pre><code>$("#mylink").click(function() { $.ajax({ type: "POST", url: "another.php", data: {id: "somedata"}, function(data) { $("#response").html(data); }); return fals...
How to access an Access database using JavaScript? <p>I have to display marks of my students through my site. The database is created using <a href="http://en.wikipedia.org/wiki/Microsoft_Access" rel="nofollow">Microsoft Access</a>. How can I display the marks of each student in a table, as they enter the registration ...
<p>Why do you want to use Javascript? It runs in the browser of the site's visitors, and even if there were a way to have it directly access a database (which there isn't), it would be a horrible security risk, since it would have to contain the DB password, so that each visitor of the site could get full access to the...
How to go to main stack <p>I am using alternate stack to handle signals for program in C over linux. When stack overflow occurs, my signal are delivered on to my alternate signal stack not on the main stack.</p> <p>So in this situation I want to dump the <strong>main</strong> stack.... how can I ?</p>
<p>remember the top stack address in main (&amp; of some local variable in that stack frame), and dump from the exception address to that. Be aware, that there are some portability issues (stack grows upward on hp-pa-risc, for example). If the failure was not due to an access into the protected area below the overflowi...
internal constructor <p>Yesterday I thought it would be nice to implement my own Trigger in a WPF app. I created a class MyTrigger which inherited TriggerBase. TriggerBase is a public abstract class. So inheritance isn't a problem. But the constructors inside this class are marked internal. The compiler throws an error...
<p>If you want the class to be visible, but only allow it to be subclassed within your own assembly. The subclasses may have public constuctors themselves - or they may be accessed with a factory.</p> <p>I can't comment on whether that's a good design decision for TriggerBase in WPF, but it's at least reasonable in so...
Visual Studio 2005 -> 2008/10 Service Installer Project Upgrade issue <p>I've upgraded a [.vdproj MSI generator project built into VS2008] System.Configuration.Install.Installer with a <code>ServiceProcessInstaller</code> and a <code>ServiceInstaller</code> from Visual Studio 2005 to 2008. There are no customisations o...
<p>This should answer your question</p> <p><a href="http://stackoverflow.com/questions/451573/how-do-i-eliminate-the-specified-service-already-exists-when-i-install-new-versio/617385">http://stackoverflow.com/questions/451573/how-do-i-eliminate-the-specified-service-already-exists-when-i-install-new-versio/617385</a><...
Auto Install activeX <p>I'm a web developer and my current task is to build an ActiveX component. </p> <p>It's the first time I have to work with ActiveX and I managed to make an working example.</p> <p>However I cannot make the ActiveX install from a browser. When installing it using visual studio 2008 and running t...
<p>You might want to check your IE security settings: By default, unsigned ActiveX controls are ignored.</p> <p>Here's another possibility:</p> <p>Did you mark your control as "Safe for scripting" and "safe for initialization"?</p> <p>I'm not sure this is the issue you're running into since 1) your sample HTML code ...
is it possible to set per-file options for Nedit like you can do for emacs/vim <p>With VIM or Emacs I can put comments in the file that will be VIM's settings for that file:</p> <p><code></p> <pre> /* * Local Variables: * mode: C * c-basic-offset: 4 * c-indentation-style: linux * indent-tabs-mode: nil * de...
<p>The short answer is, sadly, no.</p> <p>The longer answer is (as I'm sure you're aware) yes if you wrap the call to nedit in a shell script. The script would need to look at the head of the file you're trying to open for information concerning settings. You could then spit this information out to a file and use the ...
How to create a file without a Command Prompt window <p>I'm using WinRAR SFX module to create an installation, and use its presetup option to run some preliminary tests.</p> <p>Since wscript can only accept vbs file, and not the script itself, I first run "cmd /c echo {...script code...} > setup.vbs", and then I run "...
<p>Is the script code already in a file? If so,</p> <p>You can use the TYPE command to send the script to a file:</p> <pre><code>TYPE [script_file] &gt; setup.vbs </code></pre> <p>or COPY the script file:</p> <pre><code>COPY [script_file] setup.vbs </code></pre> <p>If the script code is in the body of your <code>c...
Use type of object in HQL where clause <p>In my domain model I have an abstract class CommunicationChannelSpecification, which has child classes like FTPChannelSpecification, EMailChannelSpecification and WebserviceChannelSpecification. Now I want to create an HQL query which contains a where clause that narrows down t...
<p>Not positive in NHibernate, but in Hibernate, there are two special properties that are always referenced id and class. So, for your particular case, I'd do</p> <pre><code>from CommunicationChannelSpecifications spec where spec.class in (?) </code></pre>
loadVideoById() in YouTube's regular player (not chromeless) <p>I have a YouTube's player in the webpage. I need to change the video played by this player dynamicaly.</p> <p>This is (relatively) easy using YouTube's chromeless player. It has method <a href="http://code.google.com/apis/youtube/chromeless_player_referen...
<p>You can not do that, cause the calls in the "regular youtube player" have the VideoID in the URL instead as a parameter:</p> <ul> <li>Regular Video: <a href="http://www.youtube.com/v/VIDEO_ID&amp;enablejsapi=1&amp;playerapiid=ytplayer">http://www.youtube.com/v/VIDEO_ID&amp;enablejsapi=1&amp;playerapiid=ytplayer</a>...
How do I convert NSDecimalNumber to NSInteger? <p>OK, I'm using a JSON-enabled Rails web-service to provide data to an iPhone application. I'm finding my Integer values (IDs) are being interpreted by the json-framework as a NSDecimalNumber type. I need it as an integer. How can I get an integer value out of my NSDecima...
<p>I'm not sure about JSON, but:</p> <p>NSDecimalNumber inherits from NSNumber, so you could just use the NSNumber's -integerValue method.</p> <p>Requires 10.5, but shouldn't be an issue.</p>
Find Programming Language Used <p>Whats the easiest way to find out what programming language an application was written in? I would like to know if its vb or c++ or delphi or .net etc from the program exe file.</p>
<p>Try <a href="http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/PEiD-updated.shtml">PEiD</a></p> <p>of course if they used a packer, some unpacking will need to be done first :)</p>
Oracle SQL - Parsing a name string and converting it to first initial & last name <p>Does anyone know how to turn this string: "Smith, John R"<br> Into this string: "jsmith" ?</p> <p>I need to lowercase everything with lower()<br> Find where the comma is and track it's integer location value<br> Get the first characte...
<p>Start by writing your own INSTR function - call it my_instr for example. It will start at char 1 and loop until it finds a ','.</p> <p>Then use as you would INSTR.</p>
Entities and calculated properties <p>What is the best practice to implement the following:</p> <ol> <li>we have a classes <code>Order</code> and <code>OrderItem</code> as parent-child. </li> <li>Class <code>OrderItem</code> provides property <code>Cost</code></li> <li>On the OrdersList form we have to see <code...
<p>Probably, but you have to ask yourself "why?". From the standpoint of the domain, does it "care" if you are recomputing this repeatedly? Or are you letting programmer-domain creep into your problem domain?</p> <p>One other thing --- consider making "max cost of items" part of the collection of OrderItems, and hid...
Best solution for turning a website into a pdf <p>The company I work for we have a CBT system we have developed. We have to go through and create books out of the content that is in our system, I have developed a program that goes through and downloads all of the content out of our system and creates a offline version ...
<p>I have searched and demoed and found that <a href="http://www.websupergoo.com/abcpdf-1.htm" rel="nofollow">ABCPdf from WebSuperGoo</a> is the best product for .NET. It is the most accurate and doesn't require a printer driver. It uses IE as the rendering engine, so it looks almost exactly like what you get in IE.<...
What are "unstacked calls in outer" in Perl's Devel::DProf? <p>I am profiling a Perl application with <code>perl -d:DProf</code>. When running <code>dprofpp</code> on the resulting <code>tmon.out</code> file, I get warnings like these:</p> <pre><code>Compress::Zlib::__ANON__ has 5 unstacked calls in outer Compress::Zl...
<p>I'll give this a shot:</p> <ul> <li>Unstacked calls indicate that when DProf was analyzing the profile, it encountered more (or fewer) calls on the stack (in the profile) than it expected to, meaning that the profiling data is incorrect.</li> <li>"outer" refers to the internal variable <code>%outer</code> in DProf,...
How do I do "svn st" in AnkhSVN for Visual Studio? -no text- <p>Just installed AnkhSVN and I see the equivalent of "svn up" but I'd prefer to run "svn st" first so that I don't just blindly update.</p>
<p>The next release of AnkhSVN will enable the 'Recent Changes' tab in the pending changes window. This allows the equivalent of 'svn st -u' (It shows outgoing and incoming changes).</p> <p>We are still working on the usability of this view in the <a href="http://ankhsvn.net/daily/" rel="nofollow">daily builds. </p> ...
.Net XmlWriter - unexpected encoding is confusing me <p>Environment is VS2008, .Net 3.5</p> <p>The following C# code (note the specified encoding of UTF8)</p> <pre><code>XmlWriterSettings settings = new XmlWriterSettings (); StringBuilder sb = new StringBuilder(); settings.Encoding = System.Text.Encoding.UTF8; setti...
<p>I suspect it's because it's writing to a StringBuilder, which is inherently UTF-16. An alternative to get round this is to create a class derived from StringWriter, but which overrides the Encoding property.</p> <p>I believe I've got one in <a href="http://pobox.com/~skeet/csharp/miscutil">MiscUtil</a> - but it's p...
What is MSXML2.ServerXMLHTTP's default Content-Type? <p>In my <a href="http://stackoverflow.com/questions/369226/receiving-xml-from-another-websites-call-to-serverxmlhttp-post-in-classic-asp">previous question</a>, I was accidentally sending token/value pairs with an <code>text/xml</code> Content-Type which resulted in...
<p>ASP will only fill the form array if the content type of the POST is "application/x-www-form-urlencoded". Generally ServerXMLHTTP will not set the content type header so if you don't do it manually no content type header is sent.</p> <p>An exception to this is where you pass an XML Document as the parameter to sen...
How to Save Record to Relational Tables With Linq To Sql <p>I have three tables like that:</p> <p><strong>Articles</strong> IdArticle Title Content</p> <p><strong>Tags</strong> IdTag TagName</p> <p><strong>ContentTag</strong> IdContentTag Idtag IdContent</p> <p>When user in my site write an article with adding tags...
<p>I think you're looking for something like this.</p> <p><a href="http://hookedonlinq.com/LINQtoSql5MinuteOverview.ashx" rel="nofollow">http://hookedonlinq.com/LINQtoSql5MinuteOverview.ashx</a></p>
Tables vs CSS for positioning and design <p><b>Duplicate: <a href="http://stackoverflow.com/questions/30251/tables-instead-of-divs#30271"><a href="http://stackoverflow.com/questions/30251/tables-instead-of-divs#30271">Tables instead of DIVs</a></a> and <a href="http://stackoverflow.com/questions/83073/div-vs-table#831...
<p>Yes, it matters. The most convincing argument that I've used in favor of CSS over tables is that screen readers (for the visually impaired) trip over tabular layout. That's a good argument by itself, but it gets a whole lot better when you take into account the fact that <em>Google reads your web site just like a ...
Reliable way to see process-specific perf statistics on an IIS6 app pool <p>In perfmon in Windows Server 2003, there are counter objects to get per-process processor time and memory working set statistics. The only problem is that in an environment with multiple application pools, there is no way to reliably identify t...
<p>We'd always collect the stats for all the w3wp processes, and we would capture PID. This is one of the counters in the Process group.</p> <p>There's a script that site in Server 2003's system32 folder called IISApp.vbs, that will list all the processes and their PIDs. You will need to run this to capture the PID's....
C# COM DLL: do I use Regasm, or Regsvr32? <p>I am building a C# ActiveX DLL... do I use REGASM or REGSVR32 to register it?</p> <p>How do I register the 64-bit interface vs the 32-bit interface?</p>
<p>You need to use <a href="http://msdn.microsoft.com/en-us/library/tzat5yw6%28v=vs.80%29.aspx"><code>regasm.exe</code></a> to register both the 32 bit and 64 bit interfaces I believe you need to run each of the <code>regasm.exe</code>'s in:</p> <pre><code>C:\Windows\Microsoft.NET\Framework\v2.0.50727 </code></pre> <...
.NET Processing spawning issues <p>I have an executable that runs instantly from a command prompt, but does not appear to ever return when spawned using System.Diagnostics.Process:</p> <p>Basicly, I'm writing a .NET library wrapper around the Accurev CLI interface, so each method call spawns the CLI process to execute...
<p>It is seeking for input? In particular, I notice that you are redirecting stdin, but not closing it - so if it is reading from stdin it will hang.</p>
Best practice for graceful replace of read-only SQL Server database <p>I have a read-only database that has cached information which is used to display pages on the site. There are processes that run to generate the database, and those run on a different server. When I need to update the live database, I restore this d...
<p>Probably what you want to do is take the live database offline with the command:</p> <pre><code>ALTER DATABASE name SET OFFLINE </code></pre> <p>You can read more <a href="http://www.blackwasp.co.uk/SQLOffline.aspx" rel="nofollow">here</a>, but it says:</p> <blockquote> <p>The above command attempts to take the...
Generics, arrays, and the ClassCastException <p>I think there must be something subtle going on here that I don't know about. Consider the following:</p> <pre><code>public class Foo&lt;T&gt; { private T[] a = (T[]) new Object[5]; public Foo() { // Add some elements to a } public T[] getA() { return a...
<pre><code>Foo&lt;Double&gt; f = new Foo&lt;Double&gt;(); </code></pre> <p>When you use this version of the generic class Foo, then for the member variable <code>a</code>, the compiler is essentially taking this line:</p> <pre><code>private T[] a = (T[]) new Object[5]; </code></pre> <p>and replacing <code>T</code> w...
How would someone download a website from Google Cache? <p>A friend accidentally deleted his forum database. Which wouldn't normally be a huge issue, except for the fact that he neglected to perform backups. 2 years of content is just plain gone. Obviously, he's learned his lesson.</p> <p>The good news, however, is th...
<p>You may want to consider looking at crawling the archive.org cache as well. If you're in there, it's generally better structured.</p>
.net 2.0 sp1 on Windows 98 <p>I've been searching around for this and cannot seem to find a solid answer. I know the 2.0 version of the .net framework is supported in Windows98, but does that include SP1? </p>
<p>It seems that the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&amp;displaylang=en" rel="nofollow">Microsoft .NET Framework Version 2.0 Redistributable Package (x86)</a> supports Windows 98:</p> <p>Supported Operating Systems: Windows 2000 Service Pack 3; Win...
How can I split a string into chunks of two characters each in Perl? <p>How do I take a string in Perl and split it up into an array with entries two characters long each?</p> <p>I attempted this:</p> <pre><code>@array = split(/../, $string); </code></pre> <p>but did not get the expected results.</p> <p>Ultimately ...
<pre><code>@array = ( $string =~ m/../g ); </code></pre> <p>The pattern-matching operator behaves in a special way in a list context in Perl. It processes the operation iteratively, matching the pattern against the remainder of the text after the previous match. Then the list is formed from all the text that matched...
Why is "array" marked as a reserved word in Visual-C++? <p>Visual Studio syntax highlighting colors this word blue as if it were a keyword or reserved word. I tried searching online for it but the word "array" throws the search off, I get mostly pages explaining what an array is. What is it used for?</p>
<p>It's not a reserved word under ISO standards. Microsoft's <a href="http://en.wikipedia.org/wiki/C%2B%2B/CLI">C++/CLI</a> defines <a href="http://msdn.microsoft.com/en-us/library/ts4c4dw6(VS.85).aspx">array</a> in the <a href="http://msdn.microsoft.com/en-us/library/d87eee3k(VS.85).aspx">cli namespace</a>, and Visual...
Two 'self-updating' properties in WPF MVVM <p>Considering you have an MVVM Architecture in WPF like <a href="http://joshsmithonwpf.wordpress.com/2008/11/14/using-a-viewmodel-to-provide-meaningful-validation-error-messages/" rel="nofollow">Josh Smith's examples</a></p> <p>How would you implement two properties 'synced'...
<p>One way:</p> <pre><code> public class Sample : INotifyPropertyChanged { private const double Multiplier = 1.21; #region Fields private double price; private double vat; #endregion #region Properties public double Price { get { retur...
Get/Set in the c++ world, faux-pas? <p>I notice that get/set is not the c++ way as far as I can tell by looking at boost/stl, and even reading the writings of some of the top c++ experts.</p> <p>Does anyone use get/set in their c++ class design, and can someone suggest a rule of thumb on where if at all this paradigm ...
<p>C++ does not have properties like C#. It is possible to write methods with "get" and "set" in the their names, but they don't automatically create properties. So is it good practice to use get and set methods then?</p> <p>Using get and set methods in C++ is not bad for accessing class properties. The STL and boo...
Getting started with SLIME and SWANK: Lisp connection closed unexpectedly: connection broken by remote peer <p>I was trying to use the slime-connect function to get access to a remote server with sbcl. I followed all the steps from the slime.mov movie from <a href="http://www.guba.com/watch/30000548671">Marco Baringer,...
<p>Have you checked that the version of SLIME and SWANK you use are the same? I've had odd things happening when I've used mismatched versions of those two halves of a SLIME session.</p>
Merging Visual Studio solution files <p>Microsoft Visual Studio (2005 and 2008) seems to have fun shuffling the Project IDs (GUIDs) around each time we do a little change in a solution. We found that this little detail leads to frustration each time someone has to merge branches in Source control...</p> <p>We though a...
<p>Unfortunately it does not look good so far. </p> <p>See this question: <a href="http://stackoverflow.com/questions/372357/merging-vcproj-files-scms-hell#372448">http://stackoverflow.com/questions/372357/merging-vcproj-files-scms-hell#372448</a></p> <p>closed as this appears to be a duplicate.</p>
Adding event handlers by using reflection <p>I am adding dynamically controls to page by using LoadControl and Controls.Add. I need somehow to wrap Init and Load event handlers of this loaded controls into my code. So it should be such order of events <em>SomeMyCode() -> Control.Init() -> AnotherMyCode()</em> and the s...
<p>You <em>cannot</em> forcibly inject an event handler in front of other handlers already subscribed to an event. If you need method A to be called first, then you'll need to subscribe A first.</p> <p><hr /></p> <p>Re your comment, that is incredibly hacky. First, you can't even rely on an event having a delegate-fi...
How do you databind to a System.Windows.Forms.Treeview control? <p>I'm looking at this control, and it seems to be lacking the standard .net "datasource" and "datamember" properties for databinding. Is this control not bindable? I can write some custom function that populates the treeview from a given data source, I ...
<p>You are correct in that there is no data binding. The reason being is that TreeViews are hierarchical data structures. That is, not a straight list. As a result the databind option is invalid to say a List structure.</p> <p>Sadly it's creating your own populate methods or buying 3rd party controls (which in the ...
PHP/CURL/Other - How resource intensive? <p>I am going to have a daemon that will run on a FreeBSD server, which will exchange small amounts of data with a list of URIs every minute.</p> <p>I am thinking to use the curl_multi functions to run them all at once, or in groups, every minute, using a post. I am open to ot...
<p>I'd say that SOAP processing (generating query, sending it, get it processed then getting answer back) may be more resource intensive than just a POST, even "multithreaded". Profiling or benchmarking is probably the only way to be sure anyway.</p>
Do you use the TR 24731 'safe' functions? <p>The ISO C committee (<a href="http://www.open-std.org/JTC1/SC22/WG14/">ISO/IEC JTC1/SC21/WG14</a>) has published <a href="http://www.open-std.org/JTC1/SC22/WG14/www/projects#24731-1">TR 24731-1</a> and is working on <a href="http://www.open-std.org/JTC1/SC22/WG14/www/project...
<p>I have been a vocal critic of these TRs since their inception (when it was a single TR) and would never use them in any of my software. They mask symptoms instead of addressing causes and it is my opinion that if anything they will have a negative impact on software design as they provide a false sense of security ...
.NET CF 2.0: possible single-threaded reentrancy <p>A simple application is written in CF 2.0. It's single-threaded as far as I'm concerned.</p> <p>Two parts of the application are of interest: an event handler that handles "Barcode scanned" event raised by a class that represents PDA's barcode scanner (provided by ma...
<p>The Windows.Forms timer is going to happen on the UI thread via a call to PostMessage. That is a guarantee. How the "barcode scanned" even comes in is completely up to the developer of the library that's giving you the event. You should certainly <strong>not</strong> assume that it's going to run in the same cont...
Finding the Current Active Window in Mac OS X using Python <p>Is there a way to find the application name of the current active window at a given time on Mac OS X using Python?</p>
<p>This should work:</p> <pre><code>#!/usr/bin/python from AppKit import NSWorkspace activeAppName = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName'] print activeAppName </code></pre> <p>Only works on Leopard, or on Tiger if you have PyObjC installed and happen to point at the right python bina...
Check for column name in a SqlDataReader object <p>How do I check to see if a column exists in a <code>SqlDataReader</code> object? In my data access layer, I have create a method that builds the same object for multiple stored procedures calls. One of the stored procedures has an additional column that is not used b...
<p>In the accepted answer, using Exceptions for control logic is considered bad practice and has performance costs.</p> <p>Looping through the fields can have a small performance hit if you use it a lot and you may want to consider caching the results </p> <p>The more appropriate way to do this is:</p> <pre><code>pu...
Simple (standalone) Java SOAP web service client from WSDL using Maven <p>I'm looking to generate a simple standalone Java client which will make calls to a SOAP web service, given a wsdl. When I say simple and standalone I mean that once I'm done I want to be able to do something like</p> <pre><code>import my.genera...
<p>Have a look at CXF and its Maven <a href="http://www.opendocs.net/apache/cxf/2.0/maven-integration-and-plugin.html" rel="nofollow">plug in</a>. CXF would generate code similar to yours (of course web services could fail and you should add exception handling). Have in mind though that SOAP web services is a complicat...
How do I get the UTC time of "midnight" for a given timezone? <p>The best I can come up with for now is this monstrosity:</p> <pre><code>&gt;&gt;&gt; datetime.utcnow() \ ... .replace(tzinfo=pytz.UTC) \ ... .astimezone(pytz.timezone("Australia/Melbourne")) \ ... .replace(hour=0,minute=0,second=0,microsecond=0) \ ...
<p>I think you can shave off a few method calls if you do it like this:</p> <pre><code>&gt;&gt;&gt; from datetime import datetime &gt;&gt;&gt; datetime.now(pytz.timezone("Australia/Melbourne")) \ .replace(hour=0, minute=0, second=0, microsecond=0) \ .astimezone(pytz.utc) </code></pre> <p>BUTâ€...
How would you attack this polymorphism string building problem <p>Sorry for not so discrptive title, if someone wants to change it go ahead. Also note I have already asked a <a href="http://stackoverflow.com/questions/361742/would-this-be-a-good-case-for-polymorphism">question</a> about this kind of thing but this one...
<p>I think you're over complicating things and will end up creating too many classes.</p> <p>I'd look at the problem as less a string-building one and more of how you'd present a nice interface to a .net caller. Just because there are lots of possible arguments doesn't mean you need to create lots of classes for them,...
Insert Dates in the return from a query where there is none <p>We are building a query to count the number of events per hour, per day. Most days there are hours that do not have any activity and therefore where the query is run the count of activities per hour show up but there are gaps and the query excludes these. W...
<p>You are going to somehow need a table of days and hours, and then you will have to do an outer join between that table and your query. Here's how I would do it. Note that this solution will only work in SQL Server 2005 and 2008. If you don't have those platforms, you'll have to actually create a table of times in...
Can Flash Remoting run through a HTTP (Squid) proxy server <p>I have a network were would like like to deliver data using the Flash Remoting data format over HTTP. We have Squid working as a reverse proxy/accelerator, are there any known problems running this traffic through Squid. We would configure that particular ...
<p>If Squid is not caching that URL or modifying the request or response, I think it's unlikely to cause any problems. That's the point, right? That's a big if though...</p> <p>Just be glad that you control the Squid. That way, if there is a problem, you can change the configuration relatively quickly. Relying on an e...
How can I write out or read in a Perl hash of arrays? <p>I have a program in Perl I'm working on where I would need multiple keys, and a way of giving each key multiple values and follow that by being able to both read them in and write them out to an external file depending on if the key matches what the person enters...
<p>Check out <a href="http://search.cpan.org/~ilyam/Data-Dumper-2.121/">Data::Dumper</a>.</p> <p>For instance, this microscopic script:</p> <pre><code>#!/bin/perl -w use strict; use Data::Dumper; my(%hash); $hash{key1} = [ 1, "b", "c" ]; $hash{key2} = [ 4.56, "g", "2008-12-16 19:10 -08:00" ]; print Dumper(\%hash);...
Why is App_Offline failing to work as soon as you it starts loading dlls? <p>Could anyone please help me with this. On the production site app_offline.htm works only till you start uploading dlls. As soon as you start uploading dlls it throws following error"Could not load file or assembly 'SubSonic' or one of its depe...
<p>I have heard of people having problems with app_offline.htm if it did not have enough content in the file.</p> <p>Fill it with a couple hundred kb's of Lorem Ipsum text and see if that helps.</p>
How to Check for Image in Cache Using Silverlight <p>I am creating a basic image browsing application using Silverlight. Depending on the user's connection speed, some images may take time to appear once they click on the thumb nail. I would like to show a progress bar while it is being downloaded. I have this part ...
<p>After thinking about it for a while, I did come up with one solution, though it wasn't what I was originally intending.</p> <p>I am using the WebClient class to get my image file. I attach to the DownloadProgressChanged event. If the image has already been downloaded, then the ProgressPercentage is immediately 10...
Are there well known algorithms for deducing the "return types" of parser rules? <p>Given a grammar and the attached action code, are there any standard solution for deducing what type each production needs to result in (and consequently, what type the invoking production should expect to get from it)?</p> <p>I'm thin...
<p>If you are writing code in a functional language it is easy; standard Hindley-Milner type inference works great. <strong>Do not do this</strong>. In my EBNF parser generator (never released but source code available on request), which supports Icon, c, and Standard ML, I actually <strong>implemented the idea</stro...
Unix command to find lines common in two files <p>I'm sure I once found a unix command which could print the common lines from two or more files, does anyone know its name? It was much simpler than <code>diff</code>.</p>
<p>The command you are seeking is <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/comm.html"><code>comm</code></a>.</p>
To Disable The BackButton Of Browser Window Using Javascript <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/87422/disabling-back-button-on-the-browser">Disabling Back button on the browser</a> </p> </blockquote> <p>Hi Guys, I need to disable the backbut...
<p>you can't make the user stay on your page, but you can give a yes/no prompt first, though.</p> <p>read around <a href="http://stackoverflow.com/questions/261083/is-there-a-way-to-determine-that-the-browser-window-was-closed">http://stackoverflow.com/questions/261083/is-there-a-way-to-determine-that-the-browser-wind...
Why does stdafx.h work the way it does? <p>As usual, when my brain's messing with something I can't figure out myself, I come to you guys for help :)</p> <p>This time I've been wondering why stdafx.h works the way it does? To my understanding it does 2 things:</p> <ul> <li>Includes standard headers which we <em>might...
<p>stdafx.h is ONE way of having Visual studio do precompiled headers. It's a simple to use, easy to automatically generate, approach that works well for smaller apps but can cause problems for larger more complex apps where the fact that it encourages, effectively, the use of a single header file it can cause coupling...
How to change font color of disabled input in Firefox <p>When I disable input elements the text is taking the font color: "#000000" in Firefox. This is not happening in IE. Please check the below page in IE and Firefox. Let me know how to give it a gray look as in IE.<br /> <a href="http://shivanand.in/tmp/test.html">t...
<p>Different browsers style disabled elements differently. Here is how you can control the style of disabled elements in Firefox.</p> <pre><code>[disabled] { color:#ff0000; background-color:#00ff00; } </code></pre>
Finding available LPT (parallel) ports and addresses in Delphi <p>I am doing direct I/O on a parallel port which is fine and necessary for speed. I would like to enumerate the available ports to offer the user a choice of ports at setup time rather than a tedious trawl through device manager to read the address manuall...
<p>According to <a href="http://msdn.microsoft.com/en-us/library/aa506006.aspx" rel="nofollow">this Microsoft article</a>, for Win2K and newer, you can find details of parallel-connected devices in the registry at HKLM\SYSTEM\CurrentControlSet\Enum\LPTENUM.</p>
Set folder permissions with C# - convert CreateObject("Wscript.Shell") from vb to C# <p>I'd like to know how to convert this vb script to C#</p> <pre><code>Dim strFolder As String Dim objShell As Object strFolder = "C:\zz" Set objShell = CreateObject("Wscript.Shell") objShell.Run "%COMSPEC% /c Echo Y| cacls " &amp;...
<p>It's not possible to upgrade unfortunately - I work for a big company, so would mean updating loads of people - which would be a mission...</p> <p>But - creating a process worked!</p> <pre><code>System.Diagnostics.Process meProc = System.Diagnostics.Process.Start ("cmd.exe", " /c echo y| cacls C:\\zzz /t /c /g eve...
Configuring root directory internal ASP.NET server <p>My ASP.NET always starts like this with the internal server: <a href="http://localhost:50793/Website/" rel="nofollow">http://localhost:50793/Website/</a></p> <p>I use FckEditor which points to <a href="http://localhost:50793/fckeditor" rel="nofollow">http://localho...
<p>Go click on the website project in the solution explorer, then edit the "Virtual path" in the properties window.</p>
How can I render a different controller's action from within a view? <p>I know that within a view I can render an action from the same controller using Html.RenderPartial. However, I need to render the output from an action under a different controller. What is the best way to do this? I would prefer to do this directl...
<p>The best thing to do is use <code>Html.RenderAction</code> which needs a references to the 'Futures' assembly <code>Microsoft.Web.Mvc</code> which <a href="http://stackoverflow.com/questions/334408/where-to-get-microsoftwebmvcdll">there's a question about how to get it</a>.</p> <p>You will also need to add the name...
Where is a python real project to be used as example for the unit-test part? <p>I'm looking for a python project to use as example to copy the design of the unit test parts.</p> <p>The project should have these features:</p> <ol> <li>its code is almost fully unit tested</li> <li>the code is distributed in many packag...
<p>Maybe <a href="http://code.google.com/p/python-nose/" rel="nofollow">Nose</a> itself?</p>
Ajax hyperlinking <p>I have a problem in giving Ajax functionality to a hyperlink. I have files <code>Link.html</code> and <code>GetCustomerdata.php</code>. The main function of the HTML is send the data to <code>getCutomerData.php</code> and shows flash as "success".</p> <p>And also I do not want hyperlinking,</p> <...
<p>You placed the anchor onclick event inside the href attribute. onclick should be written as a separate attribute:</p> <pre><code>... &lt;a href="getCustomerData.php?id=10" onclick="requestCustomerInfo();return false;"&gt;Show Me&lt;/a&gt; </code></pre> <p>To prevent the link from redirecting the page, you need to ...
How to be able to select a portion of the screen? <p>In some screen capture software when you press a key it's possible for the client to select a portion of the screen. How can I implement that in my software written in framework 2.0 .Net?</p> <p>Here is a image of what I would like to do : <a href="http://img341.ima...
<p>I know it might not be a solution that you could easily copy&amp;paste but this open source project in C# does have the behavior that your application want : <a href="http://www.codeplex.com/cropper" rel="nofollow">http://www.codeplex.com/cropper</a></p> <p>You might be able to take a piece of their code into you a...
How can I generate multiple classes from xsd's with common includes? <p>Aloha</p> <p>I received a few nice xsd files which I want to convert to classes (using xsd.exe) All the xsd's have the same includes, like this:</p> <pre><code>&lt;xs:include schemaLocation="kstypes.xsd" /&gt; &lt;xs:include schemaLocation="kspar...
<p>Looking over the documentation, it would appear that the 'best' way (not an easy way!) would be to use the /element:<em>elementname</em> command line switch on the second and subsequent files to specify the types you want classes generated for.</p>
Returning Japanese characters via char* in an Excel XLOPER <p>I am retrieving Japanese characters from a data source and I want to return this data to Excel in an XLOPER. I am using a Japanese version of Excel 2003 (hence XLOPERs and not XLOPER12s).</p> <pre><code>wchar_t* pszW = OLE2W(bstrResult); //I have the data ...
<p><strong><em>User Error!</em></strong></p> <p>The above code is good. The problem is that Excel was using the wrong code page. I hadn't set the language for non-unicode programs to Japanese in Control Panel.</p> <p>The code now works for the English version of Excel too.</p> <p>That was a day and a half well spe...
Will an svn:external subdirectory sync with its HEAD revision upon every 'svn update' to the parent working copy? <p>On <a href="http://svnbook.red-bean.com/en/1.0/ch07s03.html" rel="nofollow">this page in the Subversion manual</a>, it says that "When you commit a change to the svn:externals property, Subversion will s...
<p>Yes, it will be updated as well, that is the main purpose here :)</p>
How to print to a null printer in .NET? <p>I need to write a unit test for a method that will print a document. Is there an easy way to send the output to the Windows equivalent of /dev/null? I'm guessing that having our build server print a document on every check in is going to get expensive quickly. ;)</p> <p>Id...
<p>I do this by creating a Windows printer that prints to the NUL device. This is pretty straightforward though the specifics differ a bit between Windows versions: just create a local printer and specify NUL as the local port, "Generic" as the Manufacturer and "Generic / Text Only" as the printer model.</p>
Are there any plans to officially support Django with IIS? <p>I say properly because everyone I have spoken to in the past said running Django on IIS was a hack. I had it working somewhat but it never did quite right and did feel like a hack. I like python but had to give it up because I could never make Django work ...
<p>Django is WSGI-based framework so as soon as IIS get proper WSGI handling there should be no problem in running Django under this environment. Anything that connects WSGI and IIS will do.</p> <p>Quick googling reveals <a href="http://code.google.com/p/isapi-wsgi/" rel="nofollow">some project on Google Code</a>.</p>...
Chained IF structure <p>Imagine this case where I have an object that I need to check a property. However, the object can currently have a null value.</p> <p>How can I check these two conditions in a single "if" condition?</p> <p>Currently, I have to do something like this:</p> <pre><code>if (myObject != null) { ...
<pre><code>if(myObject != null &amp;&amp; myObject.Id != pId) { myObject.Id = pId; myObject.Order = pOrder; } </code></pre> <p><code>&amp;&amp;</code> is a short-circuiting logic test - it only evaluates the right-hand-side if the left-hand-side is true. Contrast to "a &amp; b", which always evaluates both sides...
Boxing/Unboxing and Nullable? <p>I understand that boxing and unboxing is about casting (real type to object... object to real type). But I do not understand what the MSDN say about it with the Nullable. Here is the text I do not understand:</p> <blockquote> <p>When a nullable type is boxed, the common language runt...
<p>What it's saying is that if you do:</p> <pre><code>int? x = 5; object y = x; // Boxing </code></pre> <p>You end up with a boxed <code>int</code>, not a boxed <code>Nullable&lt;int&gt;</code>. Similarly if you do:</p> <pre><code>int? x = null; // Same as new Nullable&lt;int&gt;() - HasValue = false; object y = x; ...
Can't re-add Service Reference Properly <p>I've got a WCF service up and running on a server. We have a proxy class that we add all service references to, and I tried to add my service reference there. However, it's not exposing all of the methods, specifically the interface, allowing me to create an instance of it (th...
<p>The issue has been resolved. It turns out that if you don't add all the necessary references to the project, then the references needing them will not appear. It turned out that we needed to add System.Drawing as a reference, and then the solution added fine. I wish there was some feedback about this from MS, but if...
Can IntelliJ IDEA open more than one editor window for files from the same project? <p>I can split editor panes horizontally or vertically, but it does not seem possible to view code in two separate physical windows. I am aware that Idea can open multiple <strong>projects</strong> in separate windows, but I'd like to ...
<p>Unfortunately there is no way (as of IDEA 8.0.1) to do what you're asking for. As you pointed out, you can split the editor pane but there is always exactly one editor per IDEA project.</p> <p>UPDATE: As of IDEA 10 (currently the latest is 10.5), the answer is yes, you can :-)</p>
Validating file types by regular expression <p>I have a .NET webform that has a file upload control that is tied to a regular expression validator. This validator needs to validate that only certain filetypes should be allowed for upload (jpg,gif,doc,pdf)</p> <p>The current regular expression that does this is:</p> <...
<p>Your regex seems a bit too complex in my opinion. Also, remember that the dot is a special character meaning "any character". The following regex should work (note the escaped dots):</p> <pre><code>^.*\.(jpg|JPG|gif|GIF|doc|DOC|pdf|PDF)$ </code></pre> <p>You can use a tool like <a href="http://www.ultrapico.com/Ex...
Why does the BitConverter return Bytes and how can I get the bits then? <p>As input I get an int (well, actually a string I should convert to an int).<br /> This int should be converted to bits.<br /> For each bit position that has a 1, I should get the position.<br /> In my database, I want all records that have an in...
<p>I suspect <a href="http://msdn.microsoft.com/en-us/library/system.collections.bitarray.aspx" rel="nofollow">BitArray</a> is what you're after. Alternatively, using bitmasks yourself isn't hard:</p> <pre><code>for (int i=0; i &lt; 32; i++) { if ((value &amp; (1 &lt;&lt; i)) != 0) { Console.WriteLine(...
SQL Server Agent: How to "sleep"? <p>In a scripting step in a scheduled task in SQL Server Agent 2005, I need to trigger a webscript that is running on a different server. I'm doing this:</p> <pre><code>Dim ie Set ie = CreateObject( "InternetExplorer.Application" ) ie.navigate "...to my dreamscript" ' Wait till IE ...
<p>You can write a console applicaton and execute the console app in SQL agent job.</p>
Will Expression Blend relieve me from having to learn xaml? <p>I don't mind learning xaml and I'm sure I need to be familiar somewhat, but when I was first trying out Silverlight 1 with javascript it looked like a tremendous amount of overhead. I decided to wait until tools matured and asp.net was added. Well, asp.ne...
<p>Just as a profressional web developer can't lean on Dreamweaver's drag-and-drop to avoid learning HTML, you should climb the XAML learning curve. </p> <p>Blend will still help, however- just as many started up the HTML curve by doing some drag-and-drop and studying the resulting HTML code. I did some prototyping ...
A couple of questions on the architecture of Ruby <p>I am primarily a fluent .NET developer (as can be seen from the amount of posts and threads I make about .NET), but I thought it would be good to learn RoR.</p> <p>In doing so, I have a few questions about the architecture of the language (Ruby) and the framework (R...
<p>Dave Thomas (Pragmatic Programmers) has an excellent <a href="http://www.pragprog.com/screencasts/v-dtrubyom/the-ruby-object-model-and-metaprogramming" rel="nofollow">screencast series</a> on the Ruby object model/metaprogramming. We watched this in a local Ruby user's group. The series isn't free, but it's not ex...
How do you manage software serial keys, licenses, etc? <p>My company is trying to find a tool that will track serial keys for software we have purchased (such as Office), as well as software that we write and sell.</p> <p>We want software that will allows us to associate a particular computer with the software on that...
<p>Take a look at SpiceWorks:</p> <p><a href="http://www.spiceworks.com/" rel="nofollow">http://www.spiceworks.com/</a></p> <p>It does a lot more than just inventory / asset management and is free.</p>
Flex: when hiding components in flex <p>When I set a component to visible=false the component hides, but how do I get it to take no space (get the container it belongs to to resize??)</p> <p></p> <pre><code>&lt;mx:HBox width="100%" height="100%"&gt; ... &lt;/mx:HBox&gt; &lt;mx:HBox width="100%" id="boxAddComment" vi...
<p>use the <strong>includeInLayout</strong> property. e.g.</p> <pre> <code> &lt;mx:HBox width=&quot;100%&quot; height=&quot;100%&quot;&gt; ... &lt;/mx:HBox&gt; &lt;mx:HBox width=&quot;100%&quot; id=&quot;boxAddComment&quot; visible=&quot;false&quot; includeInLayout=&quot;false&quot; &gt; &lt;mx:TextArea id=&quot;...
Convert style-laden HTML tables to PDF, in .NET 1.1 <p>I have colleagues working on a .NET 1.1 project, where they obtain XML files from an external party and programmatically instruct iTextSharp to generate PDF content based on the XML data.</p> <p>The tricky part is, within this XML are segments of arbitrary HTML co...
<p>I have found .NET 2.0-based components like <a href="http://www.html-to-pdf.net/" rel="nofollow">ExpertPDF</a> and <a href="http://www.websupergoo.com/products.htm#pd" rel="nofollow">ABCpdf</a> do a fairly good job interpreting the CSS styles and aligning the tables properly in PDF. Right now I am suggesting to my c...
What is the difference between these 2 function syntax types <p>As the title says, whats the difference between</p> <pre><code>MyFunction = function() { } </code></pre> <p>and</p> <pre><code>function MyFunction() { } </code></pre> <p>Nothing?</p> <p><strong>Duplicate:</strong> <a href="http://stackoverflow.com/q...
<p>The first form is actually a variable with an <strong>anonymous function</strong> assigned to it, the second is a <strong>declared function</strong>. </p> <p>They're <em>almost</em> interchangeable, but have some differences: debuggers have a harder time with anons (because they lack a name) and the JS engine can d...
How can I execute a given function on every element of a complicated data structure in Perl? <p>I want to decode all the HTML entities in a complicated data structure. Basically I'm looking for a "super map()" function. Here's what I have so far:</p> <pre><code>sub _html_decode { my $self = shift; my $ref = sh...
<p>I think this should do, but I haven't tested it.</p> <pre><code>sub _html_decode { my ($self, $ref) = @_; if (ref($ref) eq "HASH") { for my $value (values %{$ref}) { $self-&gt;_html_decode($value); } } elsif (ref($ref) eq "ARRAY") { for my $value (@{$ref}) { ...
Why can't Nginx POST to my Perl backend? <p>EDIT: So I just found out that GET methods indeed work, but POST methods however do not work! That might be significant.</p> <p>So I am on Debian Etch, running Nginx. Nginx does not normally serve cgi/pl files so I have followed a guide to get my backend working.</p> <p><a ...
<p>This particular fastcgi-wrapper.pl script was modified by Denis S. Filimonov to handle POSTS requests properly. You can read more about it at: <a href="http://www.ruby-forum.com/topic/145858" rel="nofollow">http://www.ruby-forum.com/topic/145858</a></p>
Drop Down Box Not Fully Displayed (All Browsers) <p><img src="http://farm4.static.flickr.com/3200/3116366800_570cc971b9_m.jpg" alt="Screenshot of Drop Down" /></p> <p>This would be my issue I have a drop down that's not displaying fully. I'm not sure even where to start so here's the HTML surronding the drop down and ...
<p>It looks like you are setting "line-height:15px;" on "select" elements. Remove that and see if it fixes the issue.</p>
Modifying the window opened by javascript's "window.open()" function <p>Here's my scenario:</p> <p>I have a page containing several links; each link is meant to open another window containing a pdf. The catch is, I can't have that window directly go to the PDF because I do not want to make it apparent to the end user...
<p>You can't really block until it's loaded but you can set an event in the popup, like this:</p> <pre><code>myWindow.onload = function() { document.title = pdfTitle; document.getElementById('pdfFrame').src = pdfLocation; } </code></pre>
Office documents prompt for login in anonymous SharePoint site <p>I have a MOSS 07 site that is configured for anonymous access. There is a document library within this site that also has anonymous access enabled. When an anonymous user clicks on a PDF file in this library, he or she can read or download it with no pro...
<p>To disable login prompt opening office documents from SharePoint 2010 do the following settings in web.config</p> <pre><code>&lt;system.webServer&gt; &lt;security&gt; &lt;requestFiltering allowDoubleEscaping="true"&gt; &lt;!-- here's where the magic happens --&gt; &lt;verbs allowUnlisted="true"&gt...
Java equivalent to PHP's preg_replace_callback <p>I'm in the process of moving an application from PHP to Java and there is heavy use of regular expressions in the code. I've run across something in PHP that doesn't seem to have a java equivalent:</p> <pre><code>preg_replace_callback() </code></pre> <p>For every mat...
<p>Trying to emulate PHP's callback feature seems an awful lot of work when you could just use appendReplacement() and appendTail() in a loop:</p> <pre><code>StringBuffer resultString = new StringBuffer(); Pattern regex = Pattern.compile("regex"); Matcher regexMatcher = regex.matcher(subjectString); while (regexMatche...
How to restrict client control area in a custom WinForms control <p>I have a custom control that uses a designer I've inherited from ParentControlDesigner to allow child controls to be dropped. I'm not using any internal designers, just straightforward single-parent stuff.</p> <p>This control draws a "header", so I'm...
<blockquote> <p>Prevent controls from being dragged onto the header area, period (I have a feeling this may not be possible)</p> </blockquote> <p>Having the control (the control itself, not the designer) override <code>Control.DisplayRectangle.get</code> may help restrict its children.</p>
What's the efficiency and quality of this shuffling algorithm? <p>This recent question about <a href="http://stackoverflow.com/questions/375351/most-efficient-way-to-randomly-sort-shuffle-a-list-of-integers-in-c">sorting randomly using C#</a> got me thinking about the way I've sometimes shuffled my arrays in Perl.</p> ...
<p>I'm not a Perl internals expert, so I don't know how "sort" will work here. However, most sort functions expect consistency in their comparisons, and I would expect them to work unpredictably if the function is itself random. Unfortunately, unpredictability is not the same as randomness, and so I'd have no confide...