instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm having the hardest time trying to get this to work, hoping one of you has done this before.</p>
<p>I have a C# console app that is running a child process which inherits its console. I want a ctrl-c caught by the outer app to be passed along to the inner app so that it can have a chance to shut down nicely.</p>... | <p>Not so sure this is a good approach. This only works if the child process is created with the CREATE_NEW_PROCESS_GROUP flag for <code>CreateProcess()</code>. The System.Diagnostics.Process class however does not support this.</p>
<p>Consider using the return value from the Main() method. There is already a uniqu... | <p>Here is my solution for sending ctrl-c to a process. FYI, I never got <code>GenerateConsoleCtrlEvent</code> to work.</p>
<p>Rather than using GenerateConsoleCtrlEvent, here is how I have found to send CTRL-C to a process. FYI, in this case, I didn't ever need to find the group process ID.</p>
<pre><code>using Sy... | 38,088 |
<p>What is the best practice of Unicode processing in C++?</p>
| <ul>
<li>Use <a href="http://www.icu-project.org/" rel="noreferrer">ICU</a> for dealing with your data (or a similar library)</li>
<li>In your own data store, make sure everything is stored in the same encoding</li>
<li>Make sure you are always using your unicode library for mundane tasks like string length, capitaliz... | <p>Use IBM's <a href="http://www.icu-project.org/" rel="nofollow noreferrer">International Components for Unicode</a></p>
| 7,946 |
<p>SAP HR apparently has several models for describing the relationship between Position (S), Job (C), Organization (O) and Person (P) objects that the Organizational Management (OM) module is used to maintain.</p>
<p>P (Person) objects are usually Holders of Positions (S).</p>
<p>There is the S-S relationship model,... | <p>There is no fixed model of organisation, as you can create your own objects and/or relations between objects. OM is a module by itself, so informations given here will be just a really short introduction.</p>
<p>The most simple org model is a O-O-S-P :</p>
<ul>
<li>the O-O relation (A/B 002) is a hierarchical on... | <p>The relationships used in the HRP1001 table (HRP1001-RELAT) are stored in table T778V. Their texts are stored in table T777V.</p>
<pre>RELAT RTEXT RINVT
001 Is a subdivision of Is subdivided into
002 Reports (line) to Is line supervisor of
003 Belongs to Incorporates
</pre>
| 36,210 |
<p>How do I convert TIS-620 (the extended ASCII Thai Character code page) string to UTF-8 string in Java?</p>
| <p>The problem with using script to check whether javascript is enabled is that you only find that out after the script hasn't run.</p>
<p>Some solutions try the opposite - they use javascript to set a value and then supply Javascript enabled controls if that value is later detected. However, this fails with javascri... | <p>This is a way to check when a form is being submitted. </p>
<p><a href="https://web.archive.org/web/20210428071600/http://www.4guysfromrolla.com/webtech/082400-1.shtml" rel="nofollow noreferrer">https://web.archive.org/web/20210428071600/http://www.4guysfromrolla.com/webtech/082400-1.shtml</a></p>
<p>I dont think ... | 30,595 |
<p>By "generate", I mean auto-generation of the code necessary for a particular selected (set of) variable(s).</p>
<p>But any more explicit explication or comment on good practice is welcome.</p>
| <p>Rather than using <kbd>Ctrl</kbd> + <kbd>K</kbd>, <kbd>X</kbd> you can also just type <code>prop</code> and then hit <kbd>Tab</kbd> twice.</p>
| <p>You just simply press <kbd>Alt</kbd> + <kbd>Ins</kbd> in Android Studio. </p>
<p>After declaring variables, you will get the getters and setters in the generated code.</p>
| 2,514 |
<p>All of my Visio experience is with LAN/WAN documentation. I recently had a desire to visualize the relationship between <a href="http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html" rel="nofollow noreferrer">objects</a> in the <a href="http://www.nagios.org/" rel="nofollow noreferrer">Nagios</a> configura... | <p>I just built a quad core - 8 GB of RAM and run Server 2008 with Hyper-V on it. I have VMs for my build server, dev platform, and deployment options (XP, Vista, Server 2003/2008) with snapshots at the various service pack levels. What's nice is you can spin up a VM whenever you need it, and re-allocate the resource... | <p>People are probably going to yell at me...but I've found that Vista 64 is mostly worth it. The main reason for me though is that I'm always maxing out my memory and having a 64bit OS allows me to go past the <4GB limit of 32bit.</p>
<p>But even if you don't get 64bit, just buy 2 2GB RAM cards anyways....you wil... | 3,636 |
<p>I would like to know how to change the colour of the equality sign and double quotes for html documents in the eclipse PDT IDE. I can change most colours in Preferences -> Web & XML -> HTML Files -> syntax coloring, but can't change the characters <code>=</code> or <code>"</code> e.g. in an anchor tag <code><... | <p>Just do it the usual way and then insert it using <code>SecurityContextHolder.setContext()</code> in your test class, for example:</p>
<p>Controller:</p>
<pre><code>Authentication a = SecurityContextHolder.getContext().getAuthentication();
</code></pre>
<p>Test:</p>
<pre><code>Authentication authentication = Moc... | <p>After quite a lot of work I was able to reproduce the desired behavior. I had emulated the login through MockMvc. It is too heavy for most unit tests but helpful for integration tests. </p>
<p>Of course I am willing to see those new features in Spring Security 4.0 that will make our testing easier.</p>
<pre><code... | 47,056 |
<p>I am writing software to parse ID3v2 tags in Java. I need to find some files with good examples of the tag with lots of different frames. Ideally the tags will contain an embedded picture because that is what is kicking my butt right now.</p>
<p>Does anyone know where I can find some good free (legal) ID3v2 tagge... | <p>You can create the example files with a tagger by yourself. I'm the author of the Windows freeware tagger <a href="http://www.mp3tag.de/en/" rel="nofollow noreferrer">Mp3tag</a> which is able to write ID3v2.3 (UTF-16 and ISO-8859-1) and ID3v2.4 tags in UTF-8 (both along with APIC frames). You can find a list of supp... | <p>This maybe be obvious and not what you are seeking, but what about ripping some of your legally obtained CDs and editing them using iTunes? iTunes would also allow you to add embedded picture. There are of course many open source programs that will also do this.</p>
| 20,872 |
<p>I have a bit of code that basically reads an XML document using the XMLDocument.Load(uri) method which works fine, but doesn't work so well if the call is made through a proxy.</p>
<p>I was wondering if anyone knew of a way to make this call (or achieve the same effect) through a proxy?</p>
| <p>Do you have to provide credentials to the proxy?</p>
<p>If so, this should help:
"Supplying Authentication Credentials to XmlResolver when Reading from a File"
<a href="http://msdn.microsoft.com/en-us/library/aa720674.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa720674.aspx</a></p>
<p>Basically... | <p>Actually rather than storing in settings for your app, you can use the Windows proxy config. I believe this is standard now so not having to configure proxy in each program i.e. look at Chrome's Settings for Proxy directs to Windows</p>
<pre><code>IWebProxy wp = WebRequest.GetSystemWebProxy();
wp.C... | 15,187 |
<p>Background:
I'm working on a silverlight (1.0) application that dynamically builds a map of the United States with icons and text overlayed at specific locations. The map works great in the browser and now I need to get a static (printable and insertable into documents/powerpoints) copy of a displayed map.</p>
<p>O... | <p>This should be enough to get you started:</p>
<pre><code>
private void ExportCanvas(int width, int height)
{
string path = @"c:\temp\Test.tif";
FileStream fs = new FileStream(path, FileMode.Create);
RenderTargetBitmap renderBitmap = new RenderTargetBitmap(width,
... | <p>This is what ended up working for me:</p>
<pre><code>Public Sub Capture(ByVal MyImage As Canvas)
' Normally we would obtain a user's configured DPI setting to account for the possibilty of a high DPI setting.
' However, this code is running server side so the client's DPI is not obtainable.
... | 27,487 |
<p>Most precompiled Windows binaries are made with the MSYS+gcc toolchain. It uses MSVCRT runtime, which is incompatible with Visual C++ 2005/2008.</p>
<p>So, how to go about and compile Cairo 1.6.4 (or later) for Visual C++ only. Including dependencies (png,zlib,pixman).</p>
| <p>Here are instructions for building Cairo/Cairomm with Visual C++.</p>
<p>Required:</p>
<ul>
<li>Visual C++ 2008 Express SP1 (now includes SDK)</li>
<li>MSYS 1.0</li>
</ul>
<p>To use VC++ command line tools, a batch file 'vcvars32.bat' needs to be run.</p>
<pre>
C:\Program Files\Microsoft Visual Studio 9.0\C... | <p>MSYS+gcc toolchain uses the old MSVCRT runtime library (now built into Windows) and Visual C++ 2005/2008 bring their own. It is a <a href="http://lua-users.org/lists/lua-l/2008-09/msg00077.html" rel="nofollow noreferrer">known fact</a> that code should not depend on multiple runtimes. Passing things s.a. file handle... | 11,118 |
<p>If I attempt to connect to Mac OS X 10.5 Leopard's built in vnc server at a low color depth from Windows, the client bombs after connecting. It only works when I set it to the highest color depth. I've tried with at least 3 windows VNC clients. Any ideas? There some setting I can set in Mac OS X?</p>
<p>It takes ab... | <p>Not with the builtin VNC server. <a href="http://sourceforge.net/projects/osxvnc/" rel="nofollow noreferrer">Vine Server</a> allows you to change the bit depth that clients connect at though.</p>
| <p>I use both. I find the built-in VNC server in OS X offers the most compatibility with keystrokes. I use it when I'm on the local network. When using VPN (much slower), I setup Vine Server ("System Server" mode) on a non-standard port # (say 5905), with a much lower color resolution, so the screen doesn't take 30 ... | 10,009 |
<p>Is it possible to search every field of every table for a particular value in Oracle?</p>
<p>There are hundreds of tables with thousands of rows in some tables so I know this could take a very long time to query. But the only thing I know is that a value for the field I would like to query against is <code>1/22/200... | <p>Quote:</p>
<blockquote>
<p>I've tried using this statement below
to find an appropriate column based on
what I think it should be named but it
returned no results.*</p>
<pre><code>SELECT * from dba_objects WHERE
object_name like '%DTN%'
</code></pre>
</blockquote>
<p>A column isn't an object. If you mean... | <p>The Oracle LIKE condition allows wildcards to be used in the WHERE clause of a SELECT, INSERT, UPDATE, or DELETE statement.</p>
<p>%: to match any string of any length</p>
<p>Eg-</p>
<pre><code>SELECT last_name
FROM customer_tab
WHERE last_name LIKE '%A%';
</code></pre>
<p>-: to match on a single character<... | 25,582 |
<p>I would like to <a href="http://en.wikipedia.org/wiki/Digital_signature" rel="nofollow noreferrer">sign</a> a device, and I have 64 bits to store my signature in the device. This device has a MAC address and some other details (about 30 bytes worth) I can mangle to create my signature. </p>
<p>If possible, I would ... | <p>Hash functions and digital signatures are <strong>very</strong> different things.</p>
<p>The size of a digital signature depends on the underlying hash function and the key length. So in theory, you can create an RSA implementation that generates 64-bit signatures, but that'd be an extremely weak signature.</p>
<p... | <p>You could just use a standard hashing function (MD5 SHA1) and only use the first or last 30 bytes.<br>
The number of bytes a hashing function generates is fairly arbitrary - it's obviously a trade off between space and uniqueness. There is nothing special about the lenght of the signature they use.</p>
<p>Edit - so... | 35,308 |
<p>What is the difference between <code>==</code> and <code>===</code>?</p>
<ul>
<li>How exactly does the loosely <code>==</code> comparison work?</li>
<li>How exactly does the strict <code>===</code> comparison work?</li>
</ul>
<p>What would be some useful examples?</p>
| <h2>Difference between <code>==</code> and <code>===</code></h2>
<p>The difference between the loosely <code>==</code> equal operator and the strict <code>===</code> identical operator is exactly explained in the <a href="http://php.net/manual/en/language.operators.comparison.php#language.operators.comparison" rel="nof... | <p>Variables have a type and a value.</p>
<ul>
<li>$var = "test" is a string that contain "test"</li>
<li>$var2 = 24 is an integer vhose value is 24.</li>
</ul>
<p>When you use these variables (in PHP), sometimes you don't have the good type.
For example, if you do</p>
<pre><code>if ($var == 1) {... do something ...... | 10,613 |
<p>I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory.
Google search shows a commercial one is <a href="http://www.softwareverify.com/python/memory/index.html" rel="noreferrer">Python Memory Validator</a> (Windows only).<... | <p><a href="https://github.com/zhuyifei1999/guppy3/" rel="noreferrer">guppy3</a> is quite simple to use. At some point in your code, you have to write the following:</p>
<pre><code>from guppy import hpy
h = hpy()
print(h.heap())
</code></pre>
<p>This gives you some output like this:</p>
<pre><code>Partition of a set o... | <p>Try also the <a href="http://pytracemalloc.readthedocs.org/" rel="noreferrer">pytracemalloc project</a> which provides the memory usage per Python line number.</p>
<p>EDIT (2014/04): It now has a Qt GUI to analyze snapshots.</p>
| 13,546 |
<p>I have a large set of XML files of a propriatary schema -the XML files define binary communication protocol (message structure).</p>
<p>I'd like to leverage Google's protocol buffers technology. </p>
<p>I am using existing code to load the XML files into an object model (in memory).
I'd like to generate a .proto ... | <p>Use <a href="http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx" rel="noreferrer"><code>Path.GetFileName(fullPath)</code></a> to get just the filename part, like this:</p>
<pre><code>OpenFileDialog.ShowDialog()
PictureNameTextEdit.Text = System.IO.Path.GetFileName(OpenFileDialog.FileName)
</cod... | <pre><code>//Following code return file name only
string[] FileFullPath;
string FileName;
objOpenFileDialog.Title = "Select Center Logo";
objOpenFileDialog.ShowDialog();
FileFullPath = objOpenFileDialog.FileNames[0].ToString().Split('\\');
FileName = FileFullPath[FileFullPath.Length - 1]; //return only File Name
//... | 44,494 |
<p>I know this rather goes against the idea of enums, but is it possible to extend enums in C#/Java? I mean "extend" in both the sense of adding new values to an enum, but also in the OO sense of inheriting from an existing enum. </p>
<p>I assume it's not possible in Java, as it only got them fairly recently (Java 5... | <p>The reason you can't extend Enums is because it would lead to problems with polymorphism.</p>
<p>Say you have an enum MyEnum with values A, B, and C , and extend it with value D as MyExtEnum.</p>
<p>Suppose a method expects a myEnum value somewhere, for instance as a parameter. It should be legal to supply a MyExt... | <p>You can't inherit from/extend an enum, you can use <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx" rel="nofollow noreferrer">attributes</a> to <a href="http://blog.waynehartman.com/articles/84.aspx" rel="nofollow noreferrer">declare a description</a>. If you're look... | 7,912 |
<p>I've seen a related question on this website regarding a Linux system. I have the same question on a Windows XP OS. I bought a Winchester USB external HD, and found out from technical support that the sleep feature is in the firmware and cannot be turned off. I'm looking for an application that will automatically... | <p>I have tried nearly everything to fix this problem on my external which is shared out containing my movies. Nothing ever worked. I have a WD Mybook, and I think the sleep is occurring internally in the drive.</p>
<p>I have a solution that works for me, and should for anyone else. The key is to keep the USB drive... | <p>Any text editor with an autosave function would do it.
You could also write a batch file to get a directory listing, and have it act recursively (call itself) after a set time period. Or use windows scheduler to execute it.</p>
| 40,165 |
<p>i work with sql server, but i must migrate to an application with Oracle DB.
for trace my application queries, in Sql Server i use wonderful Profiler tool. is there something of equivalent for Oracle?</p>
| <p>You can use The Oracle Enterprise Manager to monitor the active sessions, with the query that is being executed, its execution plan, locks, some statistics and even a progress bar for the longer tasks.</p>
<p>See: <a href="http://download.oracle.com/docs/cd/B10501_01/em.920/a96674/db_admin.htm#1013955" rel="nofollo... | <p>This is an Oracle doc explaining how to trace SQL queries, including a couple of tools (SQL Trace and tkprof)</p>
<p><a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/sqltrace.htm#sthref2019" rel="nofollow noreferrer">link</a></p>
| 17,905 |
<p>I made two updates to my Ender 3 Pro: Silent Mainboard and BLTouch. My printer head is way out of sync now. After I Auto Home, it moves along the X-axis to the left, hits the stop switch & moves back to the right. It does not move at all on the Z-axis and remains 3 - 4" above the bed during and after Auto ... | <p>Resolved : connected the white & black wires to the 5 pin output on the board. This solved the homing issue.</p>
| <p>I had the same issue and thought I bricked it, so thank you for getting me on the right path! For Ender 3 Pro v4.2.2 motherboard, no Pinboard A, ISP Pinboard, or Burner required! In my case, I had used the provided pins (white housing) that were on the v4.2.2 motherboard itself.</p>
<p>In doing so I had to switch th... | 1,882 |
<p>I have an abstract base class which inherits from <code>UserControl</code> and which is then used to derive a number of classes. </p>
<p>The problem I have is how to elegantly ensure that the generated function <code>InitializeComponent()</code> is called for each layer of class. </p>
<p>So the (abstract) base cla... | <p>public DerivedClass() : base()
{}</p>
<p>This will call your base constructor, there isn't usually a magic way to do things, if you need InitializeComponents called, you'll probably have to call it yourself.</p>
| <p>if you make InitializeComponent virtual, and you override it for all sub-classes, the base class will call the right method for each of the sub-classes if you call the base constructor from the derived constructor.</p>
| 31,622 |
<p>I was asking about specifics with this approach earlier today <a href="https://stackoverflow.com/questions/372572/how-to-block-the-ui-thread-from-another-thread-or-force-a-form-to-run-within-th">here</a> but the confused responses has me wondering if I'm going about this all wrong.</p>
<p>So here's the problem. I ... | <p>The previous post (with the Join()) blocks the UI but also prevents it from rendering, showing a blank (white) window, like if the app crashed. Better option would be to create a custom modal window (that the user can't move or close or do anything) with an event listener that will close the window in its handler. ... | <p>You might want to block the current thread until an other thread do the check in the background. This can be done by joining (<code>.Join()</code>) the thread that do the check in the background. This on will block the calling thread until it's over. If I have more time I'll make a snippet code for you, but this mig... | 48,802 |
<p>Modules or software solutions for generating English pronounceable passwords?</p>
<p>Are there similar modules for other languages?</p>
<p>-Adam</p>
| <p>You'll want to investigate the <a href="http://www.google.com/search?q=pronounceable+markov" rel="nofollow noreferrer">Markov chain method</a>. Here's an example:</p>
<ul>
<li><a href="http://www.multicians.org/thvv/gpw.html" rel="nofollow noreferrer">http://www.multicians.org/thvv/gpw.html</a></li>
</ul>
<p>and h... | <p>You should look for <a href="http://polygen.org/" rel="nofollow noreferrer">polygen</a>, unfortunately I don't know if there is an english version too of the software. It generates random words/sentences using determinated rule you choose (the site contains very funny things but in Italian only :\ The rules can be w... | 22,899 |
<p>In my C# winforms app, I have a datagrid. When the datagrid reloads, I want to set the scrollbar back to where the user had it set. How can I do this?</p>
<p>EDIT: I'm using the old winforms DataGrid control, not the newer DataGridView</p>
| <p>You don't actually interact directly with the scrollbar, rather you set the <code>FirstDisplayedScrollingRowIndex</code>. So before it reloads, capture that index, once it's reloaded, reset it to that index.</p>
<p><strong>EDIT:</strong> Good point in the comment. If you're using a <code>DataGridView</code> then th... | <p>I used the answer by @BFree, but also needed to capture the first visible row in the <code>DataGrid</code>:</p>
<pre><code>int indexOfTopMostRow = HitTest(dataGrid.RowHeaderWidth + 10,
dataGrid.PreferredRowHeight + 10).Row;
</code></pre>
| 49,549 |
<p>What's the best way to close the loop and have a desktop app "call home" with customer feedback? Right now our code will login to our SMTP server and send me some email.</p>
| <p>The site GetSatisfaction has been an increasingly popular way to get customer feedback.</p>
<p><a href="http://getsatisfaction.com/" rel="nofollow noreferrer">http://getsatisfaction.com/</a></p>
<p>GetSatisfaction is a community based site that builds a community around your application. Users can post questions,... | <p>Personally, I would also POST the information. However, I would send it to a PHP script that would then insert it into a mySQL database. This way, your data can be pre-sorted and pre-categorized for analysis later. It also gives you the potential to track multiple entries by single users.</p>
| 5,034 |
<p>I've got a customer trying to access one of my sites, and they keep getting this error > ssl_error_rx_record_too_long</p>
<p>They're getting this error on all browsers, all platforms. I can't reproduce the problem at all.</p>
<p>My server and myself are located in the USA, the customer is located in India.</p>
<p... | <p>The <a href="http://support.servertastic.com/error-code-ssl-error-rx-record-too-long/" rel="noreferrer">link mentioned by Subimage</a> was right on the money for me. It suggested changing the virtual host tag, ie, from <code><VirtualHost myserver.example.com:443></code> to <code><VirtualHost _default_:443&... | <p>I had the same problem in some browser to access to my SSL site.
I have found that <strong>I had to give to fireFox the right proxy</strong> (FireFox was accessing directly to internet).</p>
<p>Depending of the lan configuration (Tunneling, filtering, proxy redirection), the "direct access to internet" mode for Fi... | 14,515 |
<p>I have made a custom 3D printer with RAMPS electronics. I have printed a Benchy (ship) well, but when I try to print anything with teeth (spiral vase), gears (bearing), or a circle (rocket), the Y-axis skip steps in a regular rate giving 70-60 degrees skew along the printing the Y-direction, but each layer is perfec... | <p>The welding option is only appropriate if you have the tool needed for it, the lighter welding is really hard to do and if your printer allows it you could just watch for the moment the spool runs out and push the new filament as the last of the previous one gets extruded, that's what I used to do on my bowden extru... | <ul>
<li><p>Weld the fragment to the beginning of a new spool and use it that
way. <a href="http://www.i3dinno.com/easywelder-p186486.html" rel="noreferrer">Most are made from metal</a> so they aren't that easy to make
at home. Here is another <a href="https://3dprinting.stackexchange.com/questions/1345/how-to-connec... | 726 |
<p>I am writing an algorithm to find the dominating set of a tournament graph. Is the minimum spanning tree of a directed graph equivalent to the dominating set of the graph? In other words, if I find the smallest MST for the tournament graph (by iterating through all of the vertices), can I then say this is equivalent... | <p>This <a href="http://en.wikipedia.org/wiki/Dominating_set" rel="nofollow noreferrer">Wikipedia article</a> states that the problems of finding a dominating set and finding a spanning tree are equivalent. Given a spanning tree, the non-leaf nodes form a dominating set, and given a connected dominating set, you can ea... | <p>No, because the MST will include all vertices of the graph, and the dominating set might not.</p>
<p>See for example the graph here: <a href="http://en.wikipedia.org/wiki/Tournament_%28graph_theory%29" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Tournament<code>_</code>(graph<code>_</code>theory)</a>
Ver... | 37,901 |
<p>I'm looking for a way to obtain offsets of data members of a C++ class which is of non-POD nature.</p>
<p>Here's why: </p>
<p>I'd like to store data in <a href="http://www.hdfgroup.org/HDF5/whatishdf5.html" rel="noreferrer">HDF5</a> format, which seems most suited for my kind of material (numerical simulation outp... | <p>Greg Hewgill's solution is probably preferable to this (maybe with composition rather than inheritance).</p>
<p>However, I think that with GCC on x86 and x86_64, offsetof will actually work even for members of non-POD types, as long as it "makes sense". So for example it won't work for members inherited from virtua... | <p>This works fine for me, and I can't see why it wouldn't:</p>
<pre><code>#define myOffset(Class,Member) ({Class o; (size_t)&(o.Member) - (size_t)&o;})
</code></pre>
| 21,437 |
<p>So I am working on a project that uses a ASP.NET server and we have entities being passed over WCF from LINQ-to-Entity queries. I have already overcome the cyclic reference issue with WCF. Now that I am looking toward the next step, the Flex UI, I am wondering what things people have already faced either with dealin... | <p>I would check out Fluorine FX. It is a very mature and stable AMF implementation for .NET and it does provide WCF integration. A colleague of mine has posted some information here:</p>
<p><a href="http://jimdonaghy.com/?p=11" rel="nofollow noreferrer">http://jimdonaghy.com/?p=11</a></p>
| <p>You have several options for communicating between Flex application and your WCF service. Flex supports both SOAP web services and REST-like web services so you can choose which approach fits you best. When you receive data on the client, you will need to extract the entities from the response and build the UI accor... | 16,667 |
<p>I have simple regex</p>
<pre><code>"\".*\""
</code></pre>
<p>for me its says select everything between " and ", but it also catches</p>
<pre><code>"text") != -1 || file.indexOf(".exe"
</code></pre>
<p>for me its two strings, for regex its one. how can i make regex to see that its two strings?</p>
<p>P.S. I'm us... | <p>That's the non-greedy form:</p>
<pre><code>".*?"
</code></pre>
<p>The <code>*?</code> means: "Match as little as possible", while the <code>*</code> alone means "Match as much as possible". </p>
<p>The latter basically goes on until the end of the string, giving characters back one by one so the final <code>"</co... | <p>Look into <a href="http://en.wikipedia.org/wiki/Regex#Lazy_quantification" rel="nofollow noreferrer">Lazy Quantification</a></p>
| 49,062 |
<p>I don't care what the differences are. I just want to know whether the contents are different.</p>
| <p>The low level way:</p>
<pre><code>from __future__ import with_statement
with open(filename1) as f1:
with open(filename2) as f2:
if f1.read() == f2.read():
...
</code></pre>
<p>The high level way:</p>
<pre><code>import filecmp
if filecmp.cmp(filename1, filename2, shallow=False):
...
</code></p... | <h1>Simple and efficient solution:</h1>
<pre class="lang-py prettyprint-override"><code>import os
def is_file_content_equal(
file_path_1: str, file_path_2: str, buffer_size: int = 1024 * 8
) -> bool:
"""Checks if two files content is equal
Arguments:
file_path_1 (str): Path to th... | 31,728 |
<p>I have written a web app in PHP which makes use of Ajax requests (made using YUI.util.Connect.asyncRequest).</p>
<p>Most of the time, this works fine. The request is sent with an <strong>X-Requested-With</strong> value of <strong>XMLHttpRequest</strong>. My PHP controller code uses apache_request_headers() to che... | <p>I'm not sure why the apache_request_headers() and firebug mismatching, but in order to read request headers you can use the $_SERVER super global</p>
<p>each header that is being sent by a client (and it doesn't matter how is the client) will arrive to the $<em>SERVER array.
The key of that header will be with HTTP... | <p>Double-check that the missing header is not in the superglobal <code>$_SERVER</code>. In general, I wouldn't rely on apache_* if I really had to.</p>
<p>On a side-note, is X-Requested-With the standard yet? I've read about various libraries adding it, but I didn't know that it became the standard yet.</p>
| 31,091 |
<p>I'm current developing a WebService in a Bea Websphere 6.1 environment with Axis 2 implementation, I'm trying to respect the current standards for Web Services (JAXB, JAXWS, StAX...).</p>
<p>How long can be an XML message on this platform? </p>
<p>I've searched around but I haven't found anything related to this t... | <p>Don't know much about the limitations on you're platform, but in general, there are no hard limitations. Using Axis with the standard SOAP stack will take the SOAP envelope and create an in memory representation of it (dom or dom like), making you're heap size a limitation.
In case of using very large XMLs, a better... | <p>Yes, due to way Jax-ws & SOAP work, the whole payload gets bound: either to a Tree (higher memory usage) or to POJOs/beans (bit lower memory usage). Either way, memory usage will be proportional to message size.</p>
<p>Although theoretically it might be possible to create streaming/chunked interface for Soap pr... | 29,602 |
<p>I am now in the process of planning the deployment of a SharePoint solution into a production environment.<br>
I have read about some tools that promise an easy way to automate this process, but nothing that seems to fit my scenario.</p>
<p>In the testing phase I have used SharePoint Designer to copy site content b... | <p>I would also suggest checking out the SharePoint Content Deployment Wizard by Chris O'Brien.
<a href="http://www.codeplex.com/SPDeploymentWizard" rel="nofollow noreferrer">http://www.codeplex.com/SPDeploymentWizard</a> </p>
<p>Should help smooth the process you describe, and it's a nice tool for your kitbag regardl... | <p>We have a BizTalk 2006 with Web Application and Several WebServices that need to go from Dev to UAT to Live.</p>
<p>We use MSBuild right from within VS to build, run tests, dependent on test result, complie, zip and ship to servers.</p>
<p>Small MSBuild script on server to unzip, move the files, install clean web ... | 3,093 |
<p>I'm new at 3D Printing. I made a model of what I want to print using blender, but it's really small with a little system that must be very precise to work.</p>
<p>What I have is like a hollow cylinder with a diameter of 11mm, and a thickness of 1mm. This goes inside a counter part, that is carve with the cylinder s... | <p>It is definitively possible to do what you want, but your questions are samewhat problematic:</p>
<blockquote>
<p>So, I need to know if it's possible to print that cylinder hard enough to work as an axis.</p>
</blockquote>
<p>"hard enough" is a mysterious quantity. What is the intended application? The load of ... | <p>It is considered good practice to limit your post to one question at a time. The question about hardware and material is too broad to be a good question and I will set that aside.</p>
<p>Equally unfortunate, your drawing is ambiguous. I suppose if English is not your native language, I'm not helping things either.<... | 854 |
<p>I'm looking for a free winforms component for an application I'm writing. I basicly need a textbox that contains line numbers in a side column. Being able to tabulate data within it would be a major plus too.</p>
<p>Does anyone know of a premade component that could do this?</p>
| <p>Referencing <a href="https://stackoverflow.com/questions/124975/windows-forms-textbox-that-has-line-numbers#125093">Wayne's post</a>, here is the relevant code. It is using GDI to draw line numbers next to the text box.</p>
<pre><code>Public Sub New()
MyBase.New()
'This call is required by the Windows Form... | <p>I guess it depends on the Font size, I used "Courier New, 9pt, style=bold"</p>
<ul>
<li>Added fix for smooth scrolling, (not line by line) </li>
<li>Added fix for big files, when scroll value is over 16bit.</li>
</ul>
<p><strong>NumberedTextBox.cs</strong></p>
<pre><code>public partial class NumberedTextBox : Use... | 15,195 |
<p>I have an idea for how to solve this problem, but I wanted to know if there's something easier and more extensible to my problem.</p>
<p>The program I'm working on has two basic forms of data: images, and the information associated with those images. The information associated with the images has been previously s... | <p><a href="http://www.sqlite.org/" rel="nofollow noreferrer">Sqlite</a> is what you want. It's a fast, embeddable, single-file database that has bindings to most languages.</p>
<p>With regards to extensibility, you can store your models with default attributes, and then have a separate table for attribute extensions... | <p>So go with sqllite for the following reasons:<br>
1. You don't need to read/write the entire database from disk every time<br>
2. Much easier to add to even if you don't leave enough placeholders at the beginning<br>
3. Easier to search based on anything you want<br>
4. easier to change data in ways beyond the a... | 17,181 |
<p>If you were to write an GUI application that runs locally and calls a webservice, to be cross platform, can you do it with .Net, what tools would you recommend?</p>
<p>I was considering Java as it would be relatively easy to pick up due to its C# similarity and then I could use the JVM.</p>
| <p>You should get familiar with the <a href="http://www.mono-project.com/Main_Page" rel="noreferrer">Mono project</a> and <a href="http://www.monodevelop.com/Main_Page" rel="noreferrer">MonoDevelop</a>; the express purpose of those projects is to allow building and running .NET code on a variety of platforms, including... | <p>Honestly I would evaluate your customer base and your existing skills. If you've got a 50/50 split, or even a 70/30 split of Windows to non-Windows, you'd likely be better off with Java or some other cross-platform toolkit. </p>
<p>Mono is a decent platform (See <a href="https://stackoverflow.com/questions/42627/be... | 7,988 |
<p>I have a calendar control derived from DataGridView. A custom item hover event is already in place. When handling the event, I have the item that was hovered and the mouse location. What is the best method to show a pop-up window with detailed information about the item? Should I use a stripped down form (no titleba... | <p>Any type of Control, a Panel, a UserControl, etc. These will do as long as they doesn't have to pop outside the current form. If it needs to pop outside you might need to use a Form as you stated and removes it's border.</p>
<p>Pre create the Control or Form in the main form, then when the mouse hover the needed co... | <p>I use thickbox (jQuery plugin) for popup windows like this. It allows you to use various methods to display data (ajax, iFrame), you can also setup callbacks from the popup in case you need to capture data. If you want to see how I've used it recently you can click on any of the demo links on this page:</p>
<p><a... | 41,239 |
<p>For ASP.Net application deployment what type of information (if any) are you storing in the machine.config? </p>
<p>If you're not using it, how are you managing environment specific configuration settings that may change for each environment?</p>
<p>I'm looking for some "best practices" and the benefits/pitfalls o... | <p>We are considering using machine.config to add one key for the environment, and then have one section in the web.config which is excactly the same for all environments. This way we can do a "real" XCopy deployment.</p>
<p>E.g. in the machine.config for every computer (local dev workstations, stage servers, build se... | <p>I use machine.config for not just ASP.NET, but for overall config as well. I implemented a hash algorithm (Tiger) in C# and wanted it to be available via machine request. So, registered my assembly in the GAC and added the following to machine.config:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
&l... | 11,969 |
<p>If I have an IEnumerator variable is it possible to have a lambda function that takes it, advances it with MoveNext() and returns the Current value every single time its called?</p>
| <pre><code>e => e.MoveNext() ? e.Current : null
</code></pre>
<p>This will advance the enumerator and return the current value, and return null when the enumeration is complete.</p>
| <p>Is this what you are looking for?</p>
<pre><code>List<string> strings = new List<string>()
{
"Hello", "I", "am", "a", "list", "of", "strings."
};
IEnumerator<string> e = strings.GetEnumerator();
Func<string> f = () => e.MoveNext() ? e.Current : null;
for (; ; )
{
string str = f();... | 9,851 |
<p>I am working on a multi-purpose page and rather than adding multiple grids to the same page we wanted to use a single GridView to the page, and on Page_Init add the needed columns, and set the respective DataSourceID.</p>
<p>So to do this, we have something like the following in the aspx, the codebehind in the Page... | <ol>
<li>Make sure Windows 2000 has SP3, or encryption is far less likely to work, particularly if using Capicom (or the api it wraps).</li>
<li>Not all of the encryption algorithms and keylengths are supported on Windows 2000 if using Capicom (or the api it wraps).</li>
</ol>
| <p>There's an <a href="http://support.microsoft.com/kb/841715" rel="nofollow noreferrer">obscure issue</a> with win2000/winxp encryption/decryption. The Cryptography Service Provider on win2000 has 40 for the effective key length and that's used by default even if you use a 128 bit key. So to fix that you have to manua... | 40,684 |
<p>How can I take the string <code>foo[]=1&foo[]=5&foo[]=2</code> and return a collection with the values <code>1,5,2</code> in that order. I am looking for an answer using regex in C#. Thanks</p>
| <p>In C# you can use capturing groups</p>
<pre><code> private void RegexTest()
{
String input = "foo[]=1&foo[]=5&foo[]=2";
String pattern = @"foo\[\]=(\d+)";
Regex regex = new Regex(pattern);
foreach (Match match in regex.Matches(input))
{
Console.Ou... | <p>Assuming you're dealing with numbers this pattern should match:</p>
<pre><code>/=(\d+)&?/
</code></pre>
| 11,961 |
<p>I'm having an extremely weird problem with a PHP script of mine.</p>
<p>I'm uploading a couple of files and having PHP put them all in one folder.
I've have trouble with random files being sent and random ones not being sent. So I debugged it and I got a very weird result from the $_FILES[] array.</p>
<p>I tried i... | <p>Relevent, but probably not going to help: but move_uploaded_file is a (slightly) better way to handle uploaded files than copy.</p>
<p>Are any of the files large? PHP has limits on the filesize and the time it can take to upload them ...</p>
<p>Better to send you here than attempt to write up what it says:</p>
<p... | <p>Your loop logic is incorrect. You are using a foreach loop on the file input name directly, which stores several properties that are of no interest to you ('type','size', etc).</p>
<p>You should get the file count from the first file and use it as the loop length:</p>
<pre><code>if (!empty($_FILES['addFile']) &... | 46,819 |
<p>Is it possible to mix all these access controls in one site?</p>
<p>I have a requirement saying </p>
<ul>
<li>a) Users from the AD must be allowed
access, using integrated security </li>
<li>b) Users from some other AD must be
allowed access; potentially by
logging in </li>
<li>c) Users not in the AD's
should be ... | <p>I did something like this on a project a while ago, and it worked like this:</p>
<p>I set the application to use Forms Authentication, with anonymous access enabled in IIS.</p>
<p>I created a standard Forms Authentication login page that accepted a user ID and password to do non-integrated logins.</p>
<p>I also m... | <p>I think that there is an <a href="http://www.mail-archive.com/advanced-dotnet@discuss.develop.com/msg12098.html" rel="nofollow noreferrer">answer from the man himself</a>. Basically you should use the usual asp.net membership provider model. But create your own custom provider that wrap the active directory and th... | 47,091 |
<p>I want to profile (keep an Eye on) all the activities that goes on in a Database which is in PostgreSQL.</p>
<p>Is there any such utility which will help me do this?</p>
| <p>"Keep an eye on" and "profile" are two quite different tasks in my view.</p>
<p>For profiling (not a live view on what's going on right now, but to see which queries take most time etc), check out pgFouine:</p>
<p><a href="http://pgfouine.projects.postgresql.org/" rel="noreferrer">http://pgfouine.projects.postgres... | <p>Have a look at <a href="http://pgfoundry.org/projects/nagiosplugins/" rel="nofollow noreferrer">Nagios-Plugin script</a> or <a href="http://bucardo.org/nagios/" rel="nofollow noreferrer">check_postgres.pl</a></p>
| 47,666 |
<p>The Open/Closed Principle states that software entities (classes, modules, etc.) should be open for extension, but closed for modification. What does this mean, and why is it an important principle of good object-oriented design?</p>
| <p>It means that you should put new code in new classes/modules. Existing code should be modified only for bug fixing. New classes can reuse existing code via inheritance.</p>
<p>Open/closed principle is intended to mitigate risk when introducing new functionality. Since you don't modify existing code you can be assure... | <p>This means that the OO software should be built upon, but not changed intrinsically. This is good because it ensures reliable, predictable performance from the base classes. </p>
| 8,348 |
<p>I'm looking for real world best practices, how other people might have implemented solutions with complex domains.</p>
| <p>Any time you consider using an <code>IEqualityComparer<T></code>, pause to think if the class could be made to implement <code>IEquatable<T></code> instead. If a <code>Product</code> should always be compared by ID, just define it to be equated as such so you can use the default comparer.</p>
<p>That sa... | <p>I would say that the best use would be when you need to plug in different equality rules for a certain algorithm. Much in the same way that a sorting algorithm might accept an <code>IComparer<T></code>, a finding algorithm might accept an <code>IEqualityComparer<T></code></p>
| 9,975 |
<p>Unfortunately and regrettably.</p>
<p>Whilst trying to install and fit an SKR Turbo 1.4 Turbo Motherboard into 3D printer body, I managed to break the SKR 1.4 Turbo Motherboard SD-card reader. The card reader is not flush and protrudes from the board. It peeled the reader from the PCB.</p>
<p>I attempted to fix it w... | <p>"Completely" is always relative, but for water at the pressures involved it's probably achievable. Normally you need some sort of <em>gasket</em> (material that can bend/compress to slight imperfections in the mating surfaces), and a means of holding the two surfaces tight against the gasket, to get such a... | <p>I know this sounds obvious, but given the box has holes in the top – does it only need to be watertight when it's the right way up? If not, you could just do something like:</p>
<p><a href="https://i.stack.imgur.com/JXft9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JXft9.jpg" alt="enter image... | 1,766 |
<p>Please, now that I've re-written the question, and before it suffers from further <a href="https://stackoverflow.com/questions/56103/fastest-gun-in-the-west-problem">fast-gun answers</a> or premature closure by <a href="https://stackoverflow.com/users/905/keith">eager editors</a> let me point out that this is not a ... | <p>Here's C# app i wrote that solves this problem.</p>
<p><strong>takes</strong><br>
aabccacdcd </p>
<p><strong>outputs</strong><br>
abcacd </p>
<p>Probably looks pretty messy, took me a bit to get my head around the dynamic pattern length bit.</p>
<pre><code>class Program
{
private static List<string> ... | <p>I agree that if you can just dump the strings into a Set, then that might be the easiest solution. </p>
<p>If you don't have access to a Set implementation for some reason, I would just sort the strings alphabetically and then go through once and remove the duplicates. How to sort them and remove duplicates from th... | 8,121 |
<p>Imagine you want to animate some object on a WinForm. You setup a timer to update the state or model, and override the paint event of the Form. But from there, what's the best way to continually repaint the Form for the animation?</p>
<ul>
<li>Invalidate the Form as soon as you are done drawing?</li>
<li>Setup a se... | <p>I've created a library that might help with this. It's called Transitions, and can be found here: <a href="https://github.com/UweKeim/dot-net-transitions" rel="nofollow noreferrer">https://github.com/UweKeim/dot-net-transitions</a>. Available on nuget as the <a href="https://www.nuget.org/packages/dot-net-transitio... | <p>What you're doing is the only solution I've ever used in WinForms (a timer with constant redrawings). There are a bunch of techniques that you can use to make the user's experience with it smoother (such as double-buffering).</p>
<p>You might want to give WPF a try. There are built-in facilities for doing animation... | 3,247 |
<p>I have two branches, the main branch(black) and a feature branch(yellow).</p>
<p>As you can see, since the feature branch was forked, it was kept up to date fetching changes from main:</p>
<p><a href="http://azkotoki.org/images/stackoverflow/tgh-reintegrate1.gif" rel="nofollow noreferrer">alt text http://azkotoki.... | <p>The graph looks like this since the revisions are ordered by their revision numbers. The main repository has the revisions ordered and numbered like this:</p>
<pre><code>0 Imported initial repo.
1 Trivial change to also echo b.
2 Added another echo for c.
3 Echo for d.
4 Echo for e.
</code></pre>
<p>This reflects ... | <p>When you take a closer look you will see that the both graphs are (almost) identical, but the presentation is different. That, which looks like 3 different branches, is actually one branch, but presented slightly different.</p>
<p>I wrote "almost" because revision numbers have been reordered. And this is really str... | 39,273 |
<p>I've been trying to retrieve the locations of all the page breaks on a given Excel 2003 worksheet over COM. Here's an example of the kind of thing I'm trying to do:</p>
<pre><code>Excel::HPageBreaksPtr pHPageBreaks = pSheet->GetHPageBreaks();
long count = pHPageBreaks->Count;
for (long i=0; i < count; ++i... | <p>Experimenting with Excel 2007 from Visual Basic, I discovered that the page break isn't known unless it has been displayed on the screen at least once.</p>
<p>The best workaround I could find was to page down, from the top of the sheet to the last row containing data. Then you can enumerate all the page breaks.</p>... | <p>Did you set ScreenUpdating to True, as mentioned in the KB article?</p>
<p>You may want to actually toggle it to True to force a screen repaint. It sounds like the calculation of page breaks is a side-effect of actually rendering the page, rather than something Excel does on demand, so you have to trigger a page re... | 10,349 |
<p>I got one big question.</p>
<p>I got a linq query to put it simply looks like this:</p>
<pre><code>from xx in table
where xx.uid.ToString().Contains(string[])
select xx
</code></pre>
<p>The values of the <code>string[]</code> array would be numbers like (1,45,20,10,etc...)</p>
<p>the Default for <code>.Contains<... | <p>spoulson has it nearly right, but you need to create a <code>List<string></code> from <code>string[]</code> first. Actually a <code>List<int></code> would be better if uid is also <code>int</code>. <code>List<T></code> supports <code>Contains()</code>. Doing <code>uid.ToString().Contains(string... | <pre><code>string[] stringArray = {1,45,20,10};
from xx in table
where stringArray.Contains(xx.uid.ToString())
select xx
</code></pre>
| 23,685 |
<p>I have a char array in a C application that I have to split into parts of 250 so that I can send it along to another application that doesn't accept more at one time. </p>
<p>How would I do that? Platform: win32. </p>
| <p>From the MSDN documentation:</p>
<blockquote>
<p>The strncpy function copies the initial count characters of strSource to strDest and returns strDest. If count is less than or equal to the length of strSource, a null character is not appended automatically to the copied string. If count is greater than the length... | <p>jvasaks's answer is basically correct, except that he hasn't null terminated 'block'. The code should be this:</p>
<pre><code>void send250(char *inMsg, int msgLen)
{
char block[250];
while (msgLen > 0)
{
int len = (msgLen>249) ? 249 : msgLen;
strncpy(block, inMsg, 249);
... | 19,687 |
<p>The issue is there is a database with around 20k customer records and I want to make a best effort to avoid duplicate entries. The database is Microsoft SQL Server 2005, the application that maintains that database is Microsoft Dynamics/SL. I am creating an ASP.NET webservice that interacts with that database. My... | <p>The specifics of which <a href="http://www.cs.sunysb.edu/~algorith/files/approximate-pattern-matching.shtml" rel="nofollow noreferrer">algorithm</a> will work best for you depends greatly on your domain, so I'd suggest experimenting with a few different ones - you may even need to combine a few to get optimal result... | <p>You could try using Full Text Search with FreeText (or FreeTextTable) functions to try to find possible matches.</p>
| 27,509 |
<p>Consider the following two ways of writing a loop in Java to see if a list contains a given value:</p>
<h3>Style 1</h3>
<pre><code>boolean found = false;
for(int i = 0; i < list.length && !found; i++)
{
if(list[i] == testVal)
found = true;
}
</code></pre>
<h3>Style 2</h3>
<pre><code>boolean fo... | <p>Well, just write a micro benchmark:</p>
<pre>
import java.util.*;
public class Test {
private static int[] list = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9} ;
private static int testVal = 6;
public static boolean version1() {
boolean found = false;
for(int i = 0; i < list.length && !fou... | <p>I would say that in 98% of systems, it does not matter. The difference, if there is any, is hardly noticeable unless that loop is the main portion of code and is running a mindnumbing number of times.</p>
<p>Edit: That is ofcourse assuming that it is not being already optimized by the compiler.</p>
| 22,322 |
<p>I'm new to cryptography and modular arithmetic. So, I'm sure it's a silly question, but I can't help it. </p>
<p>How do I calculate <em>a</em> from <br>
pow(<em>a</em>,<strong>q</strong>) = 1 (mod <strong>p</strong>), <br>
where <strong>p</strong> and <strong>q</strong> are known? I don't g... | <p>The (mod p) part refers not to the right hand side, but to the equality sign: it says that <em>modulo p, pow(a,q) and 1 are equal</em>. For instance, "modulo 10, 246126 and 7868726 are equal" (and they are also both equal to 6 modulo 10): <strong>two numbers x and y are equal modulo p if they have the same remainder... | <p>Not silly at all, as <strong>this is the basis for public-key encryption.</strong> You can find an excellent discussion on this at <a href="http://home.scarlet.be/~ping1339/congr.htm#The-equation-a%3Csup%3Ex." rel="noreferrer">http://home.scarlet.be/~ping1339/congr.htm#The-equation-a%3Csup%3Ex.</a></p>
<p>PKI works... | 35,354 |
<p>I am a rookie was using the Visual Studio 2008 built-in Unit Testing components, what would be the best way to record or display your results in a unit test?</p>
<p>I want to test my service method when it returns a System.GUID and an empty System.GUID</p>
<pre><code>[TestMethod]
public void GetGUID()
{
MyWcfSe... | <p>For GetGUID()...</p>
<pre><code>Assert.IsFalse(guid == Guid.Empty);
</code></pre>
<p>Similarly for GetEmptyGUID()...</p>
<pre><code>Assert.IsTrue(guid == Guid.Empty);
</code></pre>
| <p>I used this for a few months last year, IIRC isn't there an <code>Assert</code> class? <code>Assert.IsTrue(...)</code>?</p>
<p>I've dropped VS test stuff in favor of other unit test frameworks (better IMO) so my memory is likely clouded.</p>
| 31,384 |
<p>I'm using C# in .Net 2.0, and I want to read in a PNG image file and check for the first row and first column that has non-transparent pixels. </p>
<p>What assembly and/or class should I use?</p>
| <p><a href="http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx" rel="noreferrer">Bitmap</a> class from System.Drawing.dll assembly:</p>
<pre><code>Bitmap bitmap = new Bitmap(@"C:\image.png");
Color clr = bitmap.GetPixel(0, 0);
</code></pre>
| <p>Of course I googled already and found the PngBitmapDecoder class, but it doesn't seem to be available in .Net 2.0? </p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.pngbitmapdecoder.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.media.imagi... | 12,552 |
<p>What I would like to do is have VS2008, when I open a code file, collapse all members of the classes/interfaces in the file by default (including, crucially, any XML documentation and comments).</p>
<p>I do <em>not</em> want to use regions, at all.</p>
<p>I would also like to be able to use the ctrl+m, ctrl+l chor... | <p>Yes to part 1.</p>
<p>Unsure about part 2.</p>
<p>To have VS2008 automatically open files in a Collapsed state you'll need to create an addin to run the "Edit.CollapsetoDefinition" when each document opens.</p>
<p>This isn't overly tricky - The difficult parts seems to be the that you have to run the code a few m... | <p>It would be much easier to use the Visual Studio Macros to do the same thing. Editing the "EnvironmentEvents" Macro file in MyMacros and adding a handler for DocumentEvents.DocumentOpened with :<br>
DTE.ExecuteCommand("Edit.CollapsetoDefinitions")</p>
| 37,505 |
<p>We use <a href="http://trac.edgewall.org" rel="nofollow noreferrer">Trac</a> as our bug tracking / development / wiki system and I was wondering if anyone has experience and uses some of the Trac Agile/Scrum plugins or functionalities? Anything you'd recommend?</p>
<p>Or would it be better to duplicate Trac tickets... | <p>With a collocated team, I'd always duplicate user stories on index cards. A wall of cards is much more collaborative and simple to use than any software tool. And what's most important, <em>it's in your face</em>.</p>
<p>The same is true for a burn chart. In my experience, a software chart gets online looked at by ... | <p>We recently started using Scrumban. </p>
<p>Basically a Kanban board, with the daily stand-up meetings covering the classic Agile Scrum questions - what did you work on the previous day? what do you plan to work on today? do you have any blockers?</p>
<p>We do this around a physical Kanban board, it is great for ... | 30,198 |
<p>Is there a way to test if an object is a dictionary?</p>
<p>In a method I'm trying to get a value from a selected item in a list box. In some circumstances, the list box might be bound to a dictionary, but this isn't known at compile time.</p>
<p>I would like to do something similar to this:</p>
<pre><code>if (l... | <p>Check to see if it implements IDictionary.</p>
<p>See the definition of System.Collections.IDictionary to see what that gives you.</p>
<pre><code>if (listBox.ItemsSource is IDictionary)
{
DictionaryEntry pair = (DictionaryEntry)listBox.SelectedItem;
object value = pair.Value;
}
</code></pre>
<p><strong>ED... | <p>You could be a little more generic and ask instead if it implements <code>IDictionary</code>. Then the KeyValue collection will contina plain <code>Objects</code>.</p>
| 14,990 |
<p>I have currently an installed pgsql instance that is running on port <code>1486</code>. I want to change this port to <code>5433</code>, how should I proceed for this?</p>
| <p>There should be a line in your <code>postgresql.conf</code> file that says:</p>
<pre><code>port = 1486
</code></pre>
<p>Change that.</p>
<p>The location of the file can vary depending on your install options. On Debian-based distros it is <code>/etc/postgresql/8.3/main/</code></p>
<p>On Windows it is <code>C:\Pr... | <p>You can also change the port when starting up:</p>
<pre><code>$ pg_ctl -o "-F -p 5433" start
</code></pre>
<p>Or</p>
<pre><code>$ postgres -p 5433
</code></pre>
<p>More about this in the <a href="http://www.postgresql.org/docs/8.4/interactive/reference-server.html" rel="noreferrer">manual</a>.</p>
| 22,696 |
<p>Does anybody have any pointers on how to successfully draw a bitmap that has
an alpha channel using Graphics::DrawImage() when the Graphics context is
created based on a printer HDC? The printer drivers don't generally support alpha blending - so is there an alternative to rendering everything to an offscreen bitmap... | <p>What kind of printer is that? Regular printers don't print white. Create in-memory image and 'flatten' it (remove alpha channel) and then print the result.</p>
| <p>Have you tried drawing a white rectangle to initialize the image before you call the DrawImage method?</p>
| 8,817 |
<p>In new C++ code, I tend to use the C++ iostream library instead of the C stdio library.</p>
<p>I've noticed some programmers seem to stick to stdio, insisting that it's more portable.</p>
<p>Is this really the case? What is better to use?</p>
| <p>To answer the original question:<br>
Anything that can be done using stdio can be done using the iostream library.<br></p>
<pre><code>Disadvantages of iostreams: verbose
Advantages of iostreams: easy to extend for new non POD types.
</code></pre>
<p>The step forward the C++ made over C was type safety.</p>
<ul... | <p>stdio is better for reading binary files (like freading blocks into a vector<unsigned char> and using .resize() etc.). See the read_rest function in file.hh in <a href="http://nuwen.net/libnuwen.html" rel="nofollow noreferrer">http://nuwen.net/libnuwen.html</a> for an example.</p>
<p>C++ streams can choke on ... | 14,485 |
<p>Consider a normal customer-orders application based on MVC pattern using WinForms.
The view part has grown too much (over 4000 files) and it needs to be split into smaller ones.</p>
<hr>
<p>For this example we are going to use 3 projects for the view part:</p>
<ul>
<li><strong>Main</strong> - has dependencies to ... | <p>Change at least one of the types to an interface.</p>
<p>For example have a ICustomer interface and a Customer type that implements this interface. Now add the ICustomer to the orders project and from the customers project set a reference to the Orders project so you can implement the interface. The Order type can ... | <p>Extract interfaces and put them in separate assembly. Since you're using MVC architecture, it shouldn't be hard. Take a look at Microsoft Composite UI Applications block for examples and good practices.</p>
| 14,701 |
<p>coming back to postgresql after several years of oracle ... </p>
<p>what are the state-of-the art postgresql administrative/ddl generating/data inserting frontends on windows? it would be nice if it had integration for postgis as well. it should be standalone or alternatively a plugin for intellij idea</p>
<p>thin... | <p>I like <a href="http://www.sqlmaestro.com/products/postgresql/maestro/" rel="noreferrer">Postgresql Maestro</a>. I also use their version for MySql. I'm pretty statisfied with their product. Or you can use the free tool PgAdmin.</p>
| <p>SQLExplorer is a great Eclipse plugin or standalone interface that works with many different database systems, either with dedicated drivers or with ODBC.</p>
| 13,133 |
<p>What am I doing wrong here?</p>
<pre><code>string q = "john s!";
string clean = Regex.Replace(q, @"([^a-zA-Z0-9]|^\s)", string.Empty);
// clean == "johns". I want "john s";
</code></pre>
| <p>just a FYI</p>
<pre><code>string clean = Regex.Replace(q, @"[^a-zA-Z0-9\s]", string.Empty);
</code></pre>
<p>would actually be better like</p>
<pre><code>string clean = Regex.Replace(q, @"[^\w\s]", string.Empty);
</code></pre>
| <p>The circumflex inside the square brackets means all characters except the subsequent range. You want a circumflex outside of square brackets.</p>
| 21,890 |
<p>I'm interested to know what are the "must have" JSP tag libraries apart from JSTL. All I've found so far are</p>
<ul>
<li><a href="http://www.javaranch.com/journal/200601/Journal200601.jsp#a3" rel="nofollow noreferrer">ccc</a> - for accessing static constants in JSP (without scriptlet)</li>
<li><a href="http://disp... | <p>I use displaytag, and have been quite happy with it. The only other tag library I use is the one that comes with the Stripes Action Framework.</p>
<p>But my truly indispensable Tag library is the one we wrote.</p>
<p>At the office we must have over 50 of them by now for our internal framework.</p>
<p>The key behi... | <p>The <a href="http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/c/tld-summary.html" rel="nofollow noreferrer">Core JSTL library</a>, obviously.</p>
| 31,883 |
<p>I have a long-running GUI application that outputs various statuses to the user. The user wants to view every status but doesn't want to worry about the screensaver kicking in after the inactivity settings.</p>
<p>Preferably in C#, how do I read the screensaver/power scheme settings (so I can reapply them when my ... | <p>The screensaver timeout values are in the registry:</p>
<p><a href="http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1027.mspx" rel="nofollow noreferrer">How can I change the screensaver timeout values</a> (sample code in there should be easy enough to convert to C#)</p>
<p>Not sure about the... | <p>The screensaver timeout values are in the registry:</p>
<p><a href="http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1027.mspx" rel="nofollow noreferrer">How can I change the screensaver timeout values</a> (sample code in there should be easy enough to convert to C#)</p>
<p>Not sure about the... | 45,710 |
<p>How do I multiply the values of a multi-dimensional array with weights and sum up the results into a new array in PHP or in general?</p>
<p>The boring way looks like this:</p>
<pre><code>$weights = array(0.25, 0.4, 0.2, 0.15);
$values = array
(
array(5,10,15),
array(20,25,30... | <p>Depends on what you mean by elegant, of course.</p>
<pre><code>function weigh(&$vals, $key, $weights) {
$sum = 0;
foreach($vals as $v)
$sum += $v*$weights[$key];
$vals = $sum;
}
$result = $values;
array_walk($result, "weigh", $weights);
</code></pre>
<p>EDIT: Sorry for not reading your exa... | <p>Hm...</p>
<pre><code>foreach($values as $index => $ary )
$result[$index] = array_sum($ary) * $weights[$index];
</code></pre>
| 28,826 |
<p>I develop a number of desktop Java applications using Swing, and while Swing is quite powerful (once you get the hang of it), there are still a lot of cases where I wish some advanced component was available right out of the box.</p>
<p>For example, I'd really like to see easy-to-use components (without writing the... | <p>The following are worth a look:</p>
<ul>
<li><a href="https://swingx.dev.java.net/" rel="noreferrer">swingX</a></li>
<li><a href="http://publicobject.com/glazedlists/" rel="noreferrer">Glazed lists</a></li>
<li><a href="https://substance.dev.java.net/" rel="noreferrer">Substance look'n'feel</a></li>
<li><a href="ht... | <p>I know you can get an awesome wrapping labe and an accordion from <a href="http://www.javaswingcomponents.com/products" rel="nofollow noreferrer">javaswingcomponents</a>, however they are not open source implementations. </p>
<p>Otherwise Jide and SwingX are great choices.</p>
| 26,228 |
<p>I have the following Java 6 code:</p>
<pre><code> Query q = em.createNativeQuery(
"select T.* " +
"from Trip T join Itinerary I on (T.itinerary_id=I.id) " +
"where I.launchDate between :start and :end " +
"or ADDDATE(I.launchDate, I.equipmentPullDayOfTrip) between :start and :end... | <p>The Hibernate annotations docs (<a href="http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/" rel="nofollow noreferrer">http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/</a>) suggest that this should be a class-level annotation rather than occurring inline within your code. ... | <p>Your example comes straight out of the API docs which are unfortunately poorly presented.</p>
<p>Your annotation should be placed on some class, probably the one in which you will be creating the query to use the result set mapping. However, it actually doesn't matter where this annotation is placed. Your JPA provi... | 9,205 |
<p>I have a situation where I need to be able to load assemblies in the GAC based on their partial names. In order to do this I have added the following to my app.config file:</p>
<pre><code><runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="MyAssem... | <p>I've created a class to work around this problem:</p>
<pre><code>public class RestrictDesiredSize : Decorator
{
Size lastArrangeSize = new Size(double.PositiveInfinity, double.PositiveInfinity);
protected override Size MeasureOverride(Size constraint)
{
Debug.WriteLine("Measure: " + constraint)... | <p>While I wouldn't recommend creating a UI that requires outer scroll bars you can accomplish this pretty easily:</p>
<pre><code><Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<ScrollViewer HorizontalScrollBarV... | 24,208 |
<p>I'm following the <a href="http://www.asp.net/learn/mvc-videos/video-395.aspx" rel="nofollow noreferrer">ASP.Net MVC "TaskList" example video</a> and on clicking Run in Visual Studio (~14:00 min into the video) I'm getting the following error message in the browser:</p>
<pre><code>Server Error in '/' Application.
... | <p><em>D'oh!</em></p>
<p>Found the problem, it's in the <code>HomeController.vb</code>:</p>
<pre><code>Public Class HomeController
Inherits System.Web.Mvc.Controller
' Display a list of tasks
Function Index()
Return View()
End Function
' Dislpay a form for creating a new task
Functio... | <p>It seems to have something to do with your anonymous type on Line 17. Make sure you code looks like</p>
<pre><code>routes.MapRoute( _
"Default", _
"{controller}/{action}/{id}", _
New With { .controller = "Home", .action = "Index" }
)
</code></pre>
<p>If you need any further help please post your route... | 26,514 |
<p>I am currently adding a fillet to the base of an object (the plane that's touching the bed) and I was curious if the radius of the filet contributed to any mis-prints. I've had luck so far but was wondering if the intensity of the radius had mattered.</p>
<p>I am using the Ender3 Pro.</p>
<hr />
<p><em>I may do some... | <p>You can print a fillet without support as support material causes other issues like problems with removing supports and ugly scarring on you print. However, a fillet will cause an overhang when you slice the object</p>
<p><a href="https://i.stack.imgur.com/mXpkz.png" rel="nofollow noreferrer"><img src="https://i.sta... | <blockquote>
<p>wondering if the intensity of the radius had mattered.</p>
</blockquote>
<p>Yes it does if it's an overhang.</p>
| 2,160 |
<p>Curious, how many of you develop under a VMware environment?</p>
<p>Is it popular for employers to setup vmware for everyone?</p>
<p>Seems like a great way to rollout new desktop computers and perform backups etc.</p>
<p>Just worried about the performance though (PC vmwares).</p>
<p><b>Update</b></p>
<p>I was j... | <p>VMware Workstation 6.5 runs like a champ on my older Athlon X2. I use Visual Studio on my host machine and have many VMs installed with various OS, framework and browser combinations. VMware Workstation adds VM debugging into Visual Studio as well, so I can just hit F6 to start my app in any one of my VMs and debug ... | <p>VMWare as a windows development environment runs terrible on my dual core with 2GB ram (XP guest, XP host). Even with nothing running on the host except for VMware, constant paging that takes about a minute to settle every time I switch applications. Heck, native VS2008 doesn't even run that great during intelli... | 29,816 |
<p>I'm an experienced client application developer (C++/C#), but need to come up to speed quickly on writing server side code to perform RESTful interactions. Specifically, I need to learn how to exchange data with OpenSocial containers via the RESTful API.</p>
| <p><a href="http://www.crummy.com/writing/RESTful-Web-Services/" rel="nofollow noreferrer">RESTful Web Services</a></p>
| <p>I found this <a href="http://www.xfront.com/REST-Web-Services.html" rel="nofollow noreferrer">this</a> to be a good introduction to RESTful web apps, although it doesn't refer to OpenSocial containers.</p>
| 11,134 |
<p>We all know to keep it simple, right?</p>
<p>I've seen complexity being measured as the number of interactions between systems, and I guess that's a very good place to start. Aside from gut feel though, what other (preferably more objective) methods can be used to determine the level of complexity of a particular d... | <p>Here are mine:</p>
<p>1) How hard is it to explain to someone who understands the problem but hasn't thought about the solution? If I explain the problem to someone in the hall (who probably already understands the problem if they're in the hall) and can explain the solution, then it's not too complicated. If it ... | <p>There are formal metrics. Read up on <a href="http://en.wikipedia.org/wiki/Cyclomatic_complexity" rel="nofollow noreferrer">Cyclomatic Complexity</a>, for example.</p>
<hr>
<p>Edit.</p>
<p>Also, look at <a href="http://www.functionpoints.com/" rel="nofollow noreferrer">Function Points</a>. They give you a non-g... | 31,643 |
<p>I have a function in Python which is iterating over the attributes returned from <code>dir(obj)</code>, and I want to check to see if any of the objects contained within is a function, method, built-in function, etc. Normally you could use <code>callable()</code> for this, but I don't want to include classes. The ... | <p>The inspect module has exactly what you want:</p>
<pre><code>inspect.isroutine( obj )
</code></pre>
<p>FYI, the code is:</p>
<pre><code>def isroutine(object):
"""Return true if the object is any kind of function or method."""
return (isbuiltin(object)
or isfunction(object)
or ismet... | <p>Depending on what you mean by 'class':</p>
<pre><code>callable( obj ) and not inspect.isclass( obj )
</code></pre>
<p>or:</p>
<pre><code>callable( obj ) and not isinstance( obj, types.ClassType )
</code></pre>
<p>For example, results are different for 'dict':</p>
<pre><code>>>> callable( dict ) and not... | 9,978 |
<p>I've recently searched how I could get the application's directory in Java. I've finally found the answer but I've needed surprisingly long because searching for such a generic term isn't easy. I think it would be a good idea to compile a list of how to achieve this in multiple languages.</p>
<p>Feel free to up/dow... | <p>In <strong>Java</strong> the calls</p>
<pre><code>System.getProperty("user.dir")
</code></pre>
<p>and</p>
<pre><code>new java.io.File(".").getAbsolutePath();
</code></pre>
<p>return the current working directory. </p>
<p>The call to </p>
<pre><code>getClass().getProtectionDomain().getCodeSource().getLocation()... | <p>Note to answer "20 above regarding Mac OSX only: If a JAR executable is transformed to an "app" via the OSX JAR BUNDLER, then the getClass().getProtectionDomain().getCodeSource().getLocation(); will NOT return the current directory of the app, but will add the internal directory structure of the app to the response.... | 26,823 |
<p>I'm searching for an easy to handle python native module to create python object representation from xml.</p>
<p>I found several modules via google (one of them is <a href="http://freenet.mcnabhosting.com/python/xmlobject/" rel="nofollow noreferrer">XMLObject</a>) but didn't want to try out all of them. </p>
<p>Wh... | <p>You say you want an <em>object</em> representation, which I would interpret to mean that nodes become objects, and the attributes and children of the node are represented as attributes of the object (possibly according to some Schema). This is what XMLObject does, I believe.</p>
<p>There are some packages that I k... | <p>I've had pretty good luck with Wai Yip Tung's xml2obj function available here:</p>
<p><a href="http://code.activestate.com/recipes/534109-xml-to-python-data-structure/" rel="nofollow">http://code.activestate.com/recipes/534109-xml-to-python-data-structure/</a></p>
<p>It's ~84 lines of code. It's native and pure py... | 39,452 |
<p>I just received this printer and while it seems to talk to Makerbot Desktop software I'm not sure if I should be trying to update the firmware.</p>
<p>The printer comes with firmware v7.2 and while Makerbot Desktop offers an upgrade to v7.5 I'm not sure if it's a good idea with this non-Makerbot branded printer.</p... | <p>The Monoprice Architect is is a bare-bones FlashForge Creator that has been re-badged for Monoprice. The Creator line is a very popular set of printers, so there is lots of good advice out there. The FlashForge Google Group is a good community to join: <a href="https://groups.google.com/forum/#!forum/flashforge" rel... | <p>Since the printer has no heater, I'd advise some sleuthing</p>
<ol>
<li>Look at the motherboard. Find the big black square chip and see if it is a ATmega 1280 or 2560. Likely it's a 1280, but you never know. This will impact which firmware build you use.</li>
<li>If you will eventually add a heater PCB, then fig... | 156 |
<p>I know <em>of</em> the US GIS TIGER file format from years ago, but have never used it.</p>
<p>I'm very shortly going to need to very quickly implement simple geocoding and vector graphics of roads and other features.</p>
<ul>
<li>Where do I go for information - are there tutorials, example queries, etc?</li>
</ul... | <p>As far as I'm aware of, there aren't many applications that make use of the TIGER/Line format directly. Most apps use TIGER files that have been translated into ESRI's shapefile format.</p>
<p>Edited to add:</p>
<blockquote>
<p>Is there information on ESRI's format available?</p>
</blockquote>
<p>There's an <a href... | <p>The <a href="http://www.openstreetmap.org/" rel="nofollow noreferrer">OpenStreetMap</a> project imported TIGER data, you might find useful code snippets there. See the <a href="http://wiki.openstreetmap.org/index.php/TIGER" rel="nofollow noreferrer">TIGER</a> page on the OpenStreetMap wiki for more information and l... | 12,947 |
<p>What is the best way to persist/save printer settings in .Net?
There used to be a bug in .Net 1.1 in the serialization of the <code>PrinterSetting</code> object and there were some <a href="http://www.codeproject.com/KB/cs/printersettings.aspx" rel="nofollow noreferrer">workarounds</a> but I'm wondering if there isn... | <p>I did a pretty ghetto method of <a href="http://nicholas.piasecki.name/blog/2008/11/programmatically-selecting-complex-printer-options-in-c-shar/" rel="nofollow noreferrer">dumping the current DEVMODE and overwriting it back when they want to use it again</a> to send some proprietary printer settings to a copier mac... | <p>not programmatic answer would be: use print management console from 2003 r2 server adminpack to Export Printer configuration. Maybe that feature has an API for it, wich can be called from .net.</p>
| 20,481 |
<p>Is there any good tool for working on Dabtabase apart from Toad which requires license and DBVisualiser not supportive</p>
| <p>Try fabForce Database Designer; it is GPL too.
<a href="http://fabforce.net/dbdesigner4/" rel="nofollow noreferrer">http://fabforce.net/dbdesigner4/</a></p>
| <p>I am using the free version of <a href="http://www.synametrics.com/SynametricsWebApp/WinSQL.jsp" rel="nofollow noreferrer">WinSQL</a>.<br>
I am also looking at <a href="http://www.oracle.com/technology/products/database/sql_developer/index.html" rel="nofollow noreferrer">SQLDeveloper</a> from Oracle. I have heard i... | 10,600 |
<p>How do you know if the HTTP compression setup is working? Is there any tool I can use to see the compressed page before it is uncompressed by the browser? Are there any tools to measure the amount compressed and response speed?</p>
| <p>For Windows, I highly recommend <a href="http://fiddler2.com/fiddler2/" rel="noreferrer">Fiddler</a>, which is a client-side tool that proxies your web traffic and lets you examine it. It will show you if compression is on and working. It is also useful for many other client-side HTTP-related debugging and diagnos... | <p>We searched around a bit. Apparently, there are a lot of sites which can verify that our pages are compressed.</p>
| 19,423 |
<p>I was trying to print parts for a small CD-ROM drive based plotter based on this thing <a href="https://www.thingiverse.com/thing:3521286" rel="nofollow noreferrer">https://www.thingiverse.com/thing:3521286</a></p>
<p>But as tolerances are very small and need to match the existing parts, I realized that my printed ... | <p><a href="https://3dprinting.stackexchange.com/questions/6968/slicer-line-width-vs-extrusion-multiplier-for-layer-adhesion">You are not taking into account die swell</a>.</p>
<p>When printing with a 3D printer hot plastic is forced through a nozzle, which leads to the expansion of the material. The result is, that w... | <p>There are several ways to try and adjust for this effect of squashing the material, which is ultimately about having enough space for the material you lay down.</p>
<p>As mentioned:
You can try to pre-scale models (not very effective as a general solution because it is a function of the model and how many adjacent ... | 1,488 |
<p>This error comes out whenever I click the datagrid.</p>
<p>The program does fill the datagrid every time data was selected in the combobox.</p>
<p>For example, I choose data1 which has four records in datagrid, and then I click row index no 1. No problem, it will be shown, but when I choose another data again in c... | <p>If the selected row index is larger than the largest index (number of rows minus one) in the new data, then decrease the row index as necessary before doing the fill? Or check the reason for the exception and decrease the row index instead of displaying the error message?</p>
| <p>When refilling the datagrid - make sure you reset the selected row (which is what I'd expect the Clear() to do).</p>
<p>An index outside the bounds of the array is usually caused by you trying to see a row that isn't there anymore. Do you have a pointer to the current row in the datagrid anywhere? </p>
<p>Is anyt... | 27,757 |
<p>Let's say I have a .NET Array of n number of dimensions. I would like to foreach through the elements and print out something like:</p>
<pre><code>[0, 0, 0] = 2
[0, 0, 1] = 32
</code></pre>
<p>And so on. I could write a loop using some the Rank and dimension functions to come up with the indices. Is there a bui... | <p>Thanks for the answer, here is what I wrote while I waited:</p>
<pre><code>public static string Format(Array array)
{
var builder = new StringBuilder();
builder.AppendLine("Count: " + array.Length);
var counter = 0;
var dimensions = new List<int>();
for (int i = 0; i < array.Rank; i++)... | <p><a href="http://forums.msdn.microsoft.com/en-US/csharplanguage/thread/2ca85aa4-0672-40ad-b780-e181b28fcd80/" rel="nofollow noreferrer">Take a look at this:</a> might helpful for you.</p>
| 4,607 |
<p>In my ASP.NET application using InProc sessions, Session_End calls a static method in another object to do session-specific clean up. This clean up uses a shared database connection that I am storing in application state.</p>
<p>The problem is that I cannot see how to access the application state without passing i... | <p>You should be able to access the ApplicationState object using the Application property from inside Session_End.</p>
<pre><code>void Session_End(object sender, EventArgs e)
{
HttpApplicationState state = this.Application;
}
</code></pre>
<p>(had to reply in a different answer because I don't have the reputat... | <p>You should be able to access the SessionState object using the Session property from inside Session_End.</p>
<pre><code>void Session_End(object sender, EventArgs e)
{
HttpSessionState session = this.Session;
}
</code></pre>
<p>This property and a lot more come from the base class of Global.asax</p>
| 20,676 |
<p>I want to see how long a function takes to run. What's the easiest way to do this in PLT-Scheme? Ideally I'd want to be able to do something like this:</p>
<pre><code>> (define (loopy times)
(if (zero? times)
0
(loopy (sub1 times))))
> (loopy 5000000)
0 ;(after about a seco... | <p>The standard name for timing the execution of expressions in most Scheme implementations is "time". Here is an example from within DrRacket.</p>
<blockquote>
<p>(define (loopy times)
(if (zero? times)
0
(loopy (sub1 times)))) </p>
<p>(time (loopy 5000000))
cpu time: 1526 real time... | <p>Found it...</p>
<p>From the <a href="http://download.plt-scheme.org/doc/301/html/mzscheme/mzscheme-Z-H-15.html#node_sec_15.1.3" rel="nofollow noreferrer">online documentation</a>:</p>
<blockquote>
<ul>
<li><code>(time-apply proc arg-list)</code> invokes the procedure proc with the arguments in arg-list. Four v... | 32,025 |
<p>I've recently seen the light of EventWaitHandle's powerful behavior in C# and decided to move some functionality in a sister application to do the same. The only problem is that the sister app is written in C.</p>
<p>No big deal, I'm using pthreads, which have a pthread_cond_t datatype that allows for signalling. M... | <p>If you're using condition variables correctly, this won't matter.</p>
<p>The basic flow of your code should be (in pseudocode):</p>
<pre><code>lock(lockobj);
while (!signalled) {
wait(condvar);
}
signalled = false;
unlock(lockobj);
</code></pre>
<p>on the waiting side, and:</p>
<pre><code>lock(lockobj);
sign... | <p>Alternative answer (also in pseudocode) if you want <em>multiple signallings</em> (i.e., if signalled twice, then two threads can wait before the state is unsignalled again).</p>
<p>Waiting side:</p>
<pre><code>lock(lockobj);
while (signalled != 0) {
wait(condvar);
}
--signalled;
unlock(lockobj);
</code></pre>... | 17,280 |
<p>Does anyone have a good guide to capabilities of Windows Services under XP? In particular, I am trying to find out what happens when a program being run as a service tries to open windows, but hasn't been given permission to interact with the desktop.</p>
<p>Basically, I have a program that is/was a GUI application... | <p>Generally, services should be designed to not have any visible UI. The entire point of a service is to run in the background, without UI, unattended. (Think SQL Server, IIS, etc.)</p>
<p>In most scenarios, a separate application controls the service's operation, should a GUI be needed. (Continuing the samples I jus... | <p>Usually the service won't have permission to write to the window station and desktop, so it will fail; even running applications that load user32.dll can fail simply because user32 has initialization code that wants to talk to the window station and can't get access to it unless the service is running as an administ... | 14,323 |
<p>I have hit upon this problem about whether to use bignums in my language as a default datatype when there's numbers involved. I've evaluated this myself and reduced it to a convenience&comfort vs. performance -question. The answer to that question depends about how large the performance hit is in programs that a... | <p>To be honest, the best answer is "try it and see".</p>
<p>Clearly bignums can't be as efficient as native types, which typically fit in a single CPU register, but every application is different - if yours doesn't do a whole load of integer arithmetic then the overhead could be negligible.</p>
| <p>your reduction is correct, but the choice depends on the performance characteristics of your language, which <em>we cannot possibly know</em>!</p>
<p>once you have your language implemented, you can measure the performance difference, and perhaps offer the programmer a directive to choose the default</p>
| 33,979 |
<p>I am trying to find out how to upload a file from a web user to a server using an ASP page. The displayed page has an Input tag of type "File" like this:</p>
<pre><code><input type="file" name="uploadfile">
</code></pre>
<p>And a submit button that passes the Form info to another .ASP page. This page must ... | <p>This <a href="http://www.webconcerns.co.uk/asp/uploadasp/default.asp" rel="nofollow noreferrer">script</a> will help you.</p>
<p>Also, you may google for "<a href="http://www.google.com/search?q=asp+upload+file" rel="nofollow noreferrer">asp upload file</a>" - there are tons of results.</p>
| <p>If your hosting service doesn't allow you to install components, you may also want to look at this script:</p>
<p><a href="http://chris.brimson-read.com.au/index.php?option=com_content&view=article&id=6&Itemid=7" rel="nofollow noreferrer">http://chris.brimson-read.com.au/index.php?option=com_content&... | 29,139 |
<p>Was wandering if anyone uses ASP .NET membership? If you do, tell me what you think about it.</p>
<p>If you don't use it, Are you planning to use it on future projects? If not, why?</p>
<p>RWendi</p>
| <p>Yes. Have used it quite a lot, and it will save you a lot of work. </p>
<p>There are some pain points like changing usernames, and administrative reset of passwords, that clients will often ask for, and you will have to hack your way around them. </p>
<p>The role provider is also pretty handy, and there are a ... | <p>Note that the profile provider only works out of the box with the website template:</p>
<p><a href="http://www.codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx" rel="nofollow noreferrer">http://www.codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx</... | 39,104 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.