instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I would like to debug my separately running JSP/Struts/Tomcat/Hibernate application stack using the Eclipse IDE debugger. How do I setup the java JVM and eclipse so that I can set breakpoints, monitor variable values, and see the code that is currently executing?</p>
| <p>I just Googled it. :)</p>
<p><a href="http://bugs.sakaiproject.org/confluence/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging" rel="noreferrer">http://bugs.sakaiproject.org/confluence/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging</a></p>
<p>Many more on google.</p>
<p>Effectively, set your JPDA setting... | <p>Follow these steps:</p>
<ol>
<li><p>Add the following arguments to the <code>java</code> command that is used to launch Tomcat (on Windows, I think this is in TOMCAT\bin\catalina.bat)</p>
<p>-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n</p></li>
<li><p>In Eclipse, create a 'Remote Java Appl... | 9,337 |
<p>I have been thinking about starting a side project at home to exercise my brain a bit. <a href="http://en.wikipedia.org/wiki/Reversi" rel="nofollow noreferrer">Reversi</a> looks like a simply game, where mobility has a profound effect on game play.
It is at least a step up from tic tac toe. This would be a singl... | <p>In overall, issues you will end up running onto will depend on you and your approaches. Friend tends to say that complex is simple from different perspective.</p>
<p>Choice of graphics library depends about what kind of game you are going to write? OpenGL is common choice in this kind of projects, but you could als... | <p>Reversi should be a very simple game to implement. It is perfect to learn some basic algorithms of games theory (specifically min-max) during the implementation of the AI.</p>
<p>One thing to note on the AI is that it is perfectly possible to make a perfect AI for Reversi (one that always wins no matter the moves o... | 24,323 |
<p>I want to create a unique id but <code>uniqid()</code> is giving something like <code>'492607b0ee414'</code>. What i would like is something similar to what tinyurl gives: <code>'64k8ra'</code>. The shorter, the better. The only requirements are that it should not have an obvious order and that it should look pretti... | <p>Make a small function that returns random letters for a given length:</p>
<pre><code><?php
function generate_random_letters($length) {
$random = '';
for ($i = 0; $i < $length; $i++) {
$random .= chr(rand(ord('a'), ord('z')));
}
return $random;
}
</code></pre>
<p>Then you'll want to ca... | <p>Best Answer Yet: <a href="http://www.tonymarston.net/php-mysql/converter.html" rel="nofollow">Smallest Unique "Hash Like" String Given Unique Database ID - PHP Solution, No Third Party Libraries Required.</a></p>
<p>Here's the code:</p>
<pre><code><?php
/*
THE FOLLOWING CODE WILL PRINT:
A database_id value of 2... | 39,574 |
<p>I'm looking at a batch file which defines the following variables:</p>
<pre><code>set _SCRIPT_DRIVE=%~d0
set _SCRIPT_PATH=%~p0
</code></pre>
<ul>
<li>What do <code>%~d0</code> or <code>%~p0</code> actually mean?</li>
<li>Is there a set of well-known values for things like current directory, drive, parameters to a ... | <p>The magic variables <code>%</code><em>n</em> contains the arguments used to invoke the file: <code>%0</code> is the path to the bat-file itself, <code>%1</code> is the first argument after, <code>%2</code> is the second and so on.</p>
<p>Since the arguments are often file paths, there is some additional syntax to e... | <p>It displays the current location of the file or directory that you are currently in. for example; if your batch file was in the desktop directory, then "%~dp0" would display the desktop directory. if you wanted it to display the current directory with the current file name you could type "%~dp0%~n0%~x0".</p>
| 13,721 |
<p><strong>Is there a way of forcing a (child) class to have constructors with particular signatures or particular static methods in C# or Java?</strong></p>
<p>You can't obviously use interfaces for this, and I know that it will have a limited usage. One instance in which I do find it useful is when you want to enfor... | <p>Using generics you can force a type argument to have a parameterless constructor - but that's about the limit of it.</p>
<p>Other than in generics, it would be tricky to actually <em>use</em> these restrictions even if they existed, but it could sometimes be useful for type parameters/arguments. Allowing static mem... | <p>Well, I know from the wording of your question you are looking for compile-time enforcement. Unless someone else has a brilliant suggestion/hack that will allow you to do this the way you are implying the compiler should, I would suggest that you could write a custom MSbuild task that did this. An AOP framework lik... | 19,490 |
<p>Following on from <a href="https://stackoverflow.com/questions/371418/can-you-represent-csv-data-in-googles-protocol-buffer-format">this</a> question, what would be the best way to represent a System.Decimal object in a Protocol Buffer?</p>
| <p>Well, protobuf-net will simply handle this for you; it runs off the properties of types, and has full support for <code>decimal</code>. Since there is no direct way of expressing <code>decimal</code> in proto, it won't (currently) generate a <code>decimal</code> property from a ".proto" file, but it would be a nice ... | <p>I put together a patch for protobuf-csharp-port with hooks which generates protobuf classes with native Decimal and DateTime structs. Wire format wise, they are represented by two "built-in" proto messages.</p>
<p>Here is the link:
<a href="https://code.google.com/p/protobuf-csharp-port/issues/detail?can=2&star... | 48,566 |
<p>I have a list of objects I wish to sort based on a field <code>attr</code> of type string. I tried using <code>-</code></p>
<pre><code>list.sort(function (a, b) {
return a.attr - b.attr
})
</code></pre>
<p>but found that <code>-</code> doesn't appear to work with strings in JavaScript. How can I sort a list of... | <p>Use <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/localeCompare" rel="noreferrer"><code>String.prototype.localeCompare</code></a> a per your example:</p>
<pre><code>list.sort(function (a, b) {
return ('' + a.attr).localeCompare(b.attr);
})
</code></pre>
<p>We forc... | <pre><code><!doctype html>
<html>
<body>
<p id = "myString">zyxtspqnmdba</p>
<p id = "orderedString"></p>
<script>
var myString = document.getElementById("myString").innerHTML;
orderString(myString);
function orderString(str) {
var i = 0;
var myArray = str.split("... | 7,412 |
<p>Why would you choose java over others? Why did you choose java to program your application?</p>
<p>Please include what you are using java for (desktop application/ web application/ mobile).</p>
| <ul>
<li>Excellent tooling: IDE, CI, etc.</li>
<li>Vast array of 3rd party libraries.</li>
<li>Huge amount of documentation available.</li>
<li>Large pool of developers available.</li>
<li>Platform ubiquitous.</li>
<li>Excellent performance.</li>
<li>Excellent specification.</li>
<li>Sturdy garbage collection.</li>
<li... | <p>Why would I choose Java? If I happened to have a team of <strike><a href="http://www.perlmonks.org/?node_id=142987" rel="nofollow noreferrer">replaceable</a> <a href="http://www.perlmonks.org/?node_id=41253" rel="nofollow noreferrer">code monkeys</a></strike> developers that knew Java better than anything else, that... | 25,720 |
<p>I have a fairly standard rails app and would like to be able to access the basic CRUD (Create, Update, Delete) operations as well as queries I have added, from an iPhone app. Rails provides the REST API for these operations more or less out of the box. </p>
<p>What is the best approach to deal with the REST/XML par... | <p>This is a common problem for me, so much so that I've been working on a port of the Rails ActiveResource framework called <a href="http://iphoneonrails.com/" rel="nofollow noreferrer">ObjectiveResource</a>. </p>
<p>We've had two releases of the project so far. 1.0 is already in use by a few applications in the App ... | <p>I recently put together a TouchJSON example that uses NSURLConnection. It's very basic but should be enough to get you started with asych loading.</p>
<p><a href="http://github.com/twoism/touchjsonexample/tree/master" rel="nofollow noreferrer">http://github.com/twoism/touchjsonexample/tree/master</a></p>
| 47,762 |
<p>Ok, here's a very short and to the point question. When trying to import a virtual PC 2004 Windows 2003 Server VM in VM Workstation 6.0.2 I'm getting an error 'unable to determine guest operating system'. Soo how to fix?</p>
| <p>From <a href="http://www.vi411.org/2007/03/08/vmware-converter-unable-to-determine-guest-operating-system.html" rel="nofollow noreferrer">here</a>:</p>
<ol>
<li><p>Make sure that that the VM is not currently running in VMware Server.</p></li>
<li><p>Make sure that VMware Server does not have a lock on the VM’s file... | <p>This is a fairly generic error from VMware Converter so I would try the following:</p>
<p>Step 1. Make sure you are running the latest version of VMware Converter. Updates seem to come pretty often for this tool.</p>
<p>Step 2. Check the VMware Converter log file. More often than not you will find the source of ... | 5,997 |
<p>I have the name of a function in JavaScript as a string. How do I convert that into a function pointer so I can call it later?</p>
<p>Depending on the circumstances, I may need to pass various arguments into the method too.</p>
<p>Some of the functions may take the form of <code>namespace.namespace.function(args[.... | <p>Don't use <code>eval</code> unless you <em>absolutely, positively</em> have no other choice.</p>
<p>As has been mentioned, using something like this would be the best way to do it:</p>
<pre><code>window["functionName"](arguments);
</code></pre>
<p>That, however, will not work with a namespace'd function:</p>
<pr... | <p>Without using <code>eval('function()')</code> you could to create a new function using <code>new Function(strName)</code>. The below code was tested using FF, Chrome, IE.</p>
<pre><code><html>
<body>
<button onclick="test()">Try it</button>
</body>
</html>
<script type="text/j... | 46,940 |
<p>I know this is not a "real" programming question. But, it relates to programming so I am going to set it anyway. I have a program that I need to test that reads the Byte Order Marker of the file to see if it is utf-8 or utf-16. My problem is I cannot find a program/text editor that will allow me to set the byte o... | <p>There is a pretty good program called <a href="http://www.babelstone.co.uk/Software/BabelPad.html" rel="nofollow noreferrer">BabelPad</a>. It will not only set the BOM, I believe it will also tel you if it is set or not. You can also do it programmitically in .Net. There is a good FAQ about this on <a href="http:... | <p>You should be able to see and edit this in Visual Studio.NET if you have it.</p>
<p>Bring up the open file dialog in Visual Studio.
Click the little triangle on the Open button, and select Open With.
Now select binary editor.</p>
<p>You should be able to edit the hex values at the beginning of the file to include ... | 24,490 |
<p>I ran into a problem a few days ago when I had to introduce C++ files into a Java project. It started with a need to measure the CPU usage of the Java process and it was decided that the way to go was to use JNI to call out to a native library (a shared library on a Unix machine) written in C. The problem was to fin... | <p><em>"I didn't like this because I have only two C files and it seemed very odd to split the source base at the language level like this"</em></p>
<p>Why does it seem odd? Consider this project:</p>
<pre>
project1\src\java
project1\src\cpp
project1\src\python
</pre>
<p>Or, if you decide to split things up in... | <p>Personally I'd separate the two, possibly even into their own separate projects, but that's when they are both separate things, much like you wouldn't put two different concepts in the same class. It's get much vaguer when they both touch the same conceptual area. Ofcourse there's always issues when it comes to buil... | 15,442 |
<p>I want to know which tool can be used to measure the cyclomatic complexity of a C source.</p>
<p>I have seen other post which ask the same question but I want to know specific tool for C source only.</p>
| <p><a href="http://www.spinroot.com/static/" rel="nofollow noreferrer">http://www.spinroot.com/static/</a></p>
| <p><a href="http://www.locmetrics.com/" rel="nofollow noreferrer">Locmetrics</a> is a nice tool, works for C (as well as others) and will give you the McCabe cyclomatic result.</p>
| 16,216 |
<p>I have a medium sized application that runs as a .net web-service which I do not control,
and I want to create a loose pythonic API above it to enable easy scripting.</p>
<p>I wanted to know what is the best/most practical solution for using web-services in python.</p>
<p>Edit:
I need to consume a complex soap WS
... | <p>If I have to expose APIs, I prefer doing it as JSON. Python has excellent support for JSON objects (JSON Objects are infact python dictionaries)</p>
| <p>Most of the packages on python that a SOAP service through them can be called works on python 2.x, but had problems on Python 3.x</p>
<p>The best fit for python 3.x that I've found is <a href="https://pypi.python.org/pypi/suds-jurko/0.6" rel="nofollow">suds-jurko</a></p>
| 4,863 |
<p>Lexical analyzers are quite easy to write when you have regexes. Today I wanted to write a simple general analyzer in Python, and came up with:</p>
<pre><code>import re
import sys
class Token(object):
""" A simple Token structure.
Contains the token type, value and position.
"""
def __init__(s... | <p>You can merge all your regexes into one using the "|" operator and let the regex library do the work of discerning between tokens. Some care should be taken to ensure the preference of tokens (for example to avoid matching a keyword as an identifier).</p>
| <p>This isn't exactly a direct answer to your question, but you might want to look at <a href="http://www.antlr.org" rel="nofollow noreferrer">ANTLR</a>. According to <a href="http://www.antlr.org/wiki/display/ANTLR3/Code+Generation+Targets" rel="nofollow noreferrer">this</a> document the python code generation target... | 16,198 |
<p>So, to simplify my life I want to be able to append from 1 to 7 additional characters on the end of some jpg images my program is processing*. These are dummy padding (fillers, etc - probably all 0x00) just to make the file size a multiple of 8 bytes for block encryption.</p>
<p>Having tried this out with a few pr... | <p>No, you can add bits to the end of a jpg file, without making it unusable. The heading of the jpg file tells how to read it, so the program reading it will stop at the end of the jpg data.</p>
<p>In fact, people have hidden zip files inside jpg files by appending the zip data to the end of the jpg data. Because o... | <p>As others have stated, you have no control how programs process image files and therefore some programs may find the images valid others may not.</p>
<p>However, there is a bigger issue here. Judging by your question, I'm deducing you're practicing "security through obscurity." It's widely considered a very bad p... | 7,377 |
<p>I am trying to combine some of my CSS and it is kind of an easy questions but I am kind of having some trouble, i have this code:</p>
<pre><code>h2.post-title, h2.post-title a{
display:block;
background-color:#000;
padding:3px;
color:#ffffff;
text-decoration:none;
text-transform:uppercase;
... | <p>If you remove the h2 font styling, it will revert to its default font size which is pretty big. You could set it up separately:</p>
<pre><code>h2.post-title {
font-size:130%;
}
</code></pre>
<p>But it will take up more space than simply setting both selectors to the same style. My advice — leave it as it is un... | <p>The thing is that "h2.post-title a" only applyes to the <a>-element of your code. The browser uses standard css on the <h2>-tag!</p>
<p>Lets have a look on your HTML:</p>
<pre><code><h2 class="post-title"><a href="#">Clickable title</a></h2>
</code></pre>
<p>You need rules to b... | 46,681 |
<p>I have a <code>rails</code> application which is still showing the cachebusting numeric string at the end of the URL for static mode, even though I have put it into the production environment. Can someone tell me what config option I need to set to prevent this behaviour...</p>
| <p>That file isn't there to break the cache during day-to-day operations. At least in theory, proxy servers are allowed to cache HTTP GET requests (as long the parameters remain the same).</p>
<p>Instead, that number is there to allow you to smoothly upgrade your CSS and JavaScript files from one version to the next. ... | <p>To disable the ?timestamp cache busting in production add this to your config/environments/production.rb</p>
<pre><code>ENV['RAILS_ASSET_ID'] = ''
</code></pre>
<p>If you want to dig deeper into what this does, check out asset_tag_helper.rb in the ActionPack gem, line 527 (ish)</p>
| 10,873 |
<p>In Sql Server 2000/2005, I have a few NT user groups that need to be granted access to hundreds of stored procedures.</p>
<p>Is there a nice easy way to do that?</p>
| <ul>
<li>Create a role in sql server.</li>
<li>Write a
script that grants that role
permission to use those sprocs.</li>
<li>Add those NT user groups to that role.</li>
</ul>
| <ul>
<li>Create a role in sql server.</li>
<li>Write a
script that grants that role
permission to use those sprocs.</li>
<li>Add those NT user groups to that role.</li>
</ul>
| 10,573 |
<p>If you have an STL vector which has been resized, is it safe to take the address of element 0 and assume the rest of the vector will follow in memory?</p>
<p>e.g.</p>
<pre><code>vector<char> vc(100);
// do some stuff with vc
vc.resize(200);
char* p = &vc[0];
// do stuff with *p
</code></pre>
| <p><strong>Yes, that is a valid assumption (*).</strong></p>
<p>From the C++03 standard (23.2.4.1):</p>
<blockquote>
<p>The elements of a vector are stored
contiguously, meaning that if v is a
vector where T is some
type other than bool, then it obeys
the identity &v[n] == &v[0] + n for
all 0 <... | <p>yes. </p>
<p>it should alway be contiguous</p>
| 30,773 |
<p>what is the best tool (open or commercial) currently available, that lets me send customized requests to a web server and get back a response to check the performance? </p>
<p>i will be sending it a load of more than 20K per second, but i need to get numbers for each call made. also, the numbers might be in some mi... | <p>If you're using Apache, Apache AB is a benchmarking to test how many requests your serve can serve per second and how well it handles load and concurrency. It's an open-source project - check it out <a href="http://httpd.apache.org/docs/2.0/programs/ab.html" rel="noreferrer">here</a>.</p>
<p>In addition, wikipedia ... | <p>You can find a <a href="http://www.opensourcetesting.org/performance.php" rel="nofollow noreferrer">list of Open Source software</a> for performance (most of them are for web that send custom request to webserver).</p>
| 45,121 |
<p>Will their be a new release of the compact framework with VS2010 and .net 4.0 and if so what new features will it include?
WPF?
linq to SQL?
etc</p>
| <p>Visual Studio 2010 only supports developing for windows phone 7. This is a silver light based framework, it does not support win forms or native code. </p>
<p>VS2010 can not be used to develop for Windows Mobile 6.5 or lower.</p>
<p>You can however install VS2008 along side VS2010.</p>
| <p>There's an unofficial release of CF 3.7 kicking around the intertubes:</p>
<p><a href="http://www.google.com/search?q=compact+framework+3.7&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1" rel="nofollow noreferrer">http://www.google.com/search?q=compact+framework+3.7&rls=co... | 30,462 |
<p>We have a netbeans project that has an xsd that we use to create a wsdl and we use the wsdl to create a webservice. Since we are using types in our xsd jaxb is used and one of our webservice methods looks like this: </p>
<pre><code>public void someMethod( org.netbeans.xml.schema.line.Line x )...
</code></pre>
... | <p>I wouldn't use HttpListener or something like that, in that way you'll come across so many issues. </p>
<p>Most importantly it'll be a huge pain to support:</p>
<ul>
<li>Proxy Keep-Alives</li>
<li>SSL won't work (in a correct way, you'll get popups)</li>
<li>.NET libraries strictly follows RFCs which causes some r... | <p>The browser is connected to the proxy so the data that the proxy gets from the web server is just sent via the same connection that the browser initiated to the proxy.</p>
| 28,048 |
<p>Assumption: live/production web app suppresses errors being shown to end-users.</p>
<p>Suppose your tech support team wants to see live data but through the eyes of the development-side of the application (maybe you want to see what errors are occurring, or want to see when you've got an issue fixed using an end-us... | <p>We replicate the data back to a different database. Yes, there is a delay, but it keeps people hands out of the production servers. This also allows us to "hide" information that tech support (and other people for that matter) aren't supposed to see.</p>
| <p>I would firstly make errors are either emailed to someone with details of how the user got there or at minimum logged so you can watch the error log while you perform similar actions to see if you get the same messages in the log.</p>
<p>And yes, copying the database on the dev server/site is probably your only opt... | 34,351 |
<pre><code>List<String> nameList = new List<String>();
DropDownList ddl = new DropDownList();
</code></pre>
<p>List is populated here, then sorted:</p>
<pre><code>nameList.Sort();
</code></pre>
<p>Now I need to drop it into the dropdownlist, which is where I'm having issues (using foreach):</p>
<pre><co... | <p>Replace this:</p>
<pre><code> ddl.Items.Add(new ListItem(nameList[name].ToString()));
</code></pre>
<p>with this:</p>
<pre><code> ddl.Items.Add(new ListItem(name));
</code></pre>
<p>Done like dinner.</p>
| <pre><code> foreach (string name in nameList){
ddl.Items.Add(new ListItem(nameList[name].ToString()));
}
</code></pre>
<p>Is your problem.</p>
<p>it should look more like</p>
<pre><code>foreach (string name in nameList){
ddl.Items.Add(new ListItem(name.ToString()));
}
</code></pre>
<p>But I actua... | 30,790 |
<p>I'm writing an application that includes a plugin system in a different assembly.</p>
<p>The problem is that the plugin system needs to get application settings from the main app (like the directory to look for plugins).</p>
<p>How is this done, or am I going about this the wrong way?</p>
<p>Edit: I was encourage... | <p>Let the main application get the plugin directory from the application settings and push it into the plugin system.</p>
| <p>Perhaps you could insert the configuration as an argument when creating the plugin?</p>
<pre><code>//Get the configuration for the current appDomain
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//Create the plugin, and pass in the configuration... | 37,412 |
<p>I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine?</p>
<p>I want to play with Python 3 while still being able to run 2.x scripts on the same machin... | <p>The official solution for coexistence seems to be the <a href="http://blog.python.org/2011/07/python-launcher-for-windows_11.html">Python Launcher for Windows</a>, PEP 397 which was included in <a href="http://www.python.org/download/releases/3.3.0/">Python 3.3.0</a>. Installing the release dumps <code>py.exe</code... | <p>I would assume so, I have Python 2.4, 2.5 and 2.6 installed side-by-side on the same computer.</p>
| 44,332 |
<p>I'm setting up some monitoring on a few SQL Servers. Currently our environment uses Hobbit Monitoring System, but we are probably migrating to Nagios pretty soon.</p>
<p>One of the DBAs recommended Spotlight to me, and it seems like a great piece of software, but here's what I'm wondering...</p>
<p><strong>Is it p... | <p>Spotlight Product Architect here - The answer to your question depends on how dirty you want to get your hands... </p>
<p>If you don't mind writing a bit of your own code, with some guidance you could extract monitored data at relatively near real-time rates from the historical repository. </p>
<p>Or you could w... | <p>I've not been able to & have been using the Quest suite for over 5 years</p>
| 28,815 |
<p>My knowledge of matlab is merely on a need to know basis, so this is probably an elementary question. Nevertheless here it comes:</p>
<p>I have got a file containing data (16-bit integers) stored in binary format. How do I read it into a vector /an array in matlab? How do I write this data to a file in matlab? Is t... | <p>As <a href="https://stackoverflow.com/questions/205735/read-and-write-fromto-a-binary-file-in-matlab#205819">Bill the Lizard</a> wrote you can use fread to load the data into a vector. I just want to expand a little on his answer. </p>
<h3>Reading Data</h3>
<pre><code>>> fid=fopen('data.bin','rb') % opens ... | <p>I usually hate seeing links in a response, but this looks pretty close:</p>
<p><a href="http://www.mathworks.com/support/tech-notes/1400/1403.html" rel="nofollow noreferrer">http://www.mathworks.com/support/tech-notes/1400/1403.html</a></p>
<p>As to the second part of performance tuning, it's been 6 years since I'... | 25,208 |
<p>Let's say I have a sequence of values (e.g., 3, 5, 8, 12, 15) and I want to occasionally decrease all of them by a certain value.</p>
<p>If I store them as the sequence (0, 2, 3, 4, 3) and keep a variable as a base of 3, I now only have to change the base (and check the first items) whenever I want to decrease them... | <p><a href="http://wiki.multimedia.cx/index.php?title=Differential_Coding" rel="nofollow noreferrer">Differential Coding</a> / <a href="http://en.wikipedia.org/wiki/Delta_encoding" rel="nofollow noreferrer">Delta Encoding</a>?</p>
<p>I don't know a name for the data structure, but it's basically just base+offset :-)</... | <p>If I understand your question right, you're rebasing. That's normally used in reference to <a href="http://en.wikipedia.org/wiki/Rebasing" rel="nofollow noreferrer">patching up addresses</a> in DLLs from a load address.</p>
<p>I'm not sure that's what you're doing, because your example seems to be incorrect. In ord... | 23,354 |
<p>With Merb 1.0 rapidly approaching, I would like to know what Merb/Rails users recommend?</p>
<p>Is it time to try Merb? What was downside for you when you switched to Merb from Rails?</p>
| <p>Yes. </p>
<p>Downsides: </p>
<ul>
<li>Lack of documentation, although this
is getting better (not really a
problem for some, as the code is
very well documented).</li>
<li>Rails plugins, Merb uses Gems, and not all have been ported (the most used ones have)</li>
<li>Doing a straight port of a Rails app, will not u... | <p>Everyone, including many from the Merb Core team have been recommended to wait for 1.0. But if you're at all curious, grab the latest Gem and start toying. Just don't expect to put it into production and hold off on any production work till 1.0 is out.</p>
| 20,596 |
<p>Who has their email fully encrypted ?</p>
<p>I would like to encrypt my email but I am not sure how to start. If I use encrypted email and I send an email to someone who does not encrypt his email how can the receiver read the email ?</p>
<p>What email client would you recommend to run on a windows systems for enc... | <p>Thunderbird with Enigmail is a great free solution for what you’d like to do. I use Outlook and PGP, but I think they’re approximately the same.</p>
<p>For a detailed explanation of <a href="http://en.wikipedia.org/wiki/Public-key_cryptography" rel="noreferrer">public/private key encryption</a> check out the wiki p... | <p>Use WinRAR, and give him the password in person.</p>
<p>WinRAR is VERY secure. There's a case where the goverment couldnt' get into files on a laptop a guy was carrying from Canada. He used WinRAR. They tried to make him give them the password, and he took the 5th. It was on appeal for s years, and the courts fina... | 28,743 |
<p>Could anyone recommend a good BAML Decompiler / Viewer besides BAML Viewer plugin for Reflector, which doesn't handle path geometry/data?</p>
| <p>You might like to have another look at the BAML addin for reflector as it's been recently updated by Andrew Smith. Have a look at his at <a href="http://agsmith.wordpress.com/2008/09/24/path-data-prefixes-and-known-colors/" rel="noreferrer">blog post</a> you'll note that he has fixed the issue with path data.</p>
| <p><a href="http://blogs.windowsclient.net/ricciolocristian/archive/2008/04/05/styles-explorer-baml-decompiler.aspx" rel="nofollow noreferrer">styles explorer</a> </p>
<p>Haven't tried it myself yet but worth a try</p>
| 14,307 |
<p>The documentation for <code>+[NSThread detachNewThreadSelector:toTarget:withObject:]</code> says:</p>
<blockquote>
<p>For non garbage-collected applications, the method <code>aSelector</code> is responsible
for setting up an autorelease pool for the newly detached thread and freeing
that pool before it exits.... | <p>Yes, you do. You're defining a self-contained piece of work which the NSOperationQueue will execute on "some" thread, so you're responsible for managing memory in that work piece.</p>
| <p>yes, you need to.</p>
<pre><code>- (void) main
{
NSAutoreleasePool *thePool = [[NSAutoreleasePool alloc] init];
//your code here
//more code
[thePool release];
}
</code></pre>
<p>if you don't create an autorelease pool, any convinience class-initializer (like [NSString stringWithFormat:]) will leak as thes... | 22,296 |
<p>I have a central authentication application on server a. Server b has one or more applications on the same domain that need to authenticate from server a. It's easy enough to set it up so that the server b apps redirect out to server a. What's not so easy is getting the ReturnURL to be absolute.</p>
<p>Here's the w... | <p>The way the standard AuthorizeAttribute works is by setting the response status code to 401 if the request is not authenticated. This kicks in the default authentication module's standard response to an unauthorized request. I assume that you're using forms-based authentication, which would build the return url ba... | <p>as <a href="https://stackoverflow.com/a/583608/80589">https://stackoverflow.com/a/583608/80589</a> but shorter:</p>
<pre><code>public RedirectResult LogOn(string returnUrl)
{
var r = new Uri(Request.Url, returnUrl).ToString();
return Redirect("https://logonserver.com/?return_url=" + Url.Encode(r));
}
</code></p... | 49,718 |
<p>I am calling a batch file from Javascript in this fashion:</p>
<pre><code>function runBatch(){
var exe = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
exe.initWithPath("C:\\test.bat");
var run = Components.classes['@mozilla.org/process/util;1'].creat... | <p>The only solution I've heard so far (that should work, although I haven't done it yet, comes from Mook in the Mozilla xulrunner IRC channel:</p>
<p><em>create</em> a temporary batch file, writing in the batch file to call and arguments to pass it. then execute the temporary batch file.</p>
<p>e.g psuedocode:</p>
... | <p>Pfft, very ugly code..
A much nicer trick is to use Win.com to spawn a 16bit subsystem of the command prompt.
Win.com will send the console to the right virtual terminal, showing you the output.</p>
<pre><code>var lPath = getWorkingDir.path + "\\..\\..\\WINDOWS\\system32\\win.com";
lFile.initWithPath(lPath);
var pr... | 40,075 |
<p>I am adding a custom background for my UINavigationBar. It works fine as long as the phone is in portrait mode. As soon as I switch to landscape mode, half the bar appears blue (the default navbar color) and half of it has my image</p>
<p>How can I stretch the image for landscape mode and make it small again for po... | <p>You probably need to set the autoresizingMask of your background image view; try using <code>UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight</code></p>
| <p>Try the simpler method of <code>[UIImage imageNamed:@"navbar_landscape.png"]</code> since a UI element is exactly what <strong>imageNamed:</strong> is intended for, as ljonesATL shows.</p>
| 49,863 |
<p>I'm using <code>ColdFusion</code> to return a result set from a SQL database and turn it into a list.</p>
<p>I need some way to generate an alphabetical navigation bar for that list. I have ColdFusion and the jQuery library available.</p>
<p>I'm looking to generate something like this:</p>
<pre><code>A | B | C |... | <p>To generate the navigation bar, you could do something like this:</p>
<pre><code><cfoutput>
<cfloop from="#asc('A')#" to="#asc('Z')#" index="i">
<a href="###chr(i)#">#chr(i)#</a>
<cfif asc('Z') neq i>|</cfif>
</cfloop>
</cfoutput>
</code></pre>
<p>(CFLOOP doe... | <p>This question was posted quite a long time ago, but there is now an open source vanilla JavaScript plugin available that will alphabetically filter any HTML list with alphabetical navigation</p>
<p>It's called <a href="https://elliottprogrammer.github.io/alphaListNav.js/" rel="nofollow noreferrer">AlphaListNav.js</... | 3,718 |
<p>So I have this code for these Constructors of the Weapon class:</p>
<pre><code>Weapon(const WeaponsDB * wepDB);
Weapon(const WeaponsDB * wepDB_, int * weaponlist);
~Weapon(void);
</code></pre>
<p>And I keep getting an error:</p>
<pre><code>1>c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(20) : erro... | <pre><code>#ifndef Weapon
#define Weapon
</code></pre>
<p>This is almost certainly going to cause weirdness; call the constant WEAPON_H instead.</p>
| <p>Just a quick note: in C++, unlike C, when a function (or destructor, in this case) doesn't have any parameter, you don't need to use (void), you just use ().</p>
| 48,723 |
<p>When I'm running a simple Ruby script, what's the easiest way to dump an object's fields to the console? </p>
<p>I'm looking for something similar to PHP's <code>print_r()</code> that will work with arrays as well.</p>
| <p>Possibly:</p>
<pre><code>puts variable.inspect
</code></pre>
| <p>pp File.stat('/tmp')</p>
<pre><code>#<File::Stat
dev=0x1000004,
ino=71426291,
mode=041777 (directory rwxrwxrwt),
nlink=15,
uid=0 (root),
gid=0 (wheel),
rdev=0x0 (0, 0),
size=480,
blksize=4096,
blocks=0,
atime=2021-04-20 17:50:33.062419819 +0800 (1618912233),
mtime=2021-04-21 11:35:32.808546288 +0800 (... | 46,188 |
<p>I need to reinforce the structure of a Microsoft Word document.<br/>
EG:</p>
<p><b>Style Question here blah blah blah</b><br/>
<i>Style Answer Here blah blahblah</i></p>
<p>The enforcement here would be the "Answer" style cannot be placed unless there is a "Question" style above it.</p>
<p>To do this I would use ... | <p>This thread <a href="https://stackoverflow.com/questions/269252/vba-event-for-document-edited">Event - Document Edited</a> relates to events for Word documents, including the Change event. Perhaps it will help.</p>
| <blockquote>
<p>Or anyone have any other ideas?</p>
</blockquote>
<p>You can have a button that open a custom dialog where the user can enter the question and answer and then press enter and then the dialog automatically format the question/answer correctly. Just one way to go.. </p>
| 34,268 |
<p>Is there a nice way to dependency inject using a jsp taglib?</p>
<p>either using ejb 3.0, spring, or guice...</p>
<p>I have a lot of services/pojos that I would like to use in my taglibs</p>
| <p>I think you want <a href="http://www.jboss.com/products/seam" rel="nofollow noreferrer">Seam</a>, it enables you to refer to a component by name. However, the released version is JSF based, but that's changing. </p>
| <p>just stumbled upon your question because I plan to do the same. You can actually use Spring and its @Configurable annotation (with AspectJ load-time or compile-time weaving) to inject services into your tag implementations. For a detailed explanation of all options have a look at Ramnivas' blog post <a href="http://... | 17,153 |
<p>I have two forms, form A and form B. These forms must differ in appearance, but they share a lot of logic. The problem is that this logic is tied to the appearance (validation on button click, events being fired, etc.). For example, I have a name field, and when the save button is pressed, I need to fire an event... | <p>You could create an object with data that is represented in both forms, and put validation logic in that object. The presentation layer should populate that object with the entered data, ask the object to validate itself, and then handle validation errors in a form-specific way. </p>
| <p>There are few ways that I can think of to refactor these forms to share logic. You could use one or more of these in conjunction:</p>
<ol>
<li>Create UI specific "bean" objects that wrap your business object and adds additional functionality that is shared between forms. This bean can do things like create tool t... | 32,424 |
<p>First of all, I'd like to say that this site is great!</p>
<p>My question is, what are the reasons for the following 2 error messages?</p>
<p>1) In VB.NET (I know this is a C# forum but my next question is from C# experience), property evaluation failed (I do this when putting a watch on an exception variable).</p... | <p>1) Could be any number of reasons. Some properties just don't work nicely in a debugger. (Imagine watching DateTime.Now for changes!)</p>
<p>2) You're trying to create an instance of a class which doesn't have an appropriate accessible constructor. Usually either the class only has static members, or there's a stat... | <p>First of all, apologies for making a duplicate thread (couldn't see this one so made another).</p>
<p>1) That makes sense. Watching datetime.now for changes will just display the time @ the time of adding a watch, cache that value, and then get the new value (Time) when checking again.</p>
<p>2) John Rudy: you are... | 22,736 |
<p>Another SSRS question here: <br />
We have a development, a QA, a Prod-Backup and a Production SSRS set of servers. <br />
On our production and prod-backup, SSRS will go to sleep if not used for a period of time. <br /><br />
This does not occur on our development or QA server.
<br />In the corporate environme... | <p>For anybody using the integrated webserver that is built into SQL Reporting Services (and hence IIS may not even be installed on the box), the setting to control this actually lives in:</p>
<pre><code>C:\Program Files\Microsoft SQL Server\
MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\rsreportserve... | <p>I vaguely recall having problems with SSRS on one machine when we changed the "Enable HTTP Keep-Alives" setting in IIS. Try toggling that checkbox (I don't remember whether it was checked or unchecked when it caused us problems).</p>
| 3,642 |
<p>How do I determine if an object reference is null in C# w/o throwing an exception if it is null?</p>
<p>i.e. If I have a class reference being passed in and I don't know if it is null or not.</p>
| <p>testing against null will never* throw an exception</p>
<pre><code>void DoSomething( MyClass value )
{
if( value != null )
{
value.Method();
}
}
</code></pre>
<hr>
<p>* never as in <em>should never</em>. As @Ilya Ryzhenkov points out, an <em>incorrect</em> implementation of the != operator for... | <pre><code>(YourObject != Null)
</code></pre>
<p>you can compare to null?</p>
<p>If it's null instead of throwing an exception you can initialize your object. You can use the Null Pattern.</p>
| 24,780 |
<p>I installed subclipse in eclipse, but I get an error message "Expected format '3' of repository; found format '5'" when I try to open a repository.</p>
<p>Here is the sequence of steps that leads to the error message.</p>
<p>Select "Window -> Open Perspective -> SNV Repository Exploring" from the Eclipse main menu... | <p>Just guessing here, but make sure your version of the libsvnjavahl libraries are the same as the version of SVN you're using.</p>
| <p>The root of the problem is that you are using an old SVN client that does not understand the newer format (5) of the SVN repository.</p>
| 16,142 |
<p>I have a python module that makes use of a huge dictionary global variable, currently I put the computation code in the top section, every first time import or reload of the module takes more then one minute which is totally unacceptable. How can I save the computation result somewhere so that the next import/reload... | <p>Just to clarify: the code in the body of a module is <em>not</em> executed every time the module is imported - it is run only once, after which future imports find the already created module, rather than recreating it. Take a look at sys.modules to see the list of cached modules.</p>
<p>However, if your problem is... | <p>Expanding on the delayed-calculation idea, why not turn the dict into a class that supplies (and caches) elements as necessary?</p>
<p>You might also use psyco to speed up overall execution...</p>
| 23,767 |
<p>What's the best way for constructing headers, and footers? Should you call it all from the controller, or include it from the view file? I'm using CodeIgniter, and I'm wanting to know what's the best practice for this. Loading all the included view files from the controller, like this?</p>
<pre><code>class Page ext... | <p>You could also try it this way -- define a default view template, which then pulls in the content based on a variable ('content' in my example) passed by the controller.</p>
<p>In your controller:</p>
<pre><code>$data['content'] = 'your_controller/index';
// more code...
$this->load->vars($data);
$this->l... | <p>It's bad practice to call views inside of other views. This could be a form of controller view mixing. The view function in CI allows you to pass a third parameter that causes it to return that view's output as a string. You can use this to create a compound view.</p>
<p>For example:</p>
<pre><code>class Page ext... | 21,302 |
<p>I have multiple iframes which are displaying same collection of data (help in asp.net Cache).</p>
<p>After the modifies the data on one of the frames, I would like all of the others to reflect the update without the need for explicit postback on each one of them. </p>
<p>So the question is: What is the easiest and... | <p>I'm yet to see an elegant iframe solution, but it's a pragmatic solutions to certain problems. Here's a few ideas:</p>
<ul>
<li>Post your changes to the top level frame and rebuild all the frames</li>
<li>Use a custom javascript to update the necessary frames on changes</li>
<li>Use a custom javascript to update th... | <p>Ok, I have implemented you second suggestion. However, in the final solution I managed to avoid usage of iframes, which is in any case much better :) </p>
<p>Thanks....</p>
| 40,530 |
<p>I wish to store a single variable in my application that will be saved between runs. This will be a version number that will be used to trigger an update option and so will change only rarely.</p>
<p>Does anyone have suggestions on the best way of implementing this? Considering it's such a simple requirement I am i... | <p>Normally, that sort of information will be held in a constant (not a variable) in the binary, and the binary will contact an external site to find out whether there is a more recent version of the software. When it downloads the new, the newly downloaded file will have a new constant embedded in it.</p>
<p>Alterna... | <p>It has already been mentioned, so I am going to elaborate on it. Create a file in your project directory that will contain the version number. Make that file a part of final SIS file by adding a line about it in the PKG file---for example, put a line in the PKG file to tell the installer to copy the file to a place ... | 48,178 |
<p>I used packager to make an executable file for the following code:</p>
<pre><code>Shoes.app do
stack :margin => 10 do
@edit = edit_box :width => 1.0 do
@para.text = @edit.text
end
@para = para ""
end
end
</code></pre>
<p>then I got error message:</p>
<p>Error in C:/Program Files/Common... | <p>Might be something <a href="http://www.mail-archive.com/ironruby-core@rubyforge.org/msg02138.html" rel="nofollow noreferrer">here</a> wherein saving the file in BOM-less UTF-8 is suggested.</p>
| <p>I had similar problems, but saving in Unix format made it work for me.</p>
<p>Though, another problem seems to be that the packaged .exe somehow caches the code to execute. If I change the source code, run packager to recreate the exe, and then starts the exe again, nothing seems to have happened to it. Even deleti... | 47,420 |
<p>I have some code doing this :</p>
<pre><code> var changes = document.getElementsByName(from);
for (var c=0; c<changes.length; c++) {
var ch = changes[c];
var current = new String(ch.innerHTML);
etc.
}
</code></pre>
<p>This works fine in FF and Chrome but not in IE7. Presumably because getElementsByNa... | <p>In case you don't know why this isn't working in IE, here is <a href="http://msdn.microsoft.com/en-us/library/ms536438(VS.85).aspx" rel="noreferrer">the MSDN documentation on that function</a>:</p>
<blockquote>
<p>When you use the getElementsByName method, all elements in the document that have the specified NAME at... | <p>getElementsByName is supported in IE, but there are bugs. In particular it returns elements whose ‘id’ match the given value, as well as ‘name’. Can't tell if that's the problem you're having without a bit more context, code and actual error messages though.</p>
<p>In general, getElementsByName is probably best avo... | 35,197 |
<p>Please anybody can tell me the questions, that can be asked in an interview for below topics</p>
<ul>
<li>Socket Programming</li>
<li>Multi-Threading</li>
</ul>
<p>An advance thanks goes to everybody who provide their time</p>
| <p><strong>Socket Programming</strong></p>
<ul>
<li>Difference between UDP and TCP.</li>
<li>Difference between asynchronous and synchronous sockets. </li>
<li>What is a packet. </li>
<li>How'd you determine if packet didn't arrive malformed.</li>
<li>How'd you determine where one packet ends and where another one sta... | <ul>
<li>Name some advantages and disadvantages of Java Sockets.</li>
<li>What is the difference between URL instance and URLConnection instance?</li>
<li>How do I make a connection to URL?</li>
<li>What Is a Socket in Java Networking and RMI?</li>
<li>What information is needed to create a TCP Socket?</li>
<li>What ar... | 21,343 |
<p>Note: while the use-case described is about using submodules within a project, the same applies to a normal <code>git clone</code> of a repository over HTTP.</p>
<p>I have a project under Git control. I'd like to add a submodule:</p>
<pre><code>git submodule add http://github.com/jscruggs/metric_fu.git vendor/plu... | <p>You can also set the HTTP proxy that Git uses in global configuration property <code>http.proxy</code>:</p>
<pre><code>git config --global http.proxy http://proxy.mycompany:80
</code></pre>
<p>To authenticate with the proxy:</p>
<pre><code>git config --global http.proxy http://mydomain\\myusername:mypassword@mypr... | <p>I got around the proxy using https... some proxies don't even check https.</p>
<pre><code>Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
c:\git\meantest>git clone http://github.com/linnovate/mean.git
Cloning into 'mean'...
fatal: unable to access 'http://git... | 15,584 |
<p>I'm adding a record like this:</p>
<pre><code> Dim pathString As String = HttpContext.Current.Request.MapPath("Banking.mdb")
Dim odbconBanking As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + pathString)
Dim sql As String
sql = "INSERT I... | <p>I believe a parameterized query would look something like this:</p>
<pre><code>Dim pathString As String = HttpContext.Current.Request.MapPath("Banking.mdb")
Dim odbconBanking As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + pathString)
Dim sql As String
sql = "INSERT ... | <p>The simplest way would be to generate your uniqueIdentifier value at the code level, add it to your string and send it to the server.</p>
<pre><code>Dim sql As String, _
myNewUserId as variant
myNewUserId = stGuidGen 'this function will generate a new GUID value)'
sql = "INSERT INTO tblUsers ( userId, LastN... | 45,001 |
<p>How do we decide on the best implementation of <code>hashCode()</code> method for a collection (assuming that equals method has been overridden correctly) ?</p>
| <p>The best implementation? That is a hard question because it depends on the usage pattern.</p>
<p>A for nearly all cases reasonable good implementation was proposed in <em>Josh Bloch</em>'s <strong><em>Effective Java</em></strong> in Item 8 (second edition). The best thing is to look it up there because the author ... | <p>For a simple class it is often easiest to implement hashCode() based on the class fields which are checked by the equals() implementation.</p>
<pre><code>public class Zam {
private String foo;
private String bar;
private String somethingElse;
public boolean equals(Object obj) {
if (this == ... | 13,861 |
<p>If I wrap a SQLConnection in a Using, should I close it or does the end using handle it?</p>
<pre><code>using cn as new system.data.sqlclient.sqlconnection()
cn.open
'{do a bunch of other stuff with commands and datareaders here}
cn.close 'Do I need this?
end using
</code></pre>
| <p>Exiting a using block calls .Dispose() on the object in question (<code>cn</code> in your example) which for a SqlConnection will close the connection and any open resources.</p>
| <p>using is just a shorthand to try/finally. this is equivilent code to what you posted</p>
<pre><code>Try
SqlConnection cn as new system.data.sqlclient.sqlconnection()
cn.open
'{do a bunch of other stuff with commands and datareaders here}
cn.close 'Do I need this?
Finally
cn.Dispose()
End Try
</c... | 49,213 |
<p>This problem crops up every now and then at work. Our build machine can have it's files accessed via a normal windows file share. If someone browses a folder remotely on the machine, and leaves the window open overnight, then the build fails (as it has done now). The explorer window left opened points at one of the ... | <p>Found a solution.</p>
<ol>
<li><p>Find the process using <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="noreferrer" title="Process Explorer from SysInternals">Process Explorer</a>:</p>
<ol>
<li>Download and extract <a href="http://download.sysinternals.com/Files/ProcessExplorer.zip" r... | <p>Another option is, starting from Windows Vista, to use the Windows tool built into the system: </p>
<p>monitor resources: <code>perfmon.exe /res</code></p>
<p>Extracted from: <a href="http://Http://www.sysadmit.com/2017/06/windows-how-to-know-that-process-has-open-a-file.html" rel="nofollow noreferrer">Http://www.... | 41,403 |
<p>I have a project that I would like to start beta testing soon, it is a PHP/MySQL site for programmers. I have beta tested sites before however it was always in-house, and I have never done betas that could/should be seen by someone other then those associated with the project.</p>
<p>How should I go about starting ... | <p>First, accept the fact that problems with your app (code, usability, etc.) will be discovered.</p>
<p>Then, make sure you have a clear way for users to communicate with you (form mail, email, uservoice, etc.). The easier you make this the better. For example, there is a uservoice link on every page of SO.</p>
<p>O... | <p>Beta testing is a part of acceptance testing.
This type of testing will ensure the customer about the functionality and quality of the product.
Beta testing is done on customers end in an uncontrolled environment.
In beta testing customer driven test cases are written and he can enter whatever he wants to enter.
Her... | 6,021 |
<p>I have a static object at runtime that is basically a list of other objects (ints, strings, Dictionary, other objects, etc). Is there way to determine the memory used by my static "list of other objects" object at runtime? This would be handy for instrumentation and reporting purposes.</p>
| <p>You are probably asking for something you could call from your code (which I would like to know too), but I felt I should mention Ants profiler [<a href="http://www.red-gate.com/Products/ants_profiler/index.htm]" rel="nofollow noreferrer">http://www.red-gate.com/Products/ants_profiler/index.htm]</a> in case others a... | <p>Thanks for the replies. I think my initial plan of attack, because I'm sure most of the objects will be serializable, will be something like this:</p>
<pre><code>using (MemoryStream memstream = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
try
{
formatter.Serialize(m... | 27,583 |
<p>I'm considering using Amazon's EC2 with a windows instance & SQL. I've seen <a href="http://www.brentozar.com/archive/2008/11/bad-storage-performance-on-amazon-ec2-windows-servers/" rel="noreferrer">some criticism</a> of the perf of the SQL instances here. I'm wondering if any SOers have and first hand experien... | <p>I've just fired up a 32bit Server 2003 m1 small instance with SQL 2005 Express on and had a quick play. Was just using the supplied machine disk, not an attached volume. After reading the article linked to in your post I was expecting performance to be horrific. It wasn't great, but wasn't bad either.</p>
<p>My 'te... | <p>My limited experience so far shows that using Elastic Block Storage for your database storage is essential. When using EBS, performance seems roughly comparable to a stand-alone dev machine. I haven't yet run detailed performance stats - just an overall feel.</p>
| 35,206 |
<p>How can I pad a string with spaces on the left when using printf?</p>
<p>For example, I want to print "Hello" with 40 spaces preceding it.</p>
<p>Also, the string I want to print consists of multiple lines. Do I need to print each line separately?</p>
<p>EDIT: Just to be clear, I want exactly 40 spaces printed b... | <p>If you want the word "Hello" to print in a column that's 40 characters wide, with spaces padding the left, use the following.</p>
<pre><code>char *ptr = "Hello";
printf("%40s\n", ptr);
</code></pre>
<p>That will give you 35 spaces, then the word "Hello". This is how you forma... | <p>If you want exactly 40 spaces before the string then you should just do:</p>
<pre><code>printf(" %s\n", myStr );
</code></pre>
<p>If that is too dirty, you can do (but it will be slower than manually typing the 40 spaces):
<code>printf("%40s%s", "", myStr );</code></p>
<... | 37,455 |
<p>I installed CruiseControl.net ( from the CruiseControl.NET-1.4-Setup.exe installer ) on my Vista x64 development machine. The server portion is running fine; however, the webdashboard piece is not working.</p>
<p>The first error message I saw when I tried to pull up <a href="http://localhost/ccnet" rel="nofollow n... | <p>Here's the top of the HTTP 500 error dump I was getting:</p>
<blockquote>
<p>HTTP Error 500.0 - Internal Server Error</p>
<p>Description: The page cannot be displayed because an internal server error has occurred. </p>
<p>Error Code: 0x800700c1 </p>
<p>Notification: ExecuteRequestHandler </p>
... | <p>This post seems to indicate that a host of problems can occur w/ IIS and 64-bit OS. Check out the link for some ideas on resolving it: <a href="http://blog.danbartels.com/archive/2005/05/18/662.aspx" rel="nofollow noreferrer">http://blog.danbartels.com/archive/2005/05/18/662.aspx</a></p>
| 20,599 |
<p>The <a href="http://msdn.microsoft.com/en-us/library/y23b5415.aspx" rel="nofollow noreferrer">official guidelines</a> suggest that there can be very few practical uses for these. Does anyone have examples of where they've put them to good use?</p>
| <p>Au Contrare... you'll find C/C++ people flocking to structs a.k.a. value types.<br>
An example would be data packets. If you have a large number of data packets to transfer/transmit, you'd use value structs to model your data packets.<br>
reason: Turning something into a class adds an overhead of (approx 8-16 Bytes ... | <p>Enums are first class citizens of .NET world. As for structures I found that in most cases classes can be used, however for memory-intense scenarios consider using structures. As a practical example I used structures as data structures for OSCAR (ICQ) protocols primitives.</p>
| 5,877 |
<p>I need to connect to an Exchange mailbox in a Python script, without using any profile setup on the local machine (including using Outlook). If I use win32com to create a MAPI.Session I could logon (with the Logon() method) with an existing profile, but I want to just provide a username & password.</p>
<p>Is t... | <p>I know this is an old thread, but...</p>
<p>If you're using Exchange 2007 or newer, or Office365, take a look at Exchange Web Services. It's a pretty comprehensive SOAP-based interface for Exchange, and you can do pretty much anything Outlook is able to do, including delegate or impersonation access to other user ac... | <p>You'll have to find a way to run the process as that particular user.</p>
<p><a href="http://blogs.msdn.com/mstehle/archive/2007/01/03/myth-cdo-1-21-s-session-logon-parameter-profilepassword-actually-does-something.aspx" rel="nofollow noreferrer">See this.</a></p>
<p>I think <a href="http://docs.activestate.com/ac... | 36,731 |
<p>I have a form element that contains multiple lines of inputs. Think of each line as attributes of a new object that I want to create in my web application. And, I want to be able to create multiple new objects in one HTTP POST. I'm using Javascript's built-in cloneNode(true) method to clone each line. The problem ... | <p>Don't put handler on each link (this really should be a button, BTW). Use <a href="http://www.quirksmode.org/js/events_order.html" rel="noreferrer">event bubbling</a> to handle <em>all</em> buttons with one handler:</p>
<pre><code>formObject.onclick = function(e)
{
e=e||event; // IE sucks
var target = e.tar... | <p>Looks like you're using jQuery? It has a method to clone an element with events: <a href="http://docs.jquery.com/Manipulation/clone#true" rel="nofollow noreferrer">http://docs.jquery.com/Manipulation/clone#true</a></p>
<p>EDIT: Oops I see you're using Prototype.</p>
| 4,927 |
<p>Are there any compatibility issues with running Visual Studio 6.0 (including Visual SourceSafe 6.0 Client), Visual Studio 2003 & Visual Studio 2008 on Windows Vista 64-bit?</p>
<p>Can I interactively debug the applications with the Vista Web Server? Can I still make/compile projects?</p>
<p>Is it correct to as... | <p>I can't answer for 6.0 but I have no problems whatsoever with 2003, 2005 and 2008.</p>
| <p>I read reports about VS2003 "poisoning" people's Vista systems so I didn't risk it - I instead installed it on a Virtual PC Windows XP 32-bit image. </p>
<p>Since I don't work with much .NET 1.1 code anymore I figure this is a good workaround until can get everything/everyone migrated to .NET 2.0 or later.</p>
<p>... | 25,677 |
<p>I've installed VisualSVN on my Windows Server 2008. I have several IP addresses on this server, but I want VisualSVN to only bind to one of them. By default it binds to all available addresses. How can I make VisualSVN only handle requests on one IP address?</p>
<p>I tried adding </p>
<pre><code>BindAddress xxx... | <p>To clarify, the method for binding VisualSVN to explicitly defined IP addresses is:</p>
<ol>
<li>Load the <strong>VisualSVN Server Manager</strong> MMC snap-in</li>
<li>In the left pane, right-click the <strong>VisualSVN Server</strong> item and choose <strong>Properties</strong> from the context menu</li>
<li>Clic... | <p>I found an easy way! I just upgraded to VisualSVN 1.6. Then, in the management console, right-click the VisualSVN Server node, select the Network tab, and enter your IP address(es). Cool!</p>
| 46,696 |
<p>It seems that when I use a tool (such as winmerge) to update my codebase... my Visual Studio Team System (VSTS) integration with Team Foundation Server (TFS) doesn't seem to pick it up.</p>
<p>How do I know which files to check out and check back in? Is there something I am missing? Is this a feature that isn't par... | <p>First, this is probably because the files have not yet been checked out. If you do that first before running your update, TFS will see those changes.</p>
<p>Second, you can use TFS Power Tools (available from MS) to review local repository for changes that are not recognized. If there are found differences, power... | <p>Your question sound like as if you have not installed the Team Foundation Server Client.</p>
<p>If you have installed the Visual Studio Team System edition you are able to connect with the Team Foundation Server. But to have the integration working you need to install the Team Foundation Server Client as well.</p>
... | 21,012 |
<p>I have written a WPF application that I want to port to Silverlight 2.</p>
<p>My business logic and model (for the M-V-VM design pattern) are packaged into a separate assembly which I am trying to recast as a Silverlight class library. </p>
<p>Unfortunately, the XmlNode class which I use to parse an XML file with ... | <p>Not sure how Linq to Xml is overkill. It is actually much easier to do Xml parsing with Linq2xml once you get the hang of it. I would say that regex or writing your own XmlNode would be overkill. </p>
<p>If you post some of the XmlNode work that you're doing I'm sure you would get some good translations. In the mea... | <p>The class System.Xml.Linq contains the XML DOM classes like XDocument, XElement, XNode and XAttribute that are way more performant and light-weight to their XmlDocument, XmlElemnt etc counter parts. You can use these classes without using Linq, but with Linq to Xml you can do very interesting things. It is absolutel... | 35,349 |
<p>I hope this qualifies as a programming question, as in any programming tutorial, you eventually come across 'foo' in the code examples. (yeah, right?)</p>
<p>what does 'foo' really mean?</p>
<p>If it is meant to mean <strong>nothing</strong>, when did it begin to be used so?</p>
| <p>See: <a href="https://www.rfc-editor.org/rfc/rfc3092" rel="nofollow noreferrer">RFC 3092: Etymology of "Foo", D. Eastlake 3rd et al.</a></p>
<p>Quoting only the relevant definitions from that RFC for brevity:</p>
<blockquote>
<ol start="2">
<li>Used very generally as a sample name for absolutely anything, ... | <p>In my opinion every programmer has his or her own "words" that is used every time you need an arbitrary word when programming.
For some people it's the first words from a childs song, for other it's names and for other its something completely different.
Now for the programmer community there are these "words" as w... | 7,711 |
<p>The Lab university I work at is in the process of purchasing a laser scanner for scanning 3D objects. All along from the start we've been trying to find a scanner that is able to capture real RAW normals from the actual scanned surface. It seems that most scanners only capture points and then the software interpolat... | <p>Highly unlikely. Laser scanning is done using ranges. What you want would be combining two entirely different techniques. Normals could be evaluated with higher precision using well controlled lighting etc, but requiring a very different kind of setup. Also consider the sampling problem: What good is a normal with h... | <p>You could with a structured light + camera setup.<br>
The normal would come from the angle betwen the projected line and the position on the image. As the other posters point out - you can't do it from a point laser scanner.</p>
| 35,422 |
<p>I'm just looking for a simple, concise explanation of the difference between these two. MSDN doesn't go into a hell of a lot of detail here.</p>
| <ul>
<li><p><code>__declspec(dllexport)</code> tells the linker that you want this object to be made available for other DLL's to import. It is used when creating a DLL that others can link to.</p></li>
<li><p><code>__declspec(dllimport)</code> imports the implementation from a DLL so your application can use it.</p></... | <p>Dllexport is used to mark a function as exported. You implement the function in your DLL and export it so it becomes available to anyone using your DLL.</p>
<p>Dllimport is the opposite: it marks a function as being imported from a DLL. In this case you only declare the function's signature and link your code with ... | 8,244 |
<p>I work for a product development company.We first do internal releases,and then public release.I was wondering, how other product developing companies manage their release? How do you give release number? Tag the source control?</p>
| <p>We use SubVersion, where tags and branches are cheap to create.</p>
<p>As far as releases go, we follow this convention:</p>
<p>(Major Release).(Minor Release).(Patch Release).(SVN revision)</p>
<ul>
<li>Patch Release = bug fixes</li>
<li>Minor Release = binary compatible /
interface compatible</li>
<li>Major Rel... | <p>Follow-up to co-cat's answer regarding TFS. There is a new URL with some updates for VS2010 and VS11</p>
<p><a href="http://vsarbranchingguide.codeplex.com/releases" rel="nofollow">http://vsarbranchingguide.codeplex.com/releases</a></p>
| 16,318 |
<p>I've seen examples in silverlight where the achieve a effect using 1 of 2 ways:</p>
<ol>
<li>Two image objects, both
displaying the same image, but the
bottom one rotating it 180 degrees
and applying a gradient image
opacity</li>
<li>A MediaElement object and a VideoBrush element.</li>
</ol>
<p>I have a series of ... | <p>Not in Silverlight, in WPF you have a VisualBrush which can help with this but Silverlight doesn't have one in version 2. Just to be clear though, it's not a rotation it's a negative ScaleY on a ScaleTransform. The easiest thing is to put everything into a UserControl and then use two UserControls with one having a ... | <p>For a good example, please see the following blog post from Mike Snow.</p>
<p><a href="http://silverlight.net/blogs/msnow/archive/2008/09/04/silverlight-tip-of-the-day-36-how-to-create-reflections-and-shadows-for-images-and-text.aspx" rel="nofollow noreferrer">http://silverlight.net/blogs/msnow/archive/2008/09/04/s... | 48,851 |
<p>Ok I need to determine the system's OS from a Lua script, but Lua as such has no API for this, so I use os.getenv() and query enviromental variables. On Windows checking the enviromental variable "OS" gives me the name of the system's OS, but is there some variable that exists on both Windows and most flavors of Uni... | <p>You can try <code>package.config:sub(1,1)</code>. It returns the path separator, which is <code>'\\'</code> on Windows and <code>'/'</code> on Unixes...</p>
| <p>FWIW, the simplest function I can think of:</p>
<pre><code>function MyScript:OS()
return package.config:sub(1,1) == "\\" and "win" or "unix"
end
</code></pre>
| 37,681 |
<p>I've wanted this for fluent interfaces. See, for example <a href="http://channel9.msdn.com/forums/Coffeehouse/257556-C-Extension-Properties/" rel="nofollow noreferrer">this</a> Channel9 discussion. Would probably <a href="http://ayende.com/Blog/archive/2007/12/02/Why-C-doesnt-have-extension-properties.aspx" rel="nof... | <p>Since properties are just syntactic sugar for methods, I don't see why C# should have extension methods without extension properties.</p>
| <p>No, a property is just a way to hide what has really been generated for the code. If you look at the reflected code or the IL you can determine what you're really getting and it is the following:</p>
<pre><code>public string MyProperty { get; set; }
</code></pre>
<p>becomes</p>
<pre><code>public string get_MyProp... | 16,664 |
<p>I have a MS-access database. But it is on the shared drive. And it is required that only some selected number of people can use it. Is there a way to authenticate the user?</p>
| <p>Yes, open the database then run the Tools->Security->User-Level Security Wizard. It will step you through the process of creating a new workgroup file, creating users and groups, and securing the Access objects.</p>
| <p>Two solutions:</p>
<ol>
<li><p>Place the Access file on a file share with permissions set appropriately. This doesn't work really well if you need to provide read-only access since Access can't write out the temporary .ldb file that it creates when opening an Access file (.mdb). </p></li>
<li><p>Move the "data" o... | 34,230 |
<p>Is there a way (or shortcut) to tell VS 2008 that it cuts a line like this:</p>
<p><strong>Before:</strong></p>
<pre><code>Some Text here
This gets cut
Some Code there
</code></pre>
<p><strong>After:</strong></p>
<pre><code>Some Text here
Some Code there
</code></pre>
<p><strong>What I want:</strong></p>
... | <p>Unless I misunderstood you:<br>
Just place cursor on the line you want to cut (no selection) and press <kbd>Ctrl</kbd> + <kbd>x</kbd>. That cuts the line (leaving no blanks) and puts the text in the Clipboard. (tested in <em>MS VC# 2008 Express</em> with no additional settings I'm aware of)</p>
<p>Is that what you ... | <p>Don't select anything, just hit <kbd>ctrl</kbd>+<kbd>x</kbd> when the cursor is on the line.</p>
| 8,409 |
<p>What is the best way to use multiple EVAL fields in a GridView ItemTemplate?</p>
<p>Looking to have some control over formatting for appearance as well as setting up hyperlinks/javascript etc.</p>
| <p>Even clearer, IMO, is:</p>
<pre><code><%# String.Format("{0} - {1}", Eval("Name1"), Eval("Name2")) %>
</code></pre>
| <p>I have a easiest way to do this same thing...</p>
<pre><code><asp:Label ID="lblName" runat="server" Text='<%#Eval("FirstName").ToString() +", "+ Eval("LastName").ToString() %>'></asp:Label>
</code></pre>
<p>.</p>
<pre><code><%#Eval("FirstName").ToString() +", "+ Eval("LastName").ToString() %&... | 7,941 |
<p>I like to know if there is a way to read the user input inside a batch file, because i have a file named: "fif.bat" that recives two parameters (just call them <strong><em>paramA</em></strong> and <strong><em>paramB</em></strong>) so i execute the file like this:</p>
<pre><code>fif paramA paramB
</code></pre>
<p>I... | <p>I think this might be what you're looking for:</p>
<pre><code>@ECHO OFF
SET /p paramA=Parameter A:
ECHO you typed %paramA%
PAUSE
</code></pre>
<p>Line one stops commands in batch file from being echoed to the console
Line two prompts the user with "Parameter A:" and waits for user to enter a value and press enter.... | <p>You can prompt for user input in a batch file using <code>SET /P</code> for example:</p>
<pre><code>SET /P paramB="Prompt String: "
</code></pre>
| 25,170 |
<p>I have three projects. One is a WCF Services Project, one is a WPF Project, and one is a Microsoft Unit Testing Project. I setup the WCF Services project with a data object that looks like this:</p>
<pre><code>[DataContract]
public enum Priority
{
Low,
Medium,
High
}
[DataContract]
public struct Time... | <p>I Found the Answer</p>
<p>Ok, not sure if it is kewl answering my own question, but here we go. For some reason the enumeration needed to be marked with the [EnumMember] Attributes as below:</p>
<pre><code>[DataContract]
public enum Priority
{
[EnumMember]
Low,
[EnumMember]
Medium,
[EnumMember... | <p>Someone on this thread posted that adding this element to the endpoint behavior fixed the issue.</p>
<pre><code><dataContractSerializer maxItemsInObjectGraph="2147483647" />
</code></pre>
<p>This worked but it had to be added not only to the endpoint behavior but the service behavior too (which makes sense s... | 28,727 |
<p>I recently had a problem with the z-axis of my printer. To resolve the issue with the Z axis not moving I remove the left polished rod. Am I able to use the printer with just one smooth rod?</p>
| <p>First a resounding no. Not a good idea. Are you saying it works now that you have removed the smooth rod?</p>
<p>That tells me for sure your issue was Binding. Which is a tricky problem to solve. Binding usually happens when your carriage is not level. Take a bubble leveler and verify.</p>
<p>Another time it happe... | <p>No, this is not a good idea. Your X axis is now free to rotate by a few degrees around the remaining Z rod. Parts may appear to print OK, but depending on the dynamics of a print, you will see offsets between layers. You need to resolve the issues with your Z-axis.
These questions, <a href="https://3dprinting.stack... | 470 |
<p>I'm currently designing a program that will involve some physics (nothing too fancy, a few balls crashing to each other)</p>
<p>What's the most exact datatype I can use to represent position (without a feeling of discrete jumps) in c#?</p>
<p>Also, what's the smallest ammount of time I can get between t and t+1? O... | <p>In .Net a <code>decimal</code> will be the most precise datatype that you could use for position. I would just write a class for the position:</p>
<pre><code>public class Position
{
decimal x;
decimal y;
decimal z;
}
</code></pre>
<p>As for time, your processor can't give you anything smaller than one... | <p>I'm not sure I understand your last question, could you please clarify?</p>
<p>Edit:</p>
<p>I might still not understand, but you can use any type you want (for example, doubles) to represent time (if what you actually want is to represent the discretization of time for your physics problem, in which case the tick... | 4,855 |
<p>Is there any API to get the currently logged in user's name and password in Windows?</p>
<p>Thank you in advance.</p>
| <p>Password: No, this is not retained for security reasons - it's used, then discarded. You could retrieve the encrypted password for this user from the registry, given sufficient privileges, then decrypt it using something like <a href="http://en.wikipedia.org/wiki/Rainbow_table" rel="noreferrer">rainbow tables</a>, b... | <p>You can get the user name with GetUserName(), but you cannot get the password; this would violate security for dummies 101.</p>
| 13,871 |
<p>The situation is this:</p>
<ul>
<li>You have a Hibernate context with an
object graph that has some lazy
loading defined. </li>
<li>You want to use
the Hibernate objects in your UI as
is without having to copy the data
somewhere. </li>
<li>There are different UI
contexts that require different
amounts of data. <... | <p>Let's say you have the Client and at one point you have to something with his Orders and maybe he has a Bonus for his Orders. </p>
<p>Then I would define a Repository with a fluent interface that will allow me to say something like :</p>
<pre><code>new ClientRepo().LoadClientBy(id)
.WithOrders()
... | <p>If it's a webapp and you're using Spring, then OpenSessionInViewFilter could be the solution to your problems.</p>
| 10,523 |
<p>I need to validate an integer to know if is a valid enum value.</p>
<p>What is the best way to do this in C#?</p>
| <p>You got to love these folk who assume that data not only always comes from a UI, but a UI within your control!</p>
<p><code>IsDefined</code> is fine for most scenarios, you could start with:</p>
<pre><code>public static bool TryParseEnum<TEnum>(this int enumValue, out TEnum retVal)
{
retVal = default(TEnum)... | <p>I found this <a href="http://www.cambiaresearch.com/c4/52a7e5fe-c7fc-49ab-b21d-37e6194687f3/Convert-Integer-To-Enum-Instance-in-csharp.aspx" rel="nofollow noreferrer">link</a> that answers it quite well. It uses:</p>
<pre><code>(ENUMTYPE)Enum.ToObject(typeof(ENUMTYPE), INT)
</code></pre>
| 3,457 |
<p>I'm using the .NETCF (Windows Mobile) <code>Graphics</code> class and the <code>DrawString()</code> method to render a single character to the screen.</p>
<p>The problem is that I can't seem to get it centred properly. No matter what I set for the Y coordinate of the location of the string render, it always comes o... | <p>I'd like to add another vote for the StringFormat object.
You can use this simply to specify "center, center" and the text will be drawn centrally in the rectangle or points provided:</p>
<pre><code>StringFormat format = new StringFormat();
format.LineAlignment = StringAlignment.Center;
format.Alignment = StringAli... | <p>You can use an instance of the <code>StringFormat</code> object passed into the <code>DrawString</code> method to center the text.</p>
<p>See <a href="http://msdn.microsoft.com/en-us/library/21kdfbzs.aspx" rel="nofollow noreferrer">Graphics.DrawString Method</a> and <a href="http://msdn.microsoft.com/en-us/library/... | 2,954 |
<p>I use a custom-built asp.net control that renders to a DIV and has "height='0'" hard-coded into the element (I know.. stupid). But I need to reset it - get rid of the height assignment somehow. Is this doable with CSS?</p>
<p>I can set the height to 100px for example, and it works. But that's not what I want - I... | <p>You might well need to use <code>height:auto !important</code> because the height attribute has a very high priority (IIRC).</p>
<p>But ideally you would karate-kick that attribute out of there. Yuck.</p>
| <p>The style attribute always overrides class. So you're going to have to remove the height rule of the style attribute.</p>
| 26,120 |
<p>How do you return a serialized JSON object to the client side using ASP.NET MVC via an AJAX call?</p>
| <p>From the controller you can just return a JsonResult:</p>
<pre><code>public ActionResult MyAction()
{
... // Populate myObject
return new JsonResult{ Data = myObject };
}
</code></pre>
<p>The form of the Ajax call will depend on which library you're using, of course. Using jQuery it would be something like... | <p>If you need to send JSON in response to a GET, you'll need to explicitly allow the behavior by using JsonRequestBehavior.AllowGet.</p>
<pre><code>public JsonResult Foo()
{
return Json("Secrets", JsonRequestBehavior.AllowGet);
}
</code></pre>
| 12,654 |
<p>I have some System.Diagnotics.Processes to run. I'd like to call the close method on them automatically. Apparently the "using" keyword does this for me.</p>
<p>Is this the way to use the using keyword?</p>
<pre><code>foreach(string command in S) // command is something like "c:\a.exe"
{
try
{
us... | <pre><code>using(p = Process.Start(command))
</code></pre>
<p>This will compile, as the <code>Process</code> class implements <code>IDisposable</code>, however you actually want to call the <code>Close</code> method.<br>
Logic would have it that the <code>Dispose</code> method would call <code>Close</code> for you, an... | <pre><code>try
{
foreach(string command in S) // command is something like "c:\a.exe"
{
using(p = Process.Start(command))
{
// I literally put nothing in here.
}
}
}
catch (Exception e)
{
// notify of process failure
}
</code></pre>
<p>The reason it works is because when the e... | 22,416 |
<p>I am coming from an Enterprise Java background which involves a fairly heavyweight software stack, and have recently discovered the
<a href="http://www.stripesframework.org/" rel="noreferrer">Stripes framework</a>; my initial impression is that this seems to do a good job of minimising the unpleasant parts of build... | <p>We've been using Stripes for about 4 years now. Our stack is Stripes/EJB3/JPA.</p>
<p>Many use Stripes plus Stripernate as a single, full stack solution. We don't because we want our business logic within the EJB tier, so we simply rely on JPA Entities as combined Model and DTO.</p>
<p>Stripes does the binding to ... | <p>Stripes is yesterdays technology, if you can pick something a little more modern like GWT.</p>
| 6,984 |
<p>Is it possible to obtain raw logs from Google Analytic? Is there any tool that can generate the raw logs from GA?</p>
| <p>No you can't get the raw logs, but there's nothing stopping you from getting the exact same data logged to your own web server logs. Have a look at the <a href="https://ssl.google-analytics.com/urchin.js" rel="noreferrer">Urchin code</a> and borrow that, changing the following two lines to point to your web server ... | <p>No, but there are other paid services like <a href="https://mixpanel.com/docs/api-documentation/data-export-api" rel="nofollow" title="Mixpanel Data Export API">Mixpanel</a> and <a href="http://support.kissmetrics.com/apis/data/data-export-setup" rel="nofollow" title="KISSmetrics Data Export">KISSmetrics</a> that ha... | 8,319 |
<p>What is the equivalent of Java's <code>System.currentTimeMillis()</code> in C#?</p>
| <p>An alternative:</p>
<pre><code>private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long CurrentTimeMillis()
{
return (long) (DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
</code></pre>
| <p>I know question asks for <strong>equivalent</strong> but since I use those 2 for the same tasks I throw in <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms724408%28v=vs.85%29.aspx" rel="nofollow">GetTickCount</a>. I might be nostalgic but System.currentTimeMillis() and GetTickCount() are the only ... | 36,988 |
<p>I have a page with many forms in panels and usercontrols, and a requiredfield validator I just added to one form is preventing all of my other forms from submitting. what's the rule that I'm not following?</p>
| <p>Are you using ValidationGroups? Try assigning each control with a validation group as well as the validator that you want to use. Something like:</p>
<pre><code><asp:TextBox ID="txt1" ValidationGroup="Group1" ruant="server" />
<asp:RequiredFieldValidator ID="rfv1" ... ValidationGroup="Group1" />
</cod... | <p>You should be setting ValidationGroup property to a different value for each group of elements. Your validator's ValidationGroup must only be same with the control that submit its form.</p>
| 5,564 |
<p>I'm trying to fetch Wikipedia pages using <a href="http://search.cpan.org/dist/libwww-perl" rel="noreferrer">LWP::Simple</a>, but they're not coming back. This code:</p>
<pre><code>#!/usr/bin/perl
use strict;
use LWP::Simple;
print get("http://en.wikipedia.org/wiki/Stack_overflow");
</code></pre>
<p>doesn't print... | <p>Apparently Wikipedia blocks LWP::Simple requests: <a href="http://www.perlmonks.org/?node_id=695886" rel="noreferrer">http://www.perlmonks.org/?node_id=695886</a></p>
<p>The following works instead:</p>
<pre><code>#!/usr/bin/perl
use strict;
use LWP::UserAgent;
my $url = "http://en.wikipedia.org/wiki/Stack_overfl... | <p>Because Wikipedia is blocking the HTTP user-agent string used by LWP::Simple.</p>
<p>You will get a "403 Forbidden"-response if you try using it.</p>
<p>Try the LWP::UserAgent module to work around this, setting the agent-attribute.</p>
| 4,417 |
<p>I'm trying to write a log parsing script to extract failed events. I can pull these with grep:</p>
<pre><code>$ grep -A5 "FAILED" log.txt
2008-08-19 17:50:07 [7052] [14] DEBUG: data: 3a 46 41 49 4c 45 44 20 20 65 72 72 3a 30 32 33 :FAILED err:023
2008-08-19 17:50:07 [7052] [14] DEBUG: data: 20 74 65 7... | <pre><code>grep -A 5 FAILED log.txt | \ # Get FAILED and dst and other lines
egrep '(FAILED|dst=)' | \ # Just the FAILED/dst lines
egrep -o "err:[0-9]*|dst=[0-9]*" | \ # Just the err: and dst= phrases
cut -d':' -f 2 | \ # Strip "err:" from err: lines
cut -d '... | <p>A simple solution in Ruby, here is <code>filter.rb</code>:</p>
<pre><code>#! /usr/bin/env ruby
File.read(ARGV.first).scan(/:FAILED\s+err:(\d+).*?, dst=(\d+),/m).each do |err, dst|
puts "#{err} #{dst}"
end
</code></pre>
<p>Run it with:</p>
<pre><code>ruby filter.rb my_log_file.txt
</code></pre>
<p>And you get:<... | 31,203 |
<p>OK, here is my problem, without being too specific for reasons of being fired for putting company practices on the internet.</p>
<p>There are spreadsheets made. These are uploaded to the database. I need to filter out duplicates from uploading. The only way to do this is by making sure that for each and every entry... | <p>I had a similar problem. My solution was to:</p>
<ol>
<li>import into a staging-table. </li>
<li>delete the duplicates</li>
<li>copy what's left over into the live table</li>
</ol>
<p>It's a little BFI, but it just plain works.</p>
| <p>How are you loading them into the database? Is this with your own code to read the Excel files? You can <a href="https://stackoverflow.com/questions/15828/reading-excel-files-from-c#15839">read the Excel files using ADO/ADO.NET with the right connection string</a>. Then you could read the data using a query that wou... | 4,272 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.