instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have this code </p>
<p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22580" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22580</a> </p>
<p>which is part of a small ajax application. I would like to know a better, more efficient way to assign $query, instead of copying ... | <p><strong>UPDATE</strong>: I integrated Eran's function into the refactored code. NOTE: I corrected it by passing the $table variable into it and renamed it since it doesn't search the query text only but mainly returns the needed rows!</p>
<p><strong>MAIN MISTAKES</strong>:</p>
<ul>
<li>mistake 1: you overwrite que... | <p>You haven't enclosed the statements in your IF/THEN/ELSE constructions in accolades so only the first statement in every block is conditionally executed, the rest allways is.</p>
<p>In most cases you'd be assigning $query2 to $query while $query2 probably hasn't been defined.</p>
<p>As another tip: sanitize your i... | 45,890 |
<p>If i have a parameterized SQL statement like this: </p>
<pre><code>SELECT * FROM table WHERE my_field = :field_value
</code></pre>
<p>Does anyone know if PDO will recognize this(see below) as the same SQL statement and use the cache instead of assuming it's a completely different SQL statement:</p>
<pre><code>SEL... | <p>If you're using PDO_MySQL, it rewrites prepared statements into raw SQL on its own before the server even sees them, unless you set <code>PDO::ATTR_EMULATE_PREPARES</code> to false.</p>
| <p>PDO has no cache - MySql does. And yes, it will cache the "final" query in the query cache. Not only that, but if you use use the same prepared statements multiple times, you will gain an additional speed increase, because MySql can cache the query execution plan for that statement.</p>
| 49,473 |
<p>Can anyone recommend any good resources for learning C++ Templates?</p>
<p>Many thanks.</p>
| <p>I've found <a href="http://www.cplusplus.com/" rel="noreferrer">cplusplus.com</a> to be helpful on numerous occasions. Looks like they've got a pretty good intro to <a href="http://www.cplusplus.com/doc/tutorial/templates.html" rel="noreferrer">templates.</a> </p>
<p>If its an actual book you're looking for, <a hr... | <p>"The C++ Programming language" by Bjarne Stroustrop</p>
| 18,376 |
<p>I plan to use a distributed cache in my load-balanced webapp.
So I'm going to try to abstract out the common functions between apache ehcache and memcached.</p>
<p>My goal is to be able to make a simple configuration switch to select the caching solution to use. Should I go the SPI route e.g. like how XML parsers a... | <p>single characters you can get from a string with</p>
<pre><code>str.getChar(0);
</code></pre>
<p>When you know that the string contains hex values in every character you dont have to convert every single character. You can put the complete string in and get the dec value of the hex string back. Otherwise you only ... | <p>Java strings are unicode - so the bytes have already been decoded using some encoding (probably UTF-8?). </p>
<p>So:</p>
<ol>
<li>Check the contents of the string.</li>
<li>Check the contents of the substring.</li>
</ol>
| 47,281 |
<p>I am trying to work out the overhead of the ASP.NET auto-naming of server controls. I have a page which contains 7,000 lines of HTML rendered from hundreds of nested ASP.NET controls, many of which have id / name attributes that are hundreds of characters in length. </p>
<p>What I would ideally like is something th... | <p>Quick and dirty:</p>
<p>Search for</p>
<pre><code>\w+\s*=\s*"ctl00[^"]*"
</code></pre>
<p>This will match any text that looks like an attribute, e.g. <code>name="ctl00test"</code> or <code>attr = "ctl00longer text"</code>. It will not check whether this really occurs within an HTML tag - that's a little more diff... | <p>I suggest xpath, as in this <a href="https://stackoverflow.com/questions/99279/how-do-you-parse-a-web-page-and-extract-all-the-href-links#100197">question</a></p>
| 47,338 |
<p>Is it possible to modify a UIActionSheet with a custom UIView? I have a preferences cell in one of my tables which would benefit greatly from a modal window appearing with a UIDatePicker. Having it appear as an Alert would be fantastic as well. Ideally it would be nice to get the free animation that comes in play wi... | <p>UIActionSheet is a UIView. You should be able to add in other views into its subviews.</p>
| <p>As a followup for anyone happening upon this question, modifying the UIActionSheet is not supported by Apple. Apps that do so will most likely break at major os updates.</p>
| 44,968 |
<p>I'm using jQuery validate on a form I am building and it is working great. What I want to do is when something is invalid to have the text field change colors and the error message to be white. I figured the following CSS would work:</p>
<pre><code>label .error {color: white; font-weight: bold;}
input .error {backg... | <p>One space can be one too much. Try:</p>
<pre><code>label.error {color: white; font-weight: bold;}
input.error {background-color: pink; border: 1px dashed red; color: white}
</code></pre>
<p>Background info: </p>
<pre><code>label .error /* selects all elements of class "error" *within* any label */
label.error ... | <p>Try label.error and input.error without spaces.</p>
| 30,723 |
<p>Based on a simple test I ran, I don't think it's possible to put an inline <style> tag into an ASP.NET server control. The style did not end up rendering to the output HTML. Even if it was possible, I'm sure it is bad practice to do this.</p>
<p>Is it possible to do this? I can see it being useful for quick... | <p>Intellisense won't give you hints but you can do this:</p>
<pre><code><asp:Label ID="Label1" runat="server" Text="Label" style="color:Red;"></asp:Label>
</code></pre>
| <p>I think you will have to add it as an attribute to the server control... for it to render to HTML.</p>
<p>So basically (in C#),</p>
<pre><code>ControlName.Attributes["style"] = "color:red";
</code></pre>
| 11,783 |
<p>We have a Win32 application that hosts the .NET runtime and opens up .NET managed forms from the Win32 portion of the application.</p>
<p>These windows are always opened as modal windows.</p>
<p>On some machines, when these windows are closed, the Win32 window that lies behind does not get focus, but gets sent beh... | <p>Lately I noticed that window focus is set differently on windows vista Aero as it used to be on XP. Instead of the last activated window of an app receiving the focus, the main window will receive focus on re-activation.<br>
Funny thing is, changing vista to the old style windows theme (classic or basic), the focus ... | <p>I recall helping a friend with the same problem (can't remember if it where in .net 2.0 or 3.5)</p>
<p>I assume that on your main form you create new forms and use </p>
<pre><code>Form2 form2 = new Form2();
form2.ShowDialog();
</code></pre>
<p>To display the modal popup, now apparently it seems that the ShowDialo... | 26,013 |
<p>Microsoft released the source for <a href="http://www.codeplex.com/oxite/Release/ProjectReleases.aspx?ReleaseId=20210" rel="nofollow noreferrer">Oxite</a>, their blogging engine that's intended to help .NET developers learn ASP.NET MVC. They also released the source for the <a href="http://visitmix.com/" rel="nofoll... | <p>I would stay away from it. It's a very bad example. I don't understand why microsoft put it on internet. First of all the security reasons, but the code is very hard to read for new developers. I use asp.net mvc since preview 2, but it's still very difficult to read that code because it's bad. Many better examples a... | <p>I read at the Mix website that the Oxite source code is "componentized" enough such that WebForms developers can take advantage of it too. Since I'm not ready to go with ASP.NET MVC for my projects yet, Oxite might be a good way for me to figure out how to transition from a WebForms app to an ASP.NET MVC app.</p>
| 46,058 |
<p>I would like to programatically convert a Microsoft Word document into XHTML. The language of choice is PHP, so I would appreciate any suggestions with PHP.</p>
<p>The initial idea is trying to convert the doc file into odt, and then use the <a href="http://odt2xhtml.eu.org/index_en.html" rel="nofollow noreferrer">... | <p>If you're running Linux one way to go would be to install OpenOffice on the server.</p>
<p>Example instructions for a 'headless' (i.e. no UI) install can be found <a href="http://www.oooforum.org/forum/viewtopic.phtml?t=6691" rel="noreferrer">here</a>.</p>
<p>You could then use a nice CLI app like <a href="http://... | <p>See <a href="http://www.codeplex.com/OpenXMLViewer" rel="nofollow noreferrer">http://www.codeplex.com/OpenXMLViewer</a> which includes an XSLT you could adapt, which is what I did in docx4j. Note however, that that XSLT is not for the faint of heart!</p>
| 39,119 |
<p>I've written a paged search stored procedure using SQL Server 2005. It takes a number of parameters and the search criteria is moderately complex.</p>
<p>Due to the front-end architecture I need to be able to return the number of results that would come back <strong>without</strong> actually returning the results. ... | <p>I personally go with the two query approach, yes, you have to maintain the search logic in two places, but I've found that the performance optimization benefit, and overall cleanness of the code pays off in the end.</p>
<p>Using a flag passed to a single procedure, is a potential solution, but I just find that very... | <p>I know this an old question (that has been marked already), but you can return a recordset (aka the results) AND have an OUTPUT (or multiple output) values which means that you only need one round trip to the database.</p>
<p>This is something i'm thinking out aloud (and it's waaay past my bed time...)</p>
<pre><c... | 32,354 |
<p>We have inherited an ant build file but now need to deploy to both 32bit and 64bit systems.</p>
<p>The non-Java bits are done with GNUMakefiles where we just call "uname" to get the info. Is there a similar or even easier way to mimic this with ant?</p>
| <p>you can get at the java system properties (<a href="http://java.sun.com/javase/6/docs/api/java/lang/System.html#getProperties()" rel="noreferrer">http://java.sun.com/javase/6/docs/api/java/lang/System.html#getProperties()</a>) from ant with ${os.arch}. other properties of interest might be os.name, os.version, sun.c... | <p>Assuming you are using ANT for building Java Application, Why would you need to know if it is a 32 bit arch or 64-bit? We can always pass parameters to ant tasks. A cleaner way would be to programmaticaly emit the system properties file used by Ant before calling the actual build. There is this interesting post <a ... | 26,951 |
<p>Let's have the following class hierarchy:</p>
<pre><code>public class ParentClass implements SomeInterface {
}
public class ChildClass extends ParentClass {
}
</code></pre>
<p>Then let's have these two instances:</p>
<pre><code>ParentClass parent;
ChildClass child;
</code></pre>
<p>Then we have the following TR... | <p>No it is not possible, and your intent to do so is a good hint that something is flawed in your class hierarchy. </p>
<p>Workaround: change the class hierarchy, eg. like this: </p>
<pre><code>interface SomeInterface {}
abstract class AbstractParentClass {}
class ParentClass extends AbstractParentClass implements... | <p>Maybe you have a specific case where a better solution could be devised, but for the generic case you need some black magic. Eventually <a href="http://www.csg.is.titech.ac.jp/~chiba/javassist/" rel="nofollow noreferrer">Javassist</a> could be used "hack" your objects but I'm not so sure.</p>
| 25,012 |
<p>I've got some software I created deployed on a Linux VM. I'd like to deploy a second copy of the software on a second virtual machine. Ideally, I'd like to just clone the VM volume, fire up a second copy, change the IP address, and that's that. It there anything else to it, or is it really just that simple.</p>
| <p>Sounds fine to me, as long as your VM software is smart enough to change the VM's MAC address (VMware is at least)</p>
| <p>Sounds fine to me, as long as your VM software is smart enough to change the VM's MAC address (VMware is at least)</p>
| 49,320 |
<p>I am showing an addressbook view to the user and letting them click on a contact and select a phone number. If they select a phone number, I want to get the phone number as an integer and the contact's name as an NSString. </p>
<p>I've tried doing it with the following code: </p>
<pre><code> //printf("%s\n",[[(... | <p>To get the property efficiently (as far as reading goes), you can do something like this in your callback method:</p>
<pre><code>switch( propertyType ) {
case kABMultiStringPropertyType:
// this is the phone number, do something
break;
default:
[self wrongSelection];
break;
}
</code></pre>
<p>I... | <p>Please be aware, that this code crashes in "stringWithString", if the Adressbook-Entry does not contain a name or a contacdata. cfName might be nil!</p>
<pre><code>CFStringRef cfName = ABRecordCopyCompositeName(person);
NSString *personName = [NSString stringWithString:(NSString *)cfName];
CFRelease(cfName);
</cod... | 36,367 |
<p>I have a few kg of 3 mm filament when I only have use for 1.75 mm.</p>
<p>How can I make 1.75 mm from 3 mm filament?</p>
| <p>In theory, making filament is easy. You take a 3 mm hotend with a 1.75 mm hole, and extrude the 3 mm (sometimes actually 2.85 mm) filament, let it cool, and then reel it up.</p>
<p>In reality there are a lot of pitfalls to making filament - if the pressure isn't even, the hole not perfect, the ... | <p>You could build a machine that has a nozzle with 3 mm input hole and 1.75 mm output hole, based on some designs for filament making machines. Or you could just cut the filament into little peaces and use them instead of the granulate in an original filament making machines.</p>
<p>There are some open designs for su... | 98 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/43743/asp-net-mvc-performance">ASP.NET MVC Performance</a> </p>
</blockquote>
<p>I know there is a learning curve, but what about performance? It seems to me that web forms would be less performant, but I haven... | <p>This is almost a duplicate question. Here are some similar discussions:</p>
<p><a href="https://stackoverflow.com/questions/43743/aspnet-mvc-performance">ASP.NET MVC Performance</a></p>
<p><a href="https://stackoverflow.com/questions/142132/what-are-the-key-differences-between-aspnet-webforms-and-mvc">What are the... | <p>This is debatable because both of them have different performance pros and cons, for example ASP.net MVC gives you control over the HTML/JS that gets to the browser, so you can minimize the amount of data on wire to make the whole application weight less, however ASP.net MVC routing have so much dependency on Reflec... | 27,367 |
<p>I have been tasked to optimize some sql queries at work. Everything I have found points to using Explain Plan to identify problem areas. The problem I can not find out exactly what explain plan is telling me. You get Cost, Cardinality, and bytes. </p>
<p>What do this indicate, and how should I be using this as a gu... | <p>You get more than that actually depending on what you are doing. Check out this <a href="http://www.oracle-base.com/articles/8i/ExplainPlanUsage.php" rel="noreferrer">explain plan</a> page. I'm assuming a little bit here that you are using Oracle and know how to run the script to display the plan output. What may be... | <p>This is a massive area of expertise (aka a black art).</p>
<p>The approach I generally take is:</p>
<ol>
<li>Run the SQL statement in question,</li>
<li>Get the actual plan (look up dbms_xplan),</li>
<li>Compare the estimated number of rows (cardinality) vs actual number of rows. A big difference indicates a prob... | 29,043 |
<p>I have a right outer join, that almost does what I want...</p>
<pre><code>SELECT
users_usr.firstname_usr,
users_usr.lastname_usr,
credit_acc.given_credit_acc,
users_usr.created_usr,
users_usr.sitenum_usr,
users_usr.original_aff_usr,
users_usr.id_usr
FROM
credit_acc
right Outer Join users_usr ON credit_acc.uid_usr =... | <pre><code>SELECT
users_usr.firstname_usr,
users_usr.lastname_usr,
credit_acc.given_credit_acc,
users_usr.created_usr,
users_usr.sitenum_usr,
users_usr.original_aff_usr,
users_usr.id_usr
FROM
credit_acc
right Outer Join users_usr ON credit_acc.uid_usr = users_usr.id_usr
WHERE credit_acc.type_acc = 'init' OR credit_acc.... | <p>You want all records from the two tables, joined on user-id, WHERE credit_acc is 'init' OR where there isn't a credit_acc row to be joined? How about</p>
<pre><code>where credit_acc.type_acc is null OR credit_acc.type_acc = 'init'
</code></pre>
| 36,597 |
<p>What are the benefits of upgrading from Visual Studio 2005 to 2008?</p>
<p>Any thoughts on whether it's worth the jump, or is it better to wait for whatever's coming next?</p>
| <p>There are tons of improvements. The best part is you can continue to target .Net 2.0 with VS 2008 (<a href="http://weblogs.asp.net/scottgu/archive/2007/06/20/vs-2008-multi-targeting-support.aspx" rel="noreferrer">Multi-Targeting</a>) and use all the new IDE features.</p>
<p>Posting couple of screencasts but you can... | <p>Check out <a href="https://stackoverflow.com/questions/46036/upgrading-to-visual-studio-2008-from-2005">this question</a>... it has been discussed before. </p>
<p>Though I will repeat that the main thing I love about VS 2008 is their use of the Expression Web GUI for Web App development. It is far superb to what VS... | 23,497 |
<p>Is there code in VBA I can wrap a function with that will let me know the time it took to run, so that I can compare the different running times of functions?</p>
| <p>Unless your functions are very slow, you're going to need a very high-resolution timer. The most accurate one I know is <code>QueryPerformanceCounter</code>. Google it for more info. Try pushing the following into a class, call it <code>CTimer</code> say, then you can make an instance somewhere global and just call ... | <p>Seconds with 2 decimal spaces:</p>
<pre><code>Dim startTime As Single 'start timer
MsgBox ("run time: " & Format((Timer - startTime) / 1000000, "#,##0.00") & " seconds") 'end timer
</code></pre>
<p><a href="https://i.stack.imgur.com/YgQWt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y... | 24,166 |
<p>Are there any native Git implementations for Windows that do not require Cygwin? I've become a fan of the TortoiseSVN client, and would really like to see a similar Git client for Windows.</p>
<p><strong>Edit:</strong> I am also considering <a href="http://www.selenic.com/mercurial/wiki/" rel="noreferrer">Mercuria... | <p>I started GitExtensions about a week ago. Allthough version 0.6 is a pretty complete package, I do not consider it release-ready yet. The toolset should be ready for its first stable release in a few days. There are a few things I need to fix before anyone should use it in production. The most important problem now ... | <p>Have you tried looking at the <a href="http://code.google.com/p/tortoisegit/" rel="nofollow noreferrer">TortoiseGit page on Google Code</a>? I believe it's the same project as the other link posted, but it's a bit friendlier. You can download the latest version as an installer from there.</p>
| 47,415 |
<p>There are a lot of rails plugins out there that handle user permissions. I'm impressed with the implementation in the hobo gem, but I'm not sure if I can use just this feature and not the other parts. GateKeeper is a really clever implementation, but has some bugs, though it's small enough I could probably fix it ... | <p>You can do some really complex authorization tricks on the model level with <a href="http://github.com/stffn/declarative_authorization/tree/master" rel="nofollow noreferrer">declarative_authorization</a> plugin. Nevertheless, I myself prefer <a href="http://github.com/DocSavage/rails-authorization-plugin/tree/master... | <p>You could check out <a href="http://github.com/stonean/lockdown" rel="nofollow noreferrer">lockdown</a>. I haven't implemented this on project yet but it could save you some work.</p>
| 45,629 |
<p>When compiling an ASP.NET 2.0 App names MySite for deployment I get a series of assemblies that resemble something like "bin/APP_xyz123.dll", "bin/APP_xyz456.dll" and so on. </p>
<p>Everything works fine but if I make a small code change I have to update the entire site because the "_xyz123" and "_xyz456" part of t... | <p>In 2005 and 2008 there are two options for creating a website--the WebSite project and the Web Application project.</p>
<p>The WAP is the one you want. Its available by default in 2008, but you have to download an update in 2005 to get it.</p>
<p>You can read more about it on the <a href="http://webproject.scottg... | <p>Another option is to use the <a href="http://msdn.microsoft.com/en-us/library/bb397866.aspx" rel="nofollow noreferrer">aspnet_merge.exe</a> tool which can generate a single assembly for your application.</p>
| 41,597 |
<p>What constitutes a good CI build-process?</p>
<p>We use CI, but is deployment to production even a realistic CI goal when you have dependencies on several services that should be deployed too and other apps may depend on these too.</p>
<p>Is a good good CI build process good enough when its automated to QA and man... | <p>Well "it depends" :)</p>
<p>We use our CI system to:</p>
<ol>
<li>build & unit test</li>
<li>deploy to single box, run intergration tests and code analisys</li>
<li>deploy to lab environment</li>
<li>run acceptance tests in prod-like system</li>
<li>drop builds that pass to code drop for prod deployment</li>
<... | <p>I was watching a ThoughtWorks presentation (creators of Cruise Control) and they actually addressed this issue. Their answer is that NO deployment is too complex to test. Why? Because otherwise, your customers become your testers, which is exactly where you don't want to be.</p>
<p>If you have a complex deployment ... | 12,851 |
<p>In my day job I, and others on my team write a lot of hardware models in Verilog-AMS, a language supported primarily by commercial vendors and a few opensource simulator projects.
One thing that would make supporting each others code more helpful would be a LINTER that would check our code for common problems and a... | <p>lex/flex and yacc/bison provide easy-to-use, well-understood lexer- and parser-generators, and I'd really recommend doing something like that as opposed to doing it procedurally in e.g. Perl. Regular expressions are powerful stuff for ripping apart strings with relatively-, but not totally-fixed structure. With an... | <p>In trying to find my answer, I found this on <a href="http://www.ibm.com/developerworks/edu/au-dw-au-parsingwithantlr-i.html" rel="nofollow noreferrer">ANTLR</a> - might be of use</p>
| 9,614 |
<p><strong>Environment:</strong><br/>
Windows Server 2003 R2 Enterprise 64bit, SP2<br/>
.NET framework is supposedly installed (2.0 SP2, 3.0 SP2, 3.5 SP1)</p>
<p>I say "supposedly" because they are listed as installed under Add/Remove programs. I'm not sure it's <em>properly</em> installed, because the "ASP.NET" tab i... | <p>Have you tried running:</p>
<pre><code>aspnet_regiis -i
</code></pre>
<p>from the command line?</p>
| <p>I had a similar error with IIS7 on Windows Server 2008 64 Bits.</p>
<p>The fusion log is not of any help here, and it turned out that in my case there was a third party assembly that was referencing a 32 Bits only assembly or native dll. (Xceed to be precise)</p>
<p>To find which assembly is being loaded by the 64... | 22,375 |
<p>It's simple enough to code up a class to store/validate something like <code>192.168.0.0/16</code>, but I was curious if a native type for this already existed in .NET? I would imagine it would work a lot like <code>IPAddress</code>:</p>
<pre><code>CIDR subnet = CIDR.Parse("192.168.0.0/16");
</code></pre>
<p>Basi... | <p>You can use the code from GitHub to do just that:</p>
<p><a href="https://github.com/lduchosal/ipnetwork" rel="nofollow noreferrer">https://github.com/lduchosal/ipnetwork</a></p>
<pre><code>IPNetwork ipnetwork = IPNetwork.Parse("192.168.168.100/24");
Console.WriteLine("Network : {0}", ipnetwork.Network);
Console.... | <p>No there is such native type in .NET, you will need to develop one your self.</p>
| 40,022 |
<p>I understand that <code>inline</code> by itself is a suggestion to the compiler, and at its discretion it may or may not inline the function, and it will also produce linkable object code.</p>
<p>I think that <code>static inline</code> does the same (may or may not inline) but will not produce linkable object code ... | <p>in K&R C or C89, inline was not part of the language. Many compilers implemented it as an extension, but there were no defined semantics regarding how it worked. GCC was among the first to implement inlining, and introduced the <code>inline</code>, <code>static inline</code>, and <code>extern inline</code> const... | <h2>C++ only:</h2>
<p>As others have pointed out, macros (here <code>__FILE__</code> and <code>__LINE__</code>) are evaluated before compiling and linking; So if you have a function that uses those and you want them to be different for each file, you need the opposite of <code>inline</code>. Since the <code>__FILE__</c... | 26,616 |
<p>i was wondering how you deal with permalinks on international sites. By permalink i mean some link which is unique and human readable. </p>
<p>E.g. for english phrases its no problem e.g. <strong>/product/some-title/</strong></p>
<p>but what do you do if the product title is in e.g chinese language??
how do you de... | <p>Characters outside the ISO Latin-1 set are not permitted in URLs according to <a href="http://www.w3.org/Addressing/URL/uri-spec.html" rel="nofollow noreferrer">this spec</a>, so Chinese strings would be out immediately.</p>
<p>Where the product name can be localised, you can use urls like <code><DOMAIN>/<... | <p>If memory serves, you're only able to use English letters in URLs. There's a discussion to change that, but I'm fairly positive that it's not been implemented yet.</p>
<p>that said, you'd need to have a look up table where you assign translations of products/titles into whatever word that they'll be in the other la... | 15,472 |
<p>Are there any blogs, guides, checklists, or controls we should be using to ensure our SharePoint implementation is accessible?
Preferrably to the W3C double A standard, or as close to that as we can get.</p>
<p>We're implementing an extranet solution. </p>
| <p>This study has already been funded by Microsoft, and unfortunately the results only seem to be online in a Word Document.</p>
<p>The document is hosted on this blog:
<a href="http://blog.mastykarz.nl/best-practices-for-developing-accessible-web-sites-in-microsoft-office-sharepoint-server-2007/" rel="nofollow norefe... | <p>How are you deploying the implementation? Is it as an Intranet, or, is it as a public facing website.</p>
<p>I think one of the first rules is to be extremely selective with the use of out of the box web parts. Many of the web-parts I looked at weren't compliant even on a basic level.</p>
<p>Andrew</p>
| 10,842 |
<p>c# windows forms: How do you create new settings at run time so that they are permanently saved as Settings.Default.-- values?</p>
| <p>Just in case that still matters to anyone:</p>
<p>You can dynamically add settings through <code>Settings.Default.Properties.Add(...)</code> and have these also persisted in the local storage after saving (I had those entries reflected in the roaming file).</p>
<p>Nevertheless it seems that the dynamically added s... | <p>I see how what I wanted was the wrong idea. I'm porting a c++ app over to c# and it has a lot of ini file settings and I was looking for a shortcut to add them in. I'm lazy.</p>
| 21,172 |
<p>I was wondering if the C# project setting "Allow unsafe code" applies only to unsafe C# code in the project itself, or is it necessary to set this option when linking in a native C++ DLL? What about linking in a managed DLL that itself links to a native DLL? What does this option really do, under the hood?</p>
| <p>It has to do with the "unsafe" keyword in C#. "unsafe" turns off all the checks that would normally happen and allow you to directly access the memory. it doesn't refer to calling native C++ DLL's or interfaces.</p>
| <p>Its necessary to use the unsafe { } context. It used to be required to use sizeof() but in later versions that's no longer true.</p>
<p>You don't need to allow unsafe code if you are externing to another DLL written in another language like C.</p>
| 28,935 |
<p>I build up an array of strings with</p>
<pre><code>string[] parts = string.spilt(" ");
</code></pre>
<p>And get an array with X parts in it, I would like to get a copy of the array of strings starting at element </p>
<pre><code>parts[x-2]
</code></pre>
<p>Other than the obvious brute force approach (make a new a... | <p>How about Array.Copy?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa310864(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa310864(VS.71).aspx</a></p>
<blockquote>
<p>Array.Copy Method (Array, Int32, Array, Int32, Int32)</p>
<p>Copies a range of elements from an Array star... | <p>Use <a href="http://msdn.microsoft.com/en-us/library/system.array.copy(VS.80).aspx" rel="nofollow noreferrer">Array.Copy</a>. It has an overload that does what you need: </p>
<blockquote>
<p>Array.Copy (Array, Int32, Array,
Int32, Int32)<br>
<em>Copies a range of elements from an Array starting at the specif... | 5,087 |
<p>I'm evaluating subversion's branch/merge capabilities, and I decided to do a simple test - I branched an existing project, changed a comment in one file, and then did a merge reintegrate via Tortoise.</p>
<p>It failed:</p>
<blockquote>
<p>Command: Reintegrate merge <a href="https://oscar/svn/Baxtech/ViM/Branches... | <p>This also happened to me some time ago.</p>
<p>I can't remember what I exactly did to trigger this problem, but I can say that I was also using a pre-1.5 release, and then switched to 1.5.0.</p>
<p>Subversion tracks merges using a per-directory svn:mergeinfo property. This property should only be present on the r... | <p>Can't think of any reasons why, I never seen this error and I use branching/merging heavily. A couple of things I would check:</p>
<ul>
<li>You start the merge from your trunk working copy (right click->SVN->Merge)?</li>
<li>What happens if you say Test merge?</li>
<li>What about checking on ignore ancestry?</li>
<... | 41,107 |
<p>Could you please explain what the practical usage is for the <code>internal</code> keyword in C#?</p>
<p>I know that the <code>internal</code> modifier limits access to the current assembly, but when and in which circumstance should I use it?</p>
| <p>Utility or helper classes/methods that you would like to access from many other classes within the same assembly, but that you want to ensure code in other assemblies can't access.</p>
<p>From <a href="https://web.archive.org/web/20130305112130/http://msdn.microsoft.com/en-us/library/7c5ka91b(v=vs.80).aspx" rel="no... | <p>When you have classes or methods which don't fit cleanly into the Object-Oriented Paradigm, which do dangerous stuff, which need to be called from other classes and methods under your control, and which you don't want to let anyone else use.</p>
<pre><code>public class DangerousClass {
public void SafeMethod() ... | 20,011 |
<p>How can I turn off the wavy red underlines in Netbeans? I don't want to be interrupted while I'm typing, and told that a half finished line of code is wrong.</p>
| <p>Follow this path if you want to turn them off, (I'm using NeatBeans 5.5.1)</p>
<p>Tools ->
Options ->
Advanced Options ->
Open the "Editing" node and click on "Java sources" ->
Enter 0 for the "Error Annotation Limit"</p>
<p>That will completely turn off the red underlines. You can also change the "automatic parsi... | <p>Follow this path if you want to turn them off, (I'm using NeatBeans 5.5.1)</p>
<p>Tools ->
Options ->
Advanced Options ->
Open the "Editing" node and click on "Java sources" ->
Enter 0 for the "Error Annotation Limit"</p>
<p>That will completely turn off the red underlines. You can also change the "automatic parsi... | 29,294 |
<p>One of the things that always bugs me about using Readers and Streams in Java is that the <code>close()</code> method can throw an exception. Since it's a good idea to put the close method in a finally block, that necessitates a bit of an awkward situation. I usually use this construction:</p>
<pre><code>FileReader... | <p>I'm afraid there's a big problem with the first example, which is that if an exception happens on or after the read, the <code>finally</code> block executes. So far so good. But what if the <code>fr.close()</code> then causes another exception to be thrown? This will "trump" the first exception (a bit like putting <... | <p>The standard convention I use is that you must not let exceptions escape a finally block.</p>
<p>This is because if an exception is already propagating the exception thrown out of the finally block will trump the original exception (and thus be lost).</p>
<p>In 99% of cases this is not what you want as the origina... | 22,189 |
<p>Are you aware of any open source libraries/projects that offer audio watermarking capability?</p>
| <p>check wikipedia: <a href="http://en.wikipedia.org/wiki/Steganography#Implementations" rel="noreferrer">http://en.wikipedia.org/wiki/Steganography#Implementations</a></p>
<p>section 3 of this site site is on audio: <a href="http://www.binary-universe.net/" rel="noreferrer">http://www.binary-universe.net/</a>
same a... | <p>We made a <a href="https://github.com/jcelerier/watermarking/tree/master/src/libwatermark" rel="nofollow">C++ watermarking library</a> as a student project.
It implements:</p>
<ul>
<li>Least Significant Bit watermarking (which won't resist anything), </li>
<li>Spread-Spectrum Watermarking (which should resist quite... | 28,156 |
<p>I don't really get it and it's driving me nuts.
i've these 4 lines:</p>
<pre><code>Image img = Image.FromFile("F:\\Pulpit\\soa.bmp");
MemoryStream imageStream = new MemoryStream();
img.Save(imageStream, ImageFormat.Bmp);
byte[] contentBuffer = new byte[imageStream.Length];
imageStream.Read(contentBuffer, 0, content... | <p>Try setting imageStream.Position to 0. When you write to the MemoryStream it moves the Position after the bytes you just wrote so if you try to read there's nothing there.</p>
| <pre><code>Image img = Image.FromFile("F:\\Pulpit\\soa.bmp");
MemoryStream imageStream = new MemoryStream();
img.Save(imageStream, ImageFormat.Bmp);
byte[] contentBuffer = new byte[imageStream.Length];
imageStream.Position = 0;//Reset the position at the start
imageStream.Read(contentBuffer, 0, contentBuffer.Length);
<... | 49,234 |
<ul>
<li>Say we have realized a value of TDD too late. Project is already matured, good deal of customers started using it. </li>
<li>Say automated testing used are mostly functional/system testing and there is a good deal of automated GUI testing. </li>
<li>Say we have new feature requests, and new bug reports (!). So... | <p>Creating a complex mocking infrastructure will probably just hide the problems in your code. I would recommend that you start with integration tests, with a test database, around the areas of the code base that you plan to change. Once you have enough tests to ensure that you won't break anything if you make a chang... | <p>Yes you can. Don't do it all at once, but introduce just what you need to test a module whenever you touch it.</p>
<p>You can also start with more high level acceptance tests and work your way down from there (take a look at <a href="http://fitnesse.org/" rel="nofollow noreferrer">Fitnesse</a> for this).</p>
| 13,330 |
<p>Supposedly, it is possible to get this from Google Maps or some such service. (US addresses only is not good enough.)</p>
| <p>The term you're looking for is geocoding and yes Google does provide this service.</p>
<ul>
<li><p><strong>New V3 API</strong>: <a href="http://code.google.com/apis/maps/documentation/geocoding/" rel="noreferrer">http://code.google.com/apis/maps/documentation/geocoding/</a></p></li>
<li><p>Old V2 API: <a href="http... | <p>I know this is old question but google changing way to get latitude and longitude on regular based.</p>
<p><strong>HTML code</strong></p>
<pre><code><form>
<input type="text" name="address" id="address" style="width:100%;">
<input type="button" onclick="return getLatLong()" value="Get Lat Lo... | 19,164 |
<p>I created a report model using SSRS (2005) and published to the local server. But when I tried to run the report for the model I published using report builder I get the following error. </p>
<blockquote>
<p>Report execution error:The permissions granted to user are insufficient for performing this operation. (rs... | <p>It's because of lack of privilege for the user you are running the report builder, just give that user or a group a privilege to run report builder.
Please visit this <a href="http://www.gotknowhow.com/articles/reportserver-permissions-granted-are-insufficient-for-performing-this-operation-rsaccessdenied">article</a... | <p>Run BIDS as administrator despite of existing membership of Administrators group.</p>
| 16,095 |
<p>i have got an 32bit (hexadecimal)word 0xaabbccdd and have to swap the 2. and the 3. byte. in the end it should look like 0xaaccbbdd</p>
<p>how can i "mask" the 2nd and the 3rd byte to first load them up to register r1 and r2 and the swap them..
i also know that i have to work with lsl and lsr commands but dont know... | <p>That's not a simple task in ARM assembly because you can't easily use 32 bit constants. You have to break up all your operations that mask out bytes to use 8 bit constants each (also these constants can be rotated).</p>
<p>You mask out byte2 and 3 using the AND instruction and do the shift later. in ARM-assembler y... | <p>You vould just use pointers to swap two bytes</p>
<pre><code>static union {
BYTE BBuf[4];
WORD WWBuf[2];
DWORD DWBuf;
}swap;
unsigned char *a;
unsigned char *b;
swap.DWBuf = 0xaabbccdd;
a = &swap.BBuf[1];
b = &swap.BBuf[2];
*a ^= *b;
*b ^= *a;
*a ^= *b;
</code></pre>
<p>And now the result is</p>... | 45,270 |
<p>I have an Ender 3, I got a new glass bed, the bed comes with glue on the back.</p>
<p>Should I stick the glass bed to the aluminium base? or just use it with the clips?
I saw other people just use the clips, but my glass seems to have a sticky back...</p>
<p><a href="https://i.stack.imgur.com/iq7WD.jpg" rel="nofol... | <p>This is opinion-based, but the volcano has drawbacks that affect print quality, mine is oozier and sloppier than a V6 with the shorter, more precise melt zone. It isn’t a slam dunk upgrade, more of a special applications part. I think there is no point to using a Volcano unless you’re running big nozzles fast, like ... | <p>Yes, the Volcano or the Super Volcano allow for larger flow rate (typically when using larger nozzles), that is where they were designed for. Just the nozzle will not help you, you need this larger nozzle shaft to be inside a Volcano heater block, else you cannot transfer the heat.</p>
<p>According to measurements f... | 1,652 |
<p>I have a TurboGears application I'd like to run through Facebook, and am looking for an example TurboGears project using pyFacebook or minifb.py. pyFacebook is Django-centric, and I can probably figure it out, but this is, after all, the lazy web.</p>
| <p>Why is pyFacebook django centric? Looks like it works perfectly fine with all kinds of WSGI apps or Python applications in general. No need to use Django.</p>
| <p>pyFacebook is Django-centric because it includes a Django example. I did not intend to irk, but am merely looking for a TurboGears example using pyFacebook.</p>
| 15,369 |
<p>The <a href="http://www.emacswiki.org/emacs/MercurialMode" rel="noreferrer">Emacs Wiki</a> lists several modes for supporting mercurial inside of Emacs, including the built-in VC mode. Is it worth exploring any of the other modes, such as the one distributed with mercurial itself?</p>
| <p>I would suggest <a href="http://xtalk.msk.su/~ott/en/writings/emacs-vcs/EmacsDVC.html" rel="noreferrer">DVC</a>. It supports other distributed version control systems (notably git), it's easy to configure and it works as much like the default VC mode as reasonable. It also seems to have a larger user-base than the... | <p>This depends on which other DVCS you using. If you using several, then DVC could be good choice.</p>
<p>If you want to get native support of mercurial, then you can use either mercurial.el (described in my article), either <a href="https://es.fbk.eu/people/griggio/ahg.html" rel="nofollow noreferrer">aHg</a> packag... | 30,748 |
<p>I'm going to build an API for a web app and I'm interested in what people can suggest as good practices.</p>
<p>I'm already planning to make it versioned (version 1 can only control certain aspects of the system, version 2 could control more, but this may need a change in the way authentication is performed that wo... | <p>Read the <a href="http://www.crummy.com/writing/RESTful-Web-Services/" rel="noreferrer">RESTful Web Services</a> book, which give you a good overview of how to use REST in practice, and get to up to speed quickly enough to get started now, with some confidence. This is more useful than just looking at an existing AP... | <p>Use REST.</p>
<p>Read up on standards for APIs, or copy the ideas from one of the popular ones.</p>
<p>Be careful when authenticating users.</p>
<p>Start very very simple.</p>
<p>Build a site that uses your API (even if it's not useful) to check things work. Perhaps you could build a mobile version of the site o... | 5,380 |
<p>I have a little routine that's run under Linux and Windows written in C and displays output on the console. I'm not linking in any form of curses or anything like that.</p>
<p>Currently I clear the screen using</p>
<pre><code>#ifdef __WIN32
system( "cls" );
#else
system( "clear" );
#endif
</code></pre>
<p>The... | <p>Looks like I may have found a windows specific way of doing it <a href="http://msdn.microsoft.com/en-us/library/ms686025(VS.85).aspx" rel="nofollow noreferrer">SetConsoleCursorPosition</a></p>
<p>Ansi escape sequence \033[0;0H for Linux - just printf that to the console.</p>
| <p>Yes, for unix platforms, curses (or ncurses, these days) is the way to go. And there are versions that work under windows, so you could do it the same way on both systems.</p>
| 8,021 |
<p>I'm trying to use a select statement to get all of the columns from a certain MySQL table except one. Is there a simple way to do this?</p>
<p>EDIT: There are 53 columns in this table (NOT MY DESIGN)</p>
| <p>Actually there is a way, you need to have permissions of course for doing this ...</p>
<pre><code>SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), '<columns_to_omit>,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '<table>' AND TABLE_SCHEMA = '<database>'), ' FROM ... | <p>Im pretty late at throing out an answer for this, put this is the way i have always done it and frankly, its 100 times better and neater than the best answer, i only hope someone will see it. And find it useful</p>
<pre><code> //create an array, we will call it here.
$here = array();
//create an SQL que... | 3,058 |
<p>I am working in a .NET environment where the system occasionally generates log entries for a customer. Messages are then appended to a customer log which can be reviewed at a later time.</p>
<p>For example, if a customer is subscribing to a new service, or a customer has a failed payment attempt, these messages get... | <ul>
<li>Log event identifiers rather than messages.</li>
<li>Capture event specific data along with the event identifier.</li>
<li>When a user views the log, localize the event message based on the unique identifier.</li>
</ul>
<p>The problem you'll run into is if you try to insert dynamic data into the messages in a... | <p>You can define the localised strings in your database and just log the id of the log message to your log table. The log messages table would also contain a field to indicate the language.</p>
<p>If you are doing a lot of logging, that would also reduce the size of your log (even though that is probably not relevant... | 46,953 |
<p>As the local subversion czar i explain to everyone to keep only source code and non-huge text files in the repository, not huge binary data files. Smaller binary files that are parts of tests, maybe. </p>
<p>Unfortunately i work with <em>humans</em>! Someone is likely to someday accidentally commit a 800MB bin... | <p>Some extra info about this can be found at the blog post: <a href="http://blog.projectnibble.org/2008/03/01/subversion-obliterate-the-forgotten-feature/" rel="nofollow noreferrer">Subversion Obliterate, the missing feature</a></p>
<p>Be sure to read through the comments too, where Karl Fogel puts the article into p... | <p>Once you removed the file from your HEAD revision, it doesn't slow you down on operation speed as ony deltas between revisions are handled.
(Repository backups must of course handle the load).</p>
| 10,640 |
<p>I have a Java application which I want to shutdown 'nicely' when the user selects Start->Shutdown. I've tried using JVM shutdown listeners via Runtime.addShutdownHook(...) but this doesn't work as I can't use any UI elements from it.</p>
<p>I've also tried using the exit handler on my main application UI window but... | <p>You can make shortcut to:</p>
<pre><code>msiexec /uninstall [path to msi or product code]
</code></pre>
| <p>Visual Studio 2013 allows you to create an Uninstall shortcut in the shortcut design page if you use the Installshield Add-on.</p>
| 8,695 |
<p>I'm trying to write a web-app that records WAV files (eg: from the user's microphone). I know Javascript alone can not do this, but I'm interested in the least proprietary method to augment my Javascript with. My targeted browsers are Firefox for PC and Mac (so no ActiveX).</p>
<p>I gather it can be done with Flash... | <p>Flash requires you to use a media server (note: I'm still using Flash MX, but a quick Google search brings up documentation for Flash CS3 that seems to concur - note that Flash CS4 is out soon, might change then). Macromedia / Adobe aim to flog you their media server, but the Red5 open-source project might be suitib... | <p>You could download Real Producer Basic, which is free here (<a href="http://forms.real.com/rnforms/products/tools/producerbasic/" rel="nofollow noreferrer">http://forms.real.com/rnforms/products/tools/producerbasic/</a>), and imbed it as an activeX object since it's on your intranet. Flash will embed the same way, ... | 8,948 |
<p>If I have code like this:</p>
<pre><code> public XALServiceConfiguration CreateInstance()
{
var config = ConfigurationManager.GetSection(ConfigurationSectionName) as XALServiceConfiguration;
if (config == null)
throw new ConfigurationErrorsException("Configurat... | <p>I think the other answers so far have missed the point of your question, which is how to <em>provoke</em> the exception.</p>
<p>Using a static technique like this, you really can't easily do it - you'd have to have a way of injecting the particular configuration into your test. I seem to remember that the .NET conf... | <p>You could just catch the exception in a <code>try catch</code> statment and do an <code>Assert</code> in the catch.</p>
| 40,873 |
<p>The collection of fonts available to a web developer is depressingly limited. I remember reading long ago about TrueDoc, as a way of shipping fonts alongside a website - but it seems to have languished. Has anybody used this, or something similar? Is it supported by enough browsers? Am I missing a good solution?</p>... | <p>Safari, and to a lesser extent, Firefox 3 have support for <code>@font-face</code> in CSS, which lets you use custom fonts. You need to have the appropriate licence to distribute the font files though. These articles explain it in more detail:</p>
<ul>
<li><a href="http://www.css3.info/preview/web-fonts-with-font-f... | <blockquote>
<p>Note that a responsible web developer does not use fonts that are only available on Windows (and especially ones that are only available on Vista), nor do they use a technology that isn't supported by at least the majority of browsers.</p>
</blockquote>
<p>Well… You can, as long as you know how it wi... | 3,696 |
<p>I wanted to start with the use of Remoting under C# in a testdriven way, but I got stuck.</p>
<p>One thing I found on the topic is this <a href="http://www.codeproject.com/KB/architecture/TddRemoting.aspx" rel="nofollow noreferrer">article by Marc Clifton</a>, but he seems to have the server running by starting it ... | <p>I don't really have a solution to your problem but my advice would be, not to write unit-tests in this manner. See this <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=126923" rel="nofollow noreferrer">post</a>. What code do you really want to test here. I'm pretty sure Microsoft has done a good deal of t... | <p>I found a nice way to do exactly what I wanted to do, just using WCF instead of Remoting.</p>
<p>I ported the source code given in <a href="http://blogs.microsoft.co.il/blogs/smallfish/archive/2008/11/28/testing-wcf-service.aspx" rel="nofollow noreferrer">the article by Yair Cohen</a> to NUnit within less than 5 mi... | 45,484 |
<p>I'm using the standard edition of JIRA and on the whole, I love it. However, it's a frequent source of irritation that JIRA doesn't seem to record who resolved an issue, just who the current assignee is, and who reported the issue.</p>
<p>Because the "resolver" is not recorded there's no way to find issues that I r... | <p>The <a href="http://confluence.atlassian.com/display/JIRAEXT/JIRA+Enhancer+Plugin" rel="noreferrer">JIRA Enhancer Plugin</a> adds a "last resolved user" custom field. If you add this to your issues and to the issue screen you can see who the last user to resolve the issue was.</p>
<p>I suspect it will only be searc... | <p>Typically the person the issue is assigned to is the one resolving the issue. Perhaps your workflow needs to be altered so that this is the case.
However, the changelog does record who performed a particular transition. This is not queryable tho.</p>
| 26,915 |
<p>This is probably easy but I am getting stuck: when I build a solution in Visual Studio - how do extract the exact cmd line for the current build command in order to be able to do the same build from VisualStudio console? </p>
<p>In the output window I can see the single projects in the solution build commands but n... | <p>In addition to what @JohnIdol says correctly, I've found that you need to setup a number VS environment variables. I don't have the name of the batch file in front of me, but you can modify or 'I think' use it. It is in VS program files tree somewhere. Also, as I remember you don't want to be in a standard shell but... | <p>You can start msbuild from the command line. msbuild understands .sln (solution) files. You can specify the .sln file and the build configuration (debug, release etc.) from the command line.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms164311.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en... | 35,480 |
<p>I've been using the FCK Editor for several of my client sites in the past. Recently due to some new browser security updates(I'm assuming) some of the functionality is now breaking.</p>
<p>I was planning on updating those sites to the most recent version, but sometimes I think the FCK is overly complex and tends t... | <p><a href="http://developer.yahoo.com/yui/editor/" rel="nofollow noreferrer">Yahoo Editor</a> from Yahoo YUI</p>
<p><strong>UPDATE:</strong></p>
<p>Rolling up the other answers:</p>
<p><a href="http://tinymce.moxiecode.com/" rel="nofollow noreferrer">TinyMCE</a></p>
<p><a href="http://cutesoft.net/ASP.NET+WYSIWYG+Edit... | <p>You might consider the Rich Text Editor in Flex. (Or Silverlight, for that matter.) It's a bit more of a controlled environment.</p>
| 47,183 |
<p>OK, I have been working on a random image selector and queue system (so you don't see the same images too often).</p>
<p>All was going swimmingly (as far as my crappy code does) <strong>until</strong> I got to the random bit. I wanted to test it, but how do you test for it? There is no <code>Debug.Assert(i.IsRandom)... | <p>Test from the requirement : "so you don't see the same images too often"</p>
<p>Ask for 100 images. Did you see an image too often?</p>
| <p>Random is Random. Even if the same picture shows up 4 times in a row, it could still be considered random.</p>
| 14,929 |
<p>I need to </p>
<ol>
<li>convert my Sandcastle Help File
Builder (SHFB) output that is a Web
site (HTML) to Media wiki format </li>
<li>Find a way to transfer/include the
converted pages directly into the
MediaWiki we have set up.</li>
</ol>
<p>Any ideas? we have over 1000 pages of HTML files inthe Website (out... | <p>Take a look at Help Server. It allows to publish .CHM / .HxS produced by any tool (including Sandcastle) on the web and provides <a href="http://help.x-tensive.com/" rel="nofollow noreferrer">URL-based integration API</a>.</p>
<p>We use MediaWiki as well. <a href="http://wiki.dataobjects.net/index.php?title=Code_te... | <p>I did some work with ingesting existing material from several sites into a comprehensive Wiki. It did not involve Sandcastle, but if you're dealing with HTML it shouldn't matter much. <strong>html2wiki</strong> extensions are out there, and from what I have read they can solve a lot of problems. I needed a little mo... | 34,843 |
<p>Normal OSX applications eat the first mouse click when not focused to first focus the application. Then future clicks are processed by the application. iTunes play/pause button and Finder behave differently, the first click is acted on even when not focused. I am looking for a way to force an existing application... | <p>Check NSView's acceptsFirstMouse, it may be what you're looking for. </p>
<p>acceptsFirstMouse:
Overridden by subclasses to return YES if the receiver should be sent a mouseDown: message for an initial mouse-down event, NO if not.</p>
<ul>
<li>(BOOL)acceptsFirstMouse:(NSEvent *)theEvent</li>
</ul>
<p>Parameters
t... | <p>// Assuming you have 1 view controller that's always hanging around. Over ride the loadview. N.B. this won't work pre-yosemite. </p>
<pre><code>- (void)loadView {
NSLog(@"loadView");
self.view = [[NSView alloc] initWithFrame:
[[app.window contentView] frame]];
[self.view setAutoresizi... | 15,580 |
<p>Are there any major differences in performance between http and https? I seem to recall reading that HTTPS can be a fifth as fast as HTTP. Is this valid with the current generation webservers/browsers? If so, are there any whitepapers to support it?</p>
| <p>There's a very simple answer to this: <strong><em>Profile the performance of your web server to see what the performance penalty is for your particular situation.</em></strong> There are several tools out there to compare the performance of an HTTP vs HTTPS server (JMeter and Visual Studio come to mind) and they are... | <p>A more important performance difference is that an HTTPS session is ketp open while the user is connected. An HTTP 'session' lasts only for a single item request.</p>
<p>It you are running a site with a large number of concurrent users, expect to buy a lot of memory.</p>
| 17,992 |
<p>I have a simple webform that will allow unauthenticated users to input their information, including name. I gave the name field a limit of 50 characters to coincide with my database table where the field is <code>varchar(50)</code>, but then I started to wonder.</p>
<p>Is it more appropriate to use something like th... | <p><a href="http://webarchive.nationalarchives.gov.uk/20100407120701/http://cabinetoffice.gov.uk/govtalk/schemasstandards/e-gif/datastandards.aspx" rel="noreferrer">UK Government Data Standards Catalogue</a> suggests 35 characters for each of Given Name and Family Name, or 70 characters for a single field to hold the F... | <p>The average first name is about 6 letters. That leaves 43 for a last name. :) Seems like you could probably shorten it if you like.</p>
<p>The main question is how many rows do you think you will have? I don't think varchar(50) is going to kill you until you get several million rows.</p>
| 5,035 |
<p>DBD, and Oracle Masters:</p>
<p>I have a Perl web application that is behaving oddly. I am using it to read some stuff from an Oracle DB and report. I have version 11.1.0.6.0 of Oracle's Instant Client installed. I'm running on WinXP and have the PATH environment variable set to the instant client location. I ha... | <p>The fact that the error shows the full path of the .DLL suggests that the system isn't having any trouble finding the DLL, so that does back your theory that file permissions are the issue.</p>
<p>To test whether it really is a permissions issue, try writing a trivial Perl CGI script which does nothing but directly... | <p>Thanks Alnitak. I tried doing what you suggested, and 'open' successfully opened 'C:/usr/lib/auto/DBD/Oracle/Oracle.dll'. I remember seeing this exact bug when I was developing on a different machine, but that was because the Oracle Instant Client libs were mising on it. After I installed those, and set the 'Path... | 37,588 |
<p>I was given an assignment to basically explain this. I have taken a quick look at the compiler documentation, and it seems to be a good place to start although it is quite extensive and I don't have much time. I'd like to know if I'd need to understand the C99 standards beforehand, or if there's another good source ... | <p>AFAIK, g++ is simply a C/C++ compiler, nothing more. memory is managed according to the standard C/C++ libraries.</p>
| <p>g++ is just a compiler. It follows the rules of the language it compiles (In G++'s case, C++, but you also mention C99).</p>
<p>And for your fairly specific questions, you may need to</p>
<ul>
<li>Consult the language standard (For C++ this is ISO/IEC 14882 ). Unfortunately not free, but you can find drafts online... | 48,297 |
<p>I'm on a little quest of merging the structure of two MySql databases. Is there a tool for this with the might of Red-Gate's SQL Compare? Are there any free alternatives?</p>
| <p>although i dont have any experience with it, i hear that navicat would be the tool to use:</p>
<p><a href="http://mysql.navicat.com/" rel="nofollow noreferrer">https://www.navicat.com/en/products/navicat-for-mysql</a></p>
<p>also toad for mysql i hear isnt bad:</p>
<p><a href="http://www.quest.com/toad-for-mysql/... | <p>I've used Navicat for more than 3 years. It provides all the features that I need and save me tons of time for managing and developing MySQL and Oracle.</p>
<p>You can find a visual tutorial about Navicat's data/ structure synchronization at <a href="http://support.navicat.com/visual_tutorial/data_sync.html" rel="n... | 7,582 |
<p>How can I start an interactive console for Perl, similar to the <code>irb</code> command for Ruby or <code>python</code> for Python?</p>
| <p>You can use the perl debugger on a trivial program, like so:</p>
<pre><code>perl -de1
</code></pre>
<p>Alternatively there's <a href="http://search.cpan.org/~sukria/perlconsole-0.4/perlconsole" rel="noreferrer"><em>Alexis Sukrieh</em>'s Perl Console</a> application, but I haven't used it.</p>
| <p>You can do it online (like many things in life) here:</p>
<p><a href="https://www.tutorialspoint.com/execute_perl_online.php" rel="nofollow noreferrer">https://www.tutorialspoint.com/execute_perl_online.php</a></p>
| 9,939 |
<p>My question is, if an interface that is implemented implicitly by extending a class that already implements it, should be explicitly implemented by the class, if the class wants to advertise the fact, that it fulfills the contract of that interface. </p>
<p>For instance, if you want to write a class, that fulfills ... | <p>Avoid redundancy. Use method 2.</p>
<p>Use @Override for overrides.</p>
| <p>When you extend AbstractList, MyList is of 'type' List already, so there is no need to explicityly stat (or implement) the interface.</p>
| 47,350 |
<p>Given a Python object of any kind, is there an easy way to get the list of all methods that this object has?</p>
<p>Or,</p>
<p>if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is called?</p>
| <p><strong>For many objects</strong>, you can use this code, replacing 'object' with the object you're interested in:</p>
<pre class="lang-py prettyprint-override"><code>object_methods = [method_name for method_name in dir(object)
if callable(getattr(object, method_name))]
</code></pre>
<p>I discovere... | <p>You can make use of dir() which is pre-defined in Python.</p>
<pre><code>import module_name
dir(module_name)
</code></pre>
<p>You can also pass an object to dir() as</p>
<pre><code>dir(object_name)
</code></pre>
<p>If the object is an object of a pre-defined class such as int, str, etc. it displays the methods in it... | 5,468 |
<p>I need to convert a list (or a dict) into a comma-separated list for passing to another language.</p>
<p>Is there a nicer way of doing this than:</p>
<pre><code> result = ''
args = ['a', 'b', 'c', 'd']
i = 0
for arg in args:
if i != 0: result += arg
else: result += arg + ', '
i += 1
... | <pre><code>'function(%s)' % ', '.join(args)
</code></pre>
<p>produces</p>
<pre><code>'function(a, b, c, d)'
</code></pre>
| <p>Why not use a standard that both languages can parse, like JSON, XML, or YAML? <a href="http://pypi.python.org/pypi/simplejson" rel="nofollow noreferrer">simplejson</a> is handy, and included as json in python 2.6.</p>
| 45,437 |
<p>My application's context root is /foobar and I am running an exploded deployment with maven-jetty-plugin.</p>
<p>I need to dynamically remap requets for /images/* to /foobar/images/*, and I cannot remap my application's context root to /.</p>
<p>For weblogic I have a halfwit solution where I deploy an additional w... | <p>I don't think it can be done since TryUpdateModel, which UpdateModel uses, references the ControllerContext which is null when invoked from a unit test. I use RhinoMocks to mock or stub the various components needed by the controller.</p>
<pre><code>var routeData = new RouteData();
var httpContext = MockRepository... | <p>Or you can create form data proxy, like </p>
<pre><code>public class CountryEdit {
public String Name { get; set; }
public String Iso3166 { get; set; }
}
</code></pre>
<ul>
<li>Plus. Easy create unit tests</li>
<li>Plus. Define white list of fields update from post</li>
<li>Plus. Easy setup validation rules, e... | 43,017 |
<p>I have a C# application that includes the following code:</p>
<pre><code>string file = "relativePath.txt";
//Time elapses...
string contents = File.ReadAllText(file);
</code></pre>
<p>This works fine, most of the time. The file is read relative to the directory that the app was started from. However, in testin... | <p>If the file is always in a path relative to the executable assembly, then yes, use Assembly.Location. I mostly use Assembly.GetExecutingAssembly if applicable though instead of Assembly.GetEntryAssembly. This means that if you're accessing the file from a DLL, the path will be relative to the DLL path. </p>
| <p>If you use an openfiledialog and the remember path property (not sure about the exact name) is true then it will change your current directory I think.</p>
| 19,129 |
<p>I've been having trouble getting my ASP.NET application to automatically log users into the Intranet site I'm building. No matter the googling or the experimentation I applied, there is always a login box displayed by IE7.</p>
<p>I've got Windows authentication mode set in the Web.config, disabled anonymous access... | <p>It sounds like you've covered all the server-side bases--maybe it's a client issue? I assume your users have integrated authentication enabled in IE7? (Tools -> Internet Options -> Advanced -> Security). This is enabled by default.</p>
<p>Also, is your site correctly recognized by IE7 as being in the Local Intra... | <p>In IIS, enable annonymous access and allow the web.config to handle user authentication.</p>
| 2,308 |
<p>For a project I'm working on I would like the user to be able to drag a file from the desktop or windows explorer and drop it on a web page in IE and have it uploaded to the web server. I've read that its possible with ActiveX but have not found anything about it.</p>
<p>Anyone know how to do this and where I can g... | <p><a href="http://browserplus.yahoo.com/" rel="nofollow noreferrer">Browser Plus</a> from Yahoo.</p>
<p>Cross browser support, but needs an install.</p>
| <p>I think that for drag-n-drop to work the user will have to install a plugin. That's how it's done in services like <a href="http://www.projectplace.com" rel="nofollow noreferrer">Projectplace</a> at least.</p>
| 48,460 |
<p>Every time I try to run a small application that uses a Derby DB I get this error message:</p>
<blockquote>
<p><strong>Message: Database at /path/to/db/TheDB has an incompatible format with the current version of the software. The database was created by or upgraded by version 10.4.</strong></p>
</blockquote>
<... | <p>The version included with Netbeans might be old (Derby 10.2 as of NB 6.0). If you added Derby via the project properties and added the "Library", then you probably had the old version.</p>
<p>You can update the library by going to Tool -> Libraries. Select "Java DB Driver". Delete the jar references and update them... | <p>Hmmm, all I have to do was to add the proper derby.jar <strong>manually</strong> to the project.<br>
A simple copy command operation: </p>
<blockquote>
<p>cp /opt/Apache/derbyinstall/lib/<strong>derby.jar</strong> /path/to/project/<strong>dist/lib/</strong> </p>
</blockquote>
<p>...did the job.
The problem was... | 14,899 |
<p>There is one thing that I do not understand... </p>
<p>Imagine you have a <strong>text</strong> = "hello world" and you want to split it.</p>
<p>In some places I see people that want to split the <strong>text</strong> doing:</p>
<pre><code>string.split(text)
</code></pre>
<p>In other places I see people just do... | <p>Interestingly, the docstrings for the two are not completely the same in Python 2.5.1:</p>
<pre><code>>>> import string
>>> help(string.split)
Help on function split in module string:
split(s, sep=None, maxsplit=-1)
split(s [,sep [,maxsplit]]) -> list of strings
Return a list of the w... | <p>Use whichever you like, but realize that str.split is the recommended way of doing it. :-)</p>
<p>string.split is a tad older method of doing the same thing.</p>
<p>str.split is a bit more efficient (since you don't have to import the string module or look up any names from it), but not enough to make a huge diff... | 43,261 |
<p>I have a 2.4 MB XML file, an export from Microsoft Project (hey I'm the victim here!) from which I am requested to extract certain details for re-presentation. Ignoring the intelligence or otherwise of the request, which library should I try first from a Ruby perspective?</p>
<p>I'm aware of the following (in no pa... | <p><a href="http://code.whytheluckystiff.net/hpricot/wiki/HpricotBasics" rel="nofollow noreferrer">Hpricot</a> is probably the best tool for you -- it is easy to use and should handle 2mg file with no problem.</p>
<p>Speedwise libxml should be the best. I used libxml2 binding for python few months ago (at that moment ... | <p>Nokogiri wraps libxml2 and libxslt with a clean, Rubyish API that supports namespaces, XPath and CSS3 queries. Fast, too.
<a href="http://nokogiri.org/" rel="nofollow noreferrer">http://nokogiri.org/</a></p>
| 15,366 |
<p>I'm trying to design a camera handle, which will be around 8" long and will have a brass camera thread insert in the end, where the camera will be mounted. (That way, I don't have to screw the camera thread into plastic which will wear out faster.)</p>
<p>If I print the handle normally, the end of the handle won't... | <p>I think you are approaching this wrong. Sounds like you need to design it to have a hollow wall. That said to answer your question no you cannot have your slicer modify prints like that. But it bears mentioning you can set all shells to what ever you want have have a very sparse infill. To you can set vertical shell... | <p>I believe the solution is to use more walls in Cura.</p>
<p>Here is a 50mm cylinder with a 20mm hole. I specified 10 walls in Cura.</p>
<p>This should give extra plastic for the screw to bit into, but not take all day to print!</p>
<p><a href="https://i.stack.imgur.com/cItxw.png" rel="nofollow noreferrer"><img s... | 464 |
<p>I'm attempting to print some flexible TPE filament. But I failed to imagine TPE was this difficult to print.</p>
<p>Specs of the shop-brand filament:<br>
Red 1.75 mm TPE (+-0.05 mm).<br>
Hardness: 45D.<br>
Print temperature: 220-260 °C with 0-95 °C bed.</p>
<p>I'm trying to print <a hre... | <p>I have experienced this problem. This picture is one that I could have taken. </p>
<p>It has always been because I was putting too much plastic into the available space.</p>
<p>This has been caused two things: overextrusion -- squirting out too much plastic for the intended layer height, and the bed being too "hi... | <p>This could be a number of things, I personally think it could be either over extrusion or an issue with one of the belts. Depending on the printer, you may need to manually go in and adjust your steps per millimeter, which you should be able to find a guide on. If that doesn't work, then look into belt tension adjus... | 1,395 |
<p>I'm trying to unit test a custom ConfigurationSection I've written, and I'd like to load some arbitrary configuration XML into a <a href="http://msdn.microsoft.com/en-us/library/system.configuration.configuration.aspx" rel="noreferrer">System.Configuration.Configuration</a> for each test (rather than put the test co... | <p>There is actually a way I've discovered....</p>
<p>You need to define a new class inheriting from your original configuration section as follows:</p>
<pre><code>public class MyXmlCustomConfigSection : MyCustomConfigSection
{
public MyXmlCustomConfigSection (string configXml)
{
XmlTextReader reader ... | <p>Looking at the members of the class, I'd say the answer is probably no*. I'm not sure why you'd want to do this anyway, rather than create your own XML configuration file.</p>
<p>*That's no, excluding messy reflection hacks</p>
| 4,132 |
<p>I am building an app that talks to an Access database via OleDB/Jet. There is only a 32-bit Jet provider, no 64-bit provider, so the app needs to be running in 32-bit mode. My dev box is Vista 64, so I set the project to build for x86 instead of any cpu. That gets my app running and talking to the database.</p>
<p>... | <p>Turns out the trick was using CorFlags.exe to mark Gallio.Host.exe as 32bit only.</p>
| <p>Isn't Gallio open source? You could download and build (and sign if necessary) to suit your needs, or am I missing something, should I get my coat?</p>
<p><a href="http://www.gallio.org/Development.aspx" rel="nofollow noreferrer">http://www.gallio.org/Development.aspx</a><a href="http://www.gallio.org/Development.a... | 24,837 |
<p>I am not trying to make this a preference question, I am really wondering what people's experiences are with using jQuery and Rails or jRails for development. Most rails users including myself up to now have been using Prototype. However, I am mixing in a lot of jQuery plugins since they are so easy to use and ext... | <p>In Rails it really all comes down to the helper methods. Are you using any prototype helper methods? If so then you must use jRails to switch to jQuery. But if not then it really does not matter. They are both great. I used prototype a lot before and it is great. But I prefer the selector way of doing things with jQ... | <p>Do you use prototype for things other then the rjs files and other javascript helpers? If so then you will need to determine if you want to rewrite thoose in jQuery. Otherwise, you can just use jRails to take care of any rjs helpers and you will not even notice a difference.</p>
<p>I have been using jRails and love... | 47,394 |
<p>Does anyone know a keyboard shortcut to close all tabs except for the current one in Visual Studio? And while we're at it, the shortcut for closing all tabs? Is there a Resharper option for this? I've looked in the past and have never been able to find it. </p>
| <p>I don't think there is one by default, but you can go to Tools>Options>Environment>Keyboard and bind a key to File.CloseAllButThis.</p>
<p>I use <kbd>ctrl</kbd>+<kbd>alt</kbd>+<kbd>w</kbd></p>
| <p>I follow <a href="https://stackoverflow.com/questions/97279/keyboard-shortcut-to-close-all-tabs-but-current-one-in-visual-studio#97298">aarojensen's method</a>, but put it in the file menu (right click on the menu and select customize). Then <kbd>Alt</kbd>-<kbd>F</kbd>-<kbd>B</kbd> closes all but the current.</p>
| 12,275 |
<p>I have a site that users upload images to. Those images are resized to various dimensions. I currently do that on my server, but was thinking of processing that on AWS or something similar. Is that a good idea?</p>
| <p>I've been using EC2 and dedicated servers for similar tasks, and here are some tips:</p>
<ol>
<li><p>Use as little IO as possible. If you intend on using things like ImageMagick, know that writing to disk is a waste of io resources (unless you want to cache it anyway.) PHP/GD lets you send jpeg directly in http res... | <p>You could use an EC2 server to do the resizing and store them in S3 if you anticipate the need for a large scale out and load.
Ultimately, It would would depend on alot of factors depending on your growth and budget. What is the current load on your server and are you near capacity? What is the size and amount of CP... | 29,221 |
<p>I'm creating a zip file using the class FastZip from SharpZipLib and once I after I close the program, I cannot delete the file because:</p>
<p>"Cannot delete zip.zip: It is being used by another person or program. Close any programs that might be using the file and try again."</p>
<p>The code that is generating t... | <p>Perhaps antivirus is busy checking the file? If not, then get a program that can tell you which programs have files open.</p>
<p>You can look at:</p>
<ul>
<li><a href="http://www.emptyloop.com/unlocker/" rel="nofollow noreferrer">Unlocker</a></li>
<li><a href="http://www.iarsn.com/" rel="nofollow noreferrer">IARSN... | <p>I'm not familier with the FastZip API (so this is just a punt) but do you need to close the archive with something like fZip.Close();</p>
<p>I would have thought that closing the program would have done the same thing but just a guess.</p>
| 44,206 |
<p>I would like invoke a function call in a one shot manner. What's the best way to do this in Boost / C++?</p>
<p>I would like to pass it two parameters and do not need a result.</p>
| <p>Well you can spin up a thread and then never join it again. Something like:</p>
<pre><code>boost::thread some_thread(&SomeFunction, param1, param2);
</code></pre>
<p>Once the some_thread variable goes out of scope, the thread of execution will be detached and will not be able to be joined again. It's a waste t... | <p>Perhaps you want to emit a signal?</p>
<p>I really liked Qt's signals and slots functionality, and I know Boost has signals/slots as well. I've never used signals/slots in Boost, though.</p>
| 18,781 |
<p>We're contemplating Visual Studio licensing and need to decide whether licenses for Architecture/Database/Test editions are necessary. Does anyone have enough experience with these tools to say whether they are useful? I'd love some specific examples.</p>
<p>I'll also accept links to non Microsoft sites that prov... | <p>The database edition proved invaluable to us when getting our 2 databases with 200+ tables under source control and including the databases in the continuous integration builds. This edition also include data and schema compare and lots other features that really changed the way we handled our databases</p>
| <p>I'm using the Developers edition; I can't speak about the others except in one important point.</p>
<p>Back in VSTS 2005, the only way to do continuous integration in Team Foundation Server was to write a test list. The only way to write a test list was to have VSTS for Testers, write the XML by hand, or purchase ... | 43,935 |
<p>I have a large existing c++ codebase. Typically the users of the codebase edit the source with gvim, but we'd like to start using the nifty IDE features in Eclipse. The codebase has an extensive directory hierarchy, but the source files use include directives without paths due to some voodoo we use in our build pr... | <p>The way that CDT manages build paths is by looking at the .cdtbuild xml file in the base of your projects directory (it might be a different name on windows... not sure)</p>
<p>In this you should see something like</p>
<pre><code><option id="gnu.c.compiler.option.include.paths....>
<listoptionValue builtI... | <p>Depending on the amount of voodoo you are doing in your build process, then Eclipse may not be able to correctly parse your source files, especially if you have similarly named headers for different source files. If you really want to take full advantage of Eclipse you're going to need to make sure that with whateve... | 34,532 |
<p>I've developed a Windows service which tracks business events. It uses the Windows clock to timestamp events. However, the underlying clock can drift quite dramatically (e.g. losing a few seconds per minute), particularly when the CPUs are working hard. Our servers use the Windows Time Service to stay in sync with d... | <p>Clock ticks should be predictable, but on most PC hardware - <em>because</em> they're not designed for real-time systems - other I/O device interrupts have priority over the clock tick interrupt, and some drivers do extensive processing in the interrupt service routine rather than defer it to a <a href="http://en.wi... | <p>What servers are you running? In desktops the times I've come across this are with Spread Spectrum FSB enabled, causes some issues with the interrupt timing which is what makes that clock tick. May want to see if this is an option in BIOS on one of those servers and turn it off if enabled.</p>
<p>Another option y... | 12,762 |
<p>I'm currently trying to port a SIP stack library (pjSIP) to the PSP Console (using the PSPSDK toolchain), but I'm having too much trouble with the makefiles (making the proper changes and solving linking issues). </p>
<p>Does anyone know a good text, book or something to get some insight on porting libraries?</p>
... | <p>Look at other libraries that were ported over to the PSP. Doing diffs between a linux version of a library, and a PSP version should show you.</p>
<p>Also, try to get to know how POSIX compatible the PSP is, that will tell you how big the job of porting the library over is.</p>
| <p>I did some more research and found this post at ps2dev forum:</p>
<blockquote>
<p>The PSP is not a Unix system, and the pspsdk is not POSIX compliant. It's close in some places, but you can't expect to just take any code that compiles fine on a POSIX system and have it work. For example:</p>
<ul>
<li>pspsd... | 11,523 |
<p>Is there a way through the .net framework to determine if a folder is shared or not?</p>
<p>Neither Diretory, DirectoryInfo or FileAttributes seem to have any corresponding field.</p>
<p>One thing I forgot to mention was that I want to be checking for network shares. But I'll investigate the WMI stuff.</p>
| <p>You can use WMI Win32_Share.
Take a look at:</p>
<p><a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=408923" rel="nofollow noreferrer">http://www.gamedev.net/community/forums/topic.asp?topic_id=408923</a></p>
<p>Shows a sample for querying, creating and deleting shared folders.</p>
| <p>Try using WMI and doing a <code>SELECT * FROM Win32_ShareToDirectory</code> query.</p>
| 16,524 |
<p>I've been looking at ways to implement gmail-like messaging inside a browser, and arrived at the <a href="http://en.wikipedia.org/wiki/Comet_(programming)" rel="noreferrer">Comet</a> concept. However, I haven't been able to find a good .NET implementation that allows me to do this within IIS (our application is writ... | <p>Comet is challenging to scale with IIS because of comet's persistent connectivity, but there is a team looking at Comet scenarios now. Also look at <a href="http://www.aaronlerch.com/blog/2007/07/08/creating-comet-applications-with-aspnet/" rel="noreferrer">Aaron Lerch's blog</a> as I believe he's done some early Co... | <p>I think the Comet approach isn't really scalable unless you are prepared to expand the web farm horizontally (by adding more web servers to the mix). The way it works is that it leaves a TCP connection open per user session, just so the server can push stuff into that connection from time to time to immediately info... | 9,137 |
<p>So, I want to define a singleton method for an object, but I want to do it using a closure.</p>
<p>For example,</p>
<pre><code>def define_say(obj, msg)
def obj.say
puts msg
end
end
o = Object.new
define_say o, "hello world!"
o.say
</code></pre>
<p>This doesn't work because defining a singleton method via... | <p>Here's an answer which does what you're looking for</p>
<pre><code>def define_say(obj, msg)
# Get a handle to the singleton class of obj
metaclass = class << obj; self; end
# add the method using define_method instead of def x.say so we can use a closure
metaclass.send :define_method, :say do
pu... | <p>Here's an answer which does what you're looking for</p>
<pre><code>def define_say(obj, msg)
# Get a handle to the singleton class of obj
metaclass = class << obj; self; end
# add the method using define_method instead of def x.say so we can use a closure
metaclass.send :define_method, :say do
pu... | 16,463 |
<p>I've been digging through some parts of the Linux kernel, and found calls like this:</p>
<pre><code>if (unlikely(fd < 0))
{
/* Do something */
}
</code></pre>
<p>or</p>
<pre><code>if (likely(!err))
{
/* Do something */
}
</code></pre>
<p>I've found the definition of them:</p>
<pre><code>#define likel... | <p>They are hint to the compiler to emit instructions that will cause branch prediction to favour the "likely" side of a jump instruction. This can be a big win, if the prediction is correct it means that the jump instruction is basically free and will take zero cycles. On the other hand if the prediction is wrong, the... | <p>They're hints to the compiler to generate the hint prefixes on branches. On x86/x64, they take up one byte, so you'll get at most a one-byte increase for each branch. As for performance, it entirely depends on the application -- in most cases, the branch predictor on the processor will ignore them, these days.</p>... | 13,492 |
<p>I am having difficulty with the following method. I can't figure out if my problem is, but I have narrowed it down to not populating the array list from the file. Any help is greatly appreciated.</p>
<pre><code>private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {
//create arraylists
ArrayLi... | <p>Aside from all the other problems people have listed...</p>
<pre><code>String pass = "";
while(flag = false) {
if(outputline.charAt(i) != ',')
pass.concat(Character.toString(outputline.charAt(i)));
</code></pre>
<p>pass is a String. Strings are immutable. You want</p>
<pre><code> pass = pass.concat(.....)
</... | <p>I would suggest you restructure the code. The issue is not just that there's some sort of parser error, but that it's sort of hard to tell what's going on - the code is clearly making assumptions about the structure of the input line, but you have to kind of read through and trace the method to restructure it in you... | 47,210 |
<p>How can I, as the wiki admin, enter scripting (Javascript) into a Sharepoint wiki page?<br><br>
I would like to enter a title and, when clicking on that, having displayed under it a small explanation. I usually have done that with javascript, any other idea?</p>
| <p>If the wiki authors are wise, there's probably no way to do this.</p>
<p>The problem with user-contributed JavaScript is that it opens the door for all forms of evil-doers to grab data from the unsuspecting.</p>
<p>Let's suppose evil-me posts a script on a public web site:</p>
<pre><code>i = new Image();
i.src = ... | <p>That sounds like a security risk. It seems it's possible for the wiki admin to install scripts, see <a href="http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts" rel="nofollow noreferrer">wikipedia's user scripts</a>. </p>
| 11,325 |
<p>Erasing programs such as Eraser recommend overwriting data maybe 36 times.</p>
<p>As I understand it all data is stored on a hard drive as 1s or 0s.</p>
<p>If an overwrite of random 1s and 0s is carried out once over the whole file then why isn't that enough to remove all traces of the original file?</p>
| <p>A hard drive bit which used to be a 0, and is then changed to a '1', has a slightly weaker magnetic field than one which used to be a 1 and was then written to 1 again. With sensitive equipment the previous contents of each bit can be discerned with a reasonable degree of accuracy, by measuring the slight variances ... | <p>There are "disk repair" type applications and services that can still read data off a hard drive even after it's been formatted, so simply overwriting with random 1s and 0s one time isn't sufficient if you really need to securely erase something.</p>
<p>I would say that for the average user, this is more than suffi... | 8,432 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.