input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Killing power to a USB port <p>Is there a way to programatically turning off the power or killing a USB port on the Mac?</p>
| <p>I believe that the USB power typically comes directly from the power supply. It might go through the motherboard or some other hardware to combine it with the data lines, but I don't think the voltage ever goes through any programmable circuitry. If you wanted to deactivate the data transfer, that would probably b... |
Need to mousewheel scroll a usercontrol <p>I have a usercontrol I created. I added a panel and a vertical scrollbar to the right of it. I'd like to be able to scroll it with the mousewheel. The problem is there doesn't seem to be any events that fire on mousewheel. If I take the panel off then the usercontrol has f... | <p>yes, a panel can have focus. You just have to give it focus, I prefer to use on mouse over.</p>
<p>I did this and its problem solved.</p>
|
When must we use NVARCHAR/NCHAR instead of VARCHAR/CHAR in SQL Server? <p>Is there a rule when we must use the Unicode types? </p>
<p>I have seen that most of the European languages (German, Italian, English, ...) are fine in the same database in VARCHAR columns.</p>
<p>I am looking for something like: </p>
<ol>
<l... | <p>The real reason you want to use NVARCHAR is when you have <strong>different</strong> languages in the same column, you need to address the columns in T-SQL without decoding, you want to be able to see the data "natively" in SSMS, or you want to standardize on Unicode.</p>
<p>If you treat the database as dumb storag... |
Can I use SQL to plot actual dates based on schedule information? <p>If I have a table containing schedule information that implies particular dates, is there a SQL statement that can be written to convert that information into actual rows, using some sort of CROSS JOIN, perhaps?</p>
<p>Consider a payment schedule tab... | <p>I cannot test the code right now, so take it with a pinch of salt, but I think that something looking more or less like the following should answer the question:</p>
<pre><code>with q(SchedId, PaymentNum, DueDate, RunningExpectedTotal) as
(select SchedId,
1 as PaymentNum,
StartDate as Du... |
RMI and exceptions <p>I am new to using RMI and I am relatively new to using exceptions.</p>
<p>I want to be able to throw an exception over RMI (is this possible?)</p>
<p>I have a simple server which serves up students and I have delete method which if the student doesn't exist I want to throw a custom exception of... | <p>It's OK to throw any kind of exception (even custom ones), just make sure to package them up in your export .jar file (if you're using a version of Java where you need to do this manually).</p>
<p>I wouldn't subclass RemoteException, though. Those are typically thrown if there is some kind of connection problem. ... |
How does Git solve the merging problem? <p>SVN made branching much easier by making branches really cheap, but merges remain a real problem in SVN - one that Git supposedly solves.</p>
<p>Does Git achieve this, and how?</p>
<p>(disclaimer: All I know about Git is based on the Linus lecture - total git noob here)</p>
| <p>Git will not prevent conflict in merges but can reconcile history even when they do not share any parent ancestor.<br />
(through <a href="http://community.livejournal.com/evan%5Ftech/255341.html">The grafts file (<code>.git/info/grafts</code>)</a>, which is a list, one per line, of a commit followed by its parents,... |
What's the best way to format source code on IMs to preserve indenting? <p>Is there a way to preserve indenting in instant messengers when you are pasting source code to a co-worker?</p>
<p>In particular I'm trying to write some python code via google talk, but all tabs are removed.</p>
| <p>Paste the code into <a href="http://pastebin.com" rel="nofollow">http://pastebin.com</a> and get a short link to use in an IM or IRC conversation. <em>(Disclosure: I run that site, "other pastebins are available!" :)</em></p>
|
System.Drawing.Font: no concept of font weight? <p>I just noticed that in .net that System.Drawing.Font seems to have no concept of font weight other than FontStyle of normal and bold. I don't have the fine control I had in win32. The WPF framework has font weights, but I'm not using that namespace.</p>
| <p>I think you can create the font using Win32, then wrap it using Font.FromHfont.</p>
|
How do I show like-values in custom fields in a property grid? <p>I have a property grid that helps me manage all of the controls on a form. These controls are for designer-type folks, so I'm not really worried that much about the user interface... until someone selects multiple objects.</p>
<p>I have a UITypeEditor f... | <p>In the TypeConvertor of the Datatype which is attributed to BottomDiameter Property, you might want to create a vistor like class called say, BottomDiameterVistor which would take an array or a list of the selected BottomDiameter(s). Override the to string property on the BottomDiameterVistor to return your aggregra... |
What can make a program run slower when using more threads? <p>This question is about the same program I <a href="http://stackoverflow.com/questions/564577/dividing-loop-iterations-among-threads">previously asked about</a>. To recap, I have a program with a loop structure like this:</p>
<pre><code>for (int i1 = 0; i1 ... | <p>To avoid further comments on this: When I wrote my reply, the questioner hasn't posted a link to his source yet, so I could not tailor my reply to his specific issues. I was only answering the general question what "can" cause such an issue, I never said that this will necessarily apply to his case. When he posted a... |
WCF: How do I get the list of endpoints from ServiceHost? <p>I can add endpoints using <code>ServiceHost.AddServiceEndpoint</code>. How do I get that list of endpoints back out?</p>
| <p>host.Description.Endpoints</p>
|
Do you know of any OpenSSH libraries for Windows? <p>I'd like to incorporate OpenSSH support into a Windows application and I am looking for a library (preferably .Net or something easily integrated into .Net) that can provide this functionality. I'm more interested in ssh client software than server software, but bot... | <p>Check out <a href="http://www.weonlydo.net/" rel="nofollow">WeOnlyDo</a>. They have some nice .NET SSH components like <a href="http://www.weonlydo.com/index.asp?showform=SSH.NET" rel="nofollow">wodSSH.Net</a> for $199.</p>
<p>Also, <a href="http://www.nsoftware.com/" rel="nofollow">nSoftware</a> has some great net... |
How do i determine the SQLDBType of a variable to be added to a parameter? <p>How do I determine which SQLDBType to assign to a parameter depending on the input variable to store in the DB? Is there a GetType equivelant to test with?</p>
<pre><code>If IsNumeric(ParameterValue) Then
Parameter.SqlDbType = SqlDbType... | <p>There are too many SqlDbTypes (across too many versions) to do it the safely the way you want to, especially if you need to use more precise data types (e.g. decimal as opposed to float, or even bigint).</p>
<p>I would consider creating a simple mapping system between .NET data types and SqlDbTypes, using SMO. Then... |
Costs involved with C# destructors (aka: finalizers)? <blockquote>
<p>The destructor should only release unmanaged resources that your object holds on to, and it should not reference other objects. If you have only managed references you do not need to (and should not) implement a destructor. You want this only for h... | <p>Any object that has a finalizer (I prefer that term over destructor, to emphasize the difference from C++ destructors) is added to the finalizer queue. This is a list of references to objects that has a finalizer that has to be called before they are removed.</p>
<p>When the object is up for garbage collection, the... |
Different filtered dataProviders for the same data? <p>I have several lookup tables, some of which refer to or are relationships between others.</p>
<p>For instance, I have <code>membership type included inventory</code> which has Membership ID and Inventory Type ID and is the amount of each Inventory Type that one ge... | <p>You can use a single <code>Array</code> instance with multiple <code>ArrayCollection</code> instances. If you're just displaying data, or sorting and filtering using the methods/properties provided by <code>ArrayCollection</code> (rather than editing the <code>Array</code> directly), it should have no effect on the ... |
How do I contest an iPhone app store review? <p>I have an application in the app store. I have submitted 3 updates to the app. 2 of those 3 updates have been rejected based on something that has not changed at all since the original submission. </p>
<p>I recognize that they have a different person each time review my ... | <p>I've had a similar problem with an update getting rejected. You still must address the rejection issue even though the current in store app has the same problem.</p>
<p>The only way I know of to talk with a real person is to pay $199 for an ADC support ticket.</p>
<p>Since this seems to be a fact of life right now... |
Anyone still program using xlib directly <p>I am surprised at the lack of response to all the xlib related question I've had on SO, is this because no one uses xlib directly anymore or is this the wrong place to ask these types of questions? Even if no one uses xlib directly, there must still be people the remember the... | <p>No, XLib is certainly a valid topic here but I think your first contention is correct: almost nobody uses it anymore. I vaguely remember using it some fifteen years ago and I liken it to:</p>
<ul>
<li>pulling out your teeth with a hammer.</li>
<li>trying to eat a pineapple without cutting it up first.</li>
<li>nail... |
Definitive pattern for implementing templated data-bound controls in ASP.NET <p>I am working on a project at the moment where we are building <strong>templated data-bound controls</strong> (TDBC) for <strong>ASP.NET</strong>.</p>
<p>The problem is it appears that nobody has really worked out the definitive pattern fo... | <p>I have read some in <a href="http://rads.stackoverflow.com/amzn/click/0735615829" rel="nofollow">Developing Microsoft ASP.NET Server Controls and Components (Pro-Developer) (Paperback)</a>. It is pretty good, but out of date. It takes you through various aspects of building server controls, from dealing with state,... |
Who knows what Picasa is programmed with? <p>I am looking for information on how Picasa was built as I would like to create a similar interface for my application.</p>
<p>Information can include programming language,UI design, etc.</p>
| <p>I found this <a href="http://web.archive.org/web/20081120034208/http://www.secretrobot.com/blog/archives/2004/11/the_beautiful_p_1.html" rel="nofollow">The Beautiful Picasa UI is Made of Dynamic PSD Files</a>:</p>
<blockquote>
<p>I was snooping around in Picasa's "runtime" folder and found a bunch
of Photoshop ... |
Inline editing with AJAX - how do I create multiple editable areas on the same page? <p>I found a tutorial on how to create editable regions on a page using AJAX.</p>
<p>This is great, except it was written for a single element with a unique ID. I'd like to be able to click on multiple elements on the same page and ha... | <p>The <code>Event.observe</code> method currently attaches to a single element with the ID specified. You should change this to iterate over a collection of elements located by classname and attach to each of them. According to the Prototype documentation, you can provide an element object as the first parameter, inst... |
Have I covered all bases with security when echo'ing a server variable to the page? <p>With forms I've always used</p>
<pre><code><form method="post" action="<?php echo strip_tags($_SERVER['REQUEST_URI']); ?>">
</code></pre>
<p>To get my forms to submit to themselves.</p>
<p>I use <code>striptags()</code... | <p>Use <a href="http://docs.php.net/htmlspecialchars" rel="nofollow"><code>htmlspecialchars</code></a> instead of <code>strip_tags</code>.</p>
|
How to put the build date of application somewhere in the application? <p>I would like to put the date the application was built somewhere in the application. Say the about box. Any ideas how this can be done? I need to do this for C# but I am also looking for a general idea, so you can answer this for any specific lan... | <p>Typically we just go with the executable's last modify date. This will be set when the exe is built and usually never changes (short of someone actually editing the file). When the file is installed, copied, moved, etc, Windows doesn't change that value.</p>
<pre><code>DateTime buildDate =
new FileInfo(Assemb... |
Save VSTO Word 2007 Template application to docx without prompt to save template <p>Steps to reproduce:</p>
<ol>
<li>Create Word 2007 Template Project (Visual Studio 2008 Professional SP1)</li>
<li>Place DateContentControl on document</li>
<li>Save, Publish, open .dotx</li>
<li>Modify DateContentControl, Save</li>
<li... | <p>Word checks whether the attached template of a document has been modified and prompts whether to save the changes. To avoid such a prompt you could set the <code>Saved</code> property of the attached templated to <code>true</code>.</p>
<p>In VBA this would be:</p>
<pre><code>ActiveDocument.AttachedTemplate.Saved =... |
Prοblem writing to serial port from Java <p>Duplicate of <a href="http://stackoverflow.com/questions/606074/implementation-of-xmodem-protocol-in-java">Implementation of Xmodem Protocol in Java</a></p>
<hr>
<p>Hi, I've got to implement the xmodem protocol to receive a file from a target device. For that, I have to r... | <p>Perhaps the streams are blocking. </p>
<p>Java nio has channels that do not block. Try using one of those. </p>
<p>Here's a <a href="http://stackoverflow.com/questions/326390/how-to-create-a-java-string-from-the-contents-of-a-file/326440#326440">sample of reading a file with nio</a>. I'm not sure if the same appli... |
Layer vs Scene in Cocos2d for iPhone game development <p>Using cocos2d for iPhone game development, I am confused between Layer and Scene.
For example, My simple game have several "UI Pages" like main menu, highscores, game board etc.</p>
<p>So should I use Layer or Scene for every "UI page", and why?</p>
| <p>Reviewing SpritesDemo.m/.h, it would appear that they are using Layer, and then creating new scenes, attaching the layer and then replacing the scene on the director</p>
<pre><code>@interface SpriteDemo : Layer
@interface SpriteManual : SpriteDemo
</code></pre>
<p>The code then does the following:</p>
<pre><code>... |
How do you measure a small, big, very big project? <p>I am reading Code Complete as well as a couple of other programming books at the moment. The size of the project affects a lot of other parameters that you need to take heed of in planning, coding, automating tests, etc. I was wondering what people on SO generally u... | <p>I would say it's the amount of development effort required. Taking a team of six developers:</p>
<ul>
<li>Small project - up to 6 months</li>
<li>Big project - 6-18 months</li>
<li>Very big project - 18+ months</li>
</ul>
<p>Everyone will have a different opinion though.</p>
<p><strong>Edit</strong></p>
<p>I was... |
How to run batch file on server and return result to client <p>I have a bat file on server that return result, then I want to know can I run this bat file from my client and return result to my client?</p>
<p>e.g. Bat file return string value "Hello", I want to run this bat file from my PC and get string "Hello" displ... | <p>You did not mention if you would like to do this from code? It sounds like PSExec might do what you require. </p>
<p>This is a short discription of what it does:</p>
<blockquote>
<p>PsExec's most powerful uses include launching interactive command-prompts on remote systems and remote-enabling tools like Ip... |
Backgroundworker abort <p>I recently tried to use backgroundworker instead of "classic" threads and I'm realizing that it's causing, at least for me, more problems than solutions.
I have a backgroundworker running a synchronous read (in this case from serialPort) and getting blocked around 30 seconds in 1 code line, th... | <p>I put one together that (i think) does the job. Please let me know if im waaaay off.
Here is a simple exaple of how it works.</p>
<pre><code>var backgroundWorker = new BackgroundWorker(){WorkerSupportsCancellation = true};
backgroundWorker.DoWork += (sender, args) =>
{
... |
Navigating to nodes using xpath in flat structure <p>I have an xml file in a flat structure. We do not control the format of this xml file, just have to deal with it. I've renamed the fields because they are highly domain specific and don't really make any difference to the problem.</p>
<pre><code><attribute name=... | <p>We want the "attribute" element of @name 'Author' that is following an "attribute" element of @name 'Title' with a value of 'Book n', without any other "attribute" element of @name 'Title' between them (because if there are, then the author authored some other book).</p>
<p>Said differently, it means we want an aut... |
PHP: Checking if a directory contains a Zend_Search_Lucene index <p>I am looking for a reliable way to check to see if a directory contains a <em>Zend_Search_Lucene</em> index. Currently, the only way I have managed to work this out is to check the contents of an exception returned to me using the following code:</p>
... | <p>You might first try to check if there is index segments number file </p>
<pre><code>file_exists($luceneDir.'segments.gen')
</code></pre>
|
Regex to match all except a string in quotes in C# <p>I am a novice with Regex usage in C#.
I want a regex to find the next keyword from a given list but which is not surrounded by the quotes.</p>
<p>e.g.
if i have a code which looks like:</p>
<pre><code> while (t < 10)
{
str... | <p>Try the following RegEx (<strong>Edit:</strong> fixed).</p>
<pre><code>(?:[^\"]|(?:(?:.*?\"){2})*?)(?: |^)(?<kw>for|while|if)[ (]
</code></pre>
<p>Note: Because this RegEx literal includes quotes, you can't use the @ sign before the string. Remember that if you add any RegEx special chars to the string, you'... |
Are there an error handling API / framework in Java? <p>On a Server there can occur different temporary (transient) errors. For example an OutOfMemoryError or a broken connection to a database.</p>
<p>I think it is a good idea to repeat such job a short time later. Of course it should not a endless loop because the er... | <p>This general idea is often called the Circuit Breaker pattern. Google has an <a href="http://www.google.com/search?client=opera&rls=en&q=circuit-breaker%2Bpattern&sourceid=opera&ie=utf-8&oe=utf-8" rel="nofollow">interesting list</a> of implementation ideas.</p>
|
Where can I find the binaries for arm-wince-pe-gcc? <p>I am looking for a version of the gcc (C++) compiler targeting the ARM uP and WindowsCE operating system. Thus far I have only been able to locate compilers which either target the ARM uP but produce ELF executables (GNUARM etc) or they do target windows CE but hav... | <p>I'm using CEGCC from SourceForce: <a href="http://cegcc.sourceforge.net/" rel="nofollow">http://cegcc.sourceforge.net/</a>, and so far it works OK. I've managed to build a Windows API application, zlib and libpng, and everything runs just fine on Windows CE 5.0, and the C code you write is the same one you'd write i... |
Access TimeZoneInfo from SQL 2005 Server <p>The .NET TimeZoneInfo class is great and I thought it would answer all my issues with recording data from multiple time zones in my SQL 2005 database.</p>
<p>To convert a UTC datetime in the database to any other time zone i'd just get the time zone into a TimeZoneInfo class... | <p>I just finished doing this on a SQL 2008 database. </p>
<p>First I had to set the DB to trustworthy and verify the owner was correct.</p>
<pre><code>use [myDB]
go
alter database [myDB] set trustworthy on
go
exec sp_changedbowner 'sa'
go
</code></pre>
<p>Next, I created a .NET solution</p>
<pre><code>Imports Sys... |
How do I add a namespace while doing XmlSerialization with an XmlWriter? <p>I am using the XmlWriter in conjunction with Xml Serialization. I am able to output the XML fine, but how to include the xmlns attribute with the XmlWriter seems to be escaping me.</p>
<p>To write the start of the document I use the following... | <p>You can add the namespace to the XmlSerialization attributes, e.g.:</p>
<pre><code>[XmlElement(
ElementName = "Members",
Namespace = "http://www.cpandl.com")]
public Employee[] Employees;
</code></pre>
<p>if you have control over the code.</p>
|
SocketException on Windows XP home edition on connect: an invalid argument was supplied <p>Our software needs to connect to an server and we do that with use of an TCPclient.
50+ systems (all Windows XP pro) are using the software and have no problem with connecting.
The software also has been tested on windows vista a... | <p>Just for people who wonder. We never got the time to further investigate the issue. It seemed to be a problem with the host's pc...</p>
|
I want to know the usage of filepath <p>I have made a project in which i have a business logic and a GUI. Now i have to separate them in the same project. where business logic is in different class. In my project there is a file that needs to be loaded from memory. Then manipulations in that file is done in the busines... | <p>As I understand it, you get a file path from the UI and are wondering how to best pass this path to your business logic classes.</p>
<p>A string is a very common and acceptable way to pass a file path from one class to another.</p>
<p>FxCop may complain and request you use a Uri. I think that's a bit of overkill,... |
Implementing foreign key type relationships in XSD schema <p>I'm trying to wrap my head around xml schemas and one thing I'm trying to figure out is how to do relational type schemas where on element refers to another, possibly in another schema altogether. I've looked at the xsd:key and xsd:keyref and it seems like th... | <p>I'm not aware of anything within XML Schema that will allow you to validate multiple XML documents against one another. In the <code>xs:id</code> and <code>xs:key</code> (etc) constraints, you use xpath to apply the constraints. You can go to <a href="http://www.w3.org/TR/xmlschema-1/#declare-key">XML Schema Part ... |
Exception wrapper for Carbon C app in OSX <p>How can I efficiently catch and handle segmentation faults from C in an OSX Carbon application?</p>
<p>Background: I am making an OSX Carbon application. I must call a library function from a third party. Because of threading issues, the function can occasionally crash, usu... | <p>Are you sure you're not getting a SIGBUS rather then a SIGSEGV?</p>
<p>The below catches SIGBUS as caused by trying to write at memory location 0:</p>
<pre><code>cristi:tmp diciu$ cat test.c
#include <signal.h>
static void sigac(int sig)
{
printf("sig action here, signal is %d\n", sig);
exit(1);
}
... |
JAR multiple download <p>I have this code on an applet. The applet works ok, but I get a lot of unnecessary duplicate download. In particular, I have noticed that each "getResource" triggers a download of the .JAR file.</p>
<pre><code>static {
ac = new ImageIcon(MyClass.class.getResource("images/ac.png")).getImage... | <p>Simply removing all instances of URLConnection.setDefaultUseCaches(false) will solve the problem.</p>
<p>Please refer for more details.</p>
<p><a href="http://java-junction.blogspot.com/2009/11/applet-jar-caching-not-working.html" rel="nofollow">http://java-junction.blogspot.com/2009/11/applet-jar-caching-not-work... |
Solaris GDB: Howto pause execution? <p>I am using GDB to debug a closed source program on Solaris 10 x86.</p>
<p>I attach gdb to the program and continue execution, however when I want to pause execution later to examine some memory I cant. When I press CTRL-C it only prints ^C instead of pausing the program and dropp... | <p>Just found a workaround. From another terminal give the following command:</p>
<pre><code>kill -INT 1521
</code></pre>
<p>GDB will pause execution upon the debugged program receiving the SIGINT.</p>
|
How do I save the state of the treeview nodes (expanded/collapsed) between postbacks? <p><strong>DUPE</strong> <a href="http://stackoverflow.com/questions/516192/c-treeview-state-expanded">http://stackoverflow.com/questions/516192/c-treeview-state-expanded</a></p>
<p>See above...</p>
| <p>I think that depends upon your treeview. The Telerik treeview does this via viewstate...</p>
<p><a href="http://www.telerik.com/community/forums/aspnet/treeview/how-do-i-maintain-treeview-state-after-postback.aspx" rel="nofollow">http://www.telerik.com/community/forums/aspnet/treeview/how-do-i-maintain-treeview-sta... |
How can I cut(1) camelcase words? <p>Is there an easy way in Bash to split a camelcased word into its constituent words?</p>
<p>For example, I want to split aCertainCamelCasedWord into 'a Certain Camel Cased Word' and be able to select those fields that interest me. This is trivially done with cut(1) when the word sep... | <p><code>sed 's/\([A-Z]\)/ \1/g'</code></p>
<p>Captures each capital letter and substitutes a leading space with the capture for the whole stream.</p>
<pre><code>$ echo "aCertainCamelCasedWord" | sed 's/\([A-Z]\)/ \1/g'
a Certain Camel Cased Word
</code></pre>
|
Centering several elements inside a div <p>Greetings,
I'm trying to create a pagination panel for one of my lists and want to make it centered. Currently it looks like:</p>
<pre><code><div class="panel">
<div class="page">1</div>
<div class="page">2</div>
<div class="page">3&l... | <p>Is there any reason you want the pages to be <code><div></code>s? If you make them a <code><span class='page'></code> (which is more semantically correct imho) and apply <code>text-align: center;</code> to the panel you get the effect you want. Otherwise you could do <code>display: inline;</code> on the ... |
How to change html tag attribute value from RJS template? <p>Is it possible to change a html tag attribute value from an RSJ template?
I know that there is a page.replace_html method, but it is not very useful in my case, since I have lengthy values of various attributes (such as alt, title of an image).
What I want is... | <p><strong>EDIT:</strong> My first attempt didn't work, but this one does.</p>
<pre><code>update_page do |page|
page['image_id']['src'] = new_image_url
end
</code></pre>
|
Writing a mini-language <p>I have an application that needs to allow users to write expressions similar to excel:</p>
<p>(H1 + (D1 / C3)) * I8</p>
<p>and more complex things like </p>
<p>If(H1 = 'True', D3 * .2, D3 * .5)</p>
<p>I can only do so much with regular expressions. Any suggestions as to the right approach... | <p>Some other question, you will find hints in:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/229854/how-to-write-a-programming-language">How to write a programming language?</a></li>
<li><a href="http://stackoverflow.com/questions/1669/learning-to-write-a-compiler">Learning to write a compiler</a></li>
<li... |
Problem with WCF-Service between Silverlight and Azure Cloud WebRole <p>I want to use a Silverlight application in a cloud on Azure. The communication between the Silverlight application and the WebRole is a WCF-Service with Basic-HTTP-Binding.
My problem is, that the communication doesn't work. I think the endpoint-ad... | <p>Have you tried using <a href="http://www.fiddlertool.com/fiddler/" rel="nofollow">Fiddler</a> that will at least tell you if the end point is correct.
It should also help if there are any permissions issues.</p>
|
Should I learn Python after C++? <p>I`m currently studying C++ and want to learn another language.<br>
For work I use C# + ASP (just started learning it, actually), but I want something "less Microsoft" and powerful.<br>
I have heard Python is a popular and powerful language, not so complicated as C++. But many people ... | <p>There's no right or wrong answer, really. But I think you'll benefit more from learning Python. Given the similarities between C# and C++, you'll learn a different way of thinking from Python. The more ways you learn to think about a problem, the better it makes you as a programmer, regardless of the language.</p... |
What is the real, day-to-day operational difference between Vista Home Premium and Ultimate? <p>I'm about to jump to a new machine that has Vista Home Premium 64 installed. I do development with VS2008. I have an Ultimate 64 license and disc so I can repave if I have to. </p>
<p>What are the day-to-day operational dif... | <p>The big items for me are that Ultimate has domain join capabilities, and also remote desktop support - both of those features are left out of Home Premium. </p>
<p>Other than that - the Ultimate edition is pretty much a union of the features in Business and Home Premium editions.</p>
<p>I use the Ultimate edition... |
What weaknesses can be found in using Erlang? <p>I am considering Erlang as a potential for my upcoming project. I need a "Highly scalable, highly reliable" (duh, what project doesn't?) web server to accept HTTP requests, but not really serve up HTML. We have thousands of distributed clients (other systems, not users) ... | <p>This sounds like a perfect candidate for a language like Erlang. The scaling properties of the language are very good, but if you're worried about the data processing abilities, you shouldn't be. It's a very powerful language, with many libraries available for developers. It's an old language, and it's been heavily ... |
Should I give a client a SQL Server login with the 'db_owner' role? <p>One of our clients has requested that we include the 'db_owner' role on the database login that their website uses, so that they can upload a script (an ASP page) to run some database changes. Normally the logins for the databases hosted on our ... | <p>I would suggest that you act as a filter between them and anything they might want to do to the database such as uploading and running those scripts. If they get db_owner and hose it all up, it will still probably be your head on the chopping block for letting them have it to begin with.</p>
|
How do you return a copy of original List<T> from Func<T, TResult>? <p>I have found out (in a hard way) that a collection that is being enumerated cannot be modified within "Foreach" statement</p>
<blockquote>
<p>"Collection was modified; enumeration operation may not execute."</p>
</blockquote>
<p>Now, the solutio... | <p>Just add a .ToList() to the end of the collection and it will automagically return a complete copy of the list. </p>
<pre><code>foreach (var nodeId in _AuthenticatedNodes.Keys.ToList())
...
</code></pre>
|
Can you start Crystal Reports 10 in read only mode so users can't create or change a report? <p>I'm in an environment where I have created reports in CrystalReports 10 and only want my users to view the report from an external application. The application is already set up to open the report with crystal, but I don't ... | <p>embed crviewer and craxdrt components in your app (delivered with CR developer's edition, free to distribute) so that you'll be able to view reports without modifying them. Basic manipulations (zoom, search, export to pdf, display/hide details or groups) can still be done.</p>
<p>If you must launch this viewer from... |
How to replace xml special chars manually? <p>My application produces an xml file that is then xslt transformed into a nice html report. I have a problem with \n however. There are some xslt techniques to do it, but they are pretty awkward and time consuming. </p>
<p>So my solution was to do a string.replace \n to </p... | <p><strong>Never, ever use string manipulation to produce XML.</strong> It's not just that it makes poorly-socialized people laugh at you: it leads to code that has bugs in it that you don't know exist.</p>
<p>Think about it from a test-driven perspective. You've written a method that uses string manipulation to ge... |
CIL: "Operation could destabilize the runtime" exception <p>I've been playing with PostSharp a bit and I ran into a nasty problem.</p>
<p>Following IL in Silverlight assembly:</p>
<pre><code>.method public hidebysig specialname newslot virtual final instance void
set_AccountProfileModifiedAt(valuetype [mscorlib]Syst... | <p>Did you use peverify? You should always run this utility when playing directly with MSIL (you can use the msbuild flag /p:PostSharpVerify=true).</p>
<p>Looking at your code:</p>
<ol>
<li><p>Your local variables are not initialized (missing "init" keyword). This is a property of MethodBodyDeclaration.</p></li>
<li>... |
Any ideas why this NFS setup won't work? <p>I set up an NFS server on my CentOS box with this for the /etc/exports file:</p>
<pre><code>/var/www 192.168.0.0/24(rw,sync,no_root_squash)
</code></pre>
<p>Then on my Ubuntu machine, I ran:</p>
<pre>
# cd ~/
root@bill-murray:~# mount -v 192.168.0.21:/var/www ash
mount: no... | <p>See this:
https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/213444</p>
<p>So, if your CentOS box is running the same nfs-kernel-server that is in Ubuntu, you got troubles. You may have to drop back to an earlier version.</p>
<p>I find it absolutely astounding that the bug appeared in Ubuntu 8.04 (April 2008... |
Retrieving the calling method name from within a method <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/171970/how-can-i-find-the-method-that-called-the-current-method">How can I find the method that called the current method?</a> </p>
</blockquote>
<p>I have... | <p>In .NET 4.5 / C# 5, this is simple:</p>
<pre><code>public void PopularMethod([CallerMemberName] string caller = null)
{
// look at caller
}
</code></pre>
<p>The <strong>compiler</strong> adds the caller's name automatically; so:</p>
<pre><code>void Foo() {
PopularMethod();
}
</code></pre>
<p>will pass i... |
How do I access a control in the HeaderTemplate of my GridView <p>I want to have a DropDownList in the header of my GridView. In My codebehind I can't seem to access it. Here is the HeaderTemplate:</p>
<pre><code><asp:TemplateField SortExpression="EXCEPTION_TYPE">
<HeaderTemplate>
<asp:Label... | <p>With Repeaters, you access headerTemplate items by using FindControl in the OnItemDataBoundEvent like this:</p>
<pre><code>RepeaterItem item = (RepeaterItem)e.Item;
if (item.ItemType == ListItemType.Header) {
item.FindControl("control"); //goes here
}
</code></pre>
<p>Does this work for GridViews as well?</p>
|
Is it ok to set Datacontext as a property in repository? <p>Is there any potential problem in setting datacontext as property like this:</p>
<p>repository</p>
<pre><code>public Repository()
{
public DataContext dc {get;set;}
public GetOrders(int id)
{ ...from dc.Orders...}
}
</code></pre>
<p>service... | <p>From what I have read, using the DataContext "<a href="http://odetocode.com/Blogs/scott/archive/2008/12/11/12384.aspx" rel="nofollow">for more than one business conversation is <strong>usually the wrong thing to do</strong></a>." Scroll down to the <strong>Why Is This Important?</strong> section for the quote. Due t... |
Sending Multi-threaded SendEmail request returns General Mapi Failure <p>I'm using the <a href="http://www.codeproject.com/KB/IP/SendFileToNET.aspx" rel="nofollow">MAPI code by Dave Brooks</a>.</p>
<p>I am attempting to programatically send out a Crystal Report that is generated.</p>
<p>When I run through the code wi... | <p>I encountered this same error (General MAPI failure [2]) and came across this solution early in my debugging; however, the cause for my error was due to running my application as administrator while outlook was running as my user. I had a hard time finding the cause of my error so hopefully this will help someone o... |
Orm tool not allowed: What do you do? <p>Let's say you're in an IT shop that allows no ORM tool of any kind. They don't want to buy one, and neither can you use an open source solution.</p>
<p>What would you do? Give up on a real domain model and work table-centric? Craft own DAL?</p>
| <p>Strictly speaking your options are:</p>
<ol>
<li>Don't use a relational database</li>
<li>Don't use an OOP language</li>
</ol>
<p>Otherwise some kind of ORM solution is inevitable (even if you roll your own, its still a simple ORM layer).</p>
|
print from html pages in A4 <p>I am designing this site which is for technical engineers to take prints from and the page sizes are varied. When pages are printed tables get cut up into 2 halves which makes it difficult for them to read. Is there any code which can make the prints fit into one A4 sheet per page.</p>
<... | <p>Try using the CSS media attribute to specify different CSS for printing.</p>
<p>You also need to bear in mind that each browser will implement printing in its own way (just like CSS rendering).</p>
|
Reset scroll position after Async postback - ASP.NET <p>What is the best way to reset the scroll position to the top of page after the an asynchronous postback? </p>
<p>The asynchronous postback is initiated from a ASP.NET GridView CommandField column and the ASP.NET update panel Update method is called in the GridVi... | <p>As you're using UpdatePanels you're going to need to hook into the ASP.NET AJAX <a href="http://msdn.microsoft.com/en-us/library/bb311028.aspx">PageRequestManager</a></p>
<p>You'll need to add a method to the <a href="http://msdn.microsoft.com/en-us/library/bb383810.aspx">endRequest</a> event hooks that are:</p>
<... |
Reasons for stack unwinding fail <p>I was debugging an application and encountered following code:</p>
<pre><code>int Func()
{
try
{
CSingleLock aLock(&m_CriticalSection, TRUE);
{
//user code
}
}
catch(...)
{
//exception handling
}
return -1;
}
</code></pre>
<p>m_CriticalSection is C... | <p>Are you getting an abnormal program termination? </p>
<p>I believe your <code>CCriticalSection</code> object will be released <code>CSingleLock</code>'s destructor. The destructor will get called always since this is an object on the stack. When the usercode throws, all stacks between the <code>throw</code> and the... |
Making a CSS footer either sit at the bottom of the browser window or bottom of content <p><strong>Duplicate of <a href="http://stackoverflow.com/questions/42294/how-do-you-get-the-footer-to-stay-at-the-bottom-of-a-web-page">this question</a>.</strong></p>
<p>I've got an existing site (<a href="http://www.jacquelinewh... | <p>This one's always worked well for me: <a href="http://ryanfait.com/sticky-footer/">CSS Sticky Footer</a></p>
|
Multiple inheritance + virtual function mess <p>I have a diamond multiple inheritance scenario like this:</p>
<pre><code> A
/ \
B C
\ /
D
</code></pre>
<p>The common parent, A, defines a virtual function fn().<br />
Is it possible for both B and C to define <code>fn()</code>?<br />
If it is, then ... | <p>Unless you overwrite <code>fn</code> again in <code>D</code>, no it is not possible. Because there is no final overrider in a D object: Both <code>C</code> and <code>B</code> override <code>A::fn</code>. You have several options:</p>
<ul>
<li>Drop either <code>C::fn</code> or <code>B::fn</code>. Then, the one that ... |
Cocoa/iPhone: How to I keep ibtool from outputing non-localizable strings in a xib file? <p>I'm working on internationalizing an iPhone application, and I'm using ibtool to extract the string from my xib files so they can be translated by a localization house like so:</p>
<pre><code>ibtool --generate-strings-file Blah... | <p>Ibtool is extremely verbose in its string-files output and generates stirngs by object-id, instead of by unique source string. This type of output is extremely useful when you're trying to re-create interface builder or otherwise need extensive control over the objects in your xib files, but less so when you simpl... |
Python in tcsh <p>I don't have much experience with tcsh, but I'm interested in learning. I've been having issues getting Python to see PYTHONPATH. I can echo $PYTHONPATH, and it is correct, but when I start up Python, my paths do not show up in sys.path. Any ideas?</p>
<p>EDIT:</p>
<pre><code>[dmcdonal@tg-steele ~]$... | <p>How are you setting PYTHONPATH? You might be confusing tcsh's set vs. setenv. Use "set" to set what tcsh calls <em>shell variables</em> and use "setenv" to set <em>environment variables</em>. So, you need to use setenv in order for Python to see it. For example:</p>
<pre><code>$ set FOO='bar'
$ echo $FOO
bar
$ ... |
Upgrading Python on OS X 10.4.11 <p>I downloaded a package installer for Python 2.6.1, but when I use the python command in terminal (bash) Apple's shipped 2.3.5 version loads up. How can I get 2.6.1 to load up instead? </p>
| <p>You probably need to edit your ~/.profile file. It contains your PATH variable, which tells the command line where to find things. You can do so like this:</p>
<pre><code>export PATH=/path/to/new/python:$PATH
</code></pre>
<p>That puts your new path as the first place to look.</p>
|
Sharepoint custom web part property does not show up in the toolbox <p>I have defined a boolean property as follows:</p>
<pre><code> [Browsable(true), Category("Display"), DefaultValue(false),
WebPartStorage(Storage.Shared), FriendlyName("Obey Workflow"),
Description("")]
public bool ObeyWorkflow { get; set; }
<... | <p>You are on the right track. You just need to use different attributes.</p>
<pre><code>[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[Category("Display")]
[WebDisplayName("Obey Workflow")]
[Description("")]
public bool ObeyWorkflow { get; set; }
</code></pre>
|
Windows chooses wrong icon from multi-icon file and self renders to correct size <p>I have an .ico file with 5 icon sizes embedded in it being used as the main application icon and the System Tray icon.</p>
<p>When it shows up in the task bar the icon is using the 16x16 format which is desired.
When the icon shows up ... | <p>Both responses are close, but contain a subtle poison. You should not hardcode the requested size as 16x16.</p>
<p>Instead, query SystemInformation.SmallIconSize to determine the appropriate dimensions. Although the default is certainly 16x16, this could be changed by various things, such as DPI scaling.</p>
<p>Se... |
Possible to have a inner control on a custom server control? <p>I would like to be able to do something like:</p>
<pre><code><ui:Tab Title="A nice title">
<TabTemplate>
<asp:Literal runat="server" ID="SetMe">With Text or Something</asp:Literal>
</TabTemplate>
</ui:Tab>
</cod... | <p>The ParseChildren attribute tells .NET whether to treat your control's children as properties or as controls. For your first example, you want to treat children as controls, so add</p>
<pre><code>[ ParseChildren(ChildrenAsProperties = false) ]
</code></pre>
<p>For the second, you want ChildrenAsProperties=true, a... |
How to close command windows with Java <p>Each time I use <code>Runtime.exec("cmd /c start....")</code> I am opening a cmd window. I would like to create a more seamless application by closing each previous cmd window. How can I do this?</p>
<p>If anyone knows of a better way to run a series of commands in the same cm... | <p>Don't use start, that opens another window</p>
<p>Replace: </p>
<pre><code>Runtime.exec("cmd /c start....")
</code></pre>
<p>with: </p>
<pre><code>Runtime.exec("cmd /c ....")
</code></pre>
|
javascript hangs browser <pre><code>xmlDoc.load("cd_catalog.xml")
var cd=xmlDoc.getElementsByTagName("CD");
var id_set=1;
var id=xmlDoc.getElementsByTagName("ID"+id_set);
i=0;
function next()
{
if (i<id.length-1)
{
i++;
display();
}
}
function display()
{
document.write('<div class="dd">')
d... | <p>That <a href="http://stackoverflow.com/questions/575222/newbie-hanging-browser-on-function-call">related queston</a> <em>does</em> help. You can't use <code>document.write()</code> after the document has finished loading. See the answer to that other question for how to replace <code>document.write()</code>.</p>
|
What's the Point of Selenium? <p>Ok, maybe I'm missing something, but I really don't see the point of Selenium. What is the point of opening the browser using code, clicking buttons using code, and checking for text using code? I read the website and I see how in theory it would be good to automatically unit test your ... | <p>It allows you to write functional tests in your "unit" testing framework (the issue is the naming of the later).</p>
<p>When you are testing your application through the browser you are usually testing the system fully integrated. Consider you already have to test your changes before committing them (smoke tests), ... |
linq cache and disposing datacontext <p>After disposing my datacontext, linq still holds data for other separate calls with new datacontext to those entities. Shouldnt this have been been cleared? </p>
| <p>You might be holding a reference to one of the entities. They internally point to the DataContext. If that is the case, you are looking how to change the context of the entities, regardless of what you are trying to free with dispose. Disclaimer: I don't know if dispose is supposed to clear the tracked entities list... |
Why can I not see the VS 2005 dataset visualizer anymore? <p>I cannot see the magnifying glass next to my <code>Dataset</code> anymore. Is there a way to re-enable it?</p>
| <p>I had a similar problem, and found a solution: <a href="http://stackoverflow.com/questions/239206/datatable-visualizer-disappeared-from-my-visual-studio/1978806#1978806">solution to disappearing dataset visualizer</a></p>
|
How do you spoof HTTP_REFERER? <p>I need to try and spoof the HTTP_REFERER passed my another page so that in the destination page, I can determine of the request is coming in from the "right" page and perform appropriate logic.</p>
<ol>
<li>How do I do that in JavaScript (AJAX)?</li>
<li>Can I do that in ASP.Net?</li>... | <p>Generally speaking, you cannot cause other browsers to return a false HTTP_REFERER without an exploit, plug-in, or other extension. If you want to modify the value sent from your web browser and you are using FireFox, look at the <a href="http://modifyheaders.mozdev.org/">Modify Headers</a> extension.</p>
<p>In an... |
What would you name this object? <p>So I have a table like so:</p>
<pre><code> =========================
ID | Col2 | col3 | col4 |
=========================
-> 21 | balh | blah | foo |
22 | balh | blah | foo |
</code></pre>
<p>I am making a object that can read the data from one row using the column n... | <p>RowReader?</p>
<p>Code would look like (some variations of the Get naming)</p>
<pre><code>var reader = new RowReader(sourceRow);
//var value = reader.GetValue(col => col.Col2);
//var value = reader.ByColumn(col => col.Col2);
//var value = reader.ReadColumn (col => col.Col2);
</code></pre>
<p>Based on in... |
Unmanaged x64 assemblies in mixed .NET development environment <p>What do we do if we have some devs working on 64 bit machines and some on 32 bit machines, but we need to reference unmanaged assemblies that need to be in x86 for half the team and x64 for the other half? Is there a solution besides manually updating th... | <p>You want to do this as part of your build, right?</p>
<p>Write a pre-build step to copy the referenced DLL from a permanent position in your source tree to the local project. Use the $(ConfigurationName) or $(PlatformName) macro to select which version of the unmanaged DLL actually gets copied. You just keep your D... |
Query duration estimation in SQL Server <p>I've seen in Oracle 10g a feature that estimates the remaining time for a long running query and I was wondering if this is possible too in SQL Server (at least in 2008?)?</p>
<p>Suppose I have a very large table with tens of millions of rows (well indexed etc. etc.) and I ne... | <p>I'd forget about it and just put a spinning circle!</p>
<p>Seriously though, to take MrTelly's idea further, there are dynamic management views that can give you average execution times for certain queries - maybe that can get you somewhere.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms188754.aspx" re... |
What's a better way to sort by day date? <p>I have an Array of Events and I want to divide them into a 2-dimensional Array based on event_date (which returns a Time object). But I want it to be by the day part of the date. Here's what I have so far:</p>
<pre><code>def divide_events_by_day(events)
# Sort, so we can s... | <p>For a start, you could try something like this:</p>
<pre><code>def divide_events_by_day(events)
days = [[]]
events.sort_by { |x| x.event_date }.each { |e|
if days.last.empty? or days.last.event_date_date == e.event_date.date
days.last << e
else
days << ... |
Export Orders from Magento for shipment <p>I am working on an online store on the Magento platform and have hit a major roadblock: For some reason <strong>I cannot figure out how to export current orders (with shipping information/shipment type/etc).</strong> Does anyone have any suggestions? This seems as if it should... | <p>Seeing as you want this for shipping you might want to ask whoever handles your shipping whether they have some sort of API so you can build/buy/download an appropriate shipping module and spare yourself the hassle of mucking about with CSV files.</p>
<p>If you really want a CSV file however I can show you how to c... |
What makes an application or a software development process "Enterprise"? <p>After reading <a href="http://stackoverflow.com/questions/437/what-is-your-solution-to-the-fizzbuzz-problem/1902#1902">Wolfbyte's answer</a> on <a href="http://code.google.com/p/fizzbuzz/">Enterprise FizzBuzz</a> I have thought about what cons... | <p>What "enterprise-level" really means is:</p>
<ul>
<li>Compatibility with architectural schemes and long-term technical plans that overarch anything you or your team will ever do, and thus cannot be changed.</li>
<li>Conforms to governance requirements</li>
<li>Expensive to build and maintain ;)</li>
</ul>
<p>Has t... |
Referring to a div inside a div with the same ID as another inside another <p>How can I refer to a nested div by id when it has the same id as a div nested in a similarly named div</p>
<p>eg</p>
<pre><code><div id="obj1">
<div id="Meta">
<meta></meta>
</div>
</div>
... | <p>IDs should only be used when there is one of that item on the page, be it a SPAN, DIV or whatever. CLASS is what you should use for when you may have a repeating element.</p>
<p>Code there doesn't work because you're referring to an element by unique ID, but have more than one on the page.</p>
|
Installing PL/Ruby for PostgreSQL 8.3 <p>This is to enable the development of <strong>postgres</strong> functions with embedded <strong>ruby</strong> code,
but I have been unable to build it.</p>
<p>As advised by
<a href="http://www.robbyonrails.com/articles/2005/08/22/installing-untrusted-pl-ruby-for-postgresql">http... | <p>OK, I managed to <strong>hand build</strong> this (bypassing the <em>fragile</em> extconf.rb and makefile) by googling for a logfile of
a successful build, starting with the gcc lines I saw there, then fiddling with the gcc compile
flags and paths until it worked.</p>
<p>In plruby.h change the SAFE_LEVEL to 0
as sh... |
Can I develop an iPhone app using java? <p>Is it possible to develop applications for the iPhone using Java? And if so, does it allow the use of custom jar files?</p>
<p>Thanks.</p>
| <p>Originally the reply was a no. The Apple agreement used to say that no interpreted/other languages are allowed. period.</p>
<p>This has since changed and there are several such solutions: </p>
<p>Codename One - focuses on building applications using Java with visual tools and simulators. Open source with a SaaS... |
Django flatpages backup? <p>I'm using <a href="http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/">flatpages</a> in a site that I'm developing in a locally server. I need to backup the flatpage's data for use it in the final server. Does anyone know how to do it?</p>
| <p>On your local server run this:</p>
<pre><code>python manage.py dumpdata flatpages --indent=2 > backup.json
</code></pre>
<p>Then copy backup.json to your final server and load it with:</p>
<pre><code>python manage.py loaddata backup.json
</code></pre>
|
What IDE has the strongest support for Symfony framework? <p>I'm looking for an IDE with use with the <a href="http://www.symfony-project.org">Symfony Framework</a>.</p>
<p>I have a bit of experience using the <a href="http://www.netbeans.org">NetBeans 6.5 IDE</a> but it does not always seem to complete the class meth... | <p>If you could wait, Symfony support is coming to Netbeans soon: <a href="http://www.netbeans.org/issues/show%5Fbug.cgi?id=145913">http://www.netbeans.org/issues/show_bug.cgi?id=145913</a>. I'll go with Zend Studio 5.5's debugging and inspection features for the time being. </p>
|
Simple query to a WSS/MOSS list from remote client <p>What is the simplest way to query a WSS/MOSS list from a remote client</p>
<p>Using /_vti_bin/lists.asmx and XML fragments for the query seems to be a large chunk of work for a simple task?</p>
<p>I have found the <a href="http://www.u2u.info/Blogs/karine/Lists/Po... | <p>If you write in .NET, reference Microsoft.SharePoint.Dll, get an instance of SPWeb and through that an instance of your list. Then you can access it directly, or create a CAML query through defining an SPQuery q, setting the CAML query string to q.Query and getting the SPListItemCollection col = list["myList"].GetIt... |
Adding Icon on desktop of iPhone <p>I want to place an icon on the iPhone screen form my application, like placing an icon and if i will touch that icon it will do the desired operation, like opening a sound file or an image.</p>
<p>So i want to ask is it possible to place an icon on screen through an application and... | <p>You can't do that. The only icon that will appear on the iPhone home screen will be the icon for your application itself.</p>
<p>Edit:</p>
<p>Expanding on the web shortcut idea suggested by Gene, it <em>might</em> be possible you achieve what you want by having a web short cut using a specific protocol handler to ... |
Deployment prerequisites best practice <p>I have an application that requires .NET Framework 3. I am planning to deploy the application using a Setup Kit built by VS2005 deployment project.
What is the best practice to include the last known .NET version (3.5 SP1 in my case) bootstrapper with the deployment package o... | <p>In this special case, I would prefer the latest version and also bind to it, because the 3.0 version was kind of rushed just because Vista had to ship. On the other hand, this means that 3.0 is preinstalled on Vista, which simplifies your deployment. And installing 3.0 on a 3.5SP1 machine will just skip the installa... |
How to get a custom object out of a generic List with LINQ? <p>Why do I get the following error in the following code?</p>
<p>I thought if I put custom objects in a generic List of its type then IEnumerable would be taken care of? What else do I need to do to this List to use LINQ on it?</p>
<blockquote>
<p>Cannot ... | <p>You need to add a call to <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.single.aspx" rel="nofollow"><code>Single()</code></a> - otherwise it's returning a <em>sequence</em> of customers.</p>
<p>At the same time, there's no real need to use a query expression here. It'll be simpler to use d... |
escaping bracket in postgresql query <p>I am trying to escape a bracket in a pattern matching expression for PostgreSQL 8.2</p>
<p>The clause looks something like:</p>
<pre><code>WHERE field SIMILAR TO '%UPC=\[ R%%(\mLE)%'
</code></pre>
<p>but I keep getting:</p>
<pre><code>ERROR: invalid regular expression: brack... | <p>Try this:</p>
<pre><code>select '%UPC=\[ R%%(\mLE)%';
WARNING: nonstandard use of escape in a string literal
LINE 1: select '%UPC=\[ R%%(\mLE)%';
^
HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
?column?
------------------
%UPC=[ R%%(mLE)%
(1 row)
</code></pre>
<p>You ne... |
Detecting an object on the image based on geometrical form <p>I have a basic understanding in image processing and now studying in-depth the "Digital Image Processing" book by Gonzales, but have an urgent task and will appreciate help from somebody experienced in this area.</p>
<p>When image given and object of intere... | <p>You may try using Histograms of Oriented Gradients (also called Edge Orientation Histograms). We have used them for detecting road signs. <a href="http://en.wikipedia.org/wiki/Histogram%5Fof%5Foriented%5Fgradients">http://en.wikipedia.org/wiki/Histogram_of_oriented_gradients</a> and the papers by Bill Triggs should ... |
how to pass an array of object (Users in my case) to jQuery script from controller <p>I can't understand how to use variables initialized in the controller, for example, to jQuery script (autocomplete in my case). So I'm using Rails and get my authors list. How can I refernce them in jQuery script where I' d like to us... | <p>You can do it like this.</p>
<pre><code><script type="text/javascript">
var authors = <%= Author.find(:all).to_json -%>;
$(document).ready(function() {
$("#book_author").autocomplete(authors, options ); });
</script>
</code></pre>
<p>The Json string will be evaluated directly in JavaSc... |
Is it safe to inject an EJB into a servlet as an instance variable? <p>We all know that in the web tier there is the possibility that only a single instance of a given Servlet exists which services multiple requests. This can lead to threading issues in instance variables.</p>
<p>My question is, is it safe to inject a... | <p>It is safe to inject an EJB in a Servlet as a Servlet instance variable, as long as the EJB is Stateless. You MUST NEVER inject a Stateful Bean in a Servlet.</p>
<p>You must implement your EJB stateless in that it doesn't hold any instance variable which itself holds a stateful value (like Persistence Context). If ... |
C# data allocation problem <p>I have the following problem. I have a C++ dll, containing the function</p>
<pre><code>void cpp_send (void *data_, size_t size_, free_fn *ffn_)
{
//sends data
}
</code></pre>
<p>then I have C# dll that has a class</p>
<pre><code>public class CS_dll : IDisposable
{
void cs_send (... | <p>You are sending 5 parameters to a function that receives only 3?</p>
<p>Edit: Thanks for fixing the code. You say it fails with some types of data. Can you say which type?</p>
|
Date Culture Format Problems <p>I have been having problems working with dates. I need to have a DateTime instance that has the "dd-MM-yyyy" format. I'm NOT asking to have a string of my date instance in the "dd-MM-yyyy", that I know. </p>
<p>I need to seed my date obj through the Entity framework, that calls a stored... | <p>DateTimes don't have a format. Neither are they instances, since DateTime is a value type.</p>
<p>It seems to me you think the DateTime is 'incorrectly formatted' (you claim it is 03/19/2009). How did you check the value of odate? By printing it out as odate.ToString(), or checking its value in a debugger window? T... |
What is the best way to implement versioning to a MYSQL database? <p>I have to produce a versioning system to store multiple versions of my articles in a database to allow the user to roll-back if required. My first thoughts are when the user wants to edit an article really I get the sql to no longer update but you ins... | <p>Have 2 tables:</p>
<ul>
<li>article: here you store article_id, article name and any other meta data</li>
<li>article_version: Here you store each version of the article (including the original one) and link with article_version.article_id=article.article_id. Be sure to add a timestamp and version etc in this table... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.