instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>We built a grant application system for a client. They've now asked for some simple workflow functionality (two approvals needed before the application is submitted). </p>
<p>I've given some thought to the database design that I'd use to encode the workflow requirements in a way that would offer maximum flexibility... | <p>To not look at the <a href="http://msdn.microsoft.com/en-us/netframework/aa663328.aspx" rel="nofollow noreferrer">Windows Workflow Foundation</a> would be foolish. It was made for exactly what you require.</p>
<p>Here's an <a href="http://www.devx.com/dotnet/Article/29992" rel="nofollow noreferrer">ASP.NET specifi... | <p>one solution that has worked well in the past is to create approval groups with members, approval codes as a simple lookup table, and soft-code the approval state-machine so that each step results from the assigning of an approval code to an item by a group member. This allows the group membership to change and the ... | 28,508 |
<p>I have a function that is declared and defined in a header file. This is a problem all by itself. When that function is not inlined, every translation unit that uses that header gets a copy of the function, and when they are linked together there are duplicated. I "fixed" that by making the function inline, but I'm ... | <p>I guess you're missing something, here.</p>
<h2>static function?</h2>
<p>Declaring a function static will make it "hidden" in its compilation unit.</p>
<blockquote>
<p>A name having namespace scope (3.3.6) has internal linkage if it is the name of</p>
<p>— a variable, function or function template that is ... | <p>I believe you will end up with one per translation unit. You've effectively got many versions of that function (and its declared static variable), one for every translation unit that includes the header.</p>
| 22,456 |
<p>we have several <em>"production environments"</em> (three servers each, with the same version of our system. Each one has a SQL Server Database as production database). </p>
<p>In one of this environment the <em>tempdb</em> transaction log starts to grow fast and infinitely, we can´t find why. Same version of SO, S... | <p>You might be in Full recovery model mode - if you are doing regular backups you can change this to simple and it will reduce the size of the log after the backup.</p>
<p>Here is <a href="http://support.microsoft.com/kb/873235" rel="nofollow noreferrer">some more info</a>.</p>
| <p>Your best bet is to fire up SQL Server Profiler and see what's going on. Look for high values in the "Writes" column or Spool operators, these are both likely to cause high temp usage.</p>
<p>If it is only the transaction log growing then try this, open transactions prevent the log from being shrunk down as it goe... | 11,398 |
<p>I can split editor panes horizontally or vertically, but it does not seem possible to view code in two separate physical windows. I am aware that Idea can open multiple <strong>projects</strong> in separate windows, but I'd like to be able to do this for two files in a <strong>single</strong> project. </p>
<p>One... | <p>Unfortunately there is no way (as of IDEA 8.0.1) to do what you're asking for. As you pointed out, you can split the editor pane but there is always exactly one editor per IDEA project.</p>
<p>UPDATE: As of IDEA 10 (currently the latest is 10.5), the answer is yes, you can :-)</p>
| <p>Yes- with <a href="http://www.jetbrains.com/idea/training/demos/detachable_tabs/index.html" rel="nofollow noreferrer">IDEA X</a>, it is finally possible to open multiple editor windows. </p>
| 49,043 |
<p>I wrote a small web app using ruby on rails, its main purpose is to upload, store, and display results from xml(files can be up to several MB) files. After running for about 2 months I noticed that the mongrel process was using about 4GB of memory. I did some research on debugging ruby memory leaks and could not f... | <p>Some tips to find memory leaks in Rails:</p>
<ul>
<li>use the <a href="http://www.rubyinside.com/bleakhouse-tool-to-find-memory-leaks-in-your-rails-applications-470.html" rel="nofollow noreferrer">Bleak House</a> plugin</li>
<li>implement <a href="https://scoutapm.com/" rel="nofollow noreferrer">Scout monitoring</a... | <p>These gems worked for me:</p>
<p><a href="https://github.com/binarylogic/memorylogic" rel="nofollow">MemoryLogic</a></p>
<blockquote>
<p>Adds in proccess id and memory usage in your rails logs, great for tracking down memory leaks</p>
</blockquote>
<p><a href="https://github.com/noahd1/oink" rel="nofollow">Oink... | 19,497 |
<p>I'm using Entity Framework O/R mapper from Microsoft and using entity classes (generated classes that are mapped to DB objects) as a business objects.
Is this OK? Please state your cons or pros. What to do in a case of WCF communication between business layer and presentation, how to send those objects as data memb... | <p>I am using EF in this fashion and one nice feature is that generated entities are partial classes, allowing them to be extended in a way that is fairly protected from regeneration issues.</p>
<p>Also take a look at <a href="http://msdn.microsoft.com/en-us/library/cc716789.aspx" rel="noreferrer">this link on MSDN</a... | <p>In my experience, we've used EF objects within the business layer of our application, but when we make the transition into the presentation layer through our WCF service layer, we will create view objects from the EF objects. </p>
<p>In our case, only the view is passed to the presentation layer. We do this to co... | 26,747 |
<p>Is there a mod_rewrite equivalent for IIS 7.0 that's </p>
<p>a) more or less complete </p>
<p>b) suitable for a production environment, i.e. battle-tested/dependable/secure</p>
<p>Do you have an experience-based recommendation?</p>
| <p>Check out the <a href="http://www.iis.net/downloads/microsoft/url-rewrite" rel="noreferrer">URL Rewrite Module for IIS 7</a> created by Microsoft</p>
| <p><a href="http://www.isapirewrite.com/" rel="nofollow noreferrer">ISAPI Rewrite</a> is suitable for IIS 5 or 6. There's a Lite version available for free, or you can pay for the full version to get more features, such as proxying capabilities. It's been a while since I've used it, but it worked fine at the time.</p>
| 8,590 |
<p>When I create a view in SQL Server 2005 and someone later opens it in the GUI modify mode it sometimes completely rearranges my joins. Often to the point it's virtually no longer readable. If I look at it in the GUI it's changed as well from what I originally wrote. Sometimes the join lines no longer even point t... | <p>No you cannot. That's why you should never, ever use it.</p>
<p>"Fx" means that the join is not a simple column-to-column link, but involves a function (that's also why it can't point to a field, of course). It should NOT do that by itself, though,</p>
| <p>It's the result of the view GUI parsing the SQL into it's own internal DOM style format and then writing it back out - much in the same way that HTML editors take in XHTML and emit stuff differently to how you wanted it :(</p>
| 32,873 |
<p>In the following piece of code (taken from the <a href="http://groovy-lang.org/semantics.html#_while_loop" rel="noreferrer">Groovy Semantics Manual page</a>), why prefix the assignment with the keyword <code>def</code>?</p>
<pre><code>def x = 0
def y = 5
while ( y-- > 0 ) {
println "" + x + " " + y
x++
... | <p>It's syntactic sugar for basic scripts. Omitting the "def" keyword puts the variable in the bindings for the current script and groovy treats it (mostly) like a globally scoped variable:</p>
<pre><code>x = 1
assert x == 1
assert this.binding.getVariable("x") == 1
</code></pre>
<p>Using the def keyword instead doe... | <p>Actually, I <strong>don't</strong> think it would behave the same... </p>
<p>variables in Groovy still require declaration, just not TYPED declaration, as the right-hand side generally contains enough information for Groovy to type the variable.</p>
<p>When I try to use a variable that I haven't declared with def... | 22,249 |
<p>I have this piece of code (summarized)...</p>
<pre><code>AnsiString working(AnsiString format,...)
{
va_list argptr;
AnsiString buff;
va_start(argptr, format);
buff.vprintf(format.c_str(), argptr);
va_end(argptr);
return buff;
}
</code></pre>
<p>And, on the basis that pass by reference is... | <p>If you look at what va_start expands out to, you'll see what's happening:</p>
<pre><code>va_start(argptr, format);
</code></pre>
<p>becomes (roughly)</p>
<pre><code>argptr = (va_list) (&format+1);
</code></pre>
<p>If format is a value-type, it gets placed on the stack right before all the variadic arguments... | <p>Side note:</p>
<p>The behavior for class types as varargs arguments may be undefined, but it's consistent in my experience. The compiler pushes sizeof(class) of the class's memory onto the stack. Ie, in pseudo-code:</p>
<pre><code>alloca(sizeof(class));
memcpy(stack, &instance, sizeof(class);
</code></pre>
<p... | 27,409 |
<p>I'm creating a series of builders to clean up the syntax which creates domain classes for my mocks as part of improving our overall unit tests. My builders essentially populate a domain class (such as a <code>Schedule</code>) with some values determined by invoking the appropriate <code>WithXXX</code> and chaining ... | <p>All I can say is that if there <em>is</em> a way of doing it, I want to know about it too - I use <em>exactly</em> this pattern in my <a href="http://github.com/jskeet/dotnet-protobufs/tree/master" rel="noreferrer">Protocol Buffers port</a>. In fact, I'm glad to see that someone else has resorted to it - it means we... | <p>This is a good implementation strategy for C#.</p>
<p>Some other languages (can't think of name of research language I've seen this in) have type systems that either support a covariant "self"/"this" directly, or have other clever ways to express this pattern, but with C#'s type system, this is a good (only?) solut... | 30,355 |
<p>Ok, so I just ran into the following problem that raised an eyebrow.</p>
<p>For various reasons I have a testing setup where Testing classes in a TestingAssembly.dll depend on the TestingBase class in a BaseTestingAssembly.dll.
One of the things the TestBase does in the meantime is look for a certain embedded resou... | <p>The static constructor is called by the runtime and not directly by user code. You can see this by setting a breakpoint in the constructor and then running in the debugger. The function immediately above it in the call chain is native code.</p>
<p><strong>Edit:</strong> There are a lot of ways in which static ini... | <p>I think the answer is here in the discussion of <a href="http://msdn.microsoft.com/en-us/library/k9x6w0hc(VS.80).aspx" rel="nofollow noreferrer">C# static constructors</a>. My best guess is that the static constructor is getting called from an unexpected context because:</p>
<blockquote>
<p>The user has no contro... | 14,827 |
<p>I am currently trying to learn all new features of C#3.0. I have found a very nice collection of <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx" rel="nofollow noreferrer">sample to practice LINQ</a> but I can't find something similar for Lambda.</p>
<p>Do you have a place that I could practice Lambda... | <p><a href="http://linqpad.net/" rel="noreferrer">LINQPad</a> is a good tool for learning LINQ</p>
| <p>The best that I have found is this <a href="http://www.albahari.com/nutshell/linqquiz.aspx" rel="nofollow noreferrer">link</a> for the moment. It's a quiz that let met practice, but I would like something more Lambda and less LINQ.</p>
| 30,286 |
<p>Can anyone explain the difference between <code>Server.MapPath(".")</code>, <code>Server.MapPath("~")</code>, <code>Server.MapPath(@"\")</code> and <code>Server.MapPath("/")</code>?</p>
| <p><strong>Server.MapPath</strong> specifies the relative or virtual path to map <strong>to a physical directory</strong>.</p>
<ul>
<li><code>Server.MapPath(".")</code><sup>1</sup> returns the current physical directory of the file (e.g. aspx) being executed</li>
<li><code>Server.MapPath("..")</code> returns the paren... | <p>1) <code>Server.MapPath(".")</code> -- Returns the "Current Physical Directory" of the file (e.g. <code>aspx</code>) being executed.</p>
<p>Ex. Suppose <code>D:\WebApplications\Collage\Departments</code></p>
<p>2) <code>Server.MapPath("..")</code> -- Returns the "Parent Directory"</p>
<p>Ex. <code>D:\WebApplicat... | 34,762 |
<p>How would I achieve the pseudo-code below in JavaScript? I want to include the date check in the second code excerpt, where txtDate is for the BilledDate.</p>
<pre><code>If ABS(billeddate – getdate) > 31 then yesno “The date you have entered is more than a month from today, Are you sure the date is correct,”.... | <p>Generally speaking you work with Date-objects in javascript, and these should be constructed with the following syntax:</p>
<pre><code> var myDate = new Date(yearno, monthno-1, dayno);
//you could put hour, minute, second and milliseconds in this too
</code></pre>
<p>Beware, the month-part is an index, so j... | <p>Hello and good day for everyone</p>
<p>You can try Refular Expressions to parse and validate a date format</p>
<p>here is an URL yoy can watch some samples and how to use</p>
<p><a href="http://www.javascriptkit.com/jsref/regexp.shtml" rel="nofollow noreferrer">http://www.javascriptkit.com/jsref/regexp.shtml</a><... | 29,744 |
<p>Is it a best practice to use stored procedure for every single SQL call in .NET applications?</p>
<p>Is it encouraged for performance reasons and to reduce surface area for SQL injection attacks (in web applications)?</p>
| <p>Stored procedures have a few advantages over parameterized queries:</p>
<ol>
<li><p>When used <em>exclusively</em>, you can turn off CREATE, INSERT, SELECT, UPDATE, ALTER, DROP, DELETE, etc access for your application accounts, and this way add a small amount of security.</p></li>
<li><p>They provide a consistent, ... | <p>No. </p>
<p>If you send your queries to SQL Server as parameterized queries, SQL Server will cache the execution plan AND will sanitize your parameter inputs properly to avoid SQL injection attacks.</p>
| 44,255 |
<p>I've written 2 reasonably large scale apps in .net so far, and both of them have needed an updating facility to automatically update the application when I roll out new code.</p>
<p>I've found the 'Enterprise application block updater' a bit too complex for my needs, and I've found 'click once' frustrating when it ... | <p>See the answers to <a href="https://stackoverflow.com/questions/37030/how-to-best-implement-software-updates-on-windows">this similar question</a>: a few auto-update frameworks were recommended there which are designed for (or work with) .net apps:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms978... | <p>Try an off-the-shelf autoupdate product: <a href="http://www.AutoUpdatePlus.com" rel="nofollow noreferrer">http://www.AutoUpdatePlus.com</a></p>
| 7,236 |
<p>I was writing some Unit tests last week for a piece of code that generated some SQL statements.</p>
<p>I was trying to figure out a regex to match <code>SELECT</code>, <code>INSERT</code> and <code>UPDATE</code> syntax so I could verify that my methods were generating valid SQL, and after 3-4 hours of searching and... | <p>Regular expressions can match languages only a finite state automaton can parse, which is very limited, whereas SQL is a syntax. <strong>It can be demonstrated you can't validate SQL with a regex.</strong> So, you can stop trying.</p>
| <p>I am assuming you did something like <code>.\*</code> try instead <code>[^"]*</code> that will keep you from eating the whole line. It still will give false positives on cases where you have <code>\</code> inside your strings.</p>
| 16,926 |
<p>I believe I already know the answer, but I am not 100% sure, so just a quick question: What does Red/Green Testing actually mean?</p>
<p>I understand it as "Write your tests first, so that they all fail (= all red), then write your code and watch how each test turns green, and when all are green, you're fine".</p>
... | <p>It does refer to TDD or Test Driven Development, but it would apply to each test. Write the test first, then write the code to pass the test. It would be wrong to write ALL the tests first. TDD is an incremental development approach.</p>
<p>The basic idea is no code is written before there is failing test (RED).... | <p>When you run a TDD GUI, the display is red until all tests pass, then it switches to green.</p>
<p>This is a summary of the rough outline of test-first development.</p>
<ol>
<li><p>Write some skeleton code that compiles, has enough API to be testable.</p></li>
<li><p>Write tests which -- initially -- will be mostl... | 34,914 |
<p>What column names cannot be used when creating an Excel spreadsheet with ADO.</p>
<p>I have a statement that creates a page in a spreadsheet:</p>
<pre><code>CREATE TABLE [TableName] (Column string, Column2 string);
</code></pre>
<p>I have found that using a column name of <code>Date</code> or <code>Container</cod... | <p>It may be possible to define a custom template for the DIP and deploy that to the site, setting the content type to link to that template.</p>
| <p>I found a solution in a blog, but you have to use InfoPath... Here is the link:
Using SharePoint Metadata in Word Documents – The Lookup Column </p>
<p><a href="http://vspug.com/maartene/2009/03/13/using-sharepoint-metadata-in-word-documents-the-lookup-column-issue/" rel="nofollow noreferrer">http://vspug.com/maar... | 11,310 |
<p>I am looking for guidance regarding the best practice around the use of the Profile feature in ASP.NET.</p>
<p>How do you decide what should be kept in the built-in user Profile, or if you should create your own database table and add a column for the desired fields? For example, a user has a zip code, should I sav... | <p>Ive only built 2 applications that used the profile provider. Since then I have stayed away from using it. For both of the apps I used it to store information about the user such as their company name, address and phone number. </p>
<p>This worked fine until our client wanted to be able to find a user by one of the... | <p>In my experience its best to keep an the info in the profile to a bare minimum, only put the essentials in there that are directly needed for authentication. Other information such as addresses should be saved in your own database by your own application logic, this approach is more extensible and maintainable.</p>
| 2,401 |
<p>Are people still writing <a href="http://zeroc.com/blogs/michi/" rel="noreferrer">SOAP services</a> or is it a technology that has passed its <a href="http://www.addsimplicity.com/" rel="noreferrer">architectural shelf life</a>? Are people returning to binary formats?</p>
| <p>The alternative to SOAP is not binary formats.</p>
<p>I think you're seeing a surge in the desire to leave the complexities of WS-* behind in favor of REST and JSON, because they're much simpler to use and don't require frameworks to be used successfully. The problems that WS-* ostensibly tries to solve aren't prob... | <p>Yes, some people <strong>still</strong> are (and now it's 2011!). I think the main reason is that MS WCF automatically generates SOAP bindings. The horror. </p>
| 5,938 |
<p>While porting an application from SQL 2005 to SQL Server Compact Edition, I found that I need to port this command:</p>
<pre><code>SELECT TOP 1 Id FROM tblJob WHERE Holder_Id IS NULL
</code></pre>
<p>But SQL Server Compact Edition doesn't support the <code>TOP</code> keyword. How can I port this command?</p>
| <pre><code>SELECT TOP(1) Id
FROM tblJob
WHERE Holder_Id IS NULL
</code></pre>
<p>Need the brackets as far as I know.</p>
<p>reference: <a href="http://technet.microsoft.com/en-us/library/bb686896.aspx" rel="noreferrer">http://technet.microsoft.com/en-us/library/bb686896.aspx</a></p>
<p>addition: likewise, only for... | <p>Looks like it can't be done in compact. You have to read all the jobs, or make a SqlReader, and just read the first one.</p>
| 16,759 |
<p>I work on relatively sensitive code that we wouldn't want falling into the wrong hands. Up until now, all the code has been keep in house so it hasn't been an issue. I am moving to working from home a day or two a week and we want to secure the code on my laptop.</p>
<p>We have looked at a few alternatives, but Win... | <p><a href="http://www.truecrypt.org/downloads.php" rel="nofollow noreferrer">Truecrypt</a>:</p>
<blockquote>
<p><strong>WARNING: Using TrueCrypt is not secure as it may contain unfixed security issues</strong></p>
<p>This page exists only to help migrate existing data encrypted by TrueCrypt.</p>
<p>The de... | <p>The last time I did this was a few years ago, but we used PGPdisk. It did a good job.</p>
| 16,459 |
<p>It's kind of embarassing that I find it so difficult to learn JavaScript, but .. </p>
<p>Let's say I have a really simple controller like this:</p>
<pre><code>class front extends Controller {
public function __construct()
{
parent::Controller();
}
public function index()
{
... | <p>you would just print it out basically, and re-capture that information via javascript:</p>
<pre><code>public function test() {
$somenumber = $this->input->post('someNumber');
if ($somenumber == 12) {
print "Number is 12";
} else {
print "Number is not 12";
}
}
</code></pre>
<p... | <p>I've also found in CodeIgniter that 'XMLHTTPRequest' isn't returned in the response headers, when using the standard Javascript AJAX call as mentioned above. </p>
<pre><code>$this->input->is_ajax_request();
</code></pre>
<p>The input helper doesn't ever return true unless you use jQuery to handle the AJAX PO... | 39,665 |
<p>How do I speed up prints for the Monoprice Select IIIP Plus printer?</p>
<p>The manual shows [Cura] examples of:</p>
<ul>
<li>Print speed: 50mm/s</li>
<li>Travel Speed: 80mm/s</li>
<li>Bottom Layer Speed: 20mm/s</li>
<li>Infill Speed: 50mm/s</li>
<li>Outer shell speed: 15mm/s</li>
<li>Inner shell speed: 30mm/s</li... | <p>In my experience a print speed of 50-70mm/s is ideal. Even if you set the speed to 150mm/s the print head still changes directions often and rarely will have enough time to accelerate from 0->150 before changing direction again. </p>
<p>Some more effective ways of speeding up prints is to adjust</p>
<ul>
<li>Layer... | <p>I was using Cura's default settings for a Prusa I3 on my MonoPrice Select V2 (model #13860), and got horrible results frequently. Then I used the settings you list, and got very nice results. Compare the below images for the bottom layer of 4 benchys, with adhesion brim.</p>
<p>I'm using PLA, 0.4mm nozzle, 60C for ... | 654 |
<p>How would a go about making a program where the user enters a string, and the program generates a list of words beginning with that string?</p>
<p>Ex:<br />
User: "abd"<br />
Program:abdicate, abdomen, abduct...</p>
<p>Thanks!</p>
<hr>
<p>Edit: I'm using python, but I assume that this is a fairly language-indep... | <p>Use a <a href="http://en.wikipedia.org/wiki/Trie" rel="noreferrer">trie</a>.</p>
<p>Add your list of words to a trie. Each path from the root to a leaf is a valid word. A path from a root to an intermediate node represents a prefix, and the children of the intermediate node are valid completions for the prefix.</p>... | <p>If your dictionary is really big, i'd suggest indexing with a python text index (PyLucene - note that i've never used the python extension for lucene) The search would be efficient and you could even return a search 'score'.</p>
<p>Also, if your dictionary is relatively static you won't even have the overhead of r... | 13,760 |
<p>For my current project, I need to request XML data over a tcp/ip socket connection. For this, I am using the TcpClient class:</p>
<pre><code>Dim client As New TcpClient()
client.Connect(server, port)
Dim stream As NetworkStream = client.GetStream()
stream.Write(request)
stream.Read(buffer, 0, buffer.length)
// O... | <p>You create a loop for reading.</p>
<p>Stream.Read returns int for the bytes it read so far, or 0 if the end of stream is reached.</p>
<p>So, its like:</p>
<pre><code>int bytes_read = 0;
while (bytes_read < buffer.Length)
bytes_read += stream.Read(buffer, bytes_read, buffer.length - bytes_read);
</code></pre... | <p>This is a possible way to do that and get in "response" the response string. If you need the byte array, just save ms.ToArray().</p>
<pre><code>string response;
TcpClient client = new TcpClient();
client.Connect(server, port);
using (NetworkStream ns = c.GetStream())
using (MemoryStream ms = new MemoryStream())
{
... | 20,333 |
<p>I'm working on a game (C#) that uses a <a href="http://robocode.sourceforge.net/" rel="nofollow noreferrer">Robocode-like</a> programming model: participants inherit a base Class and add strategic behaviors. The game then loads instances of participants' Classes and the competition begins. Unfortunately, participant... | <p>Load each competitor into a different AppDomain.</p>
| <p>I don't have a specific answer, but I would look at the .NET <a href="http://www.codeplex.com/terrarium2" rel="nofollow noreferrer">Terrarium</a> project. All participants are user loaded DLLs. They have done a lot of neat stuff to prevent unsafe and cheater code from loading/executing.</p>
<p>Justin Rogers has <a ... | 10,969 |
<p>I dynamically create an element (div) in javascript, on which i register an event listener:</p>
<pre><code>var tooltip = document.createElement('div');
tooltip.onclick = function() { alert('hello'); }
</code></pre>
<p>Now, if I attach this element to the document body:</p>
<pre><code>document.body.appendChild(to... | <p>Maybe you need to register the event handler after appending?</p>
| <p>Your code works fine for me on firefox 3.0.5 and IE7. Are you sure your example is correct?</p>
| 49,489 |
<p>I'm looking for a small and fast library implementing an HTTP server in .NET</p>
<p>My general requirements are:</p>
<ul>
<li>Supports multiple simultaneous connections</li>
<li>Only needs to support static content (no server side processing)</li>
<li>HTTP only, HTTPS not needed</li>
<li>Preferably be able to serv... | <p>Use <a href="http://www.asp.net/downloads/archived/cassini/" rel="nofollow noreferrer">Cassini</a>.</p>
<p>Free, Open Source.</p>
<p>It would take trivial hacking to serve from memory.</p>
| <p><a href="https://github.com/javidsho/LightHTTP" rel="nofollow noreferrer">LightHTTP</a> is an open-source library I've created that does exactly what you need.</p>
<ul>
<li>It can be used in testing and mocking, or other scenarios where a lightweight HTTP server is preferred.</li>
<li>It works asynchronously.</li>
<... | 34,421 |
<p>I've been trying for a while now to write a unit test for a UserViewControl in ASP.NET MVC. I'd like to get to code that looks something like this:</p>
<pre><code>[TestMethod]
public void HaveControlToDisplayThings()
{
var listControl = new ControlUnderTest();
var viewData = new ViewDataDictionary<IList&... | <p>Unfortunately, the ASP.NET viewengine uses the VirtualPathProvider in the ASP.NET hosting environment. To make matters worse, I traced some of the other code using Reflector and found that there is other dependencies to some hardcode references to VirtualPath utilities.
I hope they fix this in the release so we can... | <p>These are the values that need to be set in the HttpBrowserCapabilities object for a asp.net webforms site to run, I would try making sure these are set and see if that fixes your problem, I'm not sure if it would but hey it worth a shot right?</p>
<ul>
<li>Browser (aka name)</li>
<li>useragent (passed in the reque... | 28,368 |
<p>I want have to have a single imageList used by multiple forms in a project. That is to say, multiple controls use the same image list.</p>
<p><em>Note: Ideally multiple projects in a single solution will use the same image list - but I don't want to ask too much of Microsoft at once.</em></p>
<p>Some controls are ... | <p>As for the principal question:</p>
<blockquote>
<p>.NET Windows Forms 2.0: How to have a shared imagelist?</p>
</blockquote>
<p>You can share the ImageList with a UserControl. Just add the UserControl in all your form and you will be able to access the ImageList.</p>
| <p>I fired up Visual Studio and thought "lets make a enhanced ImageList control that inherits from the imagelist and fix this and post a solution on SO" and was let down with a bang, the ImageList control is sealed (noninheritable) so I got stuck before I even started. </p>
<p>But I remembered that somwhere someone ha... | 43,048 |
<p>I need to specify a date value in a sybase where clause. For example:</p>
<pre><code>select *
from data
where dateVal < [THE DATE]
</code></pre>
| <p>Use the convert function, for example:</p>
<pre><code>select * from data
where dateVal < convert(datetime, '01/01/2008', 103)
</code></pre>
<p>Where the convert style (103) determines the date format to use.</p>
| <p>102 is the rule of thumb,
convert (varchar, creat_tms, 102) > '2011'</p>
| 8,018 |
<p>I have an animation and I want it to play it just only once. From where can I set so when I export to SWF the default will be AUTO LOOPING disabled.</p>
<p>Thanks</p>
| <p>Insert a keyframe in the last frame and put a stop(); there? </p>
| <p>Please following code</p>
<pre><code><param name='loop' value='false' />
<object type='application/x-shockwave-flash' data='sourcefile' width='300' height='120' loop='false'>
</code></pre>
<p>This works perfectly</p>
| 47,082 |
<p>I'm currently doing the following to use typed datasets in vs2008: </p>
<p>Right click on "app_code" add new dataset, name it tableDS.</p>
<p>Open tableDS, right click, add "table adapter"</p>
<p>In the wizard, choose a pre defined connection string, "use SQL statements"</p>
<p>select * from tablename and next +... | <p>A bit of a shift, but you ask about different patterns - how about LINQ? Since you are using VS2008, it is possible (although not guaranteed) that you might also be able to use .NET 3.5.</p>
<p>A LINQ-to-SQL data-context provides much more managed access to data (filtered, etc). Is this an option? I'm not sure I'd ... | <p>You can add a query with a where clause to the tableadapter for the table you're interested in.</p>
<p>LINQ is nice, but it's really just shortcut syntax for what the OP is already doing.</p>
<p>Typed Datasets make perfect sense unless your data model is very complex. Then writing your own ORM would be the best c... | 37,731 |
<p>How can I insert ASCII special characters (e.g. with the ASCII value 0x01) into a string?</p>
<p>I ask because I am using the following:</p>
<pre><code>str.Replace( "<TAG1>", Convert.ToChar(0x01).ToString() );
</code></pre>
<p>and I feel that there must be a better way than this. Any Ideas?</p>
<p>Update:<... | <p>I believe you can use <code>\uXXXX</code> to insert specified codes into your string.</p>
<p>ETA: I just tested it and it works. :-)</p>
<pre><code>using System;
class Uxxxx {
public static void Main() {
Console.WriteLine("\u20AC");
}
}
</code></pre>
| <blockquote>
<p>Also If I use this methodology, do I need to worry about unicode & ASCII clashing?</p>
</blockquote>
<p>Your first problem will be your tags clashing with ASCII. Once you get to TAG10, you will clash with 0x0A: line feed. If you ensure that you will never get more than nine tags, you should be sa... | 12,548 |
<p>Our customer would like to know <strong>who</strong> is online and currently using the custom application we wrote for them. I discussed it with them and this does not need to be <strong>exact</strong>, more of a guestimate will work. </p>
<p>So my thought is a 15 minute time interval to determine user activity. ... | <p>Our solution is to maintain a "Transaction" table (which follows what was done), in addition to our "Session" table (which follows who was here). UPDATE, INSERT and DELETE instructions are all managed through a "Transaction" object and each of these SQL instruction is stored in the "Transaction" table once it has be... | <p>I'd just drop a log record table in the db. </p>
<p>UserId int FK<br>
Action char(3) ('in' or 'out')<br>
Time DateTime </p>
<p>You can drop a new record in the table when somebody logs in or out or alternatively update the last record for the user.</p>
| 20,995 |
<p>Does anyone know of a whirlwind tour of Eclipse that would help a (former) Visual Studio user get up to speed with it?</p>
<p>I just want something that tells me where all the basic features are and what all the cool stuff I've heard so much about is?</p>
<p>So far I've been using it mostly as a text editor and ha... | <p>Is the problem in an executable or a DLL?</p>
<p>If it's a DLL what is its preferred load address? If this clashes with any other DLL then it will be rebased by the loader, and this can lead to what you're seeing. </p>
<p>As part of your build process, you should ensure that all your DLLs are rebased (there's a to... | <p>When you are in the debugger and stepping into the code, can you check if the code address is within the range that you see in the "Modules" window? Sometimes the same piece of code may exist in several modules of same / different names.</p>
<p>Once you identify the "Module" which contains the code, use the base ad... | 21,985 |
<p>Ever wanted to have an HTML drag and drop sortable table in which you could sort both rows and columns? I know it's something I'd die for. There's a lot of sortable lists going around but finding a sortable table seems to be impossible to find. </p>
<p>I know that you can get pretty close with the tools that script... | <p>I've used jQuery UI's sortable plugin with good results. Markup similar to this:</p>
<pre><code><table id="myTable">
<thead>
<tr><th>ID</th><th>Name</th><th>Details</th></tr>
</thead>
<tbody class="sort">
<tr id="1"><td>1</td>... | <p>How about <a href="http://www.kryogenix.org/code/browser/sorttable/" rel="nofollow noreferrer">sorttable</a>? That would seem to fit your requirements nicely.</p>
<p>It's rather easy to use - load the sorttable Javascript file, then, for each table you want it to make sortable, apply class="sortable" to the <ta... | 10,794 |
<p>I am trying to log a method's parameters by using reflection. I read the <a href="https://stackoverflow.com/questions/168396/capturing-method-state-using-reflection">earlier question</a> posted about this issue on StackOverflow as well which pointed me to CLR API's. </p>
<p>Is it possible, someone can point me to t... | <p>Basically you can't in "vanilla" .NET code. Parameters are just local variables, and their values can't be fetched without delving into the debugger API mentioned in the other thread.</p>
<p>What you <em>may</em> be able to do is use <a href="http://www.sharpcrafters.com/solutions/logging" rel="nofollow noreferrer"... | <p>@ Sean: This seems promising, Is it possible to intercept and get values like that in WCF? I know the service log already contains that information but it is difficult to dig through it which makes me look for alternative ways to log methods and their parameters. </p>
| 22,782 |
<p>I have an algorithm that generates strings based on a list of input words. How do I separate only the strings that sounds like English words? ie. discard <strong>RDLO</strong> while keeping <strong>LORD</strong>.</p>
<p><strong>EDIT:</strong> To clarify, they do not need to be actual words in the dictionary. They j... | <p>You can build a markov-chain of a huge english text.</p>
<p>Afterwards you can feed words into the markov chain and check how high the probability is that the word is english.</p>
<p>See here: <a href="http://en.wikipedia.org/wiki/Markov_chain" rel="noreferrer">http://en.wikipedia.org/wiki/Markov_chain</a> </p>
<... | <p>I'd suggest a few simple rules and standard pairs and triplets would be good.</p>
<p>For example, english sounding words tend to follow the pattern of vowel-consonant-vowel, apart from some dipthongs and standard consonant pairs (e.g. th, ie and ei, oo, tr). With a system like that you should strip out almost all w... | 11,749 |
<p>I've got an NSColor, and I really want the 32-bit RGBA value that it represents. Is there any easy way to get this, besides extracting the float components, then multiplying and ORing and generally doing gross, endian-dependent things?</p>
<p>Edit: Thanks for the help. Really, what I was hoping for was a Cocoa fu... | <p>Another more brute force approach would be to create a temporary CGBitmapContext and fill with the color. </p>
<pre><code>NSColor *someColor = {whatever};
uint8_t data[4];
CGContextRef ctx = CGBitmapContextCreate((void*)data, 1, 1, 8, 4, colorSpace, kCGImageAlphaFirst | kCGBitmapByteOrder32Big);
CGContextSetRGBFi... | <p>Converting the 4 floats to their integer representation, however you want to accomplish that, is the only way.</p>
| 41,726 |
<p>What are all the valid self-closing elements (e.g. <br/>) in XHTML (as implemented by the major browsers)?</p>
<p>I know that XHTML technically allows any element to be self-closed, but I'm looking for a list of those elements supported by all major browsers. See <a href="http://dusan.fora.si/blog/self-closi... | <p>Every browser that supports XHTML (Firefox, Opera, Safari, <a href="https://learn.microsoft.com/en-us/archive/blogs/ie/xhtml-in-ie9" rel="noreferrer">IE9</a>) supports self-closing syntax on <strong>every element</strong>.</p>
<p><code><div/></code>, <code><script/></code>, <code><br></br></c... | <p><hr /> is another</p>
| 12,303 |
<p>In my Silverlight app I want a multi-line text box to expand every time the user hits Enter.</p>
<p>The difficult part is how to calculate the correct height based on the number of text lines.</p>
<p>I have tried the following but the textbox becomes too small:</p>
<pre><code>box.Height = box.FontSize*lineCount +... | <p>This seems to be how the textbox works out of the box. Just make sure you set the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.acceptsreturn(VS.95).aspx" rel="nofollow noreferrer">AcceptsReturn</a>="True" on the textbox. Also make sure you don't set the height of the Textbox so th... | <p>The <code>TextBox</code> will fire a <code>SizeChanged</code> event, and it will also set the <code>ActualHeight</code> property. </p>
<p>I don't think this was the case in Silverlight 2, when I had to use a <code>TextBlock</code> with the same font, set the padding to 4, and set the same text, and get the <code>Ac... | 33,739 |
<p>I'm evaluating Visual Studio productivity addons for my development team, which includes some folks who are very new to C# and some folks who are very experienced. We don't use VB.NET. I personally like ReSharper, but before I suggest something that I personally like, I would like some opinions for and reasoning beh... | <p>I downloaded both resharper and coderush trials. Initially I liked coderush a bit better. It seems a bit more polished and a bit more stable. But eventually I did go with resharper. Mainly because of the unit testing integration.</p>
<p>I don't really see why you have to choose for your development team though. In ... | <p>I recommend ReSharper 4.0 with VS 2008. It really offers the best refactoring commands.</p>
<p>ReSharper 4.0 has really been improved since it's beta. However, I heard that CodeRush had a better templating model. Personally, I rather have a powerful refactoring tool rather than a templating tool.</p>
<p>I suggest ... | 20,161 |
<p>What are the best practices when managing a software project involving a non-English-speaking client?</p>
<p>What communication issues are relevant? Would you maintain documentation in both languages (especially updating the specifications regularly)?</p>
| <p>My native language is not English, so I'm on the other side. There were times when we had to write project documents in 4-6 languages.</p>
<p>Try to find somebody who understand English (like a key person). I try to avoid the communication in different languages on a project. Of course you can talk and write on dif... | <p>Always follow up with a written confirmation of any verbal discussion. Most people can read foreign languages better then they can speak them. It also helps to pick one language as the standard for all documents and code. </p>
| 25,034 |
<p>What are some suggestions for easy to use C++ compilers for a beginner? Free or open-source ones would be preferred.</p>
| <p>GCC is a good choice for simple things.</p>
<p>Visual Studio Express edition is the free version of the major windows C++ compiler.</p>
<p>If you are on Windows I would use VS. If you are on linux you should use GCC.</p>
<p>*I say GCC for simple things because for a more complicated project the build process isn'... | <p>Visual Studio in command line behaves just like GCC. Just open the Visual Studio command line window and:</p>
<p><code><pre>
c:\temp> cl /nologo /EHsc /W4 foo.cpp
c:\temp> dir /b foo.*
foo.cpp <-- your source file
foo.obj <-- result of compiling the cpp file
foo.pdb <-- debugging symbols (friendly names... | 10,271 |
<p>We have, now, assertained that <em>inlined videos</em> (for want of a better description) are currently turned off (disabled) for SE 3D Printing, but can be turned on at any time, and there is no need to wait for the site to exit Beta, see <a href="https://3dprinting.meta.stackexchange.com/questions/226/is-the-inlin... | <p>Per answer to <a href="https://meta.stackexchange.com/questions/296832/what-are-the-limitations-in-beta">What are the limitations in Beta</a></p>
<p>"Inline videos is a feature that is off by default on all sites and only turned on if the community thinks it's necessary to improve the quality of a good portion of t... | <p>A note of caution, <a href="https://stackoverflow.com/c/moderators/questions/257#answer-261">this post</a> on the Stack Moderators site, Pᴀᴜʟsᴛᴇʀ2's post, <a href="https://stackoverflow.com/c/moderators/questions/257">How do you request embedded video for your site?</a> - As mods can only follow these links I've inc... | 42 |
<p>In a C# .NET 3.5 app (a mix of WinForms and WPF) I want to let the user select a folder to import a load of data from. At the moment, it's using <code>System.Windows.Forms.FolderBrowserDialog</code> but that's a bit lame. Mainly because you can't type the path into it (so you need to map a network drive, instead of ... | <p>Don't create it yourself! It's been done. You can use <a href="http://dotnetzip.codeplex.com/SourceControl/changeset/view/29832#432677" rel="nofollow noreferrer">FolderBrowserDialogEx</a> -
a re-usable derivative of the built-in FolderBrowserDialog. This one allows you to type in a path, even a UNC path. You ca... | <p>So far, based on the lack of responses to <a href="https://stackoverflow.com/questions/31059/how-do-you-configure-an-openfiledialog-to-select-folders">my identical question</a>, I'd assume the answer is to roll your own dialog from scratch.</p>
<p>I've seen things here and there about subclassing the common dialogs... | 6,801 |
<p>For some reason, new projects set the version number of the assembly to 1.0.*, which then assigns what appears to be a random number once compiled.</p>
<p>Why is this not set to 1.0.0.0 like all other projects.</p>
<p>Thanks.</p>
| <p>The numbers aren't random, though they can appear that way if you don't know how they're generated. I came across it a while ago:</p>
<p>When a version is 1.0.d.s, "d" is the number of days since February 1, 2000 and "s" is the number of seconds since midnight/2.</p>
| <p>I have noticed that some templates have different behaviors in regards to this. My guess is they want to make sure it increments by default.</p>
<p>You can modify the template if you don't like the default setup.</p>
| 28,978 |
<p>I want to log in to Stack Overflow with Techorati OpenID hosted at my site.</p>
<p><a href="https://stackoverflow.com/users/login">https://stackoverflow.com/users/login</a> has some basic information.</p>
<p>I understood that I should change</p>
<pre><code><link rel="openid.delegate" href="http://yourname.x.co... | <p>when reimporting your keys from the old keyring, you need to specify the command:</p>
<pre><code>gpg --allow-secret-key-import --import <keyring>
</code></pre>
<p>otherwise it will only import the public keys, not the private keys.</p>
| <p>The resolution to this problem for me, was to notify the sender that he did use the Public key that I sent them but rather someone elses. You should see the key that they used. Tell them to use the correct one.</p>
| 11,677 |
<p>I'm looking for an open source search indexing library. It will be used for embedded web application so it should have a small code size. Preferably, written in C, C++ or PHP and does not require any database to be installed for storing indexes. Indexes should be stored on a file instead (e.g., xml, txt). I tried to... | <p><a href="http://hyperestraier.sourceforge.net/" rel="nofollow noreferrer">Hyper Estraier</a>.</p>
| <p>First: you have to store indexes somewhere. So a data file will be needed unless you want memory only indexes.</p>
<p>To index generic items, I can recommend you sqlite: <a href="http://www.sqlite.org/" rel="nofollow noreferrer">http://www.sqlite.org/</a>. I even use it in memory only mode when I have a bunch of da... | 11,595 |
<p>I have a Viewbox with <code>Stretch=Uniform</code> in order to not distort the content.
However, when the frame window is wider or taller than the content, the Viewbox content is always centered.</p>
<p>I cannot seem to find any content alignment options on the Viewbox.
Is there a way to do this?</p>
| <p>Try <code>VerticalAlignment="Top"</code> and <code>HorizontalAlignment="Left"</code> on your viewbox. It will cause it to be anchored to the top and left side.</p>
<pre><code><Grid>
<Viewbox VerticalAlignment="Top" HorizontalAlignment="Left">
...
</Viewbox>
</Grid>
</code></pre>
... | <p>According to <a href="http://msdn.microsoft.com/en-us/library/ms741838.aspx" rel="nofollow noreferrer">MSDN</a> the Viewbox is used to stretch the child elements. Since the child elements would be stretched, you would have to set the content alignment of the children.</p>
<p>You may want to look at this for more i... | 44,469 |
<p>Does PHP have a method of having auto-generated class variables? I <em>think</em> I've seen something like this before but I'm not certain.</p>
<pre><code>public class TestClass {
private $data = array();
public function TestClass() {
$this->data['firstValue'] = "cheese";
}
}
</code></pre>
... | <p>See here: <a href="http://www.php.net/manual/en/language.oop5.overloading.php" rel="noreferrer">http://www.php.net/manual/en/language.oop5.overloading.php</a></p>
<p>What you want is the "__get" method. There is an example for what you need on the link.</p>
| <p>Use the PHP5 "magic" <code>__get()</code> method. It would work like so:</p>
<pre><code>public class TestClass {
private $data = array();
// Since you're using PHP5, you should be using PHP5 style constructors.
public function __construct() {
$this->data['firstValue'] = "cheese";
}
... | 12,685 |
<p>What is the best, preferably free/open source tool for auto-generating Java unit-tests? I know, the unit-tests cannot really serve the same purpose as normal TDD Unit-Tests which document and drive the design of the system. However auto-generated unit-tests can be useful if you have a huge legacy codebase and want t... | <p>Not free. Not opensource. But I have found AgitarOne Agitator (<a href="http://www.agitar.com/solutions/products/agitarone.html" rel="nofollow noreferrer">http://www.agitar.com/solutions/products/agitarone.html</a>) to be REALLY good for automatically generating unit tests AND looking for unwanted obscure side effec... | <p>To be honest, I probably wouldn't do this. Unit tests are isolated and you won't actually know if you have "unwanted, obscure side-effects" because everything is walled off from the other things that cause the side effects. As a result, you need integration or system testing and <em>that</em> is not something you ... | 10,673 |
<p>Is there an easy method to store a person's user settings in a sql 2000 database. Ideally all settings in one field so I don't keep having to edit the table every time I add a setting. I am thinking along the lines of serialize a settings class if anyone has an example.</p>
<p>The reason I don't want to use the bui... | <p>The VS designer keeps property settings in the <a href="http://msdn.microsoft.com/en-us/library/system.configuration.applicationsettingsbase.aspx" rel="nofollow noreferrer">ApplicationSettingsBase</a> class. By default, these properties are serialized/deserialized into a per user XML file. You can override this beha... | <p>First you need your table.</p>
<pre><code>create table user_settings
(
user_id nvarchar(256) not null,
keyword nvarchar(64) not null,
constraint PK_user_settings primary key (user_id, keyword),
value nvarchar(max) not null
)
</code></pre>
<p>Then you can build your API:</p>
<pre><code>public string GetU... | 20,660 |
<p>I am trying to implement a custom "broken image" icon to appear if I cannot load an image. To accomplish this, I used the brokenImageSkin parameter, but it renders the image at its true resolution, which ends up cutting off the image if the size of the control is constrained.</p>
<pre><code> <mx:Image broken... | <p>I see that in this example,
<a href="http://blog.flexexamples.com/2008/03/02/setting-a-custom-broken-image-skin-for-the-image-control-in-flex/#more-538" rel="nofollow noreferrer">http://blog.flexexamples.com/2008/03/02/setting-a-custom-broken-image-skin-for-the-image-control-in-flex/#more-538</a>, there is an IO err... | <ol>
<li><p>Make a new class that extends ProgrammaticSkin. Embed your image using the [Embed] meta keyword and associate it with a variable of type Class (see the documentation for this)</p></li>
<li><p>Override updateDisplaylist.</p></li>
<li><p>Call graphics.clear() in this function.</p></li>
<li><p>Call graphics.b... | 18,745 |
<p>Do not waste your time with this question. Follow up to: <a href="https://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons">What is so bad about singletons?</a></p>
<hr>
<p><strike>Please feel free to bitch on <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow noreferrer">Sing... | <p>There's nothing inherently wrong with the Singleton pattern. It is a tool and sometimes it should be used.</p>
| <p>Most of the singleton patterns that I see written aren't written in a thread safe manner. If written correctly, they can be useful.</p>
| 11,219 |
<p>I am having a very strange problem. I have a very large regular expression searching for certain words in some text (RegEx looks something like this: <code>(?i)\b(a|b|c|d...)\b;</code> and so on where a, b, c, d, represent words). Anyway, I put it in a pre compiled assembly to speed things up a bit, however the prob... | <p>Since you are searching for whole words, how about searching for <code>\w+</code>, and checking if the word is in a collection. A hash-based set or a hash-map would work well here. This approach would make it easier to update the list if the need should arise.</p>
| <p>You've given two different languages there. So maybe there's some interaction.</p>
<p>In any case I think some short but complete test programs might be in order - try and reproduce the problem in some independent test code to make it easier to reason about.</p>
<p>Maybe it would be more efficient to do the search... | 47,279 |
<p>Sample code that shows how to create threads using MFC declares the thread function as both static and <code>__cdecl</code>. Why is the latter required? Boost threads don't bother with this convention, so is it just an anachronism?</p>
<p>For example (MFC):</p>
<pre><code>static __cdecl UINT MyFunc(LPVOID pParam... | <p>__cdecl tells the compiler to use the C calling convention (as opposed to the stdcall, fastcall or whatever other calling convention your compiler supports). I believe, VC++ uses stdcall by default.</p>
<p>The calling convention affects things such as how arguments are pushed onto the stack (or registers, in the ca... | <p>Because your thread is going to be called by a runtime function that manages this for you, and that function expects it to be that way. Boost designed it a different way.</p>
<p>Put a breakpoint at the start of your thread function and look at the stack when it gets called, you'll see the runtime function that cal... | 20,557 |
<p>I need to load some fonts temporarily in my program. Preferably from a dll resource file.</p>
| <p>And here a Delphi version:</p>
<pre><code>procedure LoadFontFromDll(const DllName, FontName: PWideChar);
var
DllHandle: HMODULE;
ResHandle: HRSRC;
ResSize, NbFontAdded: Cardinal;
ResAddr: HGLOBAL;
begin
DllHandle := LoadLibrary(DllName);
if DllHandle = 0 then
RaiseLastOSError;
ResHandle := FindRes... | <p>Here's some code that will load/make available the font from inside your executable (ie, the font was embedded as a resource, rather than something you had to install into Windows generally). </p>
<p>Note that the font is available to <em>any</em> application until your program gets rid of it.
I don't know how usef... | 13,305 |
<p>I'm fairly new to WPF and I've come across a problem that seems a bit tricky to solve. Basically I want a 4x4 grid thats scalable but keeps a square (or any other arbitrary) aspect ratio. This actually seems quite tricky to do, which surprises me because I would imagine its a reasonably common requirement.</p>
<p... | <p>You need to put the content (the grid) inside a <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.viewbox.aspx" rel="noreferrer">Viewbox</a> and set the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.viewbox.stretch.aspx" rel="noreferrer">Viewbox.Stretch Property</a> ... | <p>put 0.25* instead of * for each Column and RowWidth</p>
| 36,785 |
<p>In my model I have:</p>
<pre><code>validate :my_custom_validation
def my_custom_validation
errors.add_to_base("error message") if condition.exists?
end
</code></pre>
<p>I would like to add some parameters to mycustomer vaildation like so:</p>
<pre><code>validate :my_custom_validation, :parameter1 => x, :para... | <p>Validators usualy have an array parameter indicating, first, the fields to validate and lastly (if it exists) a hash with the options. In your example:</p>
<pre><code>:my_custom_validation, parameter1: x, parameter2: y
</code></pre>
<p>:my_custom_validation would be a field name, while parameter1: x, parameter2: y... | <p>You should also be able to use a <a href="https://www.geeksforgeeks.org/lambda-function-ruby/" rel="nofollow noreferrer">Ruby lambda</a> to help with method based validation of your model attributes (x, y) like below:</p>
<pre><code>validate -> { my_custom_validation(parameter1: x, parameter2: y) }
</code></pre>
| 13,172 |
<p>I'm familiar with the issue behind ORA-01775: looping chain of synonyms, but is there any trick to debugging it, or do I just have to "create or replace" my way out of it? </p>
<p>Is there a way to query the schema or whatever to find out what the current definition of a public synonym is? </p>
<p>Even more awes... | <p>As it turns out, the problem wasn't actually a looping chain of synonyms, but the fact that the synonym was pointing to a view that did not exist.</p>
<p>Oracle apparently errors out as a looping chain in this condition.</p>
| <p><a href="http://ora-01775.ora-code.com/" rel="nofollow noreferrer">http://ora-01775.ora-code.com/</a> suggests:</p>
<p><strong>ORA-01775</strong>: looping chain of synonyms<br>
<em>Cause</em>: Through a series of CREATE synonym statements, a synonym was defined that referred to itself. For example, the followin... | 30,683 |
<p>I have exceptions created for every condition that my application does not expect. <code>UserNameNotValidException</code>, <code>PasswordNotCorrectException</code> etc.</p>
<p>However I was told I should not create exceptions for those conditions. In my UML those ARE exceptions to the main flow, so why should it n... | <p>My personal guideline is: an exception is thrown when a fundamental assumption of the current code block is found to be false.</p>
<p>Example 1: say I have a function which is supposed to examine an arbitrary class and return true if that class inherits from List<>. This function asks the question, "Is this obje... | <p>The exceptions versus returning error code argument should be about flow control not philosophy (how "exceptional" an error is):</p>
<pre><code>void f1() throws ExceptionType1, ExceptionType2 {}
void catchFunction() {
try{
while(someCondition){
try{
f1();
}catch(ExceptionType2 e2){
... | 10,272 |
<p>We have a solution where we are picking the messages using Windows Service. </p>
<p>The Windows Service fires every after 2 minutes and retrieves the MSMQ message to pass it to a Web Service.</p>
<ol>
<li>Can I create a WCF service which will automatically picks up the messages from MSMQ Queue?</li>
<li>Can I avoi... | <p>Q1: you can automatically pick up messages from MSMQ, you will need to look into the netmsmqbinding, there are some design considerations that you have to think about though, if you are used to the native MSMQ, you know that you have the ability to peek at the messages. But when you use WCF, you loose that ability t... | <p>One way to transfer messages from an MSMQ to a web service call is to use a netMsmqBinding service endpoint and a basicHttpBinding client endpoint that support the same contract. The netMsmq service will automatically grab messages from the queue and deserialize them into an object. In your implementation of your ... | 48,760 |
<p>I have only just set up my Anet A6 today. I am trying to print a calibration box, but the print is moving around the bed while trying to print. Any ideas how to fix this? The documentation is very vague.</p>
<p>Basically I am very new to 3D printing. I purchased an Anet A6 and have set it up stock. I am trying to j... | <p>If the printed material moves with the nozzle, you might have several problems at hand, e.g.:</p>
<ul>
<li>adhesion, </li>
<li>nozzle to bed distance and </li>
<li>overall level.</li>
</ul>
<p>Nozzle to bed distance needs to be the thickness of a plain A4 or Letter paper. This needs to be at the same distance (whe... | <p>Chances are, you're not levelled close enough. try levelling your bed when it's heated around 60C (or as high as you can get if your machine's FW won't let it go that high) with a piece of standard printer paper. you should get a bit of resistance, and play around with the paper for a bit, find a happy medium. Try s... | 1,231 |
<p>I have a Django model with a large number of fields and 20000+ table rows. To facilitate human readable URLs and the ability to break down the large list into arbitrary sublists, I would like to have a URL that looks like this:</p>
<pre><code>/browse/<name1>/<value1>/<name2>/<value2>/ .... ... | <p>A possibility that you might consider is matching the entire string of possible values within the url pattern portion and pull out the specific pieces within your view. As an example:</p>
<pre><code>urlpatterns = patterns('',
url(r'^browse/(?P<match>.+)/$', 'app.views.view', name='model_browse'),
)
def ... | <p>Same answer came to me while reading the question.</p>
<p>I believe model_browse view is the best way to sort the query parameters and use it as a generic router.</p>
| 30,964 |
<p>I created a single page (with code behind .vb) and created Public intFileID As Integer</p>
<p>in the Page load I check for the querystring and assign it if available or set intFileID = 0.</p>
<pre><code>Public intFileID As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Ha... | <p>As others have pointed out, you can store it in the Session or the ViewState. If it's page specific, I like to store it in the ViewState as opposed to the Session, but I don't know if one method is generally preferred over the other.</p>
<p>In VB, you would store an item in the ViewState like:</p>
<pre><code>View... | <p>I'll use Session as <a href="https://stackoverflow.com/questions/222999/how-to-persist-variable-on-postback/223006#223006">suggested by tvanfosson.</a>
ViewState and HiddenField might be too heavy if you want to keep large data like a dataset for comments in a forum's topic pages..</p>
| 27,521 |
<p>I am using the WebBrowser control to add a WebInterface to C# app. My desire is to verify that only such app is able to connect to our Web server using SSL client certificates.</p>
<p>My idea was to embed the client certificate in the app and just use when connecting via my app. Anybody have a sugestion on how to d... | <p>Are you sure this is what you want to do? If you embed the private key in your application (as your approach entails), an attacker can extract it and use it to authenticate their rogue software.</p>
<p>A server cannot authenticate client software. It can only test whether a client possesses some secret. When you em... | <p>The intent of using the key is not so much to validate the users as to restrict access to users of the app instead of using any WebBrowser. This is sort of an intranet behavior over the public internet.</p>
<p>This is a poor man's DRM. The losses due to people extracting the key are not that important. I think the ... | 12,188 |
<p>I would like to compare two dates in javascript. I have been doing some research, but all I can find is how to return the current date. I want to compare 2 separate dates, not related to today. How do I do that. </p>
<pre><code>var startDate = Date(document.form1.Textbox2);
</code></pre>
| <pre><code>if (date1.getTime() > date2.getTime()) {
alert("The first date is after the second date!");
}
</code></pre>
<p><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date" rel="noreferrer">Reference to Date object</a></p>
| <p>You could try adding the following script code to implement this:</p>
<pre><code>if(CompareDates(smallDate,largeDate,'-') == 0) {
alert('Selected date must be current date or previous date!');
return false;
}
function CompareDates(smallDate,largeDate,separator) {
var smallDateArr = Array();
var largeDa... | 43,934 |
<p>I would like to have two applications in my STM32 flash, one is basically a boot and the other the 'main' application. I have figured out how to load each of them into different areas of flash, and after taking a memory dump everything looks like it is in the right place.</p>
<p>So when I do a reset it loads the bo... | <p>Make sure you jump to an address where the LSB is 1. See this site for an explanation:
<a href="https://www.embedded.com/introduction-to-arm-thumb/" rel="nofollow noreferrer">https://www.embedded.com/introduction-to-arm-thumb/</a></p>
| <p>Richard,</p>
<p>I was trying to do the same thing you succeeded at, but was having problems. I was using the IAR IDE and updated the *.icf file (in the "proj" directory) to put my application at 0x08002000 and loaded a separate project at 0x08000000 that just does a jump to the address at the reset vector at 0x080... | 26,586 |
<p>I'm currently working on a project which needs to persist any kind of object (of which implementation we don't have any control) so these objects could be recovered afterwards. </p>
<p>We can't implement an ORM because we can't restrict the users of our library at development time.</p>
<p>Our first alternative was... | <p>It's 2011, and in a commercial grade REST web services project we use the following serializers to offer clients a variety of media types:</p>
<ul>
<li><a href="http://x-stream.github.io/" rel="noreferrer">XStream</a> (for XML but not for JSON)</li>
<li><a href="https://github.com/FasterXML/jackson" rel="noreferrer... | <p>Another idea: Use cache. Caches provide much better control, scalability and robustness to the application. Still need to serialize, though, but the management becomes much easier with within a caching service framework. Cache can be persisted in memory, disk, database or array - or all of the options - with one... | 29,605 |
<p>Is it possible to disable the browsers vertical and horizontal scrollbars using jQuery or javascript?</p>
| <p>In case you need possibility to hide and show scrollbars dynamically you could use</p>
<pre><code>$("body").css("overflow", "hidden");
</code></pre>
<p>and</p>
<pre><code>$("body").css("overflow", "auto");
</code></pre>
<p>somewhere in your code.</p>
| <p>Because Firefox has an arrow key short cut, you probably want to put a <code><div></code> around it with CSS style: <code>overflow:hidden;</code>.</p>
| 30,034 |
<p>I would like to be able to define and use a custom type in some of my PowerShell scripts. For example, let's pretend I had a need for an object that had the following structure:</p>
<pre><code>Contact
{
string First
string Last
string Phone
}
</code></pre>
<p>How would I go about creating this so that ... | <h2>Prior to PowerShell 3</h2>
<p>PowerShell's Extensible Type System didn't originally let you create concrete types you can test against the way you did in your parameter. If you don't need that test, you're fine with any of the other methods mentioned above. </p>
<p>If you want an actual type that you can cast to ... | <p>Here's one more option, which uses a similar idea to the PSTypeName solution mentioned by <a href="https://stackoverflow.com/a/66693/361842">Jaykul</a> (and thus also requires PSv3 or above).</p>
<h1>Example</h1>
<ol>
<li>Create a <strong><em>TypeName</em>.Types.ps1xml</strong> file defining your type. E.g. <code... | 8,454 |
<p>I worked on an embedded system this summer written in straight C. It was an existing project that the company I work for had taken over. I have become quite accustomed to writing unit tests in Java using JUnit but was at a loss as to the best way to write unit tests for existing code (which needed refactoring) as ... | <p>One unit testing framework in C is <a href="https://libcheck.github.io/check/" rel="noreferrer">Check</a>; a list of unit testing frameworks in C can be found <a href="http://check.sourceforge.net/doc/check_html/check_2.html#SEC3" rel="noreferrer">here</a> and is reproduced below. Depending on how many standard lib... | <p>In case you are targeting Win32 platforms or NT kernel mode, you should have a look at <a href="http://cfix.sf.net/" rel="nofollow noreferrer">cfix</a>.</p>
| 9,149 |
<p>I'm making a simple IRC Bot in C. And I finally got the bot connecting and receiving information. My code is supposed to be sending as well, but the server is acting as if it is not sending anything. When The bot connects, I receive this:</p>
<blockquote>
<p>Recieved: :roc.esper.net NOTICE AUTH
:*** Looking up ... | <p>Try sending the USER command before the NICK command. What IRC network are you trying to connect to?</p>
<pre><code>"
> telnet irc.freenode.net 6667
NOTICE AUTH :*** Looking up your hostname...
NOTICE AUTH :*** Checking ident
NOTICE AUTH :*** No identd (auth) response
NOTICE AUTH :*** Couldn't look up your hostn... | <p>From the tutorials I looked at (like <a href="http://www.haskell.org/haskellwiki/Roll_your_own_IRC_bot" rel="nofollow noreferrer">this one</a>), it seems that you are doing it right, except that this</p>
<pre><code>USER Goo * * :Goo
</code></pre>
<p>is</p>
<pre><code>USER Goo 0 * :Goo
</code></pre>
<p>in all the... | 41,826 |
<p>We've been using Scrum on a few projects now with varying success and I now have a query relating to documentation.</p>
<p>In Scrum, you obviously have the product backlog ("The application begins by bringing up the last document the user was working with.") and the sprint task backlog ("Implement forgot password s... | <p><a href="http://en.wikipedia.org/wiki/Scrum_(development)#Sprint_backlog" rel="noreferrer">Sprint backlog</a></p>
<blockquote>
<p>The sprint backlog is a greatly
detailed document containing
information about how the team is
going to implement the requirements
for the upcoming sprint. Tasks are
broken d... | <p>My understanding is that specific requirements such as this are handled by the product owner. They will liase with the client during Sprint Planning 2 and update the tasks with specfic requirements as needed - hence why the Product Owner is a optional attendee of the Sprint Planning 2 meeting. This gives you a hybri... | 15,372 |
<p>I have a gridview that is within an updatepanel for a modal popup I have on a page.<br>
The issue is that the entire page refreshes every time I click an imagebutton that is within my gridview. This causes my entire page to load and since I have grayed out the rest of the page so that the user cannot click on it thi... | <p>do you have ChildrenAsTriggers="false" on the UpdatePanel?</p>
<p>Are there any javascript errors on the page?</p>
| <p>Is the Modal Window popped up using the IE Modal window? Or is it a DIV that you are showing?</p>
<p>If it is an IE Modal Pop up you need to ensure you have </p>
<pre><code> <base target="_self" />
</code></pre>
<p>To make sure the post back are to the modal page.</p>
<p>If it is a DIV make sure you ha... | 5,516 |
<p>Due to a lack of response to my original <a href="https://stackoverflow.com/questions/124258/how-would-you-allow-users-to-edit-attachments-in-a-web-application">question</a>, probably due to poor wording on my part. Since then, I have thought about my original question and decided to reword it, hopefully for the be... | <ul>
<li>Start with one file upload control ("Browse button"), and use JavaScript to dynamically add more upload controls if they want to attach multiple files in a single batch.</li>
<li>Display them in a simple list format (Filename, type, size, date), but provide full details somewhere else if they want them.</li>
<... | <p><a href="http://developer.yahoo.com/yui/uploader/" rel="nofollow noreferrer">http://developer.yahoo.com/yui/uploader/</a></p>
| 15,724 |
<p>I have a requirement to read and display the owner of a file (for audit purposes), and potentially changing it as well (this is secondary requirement). Are there any nice C# wrappers?</p>
<p>After a quick google, I found only <a href="http://web.archive.org/web/20061116233324/http://www.softinsight.com/bnoyes/Perma... | <p>No need to P/Invoke. <a href="http://msdn.microsoft.com/en-us/library/system.io.file.getaccesscontrol.aspx" rel="noreferrer">System.IO.File.GetAccessControl</a> will return a <a href="http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesecurity_members.aspx" rel="noreferrer">FileSecurity</a> ob... | <pre><code>FileInfo fi = new FileInfo(@"C:\test.txt");
string user = fi.GetAccessControl().GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();
</code></pre>
| 18,477 |
<p>I have a database with <code>account numbers</code> and <code>card numbers</code>. I match these to a file to <code>update</code> any card numbers to the account number so that I am only working with account numbers.</p>
<p>I created a view linking the table to the account/card database to return the <code>Table ID<... | <p>I believe an <code>UPDATE FROM</code> with a <code>JOIN</code> will help:</p>
<h2>MS SQL</h2>
<pre><code>UPDATE
Sales_Import
SET
Sales_Import.AccountNumber = RAN.AccountNumber
FROM
Sales_Import SI
INNER JOIN
RetrieveAccountNumber RAN
ON
SI.LeadID = RAN.LeadID;
</code></pre>
<h2>MySQL and Mari... | <p>If above answers not working for you try this </p>
<pre><code>Update Sales_Import A left join RetrieveAccountNumber B on A.LeadID = B.LeadID
Set A.AccountNumber = B.AccountNumber
where A.LeadID = B.LeadID
</code></pre>
| 27,776 |
<p>What is the easiest way to manage the authorized_keys file for openssh across a large number of hosts? If I need to add or revoke a new key to an account on 10 hosts say, I must login and add the public key manually, or through a clumsy shell script, which is time consuming. </p>
<p>Ideally there would be a central... | <p>I'd checkout the <a href="http://web.monkeysphere.info/" rel="noreferrer">Monkeysphere</a> project. It uses OpenPGP's web of trust concepts to manage ssh's authorized_keys and known_hosts files, without requiring changes to the ssh client or server.</p>
| <p>I've always done this by maintaining a "master" tree of the different servers' keys, and using rsync to update the remote machines. This lets you edit things in one location, push the changes out efficiently, and keeps things "up to date" -- everyone edits the master files, no one edits the files on random hosts.</p... | 10,008 |
<p>I came across the Adobe Flex framework one day. After watching http://www.adobe.com/products/flex/media/flexapp/'> the demo of Flex, it looks to me it is a bundle of different Ajax controls. I have no working knowledge of Flex at all and know very little about Flex. Therefore, I would like to hear from the devel... | <ul>
<li>How productive it is to program in Flex compared to the .Net + Silverlight?</li>
</ul>
<p>Way more productive than Silverlight as it has a much richer and capable control library. Silverlight is rapidly gaining ground here though. I think by the time SL 4 comes out they will reach feature parity, maybe even... | <p>Well ~~ .. it's more that Silverlight is similar to Flex. It's not Ajax so much as a kind of 'walled-garden' inside of which you have a rich programming environment. Somewhat like Java apps say.</p>
<p>The usual criticism derives from just that. Flex/Flash applications tend to be ignorant of the browser (more or le... | 42,555 |
<p><strong>Is there anything built into the core C# libraries that can give me an immutable Dictionary?</strong> </p>
<p>Something along the lines of <em>Java's</em>:</p>
<pre><code>Collections.unmodifiableMap(myMap);
</code></pre>
<p>And just to clarify, I am not looking to stop the keys / values themselves from b... | <p>No, but a wrapper is rather trivial:</p>
<pre><code>public class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>
{
IDictionary<TKey, TValue> _dict;
public ReadOnlyDictionary(IDictionary<TKey, TValue> backingDict)
{
_dict = backingDict;
}
public void... | <p>There's also another alternative as I have described at:</p>
<p><a href="http://www.softwarerockstar.com/2010/10/readonlydictionary-tkey-tvalue/" rel="nofollow">http://www.softwarerockstar.com/2010/10/readonlydictionary-tkey-tvalue/</a></p>
<p>Essentially it's a subclass of ReadOnlyCollection>, which gets the work... | 5,542 |
<p>I was asked implement a licensing schema for our product. They are very expensive products with few customers sparsely distributed around the world and basically every one of them has a design environment (a windows application installed on single windows machines, from 1 to 150 client machines per customer) and a ... | <p>I have yet to see a licensing scheme that wasn't broken in a few weeks provided there was sufficient interest. Your scheme looks very good (though be certain that if someone really wants to, they'll break it). </p>
<p>Whatever you do, you should follow Eric Sink's <a href="http://www.ericsink.com/bos/Transparency.h... | <p>It's not completely clear from your question how your scheme works. Does every instance of the client software have a different key? How long does the license last? Do you have a different key per customer? How is the license paid for? How is a license renewed?</p>
<p>If you are trying to control numbers of us... | 20,519 |
<p>Say I have an input file, and a target directory. How do I determine if the input file is on the same hard-drive (or partition) as the target directory?</p>
<p>What I want to do is the copy a file if it's on a different, but move it if it's the same. For example:</p>
<pre><code>target_directory = "/Volumes/externa... | <p>In C, you would use <code>stat()</code> and compare the <code>st_dev</code> field. In python, <code>os.stat</code> should do the same.</p>
<pre><code>import os
def same_partition(f1, f2):
return os.stat(f1).st_dev == os.stat(f2).st_dev
</code></pre>
| <p>Another way is the “better to ask forgiveness than permission” approach—just try to rename it, and if that fails, catch the appropriate <code>OSError</code> and try the copy approach. ie:</p>
<pre><code>import errno
try:
os.rename(source, dest):
except IOError, ex:
if ex.errno == errno.EXDEV:
# per... | 31,061 |
<p>Why do I get compiler errors with this Java code?</p>
<pre><code>1 public List<? extends Foo> getFoos()
2 {
3 List<? extends Foo> foos = new ArrayList<? extends Foo>();
4 foos.add(new SubFoo());
5 return foos;
6 }</code></pre>
<p>Where 'SubFoo' is a concrete class that implements Foo,... | <p>Use this instead:</p>
<pre><code>1 public List<? extends Foo> getFoos()
2 {
3 List<Foo> foos = new ArrayList<Foo>(); /* Or List<SubFoo> */
4 foos.add(new SubFoo());
5 return foos;
6 }
</code></pre>
<p>Once you declare foos as <code>List<? extends Foo></code>, the compiler ... | <p>The following will work fine:</p>
<pre><code>public List<? extends Foo> getFoos() {
List<Foo> foos = new ArrayList<Foo>();
foos.add(new SubFoo());
return foos;
}
</code></pre>
| 21,254 |
<p>The scenario</p>
<ul>
<li>You have developed a webapp using EJBs version 3.</li>
<li>The system is deployed, delivered and is used by the customer.</li>
</ul>
<p>If you would have to rewrite the system from scratch, would you use EJBs again?</p>
<p><strong>No</strong>: Don't answer this question, answer <a href="... | <p>I think it depends on what version of EJBs you're talking about. Let's discuss the only two relevant (IMO) versions.</p>
<p>EJB 2.1 might still be used by some people in a legacy system. They really have the most use as an RPC abstraction. They also provided a rudimentary ORM (Object-Relational Mapping) system as w... | <p>One thing that has bitten many when using EJBs, or J2EE in general, is the dependency on the application server you're running your EJBs on. The appserver tends to be supported for a particular set of operating system releases and JVM versions. Not having the source code to a significant part of your runtime envir... | 13,099 |
<p>I am trying to read a custom (non-standard) CSS property, set in a stylesheet (not the inline style attribute) and get its value. Take this CSS for example:</p>
<pre><code>#someElement {
foo: 'bar';
}
</code></pre>
<p>I have managed to get its value with the currentStyle property in IE7:</p>
<pre><code>var elem... | <p>Firefox does not carry over tags, attributes or CSS styles it does not understand from the code to the DOM. That is by design. Javascript only has access to the DOM, not the code. So no, there is no way to access a property from javascript that the browser itself does not support.</p>
| <p>Maybe you can try with <a href="http://lesscss.org/" rel="nofollow">LESS</a>. It's The Dynamic Stylesheet language and you can create non-standard css attributes, commands that will compile later.</p>
| 31,097 |
<p>This is in reference to a <a href="https://stackoverflow.com/questions/331073/speed-up-nhibernate-calls-to-oracle">question</a> I asked earlier. Aside from viewing the SQL generated by NHibernate on calls to the database, what is the best way to find bottlenecks between NHibernate and the DB? In particular, I have q... | <p>AFAIK there is no single tool to profile NHibernate, yet. This is about to change with <a href="http://ayende.com/Blog/archive/2008/11/04/nh-prof-a-guided-tour.aspx" rel="nofollow noreferrer">Ayende's NHIbernate Profiler</a>. In the meantime, you can use a combination of code profilers (e.g. <a href="http://www.jetb... | <p>I use JProbe for analyzing my code. It can show the amount of time spent in any particular location in my code, and where the bottlenecks are. I'm sure there are other tools available though, some of which may be cheaper.</p>
| 43,053 |
<p>I'm looking for shell scripts files installed on my system, but <strong>find</strong> doesn't work:</p>
<pre><code>$ find /usr -name *.sh
</code></pre>
<p>But I know there are a ton of scripts out there. For instance:</p>
<pre><code>$ ls /usr/local/lib/*.sh
/usr/local/lib/tclConfig.sh
/usr/local/lib/tkConfig.s... | <p>Try quoting the wildcard:</p>
<pre><code>$ find /usr -name \*.sh
</code></pre>
<p>or:</p>
<pre><code>$ find /usr -name '*.sh'
</code></pre>
<p>If you happen to have a file that matches <strong>*.sh</strong> in the current working directory, the wildcard will be expanded before find sees it. If you happen to hav... | <p>For finding files on your disks, lean to use "locate" instead that is instantaneous
(looks into a daily built index)
you example would be:</p>
<pre><code>locate '/usr*.sh'
</code></pre>
| 3,936 |
<p>What software is recommended for working with and editing large XML schemas? I'm looking for both Windows and Linux software (doesn't have to be cross platform, just want suggestions for both) that help with dealing with huge XML files.</p>
| <p>I may be old fashioned, but I prefer my text editor. </p>
<p>I use emacs, and it has a fairly decent xml mode. </p>
<p>Most good text editors will have decent syntax hi-lighting and tag matching facilities. Your IDE might already do it (IntelliJ idea does, and I believe Eclipse does as well). Good text editors... | <p><strong>XML Copy Editor</strong> - Windows and Linux</p>
<p>Fast, free, and supports XML schema validation.</p>
<p>Official Website
<a href="http://xml-copy-editor.sourceforge.net/" rel="nofollow">http://xml-copy-editor.sourceforge.net/</a></p>
<p>How to install in Ubuntu
<a href="http://ubuntuforums.org/showthre... | 2,397 |
<p>I need to compare large count of PDF files for it optical content. Because the PDF files was created on different platforms and with different versions of the software there are structural differences. For example:</p>
<ul>
<li>the chunking of text can be different</li>
<li>the write order can be different</li>
<li... | <p>Because there is no such tool available that we have written one. You can download the <a href="http://www.inetsoftware.de/products/pdf-content-comparer" rel="noreferrer">i-net PDF content comparer</a> and use it. I hope that help other with the same problem. If you have problems with it or you have feedback for us ... | <p>blubeam pdf software will do this for you</p>
| 17,560 |
<p><strong>Background:</strong> I have an HTML page which lets you expand certain content. As only small portions of the page need to be loaded for such an expansion, it's done via JavaScript, and not by directing to a new URL/ HTML page. However, as a bonus the user is able to permalink to such expanded sections, i.e.... | <p>As others have mentioned, <a href="https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history#The_replaceState%28%29.C2.A0method" rel="noreferrer">replaceState</a> in HTML5 can be used to remove the URL fragment.</p>
<p>Here is an example:</p>
<pre><code>// remove fragment as much as it can go w... | <pre><code>$(document).ready(function() {
$(".lnk").click(function(e) {
e.preventDefault();
$(this).attr("href", "stripped_url_via_desired_regex");
});
});
</code></pre>
| 33,778 |
<p>I'm trying to reduce the form spam on our website. (It's actually pretty recent).</p>
<p>I seem to remember reading somewhere that the spammers aren't executing the Javascript on the site.</p>
<p>Is that true?
And if so, then could you simply check for javascript being disabled and then figure it's <em>likely</em>... | <p>There are still a large number of people that run with Javascript turned off.</p>
<p>Alternatively, I have had decent success with stopping form spam using CSS. Basically, include an input field and label that is hidden using CSS (<code>display: none;</code>) and once submitted, check if anything has been entered ... | <p>I can't remember where I've seen this method but spam bots like to fill out forms. Have you considered putting a form field that is hidden with javascript (and says don't fill this field if the user doesn't have JavaScript). This way if something fills in this field you can ignore it as spam.</p>
| 7,563 |
<p>I have a fairly good feel for what MySQL replication can do. I'm wondering what other databases support replication, and how they compare to MySQL and others?</p>
<p>Some questions I would have are:</p>
<ol>
<li>Is replication built in, or an add-on/plugin?</li>
<li>How does the replication work (high-level)? My... | <p>MySQL's replication is weak inasmuch as one needs to sacrifice other functionality to get full master/master support (due to the restriction on supported backends).</p>
<p>PostgreSQL's replication is weak inasmuch as only master/standby is supported built-in (using log shipping); more powerful solutions (such as Sl... | <p>Another way to go is to run in a virtualized environment. I thought the data in this blog article was interesting</p>
<p><a href="http://chucksblog.typepad.com/chucks_blog/2008/09/enterprise-apps.html" rel="nofollow noreferrer">http://chucksblog.typepad.com/chucks_blog/2008/09/enterprise-apps.html</a></p>
<p>It's... | 17,175 |
<p>I want to be able to generate a highly graphical (with lots of text content as well) PDF file from data that I might have in a database or xml or any other structured form.</p>
<p>Currently our graphic designer creates these PDF files in Photoshop manually after getting the content as a MS Word Document. But usuall... | <p>There are some tools out there for doing this. XSL-FO is useful. <a href="http://cocoon.apache.org/2.1/howto/howto-html-pdf-publishing.html" rel="nofollow noreferrer">Here</a> is a tutorial for creating a pdf from xml (or xhtml) with cocoon. Also see <a href="http://xmlgraphics.apache.org/fop/" rel="nofollow noref... | <p>You could look at doing the workflow in PostScript which is plain text that you can easily compose from fragments. Then you can use any <a href="http://www.cutepdf.com/Products/CutePDF/writer.asp" rel="nofollow noreferrer">free tool</a> to convert to PDF.</p>
| 14,138 |
<p>Why does the following have the effect it does - it prints a terminal full of random characters and then exits leaving a command prompt that produces garbage when you type in it. (I tried it because I thought it would produce a seg fault).</p>
<p><img src="https://i.stack.imgur.com/kGkf4.png" alt="http://oi38.tinyp... | <p>It will eventually seg fault, but before that it'll print out whatever bytes are in the same page. That's why you see random chars on the screen.</p>
<p>Those may well include escape sequences to change (say) the character encoding of the console. That's why you end up with gibberish when you type on the console af... | <p>Also, you can usually get back to your command prompt by using the 'reset' command, typing blindly of course. (type Enter, reset, Enter)</p>
| 36,591 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.