input
stringlengths 51
42.3k
| output
stringlengths 18
55k
|
|---|---|
How to remove a field from SQLServer2005 table <p>I tried this:</p>
<pre><code>ALTER TABLE My.Table DROP MyField
</code></pre>
<p>and got this error:</p>
<p>-MyField is not a constraint.</p>
<p>-Could not drop constraint. See previous errors.</p>
<p>There is just one row of data in the table and the field was just added.</p>
<p><strong>EDIT:</strong>
Just to follow up, the sql was missing COLUMN indeed.
Now I get even more seriously looking errors though:</p>
<ul>
<li>The object 'some_object__somenumbers' is dependent on column 'MyField'</li>
<li>ALTER TABLE DROP COLUMN MyField failed because one or more objects access this column.</li>
</ul>
<p><strong>EDIT:</strong></p>
<pre><code>ALTER TABLE TableName DROP Constraint ConstraintName
</code></pre>
<p>worked, after that I was able to use the previous code to remove the column. Credit goes to both of you, thanks.</p>
|
<p>I think you are just missing the COLUMN keyword:</p>
<pre><code>ALTER TABLE TableName DROP COLUMN ColumnName
</code></pre>
<p>You will also need to make sure that any constraint that is depending on ColumnName is dropped first. </p>
<p>You can do this by:</p>
<pre><code>ALTER TABLE TableName DROP ConstraintName
</code></pre>
<p>For each constraint that you have. </p>
<p>If you have indexes based on the column, you will also need to drop those indexes first.</p>
<pre><code>DROP INDEX TableName.IndexName
</code></pre>
|
Find the ip address of a remote object in .net remoting <p>I have a client-server application that uses .net remoting. The clients are in a LAN and i do not know their location in advance.</p>
<p>Sometimes we do file transfers and as an optimization I want to determine if a client is in fact on the same machine as the server (it is quite possible). In this case, I only need to do a File.Copy. </p>
<p>Let's say that a client calls the remote method: </p>
<p>RemoteFile server.GetFile(string path);</p>
<p>how can I determine if the client (the requester) is on the same machine?</p>
|
<p>If you know the IP Address for the server you're calling the remote method from you can use this method to tell whether or not you're on the same machine:</p>
<pre><code>using System.Net;
private bool CheckIfServer(IPAddress serverIP)
{
// Get all addresses assigned to this machine
List<IPAddress> ipAddresses = new List<IPAddress>();
ipAddresses.AddRange(Dns.GetHostAddresses(Dns.GetHostName()));
// If desirable, also include the loopback adapter
ipAddresses.Add(IPAddress.Loopback);
// Detect if this machine contains the IP for the remote server
// Note: This uses a Lambda Expression, which is only available .Net 3 or later
return ipAddresses.Exists(i => i.ToString() == serverIP.ToString());
}
</code></pre>
<p>If you don't know the IPAddress for your remote server you can easily get it using the server's host name like this:</p>
<pre><code>Dns.GetHostAddresses("remote_host_address")
</code></pre>
<p>This returns an IPAddress[], which includes all the resolved address for that host.</p>
|
Invoking JavaScript code in an iframe from the parent page <p>Basically, I have an iframe embedded in a page and the iframe has some <a href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a> routines I need to invoke from the parent page.</p>
<p>Now the opposite is quite simple as you only need to call <code>parent.functionName()</code>, but unfortunately I need exactly the opposite of that.</p>
<p>Please note that my problem is not changing the source <a href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL</a> of the iframe, but invoking a function defined in the iframe.</p>
|
<p>Assume your iFrame's id is "targetFrame" and the function you want to call is <code>targetFunction()</code>:</p>
<pre><code>document.getElementById('targetFrame').contentWindow.targetFunction();
</code></pre>
<p>You can also access the frame using <code>window.frames</code> instead of <code>document.getElementById</code>.</p>
<pre><code>// this option does not work in most of latest versions of chrome and Firefox
window.frames[0].frameElement.contentWindow.targetFunction();
</code></pre>
|
Can I run Visual Studio 2008 x86 on Windows Vista x64? <p>Is it possible to run the 32-bit version of Visual Studio 2008 Professional on a Windows Vista 64-bit system? </p>
<ul>
<li>Are there any known caveats that I would need to be aware of?</li>
<li>Would have to install the x64 version of the .NET Framework?</li>
<li>Would there be any issues on building software targeted for x86?</li>
<li>Would there be any (justifiable) arguments for getting the x64 version of VS2008 instead of reusing the current x86 license?</li>
</ul>
<p>Quite tempted on getting a x64 Vista rig to be able to take advantage of more RAM :)</p>
|
<p>There is no x64 version of Visual Studio 2008. I'm running the standard 32-bit version on Vista x64 Ultimate and it works fine. There really are no day-to-day issues that I've run across. You just install it and go.</p>
|
How to shrink a SQL Server Log file with Mirroring enabled? <p>I have several databases for my applications that use SQL Server 2005 mirroring to keep a nice copy of the data somewhere else. Works like a charm, however, the log file just seems to be growing and growing, one is at 15GB for a 3GB database. </p>
<p>Normally, I can just shrink it - however an error pops up that this specifically cannot be done. But, it seems eventually if unchecked would just expand to use all the space on the drive.</p>
<p>I see that I can set a maximum file size for the log file, is that the answer here? Will the log just roll when it hits the max, or will the DB just stop functioning?</p>
<p>Thanks</p>
|
<p>I would look at why your logfile is growing, then you can define a strategy for solving your issue.
It might be worth checking your mirroring state</p>
<p>When a principal database is exposed, it is active with user connections and processing transactions. However, no log records are being sent to the mirror database, and if the principal should fail, the mirror will not have any of the transactions from the principal from the point the principal entered the exposed state. Also, the principal's transaction log cannot be truncated, so the log file will be growing indefinitely.
ref <a href="http://www.microsoft.com/technet/prodtechnol/sql/2005/dbmirror.mspx" rel="nofollow">http://www.microsoft.com/technet/prodtechnol/sql/2005/dbmirror.mspx</a></p>
|
Add columns to an Access (Jet) table from .NET <p>Our app (already deployed) is using an Access/Jet database. The upcoming version of our software requires some additional columns in one of the tables. I need to first check if these columns exist, and then add them if they don't.</p>
<p>Can someone provide a quick code sample, link, or nudge in the right direction?</p>
<p>(I'm using c#, but a VB.NET sample would be fine, too).</p>
|
<p>Off the top of my head, but something like:</p>
<pre><code>Dim conn as New AdoConnection(someConnStr)
Dim cmd as New AdoCommand
cmd.Connection = conn
cmd.CommandText = "ALTER TABLE X ADD COLUMN y COLUMNTYPE"
cmd.ComandType = CommandType.Text
cmd.ExecuteNonQuery()
</code></pre>
|
Why use a web service with Linq to SQL? <p>Can anyone tell me what the need/advantage is to using a web service with an asp.net gui and using Linq to SQL? The web service layer seems unnecessary. Linq to SQL is completely new to me and I am researching as I am setting up a new project. Does anyone have any experience with this?</p>
|
<p>You would expose services for those cases in which other applications may need to access your data (such as a smart client, another application, a winforms app, etc.). A lot of people will develop using web services to prevent themselves from having to restructure to web services in the future.</p>
<p>In almost any professional/enterprise web application you want to separate the UI tier from the data access layer so you would not embed Linq to SQL calls in the UI tier. Instead you would have a service tier in between, whether its web services, WCF, or just a DLL with business logic that orchestrates your data access layer. Independent tiers are easier to maintain, update, refactor, and learn so the up front investment in creating them is worth the effort.</p>
|
Is there a way to separate long running (e.g. stress tests) out so they're not run by default in Maven 2? <p>We've had an ongoing need here that I can't figure out how to address using the stock Maven 2 tools and documentation.</p>
<p>Some of our developers have some very long running JUnit tests (usually stress tests) that under no circumstances should be run as a regular part of the build process / nightly build.</p>
<p>Of course we can use the surefire plugin's exclusion mechanism and just punt them from the build, but ideally we'd love something that would allow the developer to run them at will through Maven 2.</p>
|
<p>Normally you would add a profile to your maven configuration that runs a different set of tests:</p>
<p>run this with mvn -Pintegrationtest install</p>
<pre><code> <profile>
<id>integrationtest</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-client -Xmx896m -XX:MaxPermSize=192m</argLine>
<forkMode>once</forkMode>
<includes>
<include>**/**/*Test.java</include>
<include>**/**/*IntTest.java</include>
</includes>
<excludes>
<exclude>**/**/*SeleniumTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<activation>
<property>
<name>integrationtest</name>
</property>
</activation>
</profile>
</code></pre>
|
Odd issue with textbox and ASP.NET <p>This code was working properly before, basically I have a master page that has a single text box for searching, I named it <strong><code>searchBox</code></strong>. I have a method to pull the content of <strong><code>searchBox</code></strong> on form submit and set it to a variable <strong><code>userQuery</code></strong>. Here is the method:</p>
<pre><code>Public Function searchString(ByVal oTextBoxName As String) As String
If Master IsNot Nothing Then
Dim txtBoxSrc As New TextBox
txtBoxSrc = CType(Master.FindControl(oTextBoxName), TextBox)
If txtBoxSrc IsNot Nothing Then
Return txtBoxSrc.Text
End If
End If
Return Nothing
End Function
</code></pre>
<p>The results are displayed on <strong><code>search.aspx</code></strong>. Now, however, if <strong><code>searchBox</code></strong> is filled and submitted on a page other than <strong><code>search.aspx</code></strong>, the contents of the text box are not passed through. The form is very simple, just:</p>
<p><code><asp:TextBox ID="searchBox" runat="server"></asp:TextBox><br />
<asp:Button ID="searchbutton" runat="server" Text="search" UseSubmitBehavior="True" PostBackUrl="~/search.aspx" CssClass="searchBtn" /></code>.</p>
|
<p>I think because you are using PostBackUrl, you are going to be required to use the "<a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.previouspage.aspx" rel="nofollow">PreviousPage</a>" identifier to reference your variable.</p>
<p>Another solution would to not use the PostBackUrl property and to capture the event within the user control (I'm assuming you are encapsulating this in one location) and then use the:</p>
<pre><code>Response.Redirect("/search.aspx?sQuery=" & Server.URLEncode(searchBox.Text))
</code></pre>
<p>since you are not necessarily passing sensitive data, this should be acceptable as well.</p>
|
How do you check and see if a propel object has an i18n record? <p>I'm using symfony and propel, and I'm trying to invoke a specific culture on an object and output some fields of that object to the screen in that specific culture. However, if the object's mapped database record doesn't have those fields in that specific culture, I would like it to default to the base culture (in this case, en_US)</p>
<p>I'm doing it like this:</p>
<pre><code>$currentLesson = $currentLesson->getCurrentLessonsI18n($lessonCulture);
</code></pre>
<p>But when I output such as this</p>
<pre><code>$currentLesson->getTitle();
</code></pre>
<p>It outputs an empty string if there is no culture record for it. My question is, is there a way to make an object default to a specific culuture if the one I specify isn't available, or is there a method to see if a specific object has a culture i18n record?</p>
<p>something like this:</p>
<pre><code>if($currentLesson->cultureExists($lessonCulture) $currentLesson = $currentLesson->getCurrentLessonsI18n($lessonCulture);
</code></pre>
<p>or</p>
<pre><code>sfConfig::setPropelDefaultCulture("en_US");
</code></pre>
|
<p>You will have to overwrite symfony itself to make it default to another language.
Theres a good working solution here <a href="http://www.codemassacre.com/2008/03/10/symfony-default-language-fallback/" rel="nofollow">http://www.codemassacre.com/2008/03/10/symfony-default-language-fallback/</a></p>
|
Displaying unit test results in VS 2008 <p>I am a rookie was using the Visual Studio 2008 built-in Unit Testing components, what would be the best way to record or display your results in a unit test?</p>
<p>I want to test my service method when it returns a System.GUID and an empty System.GUID</p>
<pre><code>[TestMethod]
public void GetGUID()
{
MyWcfServiceService.MyWcfServiceClient proxy = new MyWcfServiceService.MyWcfServiceClient();
string name = "HasGuid";
System.GUID guid = proxy.GetGUID(name);
}
[TestMethod]
public void GetEmptyGUID()
{
MyWcfServiceService.MyWcfServiceClient proxy = new MyWcfServiceService.MyWcfServiceClient();
string name = "HasEmptyGuid";
System.GUID guid = proxy.GetGUID(name);
}
</code></pre>
|
<p>For GetGUID()...</p>
<pre><code>Assert.IsFalse(guid == Guid.Empty);
</code></pre>
<p>Similarly for GetEmptyGUID()...</p>
<pre><code>Assert.IsTrue(guid == Guid.Empty);
</code></pre>
|
Which SQL Read TRANSACTION ISOLATION LEVEL do I want for long running insert? <p>I have a long running insert transaction that inserts data into several related tables. </p>
<p>When this insert is running, I cannot perform a select * from MainTable. The select just spins its wheels until the insert is done. </p>
<p>I will be performing several of these inserts at the same/overlapping time. To check that the information is not inserted twice, I query the MainTable first to see if an entry is there and that its processed bit is not set. </p>
<p>During the insert transaction, it flips the MainTable processed bit for that row.</p>
<p>So I need to be able to read the table and also be able to tell if the specific row is currently being updated.</p>
<p>Any ideas on how to set this up in Microsoft SQL 2005? I am looking through the <a href="http://msdn.microsoft.com/en-us/library/ms173763.aspx" rel="nofollow">SET TRANSACTION ISOLATION LEVEL</a> documentation.</p>
<p>Thank you,<br />
Keith</p>
<p><b>EDIT:</b> I do not think that the same insert batch will happen at the same time. These are binary files that are being processed and their data inserted into the database. I check that the file has not been processed before I parse and insert the data. When I do the check, if the file has not been seen before I do a quick insert into the MainTable with the processed bit set false. </p>
<p>Is there a way to lock the row being updated instead of the entire table? </p>
|
<p>You may want to rethink your process before you use READ UNCOMMITTED. There are many good reasons for isolated transactions. If you use READ UNCOMMITTED you may still get duplicates because there is a chance both of the inserts will check for updates at the same time and both not finding them creating duplicates. Try breaking it up into smaller batches or issue periodic COMMITS</p>
<p>EDIT</p>
<p>You can wrap the MainTable update in a transaction that will free up that table quicker but you still may get conflicts with the other tables.</p>
<p>ie</p>
<pre><code>BEGIN TRANSACTION
SELECT @ProcessedBit = ProcessedBit FROM MainTable WHERE ID = XXX
IF @ProcessedBit = False
UPDATE MainTable SET ProcessedBit = True WHERE ID = XXX
COMMIT TRANSACTION
IF @ProcessedBit = False
BEGIN
BEGIN TRANSACTION
-- start long running process
...
COMMIT TRANSACTION
END
</code></pre>
<p>EDIT to enable error recovery</p>
<pre><code>BEGIN TRANSACTION
SELECT @ProcessedStatus = ProcessedStatus FROM MainTable WHERE ID = XXX
IF @ProcessedStatus = 'Not Processed'
UPDATE MainTable SET ProcessedBit = 'Processing' WHERE ID = XXX
COMMIT TRANSACTION
IF @ProcessedStatus = 'Not Processed'
BEGIN
BEGIN TRANSACTION
-- start long running process
...
IF No Errors
BEGIN
UPDATE MainTable SET ProcessedStatus = 'Processed' WHERE ID = XXX
COMMIT TRANSACTION
ELSE
ROLLBACK TRANSACTION
END
</code></pre>
|
Cross Resolution Applications in .NET <p>We are developing a small in-house application that will run on monitor having multi resolutions. Now we want that the application should adjust itself and remain consistent over all monitors.</p>
<p>I came from a Java background too where we used different layouts to accomplish the task. I experimented in .NET with different layouts like UniGrid (which provide the consistency but very restrictive), Grid, etc. but failed in the required task. </p>
<p>What are some possible layout model or some other solution?</p>
<p><strong>I think if we can specify percentage width or height as we do in CSS/HTML then we can adopt this cross-resolution policy. I found Infergistics have such controls, but can this can be achieved via default controls?</strong></p>
<p>P.S.: I am actually trying in WPF (preferably WPF native application).</p>
|
<p>The layout controls in <a href="http://msdn.microsoft.com/en-us/library/ms754130.aspx" rel="nofollow">WPF</a> are vastly superior to those found in Windows Forms. It also features true resolution independent display using <a href="http://msdn.microsoft.com/en-us/library/ms748388.aspx" rel="nofollow">Fixed Documents</a>, so the look is consistent even if the monitor DPI changes. This is something that no other Windows drawing API supports properly as far as I'm aware.</p>
|
Code Signing Certificate Options <p>I've been assigned the task of buying a digital certificate for my company to sign our code. We develop applications in the Microsoft space - mostly WPF or Web Based.</p>
<p>I've investigated options and found Comodo to be well priced and responsive, and we're ready to go ahead and purchase a cert through them.. however in the signup form there are various private key options that I'm not too sure about, namely:</p>
<ol>
<li><p>CSP</p>
<ul>
<li>Microsoft Base Cryptographic Provider</li>
<li>Microsoft Base Smart Card Crypto Provider</li>
<li>Microsoft Enhanced Cryptographic Provider v1.0</li>
<li>Microsoft Software Cryptographic Provider</li>
</ul></li>
<li><p>Key Size</p>
<ul>
<li>1024</li>
<li>2048</li>
<li>4096</li>
</ul></li>
<li><p>Exportable?</p>
<ul>
<li>Yes / No</li>
</ul></li>
<li><p>User Protected?</p>
<ul>
<li>Yes / No</li>
</ul></li>
</ol>
<p>Just wondering what all of this means, and what the best options are for our requirements? Any advice/ suggestions would be appreciated</p>
<p>thanks heaps
Greg</p>
|
<p>For "most purposes" the following options are recommended:</p>
<p>Microsoft Base Cryptographic Provider
Key Size: 2048
Exportable: Yes
User Protected: Yes</p>
<p>To be honest, I'm not familiar with the different CSPs, but the Base does the job every time for me.</p>
<p>Key Size makes the keys harder to crack, but more than 2048-bits for a short to medium term key (3-5 years) is ample (IMHO).</p>
<p>Exportable lets you export the private key/certificate pair - essential for backing it up!</p>
<p>User Protected means that you must enter a password everytime that you want to use the cert - highly recommended to prevent accidental or malicious signing of code with your certificate.</p>
<p>Hope this helps.</p>
|
Stored procedures or inline queries? <p>First of all there is a <a href="http://stackoverflow.com/questions/59880/are-stored-procedures-more-efficient-in-general-than-inline-statements-on-moder">partial question</a> regarding this, but it is not exactly what I'm asking, so, bear with me and go for it.</p>
<p>My question is, after looking at what <a href="http://subsonicproject.com/" rel="nofollow">SubSonic</a> does and the excellent videos from Rob Connery I need to ask: <strong>Shall we use a tool like this and do Inline queries or</strong> shall we do the queries <strong>using</strong> a call to the <strong>stored procedure?</strong></p>
<p>I don't want to minimize any work from Rob (which I think it's amazing) but I just want your opinion on this cause I need to start a new project and I'm in the middle of the line; shall I use SubSonic (or other like tool, like NHibernate) or I just continue my method that is always call a stored procedure even if it's a simple as</p>
<pre><code>Select this, that from myTable where myStuff = StackOverflow;
</code></pre>
|
<p>It doesn't need to be one or the other. If it's a simple query, use the SubSonic query tool. If it's more complex, use a stored procedure and load up a collection or create a dataset from the results.</p>
<p>See here: <a href="http://stackoverflow.com/questions/15142/what-are-the-pros-and-cons-to-keeping-sql-in-stored-procs-versus-code">http://stackoverflow.com/questions/15142/what-are-the-pros-and-cons-to-keeping-sql-in-stored-procs-versus-code</a> and here <a href="http://stackoverflow.com/questions/228175/subsonic-and-stored-procedures">http://stackoverflow.com/questions/228175/subsonic-and-stored-procedures</a></p>
|
using Reflector.Invoke Method on functions wih optional parameters <p>I am trying to use reflector.InvokeMethod to invoke a function with an optional parameter.
The function looks like this: </p>
<pre><code>Private Function DoSomeStuff(ByVal blah1 as string, ByVal blah2 as string, Optional ByVal blah3 as string = "45") as boolean
'stuff
end function
</code></pre>
<p>and I'm Invoking it like this:</p>
<pre><code>Dim result As Boolean = Reflector.InvokeMethod(AccessModifier.private,obj_of_Class, "DoSomeStuff", Param1, Param2, Param3)
</code></pre>
<p>This works fine, other than when I don't pass the third (optional) parameter, it dosn't hit the function.</p>
<pre><code>Dim result As Boolean = Reflector.InvokeMethod(AccessModifier.private,obj_of_Class, "DoSomeStuff", Param1, Param2)
</code></pre>
<p>Is there a way I can use Reflector.invokeMethod to call this function without passing the optional parameter? or another way to achieve this?</p>
|
<p>The Visual Basic compiler actually substitutes the optional parameter values into the calling code. So if your actual code was:</p>
<pre><code>DoSomeStuff(blah1, blah2)</code></pre>
<p>Visual Basic would have emitted IL code equivalent to:</p>
<pre><code>DoSomeStuff(blah1, blah2, "45")</code></pre>
<p>To know what that last parameter is, you'll need to get a reference to the parameter's object (I'm not sure what that is in Reflector - in .NET you'd get access to the MethodInfo and then to the ParameterInfo), then get its custom attributes, looking for an attribute marked with OptionalAttribute and DefaultParameterValueAttribute. Then, you'll need to call it with the third parameter, supplying the value from DefaultParameterValueAttribute. </p>
|
When is SqlConnection.RetrieveStatistics() useful? <p>What are the problems that calling this method can help with?<br />
Do you ever use it in debugging you data access?</p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/7h2ahss8(VS.80).aspx" rel="nofollow">This page from MSDN has more information</a>. Seems like it contains useful debugging information but I must admit I've never used it.</p>
|
What is the difference between file and record in OS's view? <p>In terms of general operating system concepts, what is the difference between a file and a record?</p>
<p>How the OS will manage them? I know what a file is and what a record is but how it is distinguished in an
OS?</p>
|
<p>yeap <p>I got the answer
<p>A file is a collection or set of records. </p>
<p><p>Typically, In database sense, A Group of records makes a file. </p>
<p><p>A group of attributes makes a record</p>
|
How can I delete my browser cookies using javascript? <p>How can I delete the session information from my browser by using javascript? Is it possible to do?</p>
|
<p>Session information is usually stored on the server. An HTTP request to a page that destroys the session would normally do the trick (using AJAX if you wish).</p>
<p>For cookies you can set the cookie expiry date to the current date, this will expire the cookie and remove it.</p>
<pre><code>var d = new Date();
document.cookie = "cookiename=1;expires=" + d.toGMTString() + ";" + ";";
</code></pre>
|
Why should we typedef a struct so often in C? <p>I have seen many programs consisting of structures like the one below</p>
<pre><code>typedef struct
{
int i;
char k;
} elem;
elem user;
</code></pre>
<p>Why is it needed so often? Any specific reason or applicable area?</p>
|
<p>As Greg Hewgill said, the typedef means you no longer have to write <code>struct</code> all over the place. That not only saves keystrokes, it also can make the code cleaner since it provides a smidgen more abstraction.</p>
<p>Stuff like</p>
<pre><code>typedef struct {
int x, y;
} Point;
Point point_new(int x, int y)
{
Point a;
a.x = x;
a.y = y;
return a;
}
</code></pre>
<p>becomes cleaner when you don't need to see the "struct" keyword all over the place, it looks more as if there really is a type called "Point" in your language. Which, after the <code>typedef</code>, is the case I guess.</p>
<p>Also note that while your example (and mine) omitted naming the <code>struct</code> itself, actually naming it is also useful for when you want to provide an opaque type. Then you'd have code like this in the header, for instance:</p>
<pre><code>typedef struct Point Point;
Point * point_new(int x, int y);
</code></pre>
<p>and then provide the <code>struct</code> declaration in the implementation file:</p>
<pre><code>struct Point
{
int x, y;
};
Point * point_new(int x, int y)
{
Point *p;
if((p = malloc(sizeof *p)) != NULL)
{
p->x = x;
p->y = y;
}
return p;
}
</code></pre>
<p>In this latter case, you cannot return the Point by value, since its declaration is hidden from users of the header file. This is a technique used widely in <a href="http://www.gtk.org/">GTK+</a>, for instance.</p>
<p><strong>UPDATE</strong> Note that there are also highly-regarded C projects where this use of <code>typedef</code> to hide <code>struct</code> is considered a bad idea, the Linux kernel is probably the most well-known such project. See Chapter 5 of <a href="https://www.kernel.org/doc/Documentation/CodingStyle">The Linux Kernel CodingStyle document</a> for Linus' angry words. :) My point is that the "should" in the question is perhaps not set in stone, after all.</p>
|
Is it best practice to achieve recursion via a partial? <p>I have the need to display a nested set structure in HTML. I am doing it with the following partial:</p>
<pre><code><ul<%= ' id="tree"' if depth == 0 %>>
<% items.each do |item| %>
<li id="node_<%= item.id %>"><a><%= item.name %></a>
<% if item.has_children? %>
<%= render :partial => 'tree_level', :locals => {:items => item.children, :depth => depth + 1} %>
<% end %>
</li>
<% end %>
</ul>
</code></pre>
<p>Is this the best place to have the code? I "feel" like there should be a <code>to_html</code> method on the object which dumps the entire tree structure for me, though this works.</p>
|
<p>I am not sure whether it is best practice but I used similar code for rendering project tree. </p>
<p>Faster alternative is to create helper method doing the same job (recursively traversing tree and adding partial strings into result string). It is a little bit PHP style :( but for such a small amount of HTML is it OK, I guess :) </p>
<p>Helper looks like:</p>
<pre><code>def render_node(node)
res = "<ul>"
...
node.items.each {|n| res << render_node(n)}
...
res << "</ul>"
res
end
</code></pre>
<p>Then it is used like this:</p>
<pre><code><%=render_node ProjectTree.new%>
</code></pre>
|
Syntax colouring using Swing <p>Is it possible to have something like a JTextArea which will color some keywords based on some mappings I have ?</p>
|
<p>Here are a few other choices that you could try</p>
<ol>
<li><a href="http://ostermiller.org/syntax/editor.html">http://ostermiller.org/syntax/editor.html</a></li>
<li><a href="http://java.sun.com/products/jfc/tsc/articles/text/editor_kit/index.html">http://java.sun.com/products/jfc/tsc/articles/text/editor_kit/index.html</a></li>
<li><a href="http://fifesoft.com/rsyntaxtextarea/">http://fifesoft.com/rsyntaxtextarea/</a></li>
<li><a href="http://code.google.com/p/jsyntaxpane/">http://code.google.com/p/jsyntaxpane/</a></li>
</ol>
|
Why is there a difference between the encoding of the Windows Command Prompt vs. a batch file? <p>For example, suppose I have a batch file called <code>'test.cmd'</code> and it simply contains:</p>
<pre><code>echo %1
</code></pre>
<p>I can call this directly from the command prompt with <code>'test.cmd some¬arg'</code> and the result is that the string <code>'some¬arg'</code> is printed.</p>
<p>However if I place that same call in a second batch file, called <code>'tester.cmd'</code> for the sake of argument, and I call this from the command prompt the result is that the string <code>'some%arg'</code> is printed.</p>
<p>What is it that messes up the encoding and how do I get around it? I am sure I've fixed this before, but I can't remember how...</p>
<p>Thanks!</p>
|
<p>This is because your batch file is encoded in a different code page than cmd.exe is currently in.</p>
<p>In western default configurations, cmd.exe starts in <a href="http://en.wikipedia.org/wiki/Codepage_850">CP850</a>, but text editors usually work in <a href="http://en.wikipedia.org/wiki/Codepage_1252">CP1252</a> (what is often wrongly referred to as Latin-1 or ISO-8859-1). </p>
<p>The characters "¬" and "¼" share the same character code in these two code pages, "BC".</p>
<p>The solution is simple. Either encode your batch file in code page 850, or switch cmd.exe to code page 1252 by issuing <code>chcp 1252</code>.</p>
|
Best way to format if statement with multiple conditions <p>If you want to some code to execute based on two or more conditions which is the best way to format that if statement ?</p>
<p>first example:-</p>
<pre><code>if(ConditionOne && ConditionTwo && ConditionThree)
{
Code to execute
}
</code></pre>
<p>Second example:-</p>
<pre><code>if(ConditionOne)
{
if(ConditionTwo )
{
if(ConditionThree)
{
Code to execute
}
}
}
</code></pre>
<p>which is easiest to understand and read bearing in mind that each condition may be a long function name or something.</p>
|
<p>I prefer Option A</p>
<pre><code>bool a, b, c;
if( a && b && c )
{
//This is neat & readable
}
</code></pre>
<p>If you do have particularly long variables/method conditions you can just line break them</p>
<pre><code>if( VeryLongConditionMethod(a) &&
VeryLongConditionMethod(b) &&
VeryLongConditionMethod(c))
{
//This is still readable
}
</code></pre>
<p>If they're even more complicated, then I'd consider doing the condition methods seperately outside the if statment</p>
<pre><code>bool aa = FirstVeryLongConditionMethod(a) && SecondVeryLongConditionMethod(a);
bool bb = FirstVeryLongConditionMethod(b) && SecondVeryLongConditionMethod(b);
bool cc = FirstVeryLongConditionMethod(c) && SecondVeryLongConditionMethod(c);
if( aa && bb && cc)
{
//This is again neat & readable
//although you probably need to sanity check your method names ;)
}
</code></pre>
<p>IMHO The only reason for option 'B' would be if you have seperate <code>else</code> functions to run for each condition.</p>
<p>e.g.</p>
<pre><code>if( a )
{
if( b )
{
}
else
{
//Do Something Else B
}
}
else
{
//Do Something Else A
}
</code></pre>
|
Tips for using Vim as a Java IDE? <p>I'm addicted to Vim, it's now my de facto way of editing text files.</p>
<p>Being that it's mainly a text editor and not an IDE, has anyone got tricks for me to make it easier when developing Java apps?</p>
<p>Some questions I have:</p>
<ul>
<li>How do I invoke a maven task without leaving vi?</li>
<li>Can I get code completion?</li>
<li>How's the syntax highlighting?</li>
</ul>
<p>Anything else (other than "Don't do it!") that I should know about?</p>
|
<p>Some tips:</p>
<ul>
<li>Make sure you use vim (vi improved). Linux and some versions of UNIX symlink vi to vim.</li>
<li>You can get code completion with <a href="http://eclim.sourceforge.net/">eclim</a></li>
<li>Or you can get vi functionality within Eclipse with <a href="http://viplugin.com/">viPlugin</a></li>
<li>Syntax highlighting is great with vim</li>
<li>Vim has good support for writing little macros like running ant/<a href="http://vim.wikia.com/wiki/Use_maven_with_quickfix">maven</a> builds</li>
</ul>
<p>Have fun :-)</p>
|
how to write vb code for custom paging and custom sorting in sql and asp:repeater <p>pl give vb code for custom paging and sorting in asp:repeater using stored procedure</p>
|
<p>Here is step <a href="http://aspnet.4guysfromrolla.com/articles/031506-1.aspx" rel="nofollow">one</a> and <a href="http://aspnet.4guysfromrolla.com/articles/032206-1.aspx" rel="nofollow">two</a> from 4guys that gives a very clear explanation along with zip download available of all code in VB and sample t-sql too. </p>
<p>It deals with ObjectDataSource from which then it should be straigtforward enough to bind your repeater to.</p>
|
webservice.htc, moz-behaviors and Firefox 3 <p>Whilst trying to get our app working in Firefox (I'm a big proponent of X-Browser support but our lead dev is resisting me saying IE is good enough). So I'm doing a little side project to see how much work it is to convert.</p>
<p>I've hit a problem straight away.</p>
<p>The main.aspx page binds to a webservice using the IE only method of adding behaviour through a htc file, which is auto-generated by VS I beleive.</p>
<p> </p>
<p>Firefox doesn't support this but there is an xml bindings file which can be used to enable htc support (see here: <a href="http://dean.edwards.name/moz-behaviors/overview/" rel="nofollow">http://dean.edwards.name/moz-behaviors/overview/</a>). The examples work in FF3 but when I use my webservice.htc as I normally would e.g.:</p>
<pre><code>//Main.aspx
/*SNIP*/
<style type="text/css" media="all">
#webservice
{
behavior:url(webservice.htc);
-moz-binding:url(bindings.xml#webservice.htc);
}
</style>
</head>
<body>
<div id="webservice"></div> <!-- we use this div to load the webservice stuff -->
/*SNIP*/
//Main.js
webservice.useService(url + asmpath + "/WebServiceWrapper.asmx?WSDL","WebServiceWrapper");
</code></pre>
<p>I get webservice is not defined (works fine in IE), I obviously tried</p>
<pre><code>var webservice = document.getElementById("webservice")
</code></pre>
<p>and </p>
<pre><code>$("#webservice").useService(url + asmpath + "/WebServiceWrapper.asmx?WSDL","WebServiceWrapper");
</code></pre>
<p>as well which just gives me "useService is not defined" in Firebug. Which leads me to beleive that the binding is not working. However I can see that webservice.htc is being loaded by Firefox in the Firebug console window.</p>
<p>Anyone got any experience of this?</p>
<p>Am I going to have to rewrite how the webservice is called?</p>
<p>Cheers,
Rob</p>
|
<p>I don't think that you are on the right way for achieving real cross-browser compatibility. Adding support for IE-specific features for Firefox is definitely <strong>not</strong> the way to go. What about Opera, Safari, Chrome...? If the app you're working on is used strictly on the intranet then supporting Firefox may be enough however...</p>
<p>IMHO, the code should be refactored, but in an other way. If you are working with ASP.NET 2.0 (in this case you'd need ASP.NET Ajax) or newer, you can create proxy between Ajax and SOAP web services. In that case you would need to rewrite all your behaviors as a JavaScript code which may not be a small feat.</p>
<p>On a side note: AFAIK VS.NET does not generate behaviors.</p>
<p>Sorry if this is not too helpful :(</p>
|
How do I insert text at beginning of a multi-line selection in vi/Vim? <p>In <a href="http://en.wikipedia.org/wiki/Vim_%28text_editor%29">Vim</a>, how would I go about inserting characters at the beginning of each line in a selection?</p>
<p>For instance, let's say I want to comment out a block of code by prepending '//' at the beginning of each line (assuming my language's comment system doesn't allow block commenting like /* */). How would I do this?</p>
|
<ul>
<li>Use <kbd>Ctrl</kbd>+<kbd>V</kbd> to enter visual block mode</li>
<li>Move <kbd>Up</kbd>/<kbd>Down</kbd>to select the columns of text in the lines you want to
comment.</li>
<li>Then hit <kbd>Shift</kbd>+<kbd>i</kbd> and type the text you want to insert.</li>
<li>Then hit <kbd>Esc</kbd>, wait 1 second and the inserted text will appear on every line.</li>
</ul>
|
Fieldsets and legends <p>Alright, I know how the <code>fieldset</code>/<code>legend</code> works out in HTML. Say you have a form with some fields:</p>
<pre><code><form>
<fieldset>
<legend>legend</legend>
<input name="input1" />
</fieldset>
</form>
</code></pre>
<p>What should I use the <code>legend</code> for? It's being displayed as a <strong>title</strong>, but isn't a legend semantically an explanation of the contents? In my view, preferably you'd do something like this:</p>
<pre><code><form>
<fieldset>
<legend>* = required</legend>
<label for="input1">input 1 *</label><input id="input1" name="input1" />
</fieldset>
</form>
</code></pre>
<p>But that doesn't really work out with how fieldsets are rendered. Is this just a ambigious naming in HTML, or is it my misunderstanding of the English word 'legend'?</p>
<hr>
<p>Edit: fixed some errors ;-)</p>
|
<p>Yes, the naming is ambiguous. Itâs best to consider it as a caption for the fieldset.</p>
<p>See <a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.10" rel="nofollow">the HTML spec on <code>FIELDSET</code> and <code>LEGEND</code> elements</a> if you havenât already:</p>
<blockquote>
<p>The <a href="http://www.w3.org/TR/html401/interact/forms.html#edef-LEGEND" rel="nofollow"><code>LEGEND</code></a> element allows authors to assign a caption to a <a href="http://www.w3.org/TR/html401/interact/forms.html#edef-FIELDSET" rel="nofollow"><code>FIELDSET</code></a>. The legend improves accessibility when the <a href="http://www.w3.org/TR/html401/interact/forms.html#edef-FIELDSET" rel="nofollow"><code>FIELDSET</code></a> is rendered non-visually.</p>
</blockquote>
|
What is the practical use of "dynamic" variable in C# 4.0? <p>What is their use if when you call the method, it might not exist?</p>
<p>Does that mean that you would be able to dynamically create a method on a dynamic object?</p>
<p>What are the practical use of this?</p>
|
<p>You won't really be able to dynamically create the method - but you can get an implementation of <code>IDynamicMetaObject</code> (often by extending <code>DynamicObject</code>) to respond <em>as if the method existed</em>.</p>
<p>Uses:</p>
<ul>
<li>Programming against COM objects with a weak API (e.g. office)</li>
<li>Calling into dynamic languages such as Ruby/Python</li>
<li>Potentially making "explorable" objects - imagine an XPath-like query but via a method/property calls e.g. <code>document.RootElement.Person[5].Name["Attribute"]</code></li>
<li>No doubt many more we have yet to think of :)</li>
</ul>
|
Hidden FreeTextBox bug on Firefox <p>I have a problem with the <a href="http://freetextbox.com/" rel="nofollow">FreeTextBox</a> rich Text Editor in my ASP.NET site. The problem occurs when I access the site with firefox, and I have a freetextbox instance in a hidden div. The hidden div might also be an AJAX Tab Panel. The actual problem is that when the page loads it throws an uncaught exception (firebug shows the StoreHtml() function) and halts the postback!! </p>
<p>Is anywhere of the problem and a solution for it?? </p>
<p>Thanks</p>
|
<p>I recently met a similar problem with jQuery UI tabs. What you need to do is to change the CSS for hidden tabs to something like:</p>
<pre><code>.hiddentab
{
position: absolute;
left: -99999999999999;
}
</code></pre>
<p>This puts hidden tabs far to the left, and in absolute position mode this does not cause horizontal scroll bars to appear. When the tab is shown, simply remove the hiddentab class from the tab element.</p>
<p>This will work if the problem is related to Firefox' odd behavior with display: none.</p>
|
Weird #include problem <p>I have a problem with a simple included file.</p>
<p>The file being included is in two MFC programs - one of which is a dll, and it also compiles itself into a non-mfc dll.</p>
<p>Recently I was using the larger dll which wraps around the <em>source</em> of the smaller dll when I wanted access to some of the features of the original code that isn't exposed by the larger dll.</p>
<p>Since this was a test I simply added the source to my project and called the functions. I got this error: <strong>syntax error : missing ')' before ';'</strong></p>
<p>The file is correctly included, and I have both the .cpp and the .h in the source folder, and within the project but it wouldn't compile. </p>
<p>I eventually created a very small test project, main.cpp, spooler.cpp and spooler.h (the spooler is a wrapper around the comms) and tried to compile that. Same issue.</p>
<p>So I ripped out all the dll related stuff just in case there is a weird issue going on with that and it still won't compile.</p>
<p>I can't think of the life of me what is wrong. Does anyone else have any ideas?</p>
<p>p.s. Jeff you really need to add the ability to attach files because the source would fill up too many screens with data.</p>
|
<p>Build using the /P option, which will create a preprocessed file (usually with the .i extension).</p>
<p>In Visual Studio, the option will be on the properties for the project under something like:</p>
<pre><code>C/C++ - Preprocessor - Generate Preprocessed File
</code></pre>
<p>With that you can see exactly how macros are being expanded. You may need to run the .i file through the compiler to find the exact line that causes the syntax error. It can be a pain to read the post-preprocessed file, but it should show what's going on.</p>
|
Have you used the Perl 5.10 backtracking control verbs in your regexes yet? <p>Have you used the Perl 5.10 backtracking control verbs in your regexes yet? And what problems did they help you accomplish? </p>
<hr>
<p>Just as background: I have done some fiddling, but I can't get any really useful results.</p>
<p>As a comparison, when I started getting what the <code>(?></code> grouping did, it started showing up more in my regexes. I liked the idea of tuning the world of Perl regex to a particular set of assumptions. As RE languages get more featured, the backtracking has made the performance of REs wildly divergent from the lean and mean FSA that they were based upon. </p>
<hr>
<p>When someone can tell me what <em>other</em> implementation of REs has backtracking control verbs--and PCRE <em>does not</em>, I can concede that it belongs in the general area of expertise of people knowledgeable about regexes. This is a <em>Perl</em> regex question, and guys helping people out with Ruby, Python, C#, Javascript--or any PCRE client implementations-- probably can't help or see it as a waste of space for the tags they normally read.</p>
|
<p>It's been years since I did any Perl programming, so I didn't even know about this feature until you mentioned it. It looks like one of those hardcore feature that only regex gurus would use (of course, the Perl community has plenty of those). Perl 6 Grammars, on the other hand, look like they'll be a lot fun to play with.</p>
<p>For now, I'm content with atomic groups and possessive quantifiers.--in fact, I'm practically addicted to them. It's gotten to the point where I reflexively try to write regexes in such a way that they'll never backtrack. I have to remind myself sometimes that backtracking is okay in small doses, and it's not worth the effort to eliminate it completely.</p>
<p>p.s., As far as I know, possessive quantifiers are only supported by Java, PCRE (PHP, Apache, Flex 3/ActionScript 3), and the JGSoft regex engine used by RegexBuddy, EditPad Pro and PowerGrep.</p>
<p>update: The Oniguruma flavor (used in Ruby 1.9+ and TextMate) supports both atomic groups and possessive quantifiers. And of course, Perl 5.10 supports them in addition to the backtracking-control verbs.</p>
|
How can I return a joined table as an enumerable on an anonymous return type in linq to sql? <p>I'd like to return an object with the following signature</p>
<pre><code>class AnonClass{
string Name {get;}
IEnumerable<Group> Groups {get;}
}
</code></pre>
<p>I have tried the following query, but g only returns a single entity, not all the joined entities</p>
<pre><code>var q = from t in dc.Themes
join g in dc.Groups on t.K equals g.ThemeK
select new {t.Name, Groups = g};
return q.ToArray();
</code></pre>
<p>but this returns</p>
<pre><code>class AnonClass{
string Name {get;}
Group Groups{get;}
}
</code></pre>
<p>What is the correct linq query to use?</p>
|
<p>I think you want "join into" instead of just "join":</p>
<pre><code>var q = from t in dc.Themes
join g in dc.Groups on t.K equals g.ThemeK into groups
select new { t.Name, Groups=groups };
</code></pre>
<p>(That's completely untested, however - worth a try, but please verify carefully!)</p>
|
MSI Bootstrapping: External URLs <p>Much searching has lead me to find several descriptions of how to create a bootstrapping msi, but these solutions all assume the msi is local or a standard Windows component. Is there a way to make an msi that downloads an installer (which is also an msi) with normal MSI or Wix code rather than by having the bootstrapper execute some non-native program to do so?</p>
|
<p>My experience with msi's has been it's not possible to run 2 at the same time. (could be wrong though)</p>
<p>What I ended up doing was to instead make an installer exe using Inno Setup (<a href="http://www.jrsoftware.org" rel="nofollow">http://www.jrsoftware.org</a>) and ISTool (<a href="http://www.istool.org" rel="nofollow">http://www.istool.org</a>) which downloads and installs the various msi's. With ISTool it's very easy to do.</p>
<p>I know it's not as chic or sexy as Wix, but it worked for me very well.</p>
|
Colemak keyboards with Emacs or VIM <p>I've been crossing things out on my TODO list. I've recently picked up Colemak. Next I wanted to learn Vim or Emacs. I was leaning towards Vim, however one of its benefits are sticking to the home row. With Colemak, the home row has been changed. I realize that I could remap the keys, but assigning the functionality to different letters is not extremely appealing to me (if there is any relation between letters and their function. I know movement is not correlated but I'm not sure on all the rest.)</p>
<p>I don't want to start an argumentative post about text editors, but rather receive comments from Colemak (or Dvorak) users about alternative keymappings and these two editors.</p>
<p>Thanks</p>
|
<p>I'm using a similar set up to <a href="http://stackoverflow.com/a/2190106/383793">Graham</a> (up, down, left, right, is hkjl (Qwerty hnyu)) but instead of using noremap, remap using langmap in my .vimrc:</p>
<pre><code>set langmap=hk,jh,kj
</code></pre>
<p>This has the added advantage of changing other commands that use these movement keys (e.g. g, z and C-w) without having to redefine all these commands manually, i.e. C-wh moves up a window, C-wk moves down a window, etc.</p>
|
Design Pattern to apply conversion to multiple properties in multiple classes <p>I am using the WMD markdown editor in a project for a large number of fields that correspond to a large number of properties in a large number of Entity classes. Some classes may have multiple properties that require the markdown.</p>
<p>I am storing the markdown itself since this makes it easier to edit the fields later. However, I need to convert the properties to HTML for display later on. The question is: is there some pattern that I can use to avoid writing markdown conversion code in all my entity classes?</p>
<p>I created a utility class with a method that accepts a markdown string and returns the HTML. I am using markdownj and this works fine.</p>
<p>The problem is for each property of each class that stores markdown I may need another method that converts to HTML:</p>
<pre><code>public class Course{
private String description;
.
.
.
public String getDescription(){
return description;
}
public String getDescriptionAsHTML(){
return MarkdownUtil.convert(getDescription());
}
.
.
.
}
</code></pre>
<p>The problem there is that if the Course class has 2 more properties Tuition and Prerequisites say, that both need converters then I will have to write getTuitionAsHTML() and getPrerequisiteAsHTML().</p>
<p>I find that a bit ugly and would like a cleaner solution. The classes that require this are not part of a single inheritance hierarchy. </p>
<p>The other option I am considering is doing this in the controller rather than the model. What are your thoughts on this? </p>
<p>Thanks.</p>
<p>[EDIT]: New thoughts (Thanks Jasper). Since the project uses struts2 (I did not say this before) I could create a view component say that will convert the markdown for me. Then I use that wherever I need to display the value as HTML.</p>
|
<blockquote>
<p>The classes that require this are not part of a single inheritance hierarchy.</p>
</blockquote>
<p>They should at least implement a common interface, otherwise coming up with a clean generic solution is going to be cumbersome.</p>
<blockquote>
<p>The other option I am considering is doing this in the controller rather than the model. What are your thoughts on this?</p>
</blockquote>
<p>This clearly is a responsibility of the View. The #1 MVC rule is that the Model doesn't care about its representation, the markdown in this case.</p>
<p>However, I feel that there is to little detail about your current architecture to give a meaningful answer to your question.</p>
|
Converting audio to CAF format for playback on iPhone using OpenAL <p>I am using the SoundEngine sample code from Apple in the CrashLanding sample to play back multiple audio files. Using the sample caf files included with CrashLanding everything works fine but when I try and use my own samplesconverted to CAF using afconvert all I get is a stony silence ;)</p>
<p>Does anyone have settings for afconvert that will produce a CAF file capable of being played back through OpenAL?</p>
|
<pre><code>afconvert -f caff -d LEI16@44100 -c 1 in.wav out.caf
</code></pre>
<p>References:</p>
<ul>
<li>Apple's <a href="https://developer.apple.com/library/ios/documentation/audiovideo/conceptual/multimediapg/usingaudio/usingaudio.html#//apple_ref/doc/uid/TP40009767-CH2-SW28">Multimedia Programming Guide: Using Audio: Preferred Audio Formats in iOS</a></li>
<li><a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man1/afconvert.1.html">afconvert(1) man page</a> (use <code>afconvert -h</code> for complete info)</li>
</ul>
|
Best approach for maintaining a quality assurance server for several mid tier clients <p>We are getting to the point where we have several mid tier clients that could benefit from a QA server, but none can afford to pay for a dedicated QA box as well as a dedicated production box. I've been toying with the idea of a virtual environment, either hosted in our office or with a third-party, that several clients could hit to view work in progress that would offset the total cost. Most of these sites will be a LAMP stack, but there is the potential every long once in a great while that a .NET or Java site would be thrown into the mix. I'm looking for a solid approach, but obviously not full implementation details.</p>
|
<p>All of our QA/Test environments are hosted on virtual boxes. We have exact replicas of our production server made into virtual servers for testing purposes. Just make sure when you set up the test environments you make them as close to the production box as you possibly can. This will give make your test results more viable and you won't run into "well it works in test, I don't know why it doesn't work in production" scenarios as much. </p>
|
Access parent property in jQuery callback <p>Unsure if I've phrased this correctly, but in the callback how do I reference the controls property of the base class?</p>
<p>This has been bugging me for some time and I usually work around it, but I'd be grateful if anybody can enlighten me on how I should do this properly.</p>
<pre><code>var base = function() {
var controls = {};
return {
init: function(c) {
this.controls = c
},
foo: function(args) {
this.init(args.controls);
$(this.controls.DropDown).change(function() {
$(this.controls.PlaceHolder).toggle();
});
}
}
};
</code></pre>
<p>Much Obliged,</p>
<p>Paul</p>
|
<p>Use the power of closures:</p>
<pre><code>var base = function() {
var controls = {};
return {
init: function(c) {
this.controls = c
},
foo: function(args) {
var self = this;
this.init(args.controls);
$(this.controls.DropDown).change(function() {
$(self.controls.PlaceHolder).toggle();
});
}
}
};
</code></pre>
|
Should javac find methods outside of an anonymous class of the same name? <p>This question is a follow up to:
<a href="http://stackoverflow.com/questions/252267/why-cant-i-call-a-method-outside-of-an-anonymous-class-of-the-same-name">Why canât I call a method outside of an anonymous class of the same name</a></p>
<p>This previous question answer <b>why</b>, but now I want to know if javac <b>should</b> find run(int bar)? (See previous question to see why run(42) fails)</p>
<p>If it shouldn't, is it due to a spec? Does it produce ambiguous code? My point is, I think this is a bug. While the previous question explained why this code fails to compile, I feel it should compile if javac searched higher in the tree if it fails to find a match at the current level. IE. If this.run() does not match, it should automatically check NotApplicable.this for a run method.</p>
<p>Also note that foo(int bar) is correctly found. If you give any reason why run(int bar) shouldn't be found, it must also explain why foo(int bar) is found.</p>
<pre><code>public class NotApplicable {
public NotApplicable() {
new Runnable() {
public void run() {
// this works just fine, it automatically used NotApplicable.this when it couldn't find this.foo
foo(42);
// this fails to compile, javac find this.run(), and it does not match
run(42);
// to force javac to find run(int bar) you must use the following
//NotApplicable.this.run(42);
}
};
}
private void run(int bar) {
}
public void foo(int bar) {
}
}
</code></pre>
|
<p>This behavior of javac conforms to the spec. See <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#20448" rel="nofollow">§15.12 Method Invocation Expressions</a> in the Java Language Specification, specifically the paragraph under "Compile Time Step 1" explaining the meaning of an unqualified method invocation:</p>
<blockquote>
<p>If the Identifier appears within the scope (§6.3) of a visible method declaration with that name, then there must be an enclosing type declaration of which that method is a member. Let T be the innermost such type declaration. The class or interface to search is T. </p>
</blockquote>
<p>In other words, the unqualified method <em>name</em> is searched for in all enclosing scopes, and the innermost "type declaration" (which means either a class or an interface declaration) in which the name is found is the one that will be searched for the whole signature (in "Compile Time Step 2").</p>
|
How do you pass commands to a Cygwin console in Windows using Inno Setup <p>I've tried variations of this, but had no luck other than the ability to start a cygwin window. (wrapped on <strong>;</strong> for clarity)</p>
<pre><code>Filename: "c:\cygwin\bin\bash.exe";
Parameters: "-c c:/scripts/step1.sh paramX";
Flags: shellexec waituntilterminated;
StatusMsg: "Running the script..."
</code></pre>
<p>(this is for an internal install, thus cywin is installed, and all paths, scripts are known)</p>
|
<p>Your problem is that <code>-c</code> tells bash to read instructions from the next parameter:
e.g.</p>
<pre><code>c:\cygwin\bin\bash.exe -c 'for NUM in 1 2 3 4 5 6 7 8 9 10; do echo $NUM; done'
</code></pre>
<p>you just need:</p>
<pre><code>c:\cygwin\bin\bash.exe "/scripts/step1.sh paramX"
</code></pre>
<p>So your code would look like:</p>
<pre><code>Filename: "c:\cygwin\bin\bash.exe";
Parameters: "c:/scripts/step1.sh paramX";
Flags: shellexec waituntilterminated;
StatusMsg: "Running the script..."
</code></pre>
<p>Maybe this will be helpful for somebody else :)</p>
|
In Python, is there a concise way of comparing whether the contents of two text files are the same? <p>I don't care what the differences are. I just want to know whether the contents are different.</p>
|
<p>The low level way:</p>
<pre><code>from __future__ import with_statement
with open(filename1) as f1:
with open(filename2) as f2:
if f1.read() == f2.read():
...
</code></pre>
<p>The high level way:</p>
<pre><code>import filecmp
if filecmp.cmp(filename1, filename2, shallow=False):
...
</code></pre>
|
Storing video duration time in sql server <p>What's the most appropriate type used to store the duration time information of a video in sql server?</p>
|
<p>It depends on how granular you need and if you have any constraints on a maximum time. For example, would you need to know down to the millisecond of time duration or is 1 second granular enough? The other thing to consider is how much data do you (or can you) store.</p>
<p>For SQL Server 2005, you have these constraints:</p>
<p>tinyint </p>
<ul>
<li>min = 0</li>
<li>max =255</li>
<li>Size = 1 byte</li>
</ul>
<p>smallint </p>
<ul>
<li>min = -2^15 (-32,768)</li>
<li>max= 2^15 - 1 (32,767)</li>
<li>Size = 2 bytes</li>
</ul>
<p>int </p>
<ul>
<li>min = -2^31 (-2,147,483,648)</li>
<li>max = 2^31 - 1 (2,147,483,647)</li>
<li>Size = 4 bytes</li>
</ul>
<p>bigint </p>
<ul>
<li>min = -2^63
(-9,223,372,036,854,775,808)</li>
<li>Max = 2^63 - 1
(9,223,372,036,854,775,807)</li>
<li>Size = 8 bytes</li>
</ul>
|
User Access Checking for Rights on Particular Database Objects or Records <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 documentID on the QueryString, I propose that the stored procedure that loads the document take the UserId as a parameter to validate rights to the document.</p>
<p>My developer friend suggests that we run a separate procedure to determine access rights to the document earlier in the page and just run a procedure to grab the document when the document should be shown.</p>
<p>Are we missing something? Which is most efficient and safe? I thought passing the UserId with the DocID into one procedure call to check rights and pull the document was a more efficient solution.</p>
|
<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 opened a big hole. This way it's apparent and baked in that you can't get to the doc unless you have access.</p>
|
Is it possible to get line numbers for stack traces on .Net CF 2.0 or 3.5 <p>I have a .Net CF 2.0 application and am using log4net to log errors. I get a stack trace, but it doesn't have any line numbers. I noticed that it doesn't appear to deploy the pdb file to the device, so I tried to manually place it in the same directory as the exe. But that didn't help.</p>
|
<p>I'm not sure if .Net CF will open pdbs. Also I'm not sure you want to deploy those to a device. If you are industrious you can make a tool to transform a callstack with il offsets into one with line #'s. I'd suggest this <a href="http://blogs.msdn.com/jmstall/archive/2005/08/25/pdb2xml.aspx" rel="nofollow">post</a> on Mike Stall's blog which provides code on extracting the info out of a managed pdb. Once you have the line to offset map making a tool to post process those callstacks is possible.</p>
|
Question SpeechSynthesizer.SetOutputToAudioStream audio format problem <p>I'm currently working on an application which requires transmission of speech encoded to a specific audio format.</p>
<pre><code>System.Speech.AudioFormat.SpeechAudioFormatInfo synthFormat =
new System.Speech.AudioFormat.SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat.Pcm,
8000, 16, 1, 16000, 2, null);
</code></pre>
<p>This states that the audio is in PCM format, 8000 samples per second, 16 bits per sample, mono, 16000 average bytes per second, block alignment of 2.</p>
<p>When I attempt to execute the following code there is nothing written to my MemoryStream instance; however when I change from 8000 samples per second up to 11025 the audio data is written successfully.</p>
<pre><code>SpeechSynthesizer synthesizer = new SpeechSynthesizer();
waveStream = new MemoryStream();
PromptBuilder pbuilder = new PromptBuilder();
PromptStyle pStyle = new PromptStyle();
pStyle.Emphasis = PromptEmphasis.None;
pStyle.Rate = PromptRate.Fast;
pStyle.Volume = PromptVolume.ExtraLoud;
pbuilder.StartStyle(pStyle);
pbuilder.StartParagraph();
pbuilder.StartVoice(VoiceGender.Male, VoiceAge.Teen, 2);
pbuilder.StartSentence();
pbuilder.AppendText("This is some text.");
pbuilder.EndSentence();
pbuilder.EndVoice();
pbuilder.EndParagraph();
pbuilder.EndStyle();
synthesizer.SetOutputToAudioStream(waveStream, synthFormat);
synthesizer.Speak(pbuilder);
synthesizer.SetOutputToNull();
</code></pre>
<p>There are no exceptions or errors recorded when using a sample rate of 8000 and I couldn't find anything useful in the documentation regarding SetOutputToAudioStream and why it succeeds at 11025 samples per second and not 8000. I have a workaround involving a wav file that I generated and converted to the correct sample rate using some sound editing tools, but I would like to generate the audio from within the application if I can.</p>
<p>One particular point of interest was that the SpeechRecognitionEngine accepts that audio format and successfully recognized the speech in my synthesized wave file...</p>
<p>Update: Recently discovered that this audio format succeeds for certain installed voices, but fails for others. It fails specifically for LH Michael and LH Michelle, and failure varies for certain voice settings defined in the PromptBuilder.</p>
|
<p>I have created some classes in my <a href="http://www.codeplex.com/naudio" rel="nofollow">NAudio</a> library to allow you to convert your audio data to a different sample rate, if you are stuck with 11025 from the synthesizer. Have a look at <code>WaveFormatConversionStream</code> (which uses ACM) or <code>ResamplerDMO</code> (uses a DirectX Media Object)</p>
|
Why don't more .NET applications use MySQL or a DAO that allows for the use of MySQL? <p>I suppose this question could just as easily be applied to PHP with regard to MSSQL. However, with some versions of MSSQL being so expensive, I always wondered, what is the real advantage of choosing it over MySQL for .NET development? Is it really difficult to use .NET tools in conjunction with a MySQL database? Why not create some sort of DAO that abstracts out the differences between the two so that you can use both? As I consider building .NET apps, I'm always wondering, should I just go with MSSQL, and not even consider MySQL as an option?</p>
|
<p>Typically, the fact MySQL came so late to the stored procedure party has kept many away from the database. However, I do like the database and use it with some regularity in my "outside the office" time. Did you know the BO ships Crystal with MySQL as its choice datasource?</p>
<p>As for .NET and what to do? If you do not need the advanced features, then I would recommend SQL Express Edition. </p>
|
Help with CredEnumerate <p>As a follow-up to <a href="http://stackoverflow.com/questions/199518/how-to-programatically-add-mapped-network-passwords-winxp">this</a> question I am hoping someone can help with the <a href="http://msdn.microsoft.com/en-us/library/aa374794(VS.85).aspx" rel="nofollow">CredEnumerate</a> API. </p>
<p>As I understand from the documentation the PCREDENTIALS out parameter is a "pointer to an array of pointers to credentials". I am able to successfully call the CredEnumerate API using C# but I am not sure of how to convert the PCREDENTIALS into something useful (like a list of credentials).</p>
<p>Edit: Here's the code I am using:</p>
<pre><code> int count = 0;
IntPtr pCredentials = IntPtr.Zero;
bool ret = false;
ret = CredEnumerate(null, 0, out count, out pCredentials);
if (ret != false)
{
IntPtr[] credentials = new IntPtr[count];
IntPtr p = pCredentials;
for (int i = 0; i < count; i++)
{
p = new IntPtr(p.ToInt32() + i);
credentials[i] = Marshal.ReadIntPtr(p);
}
List<Credential> creds = new List<Credential>(credentials.Length);
foreach (IntPtr ptr in credentials)
{
creds.Add((Credential)Marshal.PtrToStructure(ptr, typeof(Credential)));
}
}
</code></pre>
<p>Unfortunately, while this works for the first credential in the arrayâit gets generated and added to the list correctlyâsubsequent array items bomb at Marshal.PtrToStructure with the following error:</p>
<p><em>Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</em></p>
<p>Any ideas? Anyone? Bueller?</p>
|
<p>You need to dereference the pointer to the array to get the array, then for each item in the array you will need to dereference the item to get the <code>PCREDENTIALS</code> instance.</p>
<p>I found <a href="http://www.msnewsgroups.net/group/microsoft.public.dotnet.languages.csharp/topic33651.aspx" rel="nofollow">this post with some example code</a> for performing what you want to do:</p>
<pre><code>[DllImport("advapi32", SetLastError = true, CharSet=CharSet.Unicode)]
static extern bool CredEnumerate(string filter, int flag, out int count, out IntPtr
pCredentials);
</code></pre>
<p>...</p>
<pre><code>int count = 0;
IntPtr pCredentials = IntPtr.Zero;
IntPtr[] credentials = null;
bool ret = CredEnumerate(null, 0, out count, out pCredentials);
if (ret != false)
{
credentials = new IntPtr[count];
IntPtr p = pCredentials;
for (int n = 0; n < count; n++)
{
credentials[n] = Marshal.ReadIntPtr(pCredentials,
n * Marshal.SizeOf(typeof(IntPtr)));
}
}
else
// failed....
</code></pre>
<p>Then for each pointer you'll need to use <code>Marshal.PtrToStructure</code> to dereference the pointer into a <code>PCREDENTIALS</code> struct instance (sorry I cannot find the typedef for <code>PCREDENTIALS</code> anywhere, I'll assume you have it - and if you do don't forget the correct MarshalAs attributes and StructLayout attribute when you do define it):</p>
<pre><code>// assuming you have declared struct PCREDENTIALS
var creds = new List<PCREDENTIALS>(credentials.Length);
foreach (var ptr in credentials)
{
creds.Add((PCREDENTIALS)Marshal.PtrToStructure(ptr, typeof(PCREDENTIALS)));
}
</code></pre>
<p>You would obviously want to combine the example and <code>PtrToStructure</code> code for optimal results but I wanted to leave the integrity of the example intact.</p>
|
Forking open source PHP code, project classloader strategy <p>I've been looking for a good PHP ORM tool to use, and I recently found a good ORM class in Kohana. It has a fairly good and simple ORM implementation. The problem is, the code is unreusable outside of the Kohana framework without a rewrite/refactor. It relies on the Kohana class loader and various framework loading strategies to even work in the first place. Further, the required classes aren't packaged into a single dependency directory, or even multiple directories. </p>
<p>When I do this rewrite, I intend to republish the code via sourceforge or something, and those guys can of course reuse it if they want. So, should I just package the fileset needed into one directory, and make the appropriate classes do a require_once on any dependant classes, and 2 should I stick with the original class names that are project dependent (like Kohana_exception) even though it is pretty much unrelated to the Kohana project as a whole?</p>
<p>A second option would be to write another classloader that is a simplified version of the Kohana Framework classloader, and only cares about the ORM related stuff...</p>
|
<p>If you think what you are doing will be a marked improvement to the Kohana project you should make your changes and submit a patch to be considered by the project's maintainers. You probably aren't the first person to appreciate a part of their framework and component-izing their framework into smaller bits may be something you could help encourage by submitting a patch (though that will require much more time on your part to engineer).</p>
<p>It sounds like you are extracting a piece of their framework for independent use so it doesn't sound like you're forking at all, though I can imagine removing all of those dependencies may sure seem like a fork.</p>
|
Markdown and image alignment <p>I'm helping out a friend with a non-profit site that publishes articles in issues each month. They are mostly straightforward, and I think using a markdown editor (like the wmd one here in SO) would be perfect. However, they do need the ability to have images right-aligned in a given paragraph. I can't see any way to do that with the current system - is it possible?</p>
|
<p>You can embed HTML in Markdown, so you can do something like this:</p>
<pre><code><img style="float: right;" src="whatever.jpg">
Continue markdown text...
</code></pre>
|
Can you recommend a free Task Board/Burndown tool for Windows? <p>There's not a lot to add to the subject really.</p>
<p>I am after a free task board/ burndown reporting tool for Windows.</p>
|
<p>If you're willing to host your tool, </p>
<ul>
<li>TargetProcess
(<a href="http://www.targetprocess.com/Product/agile_tour.aspx" rel="nofollow">http://www.targetprocess.com/</a>)</li>
<li>XPlanner(<a href="http://xplanner.codehaus.org/" rel="nofollow">http://xplanner.codehaus.org/</a>)</li>
</ul>
<p>If not,</p>
<ul>
<li>Pivotal Tracker (<a href="http://www.pivotaltracker.com/" rel="nofollow">http://www.pivotaltracker.com/</a>)</li>
<li>ScrumWorks (<a href="http://danube.com/scrumworks/basic" rel="nofollow">http://danube.com/scrumworks/basic</a>)</li>
</ul>
<p>All are either free or have a free version.</p>
|
Automating unit tests (junit) for Eclipse Plugin development <p>I am developing Eclipse plugins, and I need to be able to automate the building and execution of the test suite for each plugin. (Using Junit)</p>
<p>Test are working within Eclipse, and I can break the plugins into the actual plugin and a fragment plugin for unit testing as described <a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.test/testframework.html?view=co" rel="nofollow">here</a>, <a href="http://rcpquickstart.com/2007/08/06/running-automated-tests-with-pde-build/" rel="nofollow">here</a> and in a couple places <a href="http://eclipsenuggets.blogspot.com/2007/09/6-great-links-for-eclipse-build.html" rel="nofollow">here</a>.</p>
<p>However, each of the approaches above results in the same issue: The java ant task/commandline command that issues the build or should trigger the test, generates no observable side effects, and returns the value "13". I've tried everything I can find, and I've learned a fair bit about how Eclipse starts up (eg: since v3.3 you can no longer use startup.jar -- it doesn't exist -- but you should use <a href="http://blog.ciscavate.org/2008/11/treat-your-mailing-lists-like-reference-documents-please.html" rel="nofollow">org.eclipse.equinox.launcher</a>). Unfortunately, while that is apparently necessary information, it is far from sufficient.</p>
<p>I am working with Eclipse 3.4, Junit 4.3.1 (the org.junit4 bundle, but I would much rather use JUnit 4.4. See <a href="http://stackoverflow.com/questions/251791">here</a>.)</p>
<p>So, my question is: How exactly do you automate the build and testing of Eclipse plugins? </p>
<p><em>Edit:</em> To clarify, I <em>want</em> to use something like ant + cruise control, but I can't even get the unit tests to run <em>at all</em> outside of Eclipse. I say "something like" because there are other technologies that accomplish the same thing, and I am not so picky as to discard a solution that works just because it's using say, Maven or Buckminster, if those technologies make this substantially easier.</p>
<p><em>Edit2:</em> The 'Java Result 13' mentioned above seems to be caused by the inability to find the coretestrunner. From the log:</p>
<pre><code>java.lang.RuntimeException: Application "org.eclipse.test.coretestapplication" could not be found in the registry. The applications available are: org.eclipse.equinox.app.error, com.rcpquickstart.helloworld.application.
at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:242)
at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
at org.eclipse.core.launcher.Main.main(Main.java:30)
!ENTRY org.eclipse.osgi 2 0 2008-11-04 21:02:10.514
!MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
!SUBENTRY 1 org.eclipse.osgi 2 0 2008-11-04 21:02:10.515
!MESSAGE Bundle update@plugins/org.eclipse.test_3.2.0/ [34] was not resolved.
!SUBENTRY 2 org.eclipse.test 2 0 2008-11-04 21:02:10.516
!MESSAGE Missing required bundle org.apache.ant_0.0.0.
!SUBENTRY 2 org.eclipse.test 2 0 2008-11-04 21:02:10.516
!MESSAGE Missing required bundle org.eclipse.ui.ide.application_0.0.0.
!SUBENTRY 1 org.eclipse.osgi 2 0 2008-11-04 21:02:10.518
!MESSAGE Bundle update@plugins/org.eclipse.ant.optional.junit_3.2.100.jar [60] was not resolved.
!SUBENTRY 2 org.eclipse.ant.optional.junit 2 0 2008-11-04 21:02:10.519
!MESSAGE Missing host org.apache.ant_[1.6.5,2.0.0).
!SUBENTRY 2 org.eclipse.ant.optional.junit 2 0 2008-11-04 21:02:10.519
!MESSAGE Missing required bundle org.eclipse.core.runtime.compatibility_0.0.0.
</code></pre>
|
<p>I have just got JUnit testing working as part of the headless build for our RCP application. </p>
<p>I found this article - <a href="http://www.eclipse.org/articles/article.php?file=Article-PDEJUnitAntAutomation/index.html">Automating Eclipse PDE Unit Tests using Ant</a> incredibly helpful. It provides code and approach to get you started. However, a number of things that I discovered:</p>
<h2>About the article's code</h2>
<ul>
<li>there was only one bundle under tests (we have separated out our build process from the code, using <a href="http://wiki.eclipse.org/Buckminster_Project">Buckminster</a>)</li>
<li>there was only one test class. </li>
<li>these were both effectively hardcoded into the build script</li>
</ul>
<h2>About Eclipse PDE</h2>
<ul>
<li>the <code>uitestapplication</code> requires another <code>testApplication</code>. Using <code>coretestapplication</code> does not. </li>
<li>as these applications are both in bundles that have dependencies on SWT. This is a deal killer in most circumstances, though not if your build machine is a Windows box. I would love to see these split into non-UI bundles.</li>
</ul>
<p>I found that the code provided was a good starting point, but had a number of the above assumptions implicit in their implementation.</p>
<p>Having discovered these assumptions, doing the work was relatively straight forward.</p>
<h2>Our new and shiny setup</h2>
<ul>
<li>buckminster builds the bundles. </li>
<li>target copies the bundles from the target platform, the org.eclipse.pde.runtime and org.eclipse.jdt.junit into a "tester-eclipse-install". This should take care of your <code>Java Result 13</code> problem.</li>
<li>find the test fragments from looking at the workspace</li>
<li>find the fragment host from looking at the manifest</li>
<li>find the test classes from looking at the project in the workspace.</li>
<li>register a <code>PDETestListener</code> modified to handle multiple test classes</li>
<li>invoke the tester-eclipse-install with the multiple test classes.</li>
</ul>
<p>I also read <a href="http://www.eclipse.org/articles/Article-PDE-Automation/automation.html">Build and Test Automation for plug-ins and features</a> but we are not using PDE-Build directly. </p>
|
Serializing Name/Value Pairs in a Custom Object via Web Service <p>This is a very complicated question concerning how to serialize data via a web service call, when the data is not-strongly typed. I'll try to lay it out as best possible.</p>
<p><strong>Sample Storage Object:</strong></p>
<pre><code>[Serializable]
public class StorageObject {
public string Name { get; set; }
public string Birthday { get; set; }
public List<NameValuePairs> OtherInfo { get; set; }
}
[Serializable]
public class NameValuePairs {
public string Name { get; set; }
public string Value { get; set; }
}
</code></pre>
<p><strong>Sample Use:</strong></p>
<pre><code>[WebMethod]
public List<StorageObject> GetStorageObjects() {
List<StorageObject> o = new List<StorageObject>() {
new StorageObject() {
Name = "Matthew",
Birthday = "Jan 1st, 2008",
OtherInfo = new List<NameValuePairs>() {
new NameValuePairs() { Name = "Hobbies", Value = "Programming" },
new NameValuePairs() { Name = "Website", Value = "Stackoverflow.com" }
}
},
new StorageObject() {
Name = "Joe",
Birthday = "Jan 10th, 2008",
OtherInfo = new List<NameValuePairs>() {
new NameValuePairs() { Name = "Hobbies", Value = "Programming" },
new NameValuePairs() { Name = "Website", Value = "Stackoverflow.com" }
}
}
};
return o;
}
</code></pre>
<p><strong>Return Value from Web Service:</strong></p>
<pre><code><StorageObject>
<Name>Matthew</Name>
<Birthday>Jan 1st, 2008</Birthday>
<OtherInfo>
<NameValuePairs>
<Name>Hobbies</Name>
<Value>Programming</Value>
</NameValuePairs>
<NameValuePairs>
<Name>Website</Name>
<Value>Stackoverflow.com</Value>
</NameValuePairs>
</OtherInfo>
</StorageObject>
</code></pre>
<p><strong>What I want:</strong></p>
<pre><code><OtherInfo>
<Hobbies>Programming</Hobbies>
<Website>Stackoverflow.com</Website>
</OtherInfo>
</code></pre>
<p><strong>The Reason & Other Stuff:</strong></p>
<p>First, I'm sorry for the length of the post, but I wanted to give reproducible code as well. </p>
<p>I want it in this format, because I'm consuming the web services from PHP. I want to easily go:</p>
<p>// THIS IS IMPORANT</p>
<pre><code>In PHP => "$Result["StorageObject"]["OtherInfo"]["Hobbies"]".
</code></pre>
<p>If it's in the other format, then there would be no way for me to accomplish that, at all. Additionally, in C# if I am consuming the service, I would also like to be able to do the following:</p>
<p>// THIS IS IMPORANT</p>
<pre><code>In C# => var m = ServiceResult[0].OtherInfo["Hobbies"];
</code></pre>
<p>Unfortunately, I'm not sure how to accomplish this. I was able to get it this way, by building a custom Dictionary that implemented IXmlSerializer (see <a href="http://stackoverflow.com/questions/67959/c-xml-serialization-gotchas">StackOverflow: IXmlSerializer Dictionary</a>), however, it blew the WSDL schema out of the water. It's also much too complicated, and produced horrible results in my WinFormsTester application!</p>
<p>Is there any way to accomplish this ? What type of objects do I need to create ? Is there any way to do this /other than by making a strongly typed collection/ ? Obviously, if I make it strongly typed like this:</p>
<pre><code>public class OtherInfo {
public string Hobbies { get; set; }
public string FavoriteWebsite { get; set; }
}
</code></pre>
<p>Then it would work perfectly, I would have no WSDL issues, I would be able to easily access it from PHP, and C# (.OtherInfo.Hobbies). </p>
<p>However, I would completely lose the point of NVP's, in that I would have to know in advance what the list is, and it would be un
|
<p>This is like dynamic properties for a object.
C# is not quite a dynamic language unlike javascript or maybe PHP can parse the object properties on the fly. The following two methods are what I can think of. The second one might fit into your requirements.</p>
<p><strong>The KISS Way</strong> </p>
<p>The Keep It Simple Stupid way </p>
<pre><code>public class StorageObject {
public string Name { get; set; }
public string Birthday { get; set; }
public List<string> OtherInfo { get; set; }
}
</code></pre>
<p>You can have name value pairs which is separated by '|'</p>
<pre><code>OtherInfo = {"Hobbies|Programming", "Website|Stackoverflow.com"}
</code></pre>
<p>Serialized forms</p>
<pre><code><StorageObject>
<Name>Matthew</Name>
<Birthday>Jan 1st, 2008</Birthday>
<OtherInfo>
<string>Hobbies|Programming</string>
<string>Website|Stackoverflow.com</string>
</OtherInfo>
</StorageObject>
</code></pre>
<p><strong>The Dynamic Way in C#</strong></p>
<p>Make the name value pair part become an XML element so that you can build it dynamically.</p>
<pre><code>public class StorageObject {
public string Name { get; set; }
public string Birthday { get; set; }
public XElement OtherInfo { get; set; } // XmlElement for dot net 2
}
</code></pre>
<p>You can easily build up OtherInfo object as element centric
e.g. </p>
<pre><code>XElement OtherInfo = new XElement("OtherInfo");
OtherInfo.Add( ..Hobbies xelement & text value..);
OtherInfo.Add( ..WebSite xelement & text value..);
</code></pre>
<p>The serialized form will be</p>
<pre><code><OtherInfo>
<Hobbies>Programming</Hobbies>
<Website>Stackoverflow.com</Website>
</OtherInfo>
</code></pre>
<p>or build it as attribute centric</p>
<pre><code>XElement OtherInfo = new XElement("OtherInfo");
OtherInfo.Add( ..nvp xattribute Hobbies & value..);
OtherInfo.Add( ..nvp xattribute WebSite & value..);
<OtherInfo>
<nvp n="Hobbies" v="Programming" />
<nvp n="Website" v="Stackoverflow.com" />
</OtherInfo>
</code></pre>
<p>For any dynamic language, it can access to the properties directly.
For the rest, they can access the value by read the XML. Reading XML is well supported by most of framework.</p>
|
What are the different doctypes in html and what do they mean? <p>As the title describes, what are the different doctypes available and what do they mean? I notice that the layout looks a little different in IE7 when I switch from </p>
<pre><code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
</code></pre>
<p>to</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</code></pre>
<p>Are there any others and what are the effects or ramifications?</p>
<p>Thanks!</p>
|
<p>A <strong>Doctype</strong>, or <strong>Document Type Declaration</strong> associates the document with a <strong>Document Type Definition</strong>.</p>
<p>The <strong>Document Type Definition</strong> is a standard for an XML document. There are many DTDs, for both XML and XHTML documents. XML itself doesn't have much of a schema or a very specific set of rules, apart from the requirement that everything be well-formed. You can think of a DTD as a more specific <strong>schema for the document</strong>.</p>
<p><strong>Rendering Modes</strong></p>
<p>Due to the standards movement, most modern browsers actually have different rendering modes (<strong>standards mode</strong>, for rendering your document and css according to more recent web standards, and <strong>quirks mode</strong>, wherein the browser brings back some rendering ideas from the early days of the web). These modes are instituted for purposes of backward-compatibility. The vast landscape of web pages which were created in the first era of the web are rendered according to the rules of their time, while newer documents can appeal to the new wave of standards. As time goes on and new formats are imagined, a corresponding DTD could potentially be created.</p>
<p><strong>Browser Discrepancies</strong></p>
<p>In an ideal world, a page that is being loaded by a browser would read the Doctype at the top and use it to look up a Document Type Definition. It would then use the schema of that DTD as the basis for reading the rest of the document. Doctypes, then, would be essential for validating markup documents. The DTD would provide the standard against which your document is to be validated.</p>
<p>Unfortunately, it's not an ideal world. Browsers don't necessarily behave consistently here, and if they do, the consistent behavior isn't quite in line with the original vision for Doctypes. Although parsing is done independently of the Doctype, major browsers will at least examine the Doctype to determine the rendering mode. If your Doctype is absent or is incomplete, the browser will likely be rendering in <strong>quirks mode</strong>. For well-written, modern documents to appear correctly, the browser should be rendering in <strong>standards mode</strong>. Mozilla, Safari, and some recent versions of Opera actually implement an <a href="http://developer.mozilla.org/en/Mozilla%27s_DOCTYPE_sniffing"><strong>Almost Standards</strong></a> mode, which is dedicated entirely to transitional pages.</p>
<p>When you change the Doctype and notice changes in the way a page is displayed, it is because the browser may be applying a slightly different set of rules when it tries to parse the document. As a consequence, the resulting page may be a little bit different, depending on whether all of its parts conform to the DTD, or at least, depending on the browser, that your data validates within the rendering mode that the doctype suggests.</p>
<p><strong>Choosing a Doctype</strong></p>
<p>In pursuit of standards-compliance, strict Doctypes should be used whenever possible.</p>
<p>When writing in <strong>XHTML</strong>, this Doctype is common:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</code></pre>
<p>When writing in <strong>HTML 4.1</strong>, this one is common instead:</p>
<pre><code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
</code></pre>
<p>Some other common doctypes for XHTML and HTML 4 are listed here, for completeness:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
</code></pre>
<p><strong>Debate on Strict versus Transitional Doctypes</strong></p>
<p>Standards evangelists have called for web developers to stop using the Transitional Doctype on new pages and instead use Strict. Again, this is a case where the theory and the practice have some difficulties being reconciled. The original hope of the transitional Doctype was to provide a halfway house for transitioning legacy websites toward standards-compliance. With transitional doctypes, the restriction on elements and attributes is literally "less strict", so developers would be able to get their work running under standards mode sooner, and phase out the outstanding differences over time.</p>
<p>Controversy exists because it isn't always quite so simple for a developer change the Doctype in an enterprise environment. Freelance developers and makers of small- or medium- sized websites may often have an easier time determining their Doctype and making this transition. In an enterprise production environment for a highly-demanded web-based service, there are inherently more complicated dependencies on legacy systems and 3rd party code products, which themselves may be on a roadmap for removal or redesign, but the execution of such changes must be done methodically and incrementally.</p>
<p><strong>Helpful Tools</strong></p>
<p>The W3C (<a href="http://en.wikipedia.org/wiki/W3C"><strong>World Wide Web Consortium</strong></a>) is a group which plays an active role in defining these kinds of standards. They maintain a helpful online tool at <a href="http://validator.w3.org/"><strong>http://validator.w3.org/</strong></a> for verifying and validating documents against their standards. There are many other 3rd party tools and <a href="http://addons.mozilla.org/en-US/firefox/search?q=validator&cat=all"><strong>browser extensions</strong></a> with similar functionality.</p>
|
Configuring SQL Server 2005 with both server replication and client replication <p>I need to set up this scenario: </p>
<blockquote>
<p>A SQL Server 2005 database will create a transactional replication subscription from another database to populate a set of lookup tables. These lookup tables will then be published as a merge replication publication to the client's SQL Server Mobile.</p>
</blockquote>
<p>I remember seeing a similar scenario defined in the SQL Server Books Online somewhere, but I was unable to find the link anymore. I hope someone can help me find it, or otherwise point me to any other similar links.</p>
|
<p>Okay, I managed to get the answers I needed at the <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4093478&SiteID=1&mode=1" rel="nofollow">MSDN SQL Server Replication forum</a>.<br />
The article I was looking for is called: <a href="http://msdn.microsoft.com/en-us/library/ms152553(SQL.90).aspx" rel="nofollow">Republishing Data</a>.</p>
<p>Apparently, it is located within "<strong>Advanced Replication Features and Internals</strong>" of the "<strong>Configuring and Maintaining Replications</strong>" section. It's a little non-obvious, so I spent most of my time looking in the "<strong>Replicating Data Between a Server and Clients</strong>" section, instead of there. Good to know, as there seems to be a number of other special scenarios worth looking at in there.</p>
|
How to implement Google Suggest in your own web application (e.g. using Python) <p>In my website, users have the possibility to store links.</p>
<p>During typing the internet address into the designated field I would like to display a suggest/autocomplete box similar to Google Suggest or the Chrome Omnibar.</p>
<p>Example:</p>
<p>User is typing as URL:</p>
<pre><code>http://www.sta
</code></pre>
<p>Suggestions which would be displayed:</p>
<pre><code>http://www.staples.com
http://www.starbucks.com
http://www.stackoverflow.com
</code></pre>
<p>How can I achieve this while not reinventing the wheel? :)</p>
|
<p>You could try with
<a href="http://google.com/complete/search?output=toolbar&q=keyword">http://google.com/complete/search?output=toolbar&q=keyword</a></p>
<p>and then parse the xml result.</p>
|
Data structure used for directory structure? <p>I'm making a program which the user build directories (not in windows, in my app) and in these folders there are subfolders and so on; every folder must contain either folders or documents. What is the best data structure to use? Notice that the user may select a subfolder and search for documents in it and in its subfolders. And I don't want to limit the folders or the subfolders levels.</p>
|
<p>This is what I do:</p>
<p>Every record in the database has two fields: ID and ParentID. IDs are 4-5 characters (Base36, a-z:0-9 or something similar). Parent IDs are a concatenation of the parent's complete structure...</p>
<p>So...</p>
<p>This structure:</p>
<pre><code>Root
Folder1
Folder2
Folder3
Folder4
Folder5
Folder6
</code></pre>
<p>Would be represented like this:</p>
<pre><code>ID ParentID Name
0000 NULL ROOT
0001 0000 Folder1
0002 0000 Folder2
0003 00000002 Folder3
0004 0000 Folder4
0005 00000004 Folder5
0006 000000040005 Folder6
</code></pre>
<p>I like this structure because if I need to find all the files under a folder I can do a query like:</p>
<pre><code>SELECT * FROM Folders WHERE ParentID LIKE '0000%' -- to find all folders under Folder1
</code></pre>
<p>To delete a folder and all its children:</p>
<pre><code>DELETE FROM Folders WHERE ID='0004' AND ParentID LIKE '00000004%'
</code></pre>
<p>To move a folder and its children, you have to update all the records that use the same parent, to the new parent.</p>
<blockquote>
<p>And I don't want to linit the folders or the subfolders levels</p>
</blockquote>
<p>An obvious limitation to this is that the number of subfolders are limited to the size of your ParentID field.</p>
|
Javascript Drag and drop <p>I'm looking for someone to explain how to drag and drop in javascript, I want a horizontal line with some customizable images in it.</p>
<p>I've had a look at the online tutorials for these but find them very hard to use.</p>
|
<p>I would recommend that you look into one of the Javascript Frameworks out there. We use <a href="http://www.prototypejs.org/" rel="nofollow">prototype</a> with scriptaculous. </p>
<p>You can look at a demo for Drag and Drop in Scriptaculous <a href="http://github.com/madrobby/scriptaculous/wikis/puzzle-demo" rel="nofollow">here</a>. And you can run through a tutorial <a href="http://www.tutorialspoint.com/script.aculo.us/scriptaculous_drag_drop.htm" rel="nofollow">here</a>.</p>
<p>Or look into any of the other frameworks such as JQuery or Dojo.</p>
|
Where can I find a good documentation about the core concept of REST? <p>I found a good description on <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" rel="nofollow">wikipedia</a> with a few reference links, but there may be better ones, please help me to find these!</p>
<p>To be clear, I am not looking for implementation for any language specific implementation guides, just the pure concept.</p>
|
<p><a href="http://www.25hoursaday.com/weblog/2007/11/19/GuidelinesForBuildingRESTfulWebServices.aspx" rel="nofollow">Guidelines for Building RESTful Web Services</a> has all the info on the resources you need.</p>
<p>This is another useful <a href="http://www.25hoursaday.com/weblog/2008/08/17/ExplainingRESTToDamienKatz.aspx" rel="nofollow">blog entry</a>:</p>
<p>The uniform interface constraints describe how a service built for the Web can be a good participant in the Web architecture. These constraints are described briefly as follows :</p>
<p>1) Identification of resources: A resource is any information item that can be named and represented (e.g. a document, a stock price at a given point in time, the current weather in Las Vegas, etc). Resources in your service should be identified using URIs. </p>
<p>2) Manipulation of resources via representations: A representation is the physical representation of a resource and should correspond to a valid media type. Using standard media types as the data formats behind your service increases the reach of your service by making it accessible to a wide range of potential clients. Interaction with the resource should be based on retrieval and manipulation of the representation of the resource identified by its URI. </p>
<p>3)Self-descriptive messages: Following the principles of statelessness in your service's interactions, using standard media types and correctly indicating the cacheability of messages via HTTP method usage and control headers ensures that messages are self descriptive. Self descriptive messages make it possible for messages to be processed by intermediaries between the client and server without impacting either. </p>
<p>4)Hypermedia as the engine of application state: Application state should be expressed using URIs and hyperlinks to transition between states. This is probably the most controversial and least understood of the architectural constraints set forth in <a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm" rel="nofollow">Roy Fielding's dissertation</a>. In fact, Fielding's dissertation contains an explicit arguments against using HTTP cookies for representing application state to hammer this point home yet it is often ignored.</p>
|
Register allocation rules in code generated by major C/C++ compilers <p>I remember some rules from a time ago (pre-32bit Intel processors), when was quite frequent (at least for me) having to analyze the assembly output generated by C/C++ compilers (in my case, Borland/Turbo at that time) to find performance bottlenecks, and to safely mix assembly routines with C/C++ code. Things like using the SI register for the <em>this</em> pointer, AX being used for return values, which registers should be preserved when an assembly routine returns, etc.</p>
<p>Now I was wondering if there's some reference for the more popular C/C++ compilers (Visual C++, GCC, Intel...) and processors (Intel, ARM, ...), and if not, where to find the pieces to create one. Ideas?</p>
|
<p>You are asking about "application binary interface" (ABI) and calling conventions. These are typically set by operating systems and libraries, and enforced by compilers and linkers. Google for "ABI" or "calling convention." Some starting points from <a href="http://en.wikipedia.org/wiki/Calling_convention" rel="nofollow">Wikipedia</a> and <a href="http://wiki.debian.org/ArmEabiPort" rel="nofollow">Debian for ARM</a>.</p>
|
Tunneling proxy on VS 2008 <p>Is there a way to tunnel a proxy to access a remote sql server database on visual studio 2008?
I'm working in a project at college that uses a sql server database but the access is restricted to the internal network. I'd like to access the database from my home too.
Thanks in advance.</p>
|
<p>You can <a href="http://stackoverflow.com/questions/68799/setting-up-a-vpn">setup a VPN</a> easily...</p>
<p>Take a look to <a href="http://secure.logmein.com/products/hamachi/vpn.asp?lang=es" rel="nofollow">Hamachi</a> and <a href="http://www.remobo.com/" rel="nofollow">Rebombo</a>, very easy 0 configuration vpn...</p>
|
Fatal CLR Error 80004005 <p>Today, everytime I try to open any <strong>.Net application</strong> I get:</p>
<pre><code>CLR error: 80004005
The program will now terminate.
</code></pre>
<p>Any suggestions?</p>
|
<p>I'd start with <a href="http://msdn.microsoft.com/en-us/netframework/aa569263.aspx">downloading</a> and re-installing the .NET framework.</p>
|
Is there an easy way to plot Polyline Area, i.e. service coverage area, and also check to see if visitor's address lies within that area using Google Maps API and PHP? <p>I am the owner of a business that is building a new website application. My partner is the programmer who is doing the development and neither one of us has any real in-depth experience with Google Map API or it's polyline/polygon area capabilities.</p>
<p>We need an easy way to capture inputs within our user admin area where our locations can enter their service coverage area info i.e. 1st street north of Jones blvd, or a 5 mile radius from the location address, etc. and have the Google Map API plot the polyline borders.</p>
<p>Then, visitors to our site need to be able to see this info when they view the google map for one of our locations and also see if their service address falls within that service area or not. We then need to set a flag somehow to trigger a notification to the visitor that their address is not eligible for service or delivery.</p>
<p>If anyone can assist us with this (example php code to interface with the suggested APIs would be preferred and ideal as we simply don't understand the complexities of the Google API, the polyline coordinate capture tool, etc), it would be greatly appreciated, as we have struggled to figure out how to create this in php and more importantly how to integrate it into our existing site.</p>
<p>Thank you in advance for your replies and assistance.</p>
<p>Sincerely, </p>
<p>Larry D
Managing Director
SunMark Ventures</p>
<p>Update: Thank you for your answer CodeMeIT...how do recommend we capture these longlats in our sql database...i.e. what is the field format or type and do we need to have separate fields for long and lat, and how can we standardize for all locations, i.e. how many long and lats are needed to create a polygon area, as we want to be able to have our location managers input this info for their own locations from their user login areas...</p>
<p>Thank you in advance for your assistance...greatly appreciated!</p>
|
<p><strong>Draw polygon on map</strong></p>
<p>You can draw polygons that covering your service area on google map. Those polygons are defined by a set of latlongs that you can collect from a google earth and sasve them somewhere. Once you had all the coordinates that can cover your each service area, you can see the link to find out how to draw them on google map</p>
<p><a href="http://code.google.com/apis/maps/documentation/examples/polygon-simple.html" rel="nofollow">Google Map polygons Sample</a></p>
<p><strong>Check if user is within service area</strong></p>
<p>If the user had address information entered or stored somewhere, you can take the address to google map geocoding service to find out the address's latitude and longitude. </p>
<p><a href="http://code.google.com/apis/maps/documentation/services.html#Geocoding" rel="nofollow">Google MAP Geocoding Service API</a></p>
<p>After getting the address' coordinate, the code can check if the coordinateis within any bound of the polygons of your service area. If false, that is out of service area.</p>
<p><a href="http://www.assemblysys.com/dataServices/php_pointinpolygon.php" rel="nofollow">PHP for checking point in polygon</a></p>
|
NSString indexOf in Objective-C <p>Are there anything similar to an <code>indexOf</code> function in the NSString objects?</p>
|
<p>Use <code>-[NSString rangeOfString:]</code>:</p>
<pre><code>- (NSRange)rangeOfString:(NSString *)aString;
</code></pre>
<blockquote>
<p>Finds and returns the range of the first occurrence of a given string within the receiver.</p>
</blockquote>
|
Where to get more information on Dictionary ADT and Skip List for Java? <p>I'm trying to go deep into Dictionary ADT and Skip List for Java. My textbook doesn't cover a lot about this and whatever it has covered is very complicated. Which is the best online site to get more information on Dictionary ADT and Skip List for Java. I'm looking for the one which talks visually and gives a lot of examples.</p>
|
<p>Since it sounds like you're in an algorithms class, I would separate the implementation of a dictionary and a skip list from what is provided by the Java API. At this point, it's more important that you understand the concept of what these abstract data types are, because they can be implemented in any language (C#, PHP, Scheme, Brainfuck, etc.)</p>
<p>Your instructor will probably want you to: first, define the interface or contract for a dictionary (or a skip list), and then figure out its implementation. If you're programming in Java, use JUnit to verify the correctness of your algorithms. If you're programming in some other language, look for any xUnit API.</p>
<p>Look in <a href="http://www.nist.gov/dads/" rel="nofollow">NIST's Dictionary of Algorithms and Data Structures</a> as a secondary resource to your textbook to understand what these things mean. Probably the best algorithm book in Java is Sedgewick's, and its main distinctive is its pedagogical use of applets. Since the sample code is not written in idiomatic Java, I wouldn't look there for industrial-strength implementations of the algorithms. After all, you're supposed to do the work yourself, not use someone else's collections API.</p>
<p>Oh, btw, Java 6 has two implementations of skip lists: <code>ConcurrentSkipListSet</code> and <code>ConcurrentSkipListMap</code>. And the interface of a dictionary data structure in Java is <code>Map</code>.</p>
|
How to get rid of stupid "pad" labels produced by RTML functions? <p>I am unlucky to be in charge of maintaining some old Yahoo! Store built using their RTML-based platform.</p>
<p>Recently I've noticed that HTML code generated by some RTML functions is sprinkled all over with "padding images" (or whatever is the conventional name for those 1x1 pixel images used to enforce layout). I have nothing against using such images, but... all those images are supplied with an ALT attribute like this:</p>
<pre><code><img href="http://.../image1x1.gif" alt="pad">
</code></pre>
<p>With all due respect to the original authors of RTML, but they must have been smoking something when they came up with this "accessibility enhancement"... :-(</p>
<p>Anyway, here are my questions:</p>
<ol>
<li><p>Does anybody know a list of all RTML functions that generate HTML with all these "pad" images?</p></li>
<li><p>Is there any way to get rid of all those <strong>alt="pad"</strong> attributes without rewriting a lot of RTML code?</p></li>
</ol>
<p><strong>NB:</strong> This may sound a little cynical, but improved accessibility is not the main goal here. The main goal is to stop exposing those moronic <strong>alt="pad"</strong> attributes to Google and other smart search engines. So client-side scripting is not going to help, as far as I know.</p>
<p>Thank you!</p>
<hr>
<p>P.S. Probably, most of you are really lucky and never heard of RTML. Because if somebody would establish a prize for software products based on</p>
<pre><code>commercial success
------------------
usability
</code></pre>
<p>ratio, this RTML-based "platform" would probably win the first place.</p>
<hr>
<p><em>P.P.S. Apparently someone from Yahoo! finally listened, because I can no longer find those silly "pad" tags in the RTML generated for our store. Nevertheless, one of the ideas offered in response to my original question does provide a very practical solution - not just to the original problem but to any similar problem with RTML platform. See the winning answer - it's really good.</em></p>
|
<p>The only way I see is to have your own website front-end that will filter whatever you want from the RTML site....</p>
<p>for example, your rtml site is at <a href="http://rtmlusglysite.yahoo.com/store/XYZ01134" rel="nofollow">http://rtmlusglysite.yahoo.com/store/XYZ01134</a> , you could host a simple PHP front-end at http:://www.example.com that would be acting like a "filtering" HTTP web proxy, so <a href="http://rtmlusglysite.yahoo.com/store/XYZ01134/item1234.rtml" rel="nofollow">http://rtmlusglysite.yahoo.com/store/XYZ01134/item1234.rtml</a> would be accessed by <a href="http://www.example.com/item1234.html" rel="nofollow">http://www.example.com/item1234.html</a></p>
<p>It's not an ideal solution, but it should work, and you could do some more fancy stuff.</p>
|
What is a View in Oracle? <p>What is a view in Oracle?</p>
|
<p>A <strong>View in Oracle</strong> and in other database systems is simply the representation of a SQL statement that is stored in memory so that it can easily be re-used. For example, if we frequently issue the following query</p>
<pre><code>SELECT customerid, customername FROM customers WHERE countryid='US';
</code></pre>
<p>To create a view use the <strong>CREATE VIEW command</strong> as seen in this example</p>
<pre><code>CREATE VIEW view_uscustomers
AS
SELECT customerid, customername FROM customers WHERE countryid='US';
</code></pre>
<p>This command creates a new view called view_uscustomers. Note that this command does not result in anything being actually stored in the database at all except for a data dictionary entry that defines this view. This means that every time you query this view, Oracle has to go out and execute the view and query the database data. We can query the view like this:</p>
<pre><code>SELECT * FROM view_uscustomers WHERE customerid BETWEEN 100 AND 200;
</code></pre>
<p>And Oracle will transform the query into this:</p>
<pre><code>SELECT *
FROM (select customerid, customername from customers WHERE countryid='US')
WHERE customerid BETWEEN 100 AND 200
</code></pre>
<p><strong>Benefits of using Views</strong></p>
<ul>
<li>Commonality of code being used. Since a view is based on one common set of SQL, this means that when it is called itâs less likely to require parsing. </li>
<li>Security. Views have long been used to hide the tables that actually contain the data you are querying. Also, views can be used to restrict the columns that a given user has access to.</li>
<li><a href="http://www.devx.com/tips/Tip/34429">Predicate pushing</a></li>
</ul>
<p>You can find advanced topics in this article about "<a href="http://www.oracle-dba-online.com/sql/create_and_manage_views.htm">How to Create and Manage Views in Oracle</a>."</p>
|
JSTL forEach tag: problems with enumeration, and with understanding how it should work <p><br />
I've experienced rather strange behavior of JSTL forEach tag.</p>
<p>I have some bean called SessionBean:</p>
<pre><code>public class SessionBean {
private Collection<MyObject> objects;
public Collection<MyObject> getObjects() {return objects;}
...
}
</code></pre>
<p>And a simple JSP page like that:</p>
<pre><code><%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<f:view>
<h:form>
<c:forEach var="myObject" items="#{SessionBean.objects}">
<h:outputText value="#{myObject}" /> <br />
</c:forEach>
</h:form>
</f:view>
</body>
</code></pre>
<p>And, it doesn't work. Exeption thrown is</p>
<pre>
javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach>
at org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(ForEachSupport.java:255)
at org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator(ForEachSupport.java:219)
....
</pre>
<p><em>Why?</em><br />
And then I change <code>items="#{SessionBean.objects}"</code> to items=<code>"${SessionBean.objects}"</code>, and there's no exception. Except for MyObjects aren't printed.</p>
<p>Then, I make the same change to <code><h:outputText value="#{myObject}" /></code>, and it's invalid value for this attribute.</p>
<p>Finally, replacing JSF <code>outputText</code> tag with just <code>${myObject}</code> works as expected.</p>
<p>Could somebody explain, what happens here on each phase, please?</p>
<p><strong>U:</strong> SessionBean is managed by JSF, and surely was created, for it performs some actions in the header.</p>
<p><strong>RESOLUTION:</strong> The problem proved to be due to incompatibility between JSTL and JSF in J2EE 1.4. Switching to J2EE 5 made the first variant work just fine.</p>
<p>Thanks!</p>
|
<p>This <a href="http://today.java.net/pub/a/today/2006/03/07/unified-jsp-jsf-expression-language.html" rel="nofollow">article</a> explains the difference between the unified EL and the EL. Here is a snippet</p>
<blockquote>
<p>Evaluation of EL</p>
<p>Evaluation of EL is categorized as immediate evaluation and deferred evaluation. Immediate evaluation means a JSP page evaluates the expression when the page is rendered. With immediate evaluation, all values are always read-only. JSP EL expressions take the form of ${imExpr}. JSP expressions are evaluated immediately.</p>
<p>Deferred evaluation means that the technology using the unified EL takes over the responsibility of evaluating the expression from the JSP engine and evaluates the expression at the appropriate time during the page lifecycle. The EL takes control from the JSP container to evaluate the expression at the appropriate time. JSF EL expressions take the form of #{defExpr}. JSF expressions work in this way.</p>
<p>The following example shows a JSF inputText tag, which represents a text field component into which a user enters a value. The inputText tag's value attribute references an expression that points to the name property of the book bean.</p>
</blockquote>
<pre><code><h:inputText id="name" value="#{student.name}"/>
</code></pre>
<blockquote>
<p>For an initial request of the page containing this tag, the JSF implementation evaluates the #{student.name} expression during the "render response" phase of the lifecycle. During this phase, the expression merely accesses the value of quantity from the book bean, as is done in immediate evaluation.</p>
<p>For a postback, the implementation evaluates the expression during the "apply request values," "process validations," and "update model" phases, during which the value is retrieved from the request, validated, and propagated to the book bean.</p>
</blockquote>
<p>I am wondering if the problem is from the fact that an instance of SessionBean was not created?</p>
<p>Try this:</p>
<pre><code><jsp:useBean class="packagename.SessionBean" id="sb"/>
<c:forEach var="myObject" items="${sb.objects}">
<h:outputText value="${myObject}" /> <br />
</c:forEach>
</code></pre>
<p>[Update] I wonder if this <a href="http://java.sun.com/products/jsp/reference/techart/unifiedEL.html" rel="nofollow">article</a> might help then. It explains how the two EL's work together.</p>
|
How do I create an nullary Functor in C++ (using the loki library) <p>Writing something like this using the <a href="http://loki-lib.sourceforge.net/" rel="nofollow">loki library</a>,</p>
<pre><code>typedef Functor<void> BitButtonPushHandler;
</code></pre>
<p>throws a compiler error, but this works</p>
<pre><code>typedef Functor<void,TYPELIST_1(Matrix3D*)> Perspective;
</code></pre>
<blockquote>
<p>Functor.h:530: error: '((Loki::FunctorHandler, int><em>)this)->Loki::FunctorHandler, int>::f</em>' cannot be used as a function
Functor.h:530: error: return-statement with a value, in function returning 'void'</p>
</blockquote>
<p>Anyone familiar with this library know how to get the first line working?</p>
|
<p>Looking at the source code, the Functor template definition is as follows:</p>
<pre><code>template <typename R = void, class TList = NullType,
template<class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>
class Functor{...};
</code></pre>
<p>As commented below, there are no template typedefs allowed, so all types (or accept all defaults) need to be specified.</p>
<p>You can just define as follows and let the defaults do the work:</p>
<pre><code>typedef Functor<> BitButtonPushHandler;
</code></pre>
<p>This compiles for me with a small test Functor class (not the actual Loki one), and I can use the typedef successfully.</p>
|
What is a good design for an extensible query interface? <p>Our application exposes queries by way of web services, and what we've found is that our clients often want custom queries, either by way of further limiting the results returned by specifying additional criteria, or by asking for things that we don't already expose.</p>
<p>Now, we can take the approach of creating new methods for each of these new methods, but that's somewhat inconvenient; deployment of our application at a client site usually requires weeks of staged integration testing. We've proposed a named query mechanism, where the application administrator would define queries by name that are parameterized, and a corresponding web service that simply invokes these parameters. However, I can't help but think that someone has solved this problem before, so I'd like some input from the SO community on possible designs.</p>
<p>Thanks!</p>
<p><strong>Updates</strong></p>
<p>The specification pattern is a good one, but our application deals with enough data that we want to push as much of the querying work down into an RDBMS, which can do a better job of optimizing the query plan than we would ever want to. Moreover, we support three RDBMS backends, so we're stuck using a greatest-common-denominator approach: we use as much capability as the least functional database can provide.</p>
|
<p>I would also recommend to consider the "Specification Pattern" in this type of applications as a design decision for your backend. Check the following posts about "Specification Pattern":</p>
<p><a href="http://www.mattberther.com/2005/03/25/the-specification-pattern-a-primer/" rel="nofollow">http://www.mattberther.com/2005/03/25/the-specification-pattern-a-primer/</a></p>
<p><a href="http://devlicio.us/blogs/jeff_perrin/archive/2006/12/13/the-specification-pattern.aspx" rel="nofollow">http://devlicio.us/blogs/jeff_perrin/archive/2006/12/13/the-specification-pattern.aspx</a></p>
|
How do I get a particular word from a string in PHP? <p>Say you have a string, but you don't know what it contains. And you want to replace all occurences of a particular word or part of a word with a formatted version of the same word.
For example, I have a string that contains "lorem ipsum" and i want to replace the entire word that contains "lo" with "lorem can" so that the end result would be "lorem can ipsum"
but if I put the string "loreal ipsum" through the same function, the result would now be "loreal can ipsum".
Thanks</p>
|
<pre><code>$str = preg_replace('/(\blo[a-z]+\b)/', '$1 can', $str);
</code></pre>
<p>The problem with RoBorg's answer are:</p>
<ol>
<li><code>\w</code> matches digits and underscores, which aren't <em>really</em> word characters in human language, so it would match 'lo_fi' or '__lo__'.</li>
<li>it would also match words that don't begin with <code>lo</code>, such as 'slorem', or even words that end in <code>lo</code> such as 'allo'.</li>
</ol>
<p><code>\b</code> makes sure <code>lo</code> follows a word-break (zero-width) and <code>[a-z]+</code> ensures that at least one alphabetical character follows 'lo'.</p>
<p>Edit: I see the text of the question says "contains" rather than "begins with", in which case, the first <code>\b</code> may be omitted.</p>
<p>Edit 2: Note that neither of these solutions are international-safe. I haven't tested this, but PHP's RegEx is pretty capable so I'm guessing it'll work:</p>
<pre><code>$str = preg_replace('/(\blo[a-z\p{L}]+\b)/', '$1 can', $str);
</code></pre>
|
How can I get the TNMHTTP Get method to respond on a redirect <p>I'm using TNMHTTP in Delphi to retrieve the code from a webpage. The code is relatively simple:</p>
<pre><code>NMHTTP1 := TNMHTTP.Create(Self);
NMHTTP1.InputFileMode := FALSE;
NMHTTP1.OutputFileMode := FALSE;
NMHTTP1.ReportLevel := Status_Basic;
NMHTTP1.TimeOut := 3000;
URL := 'http://www....';
NMHTTP1.Get(URL);
S := NMHTTP1.Body;
</code></pre>
<p>I am catching exceptions in a try/except block, but that is not the problem.</p>
<p>The problem is that on executing the NMHTTP1.Get method when the URL is a redirect, that method does not return and the program hangs. This is despite the fact that I've put a timeout of 3000 seconds in.</p>
<p>So I see three possible ways of solving this (in order of easiest to hardest for me to modify my program): </p>
<ol>
<li><p>Do whatever is necessary to get the NMHTTP1.Get method to respond.</p></li>
<li><p>Do some sort of check in advance of the NMHTTP1.Get statement to see if the URL is a redirect and get the URL it is redirecting to.</p></li>
<li><p>Use another method to get a webpage using Delphi. When I wrote this, I used Delphi 4 and did not have Indy. I now have Delphi 2009, so I would be willing to use something that works in it (maybe INDY) if a simple #1 or #2 answer is not available.</p></li>
</ol>
<p>I would love to get an answer from someone that will work for me. Thanks in advance.</p>
|
<p>I can advice you to switch to Indy. They are great for a lot of network protocols (with the exception of the IRC protocol). There are nice examples included so you can examine the working examples yourself.</p>
<p>Also have a look at <a href="http://www.indyproject.org/index.en.aspx" rel="nofollow">http://www.indyproject.org/index.en.aspx</a> for more information on indy.</p>
|
Change journal operations in .NET? <p>I'm looking for the .NET/C# way of performing <a href="http://msdn.microsoft.com/en-us/library/aa363801%28VS.85%29.aspx">Change Journal Operations</a> (without importing unmanaged code).</p>
<p>Any hints or RTFM-links?</p>
|
<p>This looks promising (and in C#):</p>
<p><a href="http://mchangejournal.codeplex.com/" rel="nofollow">http://mchangejournal.codeplex.com/</a></p>
<p>You have to download the Source code as there are no official Releases. I was able to run the demo (on Windows 7), but not able to see which Files were changed. This library may still be in its infancy.</p>
|
MySQL: get differences of each sorted column in set of rows <p>Here is a simple scenario with table characters:</p>
<pre><code>CharacterName GameTime Gold Live
Foo 10 100 3
Foo 20 100 2
Foo 30 95 2
</code></pre>
<p>How do I get this output for the query <code>SELECT Gold, Live FROM characters WHERE name = 'Foo' ORDER BY GameTime</code>:</p>
<pre><code>Gold Live
100 3
0 -1
-5 0
</code></pre>
<p>using MySQL stored procedure (or query) if it's even possible? I thought of using 2 arrays like how one would normally do in a server-side language, but MySQL doesn't have array types.</p>
<p>While I'm aware it's probably easier to do in PHP (my server-side langauge), I want to know if it's possible to do in MySQL, just as a learning material.</p>
|
<p>Do you have an ID on your Table.</p>
<pre><code>GameID CharacterName GameTime Gold Live
----------- ------------- ----------- ----------- -----------
1 Foo 10 100 3
2 Foo 20 100 2
3 Foo 30 95 2
</code></pre>
<p>If so you could do a staggered join onto itself</p>
<pre><code>SELECT
c.CharacterName,
CASE WHEN c_offset.Gold IS NOT NULL THEN c.Gold - c_offset.Gold ELSE c.Gold END AS Gold,
CASE WHEN c_offset.Live IS NOT NULL THEN c.Live - c_offset.Live ELSE c.Live END AS Live
FROM Characters c
LEFT OUTER JOIN Characters c_offset
ON c.GameID - 1 = c_offSet.GameID
ORDER BY
c.GameTime
</code></pre>
<p>Essentially it joins each game row to the previous game row and does a diff between the values. That returns the following for me.</p>
<pre><code>CharacterName Gold Live
------------- ----------- -----------
Foo 100 3
Foo 0 -1
Foo -5 0
</code></pre>
|
Why does adding a project reference break my build? <h2>solution structure [Plain Winforms + VS 2008 Express Edition]</h2>
<ul>
<li>CoffeeMakerInterface (NS CoffeeMaker)</li>
<li>CoffeeMakerSoftware (NS CoffeeMakerSoftware)</li>
<li>TestCoffeeMaker (NS TestCoffeeMaker)</li>
</ul>
<p>CoffeeMakerSoftware proj references CoffeeMakerInterface.
TestCoffeeMaker proj references CoffeeMakerInterface and CoffeeMakerSoftware.</p>
<p>Now the thing that is driving me nuts. I can't get this to build. <strong>If I remove CoffeeMakerSoftware project reference from TestCoffeeMaker it builds (??!!).. as soon as I add the second project reference, it throws build errors</strong> claiming that types declared in first reference 'can't be found.. are you missing an assembly ref'</p>
<p>At first I had the first 2 assemblies having the same namespace CoffeeMaker.. I then made them distinct (although I think having classes belonging to the same NS across assemblies should be possible) but even that doesn't seem to be it.</p>
<p>Calling more eyeballs. Any pointers.. </p>
|
<p>I broke my 'Don't code when you're tired' dictum. I zipped it up, went to sleep and looked at it today.. found the issue by looking at the output window. <em>(FWIW everything was CopyLocal=True and nothing in GAC. This is Bob Martin's OOD problem from the Agile PPnP book.. coming up with good names was particularly hard)</em></p>
<pre><code>1. CoffeeMaker > CoffeeMakerInterfaces
2. [X] > CoffeeMaker > CoffeeMakerSoftware
3. [X] > TestCoffeeMaker
</code></pre>
<p>That's how I added and renamed the projects in chronological order. Apparently renaming the Assembly via solution explorer, doesn't change the name of the produced binary or throw up a warning. As a result, #1 and #2 both were producing CoffeeMaker.dll as the output.
Adding Reference#2 to the TestCoffeeMaker rendered all the types defined in reference#1 as unknown with the ever popular </p>
<blockquote>
<p>"Error 2 The type or namespace name
'CoffeeMaker' could not be found (are
you missing a using directive or an
assembly reference?) C:\Documents and
Settings\pillaigi\Desktop\CoffeeMaker\TestCoffeeMaker\FakeCoffeeMakerDevice.cs 4 7 TestCoffeeMaker"</p>
</blockquote>
<p><strong>Solution: Open Project properties and examine if the "Assembly name:" in project properties for each (ref or otherwise) project is unique and doesn't clash.</strong></p>
<p>Maybe not enough people do this.. the IDE or compiler could easily catch this one 'If referenced assemblies have the same binary name... please fix it.. you will anyway'
I've done this to myself once before.. Making a BIG note to myself this time. Now excuse me while I wear my Dunce cap and sit in the corner. </p>
|
What is the simplest jQuery way to have a 'position:fixed' (always at top) div? <p>I'm relatively new to jQuery, but so far what I've seen I like. What I want is for a div (or any element) to be across the top of the page as if "position: fixed" worked in every browser.</p>
<p>I do not want something complicated. I do not want giant CSS hacks. I would prefer if just using jQuery (version 1.2.6) is good enough, but if I need jQuery-UI-core, then that's fine too.</p>
<p>I've tried $("#topBar").scrollFollow(); <-- but that goes slow... I want something to appear really fixed.</p>
|
<p>Using this HTML:</p>
<pre><code><div id="myElement" style="position: absolute">This stays at the top</div>
</code></pre>
<p>This is the javascript you want to use. It attaches an event to the window's scroll and moves the element down as far as you've scrolled.</p>
<pre><code>$(window).scroll(function() {
$('#myElement').css('top', $(this).scrollTop() + "px");
});
</code></pre>
<hr>
<p>As pointed out in the comments below, it's not recommended to attach events to the scroll event - as the user scrolls, it fires A LOT, and can cause performance issues. Consider using it with Ben Alman's <a href="http://benalman.com/projects/jquery-throttle-debounce-plugin/">debounce/throttle</a> plugin to reduce overhead.</p>
|
form layout with CSS <p>I need to create a form with, half linear view (textboxes and dropdownlists in separate line) and the other half, non linear view i.e. the textboxes will appear next to each other, like first name and last name will be next to each other. </p>
<p>I am aware how to acomplish the linear view with CSS. I am using</p>
<pre><code>fieldset {
clear: both;
font-size: 100%;
border-color: #000000;
border-width: 1px 0 0 0;
border-style: solid none none none;
padding: 10px;
margin: 0 0 0 0;
}
label
{
float: left;
width: 10em;
text-align:right;
}
</code></pre>
<p>How can I get the non-linear view?</p>
|
<p>if you also float:left, set a width and display:inline the other input fields, the should appear on the same line</p>
|
NSData and UIImage <p>I am trying to load <code>UIImage</code> object from <code>NSData</code>, and the sample code was to <code>NSImage</code>, I guess they should be the same. But just now loading the image, I am wondering what's the best to troubleshoot the <code>UIImage</code> loading <code>NSData</code> issue.</p>
|
<p>I didn't try <code>UIImageJPEGRepresentation()</code> before, but <code>UIImagePNGRepresentation</code> works fine for me, and conversion between <code>NSData</code> and <code>UIImage</code> is dead simple:</p>
<pre><code>NSData *imageData = UIImagePNGRepresentation(image);
UIImage *image=[UIImage imageWithData:imageData];
</code></pre>
|
php/Ajax - Best practice for pre-loading images <p>I have put together a script which is very much like the flickr photostream feature. Two thumbnails next to each other, and when you click the next or prev links the next (or previous) two images slide in. Cool!</p>
<p>Currently when the page loads it loads the two images. The first time nxt / prv is used then the next two images or previous two are loaded via ajax, with the id of the first image being passed in the url and the HTML for the two new images returned and displayed via ajax.</p>
<p>simple enough, but it got me to thinking, on a slow connection, or heavy server load then the two images, although relatively small thumbnails could still take a while to load, and the nice things with sliding panes is the fact that the hidden data slides in quickly and smoothly preferbly without a loading delay.</p>
<p>So I was wondering from a performance and good practice point of view which option is best, this is what I can think of for now, open to suggestions.</p>
<p>1, call each set of images via JSON (its supposed to be fast?) </p>
<p>2,load all the possible images into a json file and pull in the details that way - although browser will still have to load image. Plus sometimes there might be 4 images, other times there could be upto 1000!</p>
<p>3, Load 10 images via php into a Json or other file, and load all 10 images into the browser hiding the 8 which are not on show, and always showing the middle two. Problem here is that each time someone clicks, the file has to reload the first and last images, which still takes up time, although i suppose the middle images will have all been cached via the browser by now though. But still there is a loading time.</p>
<p>4, Is it possible to have a json image with all the image details (regardless of numbers) and use no 3 above to load 10 of those images, is it possible to use ajax to only read 10 lines and keep a pointer of the last one it read, so the json file can be loaded fast, short refresh and images either side are cached via the browser!!</p>
<p>Hope thats clear, any suggestions on how you would handle this?</p>
|
<p>To preload an image from Javascript, you don't need to do anything that sounds like AJAX or JSON. All you need is this:</p>
<pre><code>var img = new Image();
img.src = "http://example.com/new/image.jpg";
</code></pre>
<p>The browser will quite happily load the image in the background, even though it's not displayed anywhere. Then, when you update the <code>src</code> field of another (displayed) image tag, the browser will immediately show the part of the image it's already loaded (hopefully all of it).</p>
|
SharePoint Visual Studio document upload Web Test fails with Connot close stream until all bytes are written <p>I have created a Visual Studio 2008 sp1 test suite web test that uploads a document to a document library in SharePoint. The test is a lot like the one described <a href="http://www.helloitsliam.com/Lists/Posts/Post.aspx?ID=139" rel="nofollow">here</a>.</p>
<p>All is fine until the test is converted to a coded web test. Then the upload post returns the response </p>
<p>"Request failed: Connot close stream until all bytes are written"</p>
<p>Any ideas on how to get it going?</p>
|
<p>You can also use the Deployment settings in the testrunconfig. It's more sophisticated.</p>
|
Python vs Groovy vs Ruby? (based on criteria listed in question) <p>Considering the criteria listed below, which of Python, Groovy or Ruby would you use?</p>
<ul>
<li><em>Criteria (Importance out of 10, 10 being most important)</em></li>
<li>Richness of API/libraries available (eg. maths, plotting, networking) (9)</li>
<li>Ability to embed in desktop (java/c++) applications (8)</li>
<li>Ease of deployment (8)</li>
<li>Ability to interface with DLLs/Shared Libraries (7)</li>
<li>Ability to generate GUIs (7)</li>
<li>Community/User support (6)</li>
<li>Portability (6)</li>
<li>Database manipulation (3)</li>
<li>Language/Semantics (2)</li>
</ul>
|
<p>I think it's going to be difficult to get an objective comparison. I personally prefer Python. To address one of your criteria, Python was designed from the start to be an embeddable language. It has a very rich C API, and the interpreter is modularized to make it easy to call from C. If Java is your host environment, you should look at Jython, an implementation of Python inside the Java environment (VM and libs).</p>
|
How do you access an attached property of a Silverlight object in C#? <p>Basically I'm trying to change the <code>Canvas.Left</code> property of an Ellipse Silverlight control in C#. Here is how I'm accessing the control:</p>
<pre><code>Ellipse c1 = this.FindName("Circle1") as Ellipse;
</code></pre>
<p>How would I then set the <code>Canvas.Left</code> property?</p>
<p>Thanks,</p>
<p>Jeff</p>
|
<p>The answer lies in Silverlights use of Dependancy Properties</p>
<p>c1.SetValue(Canvas.LeftProperty, value);</p>
|
Is it possible to perform arbitrary data analysis in Erlang? <p>I want to answer questions about data in Erlang: count things, correlate messages, provide arbitrary statistics. I had thought about resorting to Hadoop for this but is it possible to build a solution in raw Erlang to do rather arbitrary data analysis not necessarily via map/reduce but somehow? I have seen some hints of people doing this but no explicit blog posts or examples of this being done. I know that Powerset's natural language capabilities are written in Erlang. I also know about CouchDB but was looking for some other solutions.</p>
|
<p>Yes.</p>
<p>For general-purpose computation and statistics, Erlang works just fine. It isn't optimized heavily for such work, so it will have trouble keeping up with similar numeric code in, say MatLab, ForTran, or any of the major C package for this work -- but for most uses it will do just fine. And of course if your code parallelizes neatly and you have multiple CPUs available, Erlang will catch up more easily.</p>
<p>(You also mentioned the map/reduce pattern; it is relatively trivial given the Erlang/OTP runtime and libraries.)</p>
<p>I and my colleagues have written plenty of "raw" Erlang to do counting, statistics, and so on. We have found it to be more than sufficient for most tasks.</p>
|
.NET training suggestion for an average developer <p>Some devs in our office need training. They're working on .NET projects and just aren't picking it up very well. (Their backgrounds are in VB6. Yes. In 2008. Go figure.) I've been to a couple training courses in the past, and they've fortunately been very good. It seems like if you have a good instructor (early DevelopMentor .NET course and Ted Pattison's SharePoint course were great) and you're actively enthusiastic about the subject matter, you can get a LOT out of a good week-long course. My question is whether it's worthwhile for someone who simply might not really care all that much -- an "average" dev. Are they likely to learn enough (or even to magically become inspired) to make the investment worth it for the company?</p>
<p>If so, which general .NET courses with a C# focus would you recommend? I always wanted to try JP Boodhoo's course for no other reason than that he is so darn efficient in Visual Studio/Resharper... and his TDD approach, of course.</p>
|
<p>I'd say that things like DevelopMentor are fine. Re your distinction between the "enthusiastic" versus "average" developer... in many ways the "enthusiastic" developer can accomplish nearly as much from blogs/trying-it/books/RTFM. So in many ways courses are <em>more</em> useful for the (in your words) "average" developer who needs to be taken away from things to focus on it.</p>
|
"Functionoids"? <p>I've read the description of "functionoids" <a href="http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.10" rel="nofollow">here</a>. They look like a poor-man's version of Boost::function and Boost::bind. Am I missing something? Is there a good reason to use them if you're already using Boost?</p>
|
<p>My vote goes to tr1::function. </p>
<p><em>Functors</em> or <em>functionoids</em> represent the base from which <code>tr1/boost::function</code> has evolved. The limit with common-interface functors is that they break the OO-paradigm since they represent different types and can only passed to template functions (unless you provide a base class from which they derive from).</p>
<p>Indeed by means of the <em><a href="http://www.artima.com/cppsource/type_erasure2.html" rel="nofollow">type erasure technique</a></em> <code>tr1::function</code> overcomes this limit: They are best used to implement dynamic <em>strategy classes</em>.</p>
|
How to convert CString and ::std::string ::std::wstring to each other? <p><code>CString</code> is quite handy, while <code>std::string</code> is more compatible with STL container.
I am using <code>hash_map</code>. However, <code>hash_map</code> does not support <code>CString</code> as key, so I want to convert <code>CString</code> into <code>std::string</code>.</p>
<p>Writing a <code>CString</code> hash function seems to take a lot of time.</p>
<pre><code>CString -----> std::string
</code></pre>
<p>How can I do this?</p>
<pre><code>std::string -----> CString:
inline CString toCString(std::string const& str)
{
return CString(str.c_str());
}
</code></pre>
<p>Am I right?</p>
<hr>
<p><strong>EDIT:</strong></p>
<p>Here are more questions:</p>
<p>How can I convert <code>wstring</code>, <code>CString</code> to each other?</p>
<pre><code>//wstring -> CString,
std::wstring src;
CString result(src.c_str());
//CString->wstring.
CString src;
::std::wstring des(src.GetString());
</code></pre>
<p>Is there <strong>any</strong> problem?</p>
<p>How can I convert <code>std::wstring</code>, <code>std::string</code> to each other?</p>
|
<p>According to <a href="http://www.codeguru.com/forum/archive/index.php/t-231155.html">CodeGuru</a>:</p>
<p><code>CString</code> to <code>std::string</code>:</p>
<pre><code>CString cs("Hello");
std::string s((LPCTSTR)cs);
</code></pre>
<p><strong>BUT:</strong> <code>std::string</code> cannot always construct from a <code>LPCTSTR</code>. i.e. the code will fail for UNICODE builds.</p>
<p>As <code>std::string</code> can construct only from <code>LPSTR</code> / <code>LPCSTR</code>, a programmer who uses VC++ 7.x or better can utilize conversion classes such as <code>CT2CA</code> as an intermediary.</p>
<pre><code>CString cs ("Hello");
// Convert a TCHAR string to a LPCSTR
CT2CA pszConvertedAnsiString (cs);
// construct a std::string using the LPCSTR input
std::string strStd (pszConvertedAnsiString);
</code></pre>
<p><a href="http://cstrings.blogspot.com/2006/08/how-to-convert-from-stdstring-to.html"><code>std::string</code> to <code>CString</code></a>: (From <a href="http://cstrings.blogspot.com/2006/08/how-to-convert-from-stdstring-to.html">Visual Studio's CString FAQs...</a>)</p>
<pre><code>std::string s("Hello");
CString cs(s.c_str());
</code></pre>
<p><code>CStringT</code> can construct from both character or wide-character strings. i.e. It can convert from <code>char*</code> (i.e. <code>LPSTR</code>) or from <code>wchar_t*</code> (<code>LPWSTR</code>).</p>
<p>In other words, char-specialization (of <code>CStringT</code>) i.e. <code>CStringA</code>, <code>wchar_t</code>-specilization <code>CStringW</code>, and <code>TCHAR</code>-specialization <code>CString</code> can be constructed from either <code>char</code> or wide-character, <del>null terminated (null-termination is very important here)</del> string sources.<br>
Althoug <a href="http://stackoverflow.com/users/1889329/iinspectable">IInspectable</a> amends the "null-termination" part <a href="http://stackoverflow.com/questions/258050/how-to-convert-cstring-and-stdstring-stdwstring-to-each-other/258052?noredirect=1#comment29168168_258052">in the comments</a>:</p>
<blockquote>
<p><strong>NUL-termination is not required</strong>.<br>
<code>CStringT</code> has conversion constructors that take an explicit length argument. This also means that you can construct <code>CStringT</code> objects from <code>std::string</code> objects with embedded <code>NUL</code> characters.</p>
</blockquote>
|
What is the memory consumption of an object in Java? <p>Is the memory space consumed by one object with 100 attributes the same as that of 100 objects, with one attribute each?</p>
<p>How much memory is allocated for an object?<br />
How much additional space is used when adding an attribute?</p>
|
<p><a href="http://mindprod.com/jgloss/sizeof.html">Mindprod</a> points out that this is not a straightforward question to answer:</p>
<blockquote>
<p>A JVM is free to store data any way it pleases internally, big or little endian, with any amount of padding or overhead, though primitives must behave as if they had the official sizes.<br>
For example, the JVM or native compiler might decide to store a <code>boolean[]</code> in 64-bit long chunks like a <code>BitSet</code>. It does not have to tell you, so long as the program gives the same answers.</p>
<ul>
<li>It might allocate some temporary Objects on the stack. </li>
<li>It may optimize some variables or method calls totally out of existence replacing them with constants. </li>
<li>It might version methods or loops, i.e. compile two versions of a method, each optimized for a certain situation, then decide up front which one to call. </li>
</ul>
<p>Then of course the hardware and OS have multilayer caches, on chip-cache, SRAM cache, DRAM cache, ordinary RAM working set and backing store on disk. Your data may be duplicated at every cache level. All this complexity means you can only very roughly predict RAM consumption. </p>
</blockquote>
<h2>Measurement methods</h2>
<p>You can use <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html#getObjectSize-java.lang.Object-"><code>Instrumentation.getObjectSize()</code></a> to obtain an estimate of the storage consumed by an object.</p>
<p>To visualize the <em>actual</em> object layout, footprint, and references, you can use the <a href="http://openjdk.java.net/projects/code-tools/jol/">JOL (Java Object Layout) tool</a>.</p>
<h2>Object headers and Object references</h2>
<p>In a modern 64-bit JDK, an object has a 12-byte header, padded to a multiple of 8 bytes, so the minimum object size is 16 bytes. For 32-bit JVMs, the overhead is 8 bytes, padded to a multiple of 4 bytes. <em>(From <a href="http://stackoverflow.com/a/32224498/6309">Dmitry Spikhalskiy's answer</a>, <a href="http://stackoverflow.com/a/35407947/6309">Jayen's answer</a>, and <a href="http://www.javaworld.com/javaworld/javatips/jw-javatip130.html">JavaWorld</a>.)</em></p>
<p>Typically, references are 4 bytes on 32bit platforms or on 64bit platforms up to <code>-Xmx32G</code>; and 8 bytes above 32Gb (<code>-Xmx32G</code>). <em>(See <a href="http://www.lowtek.ca/roo/2008/java-performance-in-64bit-land/">compressed object references</a>.)</em></p>
<p>As a result, a 64-bit JVM would typically require 30-50% more heap space. <em>(<a href="http://www.javacodegeeks.com/2012/12/should-i-use-a-32-or-a-64-bit-jvm.html">Should I use a 32- or a 64-bit JVM?</a>, 2012, JDK 1.7)</em></p>
<h2>Boxed types, arrays, and strings</h2>
<p>Boxed wrappers have overhead compared to primitive types (from <a href="http://www.javaworld.com/javaworld/javatips/jw-javatip130.html">JavaWorld</a>):</p>
<blockquote>
<ul>
<li><p><strong><code>Integer</code></strong>: The 16-byte result is a little worse than I expected because an <code>int</code> value can fit into just 4 extra bytes. Using an <code>Integer</code> costs me a 300 percent memory overhead compared to when I can store the value as a primitive type</p></li>
<li><p><strong><code>Long</code></strong>: 16 bytes also: Clearly, actual object size on the heap is subject to low-level memory alignment done by a particular JVM implementation for a particular CPU type. It looks like a <code>Long</code> is 8 bytes of Object overhead, plus 8 bytes more for the actual long value. In contrast, <code>Integer</code> had an unused 4-byte hole, most likely because the JVM I use forces object alignment on an 8-byte word boundary. </p></li>
</ul>
</blockquote>
<p>Other containers are costly too:</p>
<blockquote>
<ul>
<li><p><strong>Multidimensional arrays</strong>: it offers another surprise.<br>
Developers commonly employ constructs like <code>int[dim1][dim2]</code> in numerical and scientific computing.</p>
<p>In an <code>int[dim1][dim2]</code> array instance, every nested <code>int[dim2]</code> array is an <code>Object</code> in its own right. Each adds the usual 16-byte array overhead. When I don't need a triangular or ragged array, that represents pure overhead. The impact grows when array dimensions greatly differ.</p>
<p>For example, a <code>int[128][2]</code> instance takes 3,600 bytes. Compared to the 1,040 bytes an <code>int[256]</code> instance uses (which has the same capacity), 3,600 bytes represent a 246 percent overhead. In the extreme case of <code>byte[256][1]</code>, the overhead factor is almost 19! Compare that to the C/C++ situation in which the same syntax does not add any storage overhead. </p></li>
<li><p><strong><code>String</code></strong>: a <code>String</code>'s memory growth tracks its internal char array's growth. However, the <code>String</code> class adds another 24 bytes of overhead.</p>
<p>For a nonempty <code>String</code> of size 10 characters or less, the added overhead cost relative to useful payload (2 bytes for each char plus 4 bytes for the length), ranges from 100 to 400 percent. </p></li>
</ul>
</blockquote>
<h2>Alignment</h2>
<p>Consider this <a href="https://plumbr.eu/blog/memory-leaks/how-much-memory-do-i-need-part-2-what-is-shallow-heap">example object</a>:</p>
<pre><code>class X { // 8 bytes for reference to the class definition
int a; // 4 bytes
byte b; // 1 byte
Integer c = new Integer(); // 4 bytes for a reference
}
</code></pre>
<p>A naïve sum would suggest that an instance of <code>X</code> would use 17 bytes. However, due to alignment (also called padding), the JVM allocates the memory in multiples of 8 bytes, so instead of 17 bytes it would allocate 24 bytes.</p>
|
Sqlite Optimization: Read only scenario <p>I use SQLite for a number of application on the desktop and PDA. Most operations are readonly, as SQLite functions as a data store for reference material in my applications.</p>
<p>Basically, I am looking for suggestions on improving performance in a scenario where you know the access to the data is only read-only.</p>
<p>Maybe via various pragma settings? etc...</p>
<p>SQLite performance is excellent, however on the PDA when you have multiple databases I can see a small performance hit. I dont think this is a problem with SQLite, just the reality of the speed of a PDA. However, having said that, maybe there are ways to improve it.</p>
<hr>
<p>Good advice and well put. I am hoping for something more specific in telling the engine about what I am doing. For example, telling the engine there will be no multiple writes to the DB, or modifying the cache handling in some way.</p>
<p>However, I am glad you called attention to the "design" aspect of the database as a leading issue.</p>
|
<p>The standard database performance tips still apply:</p>
<ul>
<li>Make sure your queries use indexes rather than full table scans</li>
<li>Be as selective as you can in your queries so you aren't pulling unneeded rows from the db</li>
<li>Select only the columns you want</li>
</ul>
|
Ribbon UI for Visual Studio 2010 or beyond? <p>One of the PDC2008 presentations showed off the new VS2010 UI (not the same as the current beta) that was built with WPF. Some of the new code effects looked fairly nice (comment xml parsed and styled within the code editor).</p>
<p>It got me wondering if Microsoft would ever change the VS UI to the Ribbon; like Office, the change could possibly be forced with no 'classic' mode.</p>
<p>Would you embrace such a change?</p>
<p>From what I gather</p>
<p>Advanced programmers: minor change, hot keys are the same.</p>
<p>Intermediate/Beginner programmers: considerable change, every button has moved!</p>
<p>New programmers: Context sensitive ribbons help emphasize what they may do and where.</p>
|
<p>It all depends on how it would be implemented.<br>It could be a good thing, but just in case I would like it to be optional:)</p>
|
Better way to implement an Html Helper method? <p>I created an html helper </p>
<pre><code>Html.BreadCrumb(IDictionary<string, string> crumbs)
</code></pre>
<p>Where the first string is the label and the second string is the URL.
The helper creates the html required (an unordered list, some classes for first element, current element, last element, dead element and separators etc)
All working nice, but I do this by creating a stringbuilder, pumping all the html in it and returning the stringbuilder's content as a string.</p>
<p>I figure in this example it doesn't matter all that much, but what if an Html helper is churning out a big load of html? Isn't there a way to push it to Response.Write instead of a stringbuilder?</p>
<p>Or any other issues/improvements you have?</p>
|
<p>BTW we have a naming pattern in ASP.NET MVC for the various rendering techniques.</p>
<p>Helpers that return a string of what they are should be named what they are. For example, Url.Action() and Html.TextBox() return those exact items. Thus, these helpers should be used with the <%= %> syntax.</p>
<p>Helpers that render directly to the output stream should start with Render. For example, Html.RenderPartial(). These are used with the <% %> syntax.</p>
<p>Helpers that use the IDisposable pattern should be named with Begin/End. For example, Html.BeginForm() and Html.EndForm(). These should also be used with the <% %> syntax.</p>
<p>Thanks,
Eilon</p>
|
How to get On Focus CWindow handle? <p>Is there any way to get the handle to the control that has focus?
I am looking for a way to get the ID of control on focus in my app. </p>
<p>After that it would be easy to get the id with GetDlgCtrlID.</p>
<pre><code>CWnd *pwnd = GetWindowOnFocus();
int wID = pwnd->GetDlgCtrlID();
</code></pre>
<p>It's the GetWindowOnFocus part that I am missing!</p>
|
<p>Have a look at the static <a href="http://msdn.microsoft.com/en-us/library/f9fd0z3x(VS.80).aspx" rel="nofollow">CWnd::GetFocus</a> method.</p>
|
Python filter/remove URLs from a list <p>I have a text file of URLs, about 14000. Below is a couple of examples:</p>
<p><a href="http://www.domainname.com/pagename?CONTENT_ITEM_ID=100&param2=123" rel="nofollow">http://www.domainname.com/pagename?CONTENT_ITEM_ID=100&param2=123</a><br />
<a href="http://www.domainname.com/images?IMAGE_ID=10" rel="nofollow">http://www.domainname.com/images?IMAGE_ID=10</a><br />
<a href="http://www.domainname.com/pagename?CONTENT_ITEM_ID=101&param2=123" rel="nofollow">http://www.domainname.com/pagename?CONTENT_ITEM_ID=101&param2=123</a><br />
<a href="http://www.domainname.com/images?IMAGE_ID=11" rel="nofollow">http://www.domainname.com/images?IMAGE_ID=11</a><br />
<a href="http://www.domainname.com/pagename?CONTENT_ITEM_ID=102&param2=123" rel="nofollow">http://www.domainname.com/pagename?CONTENT_ITEM_ID=102&param2=123</a><br /></p>
<p>I have loaded the text file into a Python list and I am trying to get all the URLs with CONTENT_ITEM_ID separated off into a list of their own. What would be the best way to do this in Python?</p>
<p>Cheers</p>
|
<p>Here's another alternative to Graeme's, using the newer list comprehension syntax:</p>
<pre><code>list2= [line for line in file if 'CONTENT_ITEM_ID' in line]
</code></pre>
<p>Which you prefer is a matter of taste!</p>
|
Browser back button - does it delete session data? <p>Does hitting the back button in a web browser cause the session data set in the preceding call to be deleted?</p>
|
<p>No, it does not.</p>
<p>Well, if the user arrived to the previous page by POST (as opposed to GET) and reposts the page, the server is going to process the request again. It won't delete the data in the session though. It is possible to achieve this behaviour with some code, but that's not how it works by default.</p>
|
Can you get SkinID Autocompletion in ASCX Controls <p>Working in VS 2008</p>
<p>When working on on ASPX file in <code>Source</code> mode, if i've specified a StyleSheetTheme in the page directive of the file, then Visual Studio will provide me with AutoCompletion lists of the possible skinID values for a control </p>
<p>e.g.</p>
<pre><code><asp:Button ID="myButton" runat="server" SkinID="
//Having typed this much, I'll get an intellisense with the possible skinid values for this button
</code></pre>
<p>I'm just wondering is it possible to get the same functionality in an ASCX.
Because theres no stylesheettheme specified for the control, VS doesn't know what the possible values are... </p>
<p><strong>Can you specify a default stylesheet theme that Visual Studio can use for Web User Controls.</strong></p>
|
<p>Yes you can. If you specify a default theme in your web.config, then the available skins will also be listed by intellsense in user controls.</p>
<p>To define a default theme, edit the following entry in web.config:</p>
<pre><code>...
<system.web>
...
<pages styleSheetTheme="MyTheme">
...
</code></pre>
<p>This works for both Themes and StyleSheetThemes. But it may take some time (or a rebuild?) until the available skins are listed by intellisense.</p>
<p>BTW: specifying the theme to be used in web.config (instead of in the pages) has the additional advantage, that you can very easily switch themes.</p>
|
ASP.NET Web site/service hosting <p>Are there other possibilities besides IIS for hosting web sites and web services based on ASP.NET, which are recommended by Microsoft for small-scale environments?</p>
|
<p>You can host your own web server in-process within your own application using <a href="http://blogs.msdn.com/carlosag/archive/2008/04/14/HostYourOwnWebServerUsingIIS7.aspx">IIS 7's Hostable Web Core.</a> And, of course, you can create your own app that listens to port 80. However, the complexities involved probably doesn't make it worth while.</p>
|
How do I import svn branches rooted in different directories into git using git-svn? <p>I have an SVN repository structure like below. We are using multiple levels under branches for various release maintenance branches, plus a directory for feature branches.</p>
<p>git-svn init seems to work with a single --branches argument, i.e. it seems to expect all of the branches to be in a single location.</p>
<pre><code>trunk
branches
1.1
1.2.1
1.2.2
1.2
1.2.1
1.2.2
1.2.3
features
feature1
feature2
</code></pre>
<p>Any ideas on how to handle this?</p>
<p>Thanks</p>
|
<p>In your config file, set the svn-remotes section to something like:</p>
<pre><code>[svn-remote "svn"]
url = svn://svnserver/repo
fetch = trunk:refs/remotes/trunk
branches = branches/*/*:refs/remotes/*
tags = tags/*:refs/remotes/tags/*
</code></pre>
<p>This should let you grab the nested branches.</p>
|
How do I integrate Filenet and Outlook? <p>How do I integrate Filenet and Outlook?</p>
|
<p>Assuming that you are talking about FileNet P8, then I can provide some information. I had to do a similar thing a couple of years ago.</p>
<p>First of all you need to get good with MS Office VSTO. More information <a href="http://www.outlookcode.com/article.aspx?ID=42" rel="nofollow">here</a>.</p>
<p>Second you have to get good with using the FileNet P8 .NET Assembly or the Web Services API. Both work well with Visual Studio 2005. </p>
<p>What you are trying to do is create an Outlook toolbar or button and run code that takes an Outlook message (.msg) and archive it to FileNet.</p>
<p>Let me know if you need code examples on something specific like adding a document to P8, or getting an msg file out of an Outlook message etc. </p>
<p>To deploy this whole thing, I used ClickOnce which integrates very well.</p>
|
htaccess request forwarding if internal ip <p>Is there a possible htaccess directive that can transparently forward request from index.php to index_internal.php if the request is coming from an internal ip range?</p>
|
<pre><code>RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\. [OR]
RewriteCond %{REMOTE_ADDR} ^10\.15\.
RewriteRule ^index\.php$ index_internal.php [R,NC,QSA,L]
</code></pre>
<p>What this does: </p>
<p>start mod_rewrite engine (you may have that already)</p>
<p>if (client IP address starts with "192.168.1." [or]</p>
<p>client IP address starts with "10.15.") </p>
<p>and page name is index.php ([n]ot [c]ase sensitive), [r]edirect to index_internal.php, [q]uery [s]tring [a]ppend (i.e. <code>index.php?foo=bar</code> becomes <code>index_internal.php?foo=bar</code>), [l]eave processing.</p>
<p>Modify as needed for IP address blocks.</p>
|
What tools are built using themselves? <p>I am curious about what tools are used to build the next version of themselves.</p>
<p>For example, Delphi has long claimed that "<a href="http://en.wikipedia.org/wiki/Borland_Delphi#Products_developed_with_Delphi" rel="nofollow">Delphi is written in Delphi</a>".</p>
<p>I assume Visual Studio is written using Visual Studio.</p>
<p>What are some other examples of tools that written in themselves?</p>
|
<p>Interestingly, the VB.NET & C# compilers themselves are written in unmanaged C++ (leading to the C++ team's T-Shirt: "My compiler compiled yours"). The C# team hopes to have a fully managed-C# hosted C# compiler for VS2010.</p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.