instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I've just inherited a java application that needs to be installed as a service on XP and vista. It's been about 8 years since I've used windows in any form and I've never had to create a service, let alone from something like a java app (I've got a jar for the app and a single dependency jar - log4j). What is the m... | <p>I've had some luck with <a href="http://wrapper.tanukisoftware.org/doc/english/introduction.html" rel="noreferrer">the Java Service Wrapper</a></p>
| <p>It's possible to implement a Windows service in 100% Java code by combining the use of <a href="https://jdk.java.net/panama/" rel="nofollow noreferrer">Foreign Memory and Linker API</a> (previewing from JDK16 upwards) with <a href="https://github.com/openjdk/jextract" rel="nofollow noreferrer">OpenJDK jextract proje... | 9,362 |
<p>I have an app that run on many computers and connect to sql server
I want to log the machine names of that computers in a table every time they connect how can I do that</p>
<p>I want to know if there is a command like that</p>
<p>"Select @@MachineName"</p>
| <p>It's up to you how you want to log this information, but <a href="http://msdn.microsoft.com/en-us/library/ms178598(SQL.90).aspx" rel="nofollow noreferrer">HOST_NAME()</a> returns the name of the workstation connecting to the server.</p>
| <p>Create linked server : (allowing access to distributed, heterogeneous queries against OLE DB data sources.) using following command :</p>
<blockquote>
<p>sp_addlinkedserver [ @server= ] 'server' [ , [ @srvproduct= ] 'product_name' ]
[ , [ @provider= ] 'provider_name' ]</p>
<pre><code> [ , [ @datasrc= ] 'd... | 45,414 |
<p>Or are they two distinct applications that are not related?</p>
| <p>They are very different, although some people push the list of source control commits or latest files (head) to their team wiki (which could be SharePoint)</p>
| <p>I believe they are unrelated but both use SQL Server as their backend.</p>
| 21,169 |
<p>You can have different naming convention for class members, static objects, global objects, and structs. Some of the examples of them are as below.</p>
<pre><code>_member
m_member
</code></pre>
<p>or in Java case, the usage of <code>this.member</code>.</p>
<p>But is there any good technique or naming convention f... | <p>I actually encourage delegating this task to the IDE/editor you use.</p>
<p>No, I'm not actually talking about naming variables, that is still best done by a human. But the underlying task of such naming strategies is to show you which type of variable any one name represents.</p>
<p>Pretty much every IDE worth it... | <p>It really all comes down to whatever the style guidelines for the language suggest if there are any.</p>
| 18,268 |
<p>I made a custom printer with RAMPS. I used Y-MIN endstop at beginning. After few prints I discovered that Y-axis was inverted (mirrored).</p>
<p>I fixed Marlin firmware and now I have:</p>
<pre><code>#define Y_MAX_ENDSTOP_INVERTING true
#define INVERT_Y_DIR false
#define Y_HOME_DIR 1
#define USE_YMAX_PLUG
</code><... | <p>This <a href="https://www.everybitelectronics.co.uk/blog/3d-printer-error-prints-reversed/" rel="nofollow noreferrer">blog post</a> shows 3 main solutions:</p>
<ol>
<li>Flipping the motor cables (As suggested in the other answer)</li>
<li>Switching the x and y-axis:
This may switch the direction of your y-axis depe... | <p>Usually I just flip the connector around on the board. This causes the stepper to reverse without fiddling around with firmware.</p>
| 1,601 |
<p>I have a plugin for OpenFire that creates and delivers a message to a user using</p>
<pre><code>XMPPServer.getInstance().getMessageRouter().route(message)
</code></pre>
<p>What I would like to know is what happens to that message if the user is not online. </p>
<p>My goal is to only have the message delivered if... | <p>It's all down to Openfire config. In the Openfire admin console, go to Server -> Server Settings -> Offline Messages. There are options for store, bounce and drop. </p>
<ul>
<li>Store: deliver the message when the
user comes back online.</li>
<li>Drop: Just discard the message.</li>
<li>Bounce: Discard and notify t... | <p>Another approach, if you just want these messages to not go offline without affecting the delivery of other messages, is to use type='headline'. Headlines are not terribly well-specified, but <a href="http://xmpp.org/internet-drafts/draft-saintandre-rfc3921bis-07.html#message-syntax-type" rel="nofollow noreferrer">... | 30,761 |
<p>Here is a VB.NET code snippet</p>
<pre><code>Public Class OOPDemo
Private _strtString as String
Public Function Func(obj as OOPDemo) as boolean
obj._strString = "I can set value to private member using a object"
End Function
End Class
</code></pre>
<p>I thought we cannot access the private me... | <pre><code>Image imgControl = new Image();
Grid.SetColumn(imgControl, 1);
gridContainer.Children.Add(imgControl);
</code></pre>
<p>Objects contained in a grid are positioned based on the attached dependency properties Column Row ColumnSpan and RowSpan which are set as shown above.</p>
| <p>The row/column index on an element in WPF is an attached property. You set it using a static method on Grid, like this:</p>
<pre><code>Grid.SetColumn(img, 1);
</code></pre>
<p>More info <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.grid.setcolumn.aspx" rel="noreferrer">here</a>, and more... | 45,041 |
<p>I'm looking at the source code for the .net membership provider, and it sqlmembershipprovider.cs there are calls to EncryptPassword and DecryptPassword but I don't see the method anywhere in the source.</p>
<p>What algorithm are they using? Isn't the source for that released also?</p>
| <p>SqlMembershipProvider derives from MembershipProvider from which it inherits EncryptPassword() and DecryptPassword().</p>
<p>Looking though the code with Reflector, it looks like the algorithm is DES if the key is 8 bytes long and AES (Rijndael) otherwise.</p>
| <p>SqlMembershipProvider uses System.Web.Security.MembershipProvider as its base class. The EncryptPassword and DecryptPassword methods are being called on the base class.</p>
<p>Fire up .NET Reflector and point it at System.Web.Security.MembershipProvider and you'll see how they do it.</p>
| 35,558 |
<p>How do I open multiple pages in Internet Explorer 7 with a single DOS command? Is a batch file the only way to do this?</p>
<p>Thanks!</p>
| <p>A batch file will work as a quick and dirty solution.</p>
<pre><code>@echo off
@setlocal
:openurl
set url=%~1
if "%url:~0,4%" == "http" (
start "%ProgramFiles%\Internet Explorer\iexplore.exe" "%url%"
)
if NOT "%url:~0,4%" == "http" (
start "%ProgramFiles%\Internet Explorer\iexplore.exe" "http://%url%"
)
sh... | <p>Unfortunately, there is no way to include multiple URLs as command-line parameters. Here is a a <a href="http://blogs.msdn.com/tonyschr/archive/2007/01/19/ie-automation-amp-tabs.aspx" rel="nofollow noreferrer">blog post</a> which details another (fairly convoluted) way to do it via Javascript.</p>
| 14,459 |
<p>I recently read a nice <a href="http://macdevelopertips.com/ruby/using-a-string-as-a-file-in-ruby.html" rel="noreferrer">post</a> on using <code>StringIO</code> in Ruby. What the author doesn't mention, though, is that <code>StringIO</code> is just an "I." There's no "O." You <em>can't</em> do this, for example:<... | <p>I looked at the ruby documentation for <code>StringIO</code>, and it looks like what you want is <a href="http://ruby-doc.org/stdlib/libdoc/stringio/rdoc/classes/StringIO.html#method-i-string" rel="noreferrer"><code>StringIO#string</code></a>, not <code>StringIO#to_s</code></p>
<p>Thus, change your code to:</p>
<p... | <p>Well, a StringBuffer is not quite as necessary in Ruby, mainly because Strings in Ruby are mutable... thus you can build up a string by modifying the existing string instead of constructing new strings with each concat.</p>
<p>As a note, you can also use special string syntax where you can build a string which refe... | 3,156 |
<p>In Matlab, how can I find value of K, in a system that has oscillation?</p>
<blockquote>
<p>(system's tf, if needed: (K * (s +
25))/(s^3 + 24 s^2 + 100 s) )</p>
</blockquote>
<p>PS. I'm using root locus.</p>
| <p>I assume this is the plant for a closed-loop system with gain compensation only (that would be K). In that case I would express it as a transfer function and then use the root-locus command to see where it hits on the x-axis:</p>
<pre><code>num = [1 25];
den = [1 24 100 0];
sys=tf(num,den)
rlocus(sys)
</code></pr... | <p>Does the <code>dcgain</code> function do what you need?</p>
| 47,909 |
<p>I need to make sure that user can run only one instance of my program at a time.<br>
Which means, that I have to check programatically, whether the same program is already running, and quit in such case.</p>
<p>The first thing that came to my mind was to create a file somewhere, when the program starts. Then, each ... | <p>There are several methods you can use to accomplish only allowing one instance of your application:</p>
<p><strong>Method 1: Global synchronization object or memory</strong></p>
<p>It's usually done by creating a named global mutex or event. If it is already created, then you know the program is already running.<... | <p>I don't have a good solution, but two thoughts:</p>
<ol>
<li><p>You could add a ping capability to query the other process and make sure it's not an unrelated process. Firefox does something similar on Linux and doesn't start a new instance when one is already running.</p></li>
<li><p>If you use a signal handler, ... | 20,644 |
<p>I'm new to both ASP.Net MVC and jQuery and what I'm trying to do is make a form that either adds a new RockBand or updates an existing RockBand based on if the rockbandid is an empty guid or not. I figured now is a good time to get rolling with jQuery. So the first step is to make a list of bands and put an edit l... | <p>Just to elaborate a little further to what Frans has said...Even though the ListBox owns the ContextMenuStrip, you can still customize the items in the menu strip at the time it's opening. Thus customizing it's contents based on the mouse position within the listbox.</p>
<p>The example below selects the item in the... | <pre><code>//Create and Initialize the contextMenuStrip component
contextMenuStrip_ListaAulas = new ContextMenuStrip();
//Adding an Item
contextMenuStrip_ListaAulas.Items.Add("Modificar");
//Binding the contextMenuStrip with the ListBox
listBox_Aulas.ContextMenuStrip = contextMenuStrip_ListaAulas;
//The solution bel... | 49,342 |
<p>This question regards unit testing in Visual Studio using MSTest (this is important, because of MSTest's <a href="http://blogs.msdn.com/nnaderi/archive/2007/02/17/explaining-execution-order.aspx" rel="noreferrer">execution order</a>). Both the method marked [TestInitialize] and the test class constructor will run be... | <p>The constructor is just a structure provided by the language. Every test framework seems has its own controlled lifecycle "initialize". You'll probably only get into trouble using the constructor to mutate your locals.</p>
<p><strong>MSTest:</strong> You get an entire new instance of the test class for every <code>... | <p>It depends on the scenario. If you have a test class, and for some weird reason if you need to create instance of it on another test class, you will need to use constructor.</p>
<p>Otherwise test initialize more fits in the concept. Firstly, same reasons written above, second MS can introduce more features on that ... | 43,375 |
<p>Inside my page, I have the following:</p>
<pre><code><aspe:UpdatePanel runat="server" ID="updatePanel">
<ContentTemplate>
<local:KeywordSelector runat="server" ID="ksKeywords" />
</ContentTemplate>
</aspe:UpdatePanel>
</code></pre>
<p>The <code>KeywordSelector</code> c... | <p>Well, I've found the problem(s):</p>
<ol>
<li><p><em>User Controls</em>, as opposed to <em>Custom Controls</em> must be registered one-by-one in the <em>web.config</em> file. Do this:</p>
<p><code><add tagPrefix="local" tagName="KeywordSelector" src="~/KeywordSelector.ascx" /></code></p>
<p>instead of:</p>... | <p>In my case the reason was the Resharper 7.1 added incorrect @Register directive at the top of aspx - instead of this desired row:</p>
<pre><code><%@ Register Src="~/Controls/Hello/Hello.ascx" TagName="Hello" TagPrefix="p" %>
</code></pre>
<p>i got wrong one:</p>
<pre><code><%@ Register TagPrefix="p" Name... | 30,130 |
<p>I'm looking for a good ocaml parsing library that isn't a derivative of flex/bison. Ideally, I'd like a monadic combinator library along the lines of parsec, but I can't find anything.</p>
<p>I would use haskell, but making llvm bindings for haskell is proving more tiresome than I originally thought.</p>
<p>Cheers... | <p><a href="http://ocaml-batteries-team.github.com/batteries-included/hdoc/BatParserCo.html" rel="noreferrer">Here's one library</a>, via Google. (Which also brought up <a href="http://osp.janestreet.com/files/pcl.pdf" rel="noreferrer">this</a> and <a href="http://caml.inria.fr/cgi-bin/hump.en.cgi?sort=0&browse=96"... | <p>In the OCaml world, <a href="http://www.ffconsultancy.com/ocaml/benefits/parsing.html" rel="nofollow noreferrer">stream-based parsers</a> and <a href="http://brion.inria.fr/gallium/index.php/Full_parser_tutorial" rel="nofollow noreferrer">Camlp4</a> are the next two most common alternatives. Both have been described... | 39,577 |
<p>I've written a small service (plain Win32) and I'd like to know if it's possible to run multiple instances of it when multiple users are logged on.</p>
<p>Basically, let's say we've got UserA and UserB for UserA the service would log on as "domain\UserA" and for UserB the service would log on as "domain\UserB" - th... | <p>Win32 services are designed to be system-wide, and start running before any user is logged in. If you want something to run on a per-user basis, it's probably better to design it as a regular application and run it from the user's Startup group.</p>
| <p>The whole concept of a service is that it is started before any user is even logged on. so even if this was possible, you wouldn't be able to choose between userA and userB when the service starts because none of them is logged on yet.</p>
<hr>
<p>A possible direction would be for the service to run as SYSTEM And ... | 13,838 |
<p>I noticed in another post, someone had done something like:</p>
<pre><code>double d = 3.1415;
int i = Convert.ToInt32(Math.Floor(d));
</code></pre>
<p>Why did they use the convert function, rather than:</p>
<pre><code>double d = 3.1415;
int i = (int)d;
</code></pre>
<p>which has an implicit floor and convert.</p... | <p>Casting to int is implicit truncation, not implicit flooring:</p>
<pre><code>double d = -3.14;
int i = (int)d;
// i == -3
</code></pre>
<p>I choose Math.Floor or Math.Round to make my intentions more explicit.</p>
| <p>You can use Convert when you have a string that you want to convert to an int </p>
<pre><code>int i = Convert.ToInt32("1234");
</code></pre>
<p>Convert and casting will both throw an exception if they fail.</p>
<p>i.e, this will still throw an exception, it will not return 0:</p>
<pre><code>Convert.ToInt32("1234... | 12,961 |
<p>I'm trying to import some data from Excel to SQL Server, I have a TEXT column with some numbers in it, some of the numbers go over just fine, and some turn into scientific form.</p>
<p>Column in Excel is "text" type, column in the target sql table is varchar(255)</p>
<p>Here are some examples: </p>
<p>Excel [text... | <p>There's not really a better way than that, though I tend to put the looping part into a <code>CopyTo</code> extension method, e.g.</p>
<pre><code>public static void CopyTo(this Stream source, Stream destination)
{
var buffer = new byte[0x1000];
int bytesInBuffer;
while ((bytesInBuffer = source.Read(buff... | <p>Now that I think about it, I haven't ever seen any built-in support for piping the results of an input stream directly into an output stream as you're describing. <a href="http://msdn.microsoft.com/en-us/magazine/cc163290.aspx" rel="nofollow noreferrer">This article on MSDN</a> has some code for a "StreamPipeline" c... | 40,803 |
<p>Im using delphi's ttreeview as an 'options' menu. how would i go upon selecting the next node at runtime like a previous and next button? i tried the getprev and getnext methods but no luck.</p>
| <p>Here you have the 'Next' behavior. For 'Previous' I leave as exercise for you: :-)</p>
<pre><code>procedure TForm8.btn1Click(Sender: TObject);
var
crt: TTreeNode;
begin
with tv1 do //this is our tree
begin
if Selected=nil then
crt:=Items[0] //the first one
else
crt:=Selected.GetNext; ... | <p>here is another way to do this:</p>
<pre><code>type TfrmMain = class(TForm)
...
public
DLLHandle : THandle;
function GetNodePath(node: TTreeNode; delimiter: string = '\') : String;
...
function TfrmMain.GetNodePath(node: TTreeNode; delimiter: string = '\') : String;
begin
Result:='';
while As... | 20,684 |
<p>In particular, I'm editing the AutoCompletion.plist file for CSSEdit (if that even matters).</p>
<p>My question is, are there any characters withing the STRING elements that need to be escaped? spaces? quotes?</p>
<p>EDIT:
Just to be clear, I'm not using CSSEdit to edit the file - rather the file is part of the CS... | <p>If you're editing an XML plist using a text editor of some sort, you'll need to escape characters just like in any XML. The basic characters to watch out for are:</p>
<p>< (less than), escaped as &lt;</p>
<p>> (greater than), escaped as &gt;</p>
<p>& (ampersand), escaped as &amp;</p>
<p>' (apo... | <p>There are 3 types of plists, and the escaping rules depend on type you are working with. The most common form are XML plists, which do require certain things to be escaped. In general you can use XML escaping rules within the string elements. If you are working with older NextStep style plists I believe much less ne... | 32,015 |
<p>I have a csv file of the format:</p>
<pre><code>270291014011 ED HARDY - TRUE TO MY LOVE - Cap NEU 2008 NEU 0,00 € 0,00 € 0 1 0 22.10.2008 03:37:10 21.11.2008 02:37:10 21.11.2008 02:42:10 50 0 0 0 39,99 € http://i7.ebayimg.com/02/i/001/16/0d/68af_1.JPG?set_id=800005007 0 2 8.10.2008 13... | <p>Here's the Perl for removing the non-p tags--it won't work across lines though</p>
<pre><code>perl -pe 's/<\/?(?>[^p]|p\w+)[^>]*>//ig'
</code></pre>
<p>That will print it out to standard out and you can redirect it from there. </p>
<p>If you have only one link, you could do this:</p>
<pre><code>perl ... | <p>Use <A HREF="http://xmlstar.sf.net/" rel="nofollow noreferrer">xmlstarlet</A> to filter out the tags you want; as it knows XML syntax (which is considerably more complex than can be correctly captured in a regex), it isn't prone to failure in corner cases like nested tags, and can decode <code>&amp;</code> and k... | 34,243 |
<p>I have some javascript menu code that works just fine from a separate directory.
But, when I try to call the same .js files from within the same directory, it won't see the files.</p>
<p>The following works from another directory:</p>
<p>script type="text/javascript"> var <strong>vbImgPath="../00-Menu-Files/"</str... | <p>Usually directories are like this:</p>
<p>../ one up</p>
<p>/ root directory</p>
<p>./ The current directory. However not adding anything to the front should mean the same.</p>
| <p>Maybe you'd use:</p>
<pre><code>script type="text/javascript"> var vbImgPath="00-Menu-Files/"
</code></pre>
<p>You may want to make this work anywhere by using absolute urls with a / at the beginning and the full path afterwards, ie.</p>
<pre><code>script type="text/javascript"> var vbImgPath="/00-Menu-File... | 41,425 |
<p>I've use Moq to mock my <a href="http://martinfowler.com/eaaCatalog/repository.html" rel="nofollow noreferrer">repositories</a>. However, someone recently said that they prefer to create hard-coded test implementations of their repository interfaces.</p>
<p>What are the pros and cons of each approach?</p>
<p><stro... | <p>I generally see two scenarios with repositories. I ask for something, and I get it, or I ask for something, and it isn't there.</p>
<p>If you are mocking your repository, that means you system under test (SUT) is something that is using your repository. So you generally want to test that your SUT behaves correctl... | <p>I assume that by "repository" you mean a <a href="http://en.wikipedia.org/wiki/Data_Access_Object" rel="nofollow noreferrer">DAO</a>; if not then this answer won't apply.</p>
<p>Lately I've been making "in memory" "mock" (or test) implementations of my DAO, that basically operate off of data (a List, Map, etc.) pas... | 46,916 |
<p>I just installed the SharePoint SDK on my machine, but I can't seem to find the location of Microsoft.Sharepoint.dll so I can add a reference to it.</p>
<p>It's not in the GAC or C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\ and a search comes up with nothing.</p>
<p>Any suggestion... | <p>Just FYI, I found it on the server where SharePoint was installed at:</p>
<p>E:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI</p>
| <p>It might show up in the "add reference" dialog anyway - 99% of the time you don't reed to know the physical location. Look in the ".Net" list, which is sorted alphabetically.</p>
<p>I assume the SDK installer would assert this, but Sharepoint development also requires a server OS.</p>
| 43,146 |
<p>How is possible to set some special column values when update/insert entities via NHibernate without extending domain classes with special properties?</p>
<p>E.g. every table contains audit columns like CreatedBy, CreatedDate, UpdatedBy, UpdatedDate. But I dont want to add these poperties to the domain classes. I w... | <p>You might want to try looking into NHibernate's IUserType.</p>
<p>At the bottom of the following page is an example where ayende removes some encryption logic out of the entity and allows NHibernate to just take care of it.</p>
<p><a href="http://ayende.com/Blog/archive/2008/07/31/Entities-dependencies-best-practi... | <p>It's not the same as "not adding these properties", but the last time I saw this, the engineer addressed it by implementing concrete NHibernate classes and deriving them from a common abstract base class (e.g. MyAuditable) that implemented the properties you dislike. This way you only have to solve the problem once.... | 12,302 |
<p>I am in the start up of a project using ASP.NET MVC and have started creating my models. Since I know <em>some</em> Ruby On Rails and would like to use a system as similar to Rails <strong>Active Record</strong> as possible.</p>
<p>Have anyone used <strong>Castle Projects Active Record</strong> in a ASP.NET MVC app... | <p>I have used Castle Active Record with ASP.NET MVC. I highly encourage this model, as ActiveRecord/NHibernate are much more mature that LINQ to SQL or the Entity Framework.</p>
<p>I think that ASP.NET MVC has a bright future and would recommend it over Monorail for new projects. However, as I said, ActiveRecord is... | <p>MVC doesn't know what ORM you are using, or is there even some ORM tool behind. Controller/Action must send object references to View, so that object can be simple int, string array, DataSet, Linq object, ActiveRecord object, whatever, it doesn't matter for View how some object is filled with data!</p>
| 21,705 |
<p>Ok so I've spent a couple hours trying to resolve this issue and have had no leads so far, keep getting the same 404 error. What happens is the website picks up the Default.aspx page and displays it like it should. But the Home page has a clickable image where it routes to another view page. The image code is like s... | <p>I noticed something odd in that tutorial link you posted. Verify File Exists should be unchecked.</p>
| <p>Check out this post:</p>
<p><a href="http://www.ee99ee.com/blog/2009/02/08/how-to-get-aspnet-mvc-working-under-iis-51-on-windows-xp/" rel="nofollow noreferrer">http://www.ee99ee.com/blog/2009/02/08/how-to-get-aspnet-mvc-working-under-iis-51-on-windows-xp/</a></p>
| 49,139 |
<p>In PHP, the HEREDOC string declarations are really useful for outputting a block of html. You can have it parse in variables just by prefixing them with $, but for more complicated syntax (like $var[2][3]), you have to put your expression inside {} braces.</p>
<p>In PHP 5, it <em>is</em> possible to actually make ... | <p>I would not use HEREDOC at all for this, personally. It just doesn't make for a good "template building" system. All your HTML is locked down in a string which has several disadvantages</p>
<ul>
<li>No option for WYSIWYG</li>
<li>No code completion for HTML from IDEs</li>
<li>Output (HTML) locked to logic files</... | <pre><code><?php
echo <<<ETO
<h1>Hellow ETO</h1>
ETO;
</code></pre>
<p>you should try it . after end the ETO; command you should give an enter.</p>
| 13,011 |
<p>How do I declare a private function in Fortran?</p>
| <p>This will only work with a Fortran 90 module. In your module declaration, you can specify the access limits for a list of variables and routines using the "public" and "private" keywords. I usually find it helpful to use the private keyword by itself initially, which specifies that everything within the module is ... | <pre><code>Private xxx, yyy, zzz
real function xxx (v)
...
end function xxx
integer function yyy()
...
end function yyy
subroutine zzz ( a,b,c )
...
end subroutine zzz
...
other stuff that calls them
...
</code></pre>
| 27,249 |
<p>I'd like to stick a class down in my folder hierarchy. The scenario is too trivial to warrant it's own project or separate website. However, I hate to clutter my top-level App_Code with something that's used by a tiny corner of the site.</p>
<p>Is there a way in web.config to include another file or folder in the... | <pre><code><configuration>
<system.web>
<compilation>
<assemblies>
<add assembly="<AssemblyName>, Version=<Version>, Culture=<Culture>, PublicKeyToken=<PublicKeyToken>"/>
</assemblies>
</compilation>
</s... | <pre><code><configuration>
<system.web>
<compilation>
<assemblies>
<add assembly="<AssemblyName>, Version=<Version>, Culture=<Culture>, PublicKeyToken=<PublicKeyToken>"/>
</assemblies>
</compilation>
</s... | 30,942 |
<p>I've read different things about PLA and heat-bed. Some say it is not needed, others recommend 60-70°C, but not for the first layers.</p>
<p>For larger objects I often have the problem that the object does not stick to the blue-painters-tape-covered aluminium print plate. Instead the print "curls" up on one or more... | <p>Heating the bed helps me, even with PLA. I print with a 60 °C bed. The bed is 3/8" 6061 alloy aluminum, sanded with 600 grit sandpaper, coated with Elmer's purple glue stick, and dried.</p>
<p>The brim will help. You might make the brim thicker than one layer (like 2-3 layers).</p>
<p>If you look at the bo... | <p>Heated bed definitely helps with PLA adhesion, it also helps depending the surface, for example PEI offers better adhesion than glass. Another option is to try to overextrude the first layer (125 %) and make sure it is squeezed out, so basically you get a wavy effect on the first layer. This should help a bit e... | 455 |
<pre><code>string[] filesOfType1 = GetFileList1();
string[] filesOfType2 = GetFileList2();
var cookieMap = new Dictionary<string, CookieContainer>();
Action<string, Func<string, KeyValuePair<string, CookieContainer>>> addToMap = (filename, pairGetter) =>
{
KeyValuePair<string,... | <p>Here's my attempt - seemed simplest to split the task into three distinct statements.</p>
<p>I'm using a helper function that returns null if the action throws an exception - for consistency with the answer from Omer van Kloeten, I've called this Swallow()</p>
<p>Also, I'm not using the LINQ syntax, just the exten... | <p>Excuse my not actually going ahead and compiling this, but this is the way I'd go around to doing it:</p>
<pre><code>var cookieMap = (from pair in
(from f1 in filesOfType1
select Swallow(() => GetType1FileCookiePair(f1)))
.Concat(from f2 in file... | 29,520 |
<p>I need to call a <a href="http://en.wikipedia.org/wiki/VBScript" rel="noreferrer">VBScript</a> file (.vbs file extension) in my C# Windows application.
How can I do this? </p>
<p>There is an add-in to access a VBScript file
in Visual Studio.
But I need to access the script in code behind. How to do this?</p>
| <p>The following code will execute a VBScript script with no prompts or errors and no shell logo.</p>
<pre><code>System.Diagnostics.Process.Start(@"cscript //B //Nologo c:\scripts\vbscript.vbs");
</code></pre>
<p>A more complex technique would be to use:</p>
<pre><code>Process scriptProc = new Process();
scriptProc.... | <p>For the benefit of searchers, I found this <a href="https://social.microsoft.com/Forums/en-US/9f5505d3-ab39-4f66-9ce5-95a7af432d22/passing-a-parameter-from-a-c-form-to-a-vbscript-and-executing-script?forum=Offtopic" rel="nofollow">post</a>, which gives a clear answer (esp if you have parameters). Have tested it - se... | 24,448 |
<h2>Note</h2>
<p>The question below was asked in 2008 about some code from 2003. As the OP's <strong>update</strong> shows, this entire post has been obsoleted by vintage 2008 algorithms and persists here only as a historical curiosity.</p>
<hr>
<p>I need to do a fast case-insensitive substring search in C/C++. My r... | <p>The code you posted is about half as fast as <code>strcasestr</code>.
</p>
<pre class="lang-none prettyprint-override"><code>$ gcc -Wall -o my_stristr my_stristr.c
steve@solaris:~/code/tmp
$ gcc -Wall -o strcasestr strcasestr.c
steve@solaris:~/code/tmp
$ ./bench ./my_stristr > my_stristr.result ; ./bench ./strc... | <p>If you want to shed CPU cycles, you might consider this - let's assume that we're dealing with ASCII and not Unicode.</p>
<p>Make a static table with 256 entries. Each entry in the table is 256 bits.</p>
<p>To test whether or not two characters are equal, you do something like this:</p>
<pre><code>if (BitLookup(... | 25,999 |
<p>We want to store our overridden build targets in an external file and include that targets file in the TFSBuild.proj. We have a core set steps that happens and would like to get those additional steps by simply adding the import line to the TFSBuild.proj created by the wizard. </p>
<pre><code><Import Project="$(... | <p>The Team Build has a "bootstrap" phase where everything in the Team Build Configuration folder (the folder with TFSBuild.proj) is downloaded from version control. This is performed by the build agent before the build agent calls MSBuild.exe telling it to run TFSBuild.proj.</p>
<p>If you move your targets file from... | <p>If you create an overrides target file to import and call it something like TeamBuildOverrides.targets and put it in the same folder in source control where TFSBuild.proj lives for your Build Type, it will be pulled first and be available for import into the TFSBuild.proj file. By default, the TFSBuild.proj file is... | 12,282 |
<p>Is there a way in <em>Xcode</em> to sort my list of files under say the Classes folder Alphabetically?</p>
<p>I know I can drag them around, but with tons of files that is a pain.</p>
<p>I am surprised I can not right click on the folder and say to sort.</p>
| <p>Click on the folder, and then click Edit > Sort > By Name</p>
| <p>Czar there are advantages to having it the way you want, instead of automatically having it sort at all times.</p>
<p>Some classes might be related in some way, but the names aren't right next to each other, I've used that for certain. :)</p>
| 29,585 |
<p>How can I convert a varchar field of the form YYYYMMDD to a datetime in T-SQL?</p>
<p>Thank you.</p>
| <pre><code>select convert(datetime, '20081030')
</code></pre>
| <p>Use the CONVERT() function?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms187928.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms187928.aspx</a></p>
| 31,249 |
<p>I have an application that I would like to embed inside our companies CMS. The only way to do that (I am told), is to load it in an <code><iframe></code>.</p>
<p>Easy: just set <code>height</code> and <code>width</code> to <code>100%</code>! Except, it doesn't work.</p>
<p>I did find out about setting <code>... | <p>You could either just use a scripting language to include the page into the parent page, other wise, you might want to try one of these javascript methods:</p>
<p><a href="http://brondsema.net/blog/index.php/2007/06/06/100_height_iframe" rel="nofollow noreferrer">http://brondsema.net/blog/index.php/2007/06/06/100_h... | <p>I might be missing something here, but adding <code>scrolling=no</code> as an attribute to the <code>iframe</code> tag normally gets rid of the scrollbars.</p>
| 8,291 |
<p>I am a <code>C/C++</code> programmer professionally, but I've created a couple of personal web sites using <code>PHP and MySQL</code>. </p>
<p>They're pretty basic, and I'd like to jazz them up using <code>Ajax</code>, but I've never done any Ajax. I've done all the development so far manually, i.e. no IDE or anyth... | <p>As T.O. says, try Aptana. There's a very good free version, and they really push the AJAX. They even have Jaxer, an "AJAX Server" that they're working on. If nothing else, the plugins are great, and, other than a few quirks, I really like working in it.</p>
| <p>First off, make sure you understand the basics of the HTTP protocol. Then learn how the javascript httpXmlRequest function works. Once you've covered those, pick an Ajax library - prototype is good.</p>
<p>Then look at a few examples, and follow the API.</p>
<p>Job done.</p>
<p>I seriously have no idea how they m... | 4,316 |
<p>I have a form element that I want to address via javascript, but it doesn't like the syntax.</p>
<pre><code><form name="mycache">
<input type="hidden" name="cache[m][2]">
<!-- ... -->
</form>
</code></pre>
<p>I want to be able to say:</p>
<pre><code>document.mycache.cache[m][2]
</code>... | <p>UPDATE: Actually, I was wrong, you can use [ or ] characters as part of a form elements id and/or name attribute.</p>
<p>Here's some code that proves it:</p>
<pre><code><html>
<body>
<form id="form1">
<input type='test' id='field[m][2]' name='field[m][2]' value='Chris'/>
<input type='... | <p>Is it possible to add an id reference to the form element and use document.getElementById?</p>
| 18,798 |
<p>What are the “normal” ways to do plug-ins in compiled languages (C#/C/C++/D)? I am specifically interested in language agnostic approaches but language specific is not unacceptable.</p>
<p>For the time being, “compile time” plug in approaches (just include the code or not and everything works) are valid but things ... | <p>For compiled languages (where compiled means the program runs as a native executable, without any sort of virtual machine), you pretty much need to use some sort of platform-specific shared library approach. In Windows, this means using DLLs.</p>
<p>You define your plugin interface in terms of a set of functions (... | <p>Interfaces with a void Register(EventSource) seem to work well - see ASP.NET's <a href="http://msdn.microsoft.com/en-us/library/system.web.ihttpmodule.init.aspx" rel="nofollow noreferrer">IHttpModule.Init(HttpApplication</a>) for an example.</p>
<p>This allows the app author (who controls EventSource) to add events... | 26,692 |
<p>I've got the following example running in a simple Silverlight page:</p>
<pre><code>public Page()
{
InitializeComponent();
InitializeOther();
}
private DoubleCollection dashes;
public DoubleCollection Dashes
{
get
{
//dashes = new DoubleCollection(); //works ok
//dashes.Add(2.0);
//dashes.Add(... | <p>Thank you for your answers and comments.</p>
<p>I can run exactly the same code in a WPF application and it does not fail. For me, this is a clear indication that it is a Silverlight bug. I don't now think it has anything to do with dependency properties.</p>
| <p>The fact that StrokeDashArray is a dependency property shouldn't have anything to do with that code failing, since in XAML you are constantly setting dependency properties which are processed during parsing in InitializeComponent.</p>
<p>I would say that the problem is that in your code you are reusing the same dou... | 22,588 |
<p>I am implementing a comment control that allows a person to select comments and have them sent to specified departments. The email needs to be formatted in a specific way, and I was wondering what the best way to do this would be.</p>
<p>Should I just hard code all of the style information into one massive method,... | <p>Find and use some kind of template library, if possible. This will make each email a template which will then be much easier to maintain than the hardcoded form.</p>
| <p>I would use a template approach. It wouldn't he hard to create a simple regex template system, replacing something like #somevar# with the value for 'somevar'. You could also use a premade template system, like Smarty for PHP. I think that would be the cleanest approach.</p>
<p>Alex</p>
| 12,717 |
<pre><code> <form action="/Villa/Add" method="post">
<table>
<tr>
<td>
Name:
</td>
<td>
<%= Html.TextBox("name") %>
<%= Html.ValidationMessage("Name") %>
</td&... | <p>This works for ASP.Net MVC Beta.</p>
<pre><code> public ActionResult Add( string name ) {
....
}
or
public ActionResult Add( FormCollection form ) {
string name = form["Name"];
}
or
public ActionResult Add( [Bind(Prefix="")]Villa villa ) {
villa.Name ...
}
</code></pre>
| <p>It belongs to your url routes, you defined.</p>
<p>In your case the form ist looking for an controller named "Villa" and the action inside of it named "Add".</p>
<p>Maybe you should read ScottGu's blog post: <a href="http://weblogs.asp.net/scottgu/archive/2008/09/02/asp-net-mvc-preview-5-and-form-posting-scenarios... | 40,972 |
<p>But here's an example:</p>
<pre><code>Dim desiredType as Type
if IsNumeric(desiredType) then ...
</code></pre>
<p><strong>EDIT:</strong> I only know the Type, not the Value as a string.</p>
<p>Ok, so unfortunately I have to cycle through the TypeCode.</p>
<p>But this is a nice way to do it:</p>
<pre><code> if (... | <p>A few years late here, but here's my solution (you can choose whether to include boolean). Solves for the Nullable case. XUnit test included</p>
<pre><code>/// <summary>
/// Determines if a type is numeric. Nullable numeric types are considered numeric.
/// </summary>
/// <remarks>
/// Boolean ... | <p>Use Type.IsValueType() and TryParse():</p>
<pre><code>public bool IsInteger(Type t)
{
int i;
return t.IsValueType && int.TryParse(t.ToString(), out i);
}
</code></pre>
| 15,143 |
<p>Is there a way to change name of company to which the Visual Studio 2008 is registered without reinstalling it?</p>
| <p>This should have the answer you are looking for : <a href="http://bytes.com/forum/thread635503.html" rel="noreferrer">http://bytes.com/forum/thread635503.html</a></p>
<blockquote>
<p>For the CompanyName in AssemblyInfo, it's $registeredorganization$ which
uses value from registry key value from HKLM\Software\Mi... | <p>A quick suggestion, bring up RegEdit and search for the existing company name string. Then attempt to change it.</p>
| 24,482 |
<p>My app keeps track of the state of about 1000 objects. Those objects are read from and written to a persistent store (serialized) in no particular order. </p>
<p>Right now the app uses the registry to store each object's state. This is nice because:</p>
<ul>
<li><p>It is simple</p></li>
<li><p>It is very fast</... | <p>If what you mean by 'multiple-reader/multiple-writer' is that you keep a lot of threads writing to the store concurrently, SQLite is threadsafe (you can have concurrent SELECTs and concurrent writes are handled transparently). See the [FAQ [1]] and grep for 'threadsafe'</p>
<p>[1]: <a href="http://www.sqlite.org/fa... | <p>Do you need to persist the objects on each change event or just in memory and store on shutdown? If so, just load them up and serialize them at the end, assuming your app runs for a long time (and you don't share that state with another program) then in memory is going to be a winner.</p>
<p>If you've got fixed si... | 16,483 |
<p>From within my Java program I want to determine which .NET Framework is installed on the system. What is the best (and easiest) way to do this?</p>
<p><strong>Answer</strong> Thanks scubabbl! It worked to check the directory <code>System.getenv( "WINDIR" ) + "\\Microsoft.NET\\Framework"</code> for its directories s... | <p>From what I understand, the actual file structure in c:\windows\Microsoft.Net\Framework has folders with versions of .Net installed. On my computer, I have folders up to v3.5, or
c:\windows\Microsoft.Net\Framework\v3.5.</p>
<p>There are lots of issues with this, including security issues though.</p>
<p>The second... | <p>Checking the directory structure is not the best way to do this. Take a look at this <a href="https://stackoverflow.com/questions/199080/how-to-detect-what-net-framework-versions-and-service-packs-are-installed">thread</a> for the full details on the registry keys you need to evaluate.</p>
| 16,761 |
<p>This is my setting: I have written a .NET application for local client machines, which implements a feature that could also be used on a webpage. To keep this example simple, assume that the client installs a software into which he can enter some data and gets some data back. </p>
<p>The idea is to create a webpage... | <p>You can try to use AOT to reduce the startup time. On .NET you would use ngen for that purpoise, on mono just do a mono --aot on all assemblies used by your application.</p>
<p>AOT'ed code is slower than JIT'ed code, but has the advantage of reducing startup time.</p>
<p>You can even try to AOT framework assemblie... | <p>I believe that remoting is not an ideal thing to use in this scenario. However your idea of having mono on server instead of starting it every time is indeed solid.</p>
<p>Did you consider using SOAP webservices over HTTP? This would also help you with your 'web page' scenario.</p>
<p>Even if it is a little to sl... | 14,608 |
<p>I'm a long-time ActionScript 2 user, now getting started with ActionScript 3. The one thing I'm missing is an easy way to duplicate the functionality of AS2's MovieClip.onReleaseOutside. It is almost always necessary to implement this event, otherwise you get funny bugs like flash thinks your mouse is down when real... | <p>Simple and foolproof:</p>
<pre><code>button.addEventListener( MouseEvent.MOUSE_DOWN, mouseDownHandler );
button.addEventListener( MouseEvent.MOUSE_UP, buttonMouseUpHandler ); // *
function mouseDownHandler( event : MouseEvent ) : void {
trace( "onPress" );
// this will catch the event anywhere
event.ta... | <p>Have you looked at this event:</p>
<pre><code>flash.events.Event.MOUSE_LEAVE
</code></pre>
<p><br />
<br />
From the documentation:</p>
<p><strong>Dispatched by the Stage object when the mouse pointer moves out of the stage area.
The Event.MOUSE_LEAVE constant defines the value of the type property of a mouseLeav... | 31,834 |
<p>I've been 3D printing as a hobby for a couple of years now, and have always heard how 3D printing is great for prototyping, but once you get beyond 10 or 20 pieces it's just not cost competitive with other technologies. I just accepted this to be truth, and have even told some of the customers I've gotten through 3... | <h1>TL:DR</h1>
<p>3D printing is great for low quantities of items, but terrible for large quantities of items. This is a continuous scale and as your quantity grows, the drawbacks of 3D printing become more pronounced. In your situation, you seem to be dancing in the nebulous zone where there isn't really a good an... | <p>Break even points have always been dependent on the part.
If the goal is to make a rod or filament-like piece of your extrusion nozzle diameter, your extruder may be pretty competitive. Additive manufacture has come a long way already so the break even points may have shifted. Interestingly a great use for additive... | 555 |
<p>In many symbolic math systems, such as Matlab or Mathematica, you can use a variable like <code>Ans</code> or <code>%</code> to retrieve the last computed value. Is there a similar facility in the Python shell?</p>
| <p>Underscore.</p>
<pre><code>>>> 5+5
10
>>> _
10
>>> _ + 5
15
>>> _
15
</code></pre>
| <p>IPython allows you to go beyond the single underscore <code>_</code> with double (<code>__</code>) and triple underscore (<code>___</code>), returning results of the second- and third-to-last commands.</p>
<p>Alternatively, you can also use <code>Out[n]</code>, where <code>n</code> is the number of the input that g... | 24,390 |
<p>I have to pass some parameter from an action to another action,for example to keep trace of an event. </p>
<p>What is the best way to do that? </p>
<p>I would not use session parameters. Thanks</p>
| <p>Assuming you are serverside within one action and wishing to invoke another action with some parameters.</p>
<p>You can use the s:action tag to invoke another action, possibly with additional/other parameters than the original action:</p>
<pre><code> <s:action name="myAction" ignoreContextParams="true" exec... | <p>actually, the scope and servletConfig interceptor can be utilized in struts2, to automatic pop the action context parameters, (request/session, etc)</p>
| 48,923 |
<p>This is more a thought experiment than anything.</p>
<p>I'm wondering what it would take to detect everything I legally can about the laptops in a hotspot. My first thought was to grab every MAC address I can and extract the maker from the first 24bit.</p>
<p>The question is would this be illegal and what else cou... | <p>For the brain dead answer: <em>Quit typing and look around for a few minutes</em> :-D</p>
| <p><a href="http://www.gfi.com/lannetscan/" rel="nofollow noreferrer">GFI Languard</a> gives a lot of info like this. Check it out.</p>
| 17,675 |
<p>In Linux When I invoke python from the shell it replicates its environment, and starts the python process. Therefore if I do something like the following:</p>
<pre><code>import os
os.environ["FOO"] = "A_Value"
</code></pre>
<p>When the python process returns, FOO, assuming it was undefined originally, will still b... | <p>No process can change its parent process (or any other existing process' environment).</p>
<p>You can, however, create a new environment by creating a new interactive shell with the modified environment.</p>
<p>You have to spawn a new copy of the shell that uses the upgraded environment and has access to the exist... | <p>I needed something similar, I ended up creating a script <code>envtest.py</code> with:</p>
<pre class="lang-py prettyprint-override"><code>import sys, os
sys.stdout = open(os.devnull, 'w')
# Python code with any number of prints (to stdout).
print("This is some other logic, which shouldn't pollute stdout."... | 32,922 |
<p>I have a large script file (nearly 300MB, and feasibly bigger in the future) that I am trying to run. It has been suggested in the comments of Gulzar's answer to my <a href="https://stackoverflow.com/questions/222442/sql-server-running-large-script-files">question about it</a> that I should change the script timeou... | <pre><code>sqlcmd -t {n}
</code></pre>
<p>Where {n} must be a number between 0 and 65535.</p>
<p>Note that your question is a bit misleading since <a href="http://blogs.msdn.com/khen1234/archive/2005/10/20/483015.aspx" rel="noreferrer">the server has no concept of a timeout</a> and therefore you cannot set the timeou... | <p>I think there is <strong>no concept of timeout within a SQL script</strong> on SQL Server. You have to set the timeout in the calling layer / client.</p>
<p>According to <a href="http://support.microsoft.com/?scid=kb%3Ben-us%3B314530&x=14&y=12" rel="nofollow noreferrer">this MSDN article</a> you could try t... | 27,793 |
<p>I'd like to have some of the ScriptManager features in the new Asp.net MVC model:</p>
<p>1- Script combining<br>
2- Resolving different paths for external Javascript files<br>
3- Minify and Gzip Compression </p>
<p><a href="http://www.codeproject.com/KB/aspnet/HttpCombine.aspx" rel="nofollow noreferrer">Here</a> i... | <p>Maybe you could just create a new 'Scripts' controller with different actions serving different combinations of compressed JS files. Since MVC is designed with a resource oriented approach, i.e. URLs are now at the center of your programming model, why not define simple URIs for your Javascripts too ?</p>
<p>In you... | <p>Found this researching much the same problem: <a href="http://pietschsoft.com/post/2009/08/13/Simple-ScriptManager-for-ASPNET-MVC.aspx" rel="nofollow noreferrer">A Simple ScriptManager for ASP.NET MVC</a> - written after this question was answered so added for reference.</p>
<p>In the first instance I'm going with ... | 41,436 |
<p>In E (specman) I want to declare variables that are lists, and I want to fix their lengths.</p>
<p>It's easy to do for a member of a struct:</p>
<pre><code>thread[2] : list of thread_t;
</code></pre>
<p>while for a "regular" variable in a function the above doesn't work, and I have to do something like:</p>
<pre... | <p>A hard keep like you have is only going to fix the size at initialization but elements could still be added or dropped later, are you trying to guard against this condition? The only way I can think of to guarantee that elements aren't added or dropped later is emitting an event synced on the size != the predetermi... | <p>I know nothing of specman, but a fixed sized list is an array, so that might point you somewhere.</p>
| 4,102 |
<p>When using SubSonic, do you return the data as a dataset or do you put that in a strongly typed custom collection or a generic object?</p>
<p>I ran through the subsonic project and for the four stored procs I have in my DB, it gave me a Sps.cs with 4 methods which return a StoredProcedure object.</p>
<p>If you use... | <p>If the results of the stored procedure has the same schema as one of your tables, you can build a collection using this code (SubSonic 2.1):</p>
<pre><code>ProductCollection coll = new ProductCollection();
coll.LoadAndCloseReader(SPs.GetProducts(1).GetReader());
</code></pre>
| <p>You can do data readers, but that's so 1999. Returning objects is a breeze with SubSonic, and easier to use than a data reader. You can retrieve objects like so:</p>
<pre><code>Dim Charts As Generic.List(Of MusicDB.Billboard) = _
New SubSonic.Select(MusicDB.DB.Repository.Provider, New String() _
{"Prefix", ... | 28,239 |
<p>What are the expert debugging hints for your favourite language, you think everyone should use?</p>
<p>As an example, I'll provide my C++ debugging hints, that between them help me shake out most of the bugs I come across, in this often hard-to-debug language.</p>
<p><B>C++</B></p>
<ul>
<li><p>Increase the warnin... | <p>Learn what the different magic numbers means that VS memory handler writes when it handles memory.</p>
<p>0xCDCDCDCD Allocated in heap, but not initialized. By malloc<br>
0xCCCCCCCC Allocated on stack, but not initialized.<br>
0xDDDDDDDD Released heap memory. By free<br>
0xFDFDFDFD "NoMansLand" fences automatically... | <p>I have no references for this, but I was told the 0xABABABAB address means 'memory beyond the bounds of allocated memory'. Hope it helps.</p>
| 38,689 |
<p>I'm trying to figure out how to drop/discard a request, I'm basically trying to implement a blocked list of IPs in my app to block spammers and I don't want to return any response (just ignore the request), is this possible in ASP.NET?</p>
<p>Edit: Some of the answers suggest that I could add them in the firewall, ... | <p>Maybe you could use </p>
<pre><code>Response.Clear();
Response.End();
</code></pre>
| <p>I would suggest the best solution is not to give a specific "no response" but to give a more discouraging standard http error message. Whenever I am attempting to discourage unauthorised users I issue a page/url not found message as follows:</p>
<pre><code>throw new HttpException(404, "File not found - " + Request.... | 34,926 |
<p>I would like to change the database files location of MySQL administrator to another drive of my computer. (I run Windows XP SP2 and MySQL Administrator 1.2.8.)</p>
<p>--Under the startup variable --> General Parameters --> I changed <code>Data directory:</code> from <code>C:/Program Files/MySQL/MySQL Server 5.0/... | <p>Normally it works like this:</p>
<ol>
<li>shut down MySQL</li>
<li>change the <code>[mysqld]</code> and <code>[mysqld_safe]</code> <code>datadir</code> variable in the MySQL configuration</li>
<li>change the <code>basedir</code> variable in the same section.</li>
<li>move the location over</li>
<li>restart MySQL</l... | <p>You also have to manually modify mysql's configuration (usually my.conf)</p>
| 15,377 |
<p>I'm trying to make the switch from Emacs to Eclipse. One thing that seems to be missing is its buffer/window support.</p>
<p>I know in Eclipse I can drag an editor's tab title over to split the view, creating the equivalent of a new Emacs window, which is a step in the right direction. </p>
<p>I can't find any k... | <p>Emacs+ has this exact behavior for Eclipse: <a href="http://www.mulgasoft.com/emacsplus" rel="nofollow noreferrer">http://www.mulgasoft.com/emacsplus</a></p>
| <p>Try <kbd>Ctrl</kbd>-<kbd>Tab</kbd> and <kbd>Ctrl</kbd>-<kbd>Shift</kbd>-<kbd>Tab</kbd> for cycling through tabs (buffers) and <kbd>Ctrl</kbd>-<kbd>F4</kbd> for closing a tab. You can also look through the shortcut bindings in the eclipse configuration.</p>
| 24,109 |
<p>I'll soon be working on a large c# project and would like to build in multi-language support from the start. I've had a play around and can get it working using a separate resource file for each language, then use a resource manager to load up the strings.</p>
<p>Are there any other good approaches that I could loo... | <h1>Use a separate project with Resources</h1>
<p>I can tell this from out experience, having a current solution with <strike>12</strike> <strong>24</strong> projects that includes API, MVC, Project Libraries (Core functionalities), WPF, UWP and Xamarin. It is worth reading this long post as I think it is the best way ... | <p>Most opensource projects use <a href="http://gnuwin32.sourceforge.net/packages/gettext.htm" rel="nofollow noreferrer">GetText</a> for this purpose. I don't know how and if it's ever been used on a .Net project before.</p>
| 48,837 |
<p>My application deals with e-mails coming from different sources, e.g. Outlook and IMAP mailboxes. Before parsing them, I write them to the temporary directory (keeping them in memory is not an option). While parsing, I might be writing attachments to the temp directory (for example, if they are too large to keep in ... | <p>If changing Virus scanner configuration is not the ideal option for you. Could you keep the file open from it's creation up to the end of your process? If you got an handle on the file, it will not be available for the Virus scanner.</p>
| <p>Virus scanner have exclude folders. Just look in the documentation and add your temp folder to this list.</p>
| 26,409 |
<p>The code that I want to write is like this:</p>
<pre><code>void MethodOnThreadA()
{
for (;;)
{
// Do stuff
if (ErrorConditionMet)
ThrowOnThread(threadB, new MyException(...));
}
}
void MethodOnThreadB()
{
try
{
for (;;)
{
// Do stuff
... | <p>This is NOT a good idea</p>
<p><a href="http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html" rel="noreferrer">This article talks about ruby's timeout library.</a> which throws exceptions across threads.</p>
<p>It explains how doing such a thing is fundamentally broken. It's not just broken ... | <p>I'm interested to know why you would want to do this. There's not an easy way to do it, because it's not a good practice. You should probably go back to your design and figure out a cleaner way to accomplish the end goal.</p>
| 6,642 |
<p>Whats the best way to bind variable column names to a report field in Access when using a crosstab query? </p>
| <p>I think because it's not needed very often. However, there is an easy way to do this in C++:</p>
<pre><code>#include <algorithm>
swap_ranges(ptr1, ptr1 + nbytes, ptr2)
</code></pre>
<p>It's it may not be quite as optimized as a compiler built in, but it has the potential of being faster than a loop you wri... | <p>Probably because it's not needed very often - I memset and memcpy reasonably often, but I don't know that I'd ever have used memswap if it was available.</p>
| 13,452 |
<p>As every Haxe developer knows, you could use <code>haxe.Timer.delayed()</code> to delay function call for some time. But this function doesn't exist for Neko at all. Is there a way to achieve the same results?</p>
| <p>Have to check it first but </p>
<pre><code>function delayed(f, time) {
neko.vm.Thread.create(function() {
neko.Sys.sleep(time);
f();
});
}
</code></pre>
<p>might be the closest thing possible. The only cons is that application becomes multi threaded which could lead to serious problems.</p>
| <p>Yes I don't know anything except for what you mention in your first answer. On Linux you can use SIGALARM - but this doesn't look trivial, 100% pure C code, and needs to be handled with great care to avoid crashing the VM.</p>
| 28,002 |
<p>I've created a windows forms control, which is hosted in a web page viewable with Internet Explorer.</p>
<p>My control reads from a com port and it writes to the event log. Both of these operations by default fail when the framework requests proper permissions. This web application will always be running in the i... | <p>You would need to create an installer or have your users grant a higher trust level for your website. These settings are editable under Microsoft .NET Framework configuration. under Administrative Tools. You can also take a look at <a href="http://www.sellsbrothers.com/wahoo/" rel="nofollow noreferrer">Chris Sells ... | <p>I've struggled with this in the past and tried to elevate permissions using caspol and it was a real pain. I ended up converting it to a click once app in 30 minutes and never had a problem with it since.</p>
| 37,211 |
<p>I'd like to have revision number of source code to Delphi's source code and exe version. What is the best way to do this automatically?</p>
<p>I'd like to display the revision number in "About" screen and in the version info of the project.</p>
<p>I'm using currently Delphi IDE (2006/2007) and Tortoise SVN.</p>
| <p>There is a program called SubWCRev.exe that comes with TortoiseSVN that will do token replacement for you. So somewhere in your source, you insert the token, and pass the input and output filenames to SubWCRev.exe, and it will replace the token with various SVN info, e.g., revision number. Note, this is a standalone... | <p>Suggestion: modify your build scripts to change some version file that gets compiled in afterwards. It's difficult to suggest anything more specific without knowing the build environment you're using.</p>
| 47,520 |
<p>I need something in between a full text search and an index search:<br>
I want to search for text in one column of my table (probably there will be an index on the column, too, if that matters).</p>
<p>Problem is, I want to search for words in the column, but I don't want to match parts. </p>
<p>For example, my c... | <p>Your word delimiters are going to be many: space, tab, beginning of line, parentheses, periods, commas, exclamation/question marks etc. So, a pretty simple solution is to use a regex in your WHERE clause. (And it's going to be a lot more efficient than just ORing every possible delimiter you can think of.)</p>
<p>S... | <p>Try this:</p>
<pre><code>declare @vSearch nvarchar(100)
set @vSearch = 'About'
select * from btTab where ' ' + vText + ' ' LIKE '%[^A-z^0-9]' + @vSearch + '[^A-z^0-9]%'
</code></pre>
| 18,996 |
<p>With my multiproject pom I get an error while running release:prepare. There is nothing fancy about the project setup and every release-step before runs fine.
The error I get is:</p>
<pre>
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------... | <p>This issue is addressed in the latest version of the <a href="http://maven.apache.org/plugins/maven-release-plugin/" rel="noreferrer">maven-release-plugin</a>. Add this to your POM to pull it in.</p>
<pre><code><build>
<pluginManagement>
<plugins>
<plugin>
<artifactId... | <p>As far as I know it is a bug in Subversion 1.5 and not directly related with maven. However a workaround the fixed it for me is to update the local svn repository and run the release:prepare goal again.</p>
| 11,770 |
<p>Every time I do an <code>hg diff file.ext</code> I end up using a console diff application. I would like to use Kdiff3 or WinMerge (I'm using Windows).</p>
<p>Is there a way to change that? I can't find a reference in Mercurial documentation (<strong>I'm not talking about merge!</strong>). </p>
| <p>I've solved this using a Mercurial built-in extension... I just have to add the following lines to Mercurial.ini (on Mercurial folder):</p>
<pre><code>[extensions]
hgext.extdiff=
[extdiff]
cmd.vdiff = kdiff3
</code></pre>
<p>When I want to use kdiff3 instead of diff I only have to use:</p>
<pre><code>hg vdiff fi... | <p>I just had this problem a few minutes ago; I just installed it and added its path (default is at c:\program files\kdiff3) to my system PATH e.v. Restarted my window to pick up the new path, and "hg kdiff3" just worked. As it turns out the following is in my base "mercurial.ini" file, this allows the kdiff3 to work f... | 29,461 |
<p>We've noticed that IE7 has an odd behavor with code blocks posted on Stack Overflow. For example, this little code block:</p>
<pre><code>public PageSizer(string href, int index)
{
HRef = href;
PageIndex = index;
}
</code></pre>
<p>Copy and pasted from IE7, ends up like this:</p>
<pre>
public PageSizer(str... | <p>It seems that this is a known bug for IE6 and prettify.js has a workaround for it. Specifically it replaces the BR tags with '\r\n'.</p>
<p>By modifying the check to allow for IE6 or 7 then the cut-and-paste will work correctly from IE7, but it will render with a <em>newline</em> followed by a <em>space</em>. By ... | <p>Remove the inner <code><code></code>. IE's copy/paste behavior could see that as an inline tag and forget about the visible whitespace.</p>
| 16,511 |
<p>It's the weekend, so I relax from spending all week programming by writing a hobby project.</p>
<p>I wrote the framework of a MOS 6502 CPU emulator yesterday, the registers, stack, memory and all the opcodes are implemented. (Link to source below)</p>
<p>I can manually run a series of operations in the debugger I ... | <p>The opcode takes one byte, and the operands are in the following bytes. Check out the byte size column <a href="http://www.atariarchives.org/2bml/chapter_10.php" rel="noreferrer">here</a>, for instance.</p>
| <p>The apple II roms included a dissassembler, I think that's what it was called, and it would show you in a nice format the hex opcodes and the 3 character opcode and the operands.</p>
<p>So given how little memory was available, they managed to shove in the operand byte count (always 0, 1 or 2) the 3 character opco... | 13,694 |
<p>I'm reading in a lot of data from ldap which needs to be compared to the respective records in the database. To minimize the number of SQL queries, I want to batch multiple ldap records into a single query.</p>
<p>All this is pretty simple: A thread to produce ldap results, and a thread to consume those results a... | <p>I would follow the "Make it Run, Make it Right, Make it Fast, Make it Simple" pattern.</p>
<p>Can you implement this correctly without an special "EOF" token? If not, then you just have to use the EOF token, do not sweat it. Yes, the termination condition is more complex, but now it is "Right."</p>
| <p>The "EOF" approach is perfectly respectable. Let's look at the microcosm of an ANSI string. The null is the EOF. What's bad about that?</p>
<p>Alternatively, let's look at the microcosm of the BSTR. Instead of a trailing null, the first bytes tell you how bytes are coming.</p>
<p>Either way is fine.</p>
<... | 35,842 |
<p>How can I limit my post-build events to running only for one type of build?</p>
<p>I'm using the events to copy DLL files to a local IIS virtual directory, but I don't want this happening on the build server in release mode.</p>
| <p>Pre- and Post-Build Events run as a batch script. You can do a conditional statement on <code>$(ConfigurationName)</code>.</p>
<p>For instance</p>
<pre><code>if $(ConfigurationName) == Debug xcopy something somewhere
</code></pre>
| <p>Like any project setting, the buildevents can be configured per Configuration. Just select the configuration you want to change in the dropdown of the Property Pages dialog and edit the post build step.</p>
| 18,083 |
<p>I have a load of user-submitted content. It is HTML, and may contain URLs. Some of them will be <code><a></code>'s already (if the user is good) but sometimes users are lazy and just type www.something.com or at best <a href="http://www.something.com" rel="noreferrer">http://www.something.com</a>.</p>
<p>I ca... | <p>Jan Goyvaerts, creator of <a href="http://www.regexbuddy.com" rel="noreferrer">RegexBuddy</a>, has <a href="http://www.regexguru.com/2008/11/detecting-urls-in-a-block-of-text/" rel="noreferrer">written a response</a> to Jeff Atwood's blog that addresses the issues Jeff had and provides a nice solution. </p>
<pre><c... | <p>Shameless plug: You can look here (<a href="https://stackoverflow.com/questions/276029/#276109">regular expression replace a word by a link</a>) for inspiration. </p>
<p>The question asked to replace some word with a certain link, unless there already was a link. So the problem you have is more or less the same thi... | 36,525 |
<p>How do I check if an object has a specific property in JavaScript?</p>
<p>Consider:</p>
<pre><code>x = {'key': 1};
if ( x.hasOwnProperty('key') ) {
//Do this
}
</code></pre>
<p>Is that the best way to do it?</p>
| <h2>2022 UPDATE</h2>
<h2><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn" rel="noreferrer"><code>Object.hasOwn()</code></a></h2>
<blockquote>
<p><code>Object.hasOwn()</code> is recommended over <code>Object.hasOwnProperty()</code> because it works for objects crea... | <p>Don't over-complicate things when you can do:</p>
<pre><code>var isProperty = (objectname.keyname || "") ? true : false;
</code></pre>
<p>It Is simple and clear for most cases...</p>
| 16,405 |
<p>I have a report in SQL Server Reporting Services (SSRS) that I'd like to schedule to run automatically as an email. I'd like the report to be attached as Excel file.<br>
According to the <a href="http://www.microsoft.com/Sqlserver/2005/en/us/reporting-services.aspx" rel="noreferrer">Microsoft overview</a> this shou... | <p>When you browse to the report in your reporting services site you should see a tab for Subscriptions. That's where you'd specify the recipients and delivery methods for automated delivery.</p>
<p>Here's a <a href="http://msdn.microsoft.com/en-us/library/ms160334.aspx" rel="noreferrer">page</a> that describes the p... | <p>You can use SQL- RD Application for Dynamic schedules</p>
| 35,141 |
<p>After installing a third-party SDK, it very discourteously makes one if its templates the default item in "Add New Item..." dialog in Visual Studio 2005. This is also the case for all other similar dialogs - "Add Class...", "Add User Control..." etc.</p>
<p>Is there a way to change this behavior?</p>
| <p>You may have to manually modify the SortOrder on the Item templates yourself. You can do this by following these directions:</p>
<p>1) Find the Item Template(s)</p>
<p>Item Templates for VS2005 are stored in the following locations:</p>
<p><code></p>
<pre><code> (Installed Templates) <VisualStudioInstallDir&... | <p>Try looking at the registry under </p>
<pre><code>HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\
</code></pre>
<p>I see some relevant entries on my machine under</p>
<pre><code>HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0
</code></pre>
<p>for VS2008.</p>
| 14,866 |
<p>Is there a compression API available for use on the iPhone? We're building some RESTful web services for our iPhone app to talk to, but we want to compress at least some of the conversations for efficiency.</p>
<p>I don't care what the format (ZIP, LHA, whatever) is, and it does not need to be secure.</p>
<p>Some ... | <p>If you store the data for the conversations in an NSData object, the folks at the CocoaDev wiki have posted an <a href="http://www.cocoadev.com/index.pl?NSDataCategory" rel="noreferrer">NSData category</a> that adds gzip and zlib compression / decompression as simple methods. These have worked well for me in <a hre... | <p>NSURL says it supports the gzip encoding so you shouldn't have to do anything more than have your RESTful web service return gzip encoded content when appropriate. All the decoding will be done under the covers.</p>
| 28,588 |
<p>How do I escape the underscore character?</p>
<p>I am writing something like the following where clause and want to be able to find actual entries with _d at the end.</p>
<pre><code>Where Username Like '%_d'
</code></pre>
| <p><a href="https://learn.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql?view=sql-server-ver15#using-wildcard-characters-as-literals" rel="noreferrer">T-SQL Reference for LIKE</a>:</p>
<blockquote>
<p>You can use the wildcard pattern matching characters as literal characters. To use a wildcard cha... | <p>Adding to <a href="https://stackoverflow.com/a/10415670/12221876">Gerardo Lima's answer</a>, I was having problems when trying to use backslash as my escape character for the ESCAPE clause. This caused issues:</p>
<pre><code>SELECT * FROM table WHERE email LIKE '%@%\_%' ESCAPE '\'
</code></pre>
<p>It was resolved by... | 2,765 |
<p>Is there anyway to configure a WCF service with a failover endpoint if the primary endpoint dies? Kind of like being able to specify a failover server in a SQL cluster.</p>
<p>Specifically I am using the TCP/IP binding for speed, but on the rare occurrence that the machine is not available I would like to redirect ... | <p>You need to use a layer 4 <a href="http://en.wikipedia.org/wiki/Load_balancing_%28computing%29#Relationship_with_failover" rel="nofollow noreferrer">load balancer</a> in front of the two endpoints. Prob best to stick with a dedicated piece of hardware.</p>
| <p>We've had good luck with BigIP as a solution, though it's not cheap or easy to set up. </p>
<p>One nice feature is it allows you to set up your SSL certificate (and backdoor to the CA) at the load balancer's common endpoint. Then you can use protocols to transfer the requests back to the WCF servers so the entire t... | 2,635 |
<p>I'm working on an ASP.net 3.5 website with MooTools as the AJAX framework. I want to disable ASP.net's AJAX framework so it behaves more like ASP.net 2.0. This is to decrease page loading times and to reduce incompatibilities. Is this possible and if so how do I go about it?</p>
| <p>I was able to remove the System.Web.Extensions assembly from the references, and then I found and removed all instances of the ScriptManager control. </p>
<p>Once I did this, none of the AJAX framework stuff is rendered to the pages.</p>
<p>I wanted to keep 3.5 for LINQ and other jazz, so just targeting the 2.0 fr... | <p>I've seen some articles on how to improve the performance of asp.net ajax in the .net 3.5 framework. Just can't find the link. But there are some changes you can do in the web.config which will improve performance wise. But, if you want to use MooTools, i guess you can just remove the Assemblies and the remove all r... | 43,855 |
<p>Boost is a great set of libraries and it really <em>boosts</em> productivity. But debugging code that uses it is a total nightmare. Sure, stepping through twenty thousand header files can be a valuable intellectual exercise, but what if you need to do it over and over again?</p>
<p>Is there a developer-friendly way... | <p>You can skip the boost namespace entirely by using the techniques described <a href="http://through-the-interface.typepad.com/through_the_interface/2006/07/advanced_visual_1.html" rel="noreferrer">here</a>. Just use something like:</p>
<p><code>boost\:\:.*=NoStepInto</code></p>
<p>... in the relevant registry entr... | <p>You can skip the boost namespace entirely by using the techniques described <a href="http://through-the-interface.typepad.com/through_the_interface/2006/07/advanced_visual_1.html" rel="noreferrer">here</a>. Just use something like:</p>
<p><code>boost\:\:.*=NoStepInto</code></p>
<p>... in the relevant registry entr... | 38,142 |
<pre><code>cmd /C "myshortcut1.lnk"
cmd /C "myshortcut2.lnk"
</code></pre>
<p>Works, but gives me a pop-up DOS window which, when closed, kills my two loaded programs. Same is true for this:</p>
<pre><code>start /B cmd /C "1.lnk"
start /B cmd /C "2.lnk"
start /B cmd /C "3.lnk"
start /B cmd /C "4.lnk"
</code></pre>
| <p>The MySQL JDBC driver times out after 8 hours of inactivity and drops the connection.</p>
<p>You can set <code>autoReconnect=true</code> in your JDBC URL, and this causes the driver to reconnect if you try to query after it has disconnected. But this has side effects; for instance session state and transactions ca... | <p>I would suggest that, in almost any client/server set-up, it's a bad idea to leave connections open when they're not needed.</p>
<p>I'm thinking specifically about DB2/z connections but it applies equally to all servers (database and otherwise). These connections consume resources at the server that could be best ... | 34,046 |
<p>I built an application which displays the records from database in the window and checks the the database for new records every couple of seconds. The problem is that the window blinks each time I check for new records and I want to fix it. I have tried to compare the old datatable with the new one and refresh only ... | <p>First off, it's important to recognize that what you're comparing in your code is the <em>references</em> of the datatables, not the <em>contents</em> of the datatables. In order to determine if both datatables have the same contents, you're going to have to loop through all of the rows and columns and see if they'... | <p>You have to cast objects t1.Rows[i][dc.ColumnName] and t1.Rows[i][dc.ColumnName] otherwise the statement t1.Rows[i][dc.ColumnName] != t2.Rows[i][dc.ColumnName] is always true. I modified the code the following way:</p>
<pre><code>for(int i = 0; i < t1.Rows.Count; i++)
{
if((string)t1... | 29,275 |
<p>Consider the need to develop a lightweight desktop DB application on the Microsoft platforms.</p>
<p>It could be done fairly easily with MS Access but I'd like to be able to distribute it to others and I don't want to pay for a runtime license. </p>
<p>Requirements:</p>
<ul>
<li>easy distribution to others</li>
... | <p>One thing to keep in mind here is the MS Access product is much more than just the raw database engine. It provides a full application development platform, including form and menu designer, client application language and environment (VBA), and report designer. When you take all those things together, MS Access rea... | <p>VistaDB is the only alternative if you going to run your website at shared hosting (almost all of them won't let you run your websites under Full Trust mode) and also if you need simple x-copy deployment enabled website.</p>
| 4,871 |
<p>How do you turn a Visual Studio build that you'd perform in the IDE into a script that you can run from the command line?</p>
| <p>With VS2008 you can do this:</p>
<pre><code>devenv solution.sln /build configuration
</code></pre>
| <p>A more simple way is to change VS 2015 Projects & Solutions configuration:
Go to the Tools tab -> Options -> Projects and Solutions -> Build and Run -> On Run, when projects are out of date (choose Always build). VOILA! </p>
<p>Now your IDE will automatically build your project when you run (F5) it. Hope this h... | 4,421 |
<p>How do I truncate a java <code>String</code> so that I know it will fit in a given number of bytes storage once it is UTF-8 encoded?</p>
| <p>Here is a simple loop that counts how big the UTF-8 representation is going to be, and truncates when it is exceeded:</p>
<pre><code>public static String truncateWhenUTF8(String s, int maxBytes) {
int b = 0;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
// ranges from http... | <p>Based on <a href="https://stackoverflow.com/a/119338/6404321">billjamesdev's answer</a> I've come up with the following method which, as far as I can tell, is the simplest <em>and</em> still works OK with surrogate pairs:</p>
<pre><code>public static String utf8ByteTrim(String s, int trimSize) {
final byte[] byt... | 14,514 |
<p>I need to make changes to an in-use production database. Just adding a few columns. I've made the changes to the dev database with migrations. What is the best way to update the production database while preserving the existing data and not disrupting operation too much?</p>
<p>It's MYSQL and I will be needing t... | <p>I always follow this procedure:</p>
<ul>
<li>Dump prod database with mysqldump command</li>
<li>Populate dev / test database with dump using mysql command</li>
<li>Run migrations in dev / test</li>
<li>Check migration worked</li>
<li>Dump prod database with mysqldump command (as it may have changed) keeping backup ... | <p>Is there a reason you are not using the same migrations you used in your dev environment?</p>
| 25,214 |
<p>Here is the current architecture of my transaction scope source code. The third insert throws an .NET exception (Not a SQL Exception) and it is not rolling back the two previous insert statements. What I am doing wrong?</p>
<p><b>EDIT:</b> I removed the try/catch from insert2 and insert3. I also removed the exc... | <p>I have also run into a similar issue. My problem occurred because the SqlConnection I used in my SqlCommands was already open before the TransactionScope was created, so it never got enlisted in the TransactionScope as a transaction.</p>
<p>Is it possible that the SqlHelper class is reusing an instance of SqlConne... | <p>I dont see your helper class, but transaction scope rollsback if you don't call complete statement even if you get error from .NET code. I copied one example for you. You may be doing something wrong in debugging. This example has error in .net code and similar catch block as yours.</p>
<pre><code> private static ... | 44,059 |
<p>How do you properly override <code>isEqual:</code> in Objective-C? The "catch" seems to be that if two objects are equal (as determined by the <code>isEqual:</code> method), they must have the same hash value.</p>
<p>The <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObje... | <p>Start with</p>
<pre><code> NSUInteger prime = 31;
NSUInteger result = 1;
</code></pre>
<p>Then for every primitive you do</p>
<pre><code> result = prime * result + var
</code></pre>
<p>For objects you use 0 for nil and otherwise their hashcode.</p>
<pre><code> result = prime * result + [var hash];
</code></pre... | <p>Sorry if I risk sounding a complete boffin here but...
...nobody bothered mentioning that to follow 'best practices' you should definitely not specify an equals method that would NOT take into account all data owned by your target object, e.g whatever data is aggregated to your object, versus an associate of it, sho... | 31,719 |
<p>Is it possible to get the current source line number in Perl?
The equivalent in C++ is <code>__LINE__</code>.</p>
| <p>The <code>__LINE__</code> literal is documented in the <a href="https://perldoc.perl.org/perldata#Special-Literals" rel="nofollow noreferrer">Special Literals</a> section of the <a href="https://perldoc.perl.org/perldata" rel="nofollow noreferrer">perldata man page</a>.</p>
<pre><code>print "File: ", __FIL... | <p>This prints out the line where you are, and also the "stack" (list of lines from the calling programs (scripts/modules/etc) that lead to the place you are now)</p>
<pre><code>while(my @where=caller($frame++)) { print "$frame:" . join(",",@where) . "\n"; }
</code></pre>
| 46,327 |
<p>Ok simple question. I have a JSF application, containing a login page. The problem is if the user loads the login page, leaves it for a while, then tries to login the session expires and a ViewExpiredException is thrown. I could redirect back to the login when this happens, but that isn't very smooth. How can I allo... | <p><strong>Update</strong></p>
<p>As of Mojarra 2.1.19 / 2.2.0 you can now set the transient attribute of the <code><f:view></code> to true:</p>
<pre><code><f:view transient="true">
Your regular content
</f:view>
</code></pre>
<p>You can read about in on <a href="https://stackoverflow.com/user... | <p>Couple of slightly hacky solutions:</p>
<ul>
<li>(Very hacky) use a <code><meta http-equiv="refresh" content="5"/></code> tag to automatically reload the page every so often.</li>
<li>Use a JavaScript function to periodically send a 'ping' request to the server to keep the session alive.</li>
</ul>
<p>We use... | 28,616 |
<p>I have been involved in a lot of projects, both old and new, and one thing that they have in common is that almost none of them have been using unit testing. I prefer to use it, but often the customer isn´t ready to pay for that, and suppose that the code just works as it should.</p>
<p>So, do you use unit testing ... | <p>Using unit-testing <em>is</em> a coding skill. </p>
<p>I find it adds very little overhead to coding time. On top of that the code produced tends to be much easier to understand and to refactor, with an untold reduction in maintenance time.</p>
<p>A full discussion of the benefits here: <a href="https://stackoverf... | <p>Unit testing is an essential part of development, and (I have found) will actually reduce the time to completion of a project while improving overall quality, especially when done in a TDD fasion.</p>
| 36,426 |
<p>Can the name and icon of an Eclipse view be programmatically changed? I am referring to the name and icon that appear in the tab for the view - which are specified as XML attributes "name" and "icon" in the <view> element in plugin.xml.</p>
| <p><code>setPartName(String)</code> and <code>setTitleImage(Image)</code>, both on <code>WorkbenchPart</code> are what you're looking for. </p>
<p>Both <code>EditorPart</code>s and <code>ViewPart</code> are extensions of <code>WorkbenchPart</code>. </p>
<p>It should be noted that both these methods are <code>protecte... | <p>setPartName(..) in the ViewPart class.</p>
| 40,787 |
<p>At a recent discussion on Silverlight the advantage of speed was brought up. The argument for Silverlight was that it performed better in the browser than Javascript because it is compiled (and managed) code.</p>
<p>It was then stated that this advantage only applies to IE because IE interprets Javascript which is... | <p>Speculating is fun. Or we could actually try a test or two...</p>
<p>That <a href="http://silverlight.net/samples/sl2/silverlightchess/run/Default.html" rel="noreferrer">Silverlight vs. Javascript chess sample</a> has been updated for Silverlight 2. When I run it, C# averages 420,000 nodes per second vs. Javascript... | <p>Sre, if you're using "Internet Exploder" it probably will...</p>
<p>If you're using V8 (Chrome) or the upcoming Safari and FireFox, I seriously doubt it ;)</p>
<p>I would love to see that Chess thn BTW where IE is playing using Silverlight and Chrome is using Javascript. THAT would rock MSFT...!! ;)</p>
| 41,706 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.