instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>We have a java program that requires a large amount of heap space - we start it with (among other command line arguments) the argument -Xmx1500m, which specifies a maximum heap space of 1500 MB. When starting this program on a Windows XP box that has been freshly rebooted, it will start and run without issues. But i... | <p>Agree with Torlack, a lot of this is because other DLLs are getting loaded and go into certain spots, breaking up the amount of memory you can get for the VM in one big chunk.</p>
<p>You can do some work on WinXP if you have more than 3G of memory to get some of the windows stuff moved around, look up PAE here:
<a ... | <p>Using Minimem (<a href="http://minimem.kerkia.net/" rel="nofollow noreferrer">http://minimem.kerkia.net/</a>) for that application might fix your problem. However, I'm not sure this is the answer you are looking for. I hope it helps.</p>
| 12,928 |
<p>I need some resources that talk about how to design your software to be extensible, i.e. so that other people can write add-ons/plug-ins that adds functionality to it.</p>
<p>What do you recommend? Any books out there that discuss the subject?<br>
I would prefer something that's short and to the point; a bit of the... | <p>IF we're talking .NET, try <a href="http://www.codeproject.com/KB/system/mScriptable.aspx" rel="noreferrer">Scripting .NET applications with VBScript</a> over on CodeProject. Lots of concrete examples there.</p>
<p>Below are sites implementing various application extension techniques</p>
<ul>
<li><a href="http://c... | <p>Rather than re-inventing the wheel, use the frameworks in hand. Eclipse and Netbeans both support plugin based extensions. You have to work in Java though.</p>
| 41,829 |
<p>On all my Windows servers, except for one machine, when I execute the following code to allocate a temporary files folder:</p>
<pre><code>use CGI;
my $tmpfile = new CGITempFile(1);
print "tmpfile='", $tmpfile->as_string(), "'\n";
</code></pre>
<p>The variable <code>$tmpfile</code> is assigned the value <code>'.... | <p>The name of the temporary directory is held in <code>$CGITempFile::TMPDIRECTORY</code> and initialised in the <code>find_tempdir</code> function in CGI.pm.
The algorithm for choosing the temporary directory is described in the CGI.pm documentation (search for <strong>-private_tempfiles</strong>).
IIUC, if a C:\Temp ... | <p>If you're running this script as you, check the %TEMP% environment variable to see if if it differs.</p>
<p>If IIS is executing, check the values in registry for TMP and TEMP under
HKEY_USERS/.DEFAULT/Environment</p>
| 11,169 |
<p>In MS SQL 2000 and 2005, given a datetime such as '2008-09-25 12:34:56' what is the most efficient way to get a datetime containing only '2008-09-25'?</p>
<p>Duplicated <a href="https://stackoverflow.com/questions/2775/whats-the-best-way-to-remove-the-time-portion-of-a-datetime-value-sql-server">here</a>.</p>
| <p>I must admit I hadn't seen the floor-float conversion shown by Matt before. I had to test this out. </p>
<p>I tested a pure select (which will return Date and Time, and is not what we want), the reigning solution here (floor-float), a common 'naive' one mentioned here (stringconvert) and the one mentioned here that... | <pre><code>CONVERT(VARCHAR(10), GETDATE(), 120) AS [YYYY-MM-DD]
</code></pre>
| 16,111 |
<p>How do I stop a function/procedure in a superclass from been overridden in a subclass in Delphi (2007)?</p>
<p>I want to mark it so it can not be altered, I believe there is a final keyword but can not for the life of me find the documentation for it, so I am not 100% sure that's what I need.</p>
| <p>The keyword is <code>final</code> as you thought. See <a href="http://dn.codegear.com/article/34324" rel="noreferrer">http://dn.codegear.com/article/34324</a> and <a href="http://blogs.teamb.com/rudyvelthuis/2005/05/13/4311" rel="noreferrer">http://blogs.teamb.com/rudyvelthuis/2005/05/13/4311</a>. Also you can mark ... | <p>You're right - it's "final". This snippet shows it. (from one of <a href="http://www.marcocantu.com" rel="nofollow noreferrer">Marco Cantu</a>'s books)</p>
<pre><code>type
TDeriv1 = class (TBase)
procedure A; override; final;
end;
TDeriv2 = class (TDeriv1)
procedure A; override; // error: "cannot ove... | 20,199 |
<p>I am developing a page view counter to track the amount of views a page is having on our site and displaying it to the user. (I asked an intro question before: <a href="https://stackoverflow.com/questions/246919/page-view-counter-like-on-stackoverflow">Page View Counter like on StackOverFlow</a>).</p>
<p>Using the ... | <p>interesting questions! Like a lot of other performance-tuning questions, there are some tradeoffs.</p>
<ol>
<li><p>Possibly. It may be a better idea to load this handler inside an IMG href="", setting the sizes to 0 so it is invisible to the user.</p></li>
<li><p>With heavy load this would be preferable, that way... | <p>I would go with the logging method referenced in the other page, unless you need to track specific time/date of views. My reasoning is simply due to the sheer number of items that you might get as you application starts to scale up in size.</p>
<p>Linking to the handler as a CSS style, should not really stop load ... | 32,439 |
<p>I have a job to enter survey results (in paper form) to excel.
I've never written any macro in Office :(</p>
<p>Here I what I basically need:</p>
<ol>
<li>I have predefined columns (|A|B|...|AG|AH|)</li>
<li>All surveys are grouped into groups. All surveys from same group have few (like predefined) same columns. I... | <p>It seems to me you need a small userform with just a textbox, a range to show the order of data entry, say:</p>
<p>Group A | E | D | F | G</p>
<p>And a little code to go with the form, say:</p>
<pre><code>Dim LastCol As Integer
Dim CurRow As Integer
Private Sub UpdateCells()
Dim Col As Variant
Dim ColumnOrder A... | <p>If I understand the question correctly, you want the user to be able to type numbers only, without using enter or arrow to finalize the entry.</p>
<p>For example, typing "1253216..." instead of "1 2 5 ..."</p>
<p>If so, unfortunately there is no event that corresponds to individual characters going into the for... | 48,434 |
<p>As one of my hobby projects, I'm developing an image effects plugin for jQuery. It's supposed to allow you to apply a few basic effects to an image, and does this by using the canvas HTML element or Internet Explorer filters, which ever are supported.</p>
<p>A demo page is available at: <a href="http://sandbox.odyn... | <p>You can try to set the css zoom value to 1. If that also doesn't work. It seems that this is really a bug in IE.</p>
| <p>Looks like a Browser bug to me.</p>
| 45,211 |
<p>I use db2 v.9.1 on windows 2003 server so it can not use LPAD or RPAD functions scalar.
because that functions support only z/OS right?</p>
<p>Now, I use this way for pad zero when COLUMN1 type is VARCHAR</p>
<pre><code> RIGHT('0000' || COLUMN1 ,4) AS RPAD
LEFT('0000' || COLUMN1 ,4) AS LPAD
</code></pre>
<p>... | <p>I think you probably want the <a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0000842.htm" rel="nofollow noreferrer">REPEAT</a> scalar function.</p>
| <pre><code>REPEAT('0',4) || column_name
</code></pre>
<p>Now if you want to limit the 0 based on the number of characters you can use the <code>RIGHT</code> function and it would look something like this assuming your column is <code>varchar(10)</code>:</p>
<p><code>RIGHT(REPEAT('0',4) || column_name, 10)</code> in t... | 36,407 |
<p>I have a website built using Asp.net and LinqToSql for Data Access. In a certain section of the site, LinqToSql produces a query that looks like this (from my dev machine):</p>
<pre><code>select ...
from table1
left outer join table2 on table1 where ...
left outer join table3 on table2 where ...
</code></pre>
<p>S... | <p>Is your production database different to your development one, e.g. SQL Server 2008 instead of 2005? I believe LINQ to SQL will vary the SQL it generates based on the actual execution-time database it's talking to.</p>
<p>Also, are the schemas exactly the same on both databases?</p>
| <p>I have checked the following:</p>
<ol>
<li>Both use the same database</li>
<li>Both have the identical code</li>
<li>Both have the identical dbml file</li>
</ol>
<p>I know that something has to be out of synch somewhere, but I can't find it.</p>
<p>So I have implemented the following workaround: I added a view to... | 33,869 |
<p>I am a 3D printing beginner but wanted to get stuck in straight away and design my own 3D objects. I used Sketchup to design a badge of one of my logos. I make sure that all faces of my object are not inside out and show a white face in Sketchup. I also make my entire object a component before exporting into a .stl ... | <p>A red surface coloring is normal for the bottom when viewed in Ultimaker Cura, nothing to worry about that (e.i. when that face is touching the build plate; if it is unsupported, you should add support structures but a raft is generally not necessary for PLA).</p>
<p>Rafts are useful when you print high temperature... | <p>Note: This answer is curently wrong because I mentally reversed your "with raft" and "without raft" columns. I'll attempt to fix it soon.</p>
<p>This doesn't look like a problem with your model, but rather a problem with your bed height or slicer settings (possibly both) that may be affecting your particular model ... | 1,391 |
<p>I'm currently writing an interface to allow applications to send exception data to a central repository for support purposes. I'm at a quandary about how to pass extra contextual data:</p>
<pre><code>public interface IExceptionNotifier
{
void Notify(Exception ex, NameValueCollection context); //this
v... | <p>(Assuming .NET 3.5 here. Pre .NET 3.5, NameValueCollection would have the benefit of being able to tie multiple values to a key, with no direct equivalent in "normal" collections.)</p>
<p>Do you want keys to have potentially multiple values? If so, I'd consider ILookup<TKey, TValue>. Otherwise, I'd go for IDicti... | <p>If the context is a throw-away value and (here comes the important part) will not be serialized, e.g. for sending the data to another system, I'd go with the IDictionary because it makes using your interface more flexible.</p>
<p>If, on the other hand, the context is kept all the time or the context will be seriali... | 17,428 |
<p>I want to put Apache 2.2.9 in front of a Weblogic 9.2 server on Windows XP. What does it take to do that ?<br></p>
<p>I probably need mod_proxy on the apache side ? <br></p>
<p>As far as Weblogic and apache are concerned, is there something similar to mod_jk ?<br></p>
<p>I would like this setup so that I can intr... | <p>The right way to do this is to use the <em>Apache HTTP Server plug-in</em> provided by BEA/Oracle and bundled with Weblogic. </p>
<p>For details, refer to the legacy <a href="http://download.oracle.com/docs/cd/E13222_01/wls/docs92/index.html" rel="nofollow noreferrer">BEA WebLogic Server 9.2 Documentation</a> and m... | <p>We used the WebLogic plugin to load balance and front our applicatiosn, using virtual hosts and locations.</p>
<p>For example:</p>
<p>
ServerName www.domain.com</p>
<p>
WebLogicCluster 10.20.30.41:7002,10.20.30.42:7002
SetHandler weblogic-handler
</p>
<p></p>
<p>This config will balance requests to ... | 23,052 |
<p>Do you know a good and free Hashtable imlementation for Delphi 5 ?</p>
<p>I need to organize a huge amount of data in a hastable and I am bit worried about memory leak issues that I found in most available implementations on the web.</p>
<p>Tks</p>
| <p>You can also check out the open-source / formerly commercial <a href="http://sourceforge.net/projects/tpsystools/" rel="noreferrer">TurboPower SysTools</a>. Not sure how much it is being updated. At one point Julian Bucknall recommended it over his <a href="http://www.boyet.com/FixedArticles/EZDSL.html" rel="noref... | <p>Peter Below just posted a rework of something he did to the Embarcadero newgroups in the public.attachments. There's something under his profile on the CodeGear site at <a href="http://cc.codegear.com/Item/24825" rel="nofollow noreferrer">http://cc.codegear.com/Item/24825</a> that describes it.</p>
| 21,605 |
<p>Here is the scenario:</p>
<p>I'm writing an app that will watch for any changes in a specific directory. This directory will be flooded with thousands of files a minute each with an "almost" unique GUID. The file format is this:</p>
<p>GUID.dat where GUID == xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(the internal contents ar... | <p>A couple of things that I have in my head:</p>
<ul>
<li>If the guid is <em>not</em> unique, would it not overwrite the file with the same name, or is the check based on a lookup which does some external action (e.g. check the archive)? (i.e. is this a YAGNI moment?)</li>
<li>I've used FileSystemWatcher before with ... | <p>I suggest you take a look at the <a href="http://msdn.microsoft.com/en-us/library/bb762118(VS.85).aspx" rel="nofollow noreferrer">SHChangeNotify</a> API call, which can notify you of all kinds of shell events. To monitor file creation and deletion activity, you may want to pay special attention to the SHCNE_CREATE ... | 4,858 |
<p>I have been working hard the last year on the model below. I am new to everything 3D that is modeling and especially 3D printing. I have however successfully concluded quite a good number of 3D prints which I created in blender with my Creality Ender 3 Pro so I have a bit of experience.</p>
<p>All this new experien... | <p>Basically you need to write a G-code file yourself. This is a plain text file with a <code>.g</code> extension.</p>
<p>You need to home the printer with <code>G28</code>, then move the Y axis all the way forward (for a Prusa style printer) with <code>G1 F1500 Y{ymax}</code> (where <code>{ymax}</code> is the length ... | <p>Never mind, figured the quickest dirtiest way myself - created a tall thin cylinder shape model in Blender and positioned it in Repetier so the printer head will be clear of the table as it moves. Then just broke off the filament that was currently in the printer so it will stop feeding once the current piece gets t... | 1,648 |
<p>I get a URL from a user. I need to know:<br/>
a) is the URL a valid RSS feed?<br/>
b) if not is there a valid feed associated with that URL</p>
<p>using PHP/Javascript or something similar</p>
<p>(Ex. <a href="http://techcrunch.com" rel="nofollow noreferrer">http://techcrunch.com</a> fails a), but b) would return th... | <p>Found something that I wanted:</p>
<p>Google's <a href="http://code.google.com/apis/ajaxfeeds/" rel="noreferrer">AJAX Feed API</a> has a load feed and lookup feed function (Docs <a href="http://code.google.com/apis/ajaxfeeds/documentation/reference.html#_intro_fonje" rel="noreferrer">here</a>).</p>
<p>a) <a href="... | <p>Are you doing this in a specific language, or do you just want details about the RSS specification?</p>
<p>In general, look for the XML prolog:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
</code></pre>
<p>followed by an <rss> element, but you might want to validate it as XML, fully validate ... | 8,678 |
<p>I am doing an Financial Winforms application and am having some trouble with the controls.</p>
<p>My customer needs to insert decimal values all over the place (Prices, Discounts etc) and I'd like to avoid some of the repeating validation.</p>
<p>So I immediately tried the MaskedTextBox that would fit my needs (wi... | <p>This two overriden methods did it for me (disclaimer: this code is not in production yet. You may need to modify)</p>
<pre><code> protected override void OnKeyPress(KeyPressEventArgs e)
{
if (!char.IsNumber(e.KeyChar) & (Keys)e.KeyChar != Keys.Back
& e.KeyChar != '.')
{
... | <p>You only need to let numbers and decimal symbols through, and avoid a double decimal symbol. As an extra, this automatically adds a 0 before a starting decimal number.</p>
<pre><code>public class DecimalBox : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (e.KeyChar == ',')
... | 30,165 |
<p>I need to provide users with an easy way to move documents and lists items in WSS 3.0. They want to be able to move across lists, sites and site collections without loss of version history, metadata, and author/date info. This functionality is unfortunately not available OOB. Anyone know a good solution/product?</p>... | <p>None of the products out there can do it and even if they do, all of them would modify the dates and the by's (modified by). We developed a custom solution to do that.</p>
| <p>Ok, we also ended up developing a custom solution to meet the requirements of the customer. It turned out pretty good and we decided to make a small product out of it. For those interested a free version is now available @ <a href="http://www.sharepointproducts.com" rel="nofollow noreferrer">www.sharepointproducts.c... | 33,031 |
<p>What would be the most optimal algorithm (performance-wise) to calculate the number of divisors of a given number?</p>
<p>It'll be great if you could provide pseudocode or a link to some example.</p>
<p>EDIT: All the answers have been very helpful, thank you. I'm implementing the Sieve of Atkin and then I'm going ... | <p>Dmitriy is right that you'll want the Sieve of Atkin to generate the prime list but I don't believe that takes care of the whole issue. Now that you have a list of primes you'll need to see how many of those primes act as a divisor (and how often).</p>
<p><strike><a href="https://web.archive.org/web/20141017041436/h... | <p>I don't know the MOST efficient method, but I'd do the following:</p>
<ul>
<li>Create a table of primes to find all primes less than or equal to the square root of the number (Personally, I'd use the Sieve of Atkin)</li>
<li>Count all primes less than or equal to the square root of the number and multiply that by t... | 13,560 |
<p>There are 3 web apps.</p>
<p>Site A and B are both ASP.NET Web Application with FormsAuthentications configurations, and there is a protected folder in site B which also configured correctly in the web.config. Site C is a classic ASP web which keep authentication status with Session.</p>
<p>Now please consider the... | <p>Both ASP and ASP.NET use a session cookie which is stored in memory of the browser process. Opening a new browser window from a link doesn't start a new process just opens a new window owned by the same process as the original window.</p>
<p>Closing a window doesn't 'logoff' the session because the session cookie... | <p>Use session.abandoned on window.close event for example.</p>
<p>Create function which will be loaded in header and catch event window.close.
Do not forget to verify if previous page is from the same domain/IP.
Because your user can forgot to logoff and go to some other website and then click back button...</p>
| 33,603 |
<p>How can you get MSSQL server to accept Unicode data by default into a VARCHAR or NVARCHAR column?</p>
<p>I know that you can do it by placing a N in front of the string to be placed in the field but to by quite honest this seems a bit archaic in 2008 and particuarily with using SQL Server 2005.</p>
| <p>The <code>N</code> syntax is how you specify a unicode string literal in SQL Server.</p>
<pre><code>N'Unicode string'
'ANSI string'
</code></pre>
<p>SQL Server will auto convert between the two when possible, using either a column's collation or the database's collation.</p>
<p>So if your string literals don't ac... | <p>While you can simply store UTF8 content in a VARCHAR field in MSSQL Server as long as charset translation is not done you should be aware that:</p>
<ol>
<li><p>No management/reporting/data tools outside of your application will be able to understand your non-english characters.</p></li>
<li><p>Language specific han... | 20,187 |
<p>I know that there is no official API for Google Analytics but is there a way to access Google Analytics Reports with C#?</p>
| <p><strong>Update</strong>: Google launched a Google Analytics API today.
<a href="http://analytics.blogspot.com/2009/04/attention-developers-google-analytics.html" rel="noreferrer">Google Analytics Blog - API Launched</a></p>
| <p>Yet another analytics API for C#
<a href="https://github.com/igooana/igooana" rel="nofollow">https://github.com/igooana/igooana</a></p>
<p>This project is aimed at C# 5 and uses <code>async/await</code> and <code>dynamic</code> extensively.
I tried to make this API as simple as possible and maximum type-safe.</p>
| 3,657 |
<p>Is it possible to get Mercurial to show progress of long-running push or pull operation? Google tells me basically "no", but does somebody know better? I was expecting something like <code>hg pull -v</code>...</p>
| <pre><code>hg pull -v
</code></pre>
<p>-v / --verbose</p>
<p>is a global option that applies to all sub-functions. </p>
<p>If you want extra data: </p>
<pre><code> hg --debug -v pull
</code></pre>
| <pre><code>hg pull -v
</code></pre>
<p>-v / --verbose</p>
<p>is a global option that applies to all sub-functions. </p>
<p>If you want extra data: </p>
<pre><code> hg --debug -v pull
</code></pre>
| 39,741 |
<p>Yesterday, I asked <a href="https://stackoverflow.com/questions/119107/how-do-i-generate-a-list-of-n-unique-random-numbers-in-ruby">this</a> question and never really got an answer I was really happy with. I really would like to know how to generate a list of N unique random numbers using a functional language such ... | <pre><code>>>> import random
>>> print random.sample(xrange(100), 5)
[61, 54, 91, 72, 85]
</code></pre>
<p>This should yield 5 unique values in the range <code>0 — 99</code>. The <code>xrange</code> object generates values as requested so no memory is used for values that aren't sampled.</p>
| <p>I can't really read your LINQ, but I think you're trying to get 5 random numbers up to 100 and then remove duplicates.</p>
<p>Here's a solution for that:</p>
<pre><code>def random(max)
(rand * max).to_i
end
# Get 5 random numbers between 0 and 100
a = (1..5).inject([]){|acc,i| acc << random( 100)}
# Rem... | 14,832 |
<p>While the built-in analytics of MOSS2007 are nice to have - they are inadequate at the same time. Any ideas where I can look for a more comprehensive package? Am I missing something?</p>
<p>Thanks,
Carl</p>
| <pre><code>var=`svn ls`
if [[ $? == 0 ]]
then
export var
else
unset var
fi
</code></pre>
<p><code>$?</code> is the exit code of the last command executed, which is <code>svn ls</code> here.</p>
<p>jmohr's solution is short and sweet. Adapted mildly,</p>
<pre><code>var=`svn ls` && export var ... | <pre><code>export FOO=$(your-command) || echo "your-command failed"
</code></pre>
| 30,770 |
<p>By default the session expiry seems to be 20 minutes. </p>
<p>Update: I do not want the session to expire until the browser is closed.</p>
<p>Update2: This is my scenario. User logs into site. Plays around the site. Leaves computer to go for a shower (>20 mins ;)). Comes back to computer and <em>should</em> be abl... | <p>If you want to extend the session beyond 20 minutes, you change the default using the IIS admin or you can set it in the web.config file. For example, to set the timeout to 60 minutes in web.config:</p>
<pre><code><configuration>
<system.web>
<sessionState timeout="60" />
... other eleme... | <p>There's no way to explicitly clear the session if you don't communicate in some way between the client and the server at the point of window closing, so I would expect sending a special URI request to clear the session at the point of receiving a window close message.</p>
<p>My Javascript is not good enough to give... | 11,952 |
<p>I'm trying to start <code>iexplore.exe</code> let it run for 5 seconds and then close it again.</p>
<p><code>iexplore</code> opens just fine however it doesn't close when I call the PostThreadMessage.
Can anyone see what I'm doing wrong? Here is my code:</p>
<pre><code>CString IEPath = "C:\\Program Files\\Interne... | <p>if you can enumerate the windows on the desktop and send a WM_CLOSE to the IE window , it might work .. you can use the spy programme to get the window class of the IE window </p>
| <p>I don't have an answer specifically why PostThreadMessage didn't work. But, perhaps if you elaborate on why you want to do this, there is a better solution?</p>
<p>For example, if you just want to show a web page for 5 seconds, you can create and show your own window with an embedded Internet Explorer ActiveX contr... | 35,446 |
<p>I am looking to do some tinkering with openGL and Python and haven't been able to find good reasons for using PyOpenGl versus pyglet</p>
<p>Which would you recommend and why?</p>
| <p>As Tony said, this is really going to depend on your goals. If you're "tinkering" to try to learn about OpenGL or 3D rendering in general that I would dispense with all pleasantries and start working with PyOpenGL, which is as close are you're going to get to "raw" 3D programming using Python.</p>
<p>On the other ... | <p>pyglet has a lot of nice extras included with it (like image loading and sound). If you're starting out, I'd try pyglet first, and then switch to PyOpenGL if you feel like you want to get closer to the metal.</p>
<p>The real important question though is: what are you trying to accomplish? </p>
| 35,380 |
<p>In my database application I sometimes have to deal with <code>null</code> strings in the database. In most cases this is fine, but when it comes do displaying data in a form the Swing components - using <code>JTextField</code> for example - cannot handle null strings. (<code>.setText(null)</code> fails)</p>
<p>(<s... | <p>If you are using any ORM tool or somehow you map your DB fields to Java bean you can allways have:</p>
<pre>
public void setFoo(String str) {
this.foo = str != null ? str : "";
}
</pre>
| <p>If you can, add a default value - empty string - for a field in DB .</p>
| 34,209 |
<p>I would like to pass an x amount of geo-locations to the Google Maps API and have it centered around these locations and set the appropriate zoom level so all locations are visible on the map. I.e. show all the markers that are currently on the map.</p>
<p>Is this possible with what the Google Maps API offers by de... | <p>There are a number of ways of doing this but it is pretty easy if you are using the V2 API. See this <a href="http://blog.jeromeparadis.com/archive/2007/02/08/1468.aspx" rel="nofollow noreferrer">post for an example</a>, <a href="http://groups.google.com/group/Google-Maps-API/browse_thread/thread/996f83e075e51fdf/d1... | <p>Gray's Idea is great but does not work as is. I had to work out a hack for a <strong>zoomToMarkers</strong> API V3:</p>
<pre><code>function zoomToMarkers(map, markers)
{
if(markers[0]) // make sure at least one marker is there
{
// Get LatLng of the first marker
var tempmark =markers[0].getP... | 41,789 |
<p>I am using VMware Workstation 6.5 on Windows Vista x64. I would like to automate some of the VM management tasks. I know that there is a COM API (<a href="http://www.vmware.com/support/developer/vix-api/" rel="noreferrer">http://www.vmware.com/support/developer/vix-api/</a>) available which I could use directly.</p>... | <p>ArnieZ.</p>
<p>Any COM DLL can be used from .NET. Adding it as reference in visual studio will generate a DLL called</p>
<p>"YourDll.Interop.dll"</p>
<p>This is a .NET -> COM marshaling library, and will do what you need.</p>
<p>You can also generate this from the command line using tlbimp.exe</p>
<p>Of course,... | <p>How 'bout adding a reference to this API in your VS.Net and let VS.Net create a managed wrapper for you? I'm not aware of any "managed" API for this. Let me know if you find it :)</p>
| 49,283 |
<p>I'm having some trouble understanding how command parameter binding works.</p>
<p>When I create an instance of the widget class before the call to InitializeComponent it seems to work fine. Modifications to the parameter(Widget) in the ExecuteCommand function will be "applied" to _widget. This is the behavior I e... | <p>InitializeCompenent processes the xaml associated with the file. It is at this point in time that the CommandParameter binding is first processed. If you initialize your field before InitializeCompenent then your property will not be null. If you create it after then it is null.</p>
<p>If you want to create the wid... | <p>Even with the dependency property, you still need to call CommandManager.InvalidateRequerySuggested to force the CanExecute of the Command being evaluated.</p>
| 32,118 |
<p>For various reasons, such as cookies, SEO, and to keep things simple, I would like to make apache automatically redirect any requests for <a href="http://www.foobar.com/anything" rel="nofollow noreferrer">http://www.foobar.com/anything</a> to <a href="http://foobar.com/anything" rel="nofollow noreferrer">http://foob... | <p>It's as easy as:</p>
<pre><code><VirtualHost 10.0.0.1:80>
ServerName www.example.com
Redirect permanent / http://example.com/
</VirtualHost>
</code></pre>
<p>Adapt host names and IPs as needed :)</p>
| <pre><code>RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
</code></pre>
<p>That should do the trick.</p>
| 11,366 |
<p>We're in the process of setting up a new framework and way of doing business for our new internal apps. Our current design dictates that all security logic should be handled by our database, and all information (and I mean all) will be going in and out of the database via stored procedures.</p>
<p>The theory is, th... | <p><strong>Don't do that</strong>. We recently had a <strong>VERY BAD</strong> experience when the "database guru" decided to go to another company. The maintenance of all the logic in the procedures are just horrible!!</p>
<p>Yes, you're going to have some performance improvement, but that's not worth it. In fact, pe... | <p>My opinion is that the application itself should handle authentication and authorisation. On the database side you should only handle encryption of data as needed.</p>
| 7,967 |
<p>In history-books you often have timeline, where events and periods are marked on a line in the correct relative distance to each other. How is it possible to create something similar in LaTeX?</p>
| <p>The <a href="http://ctan.org/pkg/pgf" rel="noreferrer">tikz</a> package seems to have what you want.</p>
<pre><code>\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{snakes}
\begin{document}
\begin{tikzpicture}[snake=zigzag, line before snake = 5mm, line after snake = 5mm]
% draw horizontal line
... | <p>There is <a href="http://www.tex.ac.uk/tex-archive/macros/latex209/contrib/timeline/timeline.sty" rel="nofollow noreferrer">timeline.sty</a> floating around.</p>
<p>The syntax is simpler than using tikz:</p>
<pre><code>%%% In LaTeX:
%%% \begin{timeline}{length}(start,stop)
%%% .
%%% .
%%% .
%%% \end{timeline... | 26,776 |
<p>I'm trying to start using LINQ and specifically LINQ to SQL but I'm having some difficulties</p>
<p>I've tried this with SqlMetal and now using the database table designer in Visual Studio and I keep getting similar errors, like in this code, using the data context I created with the database layout designer in VS2... | <p>Try </p>
<pre><code>var user = from u in dc.User
where u.UserName == usn
select u;
</code></pre>
| <p>The User you are referring to (when you don't use dc.User) is the Page.User member. That's why intellisense isn't complaining.</p>
| 25,054 |
<p>I am looking to integrate Crystal Reports 2008 into a Windows Forms application. I would like to avoid direct connections from my client application to the database, while giving the user the "complete" report experience. Is it possible to for Crystal Reports 2008 to execute a report on a server into a client-side W... | <p>I don't know if it is exactly what you are after, but I can think of 2 ways you could fudge it :</p>
<ol>
<li>You can set up your report so that the 'database' is an XSD file, with no knowledge of the real backend. Then at runtime you push the data to the report.</li>
</ol>
<p>// Create an instance at runtime app... | <p>This isn't really what you're asking, but Crystal Reports Server does server-side reporting. </p>
<p>On the downside, it's annoyingly expensive.</p>
<p><a href="http://www.businessobjects.com/product/catalog/crystalreports_server/" rel="nofollow noreferrer">http://www.businessobjects.com/product/catalog/crystalrep... | 20,423 |
<p>MSDN displays the following for CreatePatternBrush:</p>
<blockquote>
<p>You can delete a pattern brush without
affecting the associated bitmap by
using the DeleteObject function.
Therefore, you can then use this
bitmap to create any number of pattern
brushes.</p>
</blockquote>
<p>My question is the opp... | <p>The HBRUSH and HBITMAP are entirely independent. The handles can be deleted entirely independent from each other, and, once created, no changes to either object will effect the other.</p>
| <p>I think the bitmap must outlive the brush: the brush just references the existing bitmap rather than copying it.</p>
<p>You could always try it and see what happened.</p>
| 7,977 |
<p>Imagine the following Ruby Module:</p>
<pre><code>module Foo
def inst_method
puts "Called Foo.inst_method"
end
def self.class_method
puts "Called Foo.class_method"
end
end
</code></pre>
<p>Obviously <code>Foo.class_method</code> can be called without any class instances. However, what's happening t... | <p>The primary purpose of instance methods within modules is to give that functionality to classes that include it.</p>
<p>"Mixing in" a module this way is most commonly used as a method of simulating <a href="http://en.wikipedia.org/wiki/Multiple_inheritance" rel="noreferrer">multiple inheritance</a>, or in other sit... | <p>My answer would be : "no you can't call module instance methods without first extending or including that module in a class" </p>
<p>now knowing ruby and all the meta programming trickery it contains there probably <em>is</em> a way to call it but it would be outside the intended use of modules</p>
<pre><code>modu... | 19,529 |
<p>I've used jdom in the past, and have looked briefly at XOM and <code>DOM4j</code>. Each seems to provide essentially the same thing, as they each provide a simplified wrapper over the (very obtuse) standard W3C DOM APIs. </p>
<p>I know that JDOM went through some effort to develop a JSR and standardization process... | <p>I like <a href="http://www.xom.nu/" rel="nofollow noreferrer">XOM</a>, because I like the way Elliotte Rusty Harold thinks. Of the ones you mention I belive it's the one that strays away from the DOM standard API:s the most, but I consider that a benefit.</p>
<p>I once implemented a DOM library for Cocoa, and XOM w... | <p>It all depends on the feature set. If you want to benefit from an XSL Transformation Engine (Like Xalan) or an XPath Engine (Like Jaxen or Saxon) I would recommend sticking to the more popular framework available like Apache Xerces, JDOM.</p>
<p>After that, it's all a matter of taste. I personnally use a W3C compli... | 4,521 |
<p>I have an after_save filter which I dont want to trigger in a specific instance. Is there a way to do this similar to save_without_validation?</p>
<p>Thanks,</p>
| <p>When using rails 2, you can invoke the private method <code>create_without_callbacks</code> by doing:</p>
<pre><code>@my_obj.send(:create_without_callbacks)
</code></pre>
| <p>There is a good example of extending ActiveRecord to provide callback skipping here: <a href="http://weareintegrum.com/?p=10" rel="nofollow noreferrer">http://weareintegrum.com/?p=10</a></p>
<p>The idea is to create a method on ActiveRecord called skip_callback that accepts a block:</p>
<pre><code>def self.skip_ca... | 40,759 |
<p>the question I am having is: when running my app with a launch code other than sysAppLaunchCmdNormalLaunch, I can not use code outside the default code segment - but could I use a shared library that is multi-segmented, thus circumventing this problem?</p>
<p>A bit of background information: I am evaluating the pos... | <p>I don't have experience with using shared libraries, but we've had this problem with our software, and we've come across three different ways to solve the problem.</p>
<p>Possibly the easiest is to enable Expanded Mode when using the Metrowerks compiler, but I'm not completely certain that this works. This special... | <p>Store a pointer to a nice large structure you allocate with MemPtr in Ftr memory using FtrSet. This can be retrieved anywhere in your application that needs global access using FtrGet.</p>
<p>Alternately use <code>__STANDALONE_CODE_RESOURCE__</code> to put each function into a seperate code segment and use a shared... | 23,626 |
<p>I'm currently using Magento 1.1.6. My store only sells unique items (shirts with exclusive designs) which means at any one time, only 1 unit is available for each items.</p>
<p>How do I omit those items which are already sold from being displayed in the front page?</p>
<p>BTW, I'm using these code to show products... | <p>Go to System>Configuration>Catalog>Inventory>Stock Options. the dropdown for "Display Out of Stock Products" change to No.</p>
| <p>I supposed the file catalog/product/list_home_batik.phtml is based on catalog/product/list.phtml</p>
<p>You can modify the file catalog/product/list_home_batik.phtml by adding</p>
<pre><code><?php if($_product->isSaleable()): ?>
</code></pre>
<p>just after</p>
<pre><code><?php foreach ($_productColle... | 49,399 |
<p>I've started refactoring some legacy code recently and came across two functions for drawing a coordinate grid, the problem is that these functions differ only in orthogonal variables they treat, something like that</p>
<pre><code>void DrawScaleX(HDC dc, int step, int x0, int x1, int y0, int y1)
{
for(int x = x... | <p>Why you just do not extract the body of the for cycle into a separate function? Then you can do the funny stuff in the extracted function. </p>
<pre><code>void DrawScaleX(HDC dc, int step, int x0, int x1, int y0, int y1)
{
for(int x = x0; x < x1; x += step)
{
DrawScale(dc, x, y0, x, y1);
}
}
... | <p>Here is my own solution</p>
<pre><code>
class CoordGenerator
{
public:
CoordGenerator(int _from, int _to, int _step)
:from(_from), to(_to), step(_step), pos(_from){}
virtual POINT GetPoint00() const = 0;
virtual POINT GetPoint01() const = 0;
bool Next()
{
if(pos > step) r... | 10,621 |
<p>I'd like to learn assembler. However, there are very few resources for doing assembler with OS X.</p>
<p>Is there anyone out there who has programmed in assembly on a Mac? Where did you learn?</p>
<p>And, is there any reason I shouldn't be doing assembly? Do I risk (significantly) crashing my computer irreparab... | <p>If you're using a PowerPC Mac, look into gcc inline assembler. Otherwise, look into nasm. I can't give any decent references to PPC ASM (they're few and far between), but I suggest the following things to learn x86 asm:</p>
<ul>
<li>The book <a href="https://rads.stackoverflow.com/amzn/click/com/0764574817" rel=... | <p>There's no reason why you shouldn't; there is nothing you can do in assembly language that you can't do in a higher level language like C.</p>
<p>As far as tools go, you might want to install <a href="http://macports.org" rel="nofollow noreferrer">MacPorts</a> and get the GNU assembler. That may or may not be the e... | 16,633 |
<p>Is there a <code>HTMLHelper</code> for file upload? Specifically, I am looking for a replace of</p>
<pre><code><input type="file"/>
</code></pre>
<p>using ASP.NET MVC HTMLHelper. </p>
<p>Or, If I use </p>
<pre><code>using (Html.BeginForm())
</code></pre>
<p>What is the HTML control for the file upload? <... | <p><strong>HTML Upload File ASP MVC 3.</strong></p>
<p><strong>Model</strong>: (<em>Note that FileExtensionsAttribute is available in MvcFutures. It will validate file extensions client side and server side.</em>)</p>
<pre><code>public class ViewModel
{
[Required, Microsoft.Web.Mvc.FileExtensions(Extensions = "cs... | <p>This is a little hacky I guess, but it results in the correct validation attributes etc being applied</p>
<pre><code>@Html.Raw(Html.TextBoxFor(m => m.File).ToHtmlString().Replace("type=\"text\"", "type=\"file\""))
</code></pre>
| 39,153 |
<p>Hey all, I need some advice on this...</p>
<p>We have certain permissions setup in the database for certain levels of control a user can have over the application. Disabled, ReadOnly and Edit. </p>
<p>My question is: Are there more generic/better ways to handle permissions applied to a form element on the page tha... | <p>Sorry for going slightly off-topic here, but learn from my mistake:</p>
<p>I had a simple web app one time that I was developing and I thought that I'd setup 3 levels of security: limited read-only (public), read-limited write (user), read-write (admin). The users table had a level of security in it and everything... | <p>To work properly, I have found that access levels should be in this increasing order:
NONE, VIEW, REQUIRED, EDIT.</p>
<p>Note that REQUIRED is NOT the top level as you may think it would be since EDIT (both populate & de-populate permission) is a greater privilege than REQUIRED (populate-only permission).</p>
... | 34,464 |
<p>Every time I call this method my NSMutableData is leaking and I cannot figure out how to plug it. theData's retain count is upped by one after the decoder is allocated and initialized and I have no idea why. I am stuck with a retain count of 2 at the end of the method and attempting to release it causes an app crash... | <p>I would suggest replacing this line:</p>
<pre><code>venueIOList = [[decoder decodeObjectForKey:inKey] mutableCopy];
</code></pre>
<p>with:</p>
<pre><code>ListClassName *decodedList = [decoder decodeObjectForKey:inKey];
self.venueIOList = decodedList;
</code></pre>
<p>This makes the memory management of <code>dec... | <p>Your code is correct; there is no memory leak.</p>
<pre><code>theData = [NSData dataWithContentsOfFile:inFile];</code></pre>
<p>is equivalent to </p>
<pre><code>theData = [[[NSData alloc] initWithContentsOfFile:inFile] autorelease];</code></pre>
<p>At this point theData has a reference count of 1 (if less, it wo... | 20,401 |
<p>I'm trying to pass u url as parameter to a get method.
I defined a route that accepts a {*url} parameter so I can send "/" characters without it separating my parameter.
As soon as there is a ":" in the url (like in http: or localhost:3857 for example), the method never gets hit.</p>
<p>The Html.ActionLink method e... | <p>Use EncodeUrl before you pass it, and then decode it on the other side.</p>
| <p>It's a bit of a hack, but you could replace the ':' with '%3A' (which is the escaped form), and see what the ActionLink does with it. If it's escaped once more, you'd have to replace the twice-escaped version back to ':' at the server, otherwise just replace '%3A' back to ':'</p>
| 45,935 |
<p>Can some one specify the windows API, one need to use in order to be able to change programmatically the screen refresh rate?</p>
| <p>I found this via a google search. Hope it helps some.</p>
<p><a href="http://www.codeproject.com/KB/winsdk/changerefresh.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/winsdk/changerefresh.aspx</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms533260(VS.85).aspx" rel="nofollow noreferrer... | <p>I found this via a google search. Hope it helps some.</p>
<p><a href="http://www.codeproject.com/KB/winsdk/changerefresh.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/winsdk/changerefresh.aspx</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms533260(VS.85).aspx" rel="nofollow noreferrer... | 17,639 |
<p>I'm trying to copy a bunch of files below a directory and a number of the files have spaces and single-quotes in their names. When I try to string together <code>find</code> and <code>grep</code> with <code>xargs</code>, I get the following error:</p>
<pre><code>find .|grep "FooBar"|xargs -I{} cp "{}" ~/foo/bar
xa... | <p>You can combine all of that into a single <code>find</code> command:</p>
<pre><code>find . -iname "*foobar*" -exec cp -- "{}" ~/foo/bar \;
</code></pre>
<p>This will handle filenames and directories with spaces in them. You can use <code>-name</code> to get case-sensitive results. </p>
<p>Note: The <code>--</co... | <p>If you are using Bash, you can convert <em>stdout</em> to an array of lines by <code>mapfile</code>:</p>
<pre><code>find . | grep "FooBar" | (mapfile -t; cp "${MAPFILE[@]}" ~/foobar)
</code></pre>
<p>The benefits are:</p>
<ul>
<li>It's built-in, so it's faster.</li>
<li>Execute the command with all file names in ... | 17,293 |
<p>Here's a very simple question. I have an SP that inserts a row into a table and at the end there's the statement RETURN @@IDENTITY. What I can't seem to find is a way to retrieve this value in C#. I'm using the Enterprise library and using the method:</p>
<pre><code>db.ExecuteNonQuery(cmd);
</code></pre>
<p>I've t... | <pre><code>Dim c as new sqlcommand("...")
Dim d As New SqlParameter()
d.Direction = ParameterDirection.ReturnValue
c.parameters.add(d)
c.executeNonQuery
(@@IDENTITY) = d.value
</code></pre>
<p>It is more or less like this...either this or just return the value from a stored procedure as an output parameter.</p>
| <p>Sounds to me like you want to execute with a scalar value</p>
<pre><code>SqlCommand.ExecuteScalar()
</code></pre>
<p>as others have mentioned I think using SCOPE_IDENTITY() is more secure than the @@IDENTITY variable</p>
| 30,573 |
<p>I have data coming from the database in the form of a <code>DataSet</code>. I then set it as the <code>DataSource</code> of a grid control before doing a <code>DataBind()</code>. I want to sort the <code>DataSet</code>/<code>DataTable</code> on one column. The column is to complex to sort in the database but I was h... | <p>Because of how DataTable (and DataView) sorting works, you can't use the delegate approach directly. One workaround is to add a column to the data-table that represents the order, and set the value (per row) based on the desired sequence. You can then add a Sort to the view on this new column. For example (using LIN... | <p>You can sort the Database in memory , but I don't know what "too complex to sort in the database" would be. If I were you I would try to get it sorted in the database, use Views, Redundancy Indexes, complex SQL statements, it's probably going to be faster than sorting a large Dataset in memory, with the added advant... | 28,327 |
<p>Consider two web pages with the following in their body respectively:</p>
<pre><code><body>
<script>
document.writeln('<textarea></textarea>')
</script>
</body>
</code></pre>
<p>and</p>
<pre><code><body>
<script>
var t = document.createElement('textarea');
document.... | <p>I believe the document.write version actually blows away an existing content on the page. Ie, the body and script tags will no longer be there. That is why people usually use appendChild.</p>
<p>Keeping the text or not is very browser specific. I wouldn't bet that Firefox would not change it's behavior on that in a... | <p>Would it be possible for you to add a hook which you could use to target the new textarea into? eg. a <div></p>
<pre><code><div id="addtextarea"></div>
var e = document.getElementByID('addtextarea');
e.innerHTML = '<textarea></textarea>';
</code></pre>
<p>Then if you needed to rememb... | 47,929 |
<p>In WinForms, I can design a form and have a TabValue to control which control is selected each time the user hits 'Tab'. My question, in a Webform, is there a mechanism for doing the same thing? </p>
<p>Edit: Does the same apply to an Ajax heavy application?</p>
| <p>You can set this with the TabIndex property on the ASP controls. If you want to do this on something that isn't an ASP control, you could also try something like the <a href="http://fluidproject.org/blog/2008/01/11/jquery-tabindex-plugin/" rel="noreferrer">jQuery tabIndex plugin</a>.</p>
| <p>Web controls have a TabIndex property that you can set.</p>
| 29,051 |
<p>Suppose we have some named enums:</p>
<pre><code>enum MyEnum {
FOO,
BAR = 0x50
};
</code></pre>
<p>What I googled for is a script (any language) that scans all the headers in my project and generates a header with one function per enum.</p>
<pre><code>char* enum_to_string(MyEnum t);
</code></pre>
<p>... | <p>You may want to check out <a href="http://www.gccxml.org/HTML/Index.html" rel="noreferrer">GCCXML</a>.</p>
<p>Running GCCXML on your sample code produces:</p>
<pre><code><GCC_XML>
<Namespace id="_1" name="::" members="_3 " mangled="_Z2::"/>
<Namespace id="_2" name="std" context="_1" members="" m... | <p>That's pretty much the only way it can be done (an array of string could work also).</p>
<p>The problem is, once a C program is compiled, the binary value of the enum is all that is used, and the name is gone.</p>
| 24,617 |
<p>I heard somewhere that you can drop down to C++ directly inside C# code.
How is this done? Or did I hear wrong?</p>
<p>Note: I do not mean C++ / CLI.</p>
| <p>You might be thinking of <a href="http://msdn.microsoft.com/en-us/library/chfa2zb8(VS.71).aspx" rel="nofollow noreferrer"><code>unsafe</code> blocks</a> where you can write code that looks a lot like C++, since you can use pointers.</p>
| <p>Why would you need to do that? You can reference native C libraries, but I doubt very much that you can run native code from within managed code.</p>
| 23,857 |
<p>Does any one know of a control that i can use with a ASP.Net gridview that provides the functionality of the ASP.Net Ajax Control PagingBulletedList. I want to provide the users with a easier way to access the data in the grid.</p>
<p>It should ideally work in the same way paging for the grid works except that it s... | <p>Unfortunatly there is nothing already buildt for this. To build your own you will have to create your own <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pagertemplate.aspx" rel="nofollow noreferrer">PagerTemplate</a>.</p>
<p>There is something similiar with code in it in this <a... | <p>DataGrid has its own set of data sorting that you can tap, for example, you can page a GridView by adding 'AllowPaging="true"' in the gridview markup (or by code-behind, doesn't matter). You can also allow for sorting ('AllowSorting="true"').</p>
<p>Unfortunately, I haven't come across a control of such nature whe... | 48,015 |
<p>Is it possible to access the database backend of a sharepoint server? My company uses Sharepoint to store data and pictures of various assets. Ideally I would be able to access the data and display it in my application to allow users both methods of access.</p>
<p>Before I go talk to the IT department I would like ... | <p>Agree with Adam. Querying the Sharepoint Database is a big no-no, as Microsoft does not guarantee that the Schema is in any way stable. Only access the database if there is really no other way.</p>
<p>As for Sharepoint, usually the Lists.asmx Web Service is what you want to look at first.</p>
<p><a href="https://www... | <p>Just a small comment. Never ever go to the database direct. If there is no way to do it via published and supported API's, then there is no way to do it. End of story. This applies even to when you are "just reading data", as this can still cause significant issues.</p>
| 5,316 |
<p>I just want ask the steps when trying to create a simple SQL select statement in UNIX inside/within IF..THEN..FI statement.</p>
<p>I know how to use the 'select' and 'if..then' statements in SQL*Plus, but I'm having a difficulties having a UNIX script to point to variables: If 'ABC' to 'Select...'</p>
<h2>Example:... | <p>This sounds like you're trying to embed SQLPlus in a shell script. From memory the incantation should look something like:</p>
<pre><code>if [ $? -eq ABC ]; then
SQLPLUS /S USER/PASS@Instance <<EOF
SET echo off;
SET pagesize 0;
SET heading off;
SPOOL foo.out
select foo from bar
EOF
fi
</code></pre>
<p>Every... | <p>The above answer was ok. However, I knew that, using SQLPlus in a shell script and unfortunately, I don't need the SQLPlus script to send the output to a file. In other words: Is there any other way of doing this, just print the output to a log?</p>
| 35,738 |
<p>I have a small C library in a DLL and I need to call a handful of its methods.</p>
<p>It uses pointers and a few structs but is otherwise quite simple. Problem is I'm not terribly knowledgable on .NET's interop with the unmanaged world and my attempts so far keep hitting memory access violation exceptions (presumab... | <p>You should check out the <a href="http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/CLRInsideOut2008_01.exe" rel="noreferrer">tool</a> given in this MSDN Magazine <a href="http://msdn.microsoft.com/en-us/magazine/cc164193.aspx" rel="noreferrer">article</a> that can translate a C snipp... | <p>Maybe you should write your wrapper in C++/CLI, because the interop between managed code and unmanaged code is very seamless.</p>
<p><strong>Update</strong></p>
<p>Here is a link to a trivial example: <a href="https://stackoverflow.com/questions/343654/c-data-structure-to-mimic-cs-listlistint#343683">C data struct... | 46,901 |
<p>In c#, is there any difference in the excecution speed for the order in which you state the condition?</p>
<pre><code>if (null != variable) ...
if (variable != null) ...
</code></pre>
<p>Since recently, I saw the first one quite often, and it caught my attention since I was used to the second one.</p>
<p>If there... | <p>It's a hold-over from C. In C, if you either use a bad compiler or don't have warnings turned up high enough, this will compile with no warning whatsoever (and is indeed legal code):</p>
<pre><code>// Probably wrong
if (x = 5)
</code></pre>
<p>when you actually probably meant</p>
<pre><code>if (x == 5)
</code></p... | <p>One more thing... If you are comparing a variable to a constant (integer or string for ex.), putting the constant on the left is good practice because you'll never run into NullPointerExceptions :</p>
<pre><code>int i;
if(i==1){ // Exception raised: i is not initialized. (C/C++)
doThis();
}
</code></pre>
... | 34,153 |
<p>I have an Anet A8 printer for about 4 months, set up pretty well (or so I thought) and printing a number of models pretty well. I made a large 3" x 6" box with a sliding lid yesterday and when it was done there was a gap on one side when the lid was slid on. I checked the parts and it turns out they are not square -... | <p><strong>Quick, low-tech solution:</strong></p>
<p>There might be several issues in your question, but in relation to bed adhesion, I'll share one of the most useful tips I wish someone had told me when I started out: <em>Spread some glue-stick over the area to be printed</em>.</p>
<p>I used ordinary school/craft g... | <p>It is hard to determine the exact source of the problem as there are few possibilities (I am assuming that you have a single nozzle and only one filament in use):</p>
<ol>
<li><p>One of the hardest issues for me to get on my printer was fact that my auto-level sensor was mounted about 0.5mm too high - so please che... | 864 |
<p>We just ran into a problem where everything was compiling correctly, but not being deployed to the mobile device during debugging. Of course this caused weird errors that were hard to track down. The solution was simple, just delete the directories on the mobile device. Is there a way to ensure/force the files to... | <p>Using VS2005 and unmanaged code (C++), I notice that VS will not deploy a new binary if there is already one on the device with a higher version number. If it is the same or lower, then everything is fine.</p>
| <p>In my experience, ActiveSync is not very consistent.<br>
Also, if the application deploys correctly if you first remove it from the device, it is probably not a configuration problem either. At least with VS2005 there are no magic knobs to twist in this regard. Does the deployment go very quickly, or does it look li... | 38,851 |
<p>I'm trying to figure out what the following line does exactly - specifically the %%s part?</p>
<pre><code>cursor.execute('INSERT INTO mastertickets (%s, %s) VALUES (%%s, %%s)'%sourcedest, (self.tkt.id, n))
</code></pre>
<p>Any good mini-tutorial about string formatting and inserting variables into strings with Pyt... | <p>The <code>%%</code> becomes a single <code>%</code>. This code is essentially doing two levels of string formatting. First the <code>%sourcedest</code> is executed to turn your code essentially into:</p>
<pre><code>cursor.execute('INSERT INTO mastertickets (BLAH, FOO) VALUES (%s, %s)', (self.tkt.id, n))
</code></... | <p>It does the same:</p>
<pre><code>cursor.execute('INSERT INTO mastertickets (%s, %s) VALUES (:%s, :%s)' % \
tuple(sourcedest + sourcedest), dict(zip(sourcedest, (self.tkt.id, n))))
</code></pre>
<p>Never do that.</p>
| 40,993 |
<p>Recently our team was facing the task to build the 2D slice between a plane and some set of 3D geometry (set of triangles). Google hasn't been as helpful as we have wanted it to be, so we turn our attention here to see if anyone has encountered this problem with a possible solution. Links are also wanted.</p>
<p>Fi... | <p>If you're not tied to any particular software, open your data set in ParaView (paraview.org) or ParaViewGeo (paraviewgeo.mirarco.org). </p>
<p>Both have a filter called Slice that does excactly what you're talking about and both allow you to save your data back out. </p>
<p>ParaViewGeo supports data formats (GoCad... | <p>The intersection of a plane and a triangle is a line segment or nothing (ignoring the degenerate case of the triangle being exactly in the plane).</p>
<p>So the result of your laser/knife scanning/slicing across the bunny model triangles is a collection of line segments. I'm not sure how/why you'd expect to get a ... | 25,500 |
<p>Is there a one button way to save a screenshot directly to a file in Windows?</p>
<br>
TheSoftwareJedi accurately answered above question for Windows 8 and 10. Below original extra material remains for posterity.
<blockquote>
<p>This is a very important question as the 316K views shows as of 2021.
Asked in 2008, SO... | <p>You can code something pretty simple that will hook the PrintScreen and save the capture in a file.</p>
<p>Here is something to start to capture and save to a file. You will just need to hook the key "Print screen".</p>
<pre class="lang-cs prettyprint-override"><code>using System;
using System.Drawing;
using Syste... | <p>Is this possible:</p>
<ol>
<li>Press Alt PrintScreen</li>
<li>Open a folder</li>
<li>Right click -> paste screenshot</li>
</ol>
<p>Example:</p>
<p>Benchmark result window is open, take a screenshot.
Open C:\Benchmarks
Right click -> Paste screenshot
A file named screenshot00x.jpg appears, with text screenshot00x ... | 19,119 |
<p>I want to use Perl to extract information from a <a href="http://en.wikipedia.org/wiki/Certificate_signing_request" rel="nofollow noreferrer">Certificate Signing Request</a>, preferably without launching an external openssl process. Since a CSR is stored in a base64-encoded ASN.1 format, I tried the <a href="http://... | <p>Maybe <a href="http://search.cpan.org/dist/Convert-X509/" rel="nofollow noreferrer">Convert::X509</a> can help you.
See also <a href="http://search.cpan.org/src/LEO/Convert-X509-0.1/X509/Parser.pm" rel="nofollow noreferrer">Convert::X509::Parser</a>.</p>
| <p>Your real question is what format are CSRs using? There are two formats to do it, PKCS #10 and SPKAC. The former is described in <a href="https://www.rfc-editor.org/rfc/rfc2986" rel="nofollow noreferrer">RFC 2986</a>. I don't know where the latter is described.</p>
| 27,959 |
<p>Why can't I create a <code>class</code> in <code>VB.NET</code> that <code>inherits</code> <code>System.IO.Directory</code>? According to Lutz Roeder, it is <em>not</em> declared as <code>NotInheritable</code>!</p>
<p>I want to create a <code>utility class</code> that adds functionality to the <code>Directory class... | <p>From the Meta Data of .NET</p>
<pre><code>namespace System.IO
{
// Summary:
// Exposes static methods for creating, moving, and enumerating through directories
// and subdirectories. This class cannot be inherited.
[ComVisible(true)]
public static class Directory
</code></pre>
<p>You ca... | <p>I'd guess that Reflector isn't picking up the sealed attribute correctly for VB (or perhaps just not displaying it properly). If you look at the IL, it is sealed:</p>
<p>class public abstract auto ansi <strong>sealed</strong> beforefieldinit Directory</p>
| 16,437 |
<p>I was surprised recently to find that it's possible to have a return statement in a finally block in Java.</p>
<p>It seems like lots of people think it's a bad thing to do as described in '<a href="https://web.archive.org/web/20070922061412/http://weblogs.java.net/blog/staufferjames/archive/2007/06/_dont_return_in.... | <p>The examples you provided are reason enough to <i>not</i> use flow-control from finally.</p>
<p>Even if there's a contrived example where it's "better," consider the developer who has to maintain your code later and who might not be aware of the subtleties. That poor developer might even be you....</p>
| <p>Returning from inside a <code>finally</code> block will cause <code>exceptions</code> to be lost.</p>
<p><strong>A return statement inside a finally block will cause any exception that might be thrown in the try or catch block to be discarded.</strong> </p>
<p>According to the <a href="http://docs.oracle.com/javas... | 7,045 |
<p>Assuming a largish template library with around 100 files containing around 100 templates with overall more than 200,000 lines of code. Some of the templates use multiple inheritance to make the usage of the library itself rather simple (i.e. inherit from some base templates and only having to implement certain busi... | <p>I'm not sure I see how/why templates are the problem, and why plain non-templated classes would be an improvement. Wouldn't that just mean even <em>more</em> classes, less type safety and so larger potential for bugs?</p>
<p>I can understand simplifying the architecture, refactoring and removing dependencies betwee... | <p>As mentioned, unit tests are a good idea. Indeed, rather than breaking your code by introducing "simple" changes that are likely to ripple out, just focus on creating a suite of tests, and fixing non-compliance with the tests. Have an activity to update the tests when bugs come to light.</p>
<p>Beyond that, I would... | 41,955 |
<p>I've got a cool piece of code taken from a VC++ project which gets complete information of the hard disk drive WITHOUT using WMI (since WMI has got its own problems).</p>
<p>I ask those of you who are comfortable with API functions to try to convert this VB6 code into VB.NET (or C#) and help A LOT of people who are ... | <p>I found it! Here is the equivalent VB.NET code. It's not exactly the converted version of the VB6 code, but does the same thing. Enjoy!</p>
<pre><code>Public Class HDDInfo
#Region " Declatrations "
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAcc... | <p>You can get this data of WMI. Let me get you an example</p>
| 35,103 |
<p>I want to put users into an instance of ADAM so that ADAM looks similar to a typical, real, Active Directory server.</p>
<p>I'm developing an application that integrates with LDAP. I've tested with OpenLDAP and its core.schema. Now I'd like to test with with Active Directory, but the closest I can get to that u... | <p>ADAM isn't really a complete replacement for Active Directory. For example, ADAM doesn't understand different group types, and doesn't include a RootDSE by default. You could test against ADAM but you may run into slight differences in your query structures.</p>
<p>If you are developing an application that will d... | <p>I am only aware of importing MS-Users file. I see ther is a step-step guide</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5163b97a-7df3-4b41-954e-0f7c04893e83&DisplayLang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?FamilyID=5163b97a-7df3-4b41-954e-0f7... | 20,633 |
<p>I configured Marlin 1.1.3 for auto-leveling with a fix mounted sensor connected to the Z end-stop pin.</p>
<p>I have the following settings in my config:</p>
<pre><code>#define X_PROBE_OFFSET_FROM_EXTRUDER 25
#define Y_PROBE_OFFSET_FROM_EXTRUDER 20
#define Z_PROBE_OFFSET_FROM_EXTRUDER 0 // Z offset: -below +... | <p>Yes, with the proper equipment.</p>
<p>Printing wax filament (at 51 seconds): <a href="https://youtu.be/tibkVZB_n9c?t=51s" rel="noreferrer">https://youtu.be/tibkVZB_n9c?t=51s</a></p>
<p>There are also options for melting wax, filling a heated reservoir head, and printing with that. I recommend doing this with a co... | <p>Just make a silicone mold of any of your prints and pour you wax in the silicone,you silicone putty is pretty cheap so is wax ,no need to break the bank as printers have become less expensive and can do a pretty good job </p>
| 630 |
<p>I want to check out all files in all subdirectories of a specified folder.</p>
<p>(And it is painful to do this using the GUI, because there is no recursive checkout option).</p>
| <p>Beware: ClearCase is File-centric, not repository centric (like SVN or CVS).</p>
<p>That means it is rarely a good solution to checkout all files (and it can be fairly long with ClearCase ;) )</p>
<p>That being said, the question is perfectly legitimate and I would like to point out another way:</p>
<p>open a <co... | <pre><code>cleartool find somedir -exec "cleartool checkout -nc \"%CLEARCASE_PN%\""
</code></pre>
<p>Also an article "<a href="http://www.ibm.com/developerworks/rational/library/4687.html" rel="noreferrer">ClearCase: The ten best scripts</a>" might be helpful</p>
| 5,366 |
<p>I'm looking for an algorithm that places tick marks on an axis, given a range to display, a width to display it in, and a function to measure a string width for a tick mark.</p>
<p>For example, given that I need to display between 1e-6 and 5e-6 and a width to display in pixels, the algorithm would determine that I ... | <p>As I didn't like any of the solutions I've found so far, I implemented my own. It's in C# but it can be easily translated into any other language.</p>
<p>It basically chooses from a list of possible steps the smallest one that displays all values, <strong>without leaving any value exactly in the edge</strong>, lets... | <p>I've been using the jQuery <a href="https://github.com/flot/flot/blob/master/API.md" rel="nofollow noreferrer">flot</a> graph library. It's open source and does axis/tick generation quite well. I'd suggest looking at it's code and pinching some ideas from there.</p>
| 29,357 |
<p>Is there a <code>SQL</code> or <code>PHP</code> script that I can run that will change the default collation in all tables and fields in a database?</p>
<p>I can write one myself, but I think that this should be something that readily available at a site like this. If I can come up with one myself before somebody p... | <p>Be careful! If you actually have utf stored as another encoding, you could have a real mess on your hands. Back up first. Then try some of the standard methods:</p>
<p>for instance
<a href="http://www.cesspit.net/drupal/node/898" rel="noreferrer">http://www.cesspit.net/drupal/node/898</a>
<a href="http://www.hacksz... | <p>Use my custom shell <a href="https://github.com/abdennour/miscs.sh/blob/master/collatedb" rel="nofollow">collatedb</a>, it should work : </p>
<pre><code>collatedb <username> <password> <database> <collation>
</code></pre>
<p>Example :</p>
<pre><code>collatedb root 0000 myDatabase utf8_bin
... | 13,105 |
<p>I have a Canvas where I'm drawing a bunch of shapes and other UI elements. This canvas can be very large so I want to put this in a panel which allows me to zoom in/out using the mouse and scroll by dragging the mouse, just like Google Maps. The closest thing I could find was the ScrollViewer but obviously this isn... | <p>Would this link be of any help? I havent gotten into WPF but a quick search yields this link and hopefully it helps you out:</p>
<p><a href="http://blogs.vertigo.com/personal/swarren/Blog/Lists/Posts/Post.aspx?ID=7" rel="nofollow noreferrer">http://blogs.vertigo.com/personal/swarren/Blog/Lists/Posts/Post.aspx?ID=7... | <p>if I remember correctly here you can find something like you want.</p>
<p><a href="http://www.codeproject.com/KB/vista/swordfishcharts.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/vista/swordfishcharts.aspx</a></p>
| 16,295 |
<p>In a web application, if it doesn't have a domain name (like a web service for example), can you still add a SSL certificate to a IP address?</p>
<p>If yes, how?</p>
| <p>You can easily put an ip address into the CN (common name) of an ssl certificate by the same procedure you would use for an ordinary hostname (ssl certificates contain hostnames, not domain names).</p>
<p>How this is done precisely in your case cannot be answered, since you have not stated what your case is.</p>
<... | <p>There's some good information here:
<a href="https://www.thawte.com/ssl-digital-certificates/technical-support/browserfaqs.html" rel="nofollow noreferrer">https://www.thawte.com/ssl-digital-certificates/technical-support/browserfaqs.html</a></p>
<p>I'm almost certain you need a domain to go with the SSL.</p>
| 39,942 |
<p>I am looking to use quartz to schedule emails, but I'm not sure which approach to take:</p>
<ol>
<li>Create a new job and trigger whenever an email is scheduled OR</li>
<li>Create a single job, and create a new trigger each time an email is scheduled</li>
</ol>
<p>I need to pass the message/recipient etc either wa... | <p>Quartz is intended to handle tens of thousands of triggers. The main limit to scalability here is the space available in your JobStore. A JDBCJobStore backed with a reasonable database should be able to handle hundreds of thousands of triggers.</p>
<p>If a single job can be parameterized through the trigger's job d... | <p>You might consider queuing or otherwise grouping a set of emails and have a single, or maybe a few, periodic (or scheduled) job(s) that then takes care of the 'batch'.</p>
<p>You could even have the Quartz job queue the emails for a collection of workers to consume and send.</p>
<p>I would not recommend thousands ... | 33,084 |
<p>It looks like I had a fundamental misunderstanding about C++ :<</p>
<p>I like the polymorphic container solution. Thank you SO, for bringing that to my attention :)</p>
<hr>
<p>So, we have a need to create a relatively generic container type object. It also happens to encapsulate some business related logic. H... | <p>You can look at using a standard container of <a href="http://www.boost.org/doc/libs/1_36_0/doc/html/any.html" rel="noreferrer">boost::any</a> if you are storing truly arbitrary data into the container.</p>
<p>It sounds more like you would rather have something like a <a href="http://www.boost.org/doc/libs/1_36_0/l... | <p>You could not have to give up Java-like interfaces and use templates as well. <a href="https://stackoverflow.com/questions/168408/c-alternatives-to-void-pointers-that-isnt-templates#168509" title="Josh's suggestion">Josh's suggestion</a> of a generic base template Container would certainly allow you do polymorp... | 20,331 |
<p>Is it possible to convert a <code>com.vividsolutions.jts.geom.Geometry</code> (or a subclass of it) into a class that implements <code>java.awt.Shape</code>? Which library or method can I use to achieve that goal?</p>
| <p>According to:</p>
<p><a href="http://lists.jump-project.org/pipermail/jts-devel/2007-May/001954.html" rel="nofollow noreferrer">http://lists.jump-project.org/pipermail/jts-devel/2007-May/001954.html</a></p>
<p>There's a class:</p>
<pre><code>com.vividsolutions.jump.workbench.ui.renderer.java2D.Java2DConverter
</c... | <p>According to:</p>
<p><a href="http://lists.jump-project.org/pipermail/jts-devel/2007-May/001954.html" rel="nofollow noreferrer">http://lists.jump-project.org/pipermail/jts-devel/2007-May/001954.html</a></p>
<p>There's a class:</p>
<pre><code>com.vividsolutions.jump.workbench.ui.renderer.java2D.Java2DConverter
</c... | 15,786 |
<p>When working with large and/or many Javascript and CSS files, what's the best way to reduce the file sizes?</p>
| <p>In addition to using server side compression, using intelligent coding is the best way to keep bandwidth costs low. You can always use tools like <a href="http://dean.edwards.name/download/#packer" rel="nofollow noreferrer">Dean Edward's Javascript Packer</a>, but for CSS, take the time to learn <a href="http://www.... | <p>I'd give a test-drive to the new runtime optimizers in ASP.Net published on <a href="http://www.codeplex.com/NCOptimizer" rel="nofollow noreferrer">http://www.codeplex.com/NCOptimizer</a></p>
| 9,123 |
<p>Looking to get a list of all the files (commit comments would be nice too) of a user in cvs. </p>
| <pre><code>cvs log -t -wJellyJoe
</code></pre>
| <p>You could also use external tools, such as <a href="http://www.viewvc.org/" rel="nofollow noreferrer">ViewVC</a>, which lets you input queries using web forms. The output is also formatted nicely in the web browser.</p>
| 46,194 |
<p>How do I learn PLC programming? Would it differ greatly for different brands of PLCs? Is ladder programming the same as PLC programming?</p>
| <p>I did a lot of PLC programming, and now do quite a bit of .NET programming. It's very dangerous to make the switch either way, because a lot of the skills that you think should be transferrable (patterns and such) lead you very far astray.</p>
<p>The biggest difference that I tell people is that PC program code sh... | <p>PLC is the term used for the devices that use ladder logic. The devices that are programmed in more typical programming languages are generally called microcontrollers. However, there are some of us that on occasion lump them all under the PLC name. :-) Not sure how much ladder logic varies, but microcontroller ... | 39,937 |
<p>Why do Linux distros have different package managers?</p>
<p>I find this very strange because other software such as text editors, desktop environments and graphics software (Inkscape, Blender, GIMP) are shared among distributions. Why not have a common setup tool?</p>
| <p>Like most things in the UNIX world where there are duplications of behaviour, it's a combination of many things, but mostly history, politics/religion, and the desire to build a better mousetrap / NiH syndrome. The existence of multiple system compononents that perform equivalent tasks is often praised as a useful f... | <p>There are also many different text-editors, desktop-environments and so on. The different distributions share this only, because they provide all these programs.</p>
<p>But they have to decide for one package-manager. Different package-manager wouldn't know about software installed by another package-manager. So di... | 35,127 |
<p>I'm trying to use cygwin as a build environment under Windows. I have some dependencies on 3rd party packages, for example, GTK+. </p>
<p>Normally when I build under Linux, in my Makefile I can add a call to pkg-config as an argument to gcc, so it comes out like so:</p>
<pre>
gcc example.c `pkg-config --libs --cfl... | <blockquote>
<p>That said, is there, say, some way I could have the Makefile store the result of pkg-config into a variable, and then use that variable, rather than using the back-tick operator?</p>
</blockquote>
<p>GTK_LIBS = $(shell pkg-config --libs gtk+-2.0)</p>
| <p>My guess would be that cygwin's gcc can't handle -Lc:/mingw/lib. Try translating that to a cygwin path.</p>
<pre><code>GTK_LIBS = $(patsubst -Lc:/%,-L/cygdrive/c/%,$(shell pkg-config --libs gtk+-2.0))
</code></pre>
| 12,724 |
<p>How can I create 7-Zip archives from my C# console application? I need to be able to extract the archives using the regular, widely available <a href="http://www.7-zip.org/" rel="noreferrer">7-Zip</a> program.</p>
<hr>
<h2>Here are my results with the examples provided as answers to this question</h2>
<ul>
<li>"S... | <p><a href="http://www.eggheadcafe.com/tutorials/aspnet/064b41e4-60bc-4d35-9136-368603bcc27a/7zip-lzma-inmemory-com.aspx" rel="noreferrer">EggCafe 7Zip cookie example</a> This is an example (zipping cookie) with the DLL of 7Zip.</p>
<p><a href="http://www.codeplex.com/7zsharp" rel="noreferrer">CodePlex Wrapper</a>
Thi... | <p>These easiest way is to work with .zip files instead of .7z and use <a href="http://dotnetzip.codeplex.com/" rel="nofollow">Dot Net Zip</a></p>
<p>When spinning off 7zip commands to shell there are other issues like user privileges, I had issue with SevenZipSharp.</p>
<pre><code>Private Function CompressFile(filen... | 27,384 |
<p>In Reporting Services I would like to add a parameter that contains data from a custom code block. Ideally, I would be able to run the following code (this is a simple testing example):</p>
<pre><code>Function GetPeriods() As String()
Dim values As System.Collections.ArrayList =
New System.Collections.ArrayL... | <p>If you're using SQL 2008 Reporting Services then you can have a look at <a href="http://msdn.microsoft.com/en-au/library/ms153561.aspx" rel="nofollow noreferrer">this page</a> which introduces the concept of using custom assemblies.</p>
<p>If you're using SQL 2005 Reporting Services then <a href="http://msdn.micros... | <p>Everything I've seen requires parameters and their respective settings to be part of the RDL. </p>
<p>That being said, if you're going to "hardcode" the values, you could create a dataset just for the report, perhaps in XML, or if it needs to be programmatically driven, do it in a web service.</p>
| 33,985 |
<p>I'm trying to get a Server application to expose some status information using WCF.
In particular I'm after using WCF services with RESTful "API".
I'm hitting somewhat of a wall when it comes to consuming the REST api from a silverlight
app/page that I want to have as an additional type of client...</p>
<p>So far I... | <p>I almost hate to suggest it but would you feel comfortable with <a href="http://msdn.microsoft.com/en-us/library/ms405827(VS.95).aspx" rel="nofollow noreferrer" title="ChannelFactoryBase<TChannel>">reimplementing the WebChannelFactory<T> class</a>?</p>
<p>From a cursory glance through the Silverlight AP... | <p>I recently ran into the same problem and decided to create a class that has a simplified REST client interface for Silverlight, more or less like WebChannelFactory. Has synchronous-like behavior also.</p>
<p><a href="http://regular-language.blogspot.com/2011/06/wcf-webhttp-rest-client-for-silverlight.html" rel="nof... | 35,038 |
<p>Is it always possible to ping localhost and it resolves to 127.0.0.1?</p>
<p>I know Windows Vista, XP, Ubuntu and Debian do it but does everyone do it?</p>
| <p>Any correct implementation of TCP/IP will reserve the address 127.0.0.1 to refer to the local machine. However, the mapping of the name "localhost" to that address is generally dependent on the system <code>hosts</code> file. If you were to remove the localhost entry from <code>hosts</code>, then the localhost name ... | <p>Ok. </p>
<p>The reason why it resolves it is record in %WINDOWS_DIR%\System32\drivers\etc\hosts file like this:</p>
<p>127.0.0.1 localhost</p>
| 13,839 |
<p>I am looking for a tool that can detect malicious requests (such as obvious SQL injection gets or posts) and will immediately ban the IP address of the requester/add to a blacklist. I am aware that in an ideal world our code should be able to handle such requests and treat them accordingly, but there is a lot of val... | <p>Your almost looking at it the wrong way, no 3party tool that is not aware of your application methods/naming/data/domain is going to going to be able to perfectly protect you.</p>
<p>Something like SQL injection prevention is something that has to be in the code, and best written by the people that wrote the SQL, b... | <p>Interesting how this is being implemented years later by google and them removing the URL all together in order to prevent XSS attacks and other malicious acitivites</p>
| 2,367 |
<p>I'm attempting to use the following code to serialize an anonymous type to JSON:</p>
<pre><code>var serializer = new DataContractJsonSerializer(thing.GetType());
var ms = new MemoryStream();
serializer.WriteObject(ms, thing);
var json = Encoding.Default.GetString(ms.ToArray());
</code></pre>
<p>However, I get the... | <p>Try the JavaScriptSerializer instead of the DataContractJsonSerializer</p>
<pre><code>JavaScriptSerializer serializer = new JavaScriptSerializer();
var output = serializer.Serialize(your_anon_object);
</code></pre>
| <pre><code>public static class JsonSerializer
{
public static string Serialize<T>(this T data)
{
try
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
var stream = new MemoryStream();
serializer.WriteObject(stream, data... | 43,008 |
<p>If I have a method such as:</p>
<pre><code>public void MyMethod(int arg1, string arg2)
</code></pre>
<p>How would I go about getting the actual names of the arguments?
I can't seem to find anything in the MethodInfo which will actually give me the name of the parameter.</p>
<p>I would like to write a method which... | <pre><code>public static string GetParamName(System.Reflection.MethodInfo method, int index)
{
string retVal = string.Empty;
if (method != null && method.GetParameters().Length > index)
retVal = method.GetParameters()[index].Name;
return retVal;
}
</code></pre>
<p>The above sample sho... | <p>without any kind of error checking:</p>
<pre><code>public static string GetParameterName ( Delegate method , int index )
{
return method.Method.GetParameters ( ) [ index ].Name ;
}
</code></pre>
<p>You could use 'Func<TResult>' and derivatives to make this work for most situations</p>
| 26,319 |
<p>When the command prompt opens and then just closes really fast (because there isn't a pause line) is there a way to see what it just showed you? </p>
| <p>You can pipe the output to a file.</p>
<pre><code>something.exe > c:\temp\output.txt
</code></pre>
<p>This works on the prompt and in the windows run dialog box.</p>
| <p>Run the console application from the command line, that way the console window will not close after the execution.</p>
<p>Open cmd prompt,</p>
<p>type the program to run Ex.: </p>
<pre><code>c:\> ipconfig /all
</code></pre>
<p>I should get more coffee in my system before answering.</p>
| 43,394 |
<p>With really small sets of data, the policy where I work is generally to stick them into text files, but in my experience this can be a development headache. Data generally comes from the database and when it doesn't, the process involved in setting it/storing it is generally hidden in the code. With the database you... | <p>Put it in the database. If it changes infrequently, cache it in your middle tier.</p>
| <p>I would add it to the database in the main table:</p>
<ol>
<li>Backup and recovery (you do want to recover this text file, right?)</li>
<li>Adhoc querying (since you can do it will a SQL tool and join it to the other database data)</li>
<li>If the database column is empty the store requirements for it should be min... | 16,152 |
<p>I'd like to capture the output of <a href="http://us3.php.net/manual/en/function.var-dump.php" rel="noreferrer"><code>var_dump</code></a> to a string.</p>
<p>The PHP documentation says;</p>
<blockquote>
<p>As with anything that outputs its result directly to the browser, the <a href="http://us3.php.net/manual/en... | <p>Use output buffering:</p>
<pre><code><?php
ob_start();
var_dump($someVar);
$result = ob_get_clean();
?>
</code></pre>
| <p>From <a href="http://htmlexplorer.com/2015/01/assign-output-var_dump-print_r-php-variable.html" rel="nofollow">http://htmlexplorer.com/2015/01/assign-output-var_dump-print_r-php-variable.html</a>:</p>
<blockquote>
<p>var_dump and print_r functions can only output directly to browser. So the output of these functi... | 16,870 |
<p>I was hoping someone could validate my assumptions before I recommend that my client upgrade from a 30/mo to a 80/mo hosting package. </p>
<p><strong>Site:</strong> the site is a custom ASP.NET ecommerce site. the shopping carts are stored in the inproc session.</p>
<p><strong>Problem</strong> during busy seasons... | <p>Using the SQL Session state means that sessions should survive a recycle of IIS, (but not a recycle of SQL Server if you use the default script which creates the session database in the tempdb).</p>
<p>There is a script available from the Microsoft website which creates a permanent session state db. I would recomme... | <p>The assumptions sound reasonable to me. might also want to look at the settings on the AppPool and try to figure out why its recycling. Maybe all you need to do is change those (if you can).</p>
| 47,365 |
<p>I have three tables like that:</p>
<p><strong>Articles</strong>
IdArticle
Title
Content</p>
<p><strong>Tags</strong>
IdTag
TagName</p>
<p><strong>ContentTag</strong>
IdContentTag
Idtag
IdContent</p>
<p>When user in my site write an article with adding tags and submit, I want to save it to tables above. </p>
<p>... | <p>Why do you need to call a function when the list is scrolled? </p>
<p>If you are changing the items as it's scrolled i would recommend setting the listview to virtual.</p>
<p>Or you could override the listview and do this:</p>
<pre><code>public class TestListView : System.Windows.Forms.ListView
{
private con... | <p>it seems the best approach is the brian's solution. However, its only responds to events generated by scrollbars, but no to events from mouse midbuttton.</p>
<p>if you change the conditional:</p>
<pre><code> if (m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL)
this.OnScroll();
</code></pre>
<p>by:</p>
... | 48,628 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.