input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How to find the next record after a specified one in SQL? <p>I'd like to use a single SQL query (in MySQL) to find the record which comes after one that I specify.</p>
<p>I.e., if the table has:</p>
<pre><code>id, fruit
-- -----
1 apples
2 pears
3 oranges
</code></pre>
<p>I'd like to be able to do a query lik... | <p>After the question's edit and the simplification below, we can change it to</p>
<pre><code>SELECT id FROM table WHERE fruit > 'apples' ORDER BY fruit LIMIT 1
</code></pre>
|
How to version control, deploy and develop php and mySQL <p>I'm working in a project where we develop php on Zend using a mySQL database and the project is about to get to a point where it will be necessary to use version control not only for the actual code but also for the database. </p>
<p>Also we are getting a goo... | <p>No, I would not force standardization on IDE for all developers. You should be standardizing on coding style, not IDEs.</p>
<p>Having a PHP/Apache/MySQL install on a developer's machine is a good idea. The only issue you may run into is the developer's machines will probably not have the exact same configuration/ru... |
Visual Source Safe - Removing files from web projects <p>I'll try to make this as straight forward as possible.</p>
<ol>
<li>Currently our team has a VSS database where our projects are stored.</li>
<li>Developers grab the code and place on their localhost machine and develop locally.</li>
<li>Designated developer gra... | <p>You number one way around this is to stop using web site projects. Web Site Projects cause visual studio to automatically add anything it finds in the project path to the project.</p>
<p>Instead, move to Web Application Projects which don't have this behavior problem.</p>
<p>Web Site projects are good for single ... |
Can Microsoft Windows Workflow route to specific workstations? <p>I want to write a workflow application that routes a link to a document. The routing is based upon machines not users because I don't know who will ever be at a given post. For example, I have a form. It is initially filled out in location A. I now w... | <p>You might also want to look at human workflow engines, as they are designed to do things such as this (and more), I'm most familiar with <a href="http://www.pnmsoft.com" rel="nofollow">PNMsoft</a>'s Sequence</p>
|
PHP - Javascript Controls <p>I'm currently developing (another) Open Source CMS in PHP and I'd like to use javascript controls especially for the admin panel. The question is, are there any open-source, freely distributable controls (for creating javascript Editable Grids, Trees, tabs etc ) that have an interface for P... | <p>I really like <a href="http://jquery.com/" rel="nofollow">jQuery</a> with their new <a href="http://ui.jquery.com/" rel="nofollow">jQuery UI</a>. Also, browse through their <a href="http://plugins.jquery.com/" rel="nofollow">plugins list</a> for more tools.</p>
<p>But you might like <a href="http://mootools.net/" r... |
Javascript/Ajax - Manually remove event handler from a Sys.EventHandlerList() <p>I have two scriptcontrols, one holds the other, and I have successfully been able to handle events from the child on the parent using:</p>
<pre><code>initialize: function()
{
this._autoComplete = $get(this._autoCompleteID);
this... | <p>I'm not sure that the "control" expando property on the DOM element is the right way to reference the control object. It is managed by the framework and as you're seeing, I think it's already munged by the time your dispose is called.</p>
<p>Have you tried using <code>$find</code> instead of <code>$get</code> and r... |
Convert XSD into SQL relational tables <p>Is there something available that could help me convert a XSD into SQL relational tables? The XSD is rather big (in my world anyway) and I could save time and boring typing if something pushed me ahead rather than starting from scratch.</p>
<p>The XSD is <a href="http://www.gr... | <p>Altova's <a href="http://www.altova.com/features_database.html">XML Spy</a> has a feature that will generate SQL DDL Script from an XSD file. XML Spy will cost you some money though.</p>
<p>Interestingly enough, a developer used a really clever trick of using an XSLT translation to create the DDL script from an XSD... |
Using a custom URL rewriter, IIS6, and urls with .htm, .html, etc <p>I have a custom site I'm building with automatic url rewriting using a custom engine. The rewriting works fine as long as the page url doesn't end in somehting like .htm or .html. For these pages it goes directly to the iis 404 page instead of hitti... | <p>Don't know if you can or would want to do this, but there is the Ionics Isapi url rewriter you can use.</p>
<p><a href="http://www.codeplex.com/IIRF" rel="nofollow">http://www.codeplex.com/IIRF</a></p>
<p>Basically install that then set a rule to remove the .html that way it hits your rewrite engine. I use it on ... |
How do regular expressions work in selenium? <p>I want to store part of an id, and throw out the rest. For example, I have an html element with an id of 'element-12345'. I want to throw out 'element-' and keep '12345'. How can I accomplish this?</p>
<p>I can capture and echo the value, like this:</p>
<pre>| storeAttr... | <p>The solution is to use the JavaScript <code>replace()</code> function with <code>storeEval</code>:</p>
<pre><code>| storeAttribute | //pathToMyElement@id | elementID |
| storeEval | '${elementID}'.replace("element-", "") | myID |
</code></pre>
<p>Now if I... |
What are the current best practices for load testing and profiling ASP.NET web applications? <p>I am tasked with improving the performance of a particular page of the website that has an extremely high response time as reported by google analytics.</p>
<p>Doing a few google searches reveals a product that came with VS... | <p>Here is an article showing how to profile using VSTS profiler.</p>
<p><a href="http://blogs.msdn.com/tess/archive/2008/10/07/using-vsts-test-and-profilers-to-troubleshoot-a-high-cpu-in-gc-issue.aspx" rel="nofollow">If broken it is, fix it you should</a></p>
<p>Also apart from all the tools why not try enabling the... |
Using Full-Text Search in SQL Server 2008 across multiple tables, columns <p>I need to search across multiple columns from two tables in my database using Full-Text Search. The two tables in question have the relevant columns full-text indexed.</p>
<p>The reason I'm opting for Full-text search:
1. To be able to search... | <p>Using FREETEXTTABLE, you just need to design some algorithm to calculate the merged rank on each joined table result. The example below skews the result towards hits from the book table.</p>
<pre><code>SELECT b.Name, a.Name, bkt.[Rank] + akt.[Rank]/2 AS [Rank]
FROM Book b
INNER JOIN Author a ON b.AuthorID = a.Autho... |
Determining the path to Outlook.exe from java? <p>I want to invoke outlook from the command line (for various reasons) and wanted to know how I go about discovering the Path to the Outlook.exe file.</p>
<p>I'm pretty sure it's stored in the registry, but was wondering how to go about reading that from Java.</p>
<p>th... | <p>I found <a href="http://javabyexample.wisdomplug.com/java-concepts/34-core-java/62-java-registry-wrapper.html" rel="nofollow">this site</a> that might be able to help you. It's a Java Registry wrapper, seems to have a lot of features but no idea how robust the implementation is.</p>
|
How to customize the background color of the standard label within a UITableViewCell? <p>I'm trying for the past several hours to figure out how to do this, but with no luck. There are several potential solutions for this when searching Google, but nothing seems to work.</p>
<p>I'm trying to customize the background c... | <p>It appears that you're assigning the text to the cell instead of the label. You probably want:</p>
<pre><code>label.text = @"Sample text here";
</code></pre>
<p>Also, you'll need to set the label's frame to what you require:</p>
<pre><code>label.frame = CGRectMake(10,10, 80, 40);
</code></pre>
<p>or directly in ... |
Handling dynamically generated controls in asp.net <p>What's the best way to handle data entered through dynamically generated controls in ASP.NET?</p>
<p>Currently, I have a group of controls that are generated in the Page_Load stage, and I need to access the data from them. It seems like it might be possible to just... | <p>The key is recreating the controls on postback.</p>
<p><a href="http://aspnet.4guysfromrolla.com/articles/092904-1.aspx" rel="nofollow">Old but good article</a> to explain how and why.</p>
<p>You can also use the request.form collection to grab the posted values.</p>
|
I am confused about SOAP namespaces <p>I am learning about SOAP implementation and have become somewhat confused regarding the appropriate namespace URI for a SOAP 1.2 Envelope. </p>
<p>The <a href="http://www.w3.org/TR/soap12-part1">w3c specification for SOAP</a> refers to the <code>"http://www.w3.org/2003/05/soap-e... | <p>It is related to the SOAP version. SOAP 1.2 uses <code>http://www.w3.org/2003/05/soap-envelope</code> for the namespace and SOAP 1.1 uses <code>http://schemas.xmlsoap.org/soap/envelope/</code>.</p>
<p>For reference, see <a href="http://www.w3.org/TR/soap/">http://www.w3.org/TR/soap/</a> and look at the envelope sec... |
Use of Print Preview in .Net Winforms <p>I am writing c# code in .Net 2008 Winforms.</p>
<p>I created a print preview window to create a report. It works fine I can preview the report and then print it. The only problem is it is not as flexible as the Office Print preview. The users cannot chose a printer other that t... | <p>Print Preview and Print are different functions and should be different menu options. Choosing Print Preview should not print your document, it is entirely likely that a user would want to see what their document looks like laid out on a page without actually printing it.</p>
<p>To print a page and allow selecting ... |
retaining list selectedIndex between data binding reloads in Flex <p>In my Flex interface, I've got a few List components that are data bound to ArrayCollections. I'm finding that when the ArrayCollections are updated (by Web services) and the data bindings for the Lists update, each List is reset and its selectedIndex... | <p>I like using the observe class found <a href="http://weblogs.macromedia.com/paulw/archives/2006/05/the_worlds_smal.html" rel="nofollow">here</a> to call a function when data changes. It takes two parameters: data to watch, and a function to call. (Saves you time of repeating setters and getters all the time)</p>
<p... |
How do you like your primary keys? <p>In a fairly animated discussion in my team I was made to think what most people like as primary keys. We had the following groups-</p>
<ol>
<li>Int/ BigInt which autoincrement are good enough primary keys.</li>
<li>There should be at least 3 columns that make up the primary key.</... | <p>If you're going to be doing any syncing between databases with occasionally connected apps, then you should be using GUIDs for your primary keys. It is kind of a pain for debugging, so apart from that case I tend to stick to ints that autoincrement.</p>
<p>Autoincrement ints should be your default, and <strong>not... |
Adding multiple function calls to a case of in delphi? <pre><code> case i of
0..99 : Function-call('bobo') ;
100..209 : function-smell('Hobo');
210..300 : function-yikes('argh');
end;
</code></pre>
<p>But what if I wanted 210..300 to call both function yikes and function smell? C... | <p>Just add a begin end block:</p>
<pre><code>case i of
0..99 : function-call('bobo') ;
100..209 : function-smell('Hobo');
210..300 : begin
function-yikes('argh');
function-smell('Hobo');
end;
end;
</code></pre>
|
Design Patterns - Architecture Astronaut <p>Perhaps my question is similar in nature to this one: <a href="http://stackoverflow.com/questions/11586/do-you-use-design-patterns">Do you use design patterns?</a></p>
<p>The programs that I write are small 50-75 K line programs mostly using <a href="http://en.wikipedia.org/... | <p>When it comes to smaller applications of this nature, I generally worry more about <a href="http://c2.com/cgi/wiki?AntiPattern">anti-patterns</a> than I do about design patterns. That said, it's really two sides to the same coin: the power of a design pattern for me is being familiar with them so as to recognize the... |
Uninstalling a Windows app installed by a nonexistent user <p>We have a .Net Winforms app running on XP machines that are not connected to the internet. We install and update this app by distributing a CD with a .MSI installer file. Users uninstall the old app from the Add or Remove Programs control panel and install t... | <p>All right, this is not an answer but just to help diagnose; can you look in the below registry key and see if there is an entry for your application? This is how Add/Remove Programs is populated:</p>
<p>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall</p>
|
splash screen w/ load assembly status <p>I'm trying to create a splash screen that shows assemblies (all referenced library) loading status. I use AppDomain.AssemblyLoad AssemblyLoadEventHandler delegate to catch what assembly is being loaded but the problem is the event is not triggered when the program initializes. I... | <p>One issue you are going to run into is that assemblies in .Net are not loaded until they are needed.</p>
<p>For instance, create a new assembly with a "Hello World" class in it, reference it with any executable, then delete the new assembly from the working directory, at no time will you notice that it is loaded.</... |
What have you used Regular Expressions for? <p>I have heard of regular expressions and only seen use cases for a few things so I don't think of using them very often. In the past I have done a couple of things and it has taken me hours to do. Later I talk to someone and they say "here is how to do it using a regular ... | <p>Many things. Including:</p>
<ul>
<li>Examining command lines</li>
<li>Parsing user input</li>
<li>Parsing various text files</li>
<li>Examining web server logs</li>
<li>Examining test results</li>
<li>Finding text in emails</li>
<li>Reading configuration files</li>
</ul>
<p>When learning regular expressions, it m... |
LINQ to SQL <p>I am finishing off a C# ASP.NET program that allows the user to build their own computer by selecting hardware components such as memory, cpu, etc from a drop down lists. The SQL datatable has 3 columns; ComputerID, Attribute and Value. The computerID is an ID that corresponds to a certain computer in my... | <p>You need to use Concat as a "Union All".</p>
<pre><code>IQueryable<ComputerAttribute> results = null;
foreach(ComputerRequirement z in requirements)
{
//must assign to a locally scoped variable to avoid using
// the same reference in all of the where methods.
ComputerRequirement cr = z;
if (results =... |
What MIME type if JSON is being returned by a REST API? <p>My REST API returns JSON. </p>
<p>I'm currently returning text/plain as the MIME type, but it feels funny.
Should I be returning <code>application/x-javascript</code> or some other type?</p>
<p>The second question is with regard to the HTTP status code for er... | <p>The <a href="http://www.ietf.org/rfc/rfc4627.txt">JSON</a> spec suggests <code>application/json</code>, and that seems to be supported by the <a href="http://www.ietf.org/rfc/rfc4627.txt">IETF</a> and <a href="http://www.iana.org/assignments/media-types/application/">IANA</a> registry.</p>
<p><strike>On the second ... |
SQL Server Enterprise Manager 2005 - stored procedures not showing up <p>When using SQL Server Management Studio from SQL Server 2005, I can connect to an instance of SQL Server 2000... but none of the stored procedures show up. Is there some trick to allow SQL Server Enterprise Manager 2005 to properly talk to SQL Ser... | <p>I'm guessing that the account that you're logging in as does not have access to execute the stored procs. If it doesn't have access to use a stored proc, SQL Server Management Studio 2005 won't show it (regardless of it you're connecting to a SQL 2000 or 2005 server)</p>
|
Cocoa Won't Capture Shift Modifier? <p>Hey All,
I have an application in which I'm trying to capture the shift key modifier to perform an action, however when I run the program and press and normal key without the shift key modifier I get a beep and the modifier and key are not sent to my keyDown event. The relevant c... | <p>First, -charactersIgnoringModifiers doesn't ignore the shift key, so you will still get shifted characters (i.e UPPERCASE and !%#$%^&*) returned from it. What's probably happening in your function is: You press shift-w, your -isEqualTo: returns false because you're comparing a lowercase 'w' and an uppercase 'W'... |
Is this a Windows XP firewall bug? <p>I have a webserver running on my Windows XP computer. I have set the firewall to allow incoming HTTP connections: Firewall settings window->'Advanced' tab->select my network connection->Settings->Services->check 'Webserver(HTTP)' checkbox. </p>
<p>Normally, this works. However, so... | <p>No, that's not a bug, you're just misunderstanding what the Services tab is for.</p>
<p>The list on that tab are for the scenario where the firewalled system also serves as a NAT gateway ("Internet Connection Sharing" or whichever name Microsoft came up with) for another computer. It's basically a form of DNAT. It ... |
http-on-examine-response observer - possible to block response from further processing? <p>I am attempting to implement a firefox extension which filters incoming HTTP responses and handles them accordingly.</p>
<p>I wish to block HTTP responses containing a specific header. Having read through some of the MDC article... | <p>Should be possible: the "subject" of that notification is a HTTP channel, on which you can call nsIRequest::cancel().</p>
<p>the page will <strong>not</strong> continue to wait for a response, though, since you blocked the response. Perhaps you've been actually looking for a way to <a href="http://stackoverflow.com... |
Can I use a Regex in an XPath expression? <p>Something like <code>.//div[@id='foo\d+]</code> to capture div tags with <code>id='foo123'</code>.</p>
<p>I'm using .NET, if that matters.</p>
| <p>As other answers have noted, <strong><a href="http://www.w3.org/TR/xpath" rel="nofollow">XPath 1.0</a> does not support regular expressions</strong>.</p>
<p><strong>Nonetheless, you have the following options</strong>:</p>
<ul>
<li><strong>Use an XPath 1.0 expression</strong> (note the <a href="http://www.w3.org/T... |
CSS issue: link is wrongly displayed <pre><code>a {
color: #000;
}
a:hover {
text-decoration: none;
color: #fff;
}
</code></pre>
<p>That is the code I use. But, none of the links I have in my pages listen to this. They abide by this instead: </p>
<pre><code>#menu li, a{
text-align: center;
displ... | <p>I think you may be mis-understanding how selectors work.</p>
<pre><code>#menu li, a { ... }
</code></pre>
<p>Means apply styles to any li descendant of a element with the id #menu <strong>and</strong> to any a found any where.</p>
<p>Did you actually intend:-</p>
<pre><code>#menu li, #menu a {...}
</code></pre>
... |
How to format a Date without using code - Format String Question <p>How can I achieve the following with a format string: Do 01.01.2009 ?
It has to work in all languages (the example would be for Germany). So there should only be the short weekday and then the short date.</p>
<p>I tried 'ddd d' (without the '). Howeve... | <pre><code>DateTime.Now.ToString("ddd dd/MM/yyyy")
</code></pre>
|
Policy to allow user to enumerate accounts only within his own OU in Active Directory <p>Is it possible to define a policy which restricts a user to enumerate only accounts in his own OU?</p>
<p>For example lets consider a domain Contosos and OUs Sales and HR.The Sales OU has two users A and B and the HR OU has users ... | <p>Don't do That!</p>
<p>But, you can create a group for each OU and put the ou users inside the group. Than you can change the permission on every other OU to deny this group the "list content" permission. I don't think that there is a way to configure this without scripting. But as the rule is simple it can be scrip... |
How do I make jQuery modify only one div, instead of all divs of the same class? <p>Each page of my site has 10 (almost) identical divs, varying only in the text within. When a certain part of a div is clicked, I want a different part of that div to be modified.</p>
<p>I'm using this code:</p>
<pre><code>$(document).... | <p>Try it like this:</p>
<pre><code>$(document).ready(function(){
$(".notLogged img").mouseover(function(){
$(this).parent().find("span").html("You must be logged in to vote.");
});
});
</code></pre>
|
What is your convention for specifying complex SQL queries in Rails? <p>I am fairly new to Rails and I was curious as to some of the conventions experts are using when they need to construct a very complex SQL query that contains many conditions. Specifically, keeping the code readable and maintainable. </p>
<p>There ... | <p>I almost never pass conditions to <code>find</code>. Usually those conditions would be valuable to add to your object model in the form of a <code>named_scope</code> or even just a class method on the model. Named scopes are nice because you can chain them, which takes a little bit of the bite out of the complexity.... |
Can my .NET Web Services be considered as a RESTful interface? <p>Happy New Year.</p>
<p>I have a bunch of SOAP Web Services. They all have an HTTP POST and GET interfaces along with the SOAP interface. I believe POST and GET are offered by default when building SOAP Web Services in .NET/Visual Studio.</p>
<p>These m... | <p>Well, it might be POX - but for true REST, the URIs themselves would be representative of the data being requested, such as /Orders/12345; is this the case?</p>
<p>Also - the data coming back would be data-centric, rather than operation-centric (which tends to be the norm for SOAP-based services). i.e. results woul... |
Best practices when applying conditional formatting in data bound controls? <p>I have a Repeater contol bound to a custom object (an EntitySpaces query) and have noticed there are a couple of ways to conditionally format the values being displayed. </p>
<p>1) From my aspx I can call a method in my code-behind and pass... | <p>Keep It Simple.</p>
<p>The more code you write (even if it is repetitive), the more errors may sneak in.</p>
<p>I prefer the first method, since you don't need the event handler, and keep all your formatting in a separate class if used more than once.</p>
|
What third-party ASP.NET controls or libraries can you not live without? <p>I am working on a project right now, and I have a few must-have controls that I include in most sites I build. Often times it strikes me that the best controls are not always that well publicized so I thought I would ask the Stack Overflow comm... | <p>Generally, I prefer to avoid dependencies whenever possible. However, there are a couple of 3rd party libraries which usually end up being used on nearly all projects:</p>
<ul>
<li>ASP.NET AJAX Toolkit</li>
<li>Log4net</li>
</ul>
<p>On many projects, I'm also using some internal libraries (compiled separately and... |
What is a cyclic data structure good for? <p>I was just reading through <a href="http://books.google.com/books?id=1HxWGezDZcgC&lpg=PP1&dq=learning%20python&pg=PA254#v=onepage&q=cyclic&f=false" rel="nofollow">"Learning Python" by Mark Lutz and came across this code sample</a>:</p>
<pre><code>
>>> L ... | <p>Lots of things. Circular buffer, for example: you have some collection of data with a front and a back, but an arbitrary number of nodes, and the "next" item from the last should take you back to the first.</p>
<p>Graph structures are often cyclic; acyclicity is a special case. Consider, for example, a graph con... |
How to get t4 files to build in visual studio? <p>When I build my c# solution the .tt files will not create the .cs file outputs. But if I right click the .tt files one at a time in solution explorer and select "Run Custom Tool" the .cs is generated, so the build tool setting is correct. What do I do to get the overall... | <p>Paul, you can also generate code at build time with <a href="http://msdn.microsoft.com/en-us/library/bb126245.aspx">TextTransform.exe</a> or <a href="http://geekswithblogs.net/EltonStoneman/archive/2008/07/25/an-msbuild-task-to-execute-t4-templates.aspx">Elton Stoneman's MSBuild task</a>. Just keep in mind that beha... |
Detecting that a ThreadPool WorkItem has completed/waiting for completion <p>For whatever reason, <code>ThreadPool</code>'s <code>QueueWorkItem</code> doesn't return an <code>IAsyncResult</code> or some other handle to the work item, which would allow to wait until it's completed. There are <code>RegisterWait...</code>... | <p>Well, you've got a race condition between fetching the WaitHandle and setting it. Do you really want the caller to be waiting forever if they happen to be a tiny bit late?</p>
<p>You should probably do some appropriate locking and keep an "I've finished" flag so that if you <em>do</em> create the WaitHandle after i... |
Methods for interacting with a Pervasive SQL database <p>I'm in the process of developing a web interface to a service business management application that uses a Pervasive SQL database to store information (not my choice, by the way). At the moment, I'm using the official Pervasive SqlClient implementation with a cust... | <p>Pervasive.SQL has a pretty solid ADO Adapter, and rocks over ODBC in most cases; I have used if successufully for years, but not without the headaches of Pervasive's syntax. In Pervasive's defense their relational engine does comply with SQL-92 and most of SQL-99. </p>
<p>What I am curious about is what parts of ... |
In Subversion can I be a user other than my login name? <p>I'd like to know how to get <code>Subversion</code> to change the name that my changes appear under.</p>
<p>I'm just starting to use <code>Subversion</code>. I'm currently using it to version control code on an XP laptop where I'm always logged in under my wif... | <p>Most Subversion commands take the <code>--username</code> option to specify the username you want to use to the repository. Subversion remembers the last repository username and password used in each working copy, which means, among other things, that if you use <code>svn checkout --username myuser</code> you never... |
Project source or published DLL's? <p>When reusing code (for example, a Util library you created), do you add its project to your solution or use a compiled/published DLL from the Util library?</p>
| <p>If an assembly is mature, not likely to change or I'm fairly certain I won't need to step into it I would reference the DLL. If it's likely that changes will be made in the assembly's project or it's likely I'll want to step into it, I reference the project.</p>
|
Why are compilers so stupid? <p>I always wonder why compilers can't figure out simple things that are obvious to the human eye. They do lots of simple optimizations, but never something even a little bit complex. For example, this code takes about 6 seconds on my computer to print the value zero (using java 1.6):</p>
... | <p>In my opinion, I don't believe it's the job of the compiler to fix what is, honestly, bad coding. You have, quite explicitly, told the compiler you want that first loop executed. It's the same as:</p>
<pre><code>x = 0
sleep 6 // Let's assume this is defined somewhere.
print x
</code></pre>
<p>I wouldn't want the c... |
Large amount of data - what is the best way to send them? <p>we have this scenario:</p>
<p>A server which contains needed data and client component which these data wants.</p>
<p>On the server are stored 2 types of data:
- some information - just a couple of strings basically
- binary data</p>
<p>We have a problem... | <p>Take a look at the W3C standard MTOM to transfer binary data as part of a SOAP service. It is efficient in that it sends as a binary and can also send as buffered chunks. It will also interop with other clients or providers:</p>
<p><a href="http://blogs.msdn.com/smguest/archive/2005/06/30/434218.aspx" rel="nofollow... |
.NET Rectangular Arrays: how to access in a loop? <p>Basically you have two ways for doing this:</p>
<pre><code>for (int x = 0; x < UPPER_X; x++)
for (int y = 0; y < UPPER_Y; y++)
{
arr1[x, y] = get_value();
arr2[y, x] = get_value();
}
</code></pre>
<p>The only difference is ... | <p>You should benchmark your particular circumstances to be sure.</p>
<p>You would think that there would be no difference for rectangular arrays (i.e. contiguously allocated memory), BUT according to this <a href="http://msdn.microsoft.com/en-us/magazine/cc163995.aspx" rel="nofollow">MSDN article</a> there is a diffe... |
Using svn with Textmate <p>Coming from IDEs with full-blown svn support such as Eclipse and Netbeans, I'm wondering what is the recommended way to use svn with Textmate? Is it all manual, ie using the command line, or are there features that allow you to diff/checkin/merge/etc in Textmate itself?</p>
| <p>There is a plugin for textmate wich can be found here: <a href="http://www.reinventar.com/2008/07/svn-plugin-for-textmate/">http://www.reinventar.com/2008/07/svn-plugin-for-textmate/</a></p>
<p>The plugin mentioned in that post is SVNMate</p>
|
Get the id of inserted row using C# <p>I have a query to insert a row into a table, which has a field called ID, which is populated using an AUTO_INCREMENT on the column. I need to get this value for the next bit of functionality, but when I run the following, it always returns 0 even though the actual value is not 0:<... | <pre><code>MySqlCommand comm = connect.CreateCommand();
comm.CommandText = insertStatement; // Set the insert statement
comm.ExecuteNonQuery(); // Execute the command
long id = comm.LastInsertedId; // Get the ID of the inserted item
</code></pre>
|
What is a RESTful way of monitoring a REST resource for changes? <p>If there is a REST resource that I want to monitor for changes or modifications from other clients, what is the best (and most RESTful) way of doing so?</p>
<p>One idea I've had for doing so is by providing specific resources that will keep the connec... | <p>Your proposed solution sounds like <a href="http://stackoverflow.com/questions/333664/simple-long-polling-example-code">long polling</a>, which could work really well.</p>
<p>You would request <code>/game/17/move/5</code> and the server will not send any data, until move 5 has been completed. If the connection drop... |
Passing Pointer To An Array Of Arrays Through Function <p>There is a pointer-to-an-Array of Arrays i.e. NameList in the code. I want the contents of each of the Arrays in the Pointer(NameList) to get printed one by one. The below code is not able do the task. Pls. help.</p>
<pre><code>int Data1[] = {10,10};
int Da... | <p>Darn it <em>litb</em>, once again you beat me to the punch by mere minutes. (If only I didn't have kids who keep waking up...)</p>
<p>Ahh, what the hell. Perhaps this will still be useful to somebody.</p>
<p><hr /></p>
<p>Oh, and just to nail this thing down:</p>
<ul>
<li>Arrays, such as <em>int a[4]</em> allo... |
Best way to have event occur n times? <p>I use the following code to create countdowns in Javascript. n is the number of times to repeat, freq is the number of milliseconds to wait before executing, funN is a function to call on each iteration (typically a function that updates part of the DOM) and funDone is the funct... | <p>This is basically the same idea as @balabaster, but it is tested, uses prototype, and has a little more flexible interface.</p>
<pre><code>var CountDownTimer = function(callback,n,interval) {
this.initialize(callback,n,interval);
}
CountDownTimer.prototype = {
_times : 0,
_interval: 1000,
_call... |
Web data grid of infragistic controls <p>I am working on a web project where i need to use web data grid of infragistic controls.
I have problem to customise the header layout. I did not find event like InisalizeLayOut in ultrawebgrid. My problem is that i want to row in header. Please give me your valuable suggations.... | <p>You need to use <code>WebHierarchicalDataGrid</code> control for representing hierarchical data structures instead <code>WebDataGrid</code>, check out the samples here <a href="http://samples.infragistics.com/aspnet/ComponentOverview.aspx?cn=hierarchical-data-grid" rel="nofollow">http://samples.infragistics.com/aspn... |
How do I add a file to Subversion that has the same name as a directory that was deleted? <p>A long time ago I had the following directory structure in my SVN repository</p>
<pre><code>trunk/
data/
levels/
1.level
2.level
...
...
...
</code></pre>
<p>But I d... | <p>Try running <code>svn update</code>. That will update the current folder's revision number and all associated metadata. You should also make sure <code>svn status</code> doesn't display anything related to this.</p>
|
Does Team Explorer integrate with VS2005 <p>I have both VS2005 and VS2008 installed on my machine. I was able to install Team Explorer 2008, but could not install Team Explorer 2005 (it kept throwing some error number 2337 which I could not resolve).</p>
<p>Currently, I am having to launch the VS2008 IDE for using sou... | <p>You must have the the 2005 version of Team Explorer installed for the TFS integration to be present in VS 2005. Visual Studio 2005 + Team Explorer 2005 can happily co-exist on a machine with Visual Studio 2008 + Team Explorer 2008 and run side by side.</p>
<p>So, to get this to work you need to work past your 2337... |
Regular expression to match line that doesn't contain a word? <p>I know it's possible to match a word and then reverse the matches using other tools (e.g. <code>grep -v</code>). However, I'd like to know if it's possible to match lines that <em>don't</em> contain a specific word (e.g. hede) using a regular expression? ... | <p>The notion that regex doesn't support inverse matching is not entirely true. You can mimic this behavior by using negative look-arounds:</p>
<pre><code>^((?!hede).)*$
</code></pre>
<p>The regex above will match any string, or line without a line break, <strong>not</strong> containing the (sub) string 'hede'.
As me... |
Add New Column in Infragistics Wingrid <p>I am using Infragistics wingrid in my application. I have assigned a datasource to my wingrid. Now i want to add a new column at a specific location.</p>
<p>Can any one please tell me how can this be performed?</p>
<p>Regards, Savan.</p>
| <p>Greetings, </p>
<p>I would add the new column to your datasource. Since the datasource is bound to the grid the column should appear. </p>
|
How to add bottom padding to a div that contains floating divs? <p>I have a div that contains other floating divs:</p>
<p><div id="parent"><br />
<div style="float:left;">text</div><br />
<div style="float:left;">text</div><br />
<div style="float:ri... | <p>In my CSS reset file i have a "clearfix" code:</p>
<pre><code>.clearfix:after {
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
.clearfix {display:inline-block;}
/* Hide from IE Mac \*/
.clearfix {display:block;}
/* End hide from IE Mac */
* html .clearfix {height:1px;}
</... |
Divide by zero error in stored procedure <p>Hi i executed the following stored procedure in .net web application. Then run the application. I got this error</p>
<p>" Divide By zero error "</p>
<p>Stored procedure:</p>
<pre><code>CREATE procedure Details(@Stringtext varchar(8000),@SearchStringtext varchar(100))
as be... | <p>Evidently:</p>
<pre><code>{ fn LENGTH(@SearchStringtext)}
</code></pre>
<p>... is evaluating to zero.</p>
|
What is the best practices in db design when I want to store a value that is either selected from a dropdown list or user-entered? <p>I am trying to find the best way to design the database in order to allow the following scenario:</p>
<ol>
<li>The user is presented with a dropdown list of Universities (for example)</... | <pre><code>CREATE TABLE university
(
id smallint NOT NULL,
name text,
public smallint,
CONSTRAINT university_pk PRIMARY KEY (id)
);
CREATE TABLE person
(
id smallint NOT NULL,
university smallint,
-- more columns here...
CONSTRAINT person_pk PRIMARY KEY (id),
CONSTRAINT person_university_fk FOREIGN K... |
How do you set up your virtual machines? <p>Recently the buzz of virtualization has reached my workplace where developers trying out virtual machines on their computers. Earlier I've been hearing from several different developers about setting up virtual machine in their desktop computers for sake of keeping their deve... | <p>I just built a real beefy machine at home so that I could run multiple VMs at once. My case is probably extreme though, but here is my logic for doing so.</p>
<p><strong>Testing</strong></p>
<p>When I test, particularly a desktop app, I typically create multiple VMs, one for each platform that my software should ... |
Vertical center an anchor tag within a fieldset <p>I am trying to vertically center an anchor within a fieldset using CSS but it always appears to align to bottom. Is there any tricks to this?</p>
| <p>You are not giving too much detail here. Besides the line-height you might also want to tweak top and bottom padding. It all depends on how much stuff you have inside the fieldset.</p>
|
Performance comparisons betweeen enum evaluations and ints <p>Would there be difference in speed between<br/></p>
<pre><code>if (myInt == CONST_STATE1)
</code></pre>
<p>and</p>
<pre><code>if (myEnum == myENUM.State1)
</code></pre>
<p>in c#?</p>
| <p>In C# Enums are in-lined to be constants by the compilier anyway, so the benefit is code legibility</p>
|
What's your most controversial programming opinion? <p>This is definitely subjective, but I'd like to try to avoid it becoming argumentative. I think it could be an interesting question if people treat it appropriately.</p>
<p>The idea for this question came from the comment thread from <a href="http://stackoverflow.c... | <p><strong>Programmers who don't code in their spare time for fun will never become as good as those that do.</strong></p>
<p>I think even the smartest and most talented people will never become truly good programmers unless they treat it as more than a job. Meaning that they do little projects on the side, or just me... |
Forcing reload of a html page after a small wait <p>I have a html page A and a link in the page which opens up page B in a new window. How to reload the page A on clicking and opening this link ? </p>
<p><strong>EDIT:</strong></p>
<p>I should have been more clear. Page B opens in a new window and not as a popup. The ... | <p>Something like this:</p>
<pre><code><a href="javascript:window.open('pageB.htm');window.location.reload();">open page b</a>
</code></pre>
|
Can Java Enumerations be merged (like Bitwise in C#)? <p>Is there a way in Java to declare an enumeration whose values can be used together? For example:</p>
<pre><code>enum FileAccess { Read, Write, ReadWrite }
</code></pre>
<p>Is it possible to define ReadWrite as <code>Read | Write</code> (or anything that would y... | <p>You use <a href="http://java.sun.com/javase/6/docs/api/java/util/EnumSet.html">EnumSet</a>:</p>
<pre><code>EnumSet<FileAccess> readWrite = EnumSet.of(FileAccess.Read, FileAccess.Write);
</code></pre>
<p>This is actually somewhat more elegant than the C#/.NET way, IMO - aside from anything else, you can easil... |
It's possible to develop for .net 2.x in Visual Studio 2008? <p>It's possible to develop only for .net 2.0 running Visual Studio 2008?</p>
<p>Thanks!</p>
| <p>Check out this article - <a href="http://weblogs.asp.net/scottgu/archive/2007/06/20/vs-2008-multi-targeting-support.aspx" rel="nofollow">http://weblogs.asp.net/scottgu/archive/2007/06/20/vs-2008-multi-targeting-support.aspx</a></p>
<p>You might be able to ditch 2005 now...</p>
<p>I still use 2.0 projects in VS 200... |
How to show all ASP.NET web application's loaded/referenced assemblies with version numbers? <p>I'd like to show a list of all used assemblies on a dedicated web page inside a ASP.NET web application for debugging and maintainance purposes (there are many instances of this web application on many different servers). Th... | <p>I think you can use AppDomain.CurrentDomain.GetAssemblies() for this, e.g something like this:</p>
<pre><code>foreach (System.Reflection.Assembly a in AppDomain.CurrentDomain.GetAssemblies())
{
Response.Write(a.FullName + "<br/>");
}
</code></pre>
|
Debugging issues <p>I have a certain application in MSVC6.0 all C code. I have it as two workspaces :</p>
<p>1.) First workspace creates a static library file, *.lib after compiling the source.</p>
<p>2.)Second workspace has a test application(main()) and links the previously generated *.lib library and creates and e... | <p>Under <strong>Project Settings / C++ / General</strong>, ensure you have debug information enabled, e.g. set to <strong>Program Database</strong>. Under <strong>Project Settings / Link / Debug</strong>, make sure <strong>Debug info</strong> is ticked and <strong>Microsoft format</strong> is selected.</p>
|
.htaccess URL is being cut at a space (I'm using Codeigniter) <p>I've used the following code to map https://live.example.com on to <a href="http://example.com/api" rel="nofollow">http://example.com/api</a></p>
<pre><code>Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^li... | <p>I got it fixed:</p>
<p>Added to apache2.conf (httpd.conf):</p>
<pre><code>RewriteMap escapemap int:escape
</code></pre>
<p>.htaccess:</p>
<pre><code>Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteCond "%{HTTP_HOST}" "^live\.domain\.com" [NC]
RewriteRule "(.*)$" "http://domain.com/api... |
VS2005 - Automatically requesting checkout of form on open, with "View Designer" <p>I'm trying to integrate our Source Control(SourceAnywhere) with VS and are getting a lot of push back because of this one issue. </p>
<p>Almost every time we open some of our Windows forms using 'View Designer' it edits the file (* ap... | <p>This usually happens when there are controls within the form that have "Dock" set. If the IDE feels it needs to resize the form, then those controls will also be resized, and all of that information needs to get re-written to the source file. In the case where you're editing a form named "Form1" this source file is ... |
Sending Keyboard Macro Commands to Game Windows <p>I wanna do a macro program for a game. But there is a problem with sending keys to only game application (game window). I am using <code>keybd_event</code> API for sending keys to game window. But I only want to send keys to the game window, not to explorer or any open... | <p>Are you retrieving the handle of the window all the time, or are you remembering it?</p>
<p>If you use the FindWindow() API, you can simply store the Handle and use the SendMessage API to send key/mouse events manually.</p>
|
Zend_Rest_Client - error on localhost <p>I am using Zend_Rest_Client to connect Zend_Rest_Server, everything seems to be allright, but when I try to get() from the server I recieve this error:</p>
<blockquote>
<p>Zend_Http_Client_Adapter_Exception:
Unable to Connect to
tcp://localhost:80. Error #10060: A
conne... | <p><a href="http://www.zfforums.com/zend-framework-components-13/web-web-services-22/http_client-raising-error-10060-a-1302.html" rel="nofollow">This thread</a> suggetss the issue may be with the 'localhost' name - try using <code>127.0.0.1</code> instead.</p>
|
Best Update Method for MySQL DB <p>I have read through the solutions to similar problems, but they all seem to involve scripts and extra tools. I'm hoping my problem simple enough to avoid that.</p>
<p>So the user uploads a csv of next week's data. It gets inserted into the DB, no problem.</p>
<p>BUT</p>
<p>an hour ... | <p>If you have a unique key on one of the fields, you can use:</p>
<pre><code>LOAD DATA LOCAL INFILE '/path/to/data.csv' REPLACE INTO TABLE table_name
</code></pre>
|
Calling a const function from a non-const object <p>I need to call a const function from a non-const object. See example</p>
<pre><code>struct IProcess {
virtual bool doSomeWork() const = 0L;
};
class Foo : public IProcess {
virtual bool doSomeWork() const {
...
}
};
class Bar
{
public:
const IProce... | <p><code>const_cast</code> is for casting <strong>away</strong> constness! </p>
<p>You're casting from non-const to const which is safe, so use <code>static_cast</code>:</p>
<pre><code> static_cast<const Bar*>(this)->getProcess().doSomeWork();
</code></pre>
<p><em>I mean techincally speaking you can cast ... |
Pros and cons of using DB id in the URL? <p>For example: <code>http://stackoverflow.com/questions/396164/exposing-database-ids-security-risk</code> and <code>http://stackoverflow.com/questions/396164/blah-blah</code> loads the same question.</p>
<p>(I guess this is DB id of Questions table? Is this standard in ASP.NET... | <p>Well, for one, simple id's are usually sequential, so it's quite easy to guess at and retrieve other data from your application.</p>
<p><a href="http://stackoverflow.com/questions/395857/doesnt-matter-what-I-type-here">http://stackoverflow.com/questions/395857/doesnt-matter-what-I-type-here</a>
<a href="http://stac... |
Calling a C# method, and make it take 10 seconds to return <p>From a web service (WCF), I want an endpoint to take 10 seconds to finish.</p>
<p>Is there a way I can do a <code>thread.sleep(10);</code> on the method?</p>
| <p>You could create a wrapper method which does the appropriate sleep.</p>
<pre><code>Thread.Sleep(TimeSpan.FromSeconds(10))
</code></pre>
|
Binding a object with a sub objects as properties to a datagrid <p>I am working with an object which has sub objects within (see example below). I am attempting to bind a <code>List<rootClass></code> to the datagrid. When I bind the <code>List<></code>, in the cell that contains the <code>subObject</code>, ... | <p>If I'm not mistaken, it shows the result of calling .ToString() on your subObject, so you can override that to return the contents of Description.</p>
<p>Have you tried just binding to Value1.Description? (I'm guessing it doesn't work).</p>
<p>I have a class that can be used instead of List when binding, that will... |
Problem with encoding after in/out of a database <p>I'm doing a bookmarking-system. But when I insert the fetched title "Chapter 4. Examples for advanced use of VLC's stream output (transcoding, multiple streaming, etc...)", it looks perfectly good in the database, but when I print it out again on the display-page, it... | <p>There is most likely a layer of your application not using utf-8. Try to isolate the problem by inserting known extended characters (e.g.âââ) into the database and into your application code and see how they are displayed.</p>
|
Custom properties in XAML of System.Windows.Window <p>I've got a very simple WPF UserControl that looks like this:</p>
<pre><code>namespace WpfControlLibrary1
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
Composite = new Composite();
Co... | <p>The syntax <code>Type.Property</code> is used to set <a href="http://msdn.microsoft.com/en-us/library/ms749011.aspx" rel="nofollow">attached properties</a>. Try this instead:</p>
<pre><code><test:UserControl1 Name="whatever">
<test:UserControl1.Composite>
<test:Composite Color="Blue"/>... |
Strange SQL2005 problem. "SqlConnection does not support parallel transactions" <p>I have a problem that seems like its a result of a deadlock-situation.
Whe are now searching for the root of the problem but meantime we wanted to restart the server and get the customer going.</p>
<p>And now everytime we start the pro... | <p>It seems to be that you are sharing connections and creating new transactions on the same open connection (this is the parallel part of the exception you are seeing).</p>
<p>Your example seems to support this as you have no mention of how you acquire the connection in it.</p>
<p>You should do a review of your code... |
How best to use XPath with very large XML files in .NET? <p>I need to do some processing on fairly large XML files ( large here being potentially upwards of a gigabyte ) in C# including performing some complex xpath queries. The problem I have is that the standard way I would normally do this through the System.XML lib... | <p>XPathReader is the answer. It isn't part of the C# runtime, but it is available for download from Microsoft. Here is an <a href="http://msdn.microsoft.com/en-us/library/ms950778.aspx" rel="nofollow">MSDN article</a>. </p>
<p>If you construct an XPathReader with an XmlTextReader you get the efficiency of a streami... |
ASP.NET: Function key shortcuts? <p>I recently participated a project that replaced a mainframe system with a web (asp.net 2.0, VS2005) system.<br/>
The 3270-terminals are still much used and I respect the IMS/CICS/Cobol application designers for their work.<br/></p>
<p>Users like the web application, but one thing th... | <p>There is nothing specific to ASP.NET for this since you would need to handle it with JavaScript. The easiest way would be to use a jQuery plugin like <a href="http://jshotkeys.googlepages.com/" rel="nofollow">js-hotkeys</a></p>
|
What is the benefit of tableless design if you need clearing blocks everywhere? <p>I understand that the goal of moving towards <code><div></code> tags from <code><table></code> makes sense since it is more semantic. However, I don't understand the benefit gained if you still need a clearing block to make c... | <p>What if I told you <a href="http://www.sitepoint.com/simple-clearing-of-floats/" rel="nofollow">you</a> <a href="http://www.innovatingtomorrow.net/2008/03/24/how-clear-floats-css" rel="nofollow">didn't</a> <a href="http://www.positioniseverything.net/easyclearing.html" rel="nofollow">need</a> a clearing block?</p>
... |
Adding Date Picker to view programatically? <p>Can someone illustrate (or point me to a good tutorial) on how to add a Date Picker to a view programatically (i.e., without using the interface editor)? </p>
| <p>It's very easy man.You can do it in seconds.</p>
<p>Just use the these methods in your.m file...all is ready</p>
<pre><code>- (void)viewDidLoad {
CGRect pickerFrame = CGRectMake(0,250,0,0);
UIDatePicker *myPicker = [[UIDatePicker alloc] initWithFrame:pickerFrame];
[myPicker addTarget:self action:@sel... |
Javascript and Translations <p>I have a PHP application that makes extensive use of Javascript on the client side. I have a simple system on the PHP side for providing translators an easy way to provide new languages. But there are cases where javascript needs to display language elements to the user (maybe an OK or ... | <p>How about feeding the javascript from php? So instead of heaving:</p>
<pre><code> <script type='text/javascript' src='jsscript.js'></script>
</code></pre>
<p>do</p>
<pre><code> <script type='text/javascript' src='jsscript.php'></script>
</code></pre>
<p>And then in the php file replace a... |
How to convert between Progress Database Character[] datatype and C# strings? <p>Progress databases allow for a Character[x] datatype. How can I write to a particular x using C# and ODBC?</p>
<p>Please do not answer unless you understand the what Character[x] means... it is not a string (array of chars), it is an arra... | <p>I figured it out. The documentation I have refers to a datatype of character[20], format x(24). character[x] (where x is a number), is like an array of strings. Format x(24) means each string in the array can be 24 characters long. </p>
<p>Essentially characters[20], format x(24) is a string that is 20 * 24 charact... |
Stop LINQ to SQL from executing select statements after insert <p>I'm using LINQ to SQL to update my database. I'm inserting a lot of records, and when I call SubmitChanges(), LINQ to SQL executes an insert and a select statement for each object. I don't really care to update my objects after they are inserted into t... | <p>You're looking for <a href="http://msdn.microsoft.com/en-us/library/system.data.linq.mapping.columnattribute.autosync.aspx" rel="nofollow">ColumnAttribute.AutoSync</a>. If you're using the designer, check each column for an Auto-Sync property and set it to Never.</p>
<p><strong>Edit:</strong>
Ok, that didn't work ... |
Mapping individual buttons on ASP.NET MVC View to controller actions <p>I have an application where I need the user to be able to update or delete rows of data from the database. The rows are displayed to the user using a foreach loop in the .aspx file of my view. Each row will have two text fields (txtName, txtDesc)... | <p>You can use multiple forms, and set the action on the form to be like this:</p>
<pre><code><form method="post" action="/YourController/YourAction/<%=rowId%>">
</code></pre>
<p>So you will have <code>YourController/YourAction/1</code>, <code>YourController/YourAction/2</code> and so on. </p>
<p>There i... |
Is there an XSLT buddy available somewhere? <p>I think a lot of people know about tools like RegexBuddy. Is there something similar for XSLT?</p>
| <p><em>XSLT IDEs</em> (Interactive Development Environments):</p>
<ul>
<li><strong><a href="http://sourceforge.net/projects/xselerator">XSelerator</a></strong> (the one I've been using for 6-7 years). Free, has a Debugger for MSXML, has intellisense for both XSLT 1.0 and XSLT 2.0. In addition has some dynamic intellis... |
ASP.NET/C# - Custom PerformanceCounters only show up in 32-bit perfmon on 64-bit system <p>I'm trying to create a set of custom performance counters to be used by my ASP.NET application. I use the following code to increment the counters:</p>
<pre><code>internal static void Increment(String instanceName, DistributedCa... | <p>I read that instantiating a PerformanceCounter is quite resource intensive. Have you thought of caching these in a Session / Application variable?</p>
<p>Also, is it wise to update the counter without locking in a multithreaded ASP.net application?</p>
<p>Patrick</p>
|
When to use a Float <p>Years ago I learned the hard way about precision problems with floats so I quit using them. However, I still run into code using floats and it make me cringe because I know some of the calculations will be inaccurate.</p>
<p>So, when is it appropriate to use a float?</p>
<p><strong>EDIT:</stro... | <p>Short answer: You only have to use a <strong>float</strong> when you know exactly what you're doing and why.</p>
<p>Long answer: <strong>floats</strong> (as opposed to <strong>doubles</strong>) aren't really used anymore outside 3D APIs as far as I know. Floats and doubles have the same performance characteristics ... |
Reference counting in PHP <p>I'd like to implement database caching functionality in PHP based on reference counts. For example, code to access the record in table <strong>foo</strong> with an ID of 1 might look like:</p>
<pre><code>$fooRecord = $fooTable->getRecord(1);
</code></pre>
<p>The first time this is cal... | <p>For php5, just make use of the destructor in the record class.</p>
<pre><code>class Table {
/* [...] */
protected $record_cache = array();
public function getRecord($id) {
if(isset($this->record_cache[$id]) return $this->record_cache[$id];
$r = $db->getRecord($id);
if($... |
Check the signature on large data sets efficiently using JCA <p>I have to verify the signature on a file that may be as large as 2Gb, and I want to do so in a way that is as memory-efficient as possible. For various reasons, the file will already be loaded completely into memory, and is accessed using an <code>InputSt... | <p>Why not just read the input stream a block (4096bytes or whatever convenient size) at a time, call update() for each block.</p>
|
Is there a foreach in MATLAB? If so, how does it behave if the underlying data changes? <p>Is there a foreach structure in MATLAB? If so, what happens if the underlying data changes (i.e. if objects are added to the set)?</p>
| <p>MATLAB's <strong>FOR</strong> loop is static in nature; you cannot modify the loop variable between iterations, unlike the <strong>for(initialization;condition;increment)</strong> loop structure in other languages. This means that the following code always prints 1, 2, 3, 4, 5 regardless of the value of B.</p>
<pre... |
How do I check out an SVN project into Eclipse as a Java project? <p>I was trying to check out a project from SVN using Eclipse. I tried using "Checkout As" to make it into a "Java project from existing Ant script", but the project wizard requires the file to have already been downloaded. Is there a way to checkout the... | <p>Here are the steps:</p>
<ul>
<li>Install the subclipse plugin (provides svn connectivity in eclipse) and connect to the repository. Instructions here:
<a href="http://subclipse.tigris.org/install.html">http://subclipse.tigris.org/install.html</a></li>
<li>Go to File->New->Other->Under the SVN category, select Check... |
SQL 2005 Query Help <p>I have table with 50 entries (users with such details like Name Surname Location etc)</p>
<p>I want to create a query that give me users from row 1 to row 10. Then another query that give me users from 11 to 20 and so on.</p>
<p>Is there any way how to do that?</p>
<p>Thanks</p>
| <p><a href="http://www.singingeels.com/Articles/Pagination_In_SQL_Server_2005.aspx" rel="nofollow">http://www.singingeels.com/Articles/Pagination_In_SQL_Server_2005.aspx</a></p>
|
Returning from inside the scope of a 'using' statement? <p>I've got some code that looks like this:</p>
<pre><code>using (DBDataContext dc = new DBDataContext(ConnectionString))
{
Main main = new Main
{
ClientTime = clientTime
};
dc.Mains.InsertOnSubmit(main);
dc.SubmitChanges();
return ma... | <p>Yes, and that's one of the big advantages of <code>using</code> it.</p>
|
How Can I Get the Index of An Item in a ListBox? <p>I am adding items to a <code>ListBox</code> like so:</p>
<pre><code>myListBox.Items.addRange(myObjectArray);
</code></pre>
<p>and I also want to select some of the items I add by the following:</p>
<pre><code>foreach(MyObject m in otherListOfMyObjects)
{
int i... | <p>You should make sure that <code>MyObject</code> overrides <code>Equals()</code>, <code>GetHashCode()</code> and <code>ToString()</code> so that the <code>IndexOf()</code> method can find the object properly.</p>
<p>Technically, <code>ToString()</code> doesn't need to be overridden for equality testing, but it is us... |
Microsoft Exception Handling Block - Isn't it a perfect example for overengineering? <p>Ever since Microsoft has introduced the application blocks, I've been bumping into people who use the <a href="http://msdn.microsoft.com/en-us/library/dd203116.aspx">Exception Handling Application Block</a>. I've recently had a clos... | <p>If you use exceptions for control flow, then you would want to stay away from policy-based exception handling.</p>
<p>But in the case of exceptions which you want to treat as non-recoverable (a background task failed, the socket was disconnected, the file was deleted, etc.), you may want to have configurable, polic... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.