instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have a complex settings style table where individual cells represent different aspects of a data model class. Users can click into a cell and edit individual attributes, such as say if I have a user class, a name, date of birth, etc. My question is, do I need to have an instance of UITextField for each unique cell... | <p>I would recommend creating a subclass of a UITableViewCell. You could do this either purely programaticaly, or if you have an aversion to CGRect's (or want to be able to drag and drop your layout around) with a combination of a XIB and a custom class file.</p>
<p>The Subclass would then contain the UITextFiled's y... | <p>It's better to have the UITableViewController you are using act as the text view delegate for each cell - make sure you are re-using cells and when you create them or reuse them attach your class as the delegate for the UITextViews you have via a custom UITableViewCell class with accessors to get to the UITextViews.... | 44,372 |
<p>I am still new to sharepoint and would like to know if it is possible to make a query that works across several lists. My list looks like this</p>
<p>Customers (id, name and so forth)
Orders ( id, order number, customer and some additional info)
OrderItems (id, name, price, description and so on)</p>
<p>I would li... | <p>Without custom code or third party components you would have only a few options. Using SharePoint Designer to create a Data View or creating a custom Query with some complex CAML which I'm not even sure is entirely possible. </p>
<p>Personally I would look more towards using Master Detail functionality using a comb... | <p>I think SPD can do that.
If you do not want get yourself dirty, take a look at <a href="http://www.boostsolutions.com/listcollection.html" rel="nofollow noreferrer">SharePoint List Collection</a>, which is perfect to you. </p>
| 26,954 |
<p>I'd like to make an (MS)SQL query that returns something like this:</p>
<pre><code>Col1 Col2 Col3
---- --------------------- ------
AAA 18.92 18.92
BBB 20.00 40.00
AAA 30.84 30.84
BBB 06.00 12.00
AAA 30.84 30.84
AA... | <p>You didn't mention what kind of database you're using. Here's something that will work in SQL Server:</p>
<pre><code>SELECT Col1, Col2,
CASE WHEN Col1='AAA' THEN Col2 WHEN Col1='BBB' THEN Col2*2 ELSE NULL END AS Col3
FROM ...
</code></pre>
| <p>Sometimes the values are <code>null</code>, so they can be handled like this:</p>
<pre><code>select Address1 + (case when Address2='' then '' else ', '+Address2 end) +
(case when Address3='' then '' else ', '+ Address3 end) as FullAddress from users
</code></pre>
| 36,642 |
<p>I have downloaded a font that looks less than desirable if it is not anti-aliased. I can not figure out how to enable anti-aliasing in VS, I have changed the 'Smooth Edges of Screen Fonts' in the system performance options but that does not seem to help.</p>
<p>VS2008 on XP SP3.</p>
<p>What am I missing?</p>
| <p>Try using ClearType, not Standard font smoothing. </p>
<p>It's in Display properties, Appearance, Effects.</p>
| <p>Could it be a problem with the color combination? Some fonts look really ugly on high contrast combinations with a black background.</p>
<p>Also, can you see the difference in the fonts in any other application?</p>
<p>Which font is it?</p>
| 6,647 |
<p>I'm looking for a good lightweight Java docking framework.</p>
<p>I know that Netbeans and Eclipse can be used as RCP, but I'm looking for something a little bit more lightweight.</p>
| <ul>
<li><a href="http://raven.java.net/ravenDocking/download.html" rel="nofollow noreferrer">Raven Docking</a> Apache 2; 0.2 MB</li>
<li><a href="http://mydoggy.sourceforge.net/" rel="nofollow noreferrer">MyDoggy</a> LGPL; only JARs: 0.7 MB; Dec 2010</li>
<li><a href="http://code.google.com/archive/p/vldocking/" rel="... | <p>See the <a href="http://www.infonode.net/index.html?idw" rel="nofollow noreferrer">infonode docking windows</a>.</p>
<p>They have a gpl version and a commercial version, but the licenses are not that expensive. Robust and good looking if you select the right skin (we use the ShapedGradientDockingTheme which looks a... | 39,199 |
<p>I have code that lets me select a single item in arange:</p>
<pre><code> COleVariant vItems = cstrAddr;
hr = AutoWrap(
DISPATCH_PROPERTYGET,
&vCell,
irange,
L"Item",
... | <p>You don't need to install the AJAX extensions into the server's GAC.</p>
<p>You can locally reference System.Web.Extensions.dll from your applications BIN folder....I've done it half a dozen times.</p>
<p>Copy that DLL to your projects local bin. Reference it from your project. Remember to deploy the DLL when you ... | <p>Note that most of AJAX is done on the client side (in the browser) in Javascript. </p>
<p>While there are some server-side libraries to make responding to a AJAX query easier, for the most part they are unnecessary. Any server technology that can server a web page to a browser can handle an AJAX request just as we... | 34,443 |
<p>Why can't we initialize members inside a structure ?</p>
<p>example:</p>
<pre><code>struct s {
int i = 10;
};
</code></pre>
| <p>If you want to initialize <strong>non-static</strong> members in <code>struct</code> <strong>declaration</strong>:</p>
<p>In C++ (not C), <code>structs</code> are almost synonymous to classes and can have members initialized in the constructor.</p>
<pre><code>struct s {
int i;
s(): i(10)
{
}
};
</... | <p>As you said it's just a member not a variable. When you declare a variable the compiler will also provide memory space for those variables where you can put values. In the case a of a struct member the compiler is not giving memory space for it, so you cannot assign values to struct members unless you create a varia... | 27,823 |
<p>Given an instance of <code>System.Reflection.Assembly</code>.</p>
| <p>Not possible. Nothing specifies a "Root" namespace. The default namespace in the options is a visual studio thing, not a .net thing</p>
| <p>Namespaces have nothing to do with assemblies - any mapping between a namespace and the classes in an assembly is purely due to a naming convention (or coincidence).</p>
| 12,193 |
<p>I'm having a friendly debate with a developer about a situation where users are logging in and accessing documents in a web application. When we load the document for the user to view, we have the userID in session and the documentID that may be passed via QueryString.</p>
<p>To prevent the user from modifying the ... | <blockquote>
<p>I propose that the stored procedure
that loads the document take the
UserId as a parameter to validate
rights to the document.</p>
</blockquote>
<p>I think this is the way to go. If for no other reason than it's safer. If you reuse this proc, and then forget to check the access - you've opene... | <p>The userID should be a session variable. Right. Pass the documentID in the querystring. Yup.</p>
<p>Assuming the documents are stored in the database, I would have a table for permissions: a recordID a userID and a documentID. You do a join with this table when calling up the document. If you don't get a result, yo... | 31,761 |
<p>I have an XHTML strict page that has an invisible div that is controlled by Javascript. The div is set to transparent and visible by the script and a mouseover event to make the div opaque on hover.</p>
<p>When someone using a browser (or firefox with noscript) without javascript the div simply remains invisible. T... | <p>noscript in head is valid HTML5. It wasn't valid before. I just tested it, it works in current Firefox, Safari, Chrome, Opera and IE.</p>
<pre><code><!doctype html>
<html>
<head>
<noscript>
<style>body{background:red}</style>
</noscript>
... | <p>What validation error do you get? <code><noscript></code> should be allowed in XHTML but it's block level, so make sure it's not in a <code><p></code>, <code><span></code>, etc</p>
| 26,842 |
<p>I'm having a lot of difficulty removing support material without damaging the print.</p>
<p><img src="https://i.imgur.com/EVtUHms.jpg" alt="Support material">
<img src="https://i.imgur.com/8akiidF.jpg" alt="Support marterial"></p>
<p>Are there any tips/tricks to doing this or is it just a case of sanding, cutting,... | <h2>Print/material specific settings</h2>
<p>If you are printing <em><strong>too hot with too less distance</strong></em>, <em><strong>the support just fuses to the print object</strong></em>. Extra cooling, lower print temperature and support distance should be in balance to create easy to remove support structures wi... | <p>It is recommended that you try "tree support" in the "experimental" module of settings.Also,before removing the support, blowing with a hot air gun to soften the support material connected to the model may achieve good results.</p>
| 1,185 |
<p>I am monitoring a folder with a .net filewatcher for certain kind of files(*.mbxml). I am using the created event of filewatcher for it. Once the created event fires I have to move this file to another folder. The problem with this approach is that the created event is fired as soon as the file copying starts. So if... | <p>i have yet to see this done in anyway except with a try catch block. usually on the oncreate event i set a bool that try's to open the file. this determines if the rest of the code proceeds, if there is another way i would be interested as well.</p>
<pre><code> private static bool creationComplete(string fileNam... | <p>If I recall correctly, the FileWatcher raises several events per IO on a given file/folder. You may be able to narrow down the FileSystemEventArgs associated with completion. It may be necessary to defer to checking if the file is accessible, but I would think it a less desirable solution.</p>
| 35,106 |
<p>I've got a Visual Studio 2008 solution with a WCF service, and a client.</p>
<p>When I run my client, and call a method from my service I get a message saying "Unable to automatically debug 'Home.Service'. The remote procedure could not be debugged. This usually indicates that debugging has not been enabled on the ... | <p>In my case the problem turned out to be a mismatch between security settings on client and server. I was using a custom binding like this:</p>
<pre><code><customBinding>
<binding name="AuthorisedBinaryHttpsBinding" receiveTimeout="00:03:00" sendTimeout="00:03:00">
<!-- this next element cau... | <p>Add this line of code after you create your service reference in your client.</p>
<pre><code>MyWCFService.IService _proxy = new MyWCFService.IService();
_proxy.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
</code></pre>
| 40,693 |
<p>I am writing a component that, given a ZIP file, needs to:</p>
<ol>
<li>Unzip the file.</li>
<li>Find a specific dll among the unzipped files.</li>
<li>Load that dll through reflection and invoke a method on it.</li>
</ol>
<p>I'd like to unit test this component.</p>
<p>I'm tempted to write code that deals dire... | <p>There's really nothing wrong with this, it's just a question of whether you call it a unit test or an integration test. You just have to make sure that if you do interact with the file system, there are no unintended side effects. Specifically, make sure that you clean up after youself -- delete any temporary file... | <p>You should not test class interaction and function calling. instead you should consider integration testing. Test the required result and not the file loading operation.</p>
| 15,690 |
<p>I've been reading about "web services" here on SO, on Wikipedia, Google, etc., and I don't quite understand what they are. What is the plain English definition/description?</p>
<p>If I make a simple website using PHP that just, say, prints a random integer to the page... is this a "web service"? If not, why not?<... | <p>A simple definition: A web service is a function that can be accessed by other programs over the web (HTTP). </p>
<p>For example, when you create a website in PHP that outputs HTML, its target is <em>the browser</em> and by extension the human reading the page in the browser. A web service is not targeted at humans... | <p>'Web Service' is composed of two words,'Web' and 'Service'.<br>
What is 'Web'? 'Web' means 'World Wide Web'.<br>
'Service' for what? Not for Human,if so,it's 'Web Page',such as text,images,video etc.<br>
It's for Programs to communicate through the Internet using the same technology the 'Web' used,such as TCP,HTTP e... | 27,954 |
<p>Is there an event for when a document is edited?
If not, does anyone know where I could find a list of the available VBA events?</p>
| <p>Here are the events for the document object:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa140279(office.10).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa140279(office.10).aspx</a></p>
<p><strong>Events</strong></p>
<pre><code>DocumentBeforeClose : Immediately before any o... | <p>To intercept any Word command, you can:</p>
<p>1.</p>
<p>Press Alt+ F8 to bring up the Macros dialog and where it says “Macros in”,
select “Word Commands”.</p>
<p>2.</p>
<p>Find and select one of the commands you want to intercept – for instance, to intercept the Print commands you need to find FilePrint and Fi... | 33,815 |
<p>Once I have my renamed files I need to add them to my project's wiki page. This is a fairly repetitive manual task, so I guess I could script it but I don't know where to start.</p>
<p>The process is:</p>
<pre><code>Got to appropriate page on the wiki
for each team member (DeveloperA, DeveloperB, DeveloperC)
{
... | <p>Check if the wiki you mean to talk to supports <a href="http://www.jspwiki.org/wiki/WikiRPCInterface2" rel="nofollow noreferrer">XMLRPC</a>, because if it does it should be a snap. I wrote a tool called <a href="http://trac.gargoyle.ath.cx/trac/wiki/WikiUp" rel="nofollow noreferrer">WikiUp</a> to solve a similar pro... | <p>If you're writing in C#, the WebClient classes might be a good place to start. I bet people could give more specific advice if you mentioned which wiki platform you are using, and whether it requires authentication, though.</p>
<p>I'd probably start by downloading fiddler and watching the http requests from doing ... | 3,347 |
<p>I'm currently using the ActiveRecord-based session store for my Rails app and I have a background process which clears out inactive sessions every 30 minutes.</p>
<p>I'd like to switch to Rails' new cookie-based session store but how do I set the expiry time of the session to 30 minutes, as opposed to the default '... | <p>I stumbled across this question after a conversation in the office. Just for the sake of completeness, I've discovered that it is possible to expire sessions after a period of inactivity and it's built into Rails. In config/environment.rb, do something along the lines of:</p>
<pre><code>config.action_controller.ses... | <p>You could try adding the following line to your environment.rb file:</p>
<pre><code>session :session_key => 'my_session_key'
session :session_expires => 1.day.from_now
</code></pre>
<p>Alternatively, you can set the session options as follows:</p>
<pre><code>ActionController::Base.session_options[:session_e... | 31,069 |
<p>I'm working on a DCOM application with the server and client on two machines, both of which are running WinXP with Service Pack 2. On both machines, I'm logged in with the same username and password.</p>
<p>When the client on one machine calls CoCreateInstanceEx, asking the other machine to start up the server appl... | <p>Right, so if your Authentication level is set to Default. What is the authentication level set to in the Default Settings? Just out of interest. (although the fact that it works to a 2000 box probably makes that redundant)</p>
<p>EDIT:</p>
<p>Also: I seem to remember doing a lot of rebooting when I used to play/wo... | <p>What is the flavor of your Windows 2000 box, btw? Professional, Server, Adv Server...</p>
<p>Also, is there a difference between domain membership between the two (one on a domain, the other not, different domains, etc...?)</p>
<p>One more thing - DCOM errors will appear in the System event log at times - especial... | 4,120 |
<p>What translation occurs when writing to a file that was opened in text mode that does not occur in binary mode? Specifically in MS Visual C.</p>
<pre><code>unsigned char buffer[256];
for (int i = 0; i < 256; i++) buffer[i]=i;
int size = 1;
int count = 256;
</code></pre>
<p>Binary mode:</p>
<pre><code>FILE *fp... | <p>I believe that most platforms will ignore the "t" option or the "text-mode" option when dealing with streams. On windows, however, this is not the case. If you take a look at the description of the fopen() function at: <a href="http://msdn.microsoft.com/en-us/library/yeby3zcb(vs.71).aspx" rel="noreferrer">MSDN</a>... | <p>In 'w' mode, the file is opened in write mode and the basic coding is 'utf-8'
in 'wb' mode, the file is opened in write -binary mode and it is resposible for writing other special characters and the encoding may be 'utf-16le' or others </p>
| 28,461 |
<p>I have 2 SQLite databases, one downloaded from a server (<code>server.db</code>), and one used as storage on the client (<code>client.db</code>). I need to perform various sync queries on the client database, using data from the server database.</p>
<p>For example, I want to delete all rows in the <code>client.db t... | <p>I just looked at the AIR SQL API, and there's an <code>attach</code> method on <code>SQLConnection</code> it looks exactly what you need.</p>
<p>I haven't tested this, but according to the documentation it should work:</p>
<pre><code>var connection : SQLConnection = new SQLConnection();
connection.open(firstDbFile)... | <p>this code can be work,it is write of me:</p>
<pre><code>package lib.tools
import flash.utils.ByteArray;
import flash.data.SQLConnection;
import flash.data.SQLStatement;
import flash.data.SQLResult;
import flash.data.SQLMode;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
import flash.filesystem.... | 2,462 |
<p>I have been investigating for some time now a way to prevent my user from accidently entering a data directory of my application.</p>
<p>My application uses a folder to store a structured project. The folder internal structure is critic and should not be messed up. I would like my user to see this folder as a whole... | <p>Inside, or outside of your program?</p>
<p>There are ways, but none of them easy. You are probably going to be looking at a Filter Driver on the file system.</p>
| <p>You could wrap your project directory into a .zip file and store your data there, much like a .jar is used (I know a .jar is pretty much read only, it's for sake of the example). Make a non-standard extension so that a double-click has no immediate effect, done. ;-)</p>
<p>Of course this means you would have to wra... | 47,485 |
<p>I can hookup to <code>AppDomain.CurrentDomain.UnhandledException</code> to log exceptions from background threads, but how do I prevent them terminating the runtime?</p>
| <p>First, you really should try not to have exceptions thrown - and not handled - in a background thread. If you control the way your delegate is run, encapsulate it in a try catch block and figure a way to pass the exception information back to your main thread (using EndInvoke if you explicitly called BeginInvoke, or... | <p>Here is a great blog post about this problem: <a href="http://www.julmar.com/blog/mark/PermaLink,guid,f733e261-5d39-4ca1-be1a-c422f3cf1f1b.aspx" rel="nofollow noreferrer">Handling "Unhandled Exceptions" in .NET 2.0</a></p>
<p>IMO it would be right to handle exceptions in background threads manually and re-throw the... | 22,616 |
<pre><code>Foo* set = new Foo[100];
// ...
delete [] set;
</code></pre>
<p>You don't pass the array's boundaries to <code>delete[]</code>. But where is that information stored? Is it standardised?</p>
| <p>When you allocate memory on the heap, your allocator will keep track of how much memory you have allocated. This is usually stored in a "head" segment just before the memory that you get allocated. That way when it's time to free the memory, the de-allocator knows exactly how much memory to free.</p>
| <p>It is not standardized. In Microsoft's runtime the new operator uses malloc() and the delete operator uses free(). So, in this setting your question is equivalent to the following: How does free() know the size of the block?</p>
<p>There is some bookkeeping going on behind the scenes, i.e. in the C runtime.</p>
| 24,051 |
<p>Is there a way to embed a browser in Java? more specifically, is there a library that can emulate a browser?</p>
| <p>Since JavaFX 2.0 you can use now <a href="http://docs.oracle.com/javafx/2.0/webview/jfxpub-webview.htm" rel="noreferrer">webview</a></p>
<p><img src="https://i.stack.imgur.com/WUfqs.png" alt="enter image description here"></p>
| <p>If you look at The Minecraft launcher (the old one), look through LoginForm or LauncherFrame, you may be able to find out that method. There is a tutorial by kippykip on youtube on how to decompile and edit it: <a href="http://www.youtube.com/watch?v=n_bh-c2nO7k" rel="nofollow">here</a></p>
| 7,063 |
<p>How do I write the SQL code to INSERT (or UPDATE) an array of values (with probably an attendant array of fieldnames, or with a matrix with them both) without simple iteration?</p>
| <p>I construct the list as an xml string and pass it to the stored procs. In SQL 2005, it has enhanced xml functionalities to parse the xml and do a bulk insert.</p>
<p>check this post:
<a href="http://weblogs.asp.net/jgalloway/archive/2007/02/16/passing-lists-to-sql-server-2005-with-xml-parameters.aspx" rel="nofollow... | <p>I understand that you are talking about writing stored procedure to accept array of values</p>
<p>With SQL Server 2005 you would need to use XML variable</p>
<p>SQL 2008 adds support to table variable as parameters</p>
<p>Here you can find good examples of passing a table to a stored procedure as <a href="http://... | 20,251 |
<p>I have a web application that needs to fire off a long-running SQL Server procedure (to rebuild a table) when certain criteria are met. What is the recommended procedure to do this?</p>
<p>I was thinking, when the criteria are met a record would be inserted into the database and a scheduled SQL server job would che... | <p>Your approach is definetly viable and is one way I've seen it done. For example in a complex web which had gigabytes of inventory data, the company implemented basically what you described to allow partial updating of the inventory data throughout the day.</p>
<p>Some other approaches I've seen involved a schedulin... | <p>If you don't have to worry about the results after making a call to execute the stored procedure, it might be good to run it asynchronously.</p>
| 38,060 |
<p>I am new to any scripting language. But, Still I worked on scripting a bit like tailoring other scripts to work for my purpose. For me, What is the best online resource to learn Python?</p>
<p>[Response Summary:] </p>
<p>Some Online Resources:</p>
<p><a href="http://docs.python.org/tut/tut.html" rel="nofollow nor... | <p>If you need to learn python from scratch - you can start here: <a href="http://docs.python.org/tut/tut.html" rel="nofollow noreferrer">http://docs.python.org/tut/tut.html</a> - good begginers guide</p>
<p>If you need to extend your knowledge - continue here <a href="http://diveintopython3.ep.io/" rel="nofollow nore... | <p>There are some screencasts on <a href="http://showmedo.com" rel="nofollow noreferrer">http://showmedo.com</a></p>
| 9,601 |
<p>I'm getting ready to start a new project and I've been researching the entity framework. My question is what is the best strategy for validating the entities? Other projects I've worked on have used attributes for most of the validation, but obviously this is not possible in the entity framework. Is the only way to ... | <p>I have not actually used the Entity framework before but a quick search indicates that you have several options.</p>
<p>1) Validate at another layer in your application</p>
<p>Always an option, I just thought I would throw it out there explicitly.</p>
<p>2) Hook into the OnChanged events of the Entity then perfor... | <p>If you are using WPF or Windows Forms then you might implement the <strong>IDataErrorInfo</strong> interface.</p>
<p>The <strong>BookLibrary</strong> sample application of the <strong><a href="http://waf.codeplex.com" rel="nofollow noreferrer">WPF Application Framework (WAF)</a></strong> project shows how entities ... | 23,206 |
<p>In F#, you can generate a set of numbers, just by saying [1..100].</p>
<p>I want to do something similar in C#. This is what I have come up with so far:</p>
<pre><code>public static int[] To(this int start, int end)
{
var result = new List<int>();
for(int i = start; i <= end; i++)
result.... | <p>Enumerable.Range(1, 100);</p>
| <p>I think something like <code>Set(1,100)</code> or <code>IntSequence(1,100)</code> is easier to read than using an extension method.</p>
<p>Personal opinion though...</p>
| 48,514 |
<p>I have a DataGridView bound to a DataTable. I have one column that's a pseudo-int -- you know the kind, where most of the time it has integers but sometimes instead there's an N/A. This column is a varchar, but I want to have it sort like an int column, treating the N/A as a -1.</p>
<p>The DataGridView provides for... | <p>When I've had to deal with sorting problems similar to this, my favorite method is to add a column to the DataTable and parse the pseudo-int into the sortable int that I want. Then in the DataGridView's binding you can simply hide that column of data, but because it's there you can still sort on it. It adds a little... | <p>Perhaps you can adapt the code in my blog post to provide an IComparer specific to your int column:</p>
<p><a href="http://adamhouldsworth.blogspot.com/2010/01/bound-datagridview-sorting.html" rel="nofollow noreferrer">http://adamhouldsworth.blogspot.com/2010/01/bound-datagridview-sorting.html</a></p>
| 34,964 |
<p>I'd like to have comments in my code, but I want them to be removed before deploying.
Yes, it's not hard to write such a thing, but if it already exists…
And how about comments in ASP pages?</p>
| <p>Sounds like you are looking for a JSMin tool or similar.</p>
<p>There are many tools which you can purchase, but there are also some online tools you can use:</p>
<p><a href="http://www.askapache.com/tools/online-compression-tool-compares-packer-jsmin-dojo-and-yui-compressor.html" rel="nofollow noreferrer">http://... | <p>Are you going to compress at runtime? I'd use <a href="http://www.smallsharptools.com/Projects/Packer/" rel="nofollow noreferrer">packer</a> and compress your javascript through a generic handler. </p>
| 25,725 |
<p>How is it possible for this to be true</p>
<pre><code>XmlDocument d = BuildReportXML(schema);
DataSet ds = new DataSet();
ds.ReadXmlSchema(schema);
ds.ReadXml(new XmlNodeReader(d));
</code></pre>
<p>Schema is the schema location that I apply to the XmlDocument before I start setting data, assuring that all the col... | <p>These <a href="http://www.quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html" rel="noreferrer">quirksmode.org bug report and comments</a> about innerHTML behaviour of Internet Explorer could help:</p>
<p>"<em>IE applies <strong>HTML normalization</strong> to the data that is assigned to the innerHTML p... | <pre><code>if (typeof div2.innerText == 'undefined')
div2.innerHTML = value;
else
div2.innerText = value;
</code></pre>
<p>that worked for me.</p>
| 23,734 |
<p>How can I set points on a 24h period spreaded by the Gaussian distributions? For example to have the peak at 10 o'clock?</p>
| <p>The following code generates a gaussian distributed random time (in hours, plus fractions of an hour) centered at a given time, and with a given standard deviation. The random times may 'wrap around' the clock, especially if the standard deviation is several hours: this is handled correctly. A different 'wrapping' a... | <p>If you have trouble generating gaussian distributed random points look up <a href="http://en.wikipedia.org/wiki/Box-Muller_transform" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Box-Muller_transform</a></p>
<p>Else please clarify your question.</p>
| 18,346 |
<p>If I start a process via Java's <a href="http://java.sun.com/javase/6/docs/api/java/lang/ProcessBuilder.html" rel="noreferrer">ProcessBuilder</a> class, I have full access to that process's standard in, standard out, and standard error streams as Java <code>InputStreams</code> and <code>OutputStreams</code>. However... | <p>You will need to copy the <a href="http://java.sun.com/javase/6/docs/api/java/lang/Process.html" rel="noreferrer">Process</a> out, err, and input streams to the System versions. The easiest way to do that is using the <a href="http://commons.apache.org/io/api-release/org/apache/commons/io/IOUtils.html" rel="norefer... | <p>For <code>System.in</code> use the following <code>pipein()</code> instead of <code>pipe()</code></p>
<pre><code>pipein(System.in, p.getOutputStream());
</code></pre>
<p>Implementation:</p>
<pre><code>private static void pipein(final InputStream src, final OutputStream dest) {
new Thread(new Runnable() {
... | 8,518 |
<p>I'm running an old little app which runs in the browser from local files, and I keep getting the, "To help protect your security, Internet Explorer has restricted this webpage from running scripts or Activex controls that could access your computer" message.</p>
<p>Is there a registry setting or something I can twe... | <p>Internet Options > Advanced > Security > Allow active content to run in files on My Computer</p>
| <p>you need to add the local file system (file://*) to the safe websites in the security settings.</p>
| 18,294 |
<p>Has anyone worked much with Microsoft's Managed Extensibility Framework (MEF)? Kinda sounds like it's trying to be all things to all people - It's an add-in manager! It's duck typing! I'm wondering if anyone has an experience with it, positive or negative.</p>
<p>We're currently planning on using an generic IoC imp... | <p>We are not aiming for MEF to be an all-purpose IoC. The best way to think about the IoC aspects of MEF is an implementation detail. We use IoC as a pattern because it is a great way to address the problems we are looking to solve. </p>
<p>MEF is focused on extensibility. When you think of MEF look at it as an inves... | <p>More detailed discussion on this in this post and the comments</p>
<p><a href="http://mikehadlow.blogspot.com/2008/09/managed-extensibility-framework-why.html" rel="nofollow noreferrer">http://mikehadlow.blogspot.com/2008/09/managed-extensibility-framework-why.html</a> </p>
| 6,369 |
<p>I'm trying to preform setup and teardown for a set of integration tests, using jUnit 4.4 to execute the tests. The teardown needs to be run reliably. I'm having other problems with TestNG, so I'm looking to port back to jUnit. What hooks are available for execution before any tests are run and after all tests have c... | <p>Yes, it is possible to reliably run set up and tear down methods before and after any tests in a test suite. Let me demonstrate in code:</p>
<pre><code>package com.test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.run... | <p>As far as I know there is no mechanism for doing this in JUnit, however you could try subclassing Suite and overriding the run() method with a version that does provide hooks.</p>
| 10,862 |
<p>I prefer dark backgrounds for coding, and I've downloaded a jar file containing an IntelliJ IDEA color theme that has a dark background. How do I tell IntelliJ about it?</p>
| <p>Go to File->Import Settings... and select the jar settings file</p>
<p>Update as of <strong>IntelliJ 2020</strong>:</p>
<p>Go to File -> Manage IDE Settings -> Import Settings...</p>
| <p>Find the .jar theme file in your disk. Drag the file into PhpStorm window and voila !</p>
| 6,025 |
<p>When attempting to open a project from source control on a newly formatted pc, I receive an "unable to get the project file from the web server" after getting the sln file from VSS. If I attempt to open the sln file from explorer, I also receive the same error.</p>
<p>Any pointers or ideas?</p>
<p>Thanks!</p>
| <p>This question is very old so you have probably solved the issue, but just in case: Does the project file use IIS? If so then it is probably trying to read the project file from IIS and the virtual directory does not exist on the newly formatted computer. Also, there should be more detail about the message in the Out... | <p>Is there anything odd in your sln file? Have you opened it with a text editor to see if it is linking to a remote resource?</p>
| 8,925 |
<p>Is there a way to implement forms authentication, but only for a specific URL. For example, I would want the formsAuthentication to protect the site on staging.mydomain.com but not hinder access to www.mydomain.com if the web.config accidentally got moved over to the production site. </p>
| <p>This can be achieved, but you'll have to implement your own IHttpModule for it. Alas FormsAuthenticationModule is sealed, meaning that you would have to start from scratch, but <a href="http://www.red-gate.com/products/reflector/" rel="nofollow noreferrer">Reflector</a> can be a great help there.</p>
| <p>Forms auth is implemented on the web site instance. Its not going to work that way.</p>
| 11,070 |
<p>I am getting this error now that I hit version number 1.256.0:
Error 4 Invalid product version '1.256.0'. Must be of format '##.##.####'</p>
<p>The installer was fine with 1.255.0 but something with 256 (2^8) it doesn't like. I found this stated on msdn.com:
The Version property must be formatted as N.N.N, whe... | <p>Change it to:</p>
<pre><code>protected static <T extends Comparable<T>> int nullCompare(T o1, T o2) {
</code></pre>
<p>You need that because Comparable is itself a generic type.</p>
| <p>I'm not sure that genericizing this method makes sense. Currently the method works on any kind of Comparable; if you genericize it you will have to implement it (with exactly the same code) multiple times. Sometimes it is possible to compare two objects that don't have a common ancestor, and any generic version won'... | 8,359 |
<p>Upon reading a <a href="http://grandtextauto.org/2008/11/20/story-generation-in-1k/" rel="nofollow noreferrer">blog post about a minimalist story-generating python program</a>, I was asking myself - and you - which are the most successful attempts at such programs. I remember seeing something using generating gramma... | <p>Search for Talespin for some famous ground breaking work. (Example: <a href="http://norvig.com/ltd/test/micro-tale-spin.lisp" rel="nofollow noreferrer">Micro-Talespin in Common Lisp</a> by Warren Sack.)</p>
| <p>Search for Talespin for some famous ground breaking work. (Example: <a href="http://norvig.com/ltd/test/micro-tale-spin.lisp" rel="nofollow noreferrer">Micro-Talespin in Common Lisp</a> by Warren Sack.)</p>
| 39,695 |
<p>I get this error:-</p>
<p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' at line 1</p>
<p>whenever I tried something like this:-</p>
<pre><code>mysql> source /home/user1/sql/ddl.sql
mysql> source /home/user1/sql/inse... | <p>A possibility is that the SQL files were written in Unicode with a <a href="https://en.wikipedia.org/wiki/Byte_Order_Mark" rel="nofollow noreferrer">BOM</a>, which MySQL cannot interpret. </p>
<p>That would explain the symptoms.</p>
<p>A solution is to open them in a decent editor and save them back without it.</p... | <p>Your input files may contain a <a href="http://en.wikipedia.org/wiki/Byte_Order_Mark" rel="nofollow noreferrer">Unicode BOM</a>, which is a bit of cruft that some programs such as Notepad place at the start of the file to indicate the file format.</p>
| 24,955 |
<p>It's criminal how wasteful the Stratsys uPrint SE Plus is with it's 'one use' modelling bases. Is there a reliable way to re purpose them? I have tried ethanol and acetone, but not had any luck. </p>
| <p>People have done quite a bit of experimenting with reusing Mojo build plates over the years. The uPrint is likely similar. Basically a different adhesion layer is placed on the bed that has easier release. BuildTak has been used successfully. Gluestick or hairspray such as Aquanet will work and are water soluble for... | <p>By oversight in training, the operators of one of our UPrint SE Plus printers was simply placing the tray in the bath with the printed part. After it was in the bath, all support material was removed and they dried and reused the tray. This process was used for months before it was discovered, and they used the sa... | 337 |
<p>I'm working on a Java based project that has a client program which needs to connect to a MySQL database on a remote server. This was implemented is as follows:</p>
<p>Use JDBC to write the SQL queries to be executed which are then hosted as a servlet using Apache Tomcat and made accessible via XML-RPC. The client ... | <p>The <a href="https://archive.org/details/pdfy-MgN0H1joIoDVoIC7" rel="nofollow noreferrer">AWK book</a> is full of great examples. They used to be collected for download from <a href="http://cm.bell-labs.com/cm/cs/who/bwk/awkcode.txt" rel="nofollow noreferrer">Kernighan's webpage</a> (404s now).</p>
| <p>Count memory used by httpd</p>
<pre><code>ps -ylC httpd | awk '/[0-9]/ {SUM += $8} END {print SUM/1024}'
</code></pre>
<p>Or any other process by replacing httpd. Dividing by 1024 to get output in MB.</p>
| 34,482 |
<pre><code>sqlite> DELETE FROM mails WHERE (`id` = 71);
SQL error: database is locked
</code></pre>
<p>How do I unlock the database so this will work?</p>
| <p>In windows you can try this program <a href="http://www.nirsoft.net/utils/opened_files_view.html" rel="noreferrer">http://www.nirsoft.net/utils/opened_files_view.html</a> to find out the process is handling db file. Try closed that program for unlock database</p>
<p>In Linux and macOS you can do something similar, ... | <p>From your previous comments you said a -journal file was present. </p>
<p>This could mean that you have opened and (EXCLUSIVE?) transaction and have not yet committed the data. Did your program or some other process leave the -journal behind??</p>
<p>Restarting the sqlite process will look at the journal file and ... | 18,208 |
<p>In my rails app I use the validation helpers in my active record objects and they are great. When there is a problem I see the standard "3 errors prohibited this foobar from being saved" on my web page along with the individual problems. </p>
<p>Is there any way I can override this default message with my own?</p>
| <p>The <code>error_messages_for</code> helper that you are using to display the errors accepts a <code>:header_message</code> option that allows you to change that default header text. As in:</p>
<blockquote>
<p><code>error_messages_for 'model', :header_message => "You have some errors that prevented saving this ... | <p>You can iterate over the model.errors hash yourself instead of using the errors helper.</p>
| 15,256 |
<p>Is there a way to programmatically disable usb storage devices from working while still keeping usb ports functional for other types of devices like keyboards and mice?</p>
| <p>Taken from <a href="http://www.pragmaticutopia.com/content/view/89/125/" rel="noreferrer">here</a>, not tested:</p>
<pre><code>Directions for Use:
1.) Take the following blue text, copy it, and paste it into a text document. Then, save it as USBSTOR.ADM.
CLASS MACHINE
CATEGORY "Custom Policies"
KEYNAME "SYSTEM\... | <ol>
<li>first restart your machine </li>
<li>open registry </li>
<li><code>HKEY_LOCAL_MACHINE</code></li>
<li>System</li>
<li>CurrentControlSet</li>
<li>Service</li>
<li>USBstore</li>
<li>set <em>Disable</em> to <code>4</code> and <em>Enable</em> to <code>3</code></li>
</ol>
| 47,679 |
<p>I've been writing a lot recently about Parallel computing and programming and I do notice that there are a lot of patterns that come up when it comes to parallel computing. Noting that Microsoft already has released a library along with the Microsoft Visual C++ 2010 Community Technical Preview (named Parallel Patter... | <p>Patterns:</p>
<ul>
<li><p>Produce/Consumer</p>
<ul>
<li>One Thread produces data</li>
<li>One Thread consumes the data</li>
</ul></li>
<li><p>Loop parallelism</p>
<ul>
<li>If you can show that each loop is independent<br>
each iteration can be done in a sperate thread</li>
</ul></li>
<li><p>Re-Draw Thread</p>
<u... | <p>You have the basics that bolt on parallelism to parts of a program. C++17 is getting many of them (e.g. parallel versions of foreach, sort, find and friends, map_reduce, map, reduce, prefix_sum ... ) see <a href="http://en.cppreference.com/w/cpp/experimental/parallelism" rel="nofollow noreferrer">C++ Extensions for... | 31,924 |
<p>I'm currently using the sun preverifier to preverify my MIDlet. I'm finding that it can be a bit slow, doesnt give any decent error messages and is only available as a windows exe.</p>
<p>Are there any better preverifiers around that will work cross platform (linux specifically)</p>
| <p>Proguard can preverify jar files. I guess you could disable the obfuscation if you didn't want that and just preverify with it.</p>
<p>It's a java application so it should run on Linux too.</p>
<p><a href="http://proguard.sourceforge.net/manual/examples.html#microedition" rel="nofollow noreferrer">http://proguard.... | <p>Actually there is also a linux version of WTK (from Sun) and I am using it every day on Ubuntu. Can't really comment on the speed.</p>
<p>About <code>Proguard</code> preverification - for some reasons this does not work, for me, on some jars and I have not been able to figure out why. Running 'preverified' jar with... | 20,069 |
<p>I would like to have an app include a custom font for rendering text, load it, and then use it with standard <code>UIKit</code> elements like <code>UILabel</code>. Is this possible?</p>
| <p>iOS 3.2 and later support this. Straight from the <em>What's New in iPhone OS 3.2</em> doc:</p>
<blockquote>
<p><strong>Custom Font Support</strong><br>
Applications that want to use custom fonts can now include those fonts in their application bundle and register those fonts with the system by including the UI... | <p>As an enhancement @bdev's <a href="https://stackoverflow.com/a/12935465/188331">answer</a>, here is an updated version for listing out custom fonts only.</p>
<p><strong>Step 1: Find out all system fonts using @bdev's answer & save to file.</strong></p>
<p>Put the following code in first View Controller's <code... | 47,078 |
<p>I have an interface A, for which I have to supply a few different
implementations. However, those implementations share some helper methods, so
I moved those methods to an abstract base class.</p>
<pre><code>Interface A {
void doX();
}
abstract Class B implements A {
protected void commonY() {
// .... | <p>I think it would be better to do it as follows:</p>
<pre><code>Interface A {
void doX();
}
abstract Class B {
protected void commonY() {
// ...
}
}
Class C extends B implements A{
public void doX() {
// ...
}
}
Class D extends B implements ... | <p>An abstract class implementing an interface must implement that interface. Specifically, it must have a public method for every method-name-and-signature specified in that interface.</p>
<p>Inheritance is transitive. You do not need to write that class C implements interface A if class C derives class B which imple... | 45,898 |
<p>I'm absolutely in love with the way GWT does RPC. Is there anything similar for Java SE you have experience with that:</p>
<ol>
<li>Is not spring</li>
<li>Doesn't require a Java EE/Servlet container to run the server side</li>
<li>Is not RMI that comes with Java SE</li>
</ol>
| <p><a href="http://mina.apache.org/" rel="nofollow noreferrer">Apache Mina</a>. Not true rpc but easy to use and surely a option to consider. </p>
| <p>Did you try sfnrpc (<a href="http://code.google.com/p/sfnrpc" rel="nofollow">http://code.google.com/p/sfnrpc</a>)
No spring required.
You can run multiple servers within same JVM
You can have a client connect to multiple servers also.
No event style programming, but supports asynch and synch calls over nio.</p>
| 18,459 |
<p>I use a console application to write some test code:</p>
<pre><code> /// <summary>
/// Returns AD information for a specified userID.
/// </summary>
/// <param name="ntID"></param>
/// <returns></returns>
public ADUser GetUser(string ntID)
{ ... | <p>You're already using groovy, does using a regular expression that gives you your answer work?</p>
<pre><code>def file = new File("file.txt")
file.delete() // clear out old version for multiple runs
file << """
foobar clientLogin=a@yahoo.com baz quux # should match a@yahoo.com
foobar email=a@yahoo.com b... | <p>You need {}'s around the variable expression. That is:</p>
<pre><code> "${l.get(0)}"
</code></pre>
<p>See <a href="http://groovy.codehaus.org/JN1525-Strings" rel="nofollow noreferrer">Groovy String</a> documentation for more information. </p>
<p>Full example:</p>
<pre><code>List l = new ArrayList{a@yahoo.com, ... | 45,639 |
<p>I'm looking for syntatic examples or common techniques for doing regular expression style transformations on words instead of characters, given a procedural language. </p>
<p>For example, to trace copying, one would want to create a document with similar meaning but with different word choices.</p>
<p>I'd like to ... | <p>One good place to start researching would be "Word Net" - it's a dictionary of semantics, grouping words together by similar meaning, and also recording the relationships between words in useful ways.</p>
<p>There are a bunch of software projects leveraging the Word Net corpus, one of them may be what you need.</p>... | <p>I am not aware of any syntaxes that exist for English language processing like you discuss. You would need to create your own DSL using one of the toolsets (such as Word Net) out there.</p>
| 28,296 |
<p>How often should I commit changes to source control ? After every small feature, or only for large features ?</p>
<p>I'm working on a project and have a long-term feature to implement. Currently, I'm committing after every chunk of work, i.e. every sub-feature implemented and bug fixed. I even commit after I've add... | <p>Anytime I complete a "full thought" of code that compiles and runs I check-in. This usually ends up being anywhere between 15-60 minutes. Sometimes it could be longer, but I always try to checkin if I have a lot of code changes that I wouldn't want to rewrite in case of failure. I also usually make sure my code comp... | <p>I like to commit changes every 30-60 minutes, as long as it compiles cleanly and there are no regressions in unit tests.</p>
| 13,279 |
<p>As a new Eclipse user, I am constantly annoyed by how long it takes compiler error messages to display. This is mostly only a problem for long errors that don't fit in the status bar or the "Problems" tab. But I get enough long errors in Java—especially with generics—that this is a nagging issue. (Note: ... | <p>Well, you can press F2 to display the popup that normally shows javadoc. If there's an error, it will display the error message with available quick fixes.</p>
<p>So you can do Ctrl+., F2 repeatedly to achieve what you want.</p>
| <p>Yeah nagging problem. <code>Ctrl+1</code> brings up the quick fixes if you use it from the same line. Sometimes I have to resort to copying the error message from the problems view :(</p>
| 20,166 |
<p>The attached code example (pseudo code) compiles, but throws this Run-Time Error:</p>
<pre><code>TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/getChildIndex()
at mx.core::Container/getChildIndex()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Con... | <p>when selectedChild is fired the viewStack doesn't have any children added so it throws a NullPointerException:</p>
<p>The following will work:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
... | <p>tried this:</p>
<pre><code>selectedChild="{this[targetViewName]}">
</code></pre>
<p>/Niels</p>
| 41,170 |
<p>Can I integrate my exsisting C++ library in an iPhone application?</p>
| <p>Objective C++ is well defined and supported by Apple's gcc.</p>
<p>But you can't mix C++ and objective C classes, which makes this rather messy pretty fast. I don't think there are many projects in the wild which mix C++ and Objective C to any serious extent.</p>
<p>This highly depends on your library, but if (rea... | <p>Objective C++ is well defined and supported by Apple's gcc.</p>
<p>But you can't mix C++ and objective C classes, which makes this rather messy pretty fast. I don't think there are many projects in the wild which mix C++ and Objective C to any serious extent.</p>
<p>This highly depends on your library, but if (rea... | 39,767 |
<p>So, In a Flex app I add a new GUI component by creating it and calling <code>parent.addChild()</code>. However in some cases, this causes an error in the bowels of Flex. Turns out, addChild actually does:</p>
<pre><code>return addChildAt(child, numChildren);
</code></pre>
<p>In the cases where it breaks, somehow t... | <p>I have noticed that it most often occurs when re-parenting a UIComponent that is already on the display list. Are you re-parenting in this situation?</p>
| <p>OK, like a dope, I was trying to add a child to a container even though it was already there, hence the confusing "wrong insertion index" message.</p>
| 17,845 |
<p>There are tons of free wysiwyg editors you can embed in web pages. I'm looking for something that is easiest to embed into an adobe air app. Means something that works in webkit and is easy to get the content from with javascript.</p>
| <p>I suppose I can answer my own question. Fckeditor is the best proven solution. Tinymce violates air's security sandbox and you have to drive it in an iframe inside air.</p>
| <p><a href="http://tinymce.moxiecode.com/examples/simple.php" rel="nofollow noreferrer">TinyMCE</a> is nice. It's quite popular, even used with the <a href="http://www.symfony-project.org/" rel="nofollow noreferrer">Symfony PHP framework</a>. Not sure how it will work out with AIR, but chances are really good. Works wi... | 21,219 |
<p>What is the difference between different optimization levels in GCC? Assuming I don't care to have any debug hooks, why wouldn't I just use the highest level of optimization available to me? does a higher level of optimization necessarily (i.e. provably) generate a faster program?</p>
| <p>Yes, a higher level can sometimes mean a better performing program. However, it can cause problems depending on your code. For example, branch prediction (enabled in -O1 and up) can break poorly written multi threading programs by causing a race condition. Optimization will actually decide something that's better... | <p>Sidenote:</p>
<p>It's quite hard to predict exactly what flags are turned on by the global <code>-O</code> directives on the gcc command line for different versions and platforms, and all documentation on the GCC site is likely to become outdated quickly or doesn't cover the compiler internals in enough detail.</p>... | 11,562 |
<p>I'm building a symbol table for a project I'm working on. I was wondering what peoples opinions are on the advantages and disadvantages of the various methods available for storing and creating a symbol table.</p>
<p>I've done a fair bit of searching and the most commonly recommended are binary trees or linked list... | <p>Your use case is presumably going to be "insert the data once (e.g., application startup) and then perform lots of reads but few if any extra insertions".</p>
<p>Therefore you need to use an algorithm that is fast for looking up the information that you need.</p>
<p>I'd therefore think the HashTable was the most s... | <p>This depends on several things, of course. I'd say that a linked list is right out, since it has few suitable properties to work as a symbol table. A binary tree might work, if you already have one and don't have to spend time writing and debugging it. My choice would be a hash table, I think that is more or less th... | 48,501 |
<p><strong>Problem:</strong> I am looking for a way to run a test that is able to disambiguate between select controls that have the same value in more than one place.</p>
<p><strong>Example:</strong> </p>
<p>I am trying to choose the third "monday" from a select control</p>
<pre><code>ie.select_list( :id , 'choose-... | <p>It looks like you could use element_by_xpath to find the option you want, with something like this:</p>
<pre>
//select/option[text()='charlie']/following::option[text()='-monday']
</pre>
<p>then you could check the value attribute of that option (not sure how to do this in Watir), and select it using:</p>
<pre><c... | <p>In WatiN you can make use of multiple attribute support to match an element (I thought something similar is also available in Watir).</p>
<p>Option option = ie.SelectList("choose-day").Options(Find.ByText("-monday") && Find.ByIndex(2))</p>
<p>(index is zero based so 2 will give the third match (if any)).</... | 49,312 |
<p>I think the field type should be string of variable length (VARCHAR), but what length should I use? </p>
<p>To clarify: I want to pick a size that would be able to store <em>average</em> URL, and don't really care about maximum possible.</p>
| <p>For I.E. the limit is <a href="http://support.microsoft.com/kb/208427" rel="nofollow noreferrer">2,083 Characters</a> </p>
<p>It appears that most other browsers don't have such limit, but if the URLs are supposed to be compatiable with all browsers I would suggest 2083 characters.</p>
| <p>It depends of the URLs itself.</p>
<p>If you work with really long URLs like <a href="http://dsddsadashf.fsdfs.fd/fsdfsdfs/dfsdfsdfdsf/ssssdfsdfsd/sdfsdfsdfsd?fsdfsdfsdf=fdfsfsdfs&fsdfsdfsdfsdfs;jsessionid=sdasdsadasdasdfsdvhbdkvhjkdvhsk" rel="nofollow noreferrer">http://dsddsadashf.fsdfs.fd/fsdfsdfs/dfsdfsdfdsf/ss... | 33,276 |
<p>I'm primarily interested in pgsql for this, but I was wondering if there is a way in any RDBMS to do an insert operation, <em>without</em> disabling and re-enabling any FOREIGN KEY or NOT NULL constraints, on two tables that refer to each other. (You might think of this as a chicken that was somehow born from its o... | <p>I think that you answered your own question - you have to make a transaction block. In PostgreSQL this should work:</p>
<pre><code>BEGIN;
SET CONSTRAINTS ALL DEFERRED;
INSERT INTO questions (questionid, answerid, question)
VALUES (1, 100, 'How long are Abraham Lincoln\'s legs?');
INSERT INTO answers (answerid, ... | <p>I'd do it in the following way:</p>
<ol>
<li>Define Questions.correct_answer as a
nullable column.</li>
<li>Insert row into Questions, with correct_answer set to NULL.</li>
<li>Insert row(s) into Answers, referencing the row in Questions.</li>
<li>UPDATE Questions SET correct_answer
= ?</li>
</ol>
| 21,660 |
<p>When I launch an ant script from Eclipse 3.4.x it prints the output to console until certain stage. After that it often hangs (wait forever). Last lines that I see at the screen (console) - partial output from my obfuscator.</p>
<p>Under Eclipse 3.3.2 everything works fine (the same project, workspace, settings, JV... | <p>i was using Eclipse 3.4.2 and ant task was hanging, ant output was getting onto the console only to a certain level and after that nothing was working.</p>
<p>I looked on the last line on the console and found some issue related to UTF-8.</p>
<p>This is the message (warning: unmappable character for encoding UTF8)... | <p>One possible cause is that you are <a href="http://dev.eclipse.org/newslists/news.eclipse.tools.jdt/msg03414.html" rel="nofollow noreferrer">running out of memory</a></p>
<p>Also try to run ant with the <code>-diagnostics</code> option.</p>
<p>You can check your <a href="https://stackoverflow.com/questions/94331/e... | 37,735 |
<p>If I use restful_authentication in my ruby on rails app are passwords transfered between the broswer and the server in paintext? And if so how worried should I be about it?</p>
| <p>Well, you need to be worried if you are not hosting it over HTTPS... because if it is straight HTTP, then yes it is being passed in plaintext.</p>
<p>I don't know Rails specifically, but I'm pretty sure it has nothing to do with whether you host it via HTTP or HTTPS.</p>
<p>Edit: I found <a href="http://blog.caboo... | <p>Authentication with plain text can be done with CHAP style protocols. Is that possible over HTTP?</p>
<p>I'm asking, because I think that it would need some state on the server to foil replay-attacks - state on the server is something to be eliminated with RESTful architectures, right?</p>
| 7,700 |
<p>What is the best approach to define additional data for typedef enums in C?</p>
<p>Example:</p>
<pre><code>typedef enum {
kVizsla = 0,
kTerrier = 3,
kYellowLab = 10
} DogType;
</code></pre>
<p>Now I would like to define names for each, for example <code>kVizsla</code> should be "vizsla".
I currently use a f... | <p>@dmckee: I think the suggested solution is good, but for simple data (e.g. if only the name is needed) it could be augmented with auto-generated code. While there are lots of ways to auto-generate code, for something as simple as this I believe you could write a simple XSLT that takes in an XML representation of the... | <p>That's kind of an open ended question, but one suggestion would be to use a map with the enum as the key type and the extra information in the value. (If your indices are continuous, unlike the example, you can use a sequence container instead of a map).</p>
| 5,657 |
<p>Is there a way to change the available elements based on a previous element value?</p>
<p>I have some lookup 'Cause' codes but some of these only belong to certain 'Products'.</p>
<p>I therefore want to create each products lookup cause code enumeration and let this only be available based on the product selection... | <p>I don't think those sort of "business rules" can be expressed in XSD. </p>
<p>One option is to also create <a href="http://www.schematron.com/" rel="nofollow noreferrer">schematron</a> validation rules to enforce those sort of conditional structure rules based upon element/attribute values.</p>
| <p>You can effect element polymorphism (of the same name) in the XSD for instance elements decorated w/ enumerated xsi:type attributes as described
<a href="https://stackoverflow.com/questions/188389/xml-schema-for-elements-with-same-name-but-different-sub-structure-depending-on#233093">here</a></p>
| 29,653 |
<p>I'm writing a DSL in Ruby to control an Arduino project I'm working on; Bardino. It's a bar monkey that will be software controlled to serve drinks. The Arduino takes commands via the serial port to tell the Arduino what pumps to turn on and for how long.</p>
<p>It currently reads a recipe (see below) and prints ... | <p>Without looking into implementation details (or your github links), I'd try write a DSL like this:</p>
<p>(stealing from here: <a href="http://supercocktails.com/1310/Long-Island-Iced-Tea-" rel="nofollow noreferrer">http://supercocktails.com/1310/Long-Island-Iced-Tea-</a>)</p>
<pre><code>describe "Long Island Iced... | <p>Orion's DSL looks very nice.
The only change I'd possibly suggest from you "updated" code is</p>
<ol>
<li>Replace <code>description</code> with <code>recipe</code>. It is a more descriptive term</li>
<li><p>Since the set of ingredients and actions is fixed, bind the ingredients to variables rather than symbols i... | 19,835 |
<p>I am on the way to build an ASP.NET MVC application with the latest beta release and I wonder if it is possible to change the default project Layout of</p>
<p>/Views/Home/Index.aspx
/Views/Home/About.aspx</p>
<p>to</p>
<p>/Blog/Views/Home/Index.aspx
/Blog/Views/Home/About.aspx</p>
<p>/Forum/Views/Home/Index.aspx... | <p>Yes, it should be possible to do this. I can think of one way; there may be others.</p>
<p>The first step is to modify the default route to include your application name:</p>
<pre><code>routes.MapRoute("Default",
"{applicationName}/{controller}/{action}/{id})",
null, null);
</code>... | <p>Yes, it should be possible to do this. I can think of one way; there may be others.</p>
<p>The first step is to modify the default route to include your application name:</p>
<pre><code>routes.MapRoute("Default",
"{applicationName}/{controller}/{action}/{id})",
null, null);
</code>... | 28,622 |
<p>I have an app that writes messages to the event log. The source I'm passing in to EventLog.WriteEntry does not exist, so the Framework tries to create the source by adding it to the registry. It works fine if the user is an Admin by I get the following whe the user is not an admin:</p>
<p>"System.Security.SecurityE... | <p>For your update I have found something that might help you : </p>
<pre><code>Run regedt32
Navigate to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security
Right click on this entry and select Permissions
Add the ASPNET user
Give it Read permission
2. Change settings in machine.... | <p>The "non-programming way" is to grant the user that user your web application/web service with access to registry (Event Log are written in the event log). </p>
| 37,376 |
<p>I've heard that the automotive industry has something called MISRA C.</p>
<p>What are the relevant standards for other high reliability/availability/security industries, such as</p>
<ul>
<li>Space</li>
<li>Aircraft</li>
<li>Banking/financial</li>
<li>Automotive</li>
<li>Medical</li>
<li>Defense/Military</li>
<li>?... | <p>Check out the Goddard Space Flight Center and its <a href="http://software.gsfc.nasa.gov/assetsbytype.cfm?TypeAsset=Standard" rel="nofollow noreferrer">coding standards</a>. One of the C standards, which I've adopted in my own code, is that headers must be self-contained, and they provide a simple way to enforce th... | <p>NIST provides a whole slew of related documents, you can dive in and peruse their work - but there is a lot of it, and it's all quite verbose, so I dont have a specific one to point you at.<br>
If you want to be more specific with your needs, I might be able to narrow it down a bit...</p>
<p>In addition, Carnegie M... | 17,244 |
<p>I am building a small website for fun/learning using a fairly standard Web/Service/Data Access layered design.</p>
<p>For the Data Access Layer, what is the best way to handle creating Connection objects to call my SQL stored procedures and why? Bearing in mind I am writing a lot of the code by hand (I know I could... | <p>You use it any time you want to write data to memory after doing some work and make sure another thread hasn't overwritten the destination since you started. A lot of <a href="https://stackoverflow.com/questions/93073/how-to-implement-thread-safe-reference-counting-in-c">lock/mutex-free algorithms</a> take this form... | <p>It's used when you need to get a shared value, do something with it, and change the value, assuming another thread hasn't already changed it.</p>
<p>As for practical uses, the last time I saw it was in implementations of concurrent queues (queues that may be pushed/popped by multiple threads without needing semapho... | 14,711 |
<p>I've got some directories that have been moved or renamed. The Linux command line SVN client ignores these directories. The TortoiseSVN plugin for Explorer shows them. If I delete them and update, they come back.</p>
<p>All of the file movement and deletion has been done using the Linux SVN CLI tools. When doing an... | <p>I have a feeling there is a deeper problem I'm not getting but here goes. In your postback event:</p>
<pre><code>// the post handling logic, e.g. the click event code
Response.Redirect(Request.RawUrl);
</code></pre>
| <p>Use Server.Transfer method.</p>
<p>The Server.Transfer method has a second parameter—"preserveForm". If you set this to True, using a statement such as Server.Transfer("WebForm2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.</p>
<p><a hre... | 42,914 |
<p><strong>In C#, is there a way to instantiate an instance of a class without invoking its constructor?</strong></p>
<p>Assume the class is public and is defined in a 3rd party library and the constructor is internal. The reasons I want to do this are complicated but it would be helpful to know if it's possible usin... | <p>I have not tried this, but there is a method called <a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatterservices.getuninitializedobject.aspx" rel="noreferrer">FormatterServices.GetUninitializedObject</a> that is used during deserialization.</p>
<p>Remarks from MSDN says:</p>
<blo... | <p>What you are asking to do is a violation of the philosophy upon which managed programming was developed. The .Net Framework and C# are built with the principle that, whenever possible, objects should be abstracted away from their underlying memory. Objects are objects, not a structured array of bytes. This is why yo... | 37,923 |
<p>I would like to append a path to the PATH environment variable in a Visual Studio 2005 deployment project. How does one do this?</p>
| <p>Use the registry editor view in the setup project and create the path key in the appropriate place
ie.
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment
and create a string value called "Path"
and enter this as your value:
"[%Path];[TARGETDIR]"</p>
<p>[%Path] is a placeholder for the ... | <p>You need to add a row to the Environment Table of the MSI file to do this. You can find information on that table here, <a href="http://msdn.microsoft.com/en-us/library/aa368369(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa368369(VS.85).aspx</a>. You can use Orca to do this or a... | 27,591 |
<p>I need to display some interactive (attaching with DOM listeners etc. and event handling) vector graphics in web site I am working on. There is a W3C recommendation for SVG though this format is still not recognized by Internet Explorer support of which is a must (for a public website). IE handles VML though and the... | <p>Safari, Opera and Firefox all support SVG natively (eg. without plugins) to varying degrees of completeness and correctness, including the ability to script the svg from javascript.</p>
<p>There's also the canvas element which is now being standardised in html5, and is already supported in the above browsers as wel... | <p>Go for SVG - and just tell the users to get the ADOBE SVG plug in for IE.</p>
<p>See this excellent site - which is a UK Government Site (public service)</p>
<p><a href="http://www.elgin.gov.uk" rel="nofollow noreferrer">ELGIN</a></p>
| 3,100 |
<p>I am cloning a hidden table row then populating it and after validation I want to show the row using a jquery effect ... say .show("slow")</p>
<pre><code>var baseRow = $("#tasks tr#baseTaskLine");
var newRow = baseRow.clone();
var lastRow = $("#tasks tr[id^='TaskLine_']" + dayClass + ":last");
var newRowId;
if (la... | <p>This is not going to work this way. Table rows and cells are not meant to be displayed as blocks so the show/fade effects are not going to work on table rows directly.</p>
<p>You could, however, put a <div> in each of the cells, something like this:</p>
<pre><code><table>
<tr id="row1"><td>... | <p>I wrote a jQuery plugin that lets you do this. You can add and remove rows (with animation) and it doesn't require wrapping your data with a div or anything like that. Check it out at <a href="http://www.fletchzone.com/post/jQuery-Unobtrusively-Animated-Add-and-Remove-Table-Rows.aspx" rel="nofollow noreferrer">http:... | 24,971 |
<p>XAMPP makes configuring a local LAMP stack for windows a breeze. So it's quite disappointing that enabling <code>.htaccess</code> files is such a nightmare.</p>
<p>My problem:
I've got a PHP application that requires apache/php to search for an <code>/includes/</code> directory contained within the application. To d... | <ol>
<li>Why do you need to rename .htaccess to htaccess.txt </li>
<li>Try setting the include_path using <a href="http://php.net/set_include_path()" rel="noreferrer">set_include_path()</a> and see if that helps (as an intermediate fix)</li>
<li>Verify which php.ini to use through a <a href="http://php.net/phpinfo" rel... | <p>My htaccess works under XAMPP fine - though some modules are disabled by default - are you sure that the modules you want are enabled? </p>
| 18,437 |
<p>You can do it in .NET by using the keyword "ref". Is there any way to do so in Java?</p>
| <p>What are you doing in your method? If you're merely populating an existing array, then you don't need pass-by-reference semantics - either in .NET or in Java. In both cases, the reference will be passed by value - so changes to the <em>object</em> will be visible by the caller. That's like telling someone the addres... | <p><strong>Java uses pass by value for method arguments</strong>. </p>
<ul>
<li><a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html" rel="nofollow noreferrer">Primitives</a> (int, boolean, etc.) are special cases in Java.. not objects per se. In this case, a copy of the primitive (argumen... | 43,176 |
<p>I'm writing an application that processes PowerPoint presentations and I'm looking into ways of detecting whether or not a PowerPoint presentation has a password if it does then stop processing it.</p>
| <p>It seems to me that there is <strong>no way to check</strong> if the presentation is password-protected. You have to open the document first to make properties accessible. You have to provide the password when you are opening the document.</p>
<p>There is a <a href="http://msdn.microsoft.com/en-us/library/aa613404(... | <p>Consider looking at this -
<a href="http://blogs.msdn.com/b/openspecification/archive/2009/07/17/overview-of-protected-office-open-xml-documents.aspx" rel="nofollow">http://blogs.msdn.com/b/openspecification/archive/2009/07/17/overview-of-protected-office-open-xml-documents.aspx</a></p>
<p>For a PPTX document, you... | 26,543 |
<p>I have read numerous articles now and it's not clear and there's lots of versions and this that and the other and I have been piecing things together and have got so far, my problem is the 'rar' command doesn't seem to accept my substition variable and instead reads it as a string.</p>
<p>But this is what I have</p... | <p>I think this is your problem:</p>
<pre><code>set _rarpath=C:\Program Files (x86)\WinRAR
</code></pre>
<p>In batch files, the environment variable delimiter is a space, so it thinks <code>_rarpath</code> is <code>C:\Program</code></p>
<p>Enclose the path in double quotes and see if that helps:</p>
<pre><code>set ... | <p>I don't see where you're asking winrar to do anything with your files? %%f needs to be on the winrar command line somewhere.</p>
<p>Also, you shouldn't need a loop at all for this: rar.exe a test.rar %yourpath%*.csv or similar. </p>
| 42,923 |
<p>I want to replace the first occurrence in a given string. </p>
<p>How can I accomplish this in .NET?</p>
| <pre><code>string ReplaceFirst(string text, string search, string replace)
{
int pos = text.IndexOf(search);
if (pos < 0)
{
return text;
}
return text.Substring(0, pos) + replace + text.Substring(pos + search.Length);
}
</code></pre>
<p>Example:</p>
<pre><code>string str = "The brown brown fox jumps ... | <pre><code>string abc = "AAAAX1";
if(abc.IndexOf("AA") == 0)
{
abc.Remove(0, 2);
abc = "XQ" + abc;
}
</code></pre>
| 17,036 |
<p>I'm not talking about bug tracking software (like Bugzilla or Jira). I'm looking for something that:</p>
<ol>
<li>Stores test specifications in text format</li>
<li>Combines test specs into test coverage scenarios</li>
<li>Keeps track of the progress through testing scenarios </li>
<li>Links test specs with bug rep... | <p>TestLink is a pretty nice open source test tracking tool with the features you need, and is still under active development. Take a look at <a href="http://testlink.org/" rel="nofollow noreferrer">http://testlink.org/</a></p>
| <p>I have personally used Trac (<a href="http://trac.edgewall.org/" rel="nofollow noreferrer">http://trac.edgewall.org/</a>) which combines a simple issue tracker with Wiki functionality. Solved the need I had on my project.</p>
| 8,804 |
<p>Scenario:</p>
<p>An <strong>event</strong> is raised in class A that needs to be handled by a <strong>method</strong> in class B. (currently via a delegate)<br/><br/>
The data that gets passed from the <strong>event</strong> to the <strong>method</strong> is currently wrapped in class C.<br/>
This obviously require... | <p>unrolling to primitives would work, but be certain that you really do want to remove this dependency. It is perfectly valid for classes A and B to both depend on C if C is a bridge between them, or if C feeds both of them, etc.</p>
<p>unrolling to primitives removes a compilation dependency, but not a data dependen... | <p>You could serialize to XML, and than read the XML directly via XPATH (without deserializing)</p>
| 32,314 |
<p>I'm looking for a generic method to implement a wait screen during long operations. I have used threading a few times before, but I have the feeling that I implemented it either very poorly, or with way too much hassle (and copy/pasting - the horror!).</p>
<p>I want to keep this as generic and simple as possible, s... | <p>Your problem is that your getting a cross thread exception when your trying to pass your Worker thread data to your ui thread. what you need to do is check InvokeRequired and begininvoke before setting the controls on your ui so you don't get the error like so:</p>
<pre><code>Private Sub work_CrossThreadEvent(ByVal... | <p>In your thread, use Application.Run(yourform) to get what you want.</p>
<p>Note that you need to signal the form to close itself somehow.</p>
| 40,933 |
<p>This is not to be confused with <a href="https://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible">"How to tell if a DOM element is visible?"</a></p>
<p>I want to determine if a given DOM element is visible on the page.
E.g. if the element is a child of a parent which has <code>display:non... | <p>From a quick test in Firefox, it looks like the size and position properties (clientWidth, offsetTop etc.) all return 0 when an element is hidden by a parent being <code>display:none</code>.</p>
| <p>As I'm using <a href="http://mochikit.com/" rel="nofollow noreferrer">MochiKit</a>, what I came up with based on Ant P's answer was:</p>
<pre><code>getElementPosition('mydiv').y != 0
</code></pre>
<p>I can also check whether it's in the viewport (vertically) by:</p>
<pre><code>y = getElementPosition('mydiv').y
(y... | 43,570 |
<p>Thinking about <a href="https://stackoverflow.com/questions/267351/how-can-i-convert-from-integers-to-roman-numerals-using-a-syntax-directed-trans">my other problem</a>, i decided I can't even create a regular expression that will match roman numerals (let alone a context-free grammar that will generate them)</p>
<... | <p>You can use the following regex for this:</p>
<pre><code>^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$
</code></pre>
<p>Breaking it down, <code>M{0,4}</code> specifies the thousands section and basically restrains it to between <code>0</code> and <code>4000</code>. It's a relatively simple:</p>
<pre><c... | <p>The problem of the solution from Jeremy and Pax is, that it does also match "nothing".</p>
<p>The following regex expects at least one roman numeral:</p>
<pre><code>^(M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})|[IDCXMLV])$
</code></pre>
| 33,538 |
<p>I'm trying to write a script to allow me to log in to a console servers 48 ports so that I can quickly determine what devices are connected to each serial line.</p>
<p>Essentially I want to be able to have a script that, given a list of hosts/ports, telnets to the first device in the list and leaves me in interacti... | <p>You need to redirect the Terminal input to the <code>telnet</code> process. This should be <code>/dev/tty</code>. So your script will look something like:</p>
<pre><code>#!/bin/bash
for HOST in `cat`
do
echo Connecting to $HOST...
telnet $HOST </dev/tty
done
</code></pre>
| <p>Perhaps you could try bash -i to force the session to be in interactive mode.</p>
| 12,613 |
<p>I am creating a "department picker" form that is going to serve as a modal popup form with many of my "primary" forms of a Winforms application. Ideally the user is going to click on an icon next to a text box that will pop up the form, they will select the department they need, and when they click OK, the dialog wi... | <p>In such cases, I usually either</p>
<ul>
<li>Write a ShowDialog function that does what I want (e.g. return the value) or</li>
<li>Just let the result be a property in the dialog. This is how the common file dialogs do it in the BCL. The caller must then read the property to get the result. That's fine in my opinio... | <p>The problem is that assigning TargetResult in the constructor is using the string as a reference. The m_TargetResult string is just a copy of the ref string, not a reference to the original string.</p>
<p>As for how to make a "pointer" to the original, I don't know.</p>
<p>This is made even harder by the fact tha... | 18,071 |
<p>How do you safely encode a URL using JavaScript such that it can be put into a GET string?</p>
<pre><code>var myUrl = "http://example.com/index.html?param=1&anotherParam=2";
var myOtherUrl = "http://example.com/index.html?url=" + myUrl;
</code></pre>
<p>I assume that you need to encode the <code>myUrl</code> v... | <p>Check out the built-in function <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent" rel="noreferrer">encodeURIComponent(str)</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI" rel="noreferrer">encodeUR... | <p>I always use this to encode stuff for URLs. This is completely safe because it will encode every single character even if it doesn't have to be encoded.</p>
<pre class="lang-js prettyprint-override"><code>function urlEncode(text) {
let encoded = '';
for (let char of text) {
encoded += '%' + char.char... | 43,144 |
<p>Is there an easy way to avoid dealing with text encoding problems?</p>
| <p>You can't really avoid dealing with the text encoding issues, but there are existing solutions in Apache Commons:</p>
<ul>
<li><code>Reader</code> to <code>InputStream</code>: <a href="https://commons.apache.org/proper/commons-io/javadocs/api-release/org/apache/commons/io/input/ReaderInputStream.html" rel="noreferr... | <p>For Reading a string in a stream using just what java supplies.</p>
<pre><code>InputStream s = new BufferedInputStream( new ReaderInputStream( new StringReader("a string")));
</code></pre>
| 8,761 |
<p>I'm in the process of setting up a new website which would greatly benefit from having user-forums.</p>
<p>Since I already have user accounts, and profile details, stored away it seems that I'd benefit from choosing an open-source forum package which I could modify so that logins were tested against my existing dat... | <p>Really simple forums are often really insecure forums. If you're determined to use perl, a major web forum doesn't come to mind, and if your competent in security I'd say roll your own. You could even release it to the open source community to help people like you. I know there are several great PHP ones out there t... | <p>I seem to remember that Drupal had a reasonable fit as a module.</p>
| 35,743 |
<p>I have a dotnet windows service that's currently hung, but running. Is there anyway to attach a debugger to it, despite the lack of symbols; and that it's already running?</p>
| <p>Ignore the "no symbols" warning. Once you have a native debugger attached (i prefer WinDbg for stuff like this), then load up the SoS tool pack:</p>
<pre><code>.loadby sos mscorwks
</code></pre>
<p>Now you can get a managed callstack using the <code>!clrstack</code> command, and hope that gives you enough ... | <p>From MS dev IDE
Debug -> Processes -> Attach (After you choose a process.) You might have to click the "show system processes" box. There may be no useful information though...</p>
| 49,226 |
<p>I always try to avoid to return string literals, because I fear they aren't defined outside of the function. But I'm not sure if this is the case. Let's take, for example, this function:</p>
<pre><code>
const char *
return_a_string(void)
{
return "blah";
}
</code></pre>
<p>Is this correct code? It does work fo... | <p>This code is fine across all platforms. The string gets compiled into the binary as a static string literal. If you are on windows for example you can even open your .exe with notepad and search for the string itself. </p>
<p>Since it is a static string literal scope does not matter.</p>
<p><strong>String pooli... | <p>You actually return a pointer to the zero-terminated string stored in the data section of the executable, an area loaded when you load the program. Just avoid to try and change the characters, it might give unpredictable results...</p>
| 33,496 |
<p>This question is coded in pseudo-PHP, but I really don't mind what language I get answers in (except for Ruby :-P), as this is purely hypothetical. In fact, PHP is quite possibly the worst language to be doing this type of logic in. Unfortunately, I have never done this before, so I can't provide a real-world exampl... | <p>The problem with PHP's "associative arrays" is that they aren't arrays at all, they're <a href="http://en.wikipedia.org/wiki/Hash_table" rel="nofollow noreferrer">Hashmaps</a>. Having holes there is perfectly fine. You might look at a <a href="http://en.wikipedia.org/wiki/Linked_List" rel="nofollow noreferrer">linke... | <p>"$i++ loops" are nooby, but only because the code becomes much clearer if you use a for loop:</p>
<pre><code>$i = 0;
while ($i < count($downloads) - 1) {
if (!is_object($downloads[$i])) {
$downloads[$i] = new DownloaderObject('http://somesite.com/doctorwho.iso');
break;
}
$i++;
}
</cod... | 45,385 |
<p>I am building a search box (input field) which should make a server call to filter a grid with the text being inserted on it but I need to make this in an smart way, I need to fire the server call only if the user has stopped.
Right now I'm trying to implement it, but if someone knows how to do it I'll be very plea... | <ol>
<li>When a key is pressed:
<ol>
<li>Check if there's an existing timer - stop it if there is one</li>
<li>start a timer. </li>
</ol></li>
<li>When the timer expires, call the server method.</li>
</ol>
<pre><code>var searchTimeout;
document.getElementById('searchBox').onkeypress = function () {
if (searchTime... | <p>I don't know much about JavaScript, but you could use a timer (lets say set to 5 seconds) that gets reset on every change event from your input box. If the user stops typing for more than 5 seconds, the timer expires and triggers the submit.</p>
<p>The problem with that approach is that the submit is triggered on e... | 46,958 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.