instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I need to deploy a few files that were checked in sometime ago (can't remember the exact ones), so I'm looking to get a list so I can deploy just those files. What is the svn command to do this?</p>
| <p><code>svn log</code> has a <code>--verbose</code> parameter. I don't have a repository here to test with, but does that return a list of modified files?</p>
<p>You can also use <code>svn diff -r <revision></code> to retrieve the full change details, which you can parse or read manually to find out which files... | <p><code>svn log</code> has a <code>--verbose</code> parameter. I don't have a repository here to test with, but does that return a list of modified files?</p>
<p>You can also use <code>svn diff -r <revision></code> to retrieve the full change details, which you can parse or read manually to find out which files... | 6,684 |
<p>In .NET, if a class contains a member that is a class object, should that member be exposed as a property or with a method?</p>
| <p>If all you are doing is exposing an object instance that is relevant to the state of the current object you should use a property.</p>
<p>A method should be used when you have some logic that is doing more than accessing an in memory object and returning that value or when you are performing an action that has a br... | <p>I confused about the using property and method before. But now I am using this rule according to <a href="https://msdn.microsoft.com/en-us/library/vstudio/ms229054%28v=vs.100%29.aspx" rel="nofollow">MSDN Guideline</a>:</p>
<p>methods represent actions and properties represent data. Properties are meant to be used ... | 19,890 |
<p>I have a class called EventConsumer which defines an event EventConsumed and a method OnEventConsumed as follows:</p>
<pre><code>public event EventHandler EventConsumed;
public virtual void OnEventConsumed(object sender, EventArgs e)
{
if (EventConsumed != null)
EventConsumed(this, e);
}
</code></pre>
... | <p>Here's the IL from a sample app:</p>
<pre><code>
.method public hidebysig virtual instance void OnEventConsumed(object sender, class [mscorlib]System.EventArgs e) cil managed
{
.maxstack 8
L_0000: nop
L_0001: ldarg.0
L_0002: ldarg.1
L_0003: ldarg.2
L_0004: cal... | <p>The using</p>
<pre><code>public virtual void OnEventConsumed(object sender, EventArgs e)
{
if (EventConsumed != null)
EventConsumed(this, e);
}
</code></pre>
<p>should be</p>
<pre><code>public virtual void OnEventConsumed(EventArgs e)
{
EventHandler handler = this.EventConsumed;
if ( null != h... | 33,735 |
<p>I'm about to start a fairly Ajax heavy feature in my company's application. What I need to do is make an Ajax callback every few minutes a user has been on the page. </p>
<ul>
<li>I don't need to do any DOM updates before, after, or during the callbacks. </li>
<li>I don't need any information from the page, just fr... | <p>If you don't want to create a blank page, you could call a IHttpHandler (ashx) file:</p>
<pre><code>public class RSSHandler : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/xml";
string sXml = BuildXMLString(); /... | <p>You can also use WebMethods which are built into the asp.net ajax library. You simply create a static method on the page's codebehind and call that from your Ajax.</p>
<p>There's a pretty basic example of how to do it <a href="https://web.archive.org/web/20200803212711/http://geekswithblogs.net/frankw/archive/2008/0... | 4,691 |
<p>On a recent project I have been working on in C#/ASP.NET I have some fairly complicated JavaScript files and some nifty Style Sheets. As these script resources grow in size it <a href="http://developer.yahoo.com/yui/compressor/" rel="nofollow noreferrer">is advisable to minify the resources</a> and keep your web pa... | <p>The <a href="https://github.com/loresoft/msbuildtasks/" rel="noreferrer">MSBuildCommunityTasks Project</a> has a few MSBuild tasks that may do what you are looking for including Merge and JSCompress. </p>
<p>You could add these into your MSBuild project in the AfterBuild target to allow the project to perform this... | <p>Not a perfect answer, but if you're using MVC4 they've built this in as a new feature. When running a Debug configuration, it outputs individual files with comments and such but when you switch to Release, it will automatically bundle, minify, and change in page references to the minified files. You can setup sepa... | 35,218 |
<p>In podcast #15, Jeff mentioned he twittered about how to run a regular event in the background as if it was a normal function - unfortunately I can't seem to find that through twitter. Now I need to do a similar thing and are going to throw the question to the masses.</p>
<p>My current plan is when the first user (... | <p>I think developing a custom solution for running background tasks doesn't always worth, so I recommend to use the <a href="http://www.quartz-scheduler.org/" rel="nofollow noreferrer">Quartz Scheduler</a> in Java.</p>
<p>In your situation (need to run background tasks in a web application) you could use the ServletC... | <p>Here is how they do it on StackOverflow.com:</p>
<p><a href="https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/">https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/</a></p>
| 7,070 |
<p>We are considering a move from SVN to Mercurial, and have encountered a stumbling block.</p>
<p>We currently use <code>svn:externals</code> to automatically pull a common set of libraries into the working directory. I can't find support for anything like this in Mercurial.</p>
<p>Is there a way to do this automati... | <p>There's no good way to do it using mercurial only. The Forest Extension mentioned elsewhere causes more problems that in fixes nowadays. Most folks just use a large repo and include all their components in the repo and then have their build scripts download and use 3rd party libraries -- using maven if they're Java... | <p>Try Mercurial's <a href="https://www.mercurial-scm.org/wiki/ForestExtension" rel="nofollow noreferrer">Forest Extension</a>.</p>
| 26,731 |
<p>MSIE v7 does not (in my hands) open a Modeless Dialog or trigger an onLoad event if there is a Javascript alert in the target page. The following fails in MSIE v7 but is OK in v6 (zip file of full source available if required). </p>
<p>Would appreciate others confirming this and discussing why this should be so.</p... | <p>It appears that IE7 is displaying the proper behavior. HTML is read and parsed sequentially, including scripts. When the parser reaches the javascript alert, it executes it and waits for a return. Then, it can finish parsing the page and raise the onLoad event.</p>
<p>If you want the alert to be displayed after the... | <p>Are you sure it's not your inline onload event that's stopping it? The code below works for me.</p>
<p>Index.htm</p>
<pre><code><html>
<head>
<title>Index</title>
<script type="text/javascript" language="JavaScript">
function openDialog() {
if (window.showModalDialog) { ... | 47,810 |
<p>Does anyone know a trick in Visual Studio 2008 to make it remember the outline toggles you have in place on aspx files between restarts? (the little plus or minus symbol on the left for code blocks)</p>
<p>In the code behind cs file it remembers the toggle on the #region tags... hoping for something like that I can... | <p>I turn those suckers off. That way, the state is always the same, I see all the code, and it reminds me that I have to clean it up.</p>
<p>However, to answer your question, I don't think there is active way to control that after you close the file.</p>
| <p>I turn those suckers off. That way, the state is always the same, I see all the code, and it reminds me that I have to clean it up.</p>
<p>However, to answer your question, I don't think there is active way to control that after you close the file.</p>
| 29,130 |
<p>It often happens that characters such as <em>é</em> gets transformed to <em>é</em>, even though the collation for the MySQL DB, table and field is set to utf8_general_ci. The encoding in the <em>Content-Type</em> for the page is also set to UTF8.</p>
<p>I know about utf8_encode/decode, but I'm not quite sure about ... | <p>On the first look at <a href="http://www.nicknettleton.com/zine/php/php-utf-8-cheatsheet" rel="noreferrer">http://www.nicknettleton.com/zine/php/php-utf-8-cheatsheet</a> I think that one important thing is missing (perhaps I overlooked this one).
Depending on your MySQL installation and/or configuration you have to ... | <p>For better unicode correctness, you should use utf8_unicode_ci (though the documentation is a little vague on the differences). You should also make sure the following Mysql flags are set correctly -</p>
<ul>
<li>default-character-set=utf8</li>
<li>skip-character-set-client-handshake //Important so the client doesn... | 17,007 |
<p>We've got dozens of versions of an SWF modified for different customers of a big Flash project, and now would have to replace some strings embedded in scripts in each copy. The FLA file for some of these is very difficult to locate or even missing (I inherited this mess and refactoring it is currently not an option)... | <p>You could try Burak's <a href="http://www.buraks.com/uae/" rel="nofollow noreferrer">URL Action Editor</a> -- it says URL, but I'm pretty sure it lets you edit any text in a SWF. I haven't used it, but I have used his ActionScript Viewer, which works wonderfully.</p>
| <p>tricky - it might not be any easier, but you could load the 'locked' swf into one you control, then spider through its objects until you hit TextBox, using some for...in loops - it'd be a long, arduous process to map them out then change them, especially if the previous developer didn't name things in a helpful way,... | 14,552 |
<p>I have an application where a user has to remember and insert an unix timestamp like 1221931027. In order to make it easier to remember the key I like to reduce the number of characters to insert through allowing the characters [a-z]. So I'm searching for an algorithm to convert the timestamp to a shorter alphanum v... | <p>You could just convert the timestamp into base-36.</p>
| <p>convert the timestamp to HEX. That will generate a shorter alphanumeric number for you out of the timestamp. </p>
| 13,411 |
<p>I have a asp.net 2.0 web site with numerous asp:DropDownList controls.
The DropDownList control contains the standard info city, state, county etc... info.
In addition to the standard codes the site also has custom codes that the users can configure themselves.
For example a animal dropdown may contain the values Do... | <p>I solved this exact same problem just two days ago. First, I moved the code that set the SelectedValue to a PreRender handler for the DropDownList. Then, I add logic to first check to see if the value is in the drop down list. If not, I add it.</p>
<p>Here's my code. ddSpecialty is my drop-down list, populated with... | <p>Try this: </p>
<pre><code>if (ddl.Items.Contains(new ListItem(selectedFacility)))
ddl.SelectedValue = selectedFacility;
</code></pre>
| 5,952 |
<p>I'd like to limit the size of the file that can be uploaded to an application. To achieve this, I'd like to abort the upload process from the server side when the size of the file being uploaded exceeds a limit.</p>
<p>Is there a way to abort an upload process from the server side without waiting the HTTP request t... | <p>You can do something like this (using the <a href="http://commons.apache.org/fileupload/" rel="nofollow noreferrer">Commons</a> library):</p>
<pre><code> public class UploadFileServiceImpl extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOE... | <p>You might try doing this in the doPost() method of your servlet </p>
<pre><code>multi = new MultipartRequest(request, dirName, FILE_SIZE_LIMIT);
if(submitButton.equals(multi.getParameter("Submit")))
{
out.println("Files:");
Enumeration files = multi.getFileNames();
while (files.hasMoreElements()) {
... | 19,014 |
<p>In Model-View-Presenter pattern where should we write validations of user input.</p>
| <p>Domain specific rules/validations should be in the Model. You can have a model.validate() to let you know if the rules are not violated. Look at Rails model (ActiveRecord) classes for a good implementation of this concept.</p>
<p>The View should make it difficult for the user to key in invalid input. So 'entering a... | <p>Presenter....</p>
<p>The view should have have "widgets" that prevent invalid input where possible.</p>
| 26,759 |
<p>I have a bowling web application that allows pretty detailed frame-by-frame information entry. One thing it allows is tracking which pins were knocked down on each ball. To display this information, I make it look like a rack of pins:</p>
<pre>o o o o
o o o
o o
o</pre>
<p>Images are used to represent the pin... | <p>You could try the css "nowrap" option in the containing div.</p>
<pre class="lang-css prettyprint-override"><code>{white-space: nowrap;}
</code></pre>
<p>Not sure how widely that is supported.</p>
| <p>Would it not be easier if you do it like this?</p>
<pre><code><div id="container">
<div id="row1">
<img/><img/><img/><img/>
</div>
<div id="row2">
<img/><img/><img/>
</div>
<div id="row3">
<img/><img/>
... | 11,868 |
<p>I am working on a ASP.net project created with local file system settings. I am using MVC and Jquery. Jquery is working fine when I run the application in debug mode i.e. in ASP.net Development server. I am trying to host the application in IIS 7. In hosted mode, it does not recognize Jquery and gives scripting erro... | <p>Try using Firebug 'Net' tab to see if the file gets loaded.</p>
<p>You can also configure Firebug to fail on all errors and see when the error happens as compared to when jQuery gets loaded.</p>
| <p>This usually occurs when you have malformed HTML or JavaScript.</p>
| 44,064 |
<p>I have two windows services running on the same machine. Both the services uses</p>
<p>private HttpListener listener;</p>
<p>I specify the baseURL as "<a href="http://IPAddress:8080/" rel="noreferrer">http://IPAddress:8080/</a>" & "<a href="http://IPAddress:8081/" rel="noreferrer">http://IPAddress:8081/</a>" r... | <p>Doesn't HttpListener work independently from IIS? Can you stop the IIS service and see what happens?</p>
<p>Or maybe port 8081 is <strong>used by another program</strong> or process. I suggest to try to set the port to another number. You could open a command line and execute the "<a href="http://en.wikipedia.org/w... | <p>It's usually a good idea to take a quick look at <a href="http://www.iana.org/assignments/port-numbers" rel="nofollow noreferrer">this</a> page when using port numbers...just to make sure a temp number you're trying to use isn't in use already.</p>
| 26,383 |
<p>I'm developing a compiler framework for .NET and want a flexible way of defining pipelines. I've considered the following options:</p>
<ul>
<li>WWF</li>
<li>Custom XML pipeline description</li>
<li>Custom pipeline description in code (using Nemerle's macros to define syntax for it)</li>
<li>Other code-based descri... | <p>If you know Ruby then a solution is to write a simple internal DSL that can generate whatever pipeline data types and reader/writer code you need. Generating XML is a quick way to get started. You can always change the DSL to generate another format later if required.</p>
<p>You may also want to look at the <a href... | <p>I know <a href="http://boo.codehaus.org/" rel="nofollow noreferrer">Boo</a> let you have fun with the compiler, not sure if it does in the manner you want.</p>
| 8,746 |
<p>We have scalar functions in our database for returning things like "number of tasks for a customer" or "total invoice amount for a customer". </p>
<p>We are experimenting and looking to try to do this w/o stored procedures ... normally we would just call this function in our stored procedure and return it as a sin... | <p>LINQ-to-SQL supports use with UDFs, if that is what you mean. Just drag the UDF onto the designer surface and you're done. This creates a matching method on the data-context, marked <a href="http://msdn.microsoft.com/en-us/library/system.data.linq.mapping.functionattribute.aspx" rel="noreferrer"><code>[Function(...,... | <p>I believe <a href="http://msdn.microsoft.com/en-us/library/bb386973.aspx" rel="nofollow noreferrer">this MSDN documentation</a> is what you're after (as part of <a href="http://msdn.microsoft.com/en-us/library/bb546175.aspx" rel="nofollow noreferrer">this wider topic of calling user-defined functions in LINQ to SQL<... | 35,577 |
<p>I've got a web page that's using jquery to receive some product information as people are looking at things and then displays the last product images that were seen. This is in a jquery AJAX callback that looks pretty much like this:</p>
<pre><code>if(number_of_things_seen > 10) {
$('#shots li:last-child').re... | <p>Browsers are notorious for memory leaks. It sounds like the problem occurs when the page is left running for a long time. How about refreshing the page before it runs out of memory?</p>
<pre><code>window.setTimeout("location.reload()",1000*60*60);//refresh in an hour
</code></pre>
| <p>how long have you observed this 'growing indefinitely' ? some implementations of garbage collectors don't necessarily give memory back to the OS so quickly if at all. can you distill what you are trying to do into a real simple test (eg, setting src of image over and over) w/o ajax or callbacks ? have you / can you ... | 43,632 |
<p>Is it possible for Eclipse to read stdin from a file?</p>
| <h3>Pure Java</h3>
<p>You can redirect System.in with a single line of code:</p>
<pre><code>System.setIn(new FileInputStream(filename));
</code></pre>
<p>See <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/System.html#setIn-java.io.InputStream-" rel="noreferrer">System.setIn()</a>.</p>
<h3>Eclipse config</h... | <p>What I did was to create an Ant target and launch it as "Run External" from Eclipse, here are the steps:</p>
<ul>
<li>I have one input file to read from: <code>res\in.txt</code> and one for the output: <code>res\out.txt</code></li>
<li><p>Create a <code>build.xml</code> with the targets you require (this is just an... | 22,863 |
<p>Using <a href="http://search.cpan.org/dist/DBIx-Class/" rel="nofollow noreferrer">DBIx::Class</a> and I have a resultset which needs to be filtered by data which cannot be generated by SQL. What I need to do is something effectively equivalent to this hypothetical example:</p>
<pre><code>my $resultset = $schem... | <p>You can’t really, due to the goals for which DBIC result sets are designed:</p>
<ul>
<li>They compile down to SQL and run a single query, which they do no earlier than when you ask for results.</li>
<li>They are composable.</li>
</ul>
<p>Allowing filtering by code that runs on the Perl side would make it extremely... | <p>If you filter the results and end up with a list of rows you can create a new resultset like this: <a href="http://search.cpan.org/~abraxxa/DBIx-Class-0.08127/lib/DBIx/Class/Manual/Cookbook.pod#Creating_a_result_set_from_a_set_of_rows" rel="nofollow">http://search.cpan.org/~abraxxa/DBIx-Class-0.08127/lib/DBIx/Class/... | 34,155 |
<p>I'm looking for an easy way to debug RESTful services. For example, most webapps can be debugged using your average web browser. Unfortunately that same browser won't allow me to test HTTP PUT, DELETE, and to a certain degree even HTTP POST.</p>
<p>I am not looking to automate tests. I'd like to run new services th... | <p>Use an existing 'REST client' tool that makes it easy to inspect the requests and responses, like <a href="https://github.com/wiztools/rest-client" rel="noreferrer">RESTClient</a>.</p>
| <p>Aside from using one of the tools in Peter Hilton's response, I would have to say that scripting the tests with LWP or some similar tool may be your only option. You <em>could</em> bypass the use of LWP by just opening a socket, sending a raw HTTP request in and examining what you get in return. But as far as I know... | 20,012 |
<p>I'm thinking about making a networked game. I'm a little new to this, and have already run into a lot of issues trying to put together a good plan for dead reckoning and network latency, so I'd love to see some good literature on the topic. I'll describe the methods I've considered.</p>
<p>Originally, I just sent... | <p>Check out how Valve does it in the Source Engine: <a href="http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking" rel="noreferrer">http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking</a></p>
<p>If it's for a first person shooter you'll probably have to delve into some of the topics... | <p>Check out Networking education topics at the XNA Creator's Club website. It delves into topics such as network architecture (peer to peer or client/server), Network Prediction, and a few other things (in the context of XNA of course). This may help you find the answers you're looking for.</p>
<p><a href="http://c... | 6,404 |
<p>Is there a way that you can have SERVEROUTPUT set to ON in sqlplus but somehow repress the message "PL/SQL procedure successfully completed" that is automatically generated upon completed execution of a plsql procedure?</p>
| <p>Use the command:</p>
<pre><code>SET FEEDBACK OFF
</code></pre>
<p>before running the procedure. And afterwards you can turn it back on again:</p>
<pre><code>SET FEEDBACK ON
</code></pre>
| <p>This has worked well for me in sqlplus, but I did just notice that "set feedback off" suppresses errors in Sql Developer (at least version 17.2.0.188). Just something to be aware of if you use Sql Developer:</p>
<pre><code>create or replace procedure test_throw_an_error as buzz number; begin dbms_output.put_line('I... | 31,173 |
<p>My application needs to set cookies for specific paths in the application. For example (in php):</p>
<pre><code>setcookie(*cookie_name*,*value*,*date*,"/subpath/subpath/unique_name");
setcookie(*cookie_name*,*value*,*date*,"/subpath/subpath/another unique name");
</code></pre>
<p>Oddly enough, the first setcookie ... | <p>I see no problem with spaces in cookies.<br>
Maybe you should check how you read back your value...<br>
My read routine is:</p>
<pre><code>function ReadCookie(name)
{
name += '=';
var parts = document.cookie.split(/;\s*/);
for (var i = 0; i < parts.length; i++)
{
var part = parts[i];
if (part.ind... | <p>No access to a webserver atm. You haven't tried one of these?</p>
<pre><code>setcookie(*cookie_name*,*value*,*date*, "/subpath/subpath/another unique name/");
setcookie(*cookie_name*,*value*,*date*, urlencode("/subpath/subpath/another unique name"));
setcookie(*cookie_name*,*value*,*date*, rawurlencode("/subpath/su... | 43,906 |
<p>While developing products, we often need to create proprietary tools to test some of their unique features or diagnose problems. In fact the tools can be at lest as interesting as the products themselves, and some of our internal groups have asked for copies of them.</p>
<p>So, aside from the obvious business-driv... | <ol>
<li>First, internal tools are always developed quick and dirty. Almost no testing - it just has to do the work.</li>
<li>UI is not as important as with a customer-facing app.</li>
<li>Internal tool can use internal/private/proprietary knowledge of the products and frameworks they test. For example, our last produc... | <p>Since the diagnostics I build are usually very special-purpose, I tend to provide more options and built-in examples than I would for customer-facing products. In other words, I assume the user is more familiar with the technology than a customer would generally be, and I provide more ability to tweak the way the t... | 34,745 |
<p>I need to make my dropdown menu apprear over the top of a flash movie, how is this done cross browser?</p>
<p>It can be done, IBM do it: <a href="http://www.ibm.com/us/" rel="noreferrer">http://www.ibm.com/us/</a> so do GE: <a href="http://www.ge.com/" rel="noreferrer">http://www.ge.com/</a></p>
<p>Setting the the... | <p>Set the wmode to transparent and if necessary, use z-index as you would on any other element, that really should work for Firefox too.</p>
| <p>Firefox for linux shows flash on top of everything. Regardles of wmode or z-index.</p>
<p>EDIT:
I just found out that the Linux issue described above can be "fixed".</p>
<p>You need to add an iframe with a z-index between the swf and the layer you want to put on top of it. The iframe needs to have style="display:n... | 30,135 |
<p>I have a struts2 application with a single page that may show one of a number of values stored in a database. The application is for a school with many departments and each department has many programs. The department page is accessed using a url like this</p>
<pre><code>department.action?id=2
</code></pre>
<p>and... | <p>This is normally done by mapping a servlet to, in your case '/department', and then using the <a href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getPathInfo()" rel="nofollow noreferrer">path</a> information (e.g., '/engineering') within the servlet to determine the ID. ... | <p>This is normally done by mapping a servlet to, in your case '/department', and then using the <a href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getPathInfo()" rel="nofollow noreferrer">path</a> information (e.g., '/engineering') within the servlet to determine the ID. ... | 28,043 |
<p>Is there any built-in utility or helper to parse <code>HttpContext.Current.User.Identity.Name</code>, e.g. <code>domain\user</code> to get separately domain name if exists and user?</p>
<p>Or is there any other class to do so?</p>
<p>I understand that it's very easy to call <code>String.Split("\")</code> but just ... | <p>This is better (<em>easier to use, no opportunity of <code>NullReferenceExcpetion</code> and conforms MS coding guidelines about treating empty and null string equally</em>):</p>
<pre><code>public static class Extensions
{
public static string GetDomain(this IIdentity identity)
{
string s = identity... | <p>Seems like a problem made to be solved by regular expressions:</p>
<pre><code>public static class UserExtensions
{
public static string GetDomain(this IIdentity identity)
{
Regex.Match(identity.Name, ".*\\\\").ToString()
}
public static string GetLogin(this IIdentity identity)
{
... | 45,474 |
<p>I'm going to make an application (in Swing) that uses a tree to visualize a data structure (JTree). A tree will be on the left side of a window. The user will be able to browse a tree. The parameters of every tree node will be displayed on the right side of the window.
The example windows will be looking like thi... | <p>Dialogs are bad.</p>
<p>Immediately discard any complete nonsense input immediately. For instance, typing a letter in the numerical field (use Document filters). Don't beep. Don't require any particular commit step. You may have retain partially entered data.</p>
| <p>I'm not totally sure what you're after, but..</p>
<p>You could maybe add this "ok" button (or "commit changes" or whatever) to data panel and when the button would be pressed, you would validate the data and save the changes if the changes are valid?</p>
<p>(So you'd have editable components at the data panel)</p>... | 39,159 |
<p>I'd like to serialize some LINQ generated objects and store them in a table as a binary field (Never you mind why). I'd like to be able to write some code that looks something like this:</p>
<pre><code>SerialTestDataContext db = new SerialTestDataContext();
relation_table row = db.relation_tables.First();
MemoryS... | <p>With linq-to-sql (from tags), then yes: you can mark the dmbl as serializable, which uses the [DataContract]/[DataMember] approach. You do this by setting the "Serialization Mode" to "Unidirectional" in the designer, or you can do it in the dbml itself:</p>
<pre><code><Database ... Serialization="Unidirectional"... | <p>Linq classes are partial classes. You can change the definition to mark the classes as implementing <a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx" rel="nofollow noreferrer">ISerializable</a> and then provide the code...</p>
<pre><code>public partial class User : I... | 43,059 |
<p>I have a WCF service, hosted in IIS 7.0 that needs to run database queries. In order to get the right permissions to do this I am impersonating within the service as follows:</p>
<h3>Code</h3>
<pre><code>[OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
public void MyOperation(int arg)
</code></pre>... | <p>If you want the SQL queries to be executed as the impersonated identity, you may actually need to enable delegation to your SQL server. Check out this article for more info:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms730088.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms730... | <p>Hmmm... I don't know. However, you could force the dll to load early on. Since you are using IIS, this would presumably be in your global.asax - something like creating and throwing away a TransactionScope should do the job...</p>
| 35,068 |
<p>C#: How do you pass an object in a function parameter?</p>
<pre><code>public void MyFunction(TextBox txtField)
{
txtField.Text = "Hi.";
}
</code></pre>
<p>Would the above be valid? Or?</p>
| <p>So long as you're not in a different thread, yes the code sample is valid. A textbox (or other windows forms items) are still objects that can be passed to and manipulated by methods.</p>
| <p>For any reference-type, that is fine - you have passed the <em>reference</em> to the object, but there is only one object, so changes are visible to the caller.</p>
<p>The main time that <em>won't</em> work is for "structs" (value-types) - but they really shouldn't be mutable anyway (i.e. they shouldn't really have... | 34,833 |
<p>Some iPhone applications, such as Pandora seem to directly manipulate the hardware volume and respond to physical volume button. How is this done?</p>
<p>AudioSessionServices allows you to get the current hardware output volume with the <code>kAudioSessionProperty_CurrentHardwareOutputVolume</code> property, but it... | <p>They use the MPVolumeView, simple add it and it's makes the rest when the user touch it. Note: Doesn't work in iPhone Simulator. I think the release note also mentioned do not use it direct in Interface Builder. </p>
<pre><code>MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(25, 378, 270, ... | <p>Here is another (complete) example of setting the hardware volume AND retrieving the volume after pressing the hardware keys:</p>
<pre><code>// AVAudiosession Delegate Method
- (void)endInterruptionWithFlags:(NSUInteger)flags
{
// When interruption ends - set the apps audio session active again
[[AVAudioSe... | 26,490 |
<p>Let's say I have two models, Classes and People. A Class might have one or two People as instructors, and twenty people as students. So, I need to have multiple relationships between the models -- one where it's 1->M for instructors, and one where it's 1->M for students.</p>
<p>Edit: Instructors and Students <em>mu... | <p>There are many options here, but assuming instructors are always instructors and students are always students, you can use inheritance:</p>
<pre><code>class Person < ActiveRecord::Base; end # btw, model names are singular in rails
class Student < Person; end
class Instructor < Person; end
</code></pre>
<... | <p>in my case i have Asset and User model
Asset can be create by an user and could be assigned to a user
and User can create many assets and can have many Asset
solution of my problem was
asset.rb</p>
<pre><code>class Asset < ActiveRecord::Base
belongs_to :creator ,:class_name=>'User'
belongs_to :assigne... | 12,156 |
<p>MSTest produces an XML file with a .trx extension containing test results.</p>
<p>If I have a .trx file on a machine without Visual Studio installed, I get prompted to "Use the Web Service..." or "Select from a list...", which is expected.
If I have a .trx file on my development machine and I open it, it opens in V... | <p>It should be a matter of defining a MIME type for the file (i.e. "application/x-test") If I'm not mistaken, if the MIME type is not provided by the server, the client has to guess (and if it looks like a XML file, it gets treated like a XML file). I could be mistaken, but it is worth a try. You can access the MIM... | <p>Have you tried changing the file association for .xml to Visual Studio instead of IE? I'm using Win7 and IE8 and I can set the associations here:
Internet Options > Programs > Set Programs > Default Programs\Set Associations</p>
| 27,998 |
<p>In a world where manual memory allocation and pointers still rule (Borland Delphi) I need a general solution for what I think is a general problem:</p>
<p>At a given moment an object can be referenced from multiple places (lists, other objects, ...). Is there a good way to keep track of all these references so that... | <p>If you want to notify others of changes you should implement the <a href="http://en.wikipedia.org/wiki/Observer_pattern" rel="nofollow noreferrer">"Observer Pattern"</a>. Delphi has already done that for you for TComponent descendants. You can call the TComponent.FreeNotification method and have your object be notif... | <p>Are you trying to keep track of who's referencing an object so you can clear those references when the object is destroyed, or are you trying to keep track of when it's safe to destroy the object?</p>
<p>If the latter then it sounds like you're looking for a garbage collector. I've never dealt with Delphi so I don... | 3,874 |
<p>Can anyone explain this behavior or how to get around it?</p>
<p>If you execute this query:</p>
<pre><code>select *
from TblA
left join freetexttable ( TblB, *, 'query' ) on TblA.ID = [Key]
inner join DifferentDbCatalog.dbo.TblC on TblA.ID = TblC.TblAID
</code></pre>
<p>It will be very very very slow.</p>
<p>If... | <p>A general rule of thumb is that OUTER JOINs cause the number of rows in a result set to <em>increase,</em> while INNER JOINs cause the number of rows in a result set to <em>decrease.</em> Of course, there are plenty of scenarios where the opposite is true as well, but it's more likely to work this way than not. Wh... | <p>Index the field you use to perform the join.</p>
<p>A good rule of thumb is to assign an index to any commonly referenced <a href="http://en.wikipedia.org/wiki/Foreign_key" rel="nofollow noreferrer">foreign</a> or <a href="http://en.wikipedia.org/wiki/Candidate_key" rel="nofollow noreferrer">candidate keys</a>.</p>... | 6,929 |
<p><strong>Problem:</strong></p>
<p>Ajax suggest-search on [<em>n</em>] ingredients in recipes. That is: match recipes against multiple ingredients.</p>
<p>For instance: <code>SELECT Recipes using "flower", "salt"</code> would produce: <code>"Pizza", "Bread", "Saltwater"</code> and so forth.</p>
<p><strong>Tables:</... | <p>You have two options. If you're using SQL Server 2008 (or Oracle) you can pass in a <a href="http://www.sqlteam.com/article/sql-server-2008-table-valued-parameters" rel="nofollow noreferrer">table value parameter</a>. </p>
<p>If you're using SQL Server 2005, you can use <a href="http://weblogs.asp.net/jgalloway/arc... | <p>Depending on how you are processing the input ingredients I think this current method has some sql injection risks. </p>
<p>You could append the ingrediant name to the join conditions which may be quicker.</p>
<p>You could also hash combinations of ingredients for receipes for a quick lookup.</p>
| 17,433 |
<p>As a beginner to TDD I am trying to write a test that assumes a property has had its value changed on a PropertyGrid (C#, WinForms, .NET 3.5).</p>
<p>Changing a property on an object in a property grid does not fire the event (fair enough, as it's a UI raised event, so I can see why changing the owned object may be... | <p>To unit test your code you will need to mock up an object of the UI interface element. There are many tools you can use to do this, and I can't recommend one over another. There's a good comparison between MoQ and Rhino Mocks here <a href="http://haacked.com/archive/2008/03/23/comparing-moq-to-rhino-mocks.aspx" re... | <p>One option I would recommend for its simplicty is to have your UI just call a helper class or method on the firing of the event and unit test that. Make sure it (your event handler in the UI) has as little logic as possible and then from there I'm sure you'll know what to do.</p>
<p>It can be pretty difficult to re... | 12,366 |
<p>I have a single line CEikLabel in my application that needs to scroll text.</p>
<p>The simple solution that comes to mind (but possibly naive) would be something like..</p>
<pre><code>[begin pseduo code]
on timer.fire {
set slightly shifted text in label
redraw label
}
start timer
[end pseudo code]
</code... | <p>You can never receive an error, or notice for a UDP packet that did not reach destination.</p>
| <p>If you need reliable UDP as in ordering or verification such that TCP/IP will give you take a look at RUDP or Reliable UDP. Sometimes you do need verification but a mixture of UDP and TCP can be held up on the TCP reliability causing a bottleneck.</p>
<p>For most large scale MMO's for isntance UDP and Reliablity U... | 43,248 |
<p>What other frameworks should ASP.Net programmers consult for code inspiration?</p>
| <p>Broaden your search - don't look just at ASP.NET MVC. Different approaches will help you better understand things you want to do.</p>
<p>Some suggestions:</p>
<ul>
<li><a href="http://www.rubyonrails.org/" rel="nofollow noreferrer">RoR</a></li>
<li><a href="http://www.djangoproject.com/" rel="nofollow noreferrer">... | <p>Well ASP.NET in pretty much unique in it's own respect. You've got user controls, master pages, web forms, a plethora of hooks for IIS...</p>
<p>I'd say you should look into other peoples code for inspiration, see how they've done it.</p>
| 45,452 |
<p>I have a web app protected by ASP.NET Forms Authentication. The site uses jQuery's $.ajax() functionality to call a web service in the same app. </p>
<p>Browsing to the web service .asmx does cause forms authentication to kick in and I once authenticated and make a $.ajax() call to the server I also see the ASP.NET... | <p>From the server's perspective, an ajax request is not very different from normal GET/POST request - just some extra headers added on in the request. It passes through your normal authentication routine, the same as any other request - if that was not the case, you should be much more worried about the overall securi... | <p>As long as your checking on the server that the user is authenticated then yes you should be protected. I am using $ajax to call both PageMethods and to call an ASP.Net WCF service, and things look good.</p>
| 38,110 |
<p>I'm running my C++ program in gdb. I'm not real experienced with gdb, but I'm getting messages like:</p>
<pre><code>warning: HEAP[test.exe]:
warning: Heap block at 064EA560 modified at 064EA569 past requested size of 1
</code></pre>
<p>How can I track down where this is happening at? Viewing the memory doesn't giv... | <p>So you're busting your heap. Here's a nice <a href="http://www.cs.princeton.edu/courses/archive/spring99/cs126/help/gdbtut.html" rel="nofollow noreferrer">GDB tutorial</a> to keep in mind.</p>
<p>My normal practice is to set a break in known good part of the code. Once it gets there step through until you error out... | <p>I had similar problem when I was trying to realloc array of pointers to my structures, but instead I was reallocating as array of ints (because I got the code from tutorial and forgot to change it). The compiler wasnt correcting me because it cannot be checked whats in size argument.
My variable was:</p>
<p><code>i... | 32,560 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/16991/what-ruby-ide-do-you-prefer">What Ruby IDE do you prefer?</a> </p>
</blockquote>
<p>I've generally been doing stuff on Microsoft .NET out of college almost 2 years ago. I just started looking at Ruby on R... | <p>Try both NetBeans and RadRails for maybe a week each, then you can find which works best for you. The best advice is to learn your tool. If you are not checking out something new about your editor, something that could potentially save you time (regexp, etc) then you are doing yourself a huge disservice.</p>
<p>I... | <p>I mainly code ColdFusion or PHP (and JS/CSS/xHTML), but have dabbled in a bit of RoR. RadRails/Apatana has been great for me, because it's built on Eclipse, which I was already using for my other work. It also integrates with Subversion via the Subclipse plugin. </p>
<p>The Eclipse platform is so extensible that it... | 3,677 |
<p>Is there any code coverage tool available for PHP?
I wish to check the code coverage of my code and API's written in PHP, but have not been able to lay my hands on any code coverage tool for PHP, as it is more of a server side language and dynamic in nature.</p>
<p>Does anyone know of a method by which code coverag... | <p><a href="http://www.xdebug.org/" rel="noreferrer">xdebug</a> has <a href="http://www.xdebug.org/docs/code_coverage" rel="noreferrer">Code Coverage Analysis</a>.</p>
<p>Check <a href="https://phpunit.de/manual/current/en/code-coverage-analysis.html" rel="noreferrer">this chapter</a> of the PHPUnit Manual</p>
| <p>Using Xdebug in combination with <a href="http://www.phpunit.de/manual/3.0/en/code-coverage-analysis.html" rel="nofollow noreferrer">PHPUnit</a> can give you code coverage analysis.</p>
| 45,389 |
<p>What does the quote "Level of Indirection solves every Problem" mean in Computer Science?</p>
| <p>Generally it means that by increasing the level of abstraction one can make the problem easier to understand/resolve.</p>
<p>Be careful with your abstractions though, the full quote at least as I heard it is, "You can solve every problem with another level of indirection, except for the problem of too many levels o... | <p>It originates from <em>Bulter Lampson</em>:</p>
<blockquote>
<p><em>"All problems in computer science can be solved by another level of indirection"</em></p>
</blockquote>
<p>It is clearly an <em>aphorism</em> and not intended to be taken literally. It is certainly not a provable theorem.</p>
| 36,748 |
<p>I have just moved from phase 1 to phase 2 of a project. In this transition we got rid of all of the XML configuration for spring and struts2, switching to a fully annotated regime.</p>
<p>All of the participants are amazed at the actual effect this has on development speed. There are a number of reasons for this:</... | <p>Basically, this could be viewed as a question about config files vs. annotation.</p>
<p>If you experienced an amelioration in productivity boost when putting some data as annotations, that means they were not "configuration" material in the first place.</p>
<p>The difference between the two:</p>
<ul>
<li><p>annot... | <p>I don't have productivity figures like you but I have seen significant improvement when moving from xml configurations to annotations. I think its because the configuration information is in the same place with the code.</p>
<p>Before you had to look at a separate file to find configurations and that slowed things ... | 35,955 |
<p>I know that I can <code> svn diff -r a:b repo </code> to view the changes between the two specified revisions. What I'd like is a diff for every revision that changed the file. Is such a command available?</p>
| <p>There's no built-in command for it, so I usually just do something like this:</p>
<pre><code>#!/bin/bash
# history_of_file
#
# Outputs the full history of a given file as a sequence of
# logentry/diff pairs. The first revision of the file is emitted as
# full text since there's not previous version to compare it ... | <p>I've seen a bunch of partial answers while researching this topic. This is what worked for me and hope it helps others. This command will display output on the command line, showing the revision number, author, revision timestamp and changes made:</p>
<pre><code>svn blame -v <filename>
</code></pre>
<p>To ma... | 35,826 |
<p>I am working on an Adobe Flex app, which needs to parse a relativley large XML file. ATM it is only 35MB, but in an ideal world would get much larger in the future.
**Edit: I have no control over the XML file</p>
<p>I am essentially dropping it's contents right into an SQLITE database, so I could use the SimpleXML... | <p>You will definitely run into some performance issues parsing an XML file that large. Back in Flex 2 days we used SOAP for services and had one data call that pulled back about 5K records and the Flash Player would hang / browser go unresponsive for about 10 seconds on a reasonably fast machine. I can't remember th... | <p>In SQL, there is always a WHERE clause because no one ever wants to see more than 100 results.</p>
<p>You might not have control over the original XML file, but perhaps you can insert something on the server-side that does the parsing and extracting the data you actually want.</p>
<p>Cheers</p>
| 45,357 |
<p>When Visual Studio (2005) has <em>Options -> Text Editor -> C/C++ -> Tabs -> Indenting</em> set to Smart it will automatically indent code blocks and line up squiggly brackets, {}, as expected. However, if you hit enter inside a code block, move the cursor to another line, and then move it back, the inserted tabs ar... | <p>As far as I know, the only way to do that is to enter something (anything) on that line, then delete it. Or hit space and you'll never see it there until you return to that line.</p>
<p>Once VS determines that you've edited a line of text, it won't automatically modify it for you (at least, not in that way that yo... | <p>This is an annoyance to myself as well. Anytime the code is reformatted the blank lines are de-tabbed.
You might look at this: <a href="http://visualstudiogallery.msdn.microsoft.com/ac4d4d6b-b017-4a42-8f72-55f0ffe850d7" rel="nofollow">http://visualstudiogallery.msdn.microsoft.com/ac4d4d6b-b017-4a42-8f72-55f0ffe850d7... | 9,956 |
<p>What is the best way to get and set the meta data for mp3, mp4, avi files etc. with .NET?</p>
| <p>I use <a href="http://mediainfo.sourceforge.net/en" rel="noreferrer">MediaInfo</a> with my C# apps, gives you a lot of information about media files.</p>
| <p>Looks like MediaInfo is read-only at this point, by the way: <a href="http://sourceforge.net/forum/message.php?msg_id=4241318&abmode=1" rel="nofollow noreferrer">http://sourceforge.net/forum/message.php?msg_id=4241318&abmode=1</a></p>
<p>Very cool project, though. It's fun finding out about all this cool st... | 3,056 |
<p>I'm just wondering if there is a quick way to echo undefined variables without getting a warning? (I can change error reporting level but I don't want to.) The smallest I have so far is:</p>
<p><code>isset($variable)?$variable:''</code></p>
<p>I dislike this for a few reasons:</p>
<ul>
<li>It's a bit "wordy" and ... | <p>You can run it with the <a href="http://www.php.net/operators.errorcontrol" rel="noreferrer">error suppression operator</a> @.</p>
<pre><code>echo @$variable;
</code></pre>
<p>However, it's best not to ignore unset variables. Unset variables could indicate a logical error on the script, and it's best to ensure all... | <p>Suppress errors using the @-operator forces the interpreter to change error level, executing the function and then change back error level. This decreases your scripts runtime.</p>
<p>Build a function like this will eliminate at least 3 of your reasons:</p>
<pre><code>function echoVar($var, $ret=NULL) {
return... | 49,304 |
<p>Is it allowable to pass parameters to a web page through the URL (after the question mark) when using the POST method? I know that it works (most of the time, anyways) because my company's webapp does it often, but I don't know if it's actually supported in the standard or if I can rely on this behavior. I'm consi... | <p>Lets start with the simple stuff. HTTP GET request variables come from the URI. The URI is a requested resource, and so any webserver <em>should</em> (and apache does) have the entire URI stored in some variable available to the modules or appserver components running within the webserver.</p>
<p>An http POST which... | <p>If you are asking whether it is possible to send parameters via both GET and POST in a single HTTP request, then the answer is "YES". This is standard functionality that can be used reliably AFAIK. </p>
<p>One such example is sending authentication credentials in two pieces, one over GET and the other through POST ... | 32,913 |
<p>I am looking to stream a file housed in a SharePoint 2003 document library down to the browser. Basically the idea is to open the file as a stream and then to "write" the file stream to the reponse, specifying the content type and content disposition headers. Content disposition is used to preserve the file name, ... | <p>It might be something really simple, believe it or not I coded exactly the same thing today, i think the issue might be that the content disposition doesnt tell the browser its an attachment and therefore able to be saved.</p>
<pre><code>
Response.AddHeader("Content-Disposition", "attachment;filename=myfile.doc");
... | <p>It might be something really simple, believe it or not I coded exactly the same thing today, i think the issue might be that the content disposition doesnt tell the browser its an attachment and therefore able to be saved.</p>
<pre><code>
Response.AddHeader("Content-Disposition", "attachment;filename=myfile.doc");
... | 7,596 |
<p>Currently our dev team set up all the websites they're working on in IIS on their local machine. We're thinking of switching to using the built in ASP.NET development server instead.</p>
<p>Is this a good idea? What are the pros / cons of using the ASP.NET dev Server? Are there any gotchas we should be aware of?</p... | <p>There is nothing that the ASP.NET Dev WebService can do that IIS can't (You can set breakpoints etc, just attach the VS debugger to the ASP.NET runtime).</p>
<p>However, the ASP.NET Dev WebService does not represent a true production environment, and as such you can get caught by gotchas that you wouldn't expect wh... | <p>The main issue I've run into with the dev server is SerializationExceptions with custom security principals stored on the thread context. Details <a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=274696" rel="nofollow noreferrer" title="here">here</a>.</p>
| 35,648 |
<p>What is the way of creating a local mailbox for a user that have a NIS account, but doesn't have any local one?</p>
| <p>I solved the issue by creating a local account with exactly the same login name, UID and GID that it has in NIS. This way a mail box is created for the user and after the user with NIS account logs in it has that mailbox working.</p>
| <p>Im not sure it's directly possible. Maybe you could add the user as local with Nologin shell and that way give ham an account with mail?</p>
| 16,000 |
<p>I have the following code which is trivial at first sight. I simply set want to set the font type to Georgia with a size of 14 if the cell is from the result of a search or if there is a count of zero in my students array. </p>
<p>However, with this particular code cell that's last in my <code>tableView</code> is t... | <p>I'm not <i>quite</i> sure what you're asking, but I do note that you're only setting the font to Georgia 14 when you have a search result; otherwise, you're ignoring it. If you have a cell with it's font set in the second if/then branch, and then retrieve that cell (using dequeueReusableCellWithIdentifier:), it will... | <p>I'd suggest that you identify the 'special' cell by giving it a different cell identifier.</p>
<p>In this case, you'd request the special cell with cell reuse identifier, e.g. @"None", and if cell has not yet been created, then create one and set its font.</p>
<p>This way, you create an extra cell with a special i... | 42,553 |
<p>Currently, primary keys in our system are 10 digits longs, just over the limit for Java Integers. I want to avoid any maintenance problems down the road caused by numeric overflow in these keys, but at the same time I do not want to sacrifice much system performance to store infinitely large numbers that I will neve... | <p>I've always gone with long keys (number(18,0) in database) because they simply remove the possibility of this situation happening in pretty much all situations (extreme data hoarding style applications aside). Having the same data-type across all tables for the key means you can share that field across all of your m... | <p>It's a balance between the cost of storing and using Long integers, versus the likelihood of overflowing a 32-bit integer.</p>
<p>Consider that an unsigned 32-bit integer stores over 4 billion values. If you think you are going to average more than 1 new row every second in this table for the next 136 years, then ... | 21,652 |
<p>My motivation for trying out git-svn is the effortless merging and branching. Then I noticed that man git-svn(1) says: </p>
<blockquote>
<p>Running git-merge or git-pull is NOT recommended on a branch you plan
to dcommit from. Subversion does not represent merges in any
reasonable or useful fashion; so users ... | <p>Actually, I found an even better way with the <code>--no-ff</code> option on git merge.
All this squash technic I used before is no longer required. </p>
<p>My new workflow is now as follows: </p>
<ul>
<li><p>I have a "master" branch that is the only branch that I dcommit from and that clone the SVN repository (<c... | <p>A safe way to merge svn branches in git is to use git merge --squash. This will create a single commit and stop for you to add a message.</p>
<p>Let's say you have a topic svn branch, called svn-branch.</p>
<pre><code>git svn fetch
git checkout remotes/trunk -b big-merge
git merge --squash svn-branch
</code></pre>... | 23,108 |
<p>I'm trying to highlight the search results but I want to include the surrounding text that is limited by the enclosing tags.</p>
<p>So if the $term is "cool" the preg_replace should end up with:</p>
<pre><code><div><span style="background: #f00">My hair cut so cool!</span></div>
</code></pr... | <p>Finding a term and everything up to the HTML tags before and after it is the same as finding the term an all characters before and after it that aren't angular brackets. This is trivial with a regex:</p>
<pre><code>$pattern = "/[^<>]*$term[^<>]*/i";
$replace = "<span style=\"background: #f00\">$0... | <p>Why the need of preg_replace?</p>
<p>This is how i would have solved the problem:</p>
<p>Case 1: <strong>Highlight a substring of the result:</strong>
Use strpos() or stripos() to get the index of the first occurrence in a string. Next: Get the substring from index-X to index+L+Y, where X and Y is definded constan... | 37,259 |
<p>Based on their work, how do you distinguish a great SQL developer? </p>
<p>Examples might include:</p>
<p>Seldom uses CURSORs, and tries to refactor them away.<br>
Seldom uses temporary tables, and tries to refactor them away.<br>
Handles NULL values in OUTER JOINs with confidence.<br>
Avoids SQL extensions that ... | <p>I've found that a great SQL developer is usually also a great database designer, and will prefer to be involved in both the design and implementation of the database. That's because a bad database design can frustrate and hold back even the best developer - good SQL instincts don't always work right in the face of p... | <p>Knows how to use INFORMATION_SCHEMA and table metadata in order to write either generic code or to code generate code in order to save repetitive database tasks.</p>
| 37,375 |
<p>I'm writing a simple program to browse the local network and pass on filenames to mplayer using "system". However, sometimes filenames contain spaces or quotes.
Obviously I could write my own function to escape those, but I'm not sure exactly what characters do or do not need escaping.</p>
<p>Is there a function av... | <p>There isn't a single solution that works everywhere because different shells have different ideas of what special characters are and how they are interpreted. For bash, you could probably get away with surrounding the entire filename in single quotes after replacing every single quote in the file name with <code>'"... | <p>And now here is a complete solution to the shell escape problem. Although this
doesn't answer the exact question of escaping a string for shell. It solves the problem of passing arguments to program. This solution is a POSIX portable way to execute commands with arguments properly passed into the command without wor... | 36,652 |
<p>I'm building a web application and would like to use the strongest hashing algorithm possible for passwords. What are the differences, if any, between sha512, whirlpool, ripemd160 and tiger192,4? Which one would be considered cryptographically stronger?</p>
| <p>bCrypt - Why would be a very long explanation, for which I recommend <a href="http://www.securityfocus.com/blogs/262" rel="noreferrer">Enough With The Rainbow Tables: What You Need To Know About Secure Password Schemes</a></p>
<p>Basically, it's secure, it's slow, it's already implemented.</p>
| <p>Here's a good <a href="http://www.codinghorror.com/blog/archives/000953.html" rel="nofollow noreferrer">post on coding horror about storing passwords</a>. In short, he suggests bcrypt or SHA-2 with a random unique salt.</p>
| 22,263 |
<p>I'm trying to get authentication working to my liking in a CakePHP app and running into a snag. </p>
<p>I want to let the user login from either the home page or from a dedicated login page. I'm using the Auth component to manage login and right now the login itself works. I am submitting the form on the home page ... | <p>in the AppController</p>
<pre><code>public function beforeFilter( )
{
$this->Auth->autoRedirect = false;
}
</code></pre>
<p>in UsersController</p>
<pre><code>public function login( )
{
if( $this->Auth->user( ) )
{
$this->redirect( array(
'controller' => 'u... | <p>Yes auth has a feature where it will redirect you to the page you tried to access before logging in. If setting the loging redirect did not work, you can try to set the loginRedirect to false and do a manual ($this->redirect([..] ) in the UsersController::login action.</p>
| 29,475 |
<p>First let me say that I really feel directionless on this question. I am using windows integrated security, and I can use vb.net to look up information about a user from AD. I also have other information about users I can look up from a MS SQL 2005 server by getting the logon identity name.</p>
<p>What I would like... | <p>The answer probably depends on how accurate you need the display to be. If it's just to give users a sense of the other people using the site I'd suggest something similar to what you've described, but backing off on the update frequency:</p>
<ul>
<li>on a page request associate the user with the page (and a timest... | <p>For the body have an onunload script:
< body onunload="userLeftPage()"</p>
<p>In that script, send an ajax call to say the user left the page.</p>
| 12,147 |
<p>What is the maximum number of threads you can create in a C# application? And what happens when you reach this limit? Is an exception of some kind thrown?</p>
| <p>There is no inherent limit. The maximum number of threads is determined by the amount of physical resources available. See this <a href="https://devblogs.microsoft.com/oldnewthing/20050729-14/?p=34773" rel="noreferrer">article by Raymond Chen</a> for specifics.</p>
<p>If you need to ask what the maximum number of t... | <p>You can <strong>test</strong> it by using this snipped code:</p>
<pre><code>private static void Main(string[] args)
{
int threadCount = 0;
try
{
for (int i = 0; i < int.MaxValue; i ++)
{
new Thread(() => Thread.Sleep(Timeout.Infinite)).Start();
threadCount ++;
}
... | 17,520 |
<p>I'm using Visual Studio 6.0 and Visual Basic 6.0.</p>
<p>I have them integrated but when I check out a Project and then try to edit a module in that project it's locked and I have to manually right-click on it and do a Check Out to unlock it.</p>
<p>I thought there was a way to have VSS automatically check out the... | <p>I agree with kris here. Now I know that a bunch of folks saying your "software stinks" doesn't really answer your question. But there is a world of difference between a check out style source control and a file locking system like Source safe. The general consensus is that Check out systems are far superior. </p>
<... | <p>I never figured out a way to do this. It was always a huge pain. Sorry for posting a negative answer, but I figured that you might want to know that you aren't alone in hating this, but that there wasn't an immediate and obvious answer. I'll be following this question along with you in case someone out there does... | 21,063 |
<p>I have a script that retrieves objects from a remote server through an Ajax call. The server returns objects in JSON notation.... | <p>You can find a <a href="http://www.JSON.org/js.html" rel="noreferrer">JSON parser written in JavaScript here</a> (<a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" rel="noreferrer">source code here</a>). You can also use the as3corelib JSON parser from JavaScript, there's <a href="http://hel... | <p>JSON is Javascript Object Notation, so if you are using Javascript you are already there!
Have a look at these links, they give examples of how to create Javascript objects from JSON:</p>
<p><a href="http://www.hunlock.com/blogs/Mastering_JSON_(_JavaScript_Object_Notation_)" rel="nofollow noreferrer">http://www.hun... | 4,178 |
<p>In C#</p>
<p>I have a processing time number data column in the database which is in in this format "###" or "##" ( eg: "813" or "67")</p>
<p>When I bind it to the grid view I wanted to display it in this format "0.###" (eg: "0.813" or "0.067")</p>
<p>I tried using {0:0.000} and other formatings. But none seem to... | <p>You need to disable HTML encoding on that column for the format string to take effect.</p>
<p><a href="http://weblogs.asp.net/rajbk/archive/2005/10/31/429090.aspx" rel="nofollow noreferrer">Further Reading</a></p>
| <p>If for some reason you can't change the value before you bind it to the grid, you can handle the RowDataBound event and divide the number by 1000 before displaying it.</p>
<pre><code>// Handle the grid's RowDataBound event
MyGridView.RowDataBound += new GridViewRowEventHandler(MyGridView_RowDataBound);
// Set the ... | 40,587 |
<p>I am working on a Software Project that needs to be translated into 30 languages. This means that changing any string incurs into a relatively high cost. Additionally, translation does not happen overnight, because the translation package needs to be worked by different translators, so this might take a while.</p>... | <p>I'm not sure the platform you're internationalizing in. I've written an answer before on the best way to il8n an application. See <a href="https://stackoverflow.com/questions/59130/what-do-i-need-to-know-to-globalize-an-asp-net-application/59184#59184">What do I need to know to globalize an asp.net application?</a><... | <p>In Java, internationalization is accomplished by moving the strings to resource bundles ... the translation process is still long and arduous, but at least it's separated from the process of producing the software, releasing service packs etc. One thing that helps is to have a CI system that repackages everything a... | 23,199 |
<blockquote>
<p>HyperTerminal is a program that you can use to connect to other
computers, Telnet sites, bulletin
board systems (BBSs), online services,
and host computers, using either your
modem, a null modem cable or Ethernet
connection.</p>
</blockquote>
<p>But My main usage of Hyperterminal is to comm... | <p>Here are two:</p>
<p><a href="http://hp.vector.co.jp/authors/VA002416/teraterm.html" rel="nofollow noreferrer">Tera Term</a></p>
<blockquote>
<p>Tera Term (Pro) is a free software terminal emulator (communication program) for MS-Windows. It supports VT100 emulation, telnet connection, serial port connection, and... | <p>Here is a better tool specificaly designed to test serial devices: <a href="http://www.caerustech.com/UDT.php" rel="nofollow noreferrer">http://www.caerustech.com/UDT.php</a> . You can save settings and commands for various devices - I use it often at work.</p>
| 8,586 |
<p>I thought the web page designer screen in 2005 was mediocre until I used the one in 2008 which I think is bad. There is an interesting white paper here:</p>
<p><a href="http://www.west-wind.com/weblog/posts/484172.aspx" rel="nofollow noreferrer">http://www.west-wind.com/weblog/posts/484172.aspx</a></p>
<p>I've g... | <pre><code>string unformattedXml = "<?xml version=\"1.0\"?><book><author>Lewis, C.S.</author><title>The Four Loves</title></book>";
string formattedXml = XElement.Parse(unformattedXml).ToString();
Console.WriteLine(formattedXml);
</code></pre>
<p>Output:</p>
<pre><code><bo... | <p>Is the string valid XML? Do you mean how can you convert an XML string into an XML document? If so, do this:</p>
<pre><code>XmlDocument xml = new XmlDocument();
xml.LoadXml( YourString );
</code></pre>
| 23,687 |
<p>Does anyone know of a good dictionary API or ruby library to lookup the definitions of words?</p>
<p>I'm thinking it should work something like:</p>
<ol>
<li>I call get_definition(word)</li>
<li>It returns the definition for that word (ideally in some way to easily format the definition for display.</li>
</ol>
<p... | <p>I discovered a webservice for this yesterday.</p>
<p>Go to the <a href="http://www.britishcouncil.org/new/" rel="noreferrer">British Council</a> homepage and double click on any word (that isn't already a hyperlink).</p>
<p>This should open a popup window with a Cambridge Dictionary definition in it. The API is re... | <p>there's also wrappers for dictionary.com's API (a few years old)</p>
<p><a href="http://rubyforge.org/snippet/detail.php?type=snippet&id=53" rel="nofollow noreferrer">http://rubyforge.org/snippet/detail.php?type=snippet&id=53</a></p>
<p><a href="http://rubyforge.org/snippet/detail.php?type=snippet&id=5... | 26,628 |
<p>As part of a larger project, i'm trying to print a translucent green dome. I set it up as follows:</p>
<ul>
<li>In Blender, create an icosphere of the maximum allowed complexity. Cut it in half and throw away one of the hemispheres.</li>
<li>Duplicate the hemisphere. Move the second one down slightly and use Subtr... | <blockquote>
<p>The filament seems to lose its translucency past a certain thickness</p>
</blockquote>
<p>That's exactly the point. Think of translucency as a percentage of light being allowed through, per amount of material. 2x the material means 1/2 the light. You need either less material (which becomes brittle a... | <p>For the modeling, I suggest to change to a proper CAD software, design a half sidecut and create the model by rotating it around Z. That way you'd create an evenly thick part.</p>
<p>As for loosing transparency, that has several reasons:</p>
<ul>
<li>light loss into printed materials is mainly due to air being captu... | 1,215 |
<p>I am currently trying to import a semi-colon delimited text file into a database in c# using OleDb where I don't know the type (SQL Server, Access, Oracle, MySQL, postgreSQL, etc.) Currently I'm reading in the file as a database using the Jet text reader then creating a prepared insert statement, populating the fie... | <p>Try this</p>
<p><a href="http://filehelpers.sourceforge.net" rel="nofollow noreferrer">http://filehelpers.sourceforge.net</a></p>
<p>....why would you want to load the db into the dataset? Have another database keep track of the uniqueness (if there is such a word). While importing, check if exists in the logging ... | <p>Your best bet is to buy an off the shelf application for doing this. </p>
<p>Professional Off The Shelf applications use native drivers and fine tune for each type of datasource they will hit against. This is always under the covers so you don't see how they go about it. For example, bulkcopy is used against SQL... | 21,196 |
<p>I'd like to automate TortoiseSVN as part of a commit process.
Specifically I'd like to dynamically create a log entry for the commit dialog.</p>
<p>I know that I can launch the commit dialog either from the commandline or by right clicking on a folder and selecting svncommit.</p>
<p>I'd like to use the start commi... | <p>Looks like it was my own misunderstanding of the the API that caused by a problem.</p>
<p>Solution:<br>
1) I've added a start commit hook script to TortoiseSVN using the hooks gui in the settings area of the right click menu.</p>
<p>2) The script receive 3 pieces of information: PATH MESSAGEFILE CWD<br>
... | <p>If you just need a static template, set the tsvn:logtemplate property.</p>
<p>For dynamic generation, the /logmsgfile parameter does work, but it seems to need the full path. A batch file that looks like the following might work for you.</p>
<pre><code>GenerateLogMsg.exe > tmp.msg
"C:\Program Files\TortoiseSVN\... | 8,346 |
<p>I have a button, I need to display a pop-up in javascript. So on its client click I call a javascript function which does that.</p>
<p>if user clicks "yes", I need to do a post back and call buttons server side click event, here is what I am doing inside the javascript function</p>
<pre><code>__doPostBack(deleteL... | <p>You are looking for a technology called Comet. <a href="http://en.wikipedia.org/wiki/Comet_(programming)" rel="nofollow noreferrer">Wikipedia entry</a>
If you Google "comet wcf" you'll find articles that should point you in the right direction.</p>
| <p>Yes.
You can use WSDualHttpBinding or NetTcpBinding.</p>
| 49,463 |
<p>Let's say I have the following ruby code :</p>
<pre><code>
def use_object(object)
puts object.some_method
end
</code></pre>
<p>and , this will work on any object that responds to <strong>some_method</strong>,right?</p>
<p>Assuming that the following java interface exists :</p>
<pre><code>
interface TestInterfa... | <p>You are right except that you can not define the body of a function in Java Interfaces, only prototypes. </p>
<p>Interfaces are the only way to implemente a pseudo multi-derivation in Java, since normal class derivation is only simple (just one parent).</p>
| <p>It look like you are trying to program in Ruby using Java, you want want to rethink your approach to use more the idioms of the language.</p>
| 29,469 |
<p>I have a function that exports a table to CSV and in the query I set which fields will export.</p>
<p>Here is the query:</p>
<pre><code>SELECT lname, fname, email, address1, address2, city,
state, zip, venue_id, dtelephone, etelephone, tshirt FROM volunteers_2009
</code></pre>
<p>The field venue_id is the the id... | <pre><code>SELECT a.lname, a.fname,a. email, a.address1,a. address2, a.city,
a.state, a.zip, a.venue_id, a.dtelephone, a.etelephone, a.tshirt,
COALESCE(b.venue_name,'') AS VenueName
FROM volunteers_2009 a
LEFT JOIN venues b ON b.id=a.venue_id
</code></pre>
| <p>Standard SQL query for this is (assuming you want both ID and name for the venue):</p>
<pre><code>SELECT a.lname as lname, a.fname as fname, a.email as email,
a.address1 as address1, a.address2 as address2, a.city as city,
a.state as state, a.zip as zip, a.venue_id as venue_id,
b.venue_name as venue_na... | 40,839 |
<p>I read the <a href="http://en.wikipedia.org/wiki/Scenario_testing" rel="nofollow noreferrer">Wikipedia</a> article on scenario testing, but I am sad to say it is very short. I am left wondering: are scenario tests a collection of sequential unit tests? Or, perhaps, like a single multi-step unit test? Do many fram... | <p>I don't think there's any fixed relationship between the number and distribution of tests and scenario tests.</p>
<p>I think the most common code-representation of a scenario is a specific set of business data required to support a specific story (scenario). This is often provided in the form of database data, fake... | <p>IMHO, scenario testing is a testing activity, as opposed to development activity ; hence it's about testing a product, not unit(s) of that product. The test scenario are end-to-end scenarios, using the <strong>natural interfaces</strong> of the product. If the product has programmatic interfaces, then you could use ... | 45,834 |
<p>I'm trying to implement a Load / Save function for a Windows Forms application.</p>
<p>I've got following components:</p>
<ul>
<li>A tree view</li>
<li>A couple of list views</li>
<li>A couple of text boxes</li>
<li>A couple of objects (which holds a big dictionarylist)</li>
</ul>
<p>I want to implement a way to ... | <p>Here's an example that binds an object and some ancestors
to the UI; the use of C# 3.0 here is purely for brevity -
everything would work with C# 2.0 too.</p>
<p>Most of the code here is setting up the form, and/or
dealing with property-change notifications -
importantly, there isn't any code devoted to updating
th... | <blockquote>
<p>it is fairly trivial to use
data-binding to tie an object model to
the UI.</p>
</blockquote>
<p>How can I tie an object with a GUI control without a persistent storage? If I do it manually that means I have to write ridiculous amount of code for every single object in memory. I already have some ... | 45,287 |
<p>I'm writing some code that id like to be able to work with any window, such as a window created through the windows API, MFC, wxWidgets, etc.</p>
<p>The problem is that for some things I need to use the same thread that created the window, which in many cases is just sat in a message loop.</p>
<p>My first thought ... | <p>If you are in the same process as the window you can hook its messages by subclassing it. Check out <a href="http://msdn.microsoft.com/en-us/library/ms633570(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms633570(VS.85).aspx</a></p>
<p>The key API is SetWindowLong.</p>
<pre><code>... | <p>Alternatively to subclassing, you can use <a href="http://msdn.microsoft.com/en-us/library/ms644906(VS.85).aspx" rel="nofollow noreferrer">SetTimer</a> to call a function in the window thread.</p>
<pre><code>VOID CALLBACK Function(
HWND hwnd,
UINT uMsg,
UINT_PTR idEvent,
DWORD dwTime
)
{
// stuff
}
SetTime... | 44,841 |
<p>I'm architecting a new app at the moment, with a high read:write ratio. At my current employer we have lots of denormalised data on our tables for performance reasons. Is it better practice to have totally 3NF tables and then use indexed views to do all the denormalisation? Should I run queries against the tables or... | <p>From your description, if you're looking for a pattern that matches better than Factory, try Strategy:</p>
<p><a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="nofollow noreferrer">Strategy Pattern</a></p>
<ol>
<li>Your <strong>context</strong> could be a custom class which encapsulates and abstracts th... | <p>We had a similar problem and went with the concept of "connectors" that are interfaces between the main report generator application and the different report engines. By doing this, we were able to create a "universal report server" application. You should check it out at www.versareports.com.</p>
| 23,273 |
<p>I have a swf with loads text into a Sprite that resizes based on the content put into - I'd like though for the ones that are longer than the page to have the browser use its native scroll bars rather than handle it in actionscript (very much like <a href="http://www.nike.com/nikeskateboarding/v3/" rel="noreferrer">... | <p>The trick is to use some simple JavaScript to resize the Flash DOM node:</p>
<pre><code>function resizeFlash( h ) {
// "flash-node-id" is the ID of the embedded Flash movie
document.getElementById("flash-node-id").style.height = h + "px";
}
</code></pre>
<p>Which you call from within the Flash movie like t... | <p>I halfway looked at swffit but the height (and width sometimes but mainly height) would be dynamic - swffit let's you declare a maxHeight but that number would be constantly changing...maybe I could figure out how to set it dynamically. A great place for me to start though - thanks!</p>
| 5,286 |
<p>In PHP, depending on your error reporting level, if you don't define a constant and then call it like so:</p>
<pre><code><?= MESSAGE ?>
</code></pre>
<p>It may print the name of the constant instead of the value!</p>
<p>So, I wrote the following function to get around this problem, but I wanted to know if y... | <p>As long as you don't mind using quotes on your constants, you can do this:</p>
<pre><code>function C($constant) {
return defined($constant) ? constant($constant) : 'Undefined';
}
echo C('MESSAGE') . '<br />';
define('MESSAGE', 'test');
echo C('MESSAGE') . '<br />';
</code></pre>
<p>Output:</p>
<bl... | <p>try </p>
<pre>if (isset(constant($constant)) ...</pre>
<p>This shouldn't trigger any E_NOTICE messages, so you don't have to set and reset error_reporting.</p>
| 42,778 |
<p>i created a register page n login page 4 members in php n mysql.and also i created a admin account and now i want to do something like if the member register he will be added only when the administrator approves it.please help</p>
| <p>The knee jerk reaction is to add a boolean column to the users table with a default value of false. However the best route is probably a CHAR(1) column with a default of 'P' for pending. Then when an admin makes a choice they can approve (set to 'Y') or deny (set to 'N') they won't have to look at everything (just... | <ol>
<li>Introduce an "approved" column into the user table which indicates whether or not the account is approved</li>
<li>Provide an interface for administrators to view a list of such accounts and toggle their approval status</li>
<li>Update existing authentication code to check this column and disallow the use of "... | 43,620 |
<p>We used to use SourceSafe, and one thing I liked about it was that when you checked out a file, it automatically got you its latest version.</p>
<p>Now we work with Team System 2005, and it doesn't work that way - you have to "get latest version" before you start working on a file that you've checked out.</p>
<p>I... | <p>There's a Visual Studio Add-in for this that someone wrote: </p>
<p><a href="http://blogs.microsoft.co.il/blogs/srlteam/archive/2007/03/24/TFS-GetLatest-version-on-check_2D00_out-Add_2D00_In.aspx" rel="nofollow noreferrer">http://blogs.microsoft.co.il/blogs/srlteam/archive/2007/03/24/TFS-GetLatest-version-on-check_... | <p>Are you sure you want that?</p>
<p>It means that when you check out a file, it will be out of sync with the rest of your files. Your project may not build or function properly until you update all files.</p>
| 8,022 |
<p>This page displays beautifully in firefox but i get all kinds of problems when testing the site in opera or internet explorer, mostly with the menu. I would like to know what techniques have caused this and how to avoid them. </p>
<p><a href="http://www.jkhbdesign.se/" rel="nofollow noreferrer">http://www.jkhbdesig... | <p>At the very least you are going to have to deal with the fact that the CSS :hover is not supported in IE for any tag except the anchor tag. You'll need to use onmouseover, onmouseout in IE to accomplish the same thing. Or change the li:hover to an a:hover but that would be a bigger overhaul of your design I think.... | <p>If you're familiar with javascript, you might want to look into the JQuery Superfish plugin. (<a href="http://plugins.jquery.com/project/Superfish" rel="nofollow noreferrer">http://plugins.jquery.com/project/Superfish</a>). Most of the hard work and weird browser issues are already taken care of for you.</p>
| 25,761 |
<p>Kind of a weird question, but. I need to have a list of strings i need to make sure that every string in that list is the same.</p>
<p>E.g:</p>
<pre><code>a = ['foo', 'foo', 'boo'] #not valid
b = ['foo', 'foo', 'foo'] #valid
</code></pre>
<p>Whats the best way to go about doing that?</p>
<p>FYI, i don't know how... | <p>Use list.count to get the number of items in a list that match a value. If that number doesn't match the number of items, you know they aren't all the same.</p>
<pre><code>if a.count( "foo" ) != len(a)
</code></pre>
<p>Which would look like...</p>
<pre><code>if a.count( a[0] ) != len(a)
</code></pre>
<p>...in p... | <p>try (if the lists are not too long):</p>
<pre><code>b == [b[0]] * len(b) #valid
a == [a[0]] * len(a) #not valid
</code></pre>
<p>this lets you compare the list to a list of the same size that is all of the same first element</p>
| 46,962 |
<p>I want my emacs buffer to have a different name than the file name. Rather than setting this manually every time, I want to have this happen automatically based on the file contents, something like:</p>
<p>// Local Variables:<br>
// buffer-name: MyName<br>
// End:</p>
<p>But this doesn't work because buffer-name ... | <p>You could say:</p>
<pre><code>// Local Variables:
// eval: (rename-buffer "my-buffer-name-here")
// end:
</code></pre>
<p>It is a trick though. </p>
<p>You could otherwise program a <code>find-file-hook</code> hook in your <code>.emacs</code> which rename the buffer to a specific local variable contents. Somethin... | <p>Thanks Pierre. Your pdp-buffer-name elisp example worked very well.</p>
<p>I made one enhancement because I noticed emacs was treating the local variable as "unsafe" i.e., always prompting to ask if the value should be applied. Since I want this to work with many different values without cluttering up my .emacs w... | 46,004 |
<p>I have Visual Studio web test attached nicely to a data source, but I need to be able to iterate over each entry in the data source. How should I do this?</p>
| <p>This <a href="http://www.codeguru.com/csharp/.net/net_general/visualstudionetadd-ins/article.php/c12645__2/" rel="nofollow noreferrer">article</a> seems to Discuss something quite like what you're talking about.
Good luck.
Ola</p>
<p><strong>EDIT:</strong> From the linked article, your DataSource is exposed to your... | <p>Open Local.testsettings file from solution explorer and go to Web Test -> Select "One run per data source now" option. That's it.</p>
| 11,496 |
<p>How exactly do you make an auto-refreshing <code>div</code> with JavaScript (specifically, jQuery)?</p>
<p>I know about the <code>setTimeout</code> method, but is it really a good practice ? Is there a better method?</p>
<pre><code>function update() {
$.get("response.php", function(data) {
$("#some_div... | <p>Another modification:</p>
<pre><code>function update() {
$.get("response.php", function(data) {
$("#some_div").html(data);
window.setTimeout(update, 10000);
});
}
</code></pre>
<p>The difference with this is that it waits 10 seconds AFTER the ajax call is one. So really the time between refreshes is 10... | <p><a href="http://plugins.jquery.com/project/Timer" rel="nofollow noreferrer">There's a jQuery Timer plugin</a> you may want to try</p>
| 27,187 |
<p>I have an application written in Delphi 7 which does not require an admin privilages to run. </p>
<p>For some reason I am able to save files to c:\windows and c:\windows\system32 from within the application even though the application <b>has not requested UAC elevation</b>. I am logged in as an admin with <b>UAC t... | <p>This is a feature of UAC to make old applications compatible with Vista. It redirects any request to write to a system folder that the user lacks permission to a local folder.</p>
<p>They are stored under "AppData\Local\VirtualStore" folder under the current user's profile.
There is a group policy setting to disabl... | <blockquote>
<p>I am running as an admin with UAC turned on.</p>
</blockquote>
<p>Do you mean that you are logged on as Administrator or do you mean that you run your Delphi application with the option "Run as administrator" (i.e. with an elevated token)?</p>
<p>If the latter is the case than your application will ... | 48,457 |
<p>This question is a follow-up from <a href="https://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 useful in many libraries. I am wondering what is the best way to offer bot... | <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... | <p>The first example is correct if you are just going to catch the exception and not do anything but return false with it. </p>
<p>You could change TrySomething to look like below.</p>
<pre><code>public bool TrySomething(string a, out result, bool throwException)
{
try
{
// Whatever
}
catch
{
if(th... | 22,046 |
<p>We are having a problem where IE6 (the only browser we have noticed this happening on) seems to be caching an empty version of our main stylesheet. The only way to resolve the problem is to request the stylesheet directly by typing the its url directly into the browser, and then when you refresh the page, it will a... | <p>I can't give you a direct answer, but I would start by installing <a href="http://www.fiddlertool.com/fiddler/" rel="nofollow noreferrer">Fiddler</a> and investigating the <code>Content-type</code> and <code>last-modified</code> response headers of the files that are causing you problems.</p>
<p>Also take note of t... | <p>I also had the same behaviour once. However, I was using a php generated stylesheet, with the headers and every other information (client-side cache, server-side cache, compression) finely tuned in PHP for optimal performance.</p>
<p>Worked like a charm, but it seemed that IE6 did not load the stylesheets on some c... | 46,787 |
<p>I want to know how to create a table where you can adjust the column widths. I have not figured out how to do this. If you know the secret sauce to this technique please let me know.</p>
| <p>There is no simple answer such as "use some foobar html property".
This is done with javascript and DOM manipulations. <br>If you are curious to see an implementation of this feature with Prototype you can take a look at <a href="http://www.millstream.com.au/view/code/tablekit/" rel="nofollow noreferrer">TableKit</... | <p>The Yahoo UI (YUI) <a href="http://developer.yahoo.com/yui/datatable/" rel="nofollow noreferrer">data table</a> widget allows resizing of columns. It's publicly available, but still in Beta, and the YUI library is pretty bulky. Any implementation will have to be in JavaScript/DHTML, because the default HTML tables... | 16,184 |
<p>I'm using SQLAlchemy 0.5rc, and I'd like to add an automatic filter to a relation, so that every time it tries to fetch records for that relation, it ignores the "remote" ones if they're flagged as "logically_deleted" (a boolean field of the child table)</p>
<p>For example, if an object "parent" has a "children" re... | <p>The and_() function is the correct way to do logical conjunctions in SQLAlchemy, together with the & operator, but be careful with the latter as it has surprising precedence rules, i.e. higher precedence than comparison operators. </p>
<p>You could also use a string as a primary join with the text() constructor... | <p>I'm only currently developing agains 0.4.something, but here's how I'd suggest it:</p>
<pre><code>db.query(Object).filter(Object.first==value).filter(Object.second==False).all()
</code></pre>
<p>I think that's what you are trying to do, right?</p>
<p>(Note: written in a web browser, not real code!)</p>
| 33,601 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.