instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>How can I determine the name of the Bash script file inside the script itself?</p>
<p>Like if my script is in file <code>runme.sh</code>, then how would I make it to display "You are running runme.sh" message without hardcoding that?</p>
| <pre><code>me=`basename "$0"`
</code></pre>
<p>For reading through a symlink<sup>1</sup>, which is usually not what you want (you usually don't want to confuse the user this way), try:</p>
<pre><code>me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
</code></pre>
<p>IMO, that'll produce confus... | <p>echo "You are running $0"</p>
| 23,374 |
<p>This is a strange one...
In a windows forms app (VB.NET/VS 2005) I have the need to occasionally check if the application DVD is inserted. <br>In my production machine (and in the majority of our clients) this code takes less than an second to execute. But in some machines, it takes about 8 to 10 seconds. I couldn't... | <p>Where's the cost in this code? Profiling would really help on a <em>bad</em> machine</p>
<p>I'd imagine the cost is somewhere in those DriveInfo calls - looking in reflector at the code behind DriveInfo:</p>
<p>.cctor seems pretty innocuous - just validates letter constraints.</p>
<p>.GetDriveType calls straight... | <ul>
<li><p>Have you considered network mapped drives? They can be very slow to respond for certain things.</p></li>
<li><p>Have you tried getting the list of drives, and then checking each drive in parallel rather than in serial? Cancel any pending requests when a result is found and return true. Since the real dvd... | 32,846 |
<p>Very simply put:</p>
<p>I have a class that consists mostly of static public members, so I can group similar functions together that still have to be called from other classes/functions.</p>
<p>Anyway, I have defined two static unsigned char variables in my class public scope, when I try to modify these values in ... | <p>If you are using <strong>C++ 17</strong> you can just use the <code>inline</code> specifier (see <a href="https://stackoverflow.com/a/11711082/55721">https://stackoverflow.com/a/11711082/55721</a>)</p>
<hr />
<p>If using older versions of the C++ standard, you must add the definitions to match your declarations of X... | <p>In my case, I was using wrong linking. <br/>
It was managed c++ (cli) but with native exporting. I have added to linker -> input -> assembly link resource the dll of the library from which the function is exported. But native c++ linking requires .lib file to "see" implementations in cpp correctly, so for me helped ... | 23,712 |
<p>I have some code that creates a fairly large xml DOM and writes it off to a file (up to 50-100MB) . It basically creates the DOM and then calls a toString on it and writes it out with ofstream. Is there a way to get streaming output of the generated dom so that it doesn't create the whole structure in memory all at ... | <p>Ok, turns out libxml2 has a streaming API:</p>
<p><a href="http://xmlsoft.org/examples/testWriter.c" rel="nofollow noreferrer">http://xmlsoft.org/examples/testWriter.c</a></p>
<p>It's a little old style (very C-ish) but you can write your wrapper around it.</p>
| <p>Look under keyword "C++ XML writer;" XML writers generate XML to file without building the entire DOM in memory so they don't need to use very much memory at all. You didn't mention platform, but Microsoft XmlLite has IXmlWriter.</p>
| 7,304 |
<p>I currently have a gridview that has an asp:ButtonField as one of the columns. The event handler for the command extracts the row id of the gridview from the command argument and uses that to perform some logic. I now need to switch to using a template field for this column, and want to do something like this:</p>
... | <p>Check out this document on Microsoft's website. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx</a></p>
<p>You don't need to bind the ro... | <pre><code>CommandArgument="<%# CType(Container, GridViewRow).RowIndex %>"
</code></pre>
| 43,953 |
<p>I have SSRS Report being accessed from a Report Server. Is there any way I can give an error message of my own, if my report fails to open there? </p>
| <p>You need to assign a Country instance to the Country property of the Person instance (not just set the ID). Something like: </p>
<pre><code>Person p = new Person();
p.Country = session.Load<Country>(countryId);
session.Save(p);
</code></pre>
<p>Then NHibernate will know what to do. This will also not cause... | <p>I had a similar requirement and solved it using <strong>SaveOrUpdateCopy</strong>.</p>
<p>Lets say you have two different People objects, and each has a reference to a different Country object. As long as the Country <em>IDs</em> are the same, you won't get an exception and only 1 Country will be in the database.</... | 37,000 |
<p>Data table structure is:<br>
id1,id2,id3,id4,... (some other fields).<br>
I want to create summary query to find out how many times some ID value is used in every column.</p>
<p>Data<br>
1,2,3,4,2008<br>
2,3,5,1,2008<br>
1,3,2,5,2007<br>
1,2,3,6,2007<br>
3,1,2,5,2007<br></p>
<p>For value 1, the result should be<br... | <p>This seems like the best solution (from <a href="http://en.wikibooks.org/wiki/Programming:MySQL/Pivot_table" rel="nofollow noreferrer">Wiki</a>):</p>
<pre><code>select years,
sum(1*(1-abs(sign(id1-56)))) as id1,
sum(1*(1-abs(sign(id2-56)))) as id2,
sum(1*(1-abs(sign(id3-56)))) as id3,
sum(1*(1-abs(sign(id4-56)))) a... | <p>if X is the id value you're looking for, you'd do it something like this.</p>
<pre><code>select (select count(*) where id1 = X) as countid1 ... etc
</code></pre>
| 46,102 |
<p>Hello I am using Cura to slice my prints, and despite turning the flow rate to the minimum value of 5%, my prints are still hugely over extruding. </p>
<p>I have calibrated the extruder stepper perfectly, using Pronterface, so I do not understand why this is occurring. I have also timed how long it took to extrude ... | <p>First of all: Can you tell us, what kind of printer do you use and which material? Please give us some pictures of some prints as well.. Also the type of the Extruder setup is relevant. Is it a Bowden or Direct Driven extruder?</p>
<p>For an FDM machine like the Prusa styled printers with PLA:</p>
<ul>
<li>Flow of... | <p>I've been building 3D printers for a few years and working in the computer science field for over 2 decades. Here's a simple trick I use for adjusting your extruder steps.</p>
<ol>
<li><p>Tweak your flow rate till it's where it should be. Then mark down
the percentage it's at.</p>
</li>
<li><p>Go into your configura... | 768 |
<p>I'm trying to use the EntLib 3.1 within .net code for a dll which is registered for COM interop. Where do I put the config file? </p>
<p>Alternatively, is there a way to specify within the dll code where it should get the entlib config from? Since my dll will be called from COM I don't always know what exe will be ... | <p>The answer is that Enterprise Library by default uses the exe's config file. If you're producing a dll, including COM, then for good reason you might not want to depend on the calling executable. One solution to this (there might be others) is to create the Enterprise Library objects yourself instead of using the de... | <p>Check the related issue which i had faced . Maybe its of some help.</p>
<p><a href="https://stackoverflow.com/questions/333595/how-to-include-com-components-on-a-published-net-site">How to include COM components on a published .Net site?</a></p>
| 46,874 |
<p>In C++ I'd like to do something like:</p>
<pre><code>int n = get_int_from_user();
char* matrix = new char[n][n];
matrix[0][0] = 'c';
//...
matrix[n][n] = 'a';
delete [][] matrix;
</code></pre>
<p>but of course this doesn't work. What is the best way to do something similar? I've seen some solutions to this bu... | <p><strong>The manual dynamic way:</strong></p>
<p>Let's say you want an array of width*height, the most efficient way is to just use a single dimensional array:</p>
<pre><code>char *matrix = new char[width*height];
</code></pre>
<p>To delete it:</p>
<pre><code>delete[] matrix;
</code></pre>
<p>To access it: </p>
... | <p>I think this would be a good one.</p>
<pre><code>int n = get_int_from_user();
char **matrix=new (char*)[n];
for(int i=0;i<n;i++)
matrix[i]=new char[n];
matrix[0][0] = 'c';
//...
matrix[n][n] = 'a';
for(int i=0;i<n;i++)
delete []matrix;
delete []matrix;
</code></pre>
| 31,983 |
<p>I'm about to get started converting a C# based desktop app to be web based. For a couple of reasons, I would like to cut the GUI from the logic via a web service. Microsoft has asmx files, WCF, and probably something new at PDC next week. Data can be passed via SOAP, REST, JSON, and probably 12 other ways as well... | <p>You are about to move to a new platform. I would go for WCF. It can support all your needs.</p>
<p>Initially when you move you can use httpBinding and that is very close to ASMX web services and is based on SOAP. If you later require some advanced features, then you can definitely utilise webHttpBinding and that wi... | <p>I vote for WCF, hands down.</p>
| 27,477 |
<p>I'm currently working on creating a new C# project that needs to interact with an older C++ application. There is an error enumeration that already exists in the C++ app that I need to use in the C# app.</p>
<p><em>I don't want to just re declare the enumeration in C# because that could cause sync issues down the l... | <p>Check out the PInvoke Interop Assistant tool <a href="http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120" rel="noreferrer">http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120</a>. Its a useful tool for generating PInvoke signatures for native methods. </p>
... | <p>If you had declared the enum like:</p>
<pre><code>namespace blah
{
enum DEVICE_ERR_CODES
{
eDEVICEINT_ERR_FATAL = 0x10001,
eDEVICEINT_ERR_OTHER = 0x10002,
};
}</code></pre>
<p>and in another file:</p>
<pre><code>DEVICE_ERR_CODES eDeviceIntErrCodes;</code></pre>
<p>and named the enum f... | 3,931 |
<p>Now, I realise the initial response to this is likely to be "you can't" or "use analytics", but I'll continue in the hope that someone has more insight than that.</p>
<p>Google adwords with "autotagging" appends a "gclid" (presumably "google click id") to link that sends you to the advertised site. It appears in th... | <p>By far the easiest solution is to manually tag your links with Google Analytics campaign tracking parameters (utm_source, utm_campaign, utm_medium, etc.) and then pull out that data. </p>
<p>The gclid is dependent on more than just the adwords account/campaign/etc. If you click on the same adwords ad twice, it coul... | <p>I agree with Ophir and Chris. My feeling is that it is purely a serial number / unique click ID, which only opens up its secrets when the Analytics and Adwords systems talk to each other behind the scenes.</p>
<p>Knowing this, I'd recommend looking at the referring URL and pulling as much as possible from this to u... | 47,765 |
<p>Most of the time, I've seen release management handled as a defined process with the supporting tool as the version control system (usually via branching and tagging). However, are there any tools dedicated to release management? I'm looking for both open source and closed source tools, if any exist.</p>
| <p>You can use <a href="http://ant.apache.org/" rel="nofollow noreferrer">ant</a> or <a href="http://maven.apache.org/" rel="nofollow noreferrer">maven</a> for automating tasks like generating packages and deploys to remote servers.</p>
| <p>By definition, Release Management is a managed process. I've seen larger organizations use HP Service Manager for process management in this area. They have a Release Control module that works with the Change Management module. </p>
<p>On a more java development side of the house I've seen the Artifactory plugin ... | 33,754 |
<p>I authenticate users through Radius, and I have the option to assign Radius attributes through SQL statements, but I can't for the life of me find any documentation on this. Anyone know the proper syntax?</p>
| <p>Okay, I figured it out, and for anyone else who ends up having this problem:</p>
<p>Under the Authorization tab, in the Response List:
When adding an attribute from an SQL query, the first selected variable from the query is the attribute and the second is the value.</p>
<p>ex.</p>
<p><code>SELECT 'attribute', va... | <p>kylex, try these links and see if they help. Specifically the first one</p>
<p><a href="http://www.xperiencetech.com/forum/topic.asp?TOPIC_ID=97" rel="nofollow noreferrer">http://www.xperiencetech.com/forum/topic.asp?TOPIC_ID=97</a></p>
<p><a href="http://www.xperiencetech.com/forum/topic.asp?TOPIC_ID=62" rel="nof... | 36,384 |
<p>I have a select query that currently produces the following results:
<BR></p>
<pre><code>Description Code Price
Product 1 A 5
Product 1 B 4
Product 1 C 2
</code></pre>
<p>Using the following query: </p>
<pre><code>SELECT DISTINCT np.Description, p.promotionalCode, p.Price... | <pre><code>SELECT
np.Id,
np.Description,
MIN(Case promotionalCode WHEN 'A' THEN Price ELSE NULL END) AS 'A',
MIN(Case promotionalCode WHEN 'B' THEN Price ELSE NULL END) AS 'B',
MIN(Case promotionalCode WHEN 'C' THEN Price ELSE NULL END) AS 'C'
FROM
Price AS p
INNER JOIN nProduct AS np ON p.... | <p>Duckworth's answer is good. If you can get more than one value for each cell, you might want to use AVG or SUM instead of MIN, depending on what you want to see.</p>
<p>If your DBMS supports it, you might also want to look into a Crosstab query, or a pivot query. For example, MS Access has crosstab queries.</p>
| 29,236 |
<p>I have a <code>ListBox</code> that scrolls images horizontally.</p>
<p>I have the following XAML I used blend to create it. It originally had a x:Key on the <code>Style TaregetType</code> line, MSDN said to remove it, as I was getting errors on that. Now I'm getting this error:</p>
<p><code>Error 3 Operation is... | <p>Wrap the Style Tag with an ItemContainerStyle as below:</p>
<pre><code><ListBox ItemsSource="{Binding Source={StaticResource WPFApparelCollection}}"
Grid.Row="1" Margin="2,26,2,104"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
... | <p>I tried the above solution but it didnt worked as expected so I found another way to solve my problem which is to disable selection for listbox</p>
<p>this is what I did</p>
<pre><code><ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Focusable" Va... | 46,277 |
<p>I am getting an error while porting my application from VC6 to Visual Studio 2005.</p>
<p>Does anyone have any idea what this means?</p>
<blockquote>
<p>mfcs80.lib(dllmodul.obj) : error
LNK2005: _DllMain@12 already defined
in MSVCRT.lib(dllmain.obj)</p>
</blockquote>
| <p>From <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;q148652" rel="nofollow noreferrer">http://support.microsoft.com/default.aspx?scid=kb;en-us;q148652</a></p>
<blockquote>
<p>A LNK2005 error occurs when the CRT
library and MFC libraries are linked
in the wrong order in Visual C++</p>
</block... | <p>You could set the linker input to ignore the troubling library in the project properties, but this may or may not work.</p>
| 46,404 |
<p>the WPF Popup control is nice, but somewhat limited in my opinion. is there a way to "drag" a popup around when it is opened (like with the DragMove() method of windows)?</p>
<p>can this be done without big problems or do i have to write a substitute for the popup class myself?
thanks</p>
| <p>Here's a simple solution using a Thumb.</p>
<ul>
<li>Subclass Popup in XAML and codebehind</li>
<li>Add a Thumb with width/height set to 0 (this could also be done in XAML)</li>
<li>Listen for MouseDown events on the Popup and raise the same event on the Thumb</li>
<li>Move popup on DragDelta</li>
</ul>
<p>XAML:</... | <pre><code>Private Point startPoint;
private void Window_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
startPoint = e.GetPosition(null);
}
private void Window_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
... | 27,383 |
<p>RPO 1.0 (Runtime Page Optimizer) is a recently (today?) released component for ASP and Sharepoint that compresses, combines and minifies (I can’t believe that is a real word) Javascript, CSS and other things.</p>
<p>What is interesting is that it was developed for ActionThis.com a NZ shop that saw at TechEd last ye... | <p>I decided to answer this question again after evalutating it a little.</p>
<ul>
<li>The image combining is really amazing</li>
<li>The CSS and Javascript is nicely minified</li>
<li>All files are cached on the server meaning that the server isn't cained every time it makes a request</li>
<li>The caching is performe... | <p>Just had a little look, a lot of the things they offer you should be able to do yourself with a little palnning and foresight (combine all javascript files, combine all css, minify, enable GZip...</p>
<p>$750 a year seems a little steep, and theres no options.</p>
<p>(edit)
After speaking with the marketing bods, ... | 10,668 |
<p>I'd like to provide some way of creating dynamically loadable plugins in my software.
Typical way to do this is using the <a href="http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx" rel="noreferrer">LoadLibrary</a> WinAPI function to load a dll and calling <a href="http://msdn.microsoft.com/en-us/library/... | <p>The following code snippet (C#) constructs an instance of any concrete classes derived from <code>Base</code> found in class libraries (*.dll) in the application path and stores them in a list.</p>
<pre><code>using System.IO;
using System.Reflection;
List<Base> objects = new List<Base>();
DirectoryInfo... | <p>This is my implementation, Inspired in <a href="https://www.codeproject.com/Tips/546639/How-to-create-an-easy-plugin-system-in-Csharp" rel="nofollow noreferrer">this code</a> avoiding to iterate over all assemblies and all types (or at least filtering with linQ). I just load the library and try to load the class whi... | 3,504 |
<p>The setup:
Multiple computers using an adp file to access a sql 2005 database. Most don't have a pdf distiller. An access form (plain form, not crystal) is created that needs to be saved as a pdf.</p>
<p>The only way I can think of is send a request from access to the sql server for a web page. Something like:
"<a... | <p>Save the form as a report, then use Access MVP Stephen Lebans free A2000ReportToPDF utility to convert it to a pdf file.</p>
<p><a href="http://www.lebans.com/reporttopdf.htm" rel="nofollow noreferrer">http://www.lebans.com/reporttopdf.htm</a></p>
<p>If they have Access 2007 they can download and install the free ... | <p>Microsoft's <a href="http://msdn.microsoft.com/en-us/library/ms251771(VS.80).aspx" rel="nofollow noreferrer">ReportViewer</a> client can generate pdfs natively.</p>
<p>It works inside of web pages and windows forms/wpf apps. You can programmatically trigger the export as well. The only downside is that you'll need ... | 12,031 |
<p>Why do we need to use:</p>
<pre><code>extern "C" {
#include <foo.h>
}
</code></pre>
<p><strong>Specifically:</strong> </p>
<ul>
<li><p>When should we use it?</p></li>
<li><p>What is happening at the compiler/linker level that requires us to use it? </p></li>
<li><p>How in terms of compilation/linking does... | <p>C and C++ are superficially similar, but each compiles into a very different set of code. When you include a header file with a C++ compiler, the compiler is expecting C++ code. If, however, it is a C header, then the compiler expects the data contained in the header file to be compiled to a certain format—the C++ '... | <p><strong>Decompile a <code>g++</code> generated binary to see what is going on</strong></p>
<p>To understand why <code>extern</code> is necessary, the best thing to do is to understand what is going on in detail in the object files with an example:</p>
<p>main.cpp</p>
<pre><code>void f() {}
void g();
extern "C" {... | 9,345 |
<p>Does anyone know of a nice (and preferably free) way to integrate Prolog and C#?</p>
<p>Im looking to create a Prolog dll or similar to call from my managed code, and retrieve an answer once all the processing has been complete. Im looking for it to be predominantly one sided (c# calls Prolog).</p>
<p>I have seen ... | <p>You can take a look at <a href="http://yieldprolog.sourceforge.net/" rel="noreferrer">Yield Prolog</a>. </p>
<p>Yield Prolog uses <code>yield</code> keyword in C# (and Python, and JavaScript) and custom <code>Variable</code> class to simulate Prolog machine. This way, you get a Prolog API in your favourite language... | <p>You can use ECLiPSe Prolog.
i have integrated it with VC8. it would be better to use VC8 instead of C#.</p>
| 21,963 |
<p>Taken from the <a href="https://3dprinting.stackexchange.com/a/60/47">answer provided by @EricJohnson</a>,</p>
<p>When should I use a raft, and when should I use a brim? What advantages does each have over the other?</p>
<p>Raft
<a href="https://i.stack.imgur.com/rOghM.jpg" rel="noreferrer"><img src="https://i.sta... | <p>A raft will allow for better adhesion for the whole print as the raft attaches to the printing surface and the print attaches to the raft. Rafts go all the way under the print and consist of multiple layers, whereas a brim is only 1 layer and on the outside of the print. Rafts are normally harder to remove than brim... | <p>I have been favoring brims recently; I am tired of the rafts becoming an integral part of my print, impossible to remove.</p>
| 103 |
<p>When I was in China my company's website was blocked for about 24 hours.</p>
<p>I assume it was the "Great Chinese Firewall" but I was wondering if there is any way that I can find out exactly where a packet or TCP/IP connection gets blocked.</p>
<p>I was able to verify that it wasn't being blocked at our end(I us... | <p><a href="http://michael.toren.net/code/tcptraceroute/" rel="nofollow noreferrer">tcptraceroute</a></p>
| <p>I have lot's of problems with that firewall. Having my server into EEUU doesn't help. If you need tools to test your site hosted outside from china like you were in China, you can try that page:</p>
<p><a href="http://www.websitepulse.com/help/tools.php" rel="nofollow noreferrer">http://www.websitepulse.com/help/to... | 7,206 |
<p>I did it using the commands as described <a href="http://www.wherecanibuyit.co.uk/ASP/full-text-search.html" rel="noreferrer">here</a> and it works but <strong>I want to do it using the SQL Management Studio</strong>.</p>
<p>SQL Server 2008 Books Online says this:</p>
<blockquote>
<p>To create a full-text catalo... | <p>You need to install <strong>SQL Server 2008 Express with Advanced Services</strong> in order to be able to use Full Text search in 2008 Express.</p>
| <p>I guess using the CodePlex addin is the only way, because even with SSMS from Standard edition you are unable to manage Express fulltext catalogs.</p>
| 31,223 |
<p>I would like to repeatedly capture snippets of audio on a Nokia mobile phone with a Java Midlet. My current experience is that using the code in Sun's documentation (see: <a href="http://java.sun.com/javame/reference/apis/jsr135/javax/microedition/media/control/RecordControl.html" rel="nofollow noreferrer">http://ja... | <p>There is a known memory leak with the N-series Nokia devices. It is not specific to Java and is in the underbelly of the OS somewhere.</p>
<p>Recently working on a game that targeted the Nokia N90, I had similar problems. I would run into memory problems that would accumulate over several different restarts of the ... | <p>I think you should file a bugreport instead of trying to work around that.</p>
| 12,614 |
<p>I wish to dynamically change the scroll position of a Silverlight ListBox from C#, and I need to know how to access the ScrollViewer element of a ListBox control from C#?</p>
<p>Thanks guys,
Jeff</p>
| <p>From within a class that inherits from the ListBox class, you can use the Protected GetTemplateChild():</p>
<p><code>var myScrollviewer = myListBox.GetTemplateChild("ScrollViewer") as ScrollViewer;</code></p>
<p>If you want to access this from outside the ListBox, then exposing the ScrollViewer via a Property shou... | <pre><code>ScrollViewer scrollViewer = yourListBox.getScrollHost();
</code></pre>
<p>Is null if no datasourse set to the listbox, in my case it return properly UI Element only after below code executed</p>
<pre><code>myListBox.ItemsSource = list;
</code></pre>
| 32,988 |
<p>I have been searching around on google and not found any answers to this dilemma. I am using a Prusa I3 printer with PLA, trying to print horseshoes for the company I work for. They are for model horses, so quality is fairly important. I seem to have gotten all the settings dialed in just the way I want them and for... | <p>It could very well be that your print speed is too high (starting from the 2nd layer) for the motors to keep up comfortably. Try reducing the print speed to perhaps 75-80% of what you are using to see if it addresses the issue. You should also check you model to make sure there are errors in the STL. Sometimes such ... | <p>Is that printed on to tape? It looks <em>very</em> uneven. I'm guessing this is general bad adhesion and its just showing up best when going around curves.
If you print onto tape, try putting it down with a squeegee, so it's absolutely flat and level with no creases or bubbles.</p>
<p>I've personally had very littl... | 862 |
<p>I have just started reading Introduction to 80x86 Assembly Language and Computer Architecture.I am trying to use NASM, to run the first example shown in chapter 3 ,but unsuccessfully.Has anyone read the book,and run the examples?</p>
| <p>According to Google Books, you should be using <a href="http://www.masm32.com/" rel="nofollow noreferrer">MASM</a>, not NASM. Try that.</p>
<p>For reference guys, page 47 <a href="http://books.google.co.nz/books?id=TFw5vo-2ZYwC&dq=Introduction+to+80x86+Assembly+Language+and+Computer+Architecture&pg=PP1&... | <p>I prefer NASM over MASM. There are significant <a href="http://www.nasm.us/doc/nasmdoc2.html#section-2.2" rel="nofollow noreferrer">differences</a> between them, especially when it comes to things like variables and procedures (they are not really part of the NASM approach). You'll have to make up your own mind abou... | 17,628 |
<p>Here's the scenario:</p>
<p>You have an ASP.Net application supported by a Microsoft SQL Server database, and for this example there won't be any caching.</p>
<p>For each page in your web application, what's more efficient:</p>
<p>Attempting to condense everything you need into one (or a few) stored procedure cal... | <p>With connection pooling enabled, there isn't much advantage (if any) to condensing multiple DB calls into one as you're suggesting. There is nothing wrong with getting data as you need it with multiple calls to the DB, even if each call opens and closes a database connection. This is because with pooling enabled, ... | <p>I had a similar concern a while back while I was putting together a web app that had many dropdown controls on different pages. I took a look at SQL Profiler and I was getting over 20 hits just to populate my dropdowns. Here what I did and maybe it will help you.</p>
<p>My picklist tables names (fictional)</p>
<ul... | 33,263 |
<p>Am I right in thinking the full name of the LSP is the Liskoff Substitution Principle? I'm having trouble finding an [online] source to cite for any information on this... it seems to be a cornerstone of OOP, and yet I'm having trouble finding definitions.</p>
| <p>Yes, you are right. It's spelled Liskov which is probably why you can't find a citation.
Here's the <a href="http://en.wikipedia.org/wiki/Liskov_substitution_principle" rel="nofollow noreferrer">link.</a> One of the better resources regarding this is Robert C. Martin's Agile Software Development Principles Patte... | <p>You got the name right. </p>
<p><a href="http://en.wikipedia.org/wiki/Liskov_substitution_principle" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Liskov_substitution_principle</a></p>
<p>It was developed by Barbra Liskov, a professor at MIT.</p>
| 5,953 |
<p>I am currently starting my Java VM with the <strong><code>com.sun.management.jmxremote.*</code></strong> properties so that I can connect to it via JConsole for management and monitoring. Unfortunately, it listens on all interfaces (IP addresses) on the machine.</p>
<p>In our environment, there are often cases whe... | <p>If anyone else will be losing his nerves with this ... After 10 years, they finally fixed it!</p>
<p>Since Java 8u102 <code>-Dcom.sun.management.jmxremote.host</code> binds to the selected IP </p>
<p>see: <a href="https://bugs.openjdk.java.net/browse/JDK-6425769" rel="noreferrer">https://bugs.openjdk.java.net/brow... | <p>The accepted answer is pretty old. There are some indications that Java now provides some options to enable this. For instance I have seen:</p>
<pre><code>-Djava.rmi.server.hostname=<YOUR_IP>
</code></pre>
<p>...as well as...</p>
<pre><code>-Dcom.sun.management.jmxremote.host=<YOUR_IP>
</code></pre>
... | 42,967 |
<p>I recently asked a question about Oracle Encryption. Along the way to finding a solution for myself I decided to move the encryption (well, obfuscation) to the application side for certain tasks. </p>
<p>My problem is that the database is already encrypting data a certain way and I need Java code to duplicate tha... | <p>I found this works:</p>
<pre><code>KeySpec ks = new DESKeySpec(new byte[] {'s','e','c','r','e','t','!','!'});
SecretKeyFactory skf = SecretKeyFactory.getInstance("DES");
SecretKey sk = skf.generateSecret(ks);
Cipher c = Cipher.getInstance("DES/CBC/NoPadding");
IvParameterSpec ips = new IvParameterSpec(new byte[] {0... | <p>Using Java in the database would have been another approach that would (should!) have guarenteed that the code (and hence results) would be identical.</p>
| 14,085 |
<p>Basically I am trying to retrieve a list of stored procedure parameters using Linq to SQL? Is there a way to do this?</p>
| <p>From a quick look I think that its fairly comprehensive. Perhaps you should allow multiple teachers on a course, and allow reuse of addresses/locations between parents and students.</p>
<p>As a general rule I would say that you should start implementing and then you will find where you need improvement.</p>
| <p>Looks like an interesting project. Do note that Django has higher-level types than SQL, so you can make use of things like the email address type.</p>
<p>If you're planning on targeting <a href="http://code.google.com/appengine/" rel="nofollow noreferrer">GAE</a>, you should find a similarly rich <a href="http://c... | 44,860 |
<p>I am implementing an installer for one of our products that requires MySQL as a prerequisite. I would like to have a bootstrap program that queries the user for any information needed for any prerequisite products and our product. Once the user has entered in all the necessary information they can press next and w... | <p>Try this one :
<a href="http://hamidseta.blogspot.com/2008/05/install-mysql-server-50-silently.html" rel="nofollow noreferrer">http://hamidseta.blogspot.com/2008/05/install-mysql-server-50-silently.html</a></p>
| <p>See on musql foruns, I <a href="http://forums.mysql.com/read.php?11,26486,26486" rel="nofollow noreferrer">found this post on the subject</a>.</p>
<p>Hope it helps.</p>
| 37,181 |
<p>I am writing a crawler in Python, in order to make Ctrl+C not to cause my crawler to start over in next run, I need to save the processing deque in a text file (one item per line) and update it every iteration, the update operation needs to be super fast. In order not to reinvent the wheel, I am asking if there is a... | <p>As an alternative, you could set up an exit function, and pickle the deque on exit.</p>
<p><a href="http://docs.python.org/library/sys.html#sys.exitfunc" rel="nofollow noreferrer">Exit function</a><br>
<a href="http://docs.python.org/library/pickle.html" rel="nofollow noreferrer">Pickle</a></p>
| <p>Some things that come to my mind:</p>
<ul>
<li>leave the file handle open (don't close the file everytime you wrote something)</li>
<li>or write the file every n items and catch a close signal to write the current non-written items</li>
</ul>
| 46,371 |
<p>I can't see the 'Collection of Repositories" page after adding authentication and access rules to svn. 'guest' can navigate to mydomain.com/svn/public and admin can see both svn/public and svn/private, but none of the users can see /svn. </p>
<p>Is it possible to have 'guest' access mydomain.com/svn and only see ... | <p>This may not be what you're looking for, but we've stopped using the collection of repositories page altogether. Instead we use websvn: <a href="http://websvn.tigris.org/" rel="nofollow noreferrer">http://websvn.tigris.org/</a> screenshot: <a href="http://chrison.net/content/binary/websvn2.png" rel="nofollow norefe... | <p>Using < location /svn/ > fixed it, all repos are now visible from /svn/ and if a guest clicks on 'private' it locks them out.</p>
<p>But, it only works with that trailing slash in the url. mydomain.com/svn/ works but mydomain.com/svn does not.</p>
| 28,206 |
<p>We are experiencing an exceedingly hard to track down issue where we are seeing ClassCastExceptions <em>sometimes</em> when trying to iterate over a list of unmarshalled objects. The important bit is <em>sometimes</em>, after a reboot the particular code works fine. This seems to point in the direction of concurrenc... | <p>I get this exception ONLY when I forget to tell JAXBContext
about ALL to-be-marshalled types it could be dealing with.</p>
<pre><code>JAXBContext.newInstance(MyClass1.class,MyClass2.class, [...]);
</code></pre>
| <p>The synchronized clause above resolved the issue for me as well, but it seems like the context should not be a local variable. Instead it should be an instance variable, or a static. I wasn't able to refactor my code how I'd like it, so instead I moved the context into a static initializer, which isn't perfect, b... | 49,488 |
<p>I've been running into this problem with Flex for nearly a year, and each time I work up a quick hack solution that works for the time being. I'd like to see if anyone has a better idea.</p>
<p>Here are the conditions of a problem:</p>
<pre><code>|------Container ------------|
| explicitHeight: 400 (or whateve... | <p>You have to use the "autoLayout" parameter on the VBox as documentation say:<br /><br />
<i>"By default, the size of the VBox container is big enough to hold the image at it original size. If you disable layout updates, and use the Zoom effect to enlarge the image, or use the Move effect to reposition the image, the... | <p>In fact, Yarin Kessler brought us the only right answer here
(unfortunately, i don't have the rights to comment its post, that's why i'm doing it here).</p>
<p>When your HBox sizing is based on a percentage value, you are hoping that only its container will influence its size. That's wrong, there is an other rule, ... | 30,425 |
<p>I would like to apply a transformation (rotation) to a <code>UIImageView</code>. I could just set the <code>transform</code> property of the view, but wouldn't setting the layer's <code>transform</code> make it faster? If so, how can I achieve this?</p>
<p>Assuming I have a <code>UIImageView</code> initialized with... | <p>If you're doing a simple rotation, the speed difference is probably insignificant, but you can get access to a view's layer by doing:</p>
<p><code>view.layer </code></p>
<p>So, you can just use </p>
<p><code>view.layer.affineTransform = newTranform; </code></p>
| <p>You can do a constant rotation using a CAAnimation that auto repeats (I think; I haven't actually tried to do this exact thing, but similar stuff). </p>
<p>If one animation won't do it, certainly two will (have one rotate 180°, then when it ends, have another one fire to do the second 180°. This can be done on eith... | 41,254 |
<p>I have a C++ tool that walks the call stack at one point. In the code, it first gets a copy of the live CPU registers (via RtlCaptureContext()), then uses a few "<code>#ifdef ...</code>" blocks to save the CPU-specific register names into <code>stackframe.AddrPC.Offset</code>, ...<code>AddrStack</code>..., and ...<... | <p>Given that fs.sf is a STACKFRAME64 structure, you need to initialize it like this before passing it to StackWalk64: (c is a CONTEXT structure)</p>
<pre><code> DWORD machine = IMAGE_FILE_MACHINE_AMD64;
RtlCaptureContext (&c);
fs.sf.AddrPC.Offset = c.Rip;
fs.sf.AddrFrame.Offset = c.Rsp;
fs.sf.AddrStack.O... | <p>FWIW, I've switched to using <code>CaptureStackBackTrace()</code>, and now it works just fine.</p>
| 16,547 |
<p>I'm trying to make a calculator that will take inputs from users and estimate for them how much money they'll save if they use various different VoIP services.</p>
<p>I've set it up like this:</p>
<pre><code><form method="get" action="voip_calculator.php">
How much is your monthly phone bill?
<inpu... | <p>You need to get the value from the QueryString and put it into a PHP variable.</p>
<p>Like this:</p>
<pre><code>$monthlyBill = $_GET['monthlybill'];
</code></pre>
<p>Now the variable $monthlyBill contains the value from the QueryString.</p>
<p>To display it:</p>
<pre><code>echo "Your monthly bill is: $monthlyBi... | <p>You need to get the value from the QueryString and put it into a PHP variable.</p>
<p>Like this:</p>
<pre><code>$monthlyBill = $_GET['monthlybill'];
</code></pre>
<p>Now the variable $monthlyBill contains the value from the QueryString.</p>
<p>To display it:</p>
<pre><code>echo "Your monthly bill is: $monthlyBi... | 44,058 |
<p>I'm creating a DSL with a template-like editor, much like the rule systems in <a href="http://www.allice.org" rel="nofollow noreferrer">Alice</a>. Users will be able to select relationships from a list as well as the objects to apply the relation to. These two lists should be filtered based on the acceptable types... | <p>You might look into <a href="http://www.scintilla.org/" rel="nofollow noreferrer">Scintilla</a>. It's the editing component used by Notepad++, among other tools. It has some support for doing autocompletion, although I haven't tried using it myself, so I'm not sure how well it works. It's open source, so if it doesn... | <p>This might help on the intellisense side - <a href="http://www.codeproject.com/KB/edit/codetextbox.aspx" rel="nofollow noreferrer">CodeTextBox</a></p>
| 13,141 |
<p>I have 2 time values which have the type <code>datetime.time</code>. I want to find their difference. The obvious thing to do is t1 - t2, but this doesn't work. It works for objects of type <code>datetime.datetime</code> but not for <code>datetime.time</code>. So what is the best way to do this?</p>
| <p>Also a little silly, but you could try picking an arbitrary day and embedding each time in it, using <code>datetime.datetime.combine</code>, then subtracting:</p>
<pre><code>>>> import datetime
>>> t1 = datetime.time(2,3,4)
>>> t2 = datetime.time(18,20,59)
>>> dummydate = datetim... | <p>Firstly, note that a datetime.time is a time of day, independent of a given day, and so the different between any two datetime.time values is going to be less than 24 hours.</p>
<p>One approach is to convert both datetime.time values into comparable values (such as milliseconds), and find the difference.</p>
<pre>... | 7,382 |
<p>Is it better to have a field in the database that stores the customers account balance or use views and queries to generate the information.</p>
| <p>For performance, I'd say both. Keep a log of all the transactions (in a separate table) but maintain a field in the customer record that stores the current balance that gets refreshed when you add more transactions.</p>
| <p>That would be a function of how often you need to access this information. If its once in a while, then I'd say go ahead and recalculate it.</p>
| 23,146 |
<p>I've tried to override WndProc, but no message show up on paste event.</p>
<p>Then I tried to create custom filter and using method PreFilterMessage I was able to catch message with value 257 (KEYUP event), but that's not enough...</p>
| <p>Use:</p>
<pre><code> protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control)
{
MessageBox.Show("Hello world");
}
base.OnKeyDown(e);
}
</code></pre>
<p>Make sure your form KeyPreview = true.</p>
| <p>You can do this by:</p>
<ul>
<li>Intercepting the <kbd>Ctrl</kbd>+<kbd>V</kbd> in KeyDown (or KeyUp) of your form</li>
<li>Creating a menu in your form that contains a Paste option that has the <kbd>Ctrl</kbd>+<kbd>V</kbd> shortcut (this would maybe be better since you will have users looking for the options)</li>
<... | 20,914 |
<p>Suppose I have an M-file that calculates, for exampleת <code>d=a+b+c</code> (The values on <code>a</code>, <code>b</code>, <code>c</code> were given earlier). </p>
<p>What command should I use in order to produce an output M-file showing the result of this sum?</p>
| <p>In Matlab a semicolon ";" at the end of a line suppresses output. So,</p>
<pre><code>>> d=1+2;
>> d=1+2
d =
3
</code></pre>
<p>Or you can use <em>disp</em> as in the <a href="https://stackoverflow.com/questions/192796/creating-output-m-file-in-matlab#192841">first answer</a>.</p>
<pre><code>>... | <pre><code>disp(num2str(d));
</code></pre>
| 23,428 |
<p>I'm trying to achieve a 50px space at the bottom of my page, below the main content area so that no matter what text size the user is at, or how much content happens to be inside the page - there is always a proceeding 50px space after the content area which will make either the container div(transparent) or body sh... | <p>Hard to tell without seeing the markup, but it could be that your container div is not clearing its child elements, which might explain why margin or padding on the bottom is not working... </p>
<p>If you have floated divs inside the container then that could be the problem. </p>
<p>There are a number of techniqu... | <p>You can create a div like this:</p>
<pre><code>height: 50px;
width: 100%;
position: fixed;
bottom: 0;
</code></pre>
<p>That will just create a white box of height 50px that will never move and it stuck at the bottom of the browser. Is this what you are trying to achieve?</p>
<p>If the content is running through t... | 48,352 |
<p>I have an a aspx page, but all content is generated by hands(yes I know that I need to make a handler, I have another question)</p>
<p>I want to cache output in client browser. Problem is that it's cached only for one query.</p>
<pre><code> public static void ProceedCaching(string etag, string lastModify, s... | <p>To change the connection of an XSD at runtime you'll need to set the ConnectionModifier property of the table adapter to Public. If they're created by the "wizard" they will be set to Friend/Internal (VB/C#) by default.</p>
<p>I had trouble finding the ConnectionModifier property (it's not listed in my vs2005 docum... | <p>I have a winforms app that I had a similar problem. I created a static class that contained my settings (clsGlobal) and one of the properties was a connection string. In the page where I referenced the datatable, I set the connection string to clsGlobal.gstrConnectionString or the connection string property. May be ... | 47,642 |
<p>Do any one know why an application that always ran on Windows XP now suddenly crashes the msvcrt.dll?</p>
<p>There were only minor changes made to the threading classes, which was done under Vista in VC++ 6.</p>
<p>For all our libraries to work we are Dynamically linking to the MFC dlls. </p>
<p>A newer version o... | <p>This isn't very helpful, but by far the most likely reason is that you have a bug in your application that, for whatever reason, didn't show up previously. Something has changed somewhere, and now the bug shows up. You're just going to have to debug it.</p>
<p>As a general rule, just because something seems to work... | <p>You may have a problem that you are unintentionally upgrading your runtime (which is the problem I have)
<a href="https://stackoverflow.com/questions/397196/why-does-windows-side-by-side-winsxs-install-policy-for-auto-upgrade-when-there">side by side, automatically upgradeing version of runtime due to policy</a></p... | 41,857 |
<p>Server 2008 machine with SP1, Visual Studio 2008 with SP1. My user; Developer, is in the local Administrators group. That said, some actions I perform in Visual Studio (use the properties window of a web application to invoke the creation of a virtual directory in local IIS) tell me that Admin privileges are require... | <p>That's not how it works on Vista with UAC. Your user being in the admin group will mean that that user can perform admin tasks. Let's say you have a normal user and that user is logged on and tries to perform an admin task. That user won't be able to perform such task cause it's not on the admin group. He will need ... | <p>Because that's how it works, I guess... It doesn't matter the group your user is in, what matters is if the application is running with admin privileges or not. If it is, than you will be able to perform admin actions, otherwise you won't.</p>
<p>All applications that use UAC to perform admin actions (when you see ... | 41,111 |
<p>I am trying to figure out the following problem.
I am building Yet another math function grapher, The function is drawn on its predefined x,y range, that's all good.</p>
<p>Now I am working on the background and the ticking of X, Y axes (if any axes are shown).</p>
<p>I worked out the following.
I have a fixed wid... | <p>One way to do this would be to "normalise" the difference between the minimum and maximum and do a case distinction on that value. In python:</p>
<pre><code>delta = maximum - minimum
factor = 10**math.ceil(math.log(delta,10)) # smallest power of 10 greater than delta
normalised_delta = delta / factor # 0... | <p>Using deltaX</p>
<p>if deltax between 2 and 10 half increment
if deltax between 10 and 20 unit increment
if smaller than 2 we multiply by 10 and test again
if larger than 20 we divide
Then we get the position of the first unit or half increment on the width using xmin.</p>
<p>I still need to test this solution.</... | 45,126 |
<p>I think this is a fun engineering-level question.</p>
<p>I need to design a control which displays a line chart. What I want to be able to do is use a designer to add multiple <code>Pens</code> which actually describe the data and presentation so that it ends up with Xaml something along these lines:</p>
<pre><co... | <p>I would go with Chart as an ItemsControl and its ItemsPanel be a Canvas(For some light use I would go with Grid as ItemsPanel). And each Pen will be a CustomControl derived from PolyLine class. Does that make any sense?</p>
| <p>Another option is to extend Canvas for the chart and extend Shape for the Pens. Then dynamically draw the shape based on the Color/Data properties.</p>
| 7,218 |
<p>Apologies, I'm a EE designer and software guy. We've been CNC'ing prototypes, and my office just bought a very cheap 3D printer.</p>
<p>I'm using Cura as recomended, and wanted to print a piece that has features on both sides.</p>
<p>Here is a screenshot of each side.</p>
<p>So if you laid one side flat, you see... | <p>I haven't tried printing anything like that, but one trick is to print the piece at an angle of 45°, so as to minimise the number of surfaces that are horizontal (or near horizontal.) You will still need some supports, but far less than if you just plonked it flat on the build plate. My only other recommendation wou... | <p>I haven't tried printing anything like that, but one trick is to print the piece at an angle of 45°, so as to minimise the number of surfaces that are horizontal (or near horizontal.) You will still need some supports, but far less than if you just plonked it flat on the build plate. My only other recommendation wou... | 693 |
<p>I'm having trouble converting my Cocoa project from a manually-synched interface model to a bindings model so that I don't have to worry about interface glue code.</p>
<p>I followed the CocoaDevCentral <a href="http://cocoadevcentral.com/articles/000080.php" rel="nofollow noreferrer">Cocoa Bindings tutorial</a> to ... | <p>Have you put a breakpoint in your key: method to determine if it is getting called or not? If it isn't, then that would indicate that something isn't set up correctly for the binding in the table column (since you have verified that your array does have items in it).</p>
<p>I don't think that you need to create an ... | <blockquote>
<p>I've created a ControllerAlias object in my nib, </p>
</blockquote>
<p>What is a “controller alias”? Is this a model, controller, or view?</p>
<blockquote>
<p>connected it to my controller,</p>
</blockquote>
<p>What do you mean?</p>
<blockquote>
<p>created an NSArrayController that binds to on... | 34,743 |
<p>Just wondering if there is any way (in C) to get the contents of the console buffer, preferably as some kind of char array. It is going to be written to a file, so if I am missing out on something stupid that will do exactly that, then point it out. It can be Windows-specific. I am using MinGW (gcc 3.4.5).</p>
<p>T... | <p>I think you need to take a look at win32 console functions for example <a href="http://msdn.microsoft.com/en-us/library/ms683231(VS.85).aspx" rel="nofollow noreferrer">GetStdHandle()</a>, <a href="http://msdn.microsoft.com/en-us/library/ms684965(VS.85).aspx" rel="nofollow noreferrer">ReadConsoleOutput()</a>, <a hre... | <p>If it's the screen in a command window, then potentially no, or no easy way. You could hack at Windows events to select-all, copy, and read the clipboard.</p>
| 42,673 |
<p>My company is moving from svn (and open source products) to TFS (and MS products). We've used maven in the past for packaging-up pre-built components into release-ready packages. Is there a tool in TFS or MS-Land as powerful as maven to do this?</p>
<p>I've looked at msbuild, but it seems a little less robust tha... | <p>In the official TFS/Microsoft stack, <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx" rel="noreferrer">MSBuild</a> is the build language. However this is more like <a href="http://ant.apache.org/" rel="noreferrer">Ant</a> (or <a href="http://nant.sourceforge.net/" rel="noreferrer">Nant</a>) rather th... | <p>You will want to look at <a href="http://msdn.microsoft.com/en-us/library/ms181710(VS.80).aspx" rel="nofollow noreferrer">Team Build</a> which is part of TFS and <a href="http://en.wikipedia.org/wiki/MSBuild" rel="nofollow noreferrer">MsBuild</a>, which Team Build uses to automate the build process. With these two ... | 38,975 |
<p>Has anybody done a comparison of the overhead of the various background processing techniques? </p>
<p>Background/RB, Starling, Workling
MemcacheQ
Beanstalk
Background Job (Bj)
delayed_job (Dj)</p>
<p>I will be implementing one of them on a slice and would like to know how much memory they take up so I can factor... | <p>I would also be interested in a comprehensive comparison, but one thing I can say is that BackgroundRB is considered deprecated by its author. At EngineYard they are specifically recommending BackgroundJob after having had intractable problems with BackgroundRB. I've heard nothing about the other options you menti... | <p>For low maintenance I like Background Job. It runs in your Rails process or via cron so there are no daemon processes to monitor. On my server Bj is currently using 35636 RSS (approximately one Rails process worth).</p>
<p>I'm always surprised when I hear about people using BackgrounDRB because it is basically unma... | 40,653 |
<p>I'm porting old VB6 code that uses the Winsock control to C#. I haven't done any socket programming and I wonder if anyone has a good reference/tutorial/howto that I can use to start getting up to speed.</p>
<p>I'm appealing to the hive mind while I proceed with my generally unproductive googling.</p>
<p>I'm usin... | <p>The August 2005 MSDN Magazine had an article about System.Net.Sockets and WinSock:</p>
<p><a href="http://msdn.microsoft.com/en-us/magazine/cc300760.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc300760.aspx</a></p>
| <p><a href="http://msdn.microsoft.com/en-us/library/b6xa24z5.aspx" rel="nofollow noreferrer">MSDN is a good place to start</a></p>
<p>Are you working on:
a client (<a href="http://www.google.com/search?q=TCPClient+Tutorials" rel="nofollow noreferrer">TCPClient</a>)
or a server (<a href="http://www.google.com/search?... | 13,025 |
<p>I am adding objects into a java Vector using its add(Object) method.
In my example, the first 5 objects are identical, followed by 2 instances different from the first five.
For some reasons, as soon as I insert the first one that is different, it changes the entire vector to that value!</p>
<p>'values' is an itera... | <p>I suspect that, somehow, the "objects" you are getting from the iterator are really multiple references to a single instance of a mutable object, which is changing its state from "1" to "2". The thing I can't guess at is how it's changing state in this apparently single-threaded operation.</p>
<p>Can you post more ... | <p>The following program compiled and ran under Mac OS X</p>
<pre><code>import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
public class Test{
public static void main( String ... args ){
List list = Arrays.asList(new String[] {"1","1","1","1","1","2","... | 34,111 |
<p>In the early days of C++ when it was bolted on top of C, you could not use NULL as it was defined as <code>(void*)0</code>. You could not assign NULL to any pointer other than <code>void*</code>, which made it kind of useless. Back in those days, it was accepted that you used <code>0</code> (zero) for null pointers.... | <p>Here's Stroustrup's take on this: <a href="http://www.stroustrup.com/bs_faq2.html#null" rel="noreferrer">C++ Style and Technique FAQ</a></p>
<blockquote>
<p>In C++, the definition of <code>NULL</code> is 0, so there is only an aesthetic difference. I prefer to avoid macros, so I use 0. Another problem with <code>NUL... | <p>Setting a pointer to 0 is just not that clear. Especially if you come a language other than C++. This includes C as well as Javascript.</p>
<p>I recently delt with some code like so:</p>
<p><code>virtual void DrawTo(BITMAP *buffer) =0;</code></p>
<p>for pure virtual function for the first time. I thought it to... | 21,318 |
<p>By that I mean, what do I need to do to have useful assertions in my code?</p>
<p>MFC is quite easy, i just use ASSERT(something).</p>
<p>What's the non-MFC way?</p>
<p><strong>Edit:</strong> Is it possible to stop assert breaking in assert.c rather than than my file which called assert()?</p>
<p><strong>Edit:</... | <pre><code>#include <cassert>
assert(something);
</code></pre>
<p>and for compile-time checking, Boost's static asserts are pretty useful:</p>
<pre><code>#include <boost/static_assert.hpp>
BOOST_STATIC_ASSERT(sizeof(int) == 4); // compile fails if ints aren't 32-bit
</code></pre>
| <p>use intellisense to open it in visual studio (right click)</p>
<pre><code>// cassert standard header
#include <yvals.h>
#include <assert.h>
</code></pre>
<p>yvals.h is windows stuff. so, as far as assert() itself is concerned, the two ways to include it are identical. it's good practice to use the <c... | 21,682 |
<p>I have a web application which has a Sql Server database on the backend. As the site will be rolled out to different clients (or different virtual directories in IIS), each client derivative of the site will use the same backend.</p>
<p>There is an admin page where text on the site can be changed (enter text in a l... | <p>This is what I tried.</p>
<p>What I am confused about, though, is whether the where clause, when using a session object, is getting an object that I have written the code to retrieve from the session, or an object I have only added but not retrieved. I get the accountID when logging in (verified via stepping in - o... | <p>It sounds like your method should be working. I would follow a debugging process:</p>
<ol>
<li>Check that you are getting the accountID value from the database. Print it on screen immediately after retrieving the value for the first time.</li>
<li>If this is working, store the value in the Session and immediately r... | 38,176 |
<p>I am trying to put version information to my C# GUI framework retrieved from the latest ClearCase label. This was originally done from Visual Soursafe as below. </p>
<pre><code>vssDB = new VSSDatabaseClass();
vssDB.Open( databaseName, "vssadmin", "vssadmin" );
VSSItem item = vssDB.get_VSSItem( @"$\BuildDCP.bat", ... | <p>I believe this could be better achieved through a script, which would be called from your C# program.</p>
<p>But you may be able to directly call some COM objects, through the <a href="http://www.ibm.com/developerworks/rational/library/06/0207_joshi/index.html" rel="nofollow noreferrer">CAL interface</a> provided w... | <p>I really wish that the COM interfaces had better documentation, or were more obvious. Or that the code to ClearCase Explorer or Project Explorer were open source.</p>
<p>I've done a few cool things, but I pretty much started by adding COM references to my C# project, and then started screwing around with the inter... | 33,714 |
<p>The new Vista Audio subsystem is set up to be a chain of devices starting with the inputs, going through all the various controls (like mixers and volumen controls) and then ending up at various endpoints (like speakers or headphones).</p>
<p>My question is: Is there a tool out there that will show all the endpoint... | <p>Here's how to add a value at the top of the list. It can be an empty string, or some text.</p>
<pre><code><asp:DropDownList ID="categories" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="categoriesDataSource" DataTextField="CategoryName" DataValueField="CategoryID" EnableViewState="... | <p>I'd provide an extension method on <code>IEnumerable<string></code> that prepended an item to the beginning of the list:</p>
<pre><code> public static IEnumerable<string> Prepend(this IEnumerable<string> data, string item)
{
return new string[] { item == null ? string.Empty : item }... | 35,139 |
<p>This is a fairly trivial matter, but I'm curious to hear people's opinions on it.</p>
<p>If I have a Dictionary which I'm access through properties, which of these formats would you prefer for the property?</p>
<pre><code>/// <summary>
/// This class's FirstProperty property
/// </summary>
[DefaultValu... | <p>I like the second one purely because any avoidance of magic strings/numbers in code is a good thing. IMO if you need to reference a number or string literal in code more than once, it should be a constant. In most cases even if it's only used once it should be in a constant </p>
| <p>This isn't answering your question, but I don't think "DefaultValue" means what you think it means. It doesn't set a default value for your property.</p>
<p>See <a href="http://support.microsoft.com/kb/311339" rel="nofollow noreferrer">MSDN</a> and <a href="https://stackoverflow.com/questions/43738/defaultvalue-for... | 6,574 |
<p>I implemented OpenID support for an ASP.Net 2.0 web application and everything seems to be working fine on my local machine.</p>
<p>I am using DotNetOpenId library. Before I redirect to the third party website I store the orginal OpenID in the session to use when the user is authenticated (standard practice I belie... | <p>Solve the realm problem that you mentioned is easy. Just set the realm to *.mysite.com instead of just mysite.com. If you're using one of the ASP.NET controls included in the library, you just set a property on the control to set the realm. If you're doing it programmatically, you set the property on the IAuthent... | <p>I dunno how OpenID works, but LiveID gives you a token based on the combination of user and domain. I just would have forwarded www to mysite.com.</p>
| 34,452 |
<p>I have a page where there is a column and a content div, somewhat like this:</p>
<pre><code><div id="container">
<div id="content">blahblahblah</div>
<div id="column"> </div>
</div>
</code></pre>
<p>With some styling I have an image that is split between the column and t... | <p>Its a bug in the rendering engine. I run into it all the time. One potential way to solve it is to hide and show the div whenever you change the content (that in turn changes the height):</p>
<pre><code>var divCol = document.getElementById('column');
divCol.style.display = 'none';
divCol.style.display = 'block';
</... | <p>If you are worried about getting a flicker from showing and hiding divCol you can ajust another css property and it will have the same effect
e.g.</p>
<pre><code>var divCol = document.getElementById('column');
divCol.style.zoom = '1';
divCol.style.zoom = '';
</code></pre>
| 5,395 |
<p>For me <strong>usable</strong> means that:</p>
<ul>
<li>it's being used in real-wold</li>
<li>it has tools support. (at least some simple editor)</li>
<li>it has human readable syntax (no angle brackets please) </li>
</ul>
<p>Also I want it to be as close to XML as possible, i.e. there must be support for attribut... | <p>YAML is a 100% superset of JSON, so it doesn't make sense to reject YAML and then consider JSON instead. YAML does everything JSON does, but YAML gives so much more too (like references).</p>
<p>I can't think of anything XML can do that YAML can't, except to validate a document with a DTD, which in my experience h... | <p>AFAIK, JSON and YAML are exactly equivalent in data structure terms. YAML just has less brackets and quotes and stuff. So I don't see how you are rejecting one and keeping the other.</p>
<p>Also, I don't see how XML's angle brackets are less "human readable" than JSON's square brackets, curly brackets and quotes.</... | 7,455 |
<p>This one has been bugging me for a while now.</p>
<p>Is there a way I can stop Intellj IDEA from reporting missing keys in tags?</p>
<p>My messages are not stored in property files so the issue does not apply in my case.</p>
<p>I'm using IntelliJ IDEA 7.0.4</p>
| <p>I <a href="http://jetbrains.net/jira/browse/IDEADEV-30407" rel="nofollow noreferrer">reported this as an issue</a> to JetBrains and according to their issue report this is fixed in "Diana 8858". AFICT that means this will be fixed in IDEA 8.0.</p>
| <p>IMHO you can disable every hint or error marker in IDEA. Please tell us the version of IDEA that you use.</p>
| 8,994 |
<p>Which Visual Studio template should be used for a ASP.NET web site, the Web Site template or the Project | Web Application template?</p>
| <p>you'd better read this:
<a href="http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx</a>
in my opinion it depends on what you are developing</p>
| <p>Personally I use web application projects exclusively now. I actually converted a rather web site to a web application because of compilation times for the web site.</p>
<p>I also use pre-build events to move configuration specific configuration files around and pre-build and post-build events are not available in ... | 10,807 |
<p>Let's start with the following snippet:</p>
<pre><code>Foreach(Record item in RecordList){
..
item = UpdateRecord(item, 5);
..
}
</code></pre>
<p>The UpdateRecode function changes some field of item and returns the altered object. In this case the compiler throws an exception saying that the item can not be ... | <p>If you need to update a collection, don't use an iterator pattern, like you said, its either error prone, or smells bad.</p>
<p>I find that using a for loop with an index a bit clearer in this situation, as its very obvious what you are trying to do that way.</p>
| <p>Do you need to update the same list? Could you return a new (updated) enumeration instead?</p>
<pre><code>foreach(Record item in RecordList){
..
yield return GetUpdatedRecord(item, 5);
..
}
</code></pre>
| 37,342 |
<p>I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas?</p>
| <p>You need <a href="http://en.wikipedia.org/wiki/Address_Resolution_Protocol" rel="noreferrer">ARP</a>. Python's standard library doesn't include any code for that, so you either need to call an external program (your OS may have an 'arp' utility) or you need to build the packets yourself (possibly with a tool like <a... | <p>as python was not meant to deal with OS-specific issues (it's supposed to be interpreted and cross platform), i would execute an external command to do so:</p>
<p>in unix the command is <code>ifconfig</code></p>
<p>if you execute it as a pipe you get the desired result:</p>
<pre><code>import os
myPipe = os.popen2... | 11,115 |
<p>I've got two sizing issue regarding a Window I've got. The basic layout is like this</p>
<pre><code><Window MaxHeight="{DynamicResource {x:Static SystemParameters.VirtualScreenHeight}}"
MaxWidth="{DynamicResource {x:Static SystemParameters.VirtualScreenWidth}}"
>
<StackPanel>
... | <p>I would recommend you to use Grid with * Lenght instead of DockPanel and StackPanel.</p>
| <p>Just get rid of those <code>StackPanel</code>s. Replace them with <code>Grid</code>s and you should be good. The layout logic of the <code>StackPanel</code> is such that it will give children as much room in a certain direction (perpendicular to the <code>StackPanel</code>s orientation) as they ask for. That's why y... | 43,903 |
<p>I'm involved with updating an Access solution. It has a good amount of VBA, a number of queries, a small amount of tables, and a few forms for data entry & report generation. It's an ideal candidate for Access.</p>
<p>I want to make changes to the table design, the VBA, the queries, and the forms. How can I ... | <p>We wrote our own script in VBScript, that uses the undocumented Application.SaveAsText() in Access to export all code, form, macro and report modules. Here it is, it should give you some pointers. (Beware: some of the messages are in german, but you can easily change that.)</p>
<p>EDIT:
To summarize various comment... | <p>I tried to help contribute to his answer by adding an export option for Queries within the access database. (With ample help from <a href="https://stackoverflow.com/questions/1275502/using-vba-to-export-all-ms-access-sql-queries-to-text-files">other</a> SO <a href="https://stackoverflow.com/questions/20252599/how-do... | 22,709 |
<p>Is there a freely available library to create a MPEG (or any other simple video format) out of an image sequence ?</p>
<p>It must run on Linux too, and ideally have Python bindings.</p>
| <p>I know there's <a href="http://www.mplayerhq.hu/design7/news.html" rel="nofollow noreferrer">mencoder</a> (part of the mplayer project), and <a href="http://ffmpeg.mplayerhq.hu/" rel="nofollow noreferrer">ffmpeg</a>, which both can do this.</p>
| <p>Not a library, but mplayer has the ability to encode JPEG sequences to any kind of format. It runs on Linux, Windows, BSD and other platforms and you can write a python script if you want to use it with python.</p>
| 11,958 |
<p>I am referring to a truly visual environment, and not something that claims to be visual but requires mountains of hand-coded script, or a code generator that farts out a Web site and leaves you to start editing in Visual Studio. Are there any truly visual Web dev platforms out there?</p>
| <p>You might try FrontPage or something, but you would probably be better served becoming more comfortable with the code, or hiring a web developer to do it for you.</p>
| <p>You might try an online forms-building service, such as <a href="http://wufoo.com/" rel="nofollow noreferrer">Wufoo</a>.</p>
| 24,349 |
<p>I'm looking for a tool that can map the relationships in my database in mysql. I would like something like the view that is generated in MS-SQL Server Management Studio in the 'Show Diagram Pane'. Does such a thing exist?</p>
<p>I'm in charge of the design of the database and its using rails conventions. I would... | <p>Doesn't <a href="http://www.quest.com/toad-for-mysql/features-benefits.aspx" rel="nofollow noreferrer">MySQL Toad</a> have a schema diagram tool? I think it does. I'm not a diagram guy (much happier with mysqldump output) but I've worked with many people who swear by Toad.</p>
| <p>Most MySQL databases still use MyISAM tables, which do not provide foreign key constraints. Without explicit FKs the best you can do is guess at the relationships between tables.</p>
| 48,312 |
<p>Sam Ruby, author of "RESTful Web Services" seems to come out against the use of HTTP PUT for partial updates: <a href="http://intertwingly.net/blog/2008/02/15/Embrace-Extend-then-Innovate" rel="noreferrer">http://intertwingly.net/blog/2008/02/15/Embrace-Extend-then-Innovate</a></p>
<p>What isn't clear is how partia... | <p>As you can see from the comments in the blog post you referenced there is no agreed upon way to do partial updates. If heavyweights like Sam Ruby, Joe Gregario, Mark Nottingham, Mark Pilgrim, Bill de hÓra, etc cannot come to an agreement, what hope do we have.</p>
<p>As far as I am concerned, I wouldn't worry too ... | <p>HTTP PATCH now has an RFC - <a href="https://www.rfc-editor.org/rfc/rfc5789" rel="nofollow noreferrer">HTTP PATCH RFC</a></p>
| 28,721 |
<p>I am trying to respond back to a client with a PDF stored in a MSSQL varbinary(MAX) field. The response works on my localhost and a test server over http connection, but does not work on the production server over https connection. I am using just a simple BinaryWrite (code below).</p>
<pre><code> byte[] display... | <p>I just managed to get around this by replacing</p>
<pre><code>Response.Clear();
</code></pre>
<p>with</p>
<pre><code>Response.ClearContent();
Response.ClearHeaders();
</code></pre>
<p>so the whole thing looks like:</p>
<pre><code>byte[] downloadBytes = doc.GetData();
Response.ClearContent();
Response.ClearHeade... | <p>I ran into kind of the same problem a couple of years back. The solution we found were not the most beautiful one. We wrote the file to disk and did a Response.Redirect to it.</p>
| 46,486 |
<p>I launch my program in C#, which then calls some unmanaged C++. </p>
<p>When I break on a line in the unmanaged C++, the 'New Data Breakpoint' menu item is grayed out.</p>
<p>Is there anyway around this?</p>
| <p>To set a data breakpoint in the native portion of a mixed mode process, see the <a href="https://stackoverflow.com/a/243643/55721">answer posted by jyoung</a>.</p>
<p>Visual Studio disables data breakpoints when running anything but pure, native code. See <a href="http://social.msdn.microsoft.com/Forums/en-US/vsdeb... | <p>Another way is attaching to the process.</p>
<p>Build and run your software normally without debugger.</p>
<p>Then in Visual Studio, “Debug / Attach to Process” in the top menu, find the process, select it in the list. Then, to the right of “Attach to” panel, click “Select…” button, click the “Debug these code types... | 30,146 |
<p>I'm writing a password encryption routine. I've written the below app to illustrate my problem. About 20% of the time, this code works as expected. The rest of the time, the decryption throws a cryptographic exception - "The data is invalid".</p>
<p>I believe the problem is in the encryption portion, because the... | <p>On the advice of a colleague, I opted for Convert.ToBase64String. Works well. Corrected program below.</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptogra... | <p>I strongly suspect that it's the call to Encoding.Unicode.GetString that's causing the problem. You need to ensure that the data passed to the Unprotect call is <strong>exactly</strong> the same as that returned from the Protect call. If you're encoding the binary data as Unicode text as an interim step then you can... | 30,644 |
<p>I would like to create a folder that users who do not have privileges to view the rest of the site can see. This user group would be granted access to the site, but I only want them to be able to view one particular page.</p>
<p>Is this possible to do without going to every single page and removing the new user gro... | <p>yeah, you should be able to create a new group and add the users to that list/subweb/whatever and just that. This is assuming that you didn't grant access to all users somewhere. If you did, then hopefully the default access is granted to a default user group (like sharepoint visitors) and you can alter that group... | <p>If you are getting thrown off by the fact that the user/group is listed as having "Limited Access" on the ACLs on, say, the parent site/web. That's just a placeholder SharePoint uses to make sure people have access to at least the bare minimum set of objects (e.g. theme and other UI files and the parent web itself)... | 7,948 |
<p>I applied the MOSS infrastructure upgrade w/o applying the WSS one before it -- uh, help!</p>
| <p>Quoting:
<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=3811c371-0e83-47c8-976b-0b7f26a3b3c4&displaylang=en" rel="nofollow noreferrer">Infrastructure Update for Microsoft Office Servers (KB951297)</a></p>
<p><b>Other Relevant Updates</b> It is strongly recommended that you install the Infrast... | <p>Sounds like time for a full restore. The MOSS upgrade steps did explicitly ask for a restore, didn't it?</p>
| 7,066 |
<p>I have a single string that contains the command-line parameters to be passed to another executable and I need to extract the string[] containing the individual parameters in the same way that C# would if the commands had been specified on the command-line. The string[] will be used when executing another assemblies... | <p>It annoys me that there's no function to split a string based on a function that examines each character. If there was, you could write it like this:</p>
<pre><code> public static IEnumerable<string> SplitCommandLine(string commandLine)
{
bool inQuotes = false;
return commandLine.Split... | <p>Yes, the string object has a built in function called <code>Split()</code> that takes a single parameter specifying the character to look for as a delimiter, and returns an array of strings (string[]) with the individual values in it.</p>
| 38,271 |
<p><em>Disclaimer: I'm stuck on TFS and I hate it.</em></p>
<p>My source control structure looks like this:</p>
<ul>
<li>/dev</li>
<li>/releases</li>
<li>/branches</li>
<li>/experimental-upgrade</li>
</ul>
<p>I branched from dev to experimental-upgrade and didn't touch it. I then did some more work in dev and merge... | <p>@Ben</p>
<p>You can actually do a full delete in TFS, but it is highly not recommended unless you know what you are doing. You have to do it from the command line with the command tf destroy</p>
<pre><code>tf destroy [/keephistory] itemspec1 [;versionspec]
[itemspec2...itemspecN] [/stopat:versionspec] ... | <p>@Nick: No changes have been made to this just yet. I may have to delete it and re-branch (however you really can't fully delete in TFS)</p>
<p>And I have to disagree... branching is absolutely a good practice for experimental changes. Shelving is just temporary storage that will get backed up if I don't want to ... | 6,400 |
<p>I need to pull some BLOB data from a SQL Server 2005 database and generate a SQL script to insert this same data in another database, in another server.</p>
<p>I am only allowed to do this using SQL scripts, I can't use any other utility or write a program in Java or .NET to do it.</p>
<p>The other big restriction... | <p>TEXTCOPY was a sample application included in SQL Server 7.0 and 2000 but no longer available in SQL Server 2005.</p>
<p>However, googling for TEXTCOPY in SQL Server 2005, I found this alternative that might do the trick:</p>
<p><a href="http://sequelserver.blogspot.com/2007/01/texcopy-sql-server-2005.html" rel="n... | <p>Take a look at this question and search for bcp on the page - has example of both import and export for varbinary(max) (which is the new standard type for such columns). you can run arbitrary query for export.</p>
<p><a href="https://stackoverflow.com/questions/1643627/how-to-insert-a-blob-into-a-database-using-sql... | 34,227 |
<p>Our client gets Excel files in Excel's HTML format.(That's the way it arrives; nobody has any control over that.) We then need to run a report based on the data in the file. Using ADO.NET (OleDbReader) results in a "External file not in expected format" exception.</p>
<p>If the data is converted to regular Excel fo... | <p>Try the HTML Agility Pack: <a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow noreferrer">http://www.codeplex.com/htmlagilitypack</a></p>
<p>I use it in a similar scenario. In my case:...</p>
<ul>
<li>someone pasted a table from excel into the clipboard</li>
<li>retrieve the HTML text</li>
<li>use HTM... | <p>I'm not sure what you mean by "Excel's HTML format". Recent versions of Excel have an XML file format, and I Excel can open an HTML file containing a table and convert it to a worksheet, but Í don't know of any specific Excel HTML format.</p>
<p>Regarding the solution using Excel Automation, once you have a Works... | 42,082 |
<p>I normally use scp to copy stuff, but now I'm trying to get used to the more powerful rsync command. It helps me use less bandwidth by copying up only files that have changed. However, rsync has a lot of complex parameters, so I thought, hey, I'll just make a little Bash script that makes it easy for me, and call th... | <p>/var/www/mysite/* is expanded by the shell, so you have many more arguments being passed in than you're handling in the script.</p>
<p>Also variables aren't substituted in single quotes, so you need to use double quotes. (See bash <a href="http://www.gnu.org/software/bash/manual/bashref.html#Double-Quotes" rel="nof... | <p>Couldn't you technically turn this into a function as well?:</p>
<pre><code> rscp() {
rsync -avzp --progress --rsh="ssh -p$PORT" "$@"
}
</code></pre>
<p>And then when you run it: rscp 3822</p>
| 37,552 |
<p>Let's say I have a split view, and I want to fill half of it with a table view (a fairly common use case, I would think). Is there any way to tell the table view to size itself to fit the split view or do I really have to size it manually?</p>
| <p>As far as I know, doing it manually is the only way to go. However, if you turn on "snap to cocoa guidelines", the inner view will snap to the edges of the enclosing view as you drag towards them. This makes it easier than having to manually mouse the edges into place, or manually edit the sizes to match.</p>
| <p>You can set all of the springs and struts of the table view to "on" in the size inspector and that will cause the table view to fill the split view. Alternatively, you can use the outline view in the main document window to place the tableview's enclosing scroll view directly into the splitview instead of in an inte... | 44,461 |
<p>Does anyone know if it is possible to reliably determine (programattically C/C++...) whether or not a firewall or IP filtering software is installed on a Windows PC? I need to detect whether a certain server IP is being blocked in my client software by the host OS.</p>
<p>I don't need to worry about external hardw... | <p>After reading some of your comments in reply to other answers, I think this might actually be closer to what you're looking for. It might not catch every type of firewall but any major firewall vendor should be registered with the Security Center and therefore detected with this method. You could also combine this w... | <p>Try invoking Ping.</p>
| 24,203 |
<p>I'm trying to build a method that will receive a Linq table, and should return a List<> of values that will be a DropDownList Datasource.</p>
<p>This is what I've got till now:</p>
<pre><code>public static List<Structs.NameValuePair> GenDropDownItens<T>(string ValueField , string TextField ) where T... | <p>Project the result of your LINQ2SQL query into a System.Collections.Generic.KeyValuePair object like so:</p>
<pre><code>
ddl.DataSource = DataContext.Table.Select(o => new KeyValuePair<string, string>(o.ID, o.DisplayField));
ddl.DataBind();
</code></pre>
<p>You will then want to set the DataValueField and Da... | <p>Table.Select( t => t.field1, t.field2 )</p>
<p>Also check out Scott Gutherie's blog series <a href="http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx" rel="nofollow noreferrer">here</a>.</p>
| 36,966 |
<p>I'm successfully using VBScript within WScript to remotely read and write IIS configurations from the server. When I attempt to run these same scripts from my desk box they fail, though. Example:</p>
<pre><code>Dim vdir
Set vdir = GetObject("IIS://servername/w3svc/226/root")
</code></pre>
<p>Error = "Invalid synta... | <p>That could be tough to do what you want. You can import a git repo into svn via something like this: <a href="http://code.google.com/p/support/wiki/ImportingFromGit" rel="nofollow noreferrer">http://code.google.com/p/support/wiki/ImportingFromGit</a>, but I think you will have conflicts. You could just recreate yo... | <p>From the git svn repository that you are trying to migrate to, do something like the following:</p>
<pre><code>git remote add old-repo <path-to-old-repo>
git fetch old-repo
# to browse and figure out the hashes, if that helps
gitk --all &
# for each branch you want to graft
git rebase --onto <new git ... | 14,297 |
<p>I have a web application that is dynamically loading PDF files for viewing in the browser.
Currently, it uses "innerHTML" to replace a div with the PDF Object. This works.</p>
<p>But, is there a better way to get the ID of the element and set the "src" or "data" parameter for the Object / Embed and have it instan... | <p>I am not sure if this will work, as I have not tried this out in my projects.</p>
<p>(Looking at your JS, I believe you are using jQuery. If not, please correct me)</p>
<p>Once you have populated the divPDF with the object you might try the code below:</p>
<pre><code>$("objPDF").attr({
data: "dir/to/newPDF"
}... | <p>If the handler for the PDF is acrobat (it doesn't have to be), it exposes a JS interface that is documented here:</p>
<p><a href="http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf" rel="nofollow noreferrer">http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf</a></p>
<p>See if you can call ope... | 12,139 |
<p>Okay, so I'm running a small test webserver on my private network. I've got a machine running Windows 2000 Pro, and I'm trying to run an ASP.NET app through IIS.</p>
<p>I wrote it so that the webpage would use the registry to store certain settings (connection strings, potentially volatile locations of other web s... | <p>If your having touble with RegEdit in Windows 2000 you can try the following:</p>
<ul>
<li>Copy the Windows XP RegEdt32.exe to the Windows 2000 Machine</li>
<li>Using a Windows XP Machine, connect to the Windows 2000 registry remotely: File > Connect Network Registry</li>
</ul>
| <p>You can set permissions at the folder level for which you want to grant user permissions read/write access. </p>
<p>In your case, right click on the "Software" folder and select "Permissions".</p>
<p>You'll probably know the rest from there.</p>
<p>EDIT: If you still run into issues, you may want to modify your w... | 4,888 |
<p>Is there a way to control the addins Visual Studio 2008 loads via the command line?
I am looking for a way to load my DevExpress plug in when I am working with VB or C# and alternatively load Visual Assist X when I am working on a c++ project.</p>
| <p>Not a direct answer but you can disable Visual Assist X either via the menu (VAssistX | Enable/Disable ) or via the command VAssistX.EnableDisable (both of these toggle between on and off). Alternatively, you can add .cs and .vb file extensions to the "Extension to ignore" list in Visual Assist Options | Projects |... | <p>There is a way to access the command line from a plugin. I think the only option, if you really want this and the plugin doesn't support it out of the box, is the write your own plugin. To do this, just read Environment.CommandLine from the OnConnection method.</p>
| 22,768 |
<p>My job would be easier, or at least less tedious if I could come up with an automated way (preferably in a Python script) to extract useful information from a FileMaker Pro database. I am working on Linux machine and the FileMaker database is on the same LAN running on an OS X machine. I can log into the webby inter... | <p>It has been a <strong>really</strong> long time since I did anything with FileMaker Pro, but I know that it does have capabilities for an ODBC (and JDBC) connection to be made to it (however, I don't know how, or if, that translates to the linux/perl/python world though). </p>
<p>This article shows how to share/ex... | <p>You'll need the FileMaker Pro installation CD to get the drivers. <a href="http://www.filemaker.com/downloads/pdf/fm9_odbc_jdbc_guide_en.pdf" rel="nofollow noreferrer">This document</a> details the process for FMP 9 - it is similar for versions 7.x and 8.x as well. Versions 6.x and earlier are completely different a... | 4,829 |
<p>Periodically (during autosave) and at close i get:</p>
<p><strong>Problems saving workspace</strong></p>
<pre><code>(X) Problems occurred while trying to save the state of the workbench.
Details >>
Could not write metadata for '/projectname'.
encoded string too long: 123456 bytes
</code></pre>
<p>Can'... | <p>It should relate to a bug in <a href="http://www.docjar.com/html/api/java/io/DataOutputStream.java.html" rel="nofollow noreferrer">DataOuputStream</a> that it cannot writeUTF with longer then 65535 utflen. </p>
<p>If I were you, I will try to find a way to reduce the data size, and I will submit bug report to Eclip... | <p>It's not a write permissions or disk-space issue. I'm getting the same problem on Eclipse 3.5 M4. No troubles with 3.4.1.</p>
| 49,977 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.