input
stringlengths
51
42.3k
output
stringlengths
18
55k
asp.net : IIS Service Unavailable <p>When I attempt to update the code on a IIS webserver by replacing the old code with my new code, I receive 503 Service Unavailable replys when attempting to access any of the replaced pages on the server. </p> <p>What is the cause of this failure and what steps can I take to corre...
<p>I would do a few things:</p> <p>Check the windows event logs for any web related errors.</p> <p>Check the IIS logs to see if there is anything odd with the requests.</p> <p>Double check the permissions of all the new files, make sure they match the files that do work.</p> <p>Perform an IISReset after you deploye...
Paver 0.8.1 compatibility with python 2.6 <p>Does anyone manage to bootstrap its development area using paver with python 2.6 ?</p> <p>I have install python 2.6, install paver with easy_install-2.6, everything looks fine. But when I try to launch the bootstrap method it raises an urllib2.HTTPError (: HTTP Error 404: N...
<p>You should try newer version. =) <a href="http://www.blueskyonmars.com/projects/paver/" rel="nofollow">http://www.blueskyonmars.com/projects/paver/</a></p>
Do you validate your URL variables? <p>When you're passing variables through your site using GET requests, do you validate (regular expressions, filters, etc.) them before you use them?</p> <p>Say you have the URL <a href="http://www.example.com/i=45&amp;p=custform" rel="nofollow">http://www.example.com/i=45&amp;p=cus...
<p>Yes. Without a doubt. Never trust user input.</p> <p>To improve the user experience, input fields can (and IMHO should) be validated on the client. This can pre-empt a round trip to the server that only leads to the same form and an error message.</p> <p>However, input must <strong>always</strong> be validated o...
How do I create a keyboard hook with a different thread in C#? <p>I'm creating a low level keyboard hook in c# using SetWindowsHookEx, question is how can I make the on keyboard event function run on a thread other from the main thread? Also I currently don't have a thread other then the main thread, so how can I creat...
<p>Here is the code for the <a href="http://forum.cheatengine.org/viewtopic.php?t=192699&amp;sid=d25bb4a9d48a3518bba28ec63d6510a2" rel="nofollow">C# Keyboard hook</a>.</p> <p>You just need to call Hook.CreateHook(METHODNAMEHERE); in a new Thread (see the Thread class).</p>
PHP/PDO and SQL Server connection and i18n issues <p>In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server 2005 database and store Russian texts.</p> <p>Database collation is <code>Cyrillic_General_CI_AS</code>, table collation is <code>Cyrillic_General_CI_AS</code>, column type is <code>NVARCHAR(MAX)</code>...
<p>Try executing <code>SET NAMES "charset"</code> after you connect.</p> <p>I don't know what the charset to match <code>Cyrillic_General_CI_AS</code> is, but try "Cyrillic"?</p>
bind Linux to Active Directory using kerberos <p>We are trying to bind a Linux machine (debian 4.0) to W2k3 AD. We have configured kerberos properly so that we can get TGTs. And users authenticate properly. However, PAM seems to be the sticky wicket. For example when we try to SSH to the linux machine as one of the...
<p>If you're confident everything but PAM works correctly, I suggest passing the debug option to pam_krb5.so to see if that gives a clue to what's happening.</p> <p>I'd also suggest verifying that nss-ldap is set up correctly using </p> <pre><code>getent passwd avalidusername </code></pre>
Microsoft ReportViewer: Session Expired Errors <p>The project is ASP.NET 2.0, I have never been able to reproduce this myself, but I get emails informing me it happens to clients many times a week, often a few times in a row.</p> <p>Here is the full error:</p> <p>Exception Details: </p> <blockquote> <p>Microsoft.R...
<p>We had the same problem. So far, we only found it when the session expired but they used the back button in a browser that does aggressive caching, which is fine. But the ReportViewer tried to to a refresh even though the main page did not. So, we just added some hacky Global.asax error handling:</p> <pre><code>pro...
ASP.NET xsd dataset where do I put it <p>I am trying to convert an ASP.NET website into a web application project. The conversion has gone ok I think apart from previously I had 2 xsd files in the App_Code folder. I believe this folder is not used in web applications projects, so where would I put xsd files now.</p>
<p>I don't think you have to put them anyplace in particular. For the purposes of organization you could create a data directory. If the project is small enough, I leave it in the root.</p>
Generic, annotation-driven event notification frameworks <p>While simple, interface-driven event notification frameworks in Java have been around since pre-Cambrian times (e.g. java.beans.PropertyChangeSupport), it is becoming increasingly popular for frameworks to use annotation-driven event notification instead. </p...
<p>You can already do this today with <a href="http://eventbus.org">EventBus</a>.</p> <p>Following example is from <a href="http://eventbus.org/confluence/display/EventBus/Getting+Started">EventBus Getting Started guide</a>. Statusbar that updates based on published events, and no need to register statusbar control/wi...
Lock Active Directory accounts programmatically <p>I have to lock user accounts in Active Directory programmatically in C#. </p> <p>Unfortunately it doesn't work via the userAccountControl attribute. Every time I set userAccountControl to 528 (=normal account w/ lockout flag), Active Directory won't accept the value a...
<p>Make sure the account you're using to disable the account has sufficient privileges to disable accounts. See <a href="http://msdn.microsoft.com/en-us/library/ms696026(VS.85).aspx" rel="nofollow">this example</a> from Microsoft.</p>
Compiler could not choose an overload between interface and exception <p>Trying to use an excpetion class which could provide location reference for XML parsing, found an interesting behavior - compiler could not choose between overload which consumes an interface and one which needs System.Exception when I trying to p...
<p>The line:</p> <pre><code>//fails throw new FilterXmlParseException("&lt;Filter&gt; element expected", reader); </code></pre> <p>because XmlReader doesn't implement IXmlLineInfo. I am not sure if your cast works, but the casts are not checked statically. If it actually works, it is because the concrete class (that ...
How do I add an MSAccess connection to CodeIgniter or CakePHP? <p>I'm trying to use a Microsoft Access database for a demo project that I'm thinking of doing in either CodeIgniter or CakePHP. Ignoring the possible folly of using Microsoft Access, I haven't been able to figure out precisely how the connection string cor...
<p>Try setting up a DSN and changing to the following:</p> <pre><code>$db['access']['hostname'] = "&lt;dsn name&gt;"; $db['access']['username'] = ""; $db['access']['password'] = ""; $db['access']['database'] = "&lt;dsn name&gt;"; </code></pre> <p>There's also a section in the CodeIgniter documentation that addresses ...
How do I find out when the Spring.NET root context has loaded? <p>I have a web service running, and it uses Spring.NET for it's IoCness. One of the classes needs to do some stuff when it loads (I'm using <code>AfterPropertiesSet</code>) and "some stuff" involves a call to <code>ContextRegistry.GetContext()</code>. Th...
<p>if possible, remove that call to <code>ContextRegistry.GetContext()</code>. That is a sign of bad design anyway because it couples your code very closely to the container - which I think we all agree shouldn't be the case.</p> <p>What exactly are you trying to do?</p> <p><strong>P.S</strong>: I'd also like to sugg...
IE8 loses cookies when opening a new window after a redirect <p>I'm using Internet Explorer 8 beta 2. </p> <ol> <li><p>Client performs POST on <a href="http://alpha/foo">http://alpha/foo</a></p></li> <li><p>Server responds with redirect to <a href="http://beta/bar">http://beta/bar</a></p></li> <li><p>Client performs ...
<p>I believe that IE8 uses a separate process for each window. If you're using session cookies, the new process will start with a fresh session and therefore won't be able to submit the session cookies received by the other process. Can you try using persistent cookies and see what happens?</p> <p>From <a href="http:/...
Correct behavior for interface methods that can't be implemented <p>If I have a class that needs to implement an interface but one or more of the methods on that interface don't make sense in the context of this particular class, what should I do?</p> <p>For example, lets say I'm implementing an adapter pattern where ...
<p>Any method that cannot be implemented according to the semantics of the interface should throw an <a href="http://java.sun.com/javase/6/docs/api/java/lang/UnsupportedOperationException.html" rel="nofollow">UnsupportedOperationException</a>.</p>
Creating local users on remote windows server using c# <p>Provided I have admin access, I need a way to manage (Create, modify, remove) local accounts in a remote machine from an ASP.NET client.</p> <p>I'm clueless in how to approach this. Is WMI a possibility (System.Management namespace)? Any pointers?</p>
<p>Give this a try:</p> <pre><code>DirectoryEntry directoryEntry = new DirectoryEntry("WinNT://ComputerName" &amp; ",computer", "AdminUN", "AdminPW"); DirectoryEntry user = directoryEntry.Children.Add("username", "user"); user.Invoke("SetPassword", new object[] { "password"}); ser.CommitChanges(); </code></pre> <p>If...
Isn't saying "C/C++" wrong? <p>I've seen a lot of questions around that use improperly the expression "C/C++". The reasons in my opinion are: </p> <ul> <li>Newbie C and C++ programmers probably don't understand the difference between the two languages.</li> <li>People don't really care about it since they want a gener...
<p>C/C++ is a holdout from the early days of C++, where they were much more similar than they were today. It's something that wasn't really wrong at first, but is getting more-so all the time.</p> <p>The basic structure is similar enough that most simple questions do still work between the two, though. There is an ent...
CSS - Is there a way to get rid of the selection rectangle after clicking a link? <p>Is there a way to get rid of the selection rectangle when clicking a link which does not refresh the current page entirely?</p>
<p>Do you mean the dotted outline of a target?</p> <p>Try:</p> <pre><code>:focus { outline: 0; } </code></pre> <p>This would remove all focus outlines. IT's essentially the same as onclick in JavaScript terms. You might prefer to apply this to <code>a:focus</code>.</p>
How can you make use of the add-in framework in .NET 3.0? <p>There are some updates with .NET 3.0 concerning how to create and use add-ins for your own applications. I read about some "<em>pipeline</em>" you have to create for the communication between add-in and host-application but couldn't find further information a...
<p>In addition to <a href="http://stackoverflow.com/questions/179680/how-can-you-make-use-of-the-add-in-framework-in-net-30#179727">Daniels</a> codeplex link, Jason He also has a nice wee series on using the System.AddIn namespace when developing Paint.NET starting here -</p> <p><a href="http://blogs.msdn.com/zifengh/...
Would you use C++/CLI if supported like C# & VB.NET? <p>I've always had a thing for C++/CLI. Maybe because not many developers use it... or just because it's different.</p> <p>Suppose Microsoft fully supported C++/CLI as they do VB.NET and C# (ie. LINQ, WPF, etc.). Would you use it? </p> <p>If not, why?</p>
<p>I <em>do</em> use it. Even with the relative lack of tool support, it still beats raw P/Invoke for dealing with Win32. </p> <p>As for LINQ, i don't really care to see too much more hacked into the C++ language. LINQ is usable enough as-is - if they're gonna enhance the compiler, they should work on C++ 0x support.....
Get the name of a class as a string in C# <p>Is there a way to take a class name and convert it to a string in C#? </p> <p>As part of the Entity Framework, the .Include method takes in a dot-delimited list of strings to join on when performing a query. I have the class model of what I want to join, and for reasons of ...
<p>You can't use <code>.GetType()</code> without an instance because <code>GetType</code> is a method.</p> <p>You can get the name from the type though like this:</p> <pre><code>typeof(Foo).Name </code></pre> <p>And as pointed out by Chris, if you need the assembly qualified name you can use</p> <pre><code>typeof(F...
is there something like alternate data streams on any linux filesystem? <p>On Windows NTFS there is a nice but mostly unused feature called "Alternate Data Streams" (ADS) which I recently used in a hobby-dev project.</p> <p>On Mac HFS+ there is also a similarly nice but mostly unused feature called "named forks".</p>...
<p>The problem with ADS is that Windows will "lose" those ADS streams the second that it moves to any non-NTFS filesystem. It does not consider those streams important, so oftentimes they are not kept around. You'll find they aren't accessible or disappear when over a network share, when burned to CD, put on a USB d...
Integrating with Great Plains, best way? <p>I can't find much information around the web about it. Has anyone used both eConnect and the Dynamics web services to interact (read/write) with Great Plains. I am looking for the pros and cons of both approaches.</p> <p>This product will be installed and configured on vario...
<p>Use the Great Plains Connector - full info here <a href="http://help.boomi.com/display/BOD/Great+Plains+Connector?showChildren=false" rel="nofollow">http://help.boomi.com/display/BOD/Great+Plains+Connector?showChildren=false</a></p> <p>and here for pro-cons/limitations etc.:</p> <p><a href="http://www.articlesbase...
Problem with width of auto-generated columns in DataGrid <p>Maybe world peace would be easier, but I have a problem with the widths of auto generated columns when a DataGrid has no rows. The column headings all squeeze up with no spacing between them. I've tried adding the following CSS to no avail:</p> <pre><code>t...
<p>I beleive headings are rendered as &lt;th&gt; not &lt;td&gt;. </p> <pre><code>th.gridHeader { padding-left:20px; padding-right: 20px; } </code></pre> <p>I also assume you have applied &lt;HeaderStyle CssClass="gridHeader" /&gt; in the DataGrid markup. I didn't think people used DataGrids anymnore? or i...
Convert UTC/GMT time to local time <p>We are developing a C# application for a web-service client. This will run on Windows XP PC's.</p> <p>One of the fields returned by the web service is a DateTime field. The server returns a field in GMT format i.e. with a "Z" at the end.</p> <p>However, we found that .NET seems t...
<p>For strings such as <code>2012-09-19 01:27:30.000</code>, <code>DateTime.Parse</code> cannot tell what time zone the date and time are from.</p> <p><code>DateTime</code> has a <em>Kind</em> property, which can have one of three time zone options:</p> <ul> <li>Unspecified</li> <li>Local</li> <li>Utc</li> </ul> <p>...
How can I find out when a picture was actually taken in C# running on Vista? <p>In windows XP "FileInfo.LastWriteTime" will return the date a picture is taken - regardless of how many times the file is moved around in the filesystem.</p> <p>In Vista it instead returns the date that the picture is copied from the camer...
<p>Here's as fast and clean as you can get it. By using FileStream, you can tell GDI+ not to load the whole image for verification. It runs over 10x as fast on my machine.</p> <pre><code> //we init this once so that if the function is repeatedly called //it isn't stressing the garbage man private static Re...
Editing tables with MSHTML <p>Is there a way to create/edit a table using MSHTML without resorting to editing the underlying HTML?</p>
<p>If you want to automate this you can manipulate the DOM by adding rows and cells and tables if need to the document.</p> <p>One the tables and rows are there the user can edit them like any other part of the document.</p>
Visual Designer errors, when there are no errors <p>I get errors when viewing forms and there are not any. I can close VS and reopen and it is fine. What cases this? Can it be fixed without closing?</p>
<p>Verify none of your custom user controls has any code errors.</p> <p>Also try starting up Visual Studios using <strong>devenv /resetskippkgs</strong> from the command prompt. It will reset packages if there is an error in loading.</p>
What are the limits of ruby on rails? <p>I have a memory of talking to people who have got so far in using Ruby on Rails and then had to abandon it when they have hit limits, or found it was ultimately too rigid. I forget the details but it may have had to do with using more than one database.</p> <p>So what I'd like...
<p>Rails (not ruby itself) is proud to be "Opinionated Software".</p> <p>What this means in practice is that the authors of rails have a certain target audience in mind (themselves basically) and aim rails specifically at that. If X feature isn't needed for that target audience, it doesn't get added.</p> <p>Off the t...
Are C++ Templates just Macros in disguise? <p>I've been programming in C++ for a few years, and I've used STL quite a bit and have created my own template classes a few times to see how it's done.</p> <p>Now I'm trying to integrate templates deeper into my OO design, and a nagging thought keeps coming back to me: They...
<p>Macros are a text substitution mechanism.</p> <p>Templates are a functional turing-complete language that is executed at compile time and is integrated into the C++ type system. You can think of them as a plugin mechanism for the language.</p>
Obtain file path of C# save dialog box <p>I've got a save dialog box which pops up when i press a button. However i dont want to save a file at that point, i want to take the name and place it in the text box next to the button, for the name to be used later. </p> <p>Can anybody tell me how to obtain the file path fro...
<p>Here is a sample code I just wrote very fast... instead of Console.Write you can simply store the path in a variable and use it later.</p> <pre><code>SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments); saveFileDialog1.F...
How to display DateTime with an abbreviated Time Zone? <p>I am aware of the <a href="http://msdn.microsoft.com/en-us/library/system.timezone(VS.80).aspx">System.TimeZone</a> class as well as the many uses of the <a href="http://msdn.microsoft.com/en-us/library/system.datetime.tostring(VS.80).aspx">DateTime.ToString()</...
<p>Here's my quick hack method I just made to work around this.</p> <pre><code>public static String TimeZoneName(DateTime dt) { String sName = TimeZone.CurrentTimeZone.IsDaylightSavingTime(dt) ? TimeZone.CurrentTimeZone.DaylightName : TimeZone.CurrentTimeZone.StandardName; String sNewName = ...
Mixed syntax for control structures generating syntax errors <p>I'm refactoring some PHP code and discovered that certain nested combinations of </p> <pre><code>if () : </code></pre> <p>and </p> <pre><code>if () { </code></pre> <p>generate syntax errors. Not that I would normally mix the two, but I like to do freq...
<p>This is a wild guess since I am not familiar with the grammar of PHP. But here goes:</p> <p>The problem is the second <code>else</code>. The parser can't see if this <code>else</code> is belonging to the first or the second if (counting from the beginning). In your second example there is an <code>endif</code> maki...
How do you deal with connection strings when deploying an ASP.NET site? <p>Right now our test and production databases are on the same server, but with different names. Deploying has meant editing Web.config to change all the connection strings for the correct database. A step which I forget all too frequently... </p...
<p>Use a <a href="http://weblogs.asp.net/scottgu/archive/2008/01/28/vs-2008-web-deployment-project-support-released.aspx" rel="nofollow">Web Deployment Project</a> and update the wdproj file (it's just an MSBuild file) with some post build tasks to output the correct .config file. I keep a web.config and web.release.co...
Is there a master list of the Big-O notation for everything? <p>Is there a master list of the Big-O notation for everything? Data structures, algorithms, operations performed on each, average-case, worst-case, etc.</p>
<p><a href="http://xlinux.nist.gov/dads/" rel="nofollow">Dictionary of Algorithms and Data Structures</a> is a fairly comprehensive list, and includes complexity (Big-O) in the algorithms' descriptions. If you need more information, it'll be in one of the linked references, and there's always Wikipedia as a fallback.<...
Using Office Ribbon in a Word Processor <p>I heard Microsoft allows use of commercially available Office UI controls, with the exception of competing products, such as a word processor or spreadsheet app, etc.</p> <p>How true is that?</p> <p>Also, if it is not true, do you know of any <em>free</em> Ribbon controls?</...
<p>You should look at <a href="http://blogs.msdn.com/jensenh/archive/2006/11/21/licensing-the-2007-microsoft-office-user-interface.aspx" rel="nofollow">Jensen Harris' blog entry about licensing the Office user interface</a> which explains it in great detail. However I believe the relevant point here is:</p> <blockquot...
Doesn't the ability to cast defeat the purpose of typed variables? <p>So, I'm working under the assumption that we have typed languages because we make a lot of mistakes... so typing is one way to have the compiler do a lot of checks for us and help us out a bit (please let me know if it is my assumptions that's incorr...
<p>The bottom line is that <strong>strong typing lets the compiler check things for you</strong> and <strong>casting lets you override the strong typing when necessary.</strong></p>
string symbol manipulation in batch files? <p>Is there a way to take substrings of a string with .bat/.cmd files?</p> <p>For example given the string "hello.txt" is there a way to strip the .txt?</p> <p>EDIT: Also is there a more general way to do this, not under the assumption that it is a file name or file path?</p...
<p>If this is a file passed as a parameter, you can use %~n1, like this:</p> <pre><code>test.bat ---------- echo %~n1 %~n2 c:\&gt; test.bat myfile.txt my.long.file.bat myfile my.long.file </code></pre> <p>If you know the length of the string you can use the substring operator:</p> <pre><code>echo %variable:0,4% ...
Makefile If-Then Else and Loops <p>Can someone explain how to use if-then statements and for loops in Makefiles? I can't seem to find any good documentation with examples.</p>
<p><strong>Conditional Forms</strong> </p> <p>Simple </p> <pre><code>conditional-directive text-if-true endif </code></pre> <p>Moderately Complex </p> <pre><code>conditional-directive text-if-true else text-if-false endif </code></pre> <p>More Complex </p> <pre><code>conditional-directive text-if-one-is-true ...
asp.net output data from DB without any html markup <p>I'm new to jquery and asp.net so please forgive if this is an obvious question. I'm using a jquery autocomplete plugin which requires that the page it looks up asynchronously for data is in this format as pure text only:</p> <p>product1|price1<br> product2|price2<...
<p>If you have a bare page with no master page referenced a repeater shouldn't produce any html. Make sure in the HTML view you only have:</p> <pre><code>&lt;asp:Repeater ID="outRepeater" runat="server"&gt; - your template here &lt;/asp:Repeater&gt; </code></pre> <p>An alternative would be to add a new Handler to yo...
CString maximum length <p>What is the maximum length in characters a CString object can hold?</p>
<p>Up to your available memory or INT_MAX-1 (whichever is less).</p>
What is the best encryption library in C/C++? <p>What is the best encryption library in C/C++ In terms of: </p> <ul> <li>entropy </li> <li>quality </li> <li>ease of use</li> <li>readability</li> <li>portability </li> <li>performance</li> </ul> <p>What's your favorite and why do you like it? </p>
<p>We've used <a href="http://www.openssl.org/">OpenSSL</a> with good success. Portable, standards compliant and easy to use.</p>
How do I change read/write mode for a file using Emacs? <p>If a file is set to read only mode, how do I change it to write mode and vice versa from within Emacs?</p>
<blockquote> <p>M-x toggle-read-only</p> </blockquote> <p>On my Windows box, that amounts to Alt-x to bring up the meta prompt and typing "toggle-read-only" to call the correct elisp function.</p> <p>If you are using the default keyboard bindings, </p> <blockquote> <p>C-x C-q </p> </blockquote> <p>(which you re...
Object Initializer syntax to produce correct Json <p>I am attempting to use linq to shape list of data into a particular shape to be returned as Json from an ajax call.</p> <p>Given this data:</p> <pre><code>var data = new List&lt;string&gt;(); data.Add("One"); data.Add("Two"); data.Add("Three"); </code></pre> <p>An...
<p>In json, the "c" in "c" : "One" is the property name. And in the C# world, you can't create property names on the fly (ignoring System.ComponentModel).</p> <p>Basically, I don't think you can do what you want.</p>
Can you allocate a very large single chunk of memory ( > 4GB ) in c or c++? <p>With very large amounts of ram these days I was wondering, it is possible to allocate a single chunk of memory that is larger than 4GB? Or would I need to allocate a bunch of smaller chunks and handle switching between them?</p> <p>Why??? I...
<p>Short answer: Not likely</p> <p>In order for this to work, you absolutely would <strong>have</strong> to use a 64-bit processor. Secondly, it would depend on the Operating System support for allocating more than 4G of RAM to a single process.</p> <p>In theory, it would be possible, but you would have to read the ...
Best way to add full web search to my site? <p>I need to add full web search to my site. I need something like Google Custom Search but with no ads and it has to be free. Any recommendation of a web service or open source project that can index my site and allow me to search it will be helpful.</p> <p>My site is made ...
<p>Check out Lucene. It's an open source search engine that will certainly be a fun learning experience to implement on your own site. It was originally designed by the Excite folks, I do believe.</p>
How can I cache a calculated column in rails? <p>I have a tree of active record objects, something like:</p> <pre><code>class Part &lt; ActiveRecord::Base has_many :sub_parts, :class_name =&gt; "Part" def complicated_calculation if sub_parts.size &gt; 0 return self.sub_parts.inject(0){ |sum, current| su...
<p>I suggest using association callbacks.</p> <pre><code>class Part &lt; ActiveRecord::Base has_many :sub_parts, :class_name =&gt; "Part", :after_add =&gt; :count_sub_parts, :after_remove =&gt; :count_sub_parts private def count_sub_parts update_attribute(:sub_part_count, calculate_sub_part_cou...
Encrypted database query <p>I've just found out about Stack Overflow and I'm just checking if there are ideas for a constraint I'm having with some friends in a project, though this is more of a theoretical question to which I've been trying to find an answer for some time.</p> <p>I'm not much given into cryptography ...
<p>You can do it the way you describe - effectively querying the hash, say, but there's not many systems with that requirement, because at that point the security requirements are interfering with other requirements for the system to be usable - i.e. no partial matches, since the encryption rules that out. It's the sa...
Database Null <p>I have an asp.net text form that contains numerous decimal fields that are optional. I want to selectively update the database but not inserting a "0" for fields that do not have data (maintaining the null status). </p> <p>Typically, I would create multiple functions, each with a different signature t...
<p><a href="http://msdn.microsoft.com/en-us/library/b3h38hb0(VS.80).aspx" rel="nofollow">Nullable Types</a> are meant for the same purpose. They represent value types with the possibility of having no data in them. Presence of value can be checked using HasValue property of these types.</p> <p>Pseudo code to read the ...
Delphi Project Needing runtime Packages, even with runtime Packages off <p>My Delphi7 project will not run on my clients computer if i don't have a few of the runtime packages in the path. eg rtl70.bpl</p> <p>I have <I>Build with runtime packages</I> unticked, so shouldn't they be complied into the exe?</p> <p>Edit: ...
<p>It has been a while, but it seems like there was something where you needed to (1) check build with runtime packages, and then that enables some other editor (maybe list of packages to use), and you (2) make a change there. (3) Then do a full build, and then (4) remove the runtime packages check and do another (5) ...
Percentages of subtotal in a report <p>I am using Report Designer in VS 2008. Is there a way to display the percentages of a subtotal in a crosstab report?</p>
<p>I'm assuming you want something that looks like this:</p> <pre><code>ITEM_ID | AMOUNT | % OF TOTAL ----------------------------------- 1 | 20 | 10% 2 | 30 | 15% 3 | 40 | 20% 4 | 50 | 25% 5 | 60 | 30% </code></pre> <p>The value...
Python style: multiple-line conditions in IFs <p>Sometimes I break long conditions in IFs to several lines. The most obvious way to do this is:</p> <pre><code> if (cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do_something </code></pre> <p>Isn't very very appealing visuall...
<p>You don't need to use 4 spaces on your second conditional line. Maybe use:</p> <pre><code>if (cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do_something </code></pre> <p>Also, don't forget the whitespace is more flexible than you might think:</p> <pre><code>if ( ...
What's a good and stable C++ tree implementation? <p>I'm wondering if anyone can recommend a good C++ tree implementation, hopefully one that is stl compatible if at all possible.</p> <p>For the record, I've written tree algorithms many times before, and I know it can be fun, but I want to be pragmatic and lazy if at...
<p>Take a look at <a href="http://tree.phi-sci.com/">this</a>.</p> <p>The tree.hh library for C++ provides an STL-like container class for n-ary trees, templated over the data stored at the nodes. Various types of iterators are provided (post-order, pre-order, and others). Where possible the access methods are compati...
Thread synchronization question (in java) <p>my java application has a loading task which requires two server calls which can be parallelized. So I launch a Thread t1 (doing <strong>task1</strong>) and a Thread t2 (for <strong>task2</strong>). I want then to do a specific task, <strong>task3</strong> when both other ta...
<p>You've got several options:</p> <ol> <li>If task3 is on a separate thread AND task1 and task2 threads are exclusive to their tasks (no thread pooling) and finish when the task finish, you can use {T1.join(); T2.join();} to wait for both threads. Pros: Easy. Cons: The situation is rarely that simple.</li> <li>If tas...
Is there a documented way to set the iPhone orientation? <p>I have an app where I would like to support device rotation in certain views but other don't particularly make sense in Landscape mode, so as I swapping the views out I would like to force the rotation to be set to portrait.</p> <p>There is an undocumented pr...
<p>This is long after the fact, but just in case anybody comes along who isn't using a navigation controller and/or doesn't wish to use undocumented methods:</p> <pre><code>UIViewController *c = [[UIViewController alloc]init]; [self presentModalViewController:c animated:NO]; [self dismissModalViewControllerAnimated:NO...
Issue with localizing html title of a page <p>I'm trying to localize my aspx pages. I'm done with content localization using L10n features provided by .net f/w, like resource files. But I'm finding it difficult to set local data in page titles. </p> <p>Most of the browsers, including IE and FF, shows content on window...
<p>I suspect this is a typeface issue. The browser title bar and other window ornaments are usually rendered by your OS, not by the browser itself, so if you've configured Windows to use a typeface that doesn't support the additional character glyphs required for Hindi, Arabic, etc., then you'll get the boxes instead. ...
How do I unit test a custom ant task? <p>I am writing a custom ant task that extends Task. I am using the log() method in the task. What I want to do is use a unit test while deveoping the task, but I don't know how to set up a context for the task to run in to initialise the task as if it were running in ant.</p> <p>...
<p>Or better yet, decouple the task object itself from the logic (lets call it TaskImpl) inside the task - so that you can pass in your own dependencies (e.g., the logger). Then, instead of testing the task object, you test TaskImpl -> which you can pass in the logger, and any other weird bits and pieces it might need ...
computing performance <p>I need to find out the time a function takes for computing the performance of the application / function. is their any open source Java APIs for doing the same ?</p>
<p>You're in luck as there are quite a few <a href="http://java-source.net/open-source/profilers" rel="nofollow">open source Java profilers</a> available for you.</p>
Help on Open source controls in commercial application <p>What are the implications of including a set of visual components released under a <a href="http://www.mozilla.org/MPL/MPL-1.1.html" rel="nofollow">Mozilla Public License</a> in a commercial application.</p> <p>Do I have any obligations?</p>
<p>I've found pretty good analysis on MPL (and others) by Frank Hecker here:</p> <p><a href="http://hecker.org/writings/setting-up-shop" rel="nofollow">http://hecker.org/writings/setting-up-shop</a> (search for "Mozilla Public License")</p> <p>This pretty much sums it up:</p> <blockquote> <p>For MozPL-ed source co...
Windows SharePoint Services vs. Microsoft Office SharePoint Server? <p>There's Windows SharePoint Services (WSS) and then there is Microsoft Office SharePoint Server (MOSS). MOSS considerably more expensive than WSS (which ships as part of Microsoft Server licensing).</p> <p>My question is: what does MOSS do that mak...
<p>Don't assume that WSS is free in all deployment scenarios. We got a nice wake up call when we deployed WSS in a client-facing extranet configuration. One "main site" w/ a bunch of segregated, client sub-sites. Turns out we needed to buy an "intranet license" (can't remember the exact name) for the OS. This is di...
SQL Server 2005 Performance: Distinct or full table in WHERE IN statement <p>We have two Tables:</p> <ul> <li>Document: id, title, document_type_id, showon_id</li> <li>DocumentType: id, name</li> <li>Relationship: DocumentType hasMany Documents. (Document.document_type_id = DocumentType.id)</li> </ul> <p>We wish to r...
<p>You can use a join:</p> <pre><code>SELECT DISTINCT DocumentType.* FROM DocumentType INNER JOIN Document ON DocumentType.id=Document.document_type_id WHERE Document.showon_id = 42 </code></pre> <p>I think it's the best way to do it.</p>
Processing Linux SIGnals using Gambas <p>I would like to send a (as yet undetermined) SIGnal from a bash script to a Gambas program when a specific file has been changed. </p> <p>How can I get my Gambas program to process this SIGnal?</p>
<p>If the documentation is anything to go by, this doesn't seem possible. However, I would suggest asking the same question on the Gambas mailing list (and/or link to this question on Stack Overflow). Please report back if you get an answer via the mailing list.</p>
Programmatically access currency exchange rates <p>I'm setting up an online ordering system but I'm in Australia and for international customers I'd like to show prices in US dollars or Euros so they don't have to make the mental effort to convert from Australian dollars.</p> <p>Does anyone know if I can pull up to da...
<p>You can get currency conversions in a simple format from yahoo:</p> <p>For example, to convert from GBP to EUR: <code>http://download.finance.yahoo.com/d/quotes.csv?s=GBPEUR=X&amp;f=sl1d1t1ba&amp;e=.csv</code></p>
Default segment name in rails resources routing <p>I want to create a route in my rails application along the lines of</p> <pre><code>/panda/blog /tiger/blog /dog/blog </code></pre> <p>where panda, tiger, and dog are all permalinks (for an animal class)</p> <p>The normal way of doing this</p> <pre><code>map.resourc...
<p>In rails 3.x, you can add <code>path =&gt; ""</code> to any <code>resource</code> or <code>resources</code> call to remove the first segment from the generated path.</p> <pre><code>resources :animals, :path =&gt; "" </code></pre> <hr> <pre><code>$ rake routes animals GET / {:action=&gt;"...
WHERE IN (array of IDs) <p>I have webservice which is passed an array of ints. I'd like to do the select statement as follows but keep getting errors. Do I need to change the array to a string?</p> <pre><code>[WebMethod] public MiniEvent[] getAdminEvents(int buildingID, DateTime startDate) { command.CommandTex...
<p>You can't (unfortunately) do that. A Sql Parameter can only be a single value, so you'd have to do:</p> <pre><code>WHERE buildingID IN (@buildingID1, @buildingID2, @buildingID3...) </code></pre> <p>Which, of course, requires you to know how many building ids there are, or to dynamically construct the query.</p> <...
Serialization problem <p>The situation is like this : Main project A. and a class library B. <strong>A references B</strong></p> <p>Project B has the classes that will be serialized. The classes are used in A. Now, the problem appears when from Project A I try to serialize the objects from B. An exception is thrown th...
<p>I have written a tool called <a href="http://kent-boogaart.com/blog/sertool" rel="nofollow">sertool</a> that will tell you what in your object graph cannot be serialized and how it is being referenced.</p>
SQL - state machine - reporting on historical data based on changeset <p>I want to record user states and then be able to report historically based on the record of changes we've kept. I'm trying to do this in SQL (using PostgreSQL) and I have a proposed structure for recording user changes like the following.</p> <pr...
<p>This can be done, but would be a lot more efficient if you stored the end date of each log. With your model you have to do something like:</p> <pre><code>select l1.userid from status_log l1 where l1.status='s' and l1.logcreated = (select max(l2.logcreated) from status_log l2 ...
Spring security: adding "On successful login event listener" <p>I'm new to Spring Security. How do I add an event listener which will be called as a user logs in successfully? Also I need to get some kind of unique session ID in this listener which should be available further on. I need this ID to synchronize with anot...
<p>You need to define a Spring Bean which implements <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/context/ApplicationListener.html">ApplicationListener</a>.</p> <p>Then, in your code, do something like this:</p> <pre class="lang-java prettyprint-override"><code>public void onAp...
Data from Google Analytics <p>So Google Analytics does not have an API that we can use to get our data, so is there an efficient way to programaticly fetch the data collected by Google, without logging it locally?</p> <p>Edit: I would prefer a Python or PHP solution but anything will work.</p>
<p>Google just announced that they're <a href="http://analytics.blogspot.com/2008/10/more-enterprise-class-features-added-to.html" rel="nofollow">making available a data export API for Google Analytics</a>. It sounds like that's exactly what you're looking for.</p> <p>Per their announcement, the feature's currently in...
Alternative to Html.Button<T>? <p>I know the Html.Button has been moved to the Microsoft.Web.Mvc namespace, but I really miss the generic versions that used to exist in the early Previews. </p> <p>All I want the Html.Button to do is to hit an action in my controller, but I'd rather not write the JavaScript in the onCl...
<p>The problem with the generic versions is that filters are allowed to change the actual name of the action away from the name of the method (like the [ActionName] attribute).</p>
How to JSON decode array elements in JavaScript? <p>I have a JavaScript array that, among others, contains a URL. If I try to simply put the URL in the page (the array is in a project involving the Yahoo! Maps API) it shows the URL as it should be.</p> <p>But if I try to do a redirect or simply do an 'alert' on the li...
<pre><code>var obj = jQuery.parseJSON('{"name":"John"}'); alert( obj.name === "John" ); </code></pre> <p><a href="http://api.jquery.com/jQuery.parseJSON/">See the jQuery API</a>.</p>
"TryParse / Parse like" pattern: what is the best way to implement it <p>This question is a follow-up from <a href="http://stackoverflow.com/questions/161822/how-to-indicate-that-a-method-was-unsuccessful">How to indicate that a method was unsuccessful</a>. The xxx() Tryxxx() pattern is something that can be very usefu...
<p>Making TrySomething just catch and swallow the exception is a really bad idea. Half the point of the TryXXX pattern is to avoid the performance hit of exceptions.</p> <p>If you don't need much information in the exception, you could make the DoSomething method just call TrySomething and throw an exception if it fai...
What is the best PHP lib/class to generate RSS/Atom <p>I have to produce RSS/Atom feed in various applications, and I want to know a good lib/class wich is able to produce both, and which already handle all common problems.</p> <p>For example the one I used for year does not put the right format for date, so my feed i...
<p>The <a href="http://www.phpclasses.org/package/4427-PHP-Generate-feeds-in-RSS-1-0-2-0-an-Atom-formats.html">PHP Universal Feed Generator</a> seems to be exactly what you're after - it has a simple, OO-based way of declaring a new feed and outputting it to your desired specification. </p> <p>It also has built-in dat...
Should one use < or <= in a for loop <p>If you had to iterate through a loop 7 times, would you use:</p> <pre><code>for (int i = 0; i &lt; 7; i++) </code></pre> <p>or:</p> <pre><code>for (int i = 0; i &lt;= 6; i++) </code></pre> <p>There are two considerations:</p> <ul> <li>performance</li> <li>readability </li> <...
<p>The first is more <a href="http://en.wiktionary.org/wiki/idiomatic">idiomatic</a>. In particular, it indicates (in a 0-based sense) the number of iterations. When using something 1-based (e.g. JDBC, IIRC) I might be tempted to use &lt;=. So:</p> <pre><code>for (int i=0; i &lt; count; i++) // For 0-based APIs for (...
jQuery Tips and Tricks <h2>Syntax</h2> <ul> <li><a href="http://stackoverflow.com/questions/182630/jquery-tips-and-tricks/2218129#2218129">Shorthand for the ready-event</a> by roosteronacid</li> <li><a href="http://stackoverflow.com/questions/182630/jquery-tips-and-tricks/2218135#2218135">Line breaks and chainability<...
<p><strong>Creating an HTML Element and keeping a reference</strong></p> <pre><code>var newDiv = $("&lt;div /&gt;"); newDiv.attr("id", "myNewDiv").appendTo("body"); /* Now whenever I want to append the new div I created, I can just reference it from the "newDiv" variable */ </code></pre> <p><br /> <strong>Check...
Visual Print Design for .NET <p>I have a project that I'm working on and I need to be able to print out ID cards from the program. Are there any products out there that are reasonably priced so I can design a document for print and use it in .NET? I'm trying to avoid using System.Drawing from having to do it manually b...
<p>You could use Adobe Acrobat and one of the libraries out there for writing PDFs. That would let you design the document template in Adobe Acrobat, fill it out in code, and print it in code. There are some open source PDF writers and some commercial ones. The differences lie in the feature sets.</p> <p>I've used <a ...
WorkFlow Unit Testing <p>How to unit test the windows workflows?</p>
<p>K. Scott Allen has posted <a href="http://odetocode.com/Blogs/scott/archive/2006/08/02/5492.aspx">this</a>, which provides an approach to unit testing custom activities (although he says that he is not satisfied). A similar approach is presented by Ron Jacobs <a href="http://blogs.msdn.com/rjacobs/archive/2008/08/26...
Map a network drive to be used by a service <p>Suppose some Windows service uses code that wants mapped network drives and no UNC paths. How can I make the drive mapping available to the service's session when the service is started? Logging in as the service user and creating a persistent mapping will not establish th...
<p>Use this at your own risk. (I have tested it on XP and Server 2008 x64 R2)</p> <p>For this hack you will need <a href="http://technet.microsoft.com/en-us/sysinternals/bb842062.aspx">SysinternalsSuite by Mark Russinovich</a>:</p> <p><strong>Step one:</strong> Open an elevated cmd.exe prompt (Run as administrator)</...
Determine highest .NET Framework version <p>I need to determine the highest .NET framework version installed on a desktop machine from C\C++ code. Looks like I can iterate the folders under <code>%systemroot%\Microsoft.NET\Framework</code>, but that seems kind of error prone. Is there a better way? Perhaps a registr...
<p>Use the <a href="http://en.wikipedia.org/wiki/Windows_Registry" rel="nofollow">Windows Registry</a> location <code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP</code>.</p>
C wrapper to remove users on command "ps" <p>I have one question maybe someone here can help me. If i do "ps aux --sort user" on linux console I have one list of users and their processes runing on the machine. My question is how do I remove the users name and print that list like this <strong>in a C program</strong>:<...
<pre><code>ps aux --sort user | perl -npe 's/^(\w+)//g; if ($user ne $1) {$user=$1; print "user: " . uc($user) . "\n";}' </code></pre>
What is returned when I call ToString() on an uninitialized char object property? <p>I have a c# object with a property called Gender which is declared as a char.</p> <pre><code>private char _Gender; public char Gender { get{ return _Gender; } set{ _Gender = value; } } </code></pre> <p>What string is returne...
<p>The default value of char is unicode 0, so I'd expect "\u0000" to be returned.</p>
How do I Update a GridView from a Page Method from code behind? <p>How do I update a Gridview on a aspx page from a webmethod?</p> <p>Here is my code.</p> <pre><code>[WebMethod] public static string GetDate() { return DateTime.Now.ToString(); } </code></pre> <p>I can't use the "findcontrol" or the "this" method...
<p>You can dynamically/programmatically build the GridView control. Then in your WebMethod, you can call RenderControl() method to retrieve the HTML content of the rendered GridView control. Return that content from the WebMethod and have the callback JavaScript function inject the HTML content into your placeholder ...
Is this the best way to get unique version of filename w/ Python? <p>Still 'diving in' to Python, and want to make sure I'm not overlooking something. I wrote a script that extracts files from several zip files, and saves the extracted files together in one directory. To prevent duplicate filenames from being over-writ...
<p>One issue is that there is a race condition in your above code, since there is a gap between testing for existance, and creating the file. There may be security implications to this (think about someone maliciously inserting a symlink to a sensitive file which they wouldn't be able to overwrite, but your program ru...
WCF Endpoint with Priority <p>I need WCF service with 3 endpoints </p> <ol> <li>High</li> <li>Normal</li> <li>Low</li> </ol> <p>Most of messages will come through Normal and Low Endpoints. If Message on High will appear it have to be processed asap.</p> <p>Does anyone knows how to do it ???</p>
<p>You should take a look at this great two part series from Michele Leroux Bustamante in MSDN Magazine:</p> <p><a href="http://msdn.microsoft.com/en-us/magazine/cc500646.aspx" rel="nofollow">Building a WCF Router, Part 1</a> and <a href="http://msdn.microsoft.com/en-us/magazine/cc546553.aspx" rel="nofollow">Building ...
Forking subprocesses in Perl unit tests stops prove; Test::Harness exiting <p>I have been trying to use the Perl utility/module "prove" as a test harness for some unit tests. The unit tests are a little more "system" than "unit" as I need to fork off some background processes as part of the test, Using the following......
<p><p>Note that you don't test whether <code>fork()</code> failed. You need to make sure <code>$pid</code> is <a href="http://perldoc.perl.org/functions/defined.html" rel="nofollow">defined</a> before assuming that "false" means "child." <p>Because your <code>$cmd</code> contains shell metacharacters (spaces), Perl is...
Organization of JUnit tests in projects <p>What would you consider best practice for organizing JUnit tests in a project, and why? For example, do you keep your tests next to the classes they test? Do you put them in a separate but parallel package structure? Do you use a different organization strategy entirely?</p>
<p>I use a separate but parallel package structure for several reasons.</p> <ol> <li>It keeps tests organized the same way as the application code. <li>I can easily build just the application files for distribution. <li>Test code still has access to my application code. <li>It's not as cluttered as having test code mi...
How to tell if a URL parameter needs to be encoded in Java <p>I'm writing a Java app that is accepting URL parameter values that may or may not be encoded. I need an easy way to tell whether or not I need to encode the parameter string.</p> <p>In other words, I want a function <code>boolean needsEncoding(String param...
<p>I thought I'd put this as a proposed answer so that people can vote:</p> <p>One way to handle this is to modify my contract - require clients to pass in un-encoded strings so that I know I always need to encode them.</p>
Add ScriptManager to Page Programmatically? <p>I am developing a WebPart (it will be used in a SharePoint environment, although it does not use the Object Model) that I want to expose AJAX functionality in. Because of the nature of the environment, Adding the Script Manager directly to the page is not an option, and s...
<p>I was able to get this to work by using the Page's Init event:</p> <pre><code>protected override void OnInit(EventArgs e) { Page.Init += delegate(object sender, EventArgs e_Init) { if (ScriptManager.GetCurrent(Page) == null) { S...
Eclipse PDT and .yml file, cannot open? <p>I am using Symphony framework and I have the default sandbox inside the Eclipse IDE. When I double click schema.yml instead of open in Eclipse it requests Windows to select a program to choose. I am a Visual Studio guy and I do not understand why it doesn't open in Eclipse, wh...
<p>Right click on the file, select OPEN WITH>Text Editor and it will open in the IDE</p>
Java Application Installers <p>I'm not looking for java-web-start, I'm looking for a thick-client application installation toolkit. I've got a stand-alone application that consists of several files (jar files, data files, etc) and would need to do some pretty standard installation tasks, like asking the user for targe...
<p>Not an MSI-Installer but crossplatform: <a href="http://izpack.org/">izPack</a></p> <p>It's xml-file based with it's own GUI or ant task (whtaever you prefer)</p>
How to get the most out of being a manual tester <p>As a student, I have just got my first co-op job as a manual tester. I know it is as intellectual and demanding a job as a coder, but I cannot help thinking the other way around. I love being a coder but it is my first job. So I am asking you for any advice on how I c...
<p>Automate the simple things you do frequently when manual testing. This doesn't always mean the actual testing, in most cases automated functional testing becomes harder and you get less for your time the further away you get from the code and the closer you get to the interface and the human brain. </p> <p>So for e...
Vista Window Focus Problem <p>I have an application that manages patient demographic information. Along with this data a user can scan a picture of a patient and assign that picture to a patient. When the user clicks the scan button a separate application is opened as a dialog in order to scan the image. When running t...
<p>I think you will have to make changes to your application to allow the imaging application to take the focus. I'm going to assume that your application launches the imaging application through <code>ShellExecute</code> or <code>CreateProcess</code>. If so, you can get the process handle of the launched process eithe...
What do I need to do to upgrade an application to the latest Rails version? <p>I am currently using Rails 2.1.0 and want to upgrade to Rails 2.1.1. After issuing the following command </p> <pre><code>gem update rails </code></pre> <p>I suppose that I need to change this line </p> <pre><code>RAILS_GEM_VERSION = '2.1....
<p>You'll also need to go into your application directory and run the following command:</p> <p>rake rails:update</p> <p>Then run your tests and make sure everything works.</p>
How to monitor MySQL space? <p>I downloaded a VM image of a web application that uses MySQL.</p> <p>How can I monitor its space consumption and know when additional space must be added?</p>
<p>I have some great big queries to share:</p> <p>Run this to get the Total MySQL Data and Index Usage By Storage Engine</p> <pre><code>SELECT IFNULL(B.engine,'Total') "Storage Engine", CONCAT(LPAD(REPLACE(FORMAT(B.DSize/POWER(1024,pw),3),',',''),17,' '),' ', SUBSTR(' KMGTP',pw+1,1),'B') "Data Size", CONCAT(LPAD(REPL...
ASP.NET: How to convert <A> or HtmlAnchor to static text? <p>i have a repeater that will output a series of items:</p> <pre><code>&lt;asp:repeater ... runat="Server"&gt; &lt;itemtemplate&gt; &lt;a href="&lt;%# GetItemLink(...) %&gt;"&gt;&lt;%# GetItemText %&gt;&lt;/a&gt; &lt;itemtemplate&gt; &lt;asp:repeat...
<p>Use an &lt;asp:HyperLink > control, which displays the text normally if no link is supplied.</p> <p><hr /></p> <p>Edited to include example:</p> <pre><code>&lt;asp:repeater ... runat="Server"&gt; &lt;itemtemplate&gt; &lt;asp:HyperLink ... runat="server" NavigateUrl="&lt;%# GetItemLink(...) %&gt;"&gt; &l...
Is there a Perl-compatible regular expression to trim whitespace from both sides of a string? <p>Is there a way to do this in one line?</p> <pre><code>$x =~ s/^\s+//; $x =~ s/\s+$//; </code></pre> <p>In other words, remove all leading and trailing whitespace from a string.</p>
<p>My first question is ... why? I don't see any of the single-regexp solutions to be any more readable than the regexp you started with. And they sure aren't anywhere near as fast.</p> <pre><code>#!/usr/bin/perl use strict; use warnings; use Benchmark qw(:all); my $a = 'a' x 1_000; my @x = ( " $a ...
Has and belongs to many relationship with multiple databases <p>I have a situation where I have two models, companies and permissions, where companies is in a separate database from my permissions database. This is a has and belongs to many relationship because each company can have many permissions and each permissio...
<p>Interesting question. For the sake of my own reference, let me try to summarize the solution proposed in the <em>Rails Recipe</em> book in this question's context.</p> <p>1) First add in <em>database.yml</em></p> <pre><code>permissions: adapter: mysql database: permissions username: root password: socke...
What is the difference between a deep copy and a shallow copy? <p>What is the difference between a deep copy and a shallow copy?</p>
<p>Breadth vs Depth; think in terms of a tree of references with your object as the root node.</p> <p>Shallow:</p> <p><img src="http://upload.wikimedia.org/wikipedia/en/thumb/6/6c/Pre_shallow_deep_copy.svg/120px-Pre_shallow_deep_copy.svg.png" alt="Before Copy"> <img src="http://upload.wikimedia.org/wikipedia/en/thumb...
ASP.NET session and storing objects that use COM interop <p>I'm working on an asp.net web site. We have to use com interop to interact with legacy vb6 activex components. The components in many cases rely on receiving a context object (which is itself a vb6 activex component) as a parameter. The context object is fa...
<p>I think you will very rapidly get problems with one request blocking another.</p> <p>ASP.NET by default initialises COM on its threads to put the thread in a multi-threaded apartment. VB6 components were apartment-model at best. That means that when the MTA thread creates the component, it's put into the main STA i...
How to get an error-code from a VB component into (serverside) JScript <p>I have an plain-old asp web site that makes a call to a method in a dll written in VB 6. This method sets an error code in the VB Err Object if something goes wrong. Now I want to access that error code and description set in the Err object from ...
<p>In your MyClass, add a property that holds the error info when an error event occurs, then you should be able to look at obj.MyErrorCode and find out what you need.</p>