input
stringlengths
51
42.3k
output
stringlengths
18
55k
Accessing a list of avaliable Wifi APs, on Windows Mobile <p>I need to query for a list of available Wireless Access points. I only need their SSIDs.</p> <p>The App is currently .Net CF 2.0, but it's not a problem going with 3.5 if we have to.</p>
<p>The list of "nearby" APs is retrived eitehr through NDIS or WZC, depending on what your NIC driver supports. Both are somewhat well documented in MSDN, but they aren't fun to wrap. OpenNETCF's SDF contains a wrapper that looks at both, depending on your NIC's support.</p> <p>It's accessible via the <a href="http...
Is there a Perl module that validates an XML against a schema? <p>I need to validate an XML agaist a schema. </p> <p>I tried XML::SAX::ParserFactory; XML::Validator::Schema and related modules but looks like they are limited.<br /> Limited in the sense that it didn't recognize schema elements such as xsd:unique, xsd:...
<p>Have a look at <a href="http://search.cpan.org/dist/XML-LibXML/">XML::LibXML</a></p> <p>This uses the highly regarded libxml2 library which most people cite as a successor to Expat and <a href="http://search.cpan.org/dist/XML-Parser/">XML::Parser</a> based modules.</p> <p>For schema validation look at <a href="htt...
Invoke gdb to automatically pass arguments to the program being debugged <p>I'd like to write a script that (under certain conditions) will execute gdb and automatically run some program X with some set of arguments Y. Once the program has finished executing the user should remain at gdb's prompt until s/he explicitly...
<p>The easiest way to do this given a program <code>X</code> and list of parameters <code>a b c</code>:</p> <pre><code>X a b c </code></pre> <p>Is to use <code>gdb</code>'s <code>--args</code> option, as follows:</p> <pre><code>gdb --args X a b c </code></pre> <p><hr /></p> <p><code>gdb --help</code> has this to s...
ASP.NET 3.5 bind to XML string <p>With ASP.NET 3.5 I can easily bind to an XML file by using an <code>XmlDataSource</code>.</p> <p>How can I bind to an XML <em>string</em> instead of a <em>file</em>?</p>
<p>Use the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.xmldatasource.data.aspx" rel="nofollow">XmlDataSource.Data</a> property.</p> <pre><code>XmlDataSource dataSource = new XmlDataSource(); dataSource.Data = "&lt;root&gt;&lt;element&gt;Item #1&lt;/element&gt;&lt;element&g...
Which Tomcat 5 context file takes precedence? <p><a href="http://tomcat.apache.org/tomcat-5.5-doc/deployer-howto.html" rel="nofollow">Tomcat documentation</a> says: </p> <p>The locations for Context Descriptors are;</p> <p>$CATALINA_HOME/conf/[enginename]/[hostname]/context.xml<br> $CATALINA_HOME/webapps/[webappname]...
<p>For the files you listed, the simple answer assuming you are using all the defaults, the order is (note the <strong>conf</strong>/Catalina/localhost):</p> <pre><code>...tomcat/conf/context.xml ...tomcat/conf/Catalina/localhost/myapp.xml ...tomcat/webapps/myapp/META-INF/context.xml </code></pre> <p>I'm basing this ...
Getting the Web Capture Web Part to work were the Sharepoint is 64bit <p>Previously our SharePoint server was 32-bit and we used the web capture web part to display a bugzilla search results page. Since we've migrated to a 64-bit server the webpart no longer works. We're running the same versions of everything, the onl...
<p>In all the times I have come across an error in changing from 64bit to 32bit, the change in the number of bits is usually a red herring and the actual cause of the failure is something else.</p> <p>Check the sharepoint logs for the WebPart errors. They will help show exactly what is wrong. Post the relevant errors ...
How do I examine the contents of an std::vector in gdb, using the icc compiler? <p>I want to examine the contents of a std::vector in gdb but I don't have access to _M_impl because I'm using icc, not gcc, how do I do it? Let's say it's a std::vector for the sake of simplicity.</p> <p>There is a very nice answer <a hre...
<p>Not sure this will work with your vector, but it worked for me.</p> <pre><code>#include &lt;string&gt; #include &lt;vector&gt; int main() { std::vector&lt;std::string&gt; vec; vec.push_back("Hello"); vec.push_back("world"); vec.push_back("!"); return 0; } </code></pre> <p>gdb:</p> <pre><code>...
API to determine cell carrier? <p>Is there a free API or some other way to determine what carrier a cell phone number is registered with?</p> <p>I'd like my application to broadcast text messages without them picking their carrier from a list.</p> <p><strong>UPDATE:</strong> Interestingly, a coworker found the answer...
<p>Data24-7 offers an API for looking up the carrier for wireless phone numbers. It also returns the email addresses to send SMS and MMS messages to the phone. It's not free, it's $12 per month and $0.006 per lookup. </p> <p>The link is: <a href="http://www.data24-7.com">http://www.data24-7.com</a></p>
Can I invoke an instance method on a Ruby module without including it? <h3>Background:</h3> <p>I have a module which declares a number of instance methods</p> <pre><code>module UsefulThings def get_file; ... def delete_file; ... def format_text(x); ... end </code></pre> <p>And I want to call some of these met...
<p>If a method on a module is turned into a module function you can simply call it off of Mods as if it had been declared as</p> <pre><code>module Mods def self.foo puts "Mods.foo(self)" end end </code></pre> <p>The module_function approach below will avoid breaking any classes which include all of Mods.</p>...
Moving from NuSOAP to PHP5 SOAP <p>I have been working on a script with PHP4 that relies on NuSOAP. Now, I'm trying to move this to PHP5, and use the buildin support for SOAP there.</p> <pre><code>$wsdlPath = ""; // I have obviously set these variables to something meaningful, just hidden for the sake of security $...
<p>Make sure NuSoap and PHPv5-SOAP are running on the same server. If I'm not totally wrong, both libraries uses the same class-name. Maybe it will work better if you make sure none NuSopa-files are included? And also verify that the SOAP-library are loaded:</p> <pre><code>if(!extension_loaded('soap')){ dl('soap.so'...
How do I convert a Char into a Keycode in .Net? <p>I want to convert a string into a series of Keycodes, so that I can then send them via PostMessage to a control. I need to simulate actual keyboard input, and I'm wondering if a massive switch statement is the only way to convert a character into the correct keycode, ...
<p>Raymond says this is a bad idea.</p> <p><a href="http://blogs.msdn.com/oldnewthing/archive/2005/05/30/423202.aspx" rel="nofollow">http://blogs.msdn.com/oldnewthing/archive/2005/05/30/423202.aspx</a></p>
How does Flash work? <p>Right now I'm developing a small canvas oriented 2D graphics engine for a game, and have been looking into several sources for hints to apply to my system's design. But obviously the most battle proven solution out there is flash, so I was wondering how is Flash architectured. I found some sourc...
<p>Well, at the root of your Flash content is a stage object (an instance of the <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Stage.html" rel="nofollow">Stage</a> class). That stage is the root node of a tree of display objects, any of which can contain graphical assets (lines, text fields, etc....
TortoiseSVN Repo-Browser urls <p>How do I remove the urls of repositories that no longer exist in the dropdown in the TortoiseSvn repo-browser?</p>
<p>Just move the mouse over the item you want to remove and press <kbd>Shift</kbd>+<kbd>Del</kbd>.</p>
What is Teredo Tunneling Pseudo-Interface? <p>Running ipconfig /all shows a Teredo Tunneling Pseudo-Interface. What is that? Does this have something to do with IPv4 vs IPv6? Should I get rid of it? If so how?</p>
<p>Is to do with IPv6 </p> <p>All the gory details here: <a href="http://www.microsoft.com/technet/network/ipv6/teredo.mspx">http://www.microsoft.com/technet/network/ipv6/teredo.mspx</a> </p> <p>Some people have had issues with it, and disabled it, but as a general rule, if it aint broke...</p>
In ruby, why does my IRB interactive debugging session always say "No sourcefile available" <p>Just trying to get my irb sessions to actually list the current line of code, and those around it. Similar to what Perl's -d debugging mode lets you ddo.</p>
<p>Its because, when you are doing it interactively, your "sourcefile" is std-in. </p>
System.BadImageFormatException: Could not load file or assembly (from installutil.exe) <p>I am trying to install a Windows service using InstallUtil.exe and am getting the error message</p> <blockquote> <p>System.BadImageFormatException: Could not load file or assembly '<code>{xxx.exe}</code>' or one of its dependen...
<p>Some more detail for completeness in case it helps someone...</p> <p>Note that the most common reason for this exception these days is attempting to load a 32 bit-specific (<code>/platform:x86</code>) DLL into a process that is 64 bit or vice versa (viz. load a 64 bit-specific (<code>/platform:x64</code>) DLL into ...
Is an HTTPS query string secure? <p>I am creating a secure web based API that uses HTTPS; however, if I allow the users to configure it (include sending password) using a query string will this also be secure or should I force it to be done via a POST?</p>
<p>Yes, it is. <strong>But using GET for sensitive data is a bad idea</strong> for several reasons:</p> <ul> <li>Mostly HTTP referrer leakage (an external image in the target page might leak the password[1])</li> <li>Password will be stored in server logs (which is obviously bad)</li> <li>History caches in browsers </...
Reading byte stream returned from JavaEE server <p>We have a JavaEE server and servlets providing data to mobile clients (first JavaME, now soon iPhone). The servlet writes out data using the following code:</p> <pre><code>DataOutputStream dos = new DataOutputStream(out); dos.writeInt(someInt); dos.writeUTF(someStri...
<p>You'll have to do the demarshalling yourself; fortunately, it's fairly straightforward. Java's <code>DataOutputStream</code> class writes integers in big-endian (network) format. So, to demarshall the integer, we grab 4 bytes and unpack them into a 4-byte integer.</p> <p>For UTF-8 strings, <code>DataOutputStream<...
Processes and threads <p>1a)Are MS Word and MS PowerPoint different processes or threads of a single process?</p> <p>b)How does a spell checker routine (common to both, word and PowerPoint) used? I mean is the code copied 2 times for each of the processes in the main memory,</p> <ul> <li>if they are different process...
<p>They are different processes that happen to have overlap in [certain] functionality.</p>
How can I remove default banner of web server from response - Apache http1.1 coyote <p>Please let me know how can I remove default banner of web server from response - Apache http1.1 coyote</p>
<p>If you're talking about the generated line at the bottom of apache generated pages, you have to update your httpd.conf with this command:</p> <pre><code>ServerSignature Off </code></pre> <p>See <a href="http://httpd.apache.org/docs/2.2/mod/core.html#serversignature" rel="nofollow">http://httpd.apache.org/docs/2.2/...
MVC architecture question for Mac application <p>I have a controller class from which I call a method of model class. Now from this model class method I want to update textView object which is a data member of controller class continuously. I have method in the controller class to edit this textView. I tried creating a...
<p>You should look into using KVO - Key Value Observing - that way you can have an observer do all of the work for you.</p> <p>I wonder if your connection to the NSTextView is missing - it won't give you an error if you try to pass a message to a nil object in Objective C.</p>
How do I get the current state of a thread (e.g. blocking, suspended, running, etc..) in win32? <p>I couldn't find a documented API that yields this information.</p> <p>A friend suggested I use NtQuerySystemInformation. After looking it up, the information is there (see <a href="http://undocumented.ntinternals.net/Use...
<p>NtQuerySystemInformation is totally documented and the best method. The other answer is completely off topic</p>
Any have a Visual Studio shortcut/macro for toggling break on handled/unhandled exceptions? <p>I've been trying to write a macro do do the equivalent of </p> <ol> <li>Hitting Ctrl+Alt+E to bring up the Exceptions window</li> <li>Toggling the textbox in the 'thrown' column for 'Common Language Runtime Exceptions'</li> ...
<p>A similar question was posted and answered <a href="http://stackoverflow.com/questions/958011/toggle-break-when-an-exception-is-thrown-using-macro-or-keyboard-shortcut">here</a>. It works for all CLR exceptions and takes ~1.5s to execute.</p>
Lucene.Net and Geosearch - is it outthere somewhere? <p>I've found an interesting article about Lucene and geosearching:</p> <p><a href="http://sujitpal.blogspot.com/2008/02/spatial-search-with-lucene.html" rel="nofollow">http://sujitpal.blogspot.com/2008/02/spatial-search-with-lucene.html</a></p> <p>Is there an equi...
<p>I came across this article, as well. I do not see a .NET-specific in my Googling, so I am planning on probably porting this code when the need arises, as well. Right now, I am just getting my feet wet with Lucene.NET and have not gotten to the point that I am comfortable enough with it to start extending it, yet.<...
Why does every build change the exe-file? <p>Building the same project (without any changes) produces <strong>binary different</strong> exe-files: some small regions of them are different. Empty project, version information (and auto-increment on every build) is turned off.</p> <p>Why it happens? And is it possible to...
<p>The various structures in the PE executable file format used by Windows include timestamps that are set by the compiler and linker.</p> <p>It is possible to post-process the file to reset these values to a defined constant (I wrote a tool to do exactly this for a secure product that needed exact hash values), but t...
IIS7 shows welcome screen in Firefox, Internet Explorer works correctly <p>Has anyone encountered the following problem: I have IIS7 running on my computer. On that same computer, I open IE7 and the website works (<a href="http://localhost/web.site/Default.aspx" rel="nofollow">http://localhost/web.site/Default.aspx</a>...
<p>One browser accesses your server via 127.0.0.1, and another via your external IP.</p> <p>Make sure virtualhost works with all network interfaces.</p>
Signaling validation errors in assigning a virtual attribute? <p>This is a Rails/ActiveRecord question.</p> <p>I have a model which basically has to represent <em>events</em> or performances. Each event has many <em>attributions</em>: an attribution is basically something like "In this event, Person X had Role Y".</p>...
<p>First of all, you're attributing the Person to the Event incorrectly. You should instead pass a Person's ID to the event, rather than a string of the person's name. For instance, what if a Person with an ID of 230404 and a name of "Elvis Costello" changes his name to "Britney Spears?" Well, if that were to happen, t...
Can I convert a C# string value to an escaped string literal <p>In C#, can I convert a string value to a string literal, the way I would see it in code? I would like to replace tabs, newlines, etc. with their escape sequences.</p> <p>If this code:</p> <pre><code>Console.WriteLine(someString); </code></pre> <p>produc...
<p>I found this:</p> <pre><code>private static string ToLiteral(string input) { using (var writer = new StringWriter()) { using (var provider = CodeDomProvider.CreateProvider("CSharp")) { provider.GenerateCodeFromExpression(new CodePrimitiveExpression(input), writer, null); ...
variable not being passed? <p>I have this code</p> <pre><code>while($row = mysql_fetch_row($result)) { echo '&lt;tr&gt;'; $pk = $row[0]['ARTICLE_NO']; foreach($row as $key =&gt; $value) { echo '&lt;td&gt;&lt;a href="#" onclick="GetAuctionData(\''.$pk.'\')"&gt;' . $value . '&lt;/a&gt;&lt;/td&gt;'; } </code></pre> <p>...
<p>mysql_fetch_row <a href="http://no.php.net/manual/en/function.mysql-fetch-row.php" rel="nofollow">link</a> does not have subarrays. It will return the first field as 0, next as 1, etc. </p> <p>Try with </p> <pre><code>$pk = $row[0]; </code></pre> <p>This can easily be used with your foreach</p> <pre><code>while(...
Hibernate and Oracle native functions <p>I have an entity that maps to an external oracle table which is one of the primary data sources of my application. This entity is modelled using hibernate.</p> <p>The oracle table now has a complex function defined the calculates some special values. I need to call this functio...
<p>I have a solution using the @Formula annotation</p>
ASP.Net: Users are logged out when deploying a new file to the server <p>Everytime I upload a file to my ASP.NET site, all users are logged out (aka, I guess their session become invalidated). </p> <p>Is there any way to "hotswap" the code in ASP.NET so that this doesn't happen? Compile before deploying etc. </p> <p>...
<p>You could store your session in a <a href="http://msdn.microsoft.com/en-us/library/ms229862(VS.80).aspx" rel="nofollow">SQL database</a>, thus the application restart would not lose your sessions.</p> <p>Having precompiled non updatable code to deploy would make your xcopy faster alright but app pool would still be...
How to access previous/next element while for looping? <p>Is there a way to access a list(or tuple, or other iterable)'s next, or previous element while looping through with for loop?</p> <pre><code>l=[1,2,3] for item in l: if item==2: get_previous(l,item) </code></pre>
<p>Expressed as a generator function:</p> <pre><code>def neighborhood(iterable): iterator = iter(iterable) prev = None item = iterator.next() # throws StopIteration if empty. for next in iterator: yield (prev,item,next) prev = item item = next yield (prev,item,None) </code>...
Autotools : how to set global compilation flag <p>I have a project with several sources directories : </p> <pre><code>src/A /B /C </code></pre> <p>In each, the Makefile.am contains </p> <pre><code>AM_CXXFLAGS = -fPIC -Wall -Wextra </code></pre> <p>How can avoid repeating this in each source folder ? </p> <p>...
<p>You can do several things:</p> <p>(1) One solution is to include a common makefile fragment on all your <code>Makefile.am</code>s:</p> <pre><code>include $(top_srcdir)/common.mk ... bin_PROGRAMS = foo foo_SOURCES = ... </code></pre> <p>in that case you would write</p> <pre><code>AM_CXXFLAGS = -fpic -Wall -Wextra...
how to block a superclass method to be called to a subclass <p>I'm extending the functionality of a class with a subclass, and I'm doing some dirty stuff that make superclass methods dangerous (app will hang in a loop) in the context of the subclass. I know it's not a genius idea, but I'm going for the low-hanging frui...
<p>You can override whichever methods you want to block in your subclass's <code>.h</code> file. You can make <code>dangerousMethod</code> unavailable by placing the following in your <code>.h</code> file.</p> <pre><code>- (int)dangerousMethod __attribute__((unavailable("message"))); </code></pre> <p>This will make ...
How to pass server-side error messages to ASP.NET Ajax client? <p>An example scenario:</p> <ol> <li>User performs an update, for example a drag &amp; drop. This is an ajax request.</li> <li>Server-side code cannot validate the update or the operation just fails. An exception is thrown.</li> <li>A reasonable error mess...
<p>You can try adding the error,handler directly in Ajax framework like this:</p> <p><a href="http://encosia.com/how-to-improve-aspnet-ajax-error-handling/" rel="nofollow">http://encosia.com/how-to-improve-aspnet-ajax-error-handling/</a></p>
Is UML a good notation for messaging systems? <p>Ever since the publication of <a href="http://rads.stackoverflow.com/amzn/click/0321200683" rel="nofollow">Enterprise Integration Patterns</a> people have been using the notation introduced in that book for documenting asynchronous heterogenous messaging systems.</p> <p...
<p>UML provides a mechanism for extension through <a href="http://en.wikipedia.org/wiki/Profile_%28UML%29" rel="nofollow">profiles</a></p> <p>A profile allows you to specify stereotypes, tagged values, and constraints.</p> <p>Every stereotype can have an optional stereotype icon.</p> <p>Perhaps there is an EIP profi...
What advice can you give me for writing a meaningful benchmark? <p>I have developed a framework that is used by several teams in our organisation. Those "modules", developed on top of this framework, can behave quite differently but they are all pretty resources consuming even though some are more than others. They all...
<p>Your question is pretty broad, so unfortunately my answer will not be very specific either.</p> <p>First, benchmarking is hard. Do not underestimate the effort necessary to produce meaningful, repeatable, high-confidence results.</p> <p>Second, what is your performance goal? Is it throughput (transaction or oper...
How to run my program on before logout on windows XP? <p>I am looking for an inverse version of "RunOnceEx".</p> <p>RunOnceEx does run some program, before the user's shell(desktop&amp;taskbar) start. The login progress will not continue before the runonceex complete.</p> <p>I want to do exact the same but on user lo...
<p>Warning, as said <a href="http://www.eggheadcafe.com/software/aspnet/30020406/trouble-getting-logoff-sc.aspx" rel="nofollow"><strong>here</strong></a>, <code>gpedit.msc</code> will allow you to configure a logoff script <strong>for <em>all</em> users</strong>.</p> <p>If you need that script only for one user, you n...
WebPartManager & Mobile Controls <p>Can WebPartManager be used with web parts constructed from mobile web controls? If possible, should it be done?</p>
<p>I looks promising and you just have to tried it out. In mobile development you always need to have full control of the generated output, and this looks like a tool to do a part of the job. </p> <p>But remember many devices have issues of their own, so you need to be able to control every part of your output. So far...
How do I redirect URLS that begin with /test/ to a separate script? <p>I have an existing htaccess that works fine:</p> <pre><code>RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule (.*) /default.php DirectoryIndex index.php /default.php </code></pre> <p>I wish to modi...
<p>Basically, just put <code>/test/</code> in front of your expression. Also, the parentheses are unnecessary here:</p> <pre><code>RewriteRule ^/test/ /test/default.php </code></pre>
HTTP headers encoding/decoding in Java <p>A custom HTTP header is being passed to a Servlet application for authentication purposes. The header value must be able to contain accents and other non-ASCII characters, so must be in a certain encoding (ideally UTF-8).</p> <p>I am provided with this piece of Java code by th...
<p>Again: RFC 2047 is not implemented in practice. The next revision of HTTP/1.1 is going to remove any mention of it.</p> <p>So, if you need to transport non-ASCII characters, the safest way is to encode them into a sequence of ASCII, such as the "Slug" header in the Atom Publishing Protocol.</p>
Safe stream update of file <p>We perform updates of large text files by writing new records to a temp file, then replacing the old file with the temp file. A heavily abbreviated version:</p> <pre><code>var tpath = Path.GetTempFileName(); try { using (var sf = new StreamReader(sourcepath)) using (var tf = new S...
<p>The normal way of avoiding the "delete then move fails problem" is:</p> <ul> <li>Write to file.new</li> <li>Move file.current to file.old</li> <li>Move file.new to file.current</li> <li>Delete file.new</li> </ul> <p>Then when you come to read, use file.new if file.current is missing, deleting file.old if you see i...
How can I customize the text color of the back button in a UINavigationController header view? <p>I'm using a custom tintColor on my UINavigationController's navigation bar, and because the color is so light I need to use dark colored text. It's relatively easy to swap out the title view, and the custom buttons I've ad...
<p>This works, solves the original question (change the Navbar BACK button - and no buttons on other toolbars, no buttons on tab bars, etc):</p> <pre><code>[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], U...
How do I determine if an email is Base64 encoded? <p>I am having difficulty determining if the body of a text email message is base64 encoded. if it is then use this line of code; making use of jython 2.2.1</p> <pre><code>dirty=base64.decodestring(dirty) </code></pre> <p>else continue as normal.</p> <p>This is the c...
<p>Try:</p> <pre><code>enc = msg['Content-Transfer-Encoding'] </code></pre> <p>It's a header so you won't be able to get it looking at the body. You should be able to get at the same place you find out the Subject.</p>
How to fill DataTable from an in-memory Excel Worksheet <p>Our client gets Excel files in Excel's HTML format.(That's the way it arrives; nobody has any control over that.) We then need to run a report based on the data in the file. Using ADO.NET (OleDbReader) results in a "External file not in expected format" excepti...
<p>Try the HTML Agility Pack: <a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow">http://www.codeplex.com/htmlagilitypack</a></p> <p>I use it in a similar scenario. In my case:...</p> <ul> <li>someone pasted a table from excel into the clipboard</li> <li>retrieve the HTML text</li> <li>use HTML Agility b...
JavaScriptSerializer C# and Generics (newbie mistakes I think!) <p>WinForms C#.. am getting some JSON in the format below (bottom of message) and trying to deserialise using:</p> <p>using System.Web.Script.Serialization;</p> <p>When I had simply this json returned:</p> <pre><code>{ "objects": [ { "catego...
<p>This seems to work fine (And no wacky string trimming!):</p> <pre><code>using System; using System.Collections.Generic; using System.Web.Script.Serialization; class Program { static void Main( string[] args ) { string json = System.IO.File.ReadAllText( "../../input.json" ); var serializer = new ...
How can you write info to a Windows "global (in-memory) variable" than can be shared by various applications, using Windows APIs? <p>Maybe this cannot be done, but please help or suggest how this can be achieved without writing something to disk.</p> <p>Lets suppose there are two string values that I want to share bet...
<p>What you probably want to do is create a memory-mapped file. You can create a memory-mapped file that doesn't have any backing store on disk, but is instead backed by the system page file. Have a look at the documentation for <a href="http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx" rel="nofollow"><code...
How to bind a click event on a recently added <a> tag in jquery <p>I have 6 links on a page to an mp3.</p> <p>The plugin I installed replaces those links with a swf and plays that mp3 inline.</p> <p>The problem I <em>had</em> was that it was possible to activate all 6 links and have all audio playing at once. I <em>s...
<p>Use event delegation - this means binding the click to some container and let that handle the event. You can then query the event.target to see if it was an anchor that was clicked then do you required behaviour. This is better for a number of reasons.</p> <ol> <li>Less events bound to elements (performance)</li> <...
Visual Studio C#-settings and StyleCop (MS Source Analysis) <p>Does anyone have settings for Visual Studio, in XML or a .vssettings-file, that is compatible with <a href="http://code.msdn.microsoft.com/sourceanalysis" rel="nofollow">StyleCop</a>?</p> <p>I've used the book <a href="http://rads.stackoverflow.com/amzn/cl...
<p><a href="http://www.codeplex.com/StyleCopForReSharper" rel="nofollow">StyleCop for ReSharper</a> would certainly help:</p> <p>StyleCop for ReSharper is now feature complete in that is has reached feature parity with StyleCop 4.3.</p> <p>There are 148 StyleCop rules.</p> <ul> <li>38 of these must be fixed manually...
How can I filter out the rows which contain a particular column with null or empty data in SQL? <p>In SQL, How we make a check to filter all row which contain a column data is null or empty ?<br /> For examile </p> <pre><code>Select Name,Age from MEMBERS </code></pre> <p>We need a check Name should not equal to null...
<p>This will work in all sane databases (<em>wink, wink</em>) and will return the rows for which name is not null nor empty</p> <pre><code>select name,age from members where name is not null and name &lt;&gt; '' </code></pre>
I need help: .NET Sample code to read file file properties like title and summary <p>I need help: .NET Sample code to read file file properties like title and summary in .NET</p>
<p>If I understand your question correctly, you need <a href="http://stackoverflow.com/questions/220097/readwrite-extended-file-properties-c">this post</a>. </p>
I need some help in Undo function in Java <p>I write a Text Editor with Java , and I want to add Undo function to it </p> <p>but without UndoManager Class , I need to use a Data Structure like Stack or LinkedList but the Stack class in Java use Object parameters e.g : push(Object o) , Not Push(String s) I need some ...
<p>Assuming you are using Java 5, Stack is a generic class. You can instantiate it according to the objects it should hold.</p> <p>You can then use:</p> <pre><code>Stack&lt;String&gt; stack = new Stack&lt;String&gt;(); String string = "someString"; stack.push(string); </code></pre> <p>Also note that in the case you ...
Aspect-oriented programming in Java <p>What is the best tool for Java for aspect-oriented programming? </p> <p>The requirements for a tool are of course IDE support, expressiveness and proper documentation.</p>
<p>JBossAOP and AspectJ are two commonly used, mature frameworks for AOP. Another popular choice is Spring AOP, but it lacks some of the features of the other two.</p> <p>Both JBossAOP and AspectJ have similar features, one big difference being that AspectJ relies on extensions to the Java language, whereas JBoss AOP ...
binary .dat file <p>how can access the binary data file(.DAT). i am using geonames API. can anyone help me? </p>
<p>If you are referring to the binary flat file format used by MaxMinds GeoLocation database, they offer some handy utility classes in C# and Java to access it.</p> <p><a href="http://www.maxmind.com/app/api" rel="nofollow">http://www.maxmind.com/app/api</a></p>
Wanted : review of collection libraries features / issues / performance <p>I know there are couple 3rd party collection libraries out there (C5, PowerCollections and I guess loads more of other not so complete libraries) as well as the System.Collections.Generics classes. I am however quite unsure which library use to ...
<p>I think the choice of library depends on your need for a particular type of collection. Just because one library has a great linked list, doesn't mean it has an awesome dictionary. </p> <p>But, having that said, I have generally found PowerCollections to work as my starting collection library of choice because they...
What is the Constant Value of the Underline font in Java? <p>What is the Constant Value of the Underline font in Java ?</p> <p>Font.BOLD <strong>bold</strong> font</p> <p>Font.ITALIC <em>italic</em> font</p> <p>What is the UNDERLINE font Constant ? I try all the available constants but it didn't work .</p>
<p>Looking at the <a href="http://java.sun.com/javase/6/docs/api/">Java API Specification</a>, it appears that the <a href="http://java.sun.com/javase/6/docs/api/java/awt/Font.html"><code>Font</code> class</a> does not have a constant for underlining.</p> <p>However, using the <a href="http://java.sun.com/javase/6/doc...
What are areas where you can program artificial intelligence? <p>Welcome! I very enjoyed programming artificial intelligence in my studies - neural networks, expert machines and other. But in work I develop mainly web applications. </p> <p>And now I think about returning to such programming, maybe in hobby, or maybe i...
<p>I recently started reading the book <a href="http://rads.stackoverflow.com/amzn/click/0596529325" rel="nofollow">Programming Collective Intelligence</a>. It's an excellent book which discusses exactly what you are looking for - using AI techniques in web applications.</p> <p>The book is written clearly, is easy to ...
How do I Insert or Update (or overwrite) a record using NHibernate? <p>I need to write a row to the database regardless of whether it already exists or not. Before using NHibernate this was done with a stored procedure. The procedure would attempt an update and if no rows were modified it would fallback to an insert. T...
<p>I`m using </p> <pre><code> public IList&lt;T&gt; GetByExample&lt;T&gt;(T exampleInstance) { return _session.CreateCriteria(typeof(T)) .Add(Example.Create(exampleInstance)) .List&lt;T&gt;(); } public void InsertOrUpdate&lt;T&gt;(T target) { ...
How to use library org.hibernate in java? <p>I create new project in Netbeans, but when I look the library it still using JDK 1.6 (default) I want to change into JDK 6 Update 10 but how? I already instal JDK 6 Update 10 but when I import org.hibernate the neatbeans didn't know which library that org.hibernate.</p> <p>...
<p>In Netbeans you can define a new Java Platform from Tools > Java Platforms. This brings up the platform manager. At this point you can click the "Add Platform" button and browse to the location of the new platform. You will then have multiple platforms set up and you can configure each project to use the appropriate...
variable.ToString() vs. Convert.ToString(variable) <p>Let's say I have an integer that I need to convert to a string (I might be displaying the value to the user by means of a TextBox, for example.</p> <p>Should I prefer <code>.ToString()</code> or <code>Convert.ToString()</code>. They both do the same thing (don't th...
<p>One test is </p> <pre><code>//This will set the variable test to null: string test = Convert.ToString(ConfigurationSettings.AppSettings["Missing.Value"]); //This will throw an exception: string test = ConfigurationSettings.AppSettings["Missing.Value"].ToString(); </code></pre> <p>Got the above ready example from ...
Flex intellisense forgets flash.* <p>I am using Eclipse 3.3.2 with the Flex Builder Plugin (3.0.194161) and the Flex SDK 3.2. Recently the intellisense has started forgetting about everything in the flash.* package EXCEPT flash.errors.*</p> <p>The code still compiles, but attempting to automatically resolve something ...
<p>I was able to work around the problem by adding the following SWC to my library path: FLEX_SDK\libs\player\10\playerglobal.swc</p> <p>It looks like the problem is caused by {targetPlayerMajorVersion} no longer resolving, though I have no idea how that happened.</p> <p><strong>Edit:</strong> Known bug, as described...
BlogEngine.Net Code Formatting Extension that works? <p>For months now I've been trying to find a code syntax formatting extension that works for BlogEngine.Net. I'm not fond of the behavior of the default formatting extension, and have tried a couple of others (manoli is among them), but they always seem to interact ...
<p>I would try using Windows Live Writer along w/ the Paste From Visual Studio plugin. One you go WLW, you'll never go back to that damn TinyMCE interface.</p> <p>WLW here: <a href="http://get.live.com/writer/overview" rel="nofollow">http://get.live.com/writer/overview</a></p> <p>Plugin here: <a href="http://gallery....
Simple role authentication in asp.net <p>I want to do a simple role authentication in .NET - but am lost in the profusion of apis...</p> <p>I would like to have a web.config per directory with role access like:</p> <pre><code>&lt;authorization&gt; &lt;allow roles="admin"/&gt; &lt;deny users="*"/&gt; &lt;/auth...
<p>Here is a link on a very simple Forms Authentication implementation with roles. I believe this is the most basic Forms Authentication implementation: <a href="http://www.codeproject.com/KB/web-security/formsroleauth.aspx">http://www.codeproject.com/KB/web-security/formsroleauth.aspx</a></p> <p>Here is one on the m...
How do I create a Java string from the contents of a file? <p>I've been using the idiom below for some time now. And it seems to be the most wide-spread, at least on the sites I've visited.</p> <p>Is there a better/different way to read a file into a string in Java?</p> <pre><code>private String readFile(String file)...
<h2>Read all text from a file</h2> <p>Here's a compact, robust idiom for Java 7, wrapped up in a utility method:</p> <pre><code>static String readFile(String path, Charset encoding) throws IOException { byte[] encoded = Files.readAllBytes(Paths.get(path)); return new String(encoded, encoding); } </code></pre>...
Unit testing with Entity Framework <p>I want to test my Entities that are built using Entity Framework. My concern is that using Entity Framework means directly working with data source. So any ideas how to unit testing Entity Framework based components?</p>
<p>For Enity Framework 4, this looks promising: <a href="http://msdn.microsoft.com/en-us/ff714955.aspx">Testability and Entity Framework 4.0</a></p>
Register Startup Script Control <p>I am looking to make a web control where I can register client startup scripts inline with my aspx because I hate registering in the codebehind!</p> <p>An example of what I have so far:</p> <p>&lt;Ben:StartupScript runat="server"&gt;</p> <p>var form = document.getElementById("&lt;%...
<p>it sounds like a good idea, but if you spend too much time fighting the inherited/default behaviors then it may be more trouble than it's worth</p> <p>if this is a one-shot issue, a cheap-hack solution is to just directly embed your scripts in the header of a master page ;-)</p> <p>on the other hand, allowing deve...
Navigation, background swap not having every <li> on mouseover <p>I am using the following jquery code:</p> <pre><code>$("#top ul li.corner").mouseover(function(){ $("span.left-corner").addClass("left-corner-hover"); $("span.right-corner").addClass("right-corner-hover"); $("span.content").addClass("content...
<p>are your <code>&lt;span&gt;</code> elements within your <code>&lt;li&gt;</code>? if so you could do something like:</p> <pre><code>$('#top ul li.corner').mouseover(function() { $('span.left-corner', this).addClass('left-corner-hover'); // etc... }).mouseout(function() { $('span.left-corner', this).remov...
How can I control/override the auto-complete in my iPhone app? <p>I want to control/override the auto-complete feature when a user enters text in my iPhone app.</p> <p>Specifically I'd like to auto-complete a collection of words I supply. For example say my name is BillBobJohn. When I type "billb" auto-complete will ...
<p>This is discussed here: <a href="http://forums.macrumors.com/showthread.php?t=573894" rel="nofollow">http://forums.macrumors.com/showthread.php?t=573894</a></p>
Vertically align text within input field of fixed-height without display: table or padding? <p>The line-height property usually takes care of vertical alignment, but not with inputs. Is there a way to automatically center text without playing around with padding?</p>
<p>I ran into this problem myself. I found that not specifying an input height, but using the font-height and padding combined, results in vertically aligned text.</p> <p>For instance, lets say you want to have a 42px tall input box, with a font-size of 20px. You could simply find the difference between the input he...
Is There An OSS Implementation Of Google AdWords <p>Is there an open source implementation of Google AdWords, or is the technology protected in some way (such as being patented)?</p> <p>Edit: To clarify, I'm looking for a 3rd party implementation of an AdWords-like system (that has nothing to to with Google AdWords be...
<p>Depending on what part of the system you are looking to replicate you should give <a href="http://www.openx.org/" rel="nofollow">OpenX ad server</a> a try. You can install it on your own servers or use their hosted version. There are other open source ad servers but this one seems to work pretty well.</p>
Blogs to freshen up my math (in practice) <p>My question, <a href="http://stackoverflow.com/questions/11743/useful-math-for-programmers">his question</a>, but blogs as resources to be specific.</p> <p>I find blogs great to keep up to date... refresh material...</p> <p>So do you know any blogs who tackle math-related ...
<p>Not exactly what you're asking for, but <a href="http://projecteuler.net/" rel="nofollow">Project Euler</a> freshens up <em>my</em> math skills.</p>
How can I dynamically get the set of classes from the current python module? <p>I have a python module that defines a number of classes:</p> <pre><code>class A(object): def __call__(self): print "ran a" class B(object): def __call__(self): print "ran b" class C(object): def __call__(self)...
<pre><code>import sys getattr(sys.modules[__name__], 'A') </code></pre>
Methods and Anonymous Types <p>I know that you cannot return anonymous types from methods but I am wondering how the Select extension method returns an anonymous type. Is it just a compiler trick?</p> <p>Edit</p> <p>Suppose L is a List. How does this work?</p> <pre><code>L.Select(s =&gt; new { Name = s }) </code></p...
<p>Well, it's normal type inference for generic method type arguments. For instance:</p> <pre><code>List&lt;string&gt; x = new List&lt;string&gt;(); // The compiler converts this: x.Select(y =&gt; y.Length); // Into this, using type inference: Enumerable.Select&lt;string, int&gt;(x, y =&gt; y.Length); </code></pre> ...
What are the best practices for Hardware Description Languages (Verilog, VHDL etc.) <p>What best practices should be observed when implementing HDL code?</p> <p>What are the commonalities and differences when compared to more common software development fields?</p>
<p>Sort of an old thread, but wanted to put in my $0.02. This isn't really specific to Verilog/VHDL.. more on hardware design in general... specifically synthesizable design for custom ASICs. </p> <p>This is my <em>opinion</em> based on years of industry (as opposed to academic) experience on design. They are in no ...
Running unit tests on nested functions <p>I come from the Java world, where you can hide variables and functions and then run unit tests against them using reflection. I have used nested functions to hide implementation details of my classes so that only the public API is visible. I am trying to write unit tests agai...
<p>inner doesn't exist until outer makes it. You should either move inner up to a toplevel function for testability, or have the outer test test all the possible execution paths of itself and inner.</p> <p>Do note that the inner function isn't a simple function, it's a closure. Consider this case:</p> <pre><code>de...
Can I atomically rename/replace 2 or more tables and views? <p>Given a table X and a view Y (that has the same structure as X) is there a way to rename X to Z and Y to X atomically so that no query will ever see nothing named X? Renaming X and creating the view would also be valid.</p> <p>The point would be to, as par...
<p>This is trivial in postgres and impossible in mysql.</p> <p>mysql exempts schema modifications from transactions. I have a postgres background, so that's an obvious thing to do (begin a transaction, do some stuff, commit or rollback -- postgres isn't picky about what "do some stuff" is).</p> <p>You can find a few...
Comparing 2 XML docs and applying the changes to source document <p>Here's my problem.I have 2 xmlfiles with identical structure, with the second xml containing only few node compared to first.</p> <p>File1</p> <pre><code> &lt;root&gt; &lt;alpha&gt;111&lt;/alpha&gt; &lt;beta&gt;22&lt;/beta&gt; &lt;gamma&...
<p>In XSLT you can use the <code>document()</code> function to retrieve nodes from File2 if you encounter an empty node in File1. Something like:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt; &lt;xsl:template match="...
using a vector of column names, to generate a sql statement <p>A problem that we need to solve regularly at my workplace is how to build sql statements based on user supplied table/column names. The issue I am trying to address is the commas between column names. </p> <p>One technique looks something like this.</p> ...
<p>In your case it is probably safe to assume that there is at least one column since otherwise there is no point in doing the select. In that case you could do:</p> <pre><code>selectSql = "SELECT "; selectSql += columns[0]._name; for (z = 1; z &lt; columns.size(); z++) { selectSql += ", "; selectSql += colum...
Cruisecontrol.NET & IIS7 Static File Handler Problem <p>I'm trying to get Cruisecontrol.NET running with Server 2008/IIS7 and when I try and navigate to the dashboard I get the following error: HTTP Error 404.17 - Not Found The requested content appears to be script and will not be served by the static file handler.</p...
<p>Is the dashboard set up as an application in IIS?</p> <p>I've not used IIS7, but I know in IIS6 you need to enable an application and assign it to an app pool before you can run ASPX code.</p> <p><strong>EDIT:</strong> This works in IIS6.</p> <p>Open the IISAdmin tool on the web server. Expand the web sites fol...
Dynamic logical expression parsing/evaluation in PHP? <p>I have a need to evaluate user-defined logical expressions of arbitrary complexity on some PHP pages. Assuming that form fields are the primary variables, it would need to:</p> <ul> <li>substitute"varibles" for form fields values;</li> <li>handle comparison ope...
<p>Much time has gone by since this question was asked, and I happened to be looking for an expression parser for php. I chose to use the <a href="http://symfony.com/blog/new-in-symfony-2-4-the-expressionlanguage-component" rel="nofollow">ExpressionLanguage</a> component from Symfony 2.4. It can be installed with no ...
Removing a file in a Restricted Folder in Linux <p>I have been attempting to create a new directory for my apache server. As I tried to access the new directory, I type:</p> <p>sudo /etc/init.d/apache2 restart</p> <p>But I obtain this error in the Ubuntu Terminal:</p> <p>Syntax Error on line 1 of /etc/apache2/conf.d...
<p>You've got sudo; I'm going to assume that's the standard Ubuntu "blanket" sudo that lets you do anything.</p> <p>Check out what's in the file by doing:</p> <pre><code>sudo cat /etc/apache2/conf.d/fqdn.save </code></pre> <p>Make a backup of the file, just in case:</p> <pre><code>sudo cp /etc/apache2/conf.d/fqdn.s...
JSCocoa and the iPhone <p>Now I have a stack of free time on my hands, I wanna get into iphone dev fo real.</p> <p>But Objective C scares me (a bit). It feels I'm going a bit back in time. I say this because I've spent the last 8 months coding in C++.</p> <p><a href="http://inexdo.com/JSCocoa" rel="nofollow">JSCocoa<...
<p>(Hi, I'm the JSCocoa dev) JSCocoa works on the iPhone simulator. Check out the latest version from Google svn and compile iPhoneTest2. </p> <p>To work on the iPhone, it needs libffi. I've seen <a href="http://code.google.com/p/iphone-dev/source/browse/trunk/llvm-gcc-4.0-iphone/">http://code.google.com/p/iphone-dev...
How can I make some items in a ListBox bold? <p>In Visual c# Express Edition, is it possible to make some (but not all) items in a ListBox bold? I can't find any sort of option for this in the API.</p>
<p>You need to change listbox's DrawMode to DrawMode.OwnerDrawFixed. Check out these articles on msdn:<br /> <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.drawmode.aspx">DrawMode Enumeration</a><br /> <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.drawitem.aspx">Li...
What are some good resources for learning Grails? <p>I am planning to learn Grails. Which is the best book that I should refer for this? Is there any website available on this for beginners?</p>
<p>There is good book for beginners <em>The Definitive guide to Grails</em> by Graeme Keith Rocher.</p> <p><a href="http://rads.stackoverflow.com/amzn/click/1430243775" rel="nofollow">The Definitive Guide to Grails 2</a> is out.</p>
logging for web application <p>I'm in the middle of building a pretty big site using asp.net (forms if it's of any interest), and I'm wondering if i need a logging framework such as log4net. I've used such frameworks before, but i don't see how i could put it to any use in this type of project. usually i think logging ...
<p>Heck no - logging is <em>incredibly</em> important for web applications. If you log appropriately, it makes troubleshooting <em>so</em> much easier.</p> <p>Log4Net is probably a good bet as a framework. You might also want a way of gathering logs together from multiple servers - and even if you don't use more than ...
batch file to keep one of ten lines <p>I have a file with n lines. (n above 100 millions)</p> <p>I want to output a file with only 1 of 10 lines, I can't split the file in ten part and keep only one part, as it must be a little more random. later I have to do a statistical analysis I can't afford to create a strong bi...
<p>Ok, I think I've cracked it:</p> <pre><code>findstr/N . path-to-log-file | findstr ^[0-9]*0: </code></pre> <p>(use findstr to add the line number to the beginning of the line, then again to print only lines with a line number ending in zero)</p> <p>So you'll get one line in 10, but with the linenumber and colon p...
SecurityException in ASP.net application <p>I have a web app which queries a Lucene index and it works just fine in a W2K3 server in my network. Now I got my azure code so I wanted to test the service uploading the app. In order to do that I had to install Vista (I did it in a Virtual machine) cause the Azure SDK won'...
<p>Ok, in case somebody is facing the same issues, this is the correct answer which I got from the Azure forum:</p> <blockquote> <p>This is because of the trust policy for the Windows Azure CTP. The enviroment variablies TEMP and TMP are avaliable and set up appropiately. However, System.IO.Path.GetTempPath...
MySQL stored procedure vs. multiple selects <p>Here's my scenario:</p> <p>I've got a table of (let's call them) nodes. Primary key on each one is simply "node_id".</p> <p>I've got a table maintaining a hierarchy of nodes, with only two columns: parent_node_id and child_node_id.</p> <p>The hierarchy is maintained in...
<p>"which one is likely to have the best performance? " : No one can know ! The only thing you can do is try both and MEASURE. That's sadly enough the main answer to all performance related questions... except in cases where you clearly have a O(n) difference between algorithms.</p> <p>And, by the way, "multiple paren...
Calculate time period using C <p>How do I calculate the time period between 2 dates in C (any library, etc.)? </p> <p>The program should take two (local) dates as input and provide the duration period between them as output. </p> <p>For example,</p> <pre><code>startDate = OCT-09-1976 and endDate = OCT-09-2008 shoul...
<p>Convert the dates into two struct tm structures with <a href="http://www.manpagez.com/man/3/strptime/" rel="nofollow">strptime</a></p> <p><a href="http://www.manpagez.com/man/3/difftime/" rel="nofollow">Difftime</a> gives you the difference between the two in seconds.</p> <p>Convert that into months etc with the c...
WMI invalid Class error (trying to uninstall a software on remote pc) <p>All, I am trying to uninstall a software remotely, it is working fine in the test machines, but i got problem in production servers. test machines i have used windows xp, windows 2003 server,</p> <p>production machine : windows server 2003...
<p>Win2003 doesn't have this class installed by default - you have to install it manually from the product disc.</p>
How to dynamically generate a pdf from Google's appengine? <p>I'd like to create an application that would run on Google's appengine.</p> <p>However, this application needs to be able to generate PDFs dynamically.</p> <p>How could I do this?</p>
<p>You can use the <a href="http://www.reportlab.org/rl_toolkit.html"><code>reportlab</code> library</a> to generate a PDF from Python. You can just include the ReportLab files in with your application's code, or you can include a <a href="http://code.google.com/appengine/articles/django10_zipimport.html">zip archive</...
Struts 2 & Dojo files are too heavy and affect site's performance.. Any remedies? <p>Well.. we've developed a j2ee application using struts2 ajax capabilities. We find that the dojo implementation is quite slow. We did the following things: 1. Custom build of the dojo library. (increased dojo.js from 240kb to 350kb) 2....
<p>First of all check that you did everything on the server to facilitate caching (e.g., setting right HTTP headers, compression, server-side caching, upstream caches, and so on). See <a href="http://lazutkin.com/blog/2007/feb/1/improving-performance/">Improving performance&hellip;</a> for more details.</p> <p>The goa...
THotkey with win-key support? <p>Is there anyway to get the THotkey component in delphi to support the windows key?</p> <p>Or does anyone know of a component that can do this?</p> <p>Thanks heaps!</p>
<p>IMHO it is a good thing THotKey does not support this.</p> <p>Don't use the windows key for keyboard shortcuts in your program, the "Windows Vista User Experience Guidelines" says the following under <a href="http://msdn.microsoft.com/en-us/library/bb545460.aspx">Guidelines - Interaction - Keyboard</a>:</p> <block...
How would you read input file in Scheme? <p>I am trying to input data from a .txt file into a scheme structure. Each element is separated by a tab in the data file and each structure set is on a new line. I want to be able to read in the data from one line into a structure and make a list of each structure set in the...
<p>Not really sure what structures you had in mind, but say you had a text file like the following:</p> <pre> --> cat blah.txt foo bar baz 1 2 3 4 5 aa bb cc dd ee </pre> <p>You could convert it directly into a list of lists in scheme using sed:</p> <pre> --> echo "(define mylist '("`sed -e 's/\(.*\)/(\1)/' blah.tx...
jQuery Autocomplete: Determining if entered text is not a match <p>I've got jQuery Autocomplete (UI 1.6rc2) up and running fine and when the user picks an item, it updates a hidden form value with the associated ID. How do I set the hidden form value to '0' when the text entered does not match a result from the autocom...
<p>I did this in the autocomplete function:</p> <pre><code>change: function(event, ui){ $(this).next("input[id^=person_id]").val(''); return false; </code></pre> <p>After the user selects the option and it populates my hidden input with the item ID, if any changes occur to the visible input, the hidden input val...
Monitoring a displays state in python? <p>How can I tell when Windows is changing a monitors power state?</p>
<p>It seems that, when Windows wants to start the screen saver or turn the monitor off, it will send a <code>WM_SYSCOMMAND</code> to the topmost window with a <code>wParam</code> of <code>SC_SCREENSAVE</code> (to start the screen saver) or a <code>wParam</code> of <code>SC_MONITORPOWER</code> and a <code>lParam</code> ...
Proper way to scale an SDL Surface without clipping? <p>what is the proper way to scale an SDL Surface? I found one explanation online but it required redrawing the Surface pixel by pixel. It seems like there should be some way of doing this natively through SDL rather than redrawing the image like that. I haven't been...
<p>SDL doesn't support scaled blitting. According to the documentation of <a href="http://www.libsdl.org/cgi/docwiki.cgi/SDL_BlitSurface">SDL_BlitSurface</a>:</p> <blockquote> <p>Note: the SDL blitter does not (yet) have the capability of scaling the blitted surfaces up or down like it is the case with other m...
decode a quoted printable message in php <p>I have the string which that encoded in <a href="http://en.wikipedia.org/wiki/Quoted_printable" rel="nofollow">quoted-printable</a>. How do I decode this in php?</p> <pre><code>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum felis = pede, vestibulum et,...
<p>This should help: <a href="http://us2.php.net/quoted_printable_decode" rel="nofollow">quoted_printable_decode</a></p>
How do you do a SQL style 'IN' statement in LINQ to Entities (Entity Framework) if Contains isn't supported? <p>I'm using LINQ to Entities (not LINQ to SQL) and I'm having trouble creating an 'IN' style query. Here is my query at the moment:</p> <pre><code>var items = db.InventoryItem .Include("Kind")...
<p>You can use Linq's <code>Any</code> extension method for this in some cases:</p> <pre><code>var userIds = new[] { 1, 2, 3 }; from u in Users where userIds.Any(i =&gt; i==u.Id) select u; </code></pre> <p>The generated SQL looks pretty strange in such a case, but like much Linq-to-Entities generated SQL i...
Resolving SVN merge postponed conflicts recursively <p>I have a dev branch that hasn't been touched for a while. I merged the trunk into it to integrate many fixes/changes in the main line since it was branched out, but now I have many small conflicts (merge-left/merge-right).</p> <p>I want the latest trunk revision t...
<p>I think you can use the "--accept theirs-full" option when you issue the svn merge command. That should do what you want...</p>