instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have multiple applications running in one virtual machine. I have multiple virtual machines running on one server. And I have multiple servers. They all share a file using a shared folder on linux. The file is read and written by all applications. During the write process no application is allowed to read this fil... | <p>You can use NIO locking capabilities. See <a href="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html#lock()" rel="nofollow noreferrer">FileChannel#lock()</a>.</p>
<p>However, this will work only if underlying filesystem supports locking over the network. Recent NFS should support it. Probably... | <p>Have a look at the Javadocs for the <a href="http://java.sun.com/javase/6/docs/api/java/io/File.html#createNewFile()" rel="nofollow noreferrer">createNewFile()</a> method - it specifically states that creating files is not a reliable method for synchronization, and recommends the <a href="http://java.sun.com/javase/... | 41,408 |
<p>To preface I am using Borland C++ and the VCL.</p>
<p>I need some sort of structured storage object which can be saved to disk as a single file and can contain multiple named blobs of binary data which I can programatically enumerate, access and manipulate.</p>
<p>The <a href="http://msdn.microsoft.com/en-us/libra... | <p>A zip file is de facto a standard container, and it seems you can get a TStream interface to them: <a href="http://www.tek-tips.com/faqs.cfm?fid=6734" rel="nofollow noreferrer">http://www.tek-tips.com/faqs.cfm?fid=6734</a></p>
| <p>I went for <a href="http://www.componentace.com/zip_component_zip_delphi_zipforge.htm" rel="nofollow noreferrer">ZipForge</a> by ComponentAce. It's fast, is being actively developed/supported and has the perfect interface to support what I want.</p>
<p>Thanks for everybodys other suggestions.</p>
| 27,048 |
<p>I'm currently using the Infragistics component set for .Net 2.0, Visual Studio 2005 and C#. I have the following chunk of javascript code (text and other variables are declared elsewhere):</p>
<blockquote>
<p>***alert(box[select].value);</p>
<p>text.value(box[select].value);</p>
<p>alert(text.value);***</p>
</blockq... | <p>The first time I looked into PRADO, I spent about 10 days using it and kept saying to myself: "This framework is amazing!". A couple of months later, I started working on a big project where the customer had chosen to use PRADO... And Hell began... As long as we kept using PRADO's base components, everything was per... | <p>We are working with PRADO framework since 4 years.
We are developing huge (+4000 programs) web apps for e-Goverment with Oraracle and MySql databases containing more than 60 millon records. As infrastructure for development we use SVN+TRAC+ our own tools for project control AND phpEdit w/tortoiseSVN as client tools... | 11,941 |
<pre><code>Type.GetType("System.String")
</code></pre>
<p>Is there a lookup for the aliases available somewhere?</p>
<pre><code>Type.GetType("string")
</code></pre>
<p>returns <code>null</code>.</p>
| <p>This is not possible programmatically, since the 'aliases' are in fact keywords introduced in C#, and <code>Type.GetType</code> (like every other framework method) is part of the language-independent framework.</p>
<p>You could create a dictionary with the following values:</p>
<pre><code> bool System.Bool... | <p>The "aliases" are part of the language definition. You need to look them up in the <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx" rel="nofollow noreferrer">language spec</a> in question. They are compiled away, and don't exist at runtime - string becomes System.String, int becomes System.Int32, etc.... | 41,522 |
<p>I've read a little bit about unit testing and was wondering how YOU unit test. Apparently unit testing is supposed to break a program down into very small "units" and test functionality from there.</p>
<p>But I'm wondering, is it enough to unit test a class? Or do you take it even further and unit test algorithms... | <blockquote>
<p>But I'm wondering, is it enough to unit test a class? Or do you take it even further and unit test algorithms, formulas, etc.? Or do you broaden it to unit test asp pages/functionality? Or do you unit test at all?</p>
</blockquote>
<p>An algorithm should be in a class and automatically should be Unit... | <p>We usually program in Java libraries for machines. A program is usually formed by over twenty libraries so what we do is unit test each library. It is not an easy task since many times libraries are very coupled between each other and this is not many times possible. </p>
<p>Our code is not as modular as we would l... | 42,281 |
<p>I'm a PHP developer who knows a little bit of Ruby. I want to learn Ruby on Rails, but most of the resources I've come across treat RoR functionality as "magic" -- i.e., it has a certain internal consistency, but don't bother asking how it works in terms of Ruby, MySQL, etc.</p>
<p>Anyway, I want a deep understandi... | <p>The books "Agile Web Development with Rails" and "The Rails Way" are both pretty good. "Pro Active Record" goes really in depth for Active Record, but doesn't touch on too much else. The podcast Railscasts sometimes just uses the magic, but sometimes it explains what is really going on.... | <p>If you really want to understand Rails, read the source for the bit of Rails that you want. </p>
<p>/Library/Ruby/Gems/1.8/gems/ on OSX or freeze rails and have access to it in your RAILS_ROOT/vendor/ directory</p>
| 24,870 |
<p>I'm looking to convert a SQL like statement on the fly to the equivalent regex i.e. </p>
<pre><code>LIKE '%this%'
LIKE 'Sm_th'
LIKE '[C-P]arsen'
</code></pre>
<p>What's the best approach to doing this?</p>
<p>P.S. I'm looking to do this on the .Net Framework (C#).</p>
| <p>The following Regex converts an SQL like pattern into a Regex pattern with the help of a <a href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchevaluator.aspx" rel="nofollow noreferrer"><code>MatchEvaluator</code></a> delegate. It correctly handles square bracket blocks and escapes spec... | <p>I found a Perl module called <a href="http://search.cpan.org/dist/Regexp-Wildcards/lib/Regexp/Wildcards.pm" rel="nofollow noreferrer">Regexp::Wildcards</a>. You can try to port it or try Perl.NET. I have a feeling you can write something up yourself too.</p>
| 6,924 |
<p>We have a service that handles authorization based on a User Name and Password. Instead of making the username and password part of the call, we place it in the SOAP header. </p>
<p>In a typical scenario, a Web Service calls the Authorization service at the start of execution to check that the caller is allowed to... | <p>Ok, replacing my older answers with hopefully a better one.</p>
<p>What you describe should work if you have a way to securely share data between your services. For example, if your services share a secret key with the Authorization Service, you can use this key to get the salt.</p>
<p>BTW, I don't know enough cry... | <p>First of all, read @CJP 's post, he makes an excellent and valid point.<br>
If you want to go ahead and roll it yourself anyway (maybe you do have a good reason for it), I would make the following points: </p>
<ul>
<li>You're talking about an Authentication Service, NOT an authorization service. Just to make sure ... | 18,503 |
<p>Let's say I have a payments table like so:</p>
<pre><code>CREATE TABLE Payments (
PaymentID INT,
CustomerID INT,
Value INT,
PaidOn DATE
);
INSERT INTO Payments
VALUES
(1, 1, 5, '2000-01-01'),
(2, 1, 10, '2000-02-01'),
(3, 2, 10, '2000-01-02'),
(4, 2, 10, '2000-01-20'),
(5, 2, 5, '2000-02-02'),
</code></pr... | <p>The following query will accomplish that. It pulls out all the rows for which there is not a greater Value.</p>
<pre><code>SELECT *
FROM payments p
WHERE NOT EXISTS (
SELECT *
FROM payments p2
WHERE p2.CustomerID = p.CustomerId
AND p2.Value > p.Value
)
</code></pre>
| <p>One more using Self join - matter of syntactic sugar. Easier to understand and good on performance.</p>
<pre><code>select PaymentID, CustomerID, Value, PaidOn
from
( select customerID, max(value) as maxValue
from payments
group by customerID
)as T
INNER JOIN payments as P
ON P.Value=T.maxValue AND P.Custome... | 49,102 |
<p>I was reading Jeff Atwood's blog on <a href="http://www.codinghorror.com/blog/archives/001105.html" rel="noreferrer">Behold WordPress, Destroyer of CPUs</a> and saw that many people there considered 20 SQL Queries per page load to be a lot. What is the average amount of queries per page nowadays for a highly dynami... | <p>You can usually bring all the data in two or three big queries instead of on twenty small ones. Minimizing the amount of queries is as important as, if not most important than, writing optimal queries to maximize performace. </p>
<p>Of course you should always analyze the query plans and aim towards optimal queries... | <p>My rule of thumb is keep the front pages down to under 5-7 if possible, depending on the type of the site.</p>
<p>Interior pages, depending on what they need might have more, but I do what I can to keep it under 20.</p>
<p>However, at the same time, depending on what you are trying to do AND what types of caching ... | 44,526 |
<p>I'm no UNIX Guru, but I've had to set up a handful of slices for various web projects. I've used the articles on there to set up users, a basic firewall, nginx or apache, and other bits and pieces of a basic web server. </p>
<p>I foresee more slice administration in my future. <strong>Is there a more efficient way ... | <p>It sounds like you can create a new slice from the backup of an existing one. This might not work for you if the slices would be different sizes, different distros, etc. Their forums mention this: <a href="http://forum.slicehost.com/comments.php?DiscussionID=1902" rel="nofollow noreferrer">Clone a slice?</a></p>
| <p>Depending on the number of machines you might find it makes sense to use something like CFEngine, or Puppet, to configure the new installs.</p>
<p>That brings your work down to configuring each new machine as a CFEngine, for example, client. Then that may be used to install the packages, edit files, & etc.</p>... | 18,137 |
<p>I have a web directory where I store some config files. I'd like to use wget to pull those files down and maintain their current structure. For instance, the remote directory looks like:</p>
<pre><code>http://mysite.com/configs/.vim/
</code></pre>
<p>.vim holds multiple files and directories. I want to replicate t... | <p>You have to pass the <code>-np</code>/<code>--no-parent</code> option to <code>wget</code> (in addition to <code>-r</code>/<code>--recursive</code>, of course), otherwise it will follow the link in the directory index on my site to the parent directory. So the command would look like this:</p>
<pre><code>wget --rec... | <p>You should be able to do it simply by adding a -r</p>
<pre><code>wget -r http://stackoverflow.com/
</code></pre>
| 34,492 |
<p>What is the best way to create a lock on a file in Perl?</p>
<p>Is it best to flock on the file or to create a lock file to place a lock on and check for a lock on the lock file?</p>
| <p>If you end up using flock, here's some code to do it:</p>
<pre><code>use Fcntl ':flock'; # Import LOCK_* constants
# We will use this file path in error messages and function calls.
# Don't type it out more than once in your code. Use a variable.
my $file = '/path/to/some/file';
# Open the file for appending. N... | <p>Use the <a href="http://perldoc.perl.org/functions/flock.html" rel="nofollow noreferrer">flock</a> Luke. </p>
<p><strong>Edit:</strong> <a href="http://www.perlmonks.org/?node_id=7058" rel="nofollow noreferrer">This</a> is a good explanation.</p>
| 5,530 |
<p>I have an ender 5, and I'm not certain that the bed is getting up to temperature. Or maybe I'm not understanding what it should be like when it gets up to temperature.</p>
<p>If I use an infrared thermometer, where should I aim it, and what should it be saying in comparison to what the screen on the printer says?</p... | <h2>Sensor mounting</h2>
<p>An Infrared Thermometer prefers a non-reflective surface to accurately read the temperature reliably - glass is reflective for Infrared light under many angles and can in the worst case result in measuring anything <em>but</em> what you want to measure. To that degree, a piece of paper tape ... | <p>The actual numerical reading doesn't really matter - as long as the first layer goes down, and stays down through the entire print.</p>
<p>I've noticed that the center of the bed is ~2 degrees C under the set temp, and the edges could be 15 degrees low.</p>
<p>So "verify by effect" - if the bed seems too c... | 2,092 |
<p>I am having trouble with IE7. I have a header, which is an IMG. Under it I have a div that represents a menu, they have to be attached to each other without space in between. Both are 1000px width. In Opera and FireFox the header and the menu are neatly attached to each other. However, in IE7, there is a small space... | <p>Try the IE Developer Toolbar, which will let you inspect what is going on with the elements and give you outlines of the areas covered. It might give you a better understanding of the problem.</p>
| <p>The solution: </p>
<pre><code>img {
padding: 0px;
margin: 0px;
display: block;
}
</code></pre>
<p>display: block</p>
| 3,478 |
<p>I am preparing a presentation using Google Slides, though I can also work on the presentation within Open Office that will include code snippets. </p>
<p>Is there any easy way to perform basic syntax highlighting on the code snippets with either Google Docs or Open Office Presenter?</p>
<p><b>Edit:</b> Since I bel... | <p>An on-line syntax highlighter:</p>
<p><a href="http://hilite.me/" rel="noreferrer">http://hilite.me/</a></p>
<p>Just copy and paste into your document.</p>
| <p>Check out <a href="http://codepad.org" rel="nofollow">http://codepad.org</a>. It probably won't solve the poster's problem; but, I think it will be of use to others who read this article. </p>
| 35,551 |
<p>I understand that you can use forms authentication to grant/deny access to certain pages based on the criteria of your choosing.</p>
<p>However I wish to go in a little more specific than that and say, have different buttons appear for users based on thier permissions.</p>
<p>I know I could do something like</p>
... | <p>Use role-based authentication, then set roles appropriately. Then you can do things like:</p>
<pre><code>if (ViewContext.HttpContext.User.IsInRole("vEmployee") {
</code></pre>
<p>The advantage of this is that it's core ASP.NET functionality -- not even MVC-specific -- so it's going to work with every possible memb... | <p>Don't do it. Use the controller for that kind of logic</p>
| 48,465 |
<p>Frameworks simplify coding at the cost of speed and obfuscation of the OS. With the passing of Moore's law do you thing that there might be a shift away from Frameworks?</p>
<p>I suspect that one of the reasons for Vista not being an outstanding success was that it ran much slower than XP, and, because computers ... | <p>If there is selective pressure to make apps faster, I think that people will become better at writing frameworks that encapsulate functionality without slowing down the system too much.</p>
<p>The Boost::Gil framework that handles pixels is a nice template-based system that boils down to many inlined functions - th... | <p>Stepping away from frameworks would be a step backwards and I think and hope that this won't happen.</p>
| 10,447 |
<p>How can you programmatically tell an HTML <code>select</code> to drop down (for example, due to mouseover)?</p>
| <p><em>This used to actually be possible with HTML+Javascript, despite everywhere else people say it is not, but it was deprecated later on and does not work now.</em></p>
<p><strong>However, this only worked in Chrome. Read more if you're interested.</strong></p>
<hr>
<p>According to <a href="http://www.w3.org/TR/h... | <p>I don't know if I'm fully understanding the question, but to open a dropdown, this simple approach worked for me.</p>
<p>You have an element:</p>
<pre><code><span onclick="openDropdown();">Open dropdown</span>
</code></pre>
<p>You have a dropdown:</p>
<pre><code><select class="dropdown&... | 30,973 |
<p>Is there a simple Model Checker tool. I am planning to implement a model checker tool which will analyze the code for some of the predefined properties.</p>
| <p>One important tool is <a href="http://spinroot.com" rel="noreferrer">SPIN</a>, with the Promela language. If you use LaTeX, there is also <a href="http://research.microsoft.com/users/lamport/tla/tla.html" rel="noreferrer">TLA+</a>.</p>
<p>These will not analyse your code, but will let you express a model for your ... | <p><a href="http://www.cs.cmu.edu/~modelcheck/cbmc/" rel="nofollow noreferrer">CBMC</a> is one simple-ish tool I'm aware of that actually operates on code. Model checking in general is a heavily-researched field, but as folks have already commented, this breadth makes it difficult to suggest something with the info pr... | 26,947 |
<p>I am trying to come up with the best way to render some hierarchical data in to a nested unordered list using ASP.NET MVC. Does anyone have any tips on how to do this?</p>
| <p>I suggest jquery tree view plugins for making it function like a tree, but as for render, just put it in a recursive lambda helper to do the nesting.</p>
| <p>For that (rendering hierarchical menu, treeview, etc) i use recursive calls of custom component (ascx, or aspx in new preview5).<br>
I give component first level of items (List of items), and component then check for each item in list if there's any child items and call itself with list of that child items.<br>
You ... | 8,256 |
<p>In my views.py, i have a snippit of code like this:</p>
<pre><code>def clean_post_data(form):
for i in form.cleaned_data:
form.cleaned_data[i] = form.cleaned_data[i].rstrip()
def add_product(request):
form = ProductForm(request.POST, request.FILES or None)
image = Image.objects.all()
act... | <p>The <code>clean_post_data</code> shouldn't be a stand-alone function.</p>
<p>It should be a method in the form, named <code>clean</code>. See <a href="http://docs.djangoproject.com/en/dev/ref/forms/validation/#ref-forms-validation" rel="nofollow noreferrer">Form and Field Validation</a>.</p>
| <p>Most likely you have several elements on your form with same name. When it is submitted one of the elements returned by cleaned_data is a list</p>
<p>If you want to skip (or do something special about) such cases you need to check for it:</p>
<pre>
def clean_post_data(form):
for i in form.cleaned_data:
... | 40,058 |
<p>How do you return values or structures from a Popup window in Powerbuilder 9.0? The CloseWithReturn is only valid for Response windows and thus is not available. When I set a value to the Message.PowerObjectParm, the value becomes null when the Popup window closes. I need to use a Popup window so the user can click ... | <p>You won't be able to accomplish this the way you are thinking. Since the window you are opening from the parent is not a Response window, the two aren't explicitly linked together. </p>
<p>But you could accomplish this by having a public instance variable in the parent window that is of the type of your custom st... | <p>If you're using the PFC, if I remember right there was a service that you could use as well.</p>
| 19,910 |
<p>I have an SLA printed part I want to put a brass threaded insert in using a soldering iron. The insert is slightly larger than the hole so I would assume the edge will melt and re-freeze around the teeth. Are there any issues with melting SLA or this idea in general? </p>
| <p>The plastic used in SLA printing is what is known as a <em>thermoset</em> plastic, as opposed to the <em>thermoplastic</em> plastics used in FDM printing. What this means, is that it <em>can not be melted</em>. The reaction that hardens SLA materials is irreversible. If you heat up the plastic it won't melt, it will... | <p>Is it possible to make the hole larger, put the brass insert with a pre-installed screw inside the hole, fill the area with resin and cure with UV lamp?</p>
| 1,066 |
<p>Have people been using 3D printing to genuinely create a number of needed objects in their homes, and if so, what? Or is 3D printing better for special niche interests like art projects, home engineering projects, etc?</p>
| <p>Both.</p>
<p>3D printing is especially useful for creating replacement parts for things for which it would otherwise be difficult, expensive, or impossible to obtain a conventionally manufactured one. You may have seen in the news recently the <a href="https://www.bbc.com/news/technology-51911070" rel="nofollow nor... | <p>Both.</p>
<p>3D printing is especially useful for creating replacement parts for things for which it would otherwise be difficult, expensive, or impossible to obtain a conventionally manufactured one. You may have seen in the news recently the <a href="https://www.bbc.com/news/technology-51911070" rel="nofollow nor... | 1,614 |
<p><a href="http://subclipse.tigris.org/" rel="noreferrer">Subclipse</a>, <a href="http://www.eclipse.org/subversive/" rel="noreferrer">Subversive</a>, or <a href="http://www.google.com/search?hl=en&safe=off&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=svn+eclipse&spell=1" rel="noreferrer">so... | <p>This depends. <a href="http://subclipse.tigris.org/" rel="noreferrer">Subclipse</a> has superior support for checking out projects as maven projects - this is the sole reason we use Subclipse. Other than that, I have noticed subclipse bugs with syncing with SVN.</p>
<p><a href="http://www.eclipse.org/subversive/"... | <p>subclipse is fully packed with features, I have never had an issue with it.</p>
| 22,434 |
<p>I have three tables <code>tag</code>, <code>page</code>, <code>pagetag</code></p>
<p>With the data below</p>
<p><strong><em>page</em></strong></p>
<pre><code>ID NAME
1 page 1
2 page 2
3 page 3
4 page 4
</code></pre>
<p><strong><em>tag</em></strong></p>
<pre><code>ID NAME
1 ... | <blockquote>
<p>Sergio del Amo:</p>
<blockquote>
<p>However, I am not getting the pages without tags. I guess i need to write my query with left outer joins.</p>
</blockquote>
</blockquote>
<pre><code>SELECT pagetag.id, page.name, group_concat(tag.name)
FROM
(
page LEFT JOIN pagetag ON page.id = paget... | <p>I think you may need to use multiple updates.</p>
<p>Something like (not tested):</p>
<pre><code>select ID as 'PageId', Name as 'PageName', null as 'Tags'
into #temp
from [PageTable]
declare @lastOp int
set @lastOp = 1
while @lastOp > 0
begin
update p
set p.tags = isnull(tags + ', ', '' ) + t.[Tagid]... | 5,849 |
<p>movie id tt0438097 can be found at <a href="http://www.imdb.com/title/tt0438097/" rel="noreferrer">http://www.imdb.com/title/tt0438097/</a></p>
<p>What's the url for its poster image?</p>
| <p>As I'm sure you know, the actual url for that image is </p>
<p><a href="http://ia.media-imdb.com/images/M/MV5BMTI0MDcxMzE3OF5BMl5BanBnXkFtZTcwODc3OTYzMQ@@._V1._SX100_SY133_.jpg" rel="noreferrer">http://ia.media-imdb.com/images/M/MV5BMTI0MDcxMzE3OF5BMl5BanBnXkFtZTcwODc3OTYzMQ@@._V1._SX100_SY133_.jpg</a></p>
<p>You'... | <p>Now a days, all modern browser have "<strong>Inspect</strong>" section:</p>
<p>100% Correct for Google Chrome only:</p>
<ol>
<li>Take your cursor on image.</li>
<li>Right click on it, select "<strong>Inspect Element</strong>".</li>
<li>In the window appear, under <strong>Elements</strong> tab you will find the hig... | 18,233 |
<p>Several questions are related to first layer calibration or issues: I found 43 of them with "first layer" in the title alone, 150 with "first layer" anywhere (no duplicates).</p>
<p>I propose adding a "first-layer" tag to more easily retrieve said questions.</p>
<p>I already applied it to my latest question withou... | <p>I think the <a href="https://3dprinting.stackexchange.com/questions/tagged/adhesion" class="post-tag" title="show questions tagged 'adhesion'" rel="tag">adhesion</a> tag should be used instead.</p>
| <p>Yes, I support this idea. A <a href="https://3dprinting.stackexchange.com/questions/tagged/first-layer" class="post-tag" title="show questions tagged 'first-layer'" rel="tag">first-layer</a> tag would be useful.</p>
| 76 |
<p>Ok: This is some of my table structure that matters here</p>
<pre><code>CaseStudyID int
Title nvarchar(50)
OverrideTitle nvarchar(50)
</code></pre>
<p>Part of my procedure</p>
<pre><code>Declare @Temp table(CaseStudyID int,
Title nvarchar(50))
Insert Into @Temp
SELECT CaseStudyID,Title
FROM CaseStu... | <p>I'm not sure whether you need every single row of the orginal table. So here is my alternative solution which gives you every row:</p>
<pre><code>SELECT CaseStudyID, Title
FROM CaseStudy c1
WHERE NOT EXISTS (
SELECT * FROM CaseStudy c2
WHERE c2.CaseStudyID <> c1.CaseStudyID and c2.Title = c1.Title
)
... | <p>You could achieve it without using tempory table this way:</p>
<pre><code>SELECT
MIN(CaseStudyID) AS CaseStudyID,
CASE WHEN count(*) = 1 THEN
MIN(Title)
ELSE
MIN(OverrideTitle)
END AS Title
FROM CaseStudy
GROUP BY Title
ORDER BY Title
</code></pre>
| 28,838 |
<p>Do you know a way to organize boolean expressions in a database while allowing infinite nesting of the expressions?</p>
<p>Example:</p>
<pre><code>a = 1 AND (b = 1 OR b = 2)
</code></pre>
<p>The expression as a whole shouldn't be stored as varchar to preserve data integrity.</p>
| <p>Option 1 would be to use a nested table (a tree with id / parent_id structure), like Gamecat suggested. This is relatively expensive to do, and requires issuing SQL queries repetitively to build the equivalent of a single nested expression.</p>
<p>Option 2 would be to use a serialized object and store it into a var... | <p>Adding to @Gamechat answer</p>
<p>I think it should be like this</p>
<p>ID </p>
<p>TypeExpression (and, or etc...) </p>
<p>FirstChildID --This can be a leaf node or a pointer to another row in same table</p>
<p>SecondChildID --This can be a leaf node or a pointer to another row in same table</p>
<p>isFirstChil... | 32,736 |
<p>I restored my development database from production, and the stored procedures I need in my development environment doesn't exist in my production database. Is there a command Ii can use to import the developmetn stored procedures back into SQL Server. There are about 88 files, as each procedure is in a different t... | <p>Oops, you did the painful way of generating scripts. You should have created a single script for all procedures by right clicking on the database in SSMS, choosing Tasks -> Generate Scripts.</p>
<p>However, if you don't want to go through that process again, open up a cmd shell in the folder and remember those old ... | <p>Right click on the development database Hit Generate SQL Scripts and then only select stored precedures. If you need need additional filtering you can even select the stored procedures you dont want.</p>
<p>Then just run that query on development.</p>
| 49,587 |
<p>What's the best way to combine results sets from disparate data sources in SSRS?</p>
<p>In my particular example, I need to write a report that pulls data from SQL Server and combines it with another set of data that comes from a DB2 database. In the end, I need to join these separate data sets together so I have ... | <p>We had to do something similar (i.e. inner join 2 data sources from different servers). I believe the best way is to write your own custom Data Extension. It's not very difficult and it would give you the ability to do this and more.</p>
| <p>You could attach both the MSSQL tables and the DB2 tables to a Jet database and bind your report to the Jet database. I don't know the implications of the single threaded nature of Jet, or how much work would be delegated to the backing stores.</p>
| 5,575 |
<p>I want to intercept a request in a filter/servlet and add a few parameters to it. However, the request does not expose a 'setParameter' method and the parameter map when manipulated throws an error saying it is locked. Is there an alternative I can try?</p>
| <p>Subclass <a href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequestWrapper.html" rel="noreferrer"><code>HttpServletRequestWrapper</code></a> and override the <code>getParameter</code> methods. The description of this class reads:</p>
<blockquote>
<p>Provides a convenient implemen... | <p>Otherwise, you can use the setAttribute() method which is strongly typed. Therefore, the getAttribute() method can be used ...</p>
| 23,167 |
<p>We need some input on what is a good design pattern on using AJAX in a Java application. </p>
<p><strong>Consider a simple scenario:</strong></p>
<ol>
<li>User clicks a button which sends a request to a Java method to fetch data from DB.</li>
<li>Java object is returned by method and needs to be converted into a H... | <p>Sounds fine. You are separating view components from model components. It shouldn't matter how the call comes to the server, AJAX or not, it should be received by a controller (a servlet say) that interacts with the model, thats your Java classes that get the data from the database and forward to a JSP page for rend... | <p>I'm not sure if you noticed, but there's one significant difference between your solution and what Vincent proposed. This is that the request should be initially received by a servlet (or controller, or Struts action, etc.) rather than a "middleman" JSP.</p>
<p>MVC dictates that JSPs should really only we used for ... | 34,041 |
<p>In Visual Studio 2005, whenever I would view a file in the main editor, the Solution Explorer would find and highlight that file. Some time ago, this stopped working and the Solution Explorer would do nothing.</p>
<p>This has become quite a pain since following a chain of "Go To Definition"s can lead you all over ... | <p>Click on the Tools → Options menu. Select the Projects and Solutions → General option page.</p>
<p>Make sure "Track active item in Solution Explorer" is checked. That should do it.</p>
| <p>Tools->Options->Project and Solutions->General</p>
<p>Check the box "Track Active Item in Solution Explorer"</p>
| 5,107 |
<p>I was working on some code recently and came across a method that had 3 for-loops that worked on 2 different arrays. </p>
<p>Basically, what was happening was a foreach loop would walk through a vector and convert a DateTime from an object, and then another foreach loop would convert a long value from an object. Ea... | <p>The best approach? Write the most readable code, work out its complexity, and work out if that's actually a problem.</p>
<p>If each of your loops is O(n), then you've still only got an O(n) operation.</p>
<p>Having said that, it does sound like a LINQ approach would be more readable... and quite possibly more effi... | <p>Thank you every one for the information. Thinking in terms of Big-O and how to optimize has never been my strong point. I believe I am going to put the code back to the way it was, I should have trusted the way it was written before instead of jumping on my novice instincts. Also, in the future I will put more refer... | 43,562 |
<p>I am new to 3D printing and just purchased an Ender 3 V2 about two weeks ago. Since I've got it, I've been having trouble leveling the bed. I've tried watching videos, but they don't say how much friction on the paper is good or bad. I have even tried foil, playing cards, and a business card but still can't tell if ... | <p>Step 1: stop using paper and get some feeler gauges. The gauge should be able to just barely pass under the HEATED nozzle.</p>
<p>Step 2: What are you using for bed adhesion? I use Elmer's white glue. After you think you've trammed (aka levelled) the bed, apply a generous layer of the glue in a coat on the bed. Let ... | <p>Don't worry too much about it. If you print with a first layer height of 0.3mm, bed levelling only needs to be approximate. If that doesn't work, and you cannot get good bed adhesion, try printing onto blue painter's tape (ScotchBlue). This makes a very forgiving build surface. You will need to clean it well with is... | 1,801 |
<p>I have a class that processes a 2 xml files and produces a text file. </p>
<p>I would like to write a bunch of unit / integration tests that can individually pass or fail for this class that do the following:</p>
<ol>
<li>For input A and B, generate the output.</li>
<li>Compare the contents of the generated file ... | <p>As for the multiple tests with different data, use the NUnit RowTest extension:</p>
<pre><code>using NUnit.Framework.Extensions;
[RowTest]
[Row("x1.xml", "x2.xml", "x-expected.xml")]
[Row("y1.xml", "y2.xml", "y-expected.xml")]
public void TestGenerate(string pathToInputA, string pathToInputB, string pathToExpected... | <p>Rather than call .AreEqual you could parse the two input streams yourself, keep a count of line and column and compare the contents. As soon as you find a difference, you can generate a message like...</p>
<blockquote>
<p>Line 32 Column 12 - Found 'x' when 'y' was expected</p>
</blockquote>
<p>You could optiona... | 17,182 |
<p>We are using LINQ very widely in our system. Particularly LINQ-to-objects. So in some places we end up having a LINQ query in memory build up from some huge expressions. The problem comes when there's some bug in the expressions. So we get NullReferenceException and the stack trace leads us nowhere (to [Lightweight ... | <p>If you are building your own expressions and compiling them, or using AsQueryable, then yes; the LINQ-generated methods will be a royal pain to debug.</p>
<p>You can save some pain by using small fragements of <em>actual</em> methods - at least something useful will show in the stack trace...</p>
<p>Another consid... | <p>Take a look at the <a href="http://weblogs.asp.net/rosherove/archive/2007/11/02/debugger-visualizers-for-methodinfo-dynamicmethod-and-methodbase.aspx" rel="nofollow noreferrer">debug visualizer</a> for dynamic methods originally developed by <a href="http://blogs.msdn.com/haibo_luo/archive/2005/10/25/484861.aspx" re... | 30,537 |
<p>I am new to mysqli, and trying to confirm that if I so something like the below, the errno will be set to the last error, if any, and not the error of the last query. </p>
<p>Is this a decent practice or should I be checking for the error in between every query?</p>
<p>Thanks! </p>
<pre><code>$mysqli->autocomm... | <p>mysqli_errno — Returns the error code for <strong>the most recent function call</strong>.</p>
| <p>No you have to check in between every query because it will always give you error for last query only... So if your first query failed and last execute properly then you will not get error... so check after all query one by one not at last...</p>
| 41,300 |
<p>I have a page in my vb.net web application that needs to toss a bunch of data into a text file and then present it to the user for download. What's the best / most efficient way to build such a text file on a .net web server?</p>
<p>Edit: to answer a question down below, this is going to be a download once and the... | <p>The answer will depend on whether, as Forgotten Semicolon mentions, you need repeated downloads or once-and-done throwaways.</p>
<p>Either way, the key will be to set the content-type of the output to ensure that a download window is displayed. The problem with straight text output is that the browser will attempt ... | <p>Bear in mind it doesn't ever need to be a 'file' at the server end. It's the client which turns it into a file.</p>
| 15,782 |
<p>When using tables in a CSS-based layout, I've noticed if I have a table with 4 columns (2 on the side are small for spacing, 2 in the middle are for content), when I type content in one of the two middle columns, it will stay at the top, which is perfect.</p>
<p>However, if I type content in the other middle column... | <p>I believe the solution would be to create a rule which aligns text to the top of table cells.</p>
<pre><code>td {
vertical-align:top;
}
</code></pre>
<p>As an alternative, you can use column groups and columns to specify the vertical alignment of different columns. An example:</p>
<pre><code><!DOCTYPE html P... | <p>I'm not sure if I understand the problem entirely but you could look at the <a href="http://www.w3schools.com/Css/pr_pos_vertical-align.asp" rel="nofollow noreferrer">vertical-align css property</a>.</p>
| 39,520 |
<p>My CR-10 is starting prints, BUT then makes weird spiral pattern, layers go up vertically with large gaps. Hollow infill.</p>
<p><img src="https://i.stack.imgur.com/cQynM.jpg" alt="wierd vertical spiral layering pattern">
<img src="https://i.stack.imgur.com/bEbhg.jpg" alt="printed fine at base then randomly happene... | <p><sub>This is partial answer and comment as it was too big to fit the comment section, it will be a proper answer once the question is updated by the OP.</sub></p>
<p>What you call a weird spiral pattern is the result of under-extrusion. When there is under-extrusion, the resulting print is sparsely filled. The reaso... | <p>While uncommon, this issue could be caused by having no minimum layer time set. This could lead to printing on a still very hot surface, which in turn ripples and moves, creating a little wave pattern. The wave pattern then can grow into this diagonal pattern.</p>
<p>You might manage to reduce the issue by setting ... | 1,191 |
<p>I have a command-line process I would like to automate and capture in C#.</p>
<p>At the command line, I type:</p>
<pre><code>nslookup
</code></pre>
<p>This launches a shell which gives me a > prompt. At the prompt, I then type:</p>
<pre><code>ls -a mydomain.local
</code></pre>
<p>This returns a list of local CN... | <pre><code>ProcessStartInfo si = new ProcessStartInfo("nslookup");
si.RedirectStandardInput = true;
si.RedirectStandardOutput = true;
Process nslookup = new Process(si);
nslookup.Start();
nslookup.StandardInput.WriteLine("ls -a mydomain.local");
nslookup.StandardInput.Flush();
// use nslookup.StandardOutput stream to r... | <p>I know this is an old one, but still like to contribute.
I used the shell output from "NsLookup Hostname Server" to get the IPv4 addresses from a computername in our domain and strip out any other information like DNS server / ipv6 addresses..</p>
<p>This is kinda quickly done but it works, there is also a failove... | 46,057 |
<p>What is the best MemCache solution for ASP.NET applications running in a windows server environment? Why?</p>
| <p>You could also check out <a href="http://code.msdn.microsoft.com/velocity" rel="nofollow noreferrer">Microsoft Velocity</a>, especially if you're at a place that prefers Microsoft products.</p>
| <p>My sentiments exactly - <a href="https://stackoverflow.com/questions/161106/distributed-cachesession-where-should-i-turn">My Question</a></p>
<p>From what I've gathered, <a href="http://sourceforge.net/projects/memcacheddotnet/" rel="nofollow noreferrer">memcacheddotnet</a> is the best free options,
<a href="http:/... | 19,560 |
<p>My main JavaScript framework is <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a>, so I would like my unit test and mocking frameworks to be compatible with that. I'd rather not have to introduce another JavaScript framework.</p>
<p>I am currently using <a href="http://docs.jquery.com/QUnit" rel="nof... | <p><a href="http://docs.jquery.com/QUnit" rel="nofollow noreferrer">QUnit</a> <br/>
<a href="http://code.google.com/p/jqunit/" rel="nofollow noreferrer">jqUnit</a> <br/>
<a href="http://wiki.fluidproject.org/display/fluid/Writing+JavaScript+Unit+Tests" rel="nofollow noreferrer">Writing JavaScript tests with QUnit and j... | <p>I know you are asking for jQuery-compatible frameworks, but I want to throw <a href="http://github.com/madrobby/scriptaculous/wikis" rel="nofollow noreferrer">script.aculo.us</a> into the mix for completeness. They have a <a href="http://github.com/madrobby/scriptaculous/wikis/unit-testing" rel="nofollow noreferrer"... | 25,701 |
<p>I would like to monitor a log file that is being written to by an application. I want to process the file line by line as, or shortly after, it is written. I have not found a way of detecting that a file has been extended after reaching eof.</p>
<p>The code needs to work on Mac and PC, and can be in any language, t... | <p>In Perl, the <a href="http://search.cpan.org/dist/File-Tail/" rel="noreferrer">File::Tail</a> module does exactly what you need.</p>
| <p>I'd have thought outputting the actions via tee, and thence tail'ing (or using the loop <a href="https://stackoverflow.com/questions/62832#63446">above</a>) the file created by tee some use.</p>
| 8,833 |
<p>I currently work at a company that has a lot of custom applications that are made internally. There are not currently standards for a lot of things. I would like to implement a way to record/track errors that happen in this programs (most are asp.net).</p>
<p>I am currently thinking of handling this in the Global... | <p>Jeff Atwood wrote a great Exception Handler that you should look at on <a href="http://www.codeproject.com/KB/exception/ExceptionHandling.aspx" rel="nofollow noreferrer">CodeProject</a></p>
<p>I would attempt to collect as much information as possible.
Stack Information
Session Information
Location of Error</p>
<p... | <p>It actually sounds like you've thought out the solution pretty well. </p>
<p>I work in web development shop, so in addition to logging errors, I also make sure that any system critical errors such as failing db query's and the like are also emailed so that we can jump on them and fix them right away. </p>
<p>An al... | 29,307 |
<p>Does combining an Enterprise Messaging solution with Web Services result in a real performance gain over simple HTTP requests over sockets?</p>
<p>(if implementation details will help, interested in JMS with a SOAP webservice)</p>
| <p>yes, make a copy of the FlowDocument before printing it. This is because the pagination and margins will be different. This works for me.</p>
<pre><code> private void DoThePrint(System.Windows.Documents.FlowDocument document)
{
// Clone the source document's content into a new FlowDocument.
... | <p>I am also generating a WPF report off a Flow document, but I am purposely using the flow document as a print preview screen. I there for want the margins to be the same. You can read about <a href="http://kiwiingenuity.net.nz/post/My-First-WPF-Report" rel="nofollow noreferrer">how I did this here</a>.</p>
<p>In y... | 44,888 |
<p>I found this:</p>
<p><a href="http://www.evolt.org/failover-database-connection-with-php-mysql" rel="nofollow noreferrer">http://www.evolt.org/failover-database-connection-with-php-mysql</a></p>
<p>and similar examples. But is there a better way?</p>
<p>I am thinking along the lines of the <a href="http://www.mic... | <p>It's traditional to handle failover strategies at the system level; that way all applications can enjoy a robust environment.</p>
<p>I'd like to refer to <a href="http://dev.mysql.com/tech-resources/articles/failover-strategy-part1.html" rel="nofollow noreferrer">MySQL failover strategy</a> and <a href="http://forg... | <p>No, it does not have that build in. I think an easy way is to employ <a href="http://forge.mysql.com/wiki/MySQL_Proxy" rel="nofollow noreferrer">MySQL Proxy</a>. Otherwise, but the <em>logic</em> (<code>if (fails) { connect to another }</code>) in your application, but that's not so pretty and great in terms of perf... | 23,261 |
<p>I need to put the image from an NSProgressIndicator into an NSOutlineView Cell. I have written up code that does this for a determinate indicator and it works just great:</p>
<pre><code>NSProgressIndicator *progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 16, 16)];
[progressIndicator ... | <p>I've used <a href="https://www.harmless.de/cocoa-code.php" rel="nofollow noreferrer">AMIndeterminateProgressIndicatorCell</a> for indeterminate progress indicators in cells. It's not a true NSProgressIndicator, as it does it's own drawing, but it's a pretty good replica, IMO.</p>
<p><a href="https://i.stack.imgur.... | <p>Progress indicators do use a background thread to keep their animation drawing even if the main thread is busy doing something else, so it's possible that's what's causing the problem. You might try calling setUsesThreadedAnimation:NO on the progress indicator before doing your drawing to see if that makes a differ... | 32,842 |
<p>Anyone got a working example of using ruby to post to a presigned URL on s3</p>
| <p>I have used aws-sdk and right_aws both.</p>
<p>Here is the code to do this.</p>
<pre><code>require 'rubygems'
require 'aws-sdk'
require 'right_aws'
require 'net/http'
require 'uri'
require 'rack'
access_key_id = 'AAAAAAAAAAAAAAAAA'
secret_access_key = 'ASDFASDFAS4646ASDFSAFASDFASDFSADF'
s3 = AWS::S3.new( ... | <p>I've managed to sort it out. Turns out the HTTP:Net in Ruby is has some short comings. Lot of Monkeypatch later I got it working.. More details when I have time. thank</p>
| 11,554 |
<p>I have an abstract base class and I want to declare a field or a property that will have a different value in each class that inherits from this parent class. </p>
<p>I want to define it in the baseclass so I can reference it in a base class method - for example overriding ToString to say "This object is of type <i... | <p>Of the three solutions only <strong>Option 1</strong> is <strong>polymorphic</strong>. </p>
<p>Fields by themselves cannot be overridden. Which is exactly why <strong>Option 2</strong> returns the <strong><em>new</em></strong> keyword warning. </p>
<p>The solution to the warning is not to append the “new” keyword... | <p>I'd go with option 3, but have an abstract setMyInt method that subclasses are forced to implement. This way you won't have the problem of a derived class forgetting to set it in the constructor.</p>
<pre><code>abstract class Base
{
protected int myInt;
protected abstract void setMyInt();
}
class Derived : Base... | 42,265 |
<p>I'm trying to use a generic list as a property of the users profile. I'll admit this is probably just making my life harder than it needs to be but I don't want to change the programming model just because the data store struggles.</p>
<p>I have this in my web.config</p>
<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,470 |
<p>How do I declare a session variable in PL/SQL - one that will persist for the duration of the session only, without me having to store it in the database itself?</p>
| <p>You create a package level variable. This is a minimal example:</p>
<pre><code>CREATE OR REPLACE PACKAGE my_package
AS
FUNCTION get_a RETURN NUMBER;
END my_package;
/
CREATE OR REPLACE PACKAGE BODY my_package
AS
a NUMBER(20);
FUNCTION get_a
RETURN NUMBER
IS
BEGIN
RETURN a;
END ... | <p>I like to use a <strong>short, but intuitive syntax</strong> and thus would create e.g. some <strong><code>ctx</code> package</strong> that just provides <strong>one function to set and get some global "variables"</strong>.<br>
(valid for the current session only ; in my case no need to implement it as user-created-... | 38,657 |
<p>What's the difference between a string and a symbol in Ruby and when should I use one over the other?</p>
| <p>The main difference is that multiple symbols representing a single value are identical whereas this is not true with strings. For example:</p>
<pre><code>irb(main):007:0> :test.object_id
=> 83618
irb(main):008:0> :test.object_id
=> 83618
irb(main):009:0> :test.object_id
=> 83618
</code></pre>
<p... | <p>A symbol is something you use to represent names and strings. You would want to use a symbol when you may have need to use a string several times as this far easier and more productive.</p>
<p>And just found this via google, which may offer greater detail: <a href="http://glu.ttono.us/articles/2005/08/19/understan... | 31,826 |
<p>The <strong><code>fuser</code></strong> command lets me know which processes are using a file or directory.</p>
<p>I'm looking for command that does the opposite: lets me know which files are being used by a process.</p>
<hr>
<h2>Update</h2>
<p>Forgot to mention that it's for a Solaris system.</p>
| <pre><code>lsof -p <pid>
</code></pre>
<p>From <a href="http://ph7spot.com/articles/leveraging_lsof" rel="noreferrer">here</a></p>
<blockquote>
<p>lsof stands for “<strong>LiSt Open Files</strong>”. This shell command seems deceptively simple: It lists information about files opened by processes on a UNIX box.</p... | <p>You can get lsof from <a href="http://www.sunfreeware.com/programlistsparc10.html#lsof" rel="nofollow noreferrer">http://www.sunfreeware.com/programlistsparc10.html#lsof</a></p>
<p>You can also try pfiles:</p>
<p><a href="http://docs.oracle.com/cd/E23823_01/html/816-5165/pfiles-1.html#scrolltoc" rel="nofollow nore... | 38,638 |
<p>I can't seem to find any <em>useful</em> documentation from Microsoft about how one would use the <code>Delimiter</code> and <code>InheritsFromParent</code> attributes in the <code>UserMacro</code> element when defining user Macros in <code>.vsprops</code> property sheet files for Visual Studio.</p>
<p>Here's sampl... | <p><em>[Answering my own question]</em></p>
<p><code>InheritsFromParent</code> means prepend. To verify this, I did an experiment that reveals how User Macros work in Visual Studio 2008. Here's the setup:</p>
<ul>
<li>Project <code>p.vcproj</code> includes the property sheet file <code>d.vsprops</code> ('d' for <em>... | <p>There's documentation on the UI version of this <a href="http://msdn.microsoft.com/en-us/library/a2zdt10t.aspx" rel="nofollow noreferrer">here</a>.
A lot of the XML files seem somewhat undocumented, often just giving a <a href="http://msdn.microsoft.com/en-us/library/ak4435es.aspx" rel="nofollow noreferrer">schema f... | 17,242 |
<p>I need an API that can make menus like Win32API,<br>
But something simpler and better than WinAPI.<br>
That can make GUI, with text zones, buttons etc...like an average Windows program.(Windows GUI Style)<br>
Can anyone recommand on one like it? Thanks.</p>
| <p><a href="http://www.wxwidgets.org/" rel="nofollow noreferrer">wxWidgets</a>:</p>
<blockquote>
<p>wxWidgets lets developers create applications for Win32, Mac OS X, GTK+, X11, Motif, WinCE, and more using one codebase. It can be used from languages such as C++, Python, Perl, and C#/.NET. Unlike other cross-platfor... | <p>If you really are using Win32 directly, you might try MFC.</p>
<p>Or if you want something more modern, WTL</p>
<p><a href="http://wtl.sourceforge.net/" rel="nofollow noreferrer">http://wtl.sourceforge.net/</a></p>
<blockquote>
<p>Windows Template Library (WTL) is a
C++ library for developing Windows
applic... | 20,629 |
<p>We are trying to automate a build of one of our products which includes a step where it packages some things with WISE. At one point WISE pops up a window with a progress bar on it to show how it is doing. If one is connected to the machine with remote desktop the build works fine but if one is not connected the b... | <p>Sorry for yet another guess - but I had a problem with a wise installer locking up. It was because WISE had installed a "font" and so broadcast a "system config changed" message. My DELL had a Dell utility running on it that had a message queue it wasn't reading from so the broadcast locked up the installer. WISE... | <p>What version are you using? Looking at the feature set, it looks like their "std" version might be limited. Perhaps unattended installs require the Pro version?
That's just a guess....</p>
<p>Regardless, I wonder whether you could simply code up an auto-run task for the box that calls<br>
<a href="http://msdn.mic... | 19,857 |
<p>I faced a little trouble - I do not know if I can define my own operators for my classes.
For example:<br></p>
<pre><code>type
TMinMatrix = class(TMatrix)
private
RowAmount: Byte;
ColAmount: Byte;
Data: DataMatrix;
DemVector, SupVector: SupplyDemand;
public
constructor Create... | <p>Operator overloading is possible in Delphi .NET versions, older versions of Delphi don't support it.</p>
| <p>I suppose copy constructor is an idiom, not a language feature.<br>
So I can do it like this:<br>
constructor CreateCopy(var t: MyType);<br></p>
<p>constructor MyType.CreateCopy(var t: MyType);<br>
begin<br>
//...<br>
end;<br></p>
| 42,676 |
<p>Our company makes the web based application which is priced per workstation.</p>
<p>That means that user/pass credentials should only be used from one particular machine. </p>
<p>Currently what is happening that several users are sharing credentials and we do not have any way to prevent this if they are not doing ... | <p>Set a cookie on the machine with an id. Retrieve the cookie each time the user logs in. If you see several different cookies alternating for a single user you know you've got something odd going on. </p>
<p>(Of course a single switch may just mean they've moved to a new PC as one off. )</p>
<p>Alternatively, price... | <p>There's no easy answer as your clients (the software) are effectively anonymous and the users are self-identifying.</p>
<p>For IE "locking you out" (I'm hardly an IE expert), but can't the IE settings be set for particular domains? You could simply make it a requirement that the users configure their browsers to gi... | 31,359 |
<p>How would I get the <code>here</code> and <code>and here</code> to be on the right, on the same lines as the lorem ipsums? See the following:</p>
<pre class="lang-none prettyprint-override"><code>Lorem Ipsum etc........here
blah.......................
blah blah..................
blah.......................
... | <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><div style="position: relative; width: 250px;">
<div style="position: absolute; top: 0; right: 0; width: 100px; t... | <p>The first line would consist of 3 <code><div></code>s. One outer that contains two inner <code><div></code>s. The first inner <code><div></code> would have <code>float:left</code> which would make sure it stays to the left, the second would have <code>float:right</code>, which would stick it to the... | 9,129 |
<p>Does anyone know of a good YAML Parser for PHP? If so, what are the pros and cons of this library?</p>
| <blockquote>
<p><strong>Last updated</strong>: July 26th, 2017</p>
</blockquote>
<p>Here's a summary of the state of YAML in PHP:</p>
<ul>
<li>Wrappers to C libraries: You'll probably want these if you need sheer speed:
<ul>
<li><a href="https://pecl.php.net/package/yaml" rel="noreferrer">php-yaml</a>: Wrapper for... | <p>If you're using a lot of YAML in your project you may find that the pure PHP libraries like spyc or Symfony YAML are not fast enough. There are at least two PHP bindings for C YAML parsers:</p>
<ul>
<li><a href="http://pecl.php.net/package/yaml/" rel="nofollow noreferrer">yaml</a> - a wrapper for the LibYAML YAML 1... | 37,575 |
<p>Although I've done programming, I'm not a programmer. I've recently agreed to coordinate getting a Website up for a club. The resources are--me, who has done Web content maintenance (putting content into HTML and ColdFusion templates via a gatekeeper to the site itself; doing simple HTML and XML coding); a serious W... | <p>If you don't require any dynamic content, heck, if you don't plan on editing the content more than once a week, I'd say stick to basic HTML.</p>
<p>Later, you'd probably want a basic, no-fuss and easily installable CMS. The brand really depends on the platform (most likely PHP/Rails/ASP), but most of them can be fo... | <p>Personally, I'd never use JPEG images on a website, mainly because of three reasons:</p>
<ol>
<li>JPEGs often contains artifacts.</li>
<li>Quality is often proportional
with filesize. </li>
<li>Does not support
alpha transparency.</li>
</ol>
<p>That said, I'd recommend you to use PNGs for images since it's lossles... | 3,796 |
<p>Im trying to add a connection to a database in SQL Server 2008 using Visual Studio 2008. When testing the connection, it says that it is successful. However, once I said okay, it complains and say: "Cannot add data connection. Object reference not set to an instance of an object."</p>
<p>How do I go about adding a ... | <p>Via code would be something like:</p>
<pre><code>var conn = new SqlConnection([connectionString]);
conn.Open();
</code></pre>
| <p>"Object reference not set to an instance of an object" is usually an indicator of not using the Keyword "New".</p>
| 47,870 |
<p>What are all the other things the <code>new</code> operator does other than allocating memory and calling a constructor?</p>
| <p>The C++ standard has this to say about the single object form (the form usually used) of the new operator from the <code><new></code> header:</p>
<blockquote>
<p>Required behavior: </p>
<p>Return a nonnull pointer to suitably aligned storage (3.7.3), or else throw a
bad_alloc exception. This requirem... | <p>Depends on if it's overloaded or not, if you built the app for debugging, if you're using a memory leak detector, if you have some kind of memory pooling scheme, if you have something like the Boehm garbage collector that's marking/unmarking bits, etc., etc. It could be doing a lot of custom stuff inside, or nothin... | 49,386 |
<p><strong>To Clarify to all this problem absolutely does not stem from rebinding of the controls and the value does not remain the initial value after binding.</strong></p>
<p>I have a DropDownList on an aspx page which is being used in multiple projects.</p>
<p>Along the life cycle of the page the SelectedValue is ... | <p>Maybe some initialization is performed twice in the on_load event because you dont check the page is posted back using <a href="http://msdn.microsoft.com/fr-fr/library/system.web.ui.page.ispostback(VS.80).aspx" rel="nofollow noreferrer">IsPostBack</a> in a test ?</p>
<p>It exactly happens to one of my colleague ten... | <p>I usually see this behavior when I've forgotten to check IsPostback somewhere. The page will load all of the original data before going to the SelectedIndexChanged event handler.</p>
| 21,499 |
<p>I want the equivalent online resource to DNS in Twenty-One Days. I need one evening's reading that will explain what the different record types do, how do propagation and caching work, what is an SoA, etc.</p>
<p>I don't want anything that begins by explaining what DNS is.</p>
<p>Can anybody please point me in th... | <p>Check out <a href="http://www.zytrax.com/books/dns/" rel="nofollow noreferrer">DNS for Rocket Scientists</a></p>
<p>It does start with a very brief "What DNS is" but you can easily skip that.</p>
<p>You can also check out <a href="http://www.dnsmadeeasy.com/s0306/res/recs.html" rel="nofollow noreferrer">Records 10... | <p>When I set up DNS for the first time I read <a href="http://www.langfeldt.net/DNS-HOWTO/BIND-9/" rel="nofollow noreferrer">DNS HOWTO</a>. It worked pretty well for me.</p>
| 34,789 |
<p>I'm looking for an algorithm to generate permutations of a set in such a way that I could make a lazy list of them in Clojure. i.e. I'd like to iterate over a list of permutations where each permutation is not calculated until I request it, and all of the permutations don't have to be stored in memory at once.</p>
... | <p>Yes, there <em>is</em> a "next permutation" algorithm, and it's quite simple too. The C++ standard template library (STL) even has a function called <code>next_permutation</code>.</p>
<p>The algorithm actually finds the <em>next</em> permutation -- the lexicographically next one. The idea is this: suppose you are g... | <p>It looks necromantic in 2022 but I'm sharing it anyway</p>
<p><a href="https://github.com/hextriclosan/algorithm" rel="nofollow noreferrer">Here</a> an implementation of C++ <code>next_permutation</code> in Java can be found. The idea of using it in Clojure might be something like</p>
<pre><code>(println (lazy-seq (... | 45,861 |
<p>Does anyone have some numbers on this? I am just looking for a percentage, a summary will be better.</p>
<p>Standards compliance: How does the implementation stack up to the standard language specification?</p>
<p>For those still unclear: I place emphasis on <strong>current</strong>. The IronPython link provided b... | <p>The following sites usually have updates as to how their 'compliance' is progressing:</p>
<p>IronPython -</p>
<p><a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython" rel="nofollow noreferrer">http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython</a><br>
<a href="http://www.codeplex.com/I... | <p>We don't actively track these kinds of numbers, but you could download them and run them against the respective test suites for the languages if you wanted to boil it down to a single numeric value.</p>
| 16,258 |
<p>In a table, I have three columns - id, name, and count. A good number of name columns are identical (due to the lack of a UNIQUE early on) and I want to fix this. However, the id column is used by other (4 or 5, I think - I would have to check the docs) tables to look up the name and just removing them would break t... | <p>This kind of question comes up from time to time. No, there's not a really clean way to do it. You have to change all the rows in the child table that depend on unwanted values in the parent table before you can eliminate the unwanted rows in the parent table.</p>
<p>MySQL supports multi-table <code>UPDATE</code>... | <p>Why can't you do something like</p>
<pre><code>update dependent_table set name_id = <id you want to keep> where name_id in (
select id from names where name = 'foo' and id != <id you want to keep>)
</code></pre>
| 31,721 |
<p>I'm interested in compressing data using Python's <code>gzip</code> module. It happens that I want the compressed output to be deterministic, because that's often a really convenient property for things to have in general -- if some non-gzip-aware process is going to be looking for changes in the output, say, or if... | <p>From Python 2.7 onwards you can specify the time to be used in the gzip header. N.B. filename is also included in the header and can also be specified manually.</p>
<pre><code>import gzip
content = b"Some content"
f = open("/tmp/f.gz", "wb")
gz = gzip.GzipFile(fileobj=f,mode="wb",filename="",mtime=0)
gz.write(cont... | <p>In lib/gzip.py, we find the method that builds the header, including the part that does indeed contain a timestamp. In Python 2.5, this begins on line 143:</p>
<pre><code>def _write_gzip_header(self):
self.fileobj.write('\037\213') # magic header
self.fileobj.write('\010') # comp... | 33,088 |
<p>I'm working with an XML file that subscribes to an industry standard. The standards document for the schema defines one of the fields as a rational number and its data is represented as two integers, typically with the second value being a 1 (e.g. <code><foo>20 1</foo></code>). I've been hunting around w... | <p>This isn't exactly an answer to the XML-side of things, but if you are wanting a C# class for representing rational numbers, I write a very flexible one a while back as part of my <a href="https://github.com/mckamey/exif-utils.net" rel="nofollow noreferrer">ExifUtils library</a> (since most EXIF values are represent... | <p>i'm glad they didn't accept this proposal as a standard! the guy proposing to base all other numbers on a 'rational number' primitive has never heard of transcendental numbers (like Pi, for example) which cannot be represented in this manner</p>
<p>but back to your question - i've only run across rational numbers i... | 37,162 |
<p>how to create a good plugin engine for standalone executables created with pyInstaller, py2exe or similar tools? </p>
<p>I do not have experience with py2exe, but pyInstaller uses an import hook to import packages from it's compressed repository. Of course I am able to import dynamically another compressed reposito... | <p>When compiling to exe, your going to have this issue.</p>
<p>The only option I can think of to allow users access with thier plugins to use any python library is to include all libraries in the exe package. </p>
<p>It's probably a good idea to limit supported libraries to a subset, and list it in your documentati... | <p>PyInstaller <em>does</em> have a plugin system for handling hidden imports, and ships with several of those already in. See the webpage (<a href="http://www.pyinstaller.org" rel="nofollow noreferrer">http://www.pyinstaller.org</a>) which says:</p>
<blockquote>
<p>The main goal of PyInstaller is to be compatible w... | 39,550 |
<p>My php is weak and I'm trying to change this string:</p>
<pre><code>http://www.example.com/backend.php?/c=crud&m=index&t=care
^
</code></pre>
<p>to be:</p>
<pre><code>http://www.example.com/backend.php?c=crud&m=index&t=care
^
</c... | <p>I think that it's better to use simply <a href="http://www.php.net/str_replace" rel="noreferrer">str_replace</a>, like the manual says:</p>
<blockquote>
<p>If you don't need fancy replacing
rules (like regular expressions), you
should always use this function
instead of ereg_replace() or
preg_replace().<... | <p>While a regexp would suit here just fine, I'll present you with an alternative method. It <em>might</em> be a tad faster than the equivalent regexp, but life's all about choices (...or something).</p>
<pre><code>$length = strlen($urlString);
for ($i=0; $i<$length; i++) {
if ($urlString[$i] === '?') {
$urlS... | 33,129 |
<p>I have a string coming from a table like "can no pay{1},as your payment{2}due on {3}". I want to replace {1} with some value , {2} with some value and {3} with some value .</p>
<p>Is it Possible to replace all 3 in one replace function ? or is there any way I can directly write query and get replaced value ? I wa... | <p>Although it is not one call, you can nest the <code>replace()</code> calls:</p>
<pre><code>SET mycol = replace( replace(mycol, '{1}', 'myoneval'), '{2}', mytwoval)
</code></pre>
| <p>If you are doing this inside of a select, you can just piece it together, if your replacement values are columns, using string concatenation.</p>
| 10,941 |
<p>There are many editions of Eclipse for Java development. I am trying out MyEclipse and am pretty impressed with the out-of-box experience. Before I get too comfortable with it, I would like to find out if it is the best edition available. Feel free to list free or commercial packages, but for the sake of other re... | <p>I'm always just downloading <strong>classic</strong> edition and just add plugins I need. That way I keep Eclipse as lean as possible.</p>
| <p>Agree with <a href="https://stackoverflow.com/questions/305708/best-eclipse-version-for-java-development#305743">Marko</a> and <a href="https://stackoverflow.com/questions/305708/best-eclipse-version-for-java-development#305749">Epaga</a></p>
<p>I have Eclipse 3.4 (Ganymede) with following additional plugins (links... | 39,328 |
<p>I need to test a url that it <strong>does not</strong> end with <code>.asp</code></p>
<p>So <code>test</code>, <code>test.html</code> and <code>test.aspx</code> should match, but <code>test.asp</code> should not match.</p>
<p>Normally you'd test if the url <strong>does</strong> end with .asp and negate the fact th... | <p>The trick is to use <a href="http://www.regular-expressions.info/lookaround.html" rel="noreferrer">negative lookbehind</a>.</p>
<p>If you need just a yes/no answer:</p>
<pre><code>(?<!\.asp)$
</code></pre>
<p>If you need to match the whole URL:</p>
<pre><code>^.*(?<!\.asp)$
</code></pre>
<p>These regexes ... | <p>Try this</p>
<pre><code>^((?!\.asp$).)*$
</code></pre>
| 41,907 |
<p>I've created an Access 2007 form that displays, for example, Products from a Product table. One of the fields in the Product table is a CategoryID that corresponds to this product's parent category.</p>
<p>In the form, the CategoryID needs to be represented as a combo box that is bound to the Category table. The ... | <p>You need to use both values in the query for the combo box.<br>
e.g. SELECT CategoryId, CategoryName FROM CategoryTable...
Bind the combo box to the fist column, CategoryId.
Set the column widths for the combo box to 0in (no second value need, so there is no limit). This will hide the first column which contains you... | <p>You should also check that your categories table has a primary key on the CategoryName field. You original configuration should have thrown an error or message saying the update would violate the key. As it is it seems you can have 2 categories with the same name.</p>
| 9,449 |
<p>Can we write an regular expression such that it splits the stored procedure in multiple SQL statements.
It should split update, delete select etc statements.</p>
<p>Edit: my attempt to solve the problem <a href="http://tsqlparsergdr.codeplex.com/" rel="nofollow noreferrer">http://tsqlparsergdr.codeplex.com/</a></p... | <p>If you have the grammar for the stored procedure language you could use <a href="http://www.antlr.org/" rel="nofollow noreferrer">ANTLR</a> so parse the procedure to get the relevant parts of the language out and the do any further processing necessary. It should be reletively easy to get a grammar going from scratc... | <p>To parse arbitrary stored procedures, you're far better off with a SQL parser. Trying to parse arbitrary SQL with regexes will amount to writing your own parser.</p>
<p>To parse a specific set of stored procedures, a regex may be able to do the job. You'll need to provide a few examples of the input you have and ... | 44,125 |
<p>So, I have a pair of typeclasses that I'll be using a lot together, and I want to avoid specifying both each time. Basically, instead of putting</p>
<pre><code>:: (Ord a, Fractional a, Ord b, Fractional b, ... Ord z, Fractional z) =>
</code></pre>
<p>at the beginning of all my type specifications, I'd rather p... | <p>With the ConstraintKinds extension introduced in GHC 7.4, constraints are now types of kind <code>Constraint</code>, so you can use ordinary type synonyms to get what you want:</p>
<pre><code>{-# LANGUAGE ConstraintKinds #-}
type OrdFractional a = (Ord a, Fractional a)
</code></pre>
| <p>No.</p>
<p>Your solution of a superclass implying the other classes is the closest to what you want that is possible in Haskell. Even though that requires manual instances of that new class it is sometimes used, for example in the <a href="http://hackage.haskell.org/package/rewriting" rel="nofollow noreferrer">rewr... | 39,401 |
<p>If it does, then how do you justify the overheads incurred (journaling etc.)?
If it does not, then how come the pagefile gets fragmented?
Additionally, would increasing the cluster size improve pagefile performance (cluster slack space is a non-issue)?</p>
| <p>You can skip the boost namespace entirely by using the techniques described <a href="http://through-the-interface.typepad.com/through_the_interface/2006/07/advanced_visual_1.html" rel="noreferrer">here</a>. Just use something like:</p>
<p><code>boost\:\:.*=NoStepInto</code></p>
<p>... in the relevant registry entr... | <p>You can skip the boost namespace entirely by using the techniques described <a href="http://through-the-interface.typepad.com/through_the_interface/2006/07/advanced_visual_1.html" rel="noreferrer">here</a>. Just use something like:</p>
<p><code>boost\:\:.*=NoStepInto</code></p>
<p>... in the relevant registry entr... | 38,143 |
<p>I'm reading text from a flat file in c# and need to test whether certain values are dates. They could be in either YYYYMMDD format or MM/DD/YY format. What is the simplest way to do this in .Net?</p>
| <pre class="lang-cs prettyprint-override"><code>string[] formats = {"yyyyMMdd", "MM/dd/yy"};
var Result = DateTime.ParseExact(input, formats, CultureInfo.CurrentCulture, DateTimeStyles.None);
</code></pre>
<p>or</p>
<pre class="lang-cs prettyprint-override"><code>DateTime result;
string[] formats = ... | <p>You can also do Convert.ToDateTime</p>
<p>not sure the advantages of either</p>
| 15,000 |
<p>I have a structure that represents a wire format packet. In this structure is an array of other structures. I have generic code that handles this very nicely for most cases but this array of structures case is throwing the marshaller for a loop.</p>
<p>Unsafe code is a no go since I can't get a pointer to a struc... | <p>Using memcpy to copy an array of bytes to a structure is extremely dangerous if you are not controlling the byte packing of the structure. It is safer to marshall and unmarshall a structure one field at a time. Of course you will lose the generic feature of the sample code you have given.</p>
<p>To answer your real... | <p>Not altering the structure is certainly sound advice. I use liberal amounts of StructLayout attributes to specify the packing, layout and character encoding. Everything flows just fine.</p>
<p>My issue is just that I need a performant and preferably generic solution. Performance because this is a server applicat... | 42,758 |
<p>I want a C program to produce a core dump under certain circumstances. This is a program that runs in a production environment and isn't easily stopped and restarted to adjust other kinds of debugging code. Also, since it's in a production environment, I don't want to call abort(). The issues under investigation are... | <pre><code>void create_dump(void)
{
if(!fork()) {
// Crash the app in your favorite way here
*((void*)0) = 42;
}
}
</code></pre>
<p>Fork the process then crash the child - it'll give you a snapshot whenever you want</p>
| <p>The source code to produce a core dump is in 'gcore', which is part of the gdb package.</p>
<p>Also, the Sun has <a href="http://docs.oracle.com/cd/E23823_01/html/816-5165/gcore-1.html" rel="nofollow noreferrer">gcore</a>.</p>
<p>Also, you have to have a separate process running the core dump, as the current proce... | 15,949 |
<p>As the title really, I'm in one part of my code and I would like to invoke any methods that have been added to the Button.Click handler.</p>
<p>How can I do this?</p>
| <p>Do you mean you need to access it from elsewhere in your code? It may be an idea to refactor that section to it's own method then call that method whenever you need to access it (including in the Click event)</p>
| <p>You will need an event to act as a proxy, but you are pretty much better off just refactoring your code.</p>
<pre><code> private EventHandler ButtonClick;
protected override void CreateChildControls()
{
base.CreateChildControls();
m_Button = new Button{Text = "Do something"};
m... | 36,421 |
<p>If I have a class that needs to implement an interface but one or more of the methods on that interface don't make sense in the context of this particular class, what should I do?</p>
<p>For example, lets say I'm implementing an adapter pattern where I want to create a wrapper class that implements <a href="http://... | <p>Any method that cannot be implemented according to the semantics of the interface should throw an <a href="http://java.sun.com/javase/6/docs/api/java/lang/UnsupportedOperationException.html" rel="nofollow noreferrer">UnsupportedOperationException</a>.</p>
| <p>Your two choices are really only:</p>
<ol>
<li>Do nothing.</li>
<li>Throw an exception.</li>
</ol>
<p>Both have disadvantages. In the first case, by having an empty method, you could mislead the programmer into thinking something happened to your data. The second case breaks the whole idea of polymorphism inherent... | 21,641 |
<p>I'm writing an HTTP Cache library for Java, and I'm trying to use that library in the same application which is started twice. I want to be able to share the cache between those instances.</p>
<p>What is the best solution for this? I also want to be able to write to that same storage, and it should be available for... | <p>First, are you sure you want to write your own cache when there are several around? Things like:</p>
<ul>
<li><a href="http://ehcache.sourceforge.net/" rel="nofollow noreferrer">ehcache</a></li>
<li><a href="http://www.jboss.org/jbosscache/" rel="nofollow noreferrer">jboss cache</a></li>
<li><a href="http://www.dan... | <p>I think you should have a look at the <a href="http://www.greenbytes.de/tech/webdav/" rel="nofollow noreferrer">WebDav-Specifications</a>. It's an HTTP extension for sharing/editing/storing/versioning resources on a server. There exists an implementation as an <a href="http://www.webdav.org/mod_dav/" rel="nofollow n... | 38,431 |
<p>Encouraged by SO, I'm trying to write an ASP.NET site that uses OpenID for user authentication. It's a regular WinForms site (not MVC.NET), using the <a href="http://code.google.com/p/dotnetopenid/" rel="nofollow noreferrer">DotNetOpenId</a> library for authentication.</p>
<p>Is it safe for me to permit/deny admin... | <p>Jarrett makes some good comments about using database tables.</p>
<p>Just to answer another one of your questions, no, it's not a confidentiality thing to put your OpenID in your code generally. If setting up roles seems overkill for your site, a simple equality check against your ClaimedIdentifier is just perfect... | <p>My solution is to follow the same idea of the Roles table. After you've authenticated the user, look up that user's roles. If the user has role "Administrator" in the UserRoles table, then they can do whatever the Administrator can do.</p>
<p>I don't broadcast open ID's in my app. They're stored in the table. On ev... | 8,109 |
<p>I've been using some basic AOP style solutions for cross-cutting concerns like security, logging, validation, etc. My solution has revolved around <a href="http://www.castleproject.org/container/index.html" rel="nofollow noreferrer">Castle Windsor</a> and DynamicProxy because I can apply everything using a Boo base... | <p>I only looked at castle-windsor for a short time (yet) so I can't comment on that but I did use postsharp.</p>
<p>Postsharp works by weaving at compile time. It ads a post-compile step to your build where it modifies your code. The code is compiled as if you just programmed the cross cutting concerns into you code.... | <p>I only looked at castle-windsor for a short time (yet) so I can't comment on that but I did use postsharp.</p>
<p>Postsharp works by weaving at compile time. It ads a post-compile step to your build where it modifies your code. The code is compiled as if you just programmed the cross cutting concerns into you code.... | 8,828 |
<p>Currently I know of only two ways to cache data (I use PHP but I assume that the same will apply to most languages).</p>
<ol>
<li>Save the cache to a file</li>
<li>Save the cache to a large DB field</li>
</ol>
<p>Are there any other (perhaps better) ways of caching or is it really just this simple?</p>
| <p>Maybe you want to explicit more precisely what you want to cache. You have all this opportunities to cache: </p>
<ul>
<li><b>Accessing the Data Base</b> where you cache the data first correctly tuning your RDBMS, then using a layer to delegate the decision to detect multiple queries for the same data (with <a href=... | <p>Seconding memcached, does the simple stuff well and can go distributive and all that jazz if you need it too</p>
| 2,608 |
<p>MXML lets you do some really quite powerful data binding such as:</p>
<pre><code><mx:Button id="myBtn" label="Buy an {itemName}" visible="{itemName!=null}"/>
</code></pre>
<p>I've found that the BindingUtils class can bind values to simple properties, but neither of the bindings above do this. Is it possible... | <p>The way to do it is to use <code>bindSetter</code>. That is also how it is done behind the scenes when the MXML in your example is transformed to ActionScript before being compiled.</p>
<pre><code>// assuming the itemName property is defined on this:
BindingUtils.bindSetter(itemNameChanged, this, ["itemName"]);
//... | <p>I believe flex generates a small anonymous function to deal with this.</p>
<p>You could do similar using a ChangeWatcher. You could probably even make a new anonymous function in the changewatcher call.</p>
| 12,772 |
<p>I am generating the json from PHP.</p>
| <p>The correct way is to use <a href="http://www.php.net/json_encode" rel="noreferrer">json_encode()</a></p>
| <p>The JSON is just a subset of Javascript, so everything you know about escaping strings in Javascript applies to JSON.</p>
<p>And yes, the correct answer is to use one of library functions, there is a quite a few of them around: see <a href="http://gggeek.altervista.org/sw/article_20061113.html" rel="nofollow norefe... | 31,535 |
<p>Is there a control or method to accept formatted input in VB.NET?</p>
<p>i.e. It accepts input in a given format ##/##/## or similar?</p>
| <p>You want the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx" rel="nofollow noreferrer">MaskedTextBox</a> control, I believe.</p>
| <p>You want the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx" rel="nofollow noreferrer">MaskedTextBox</a> control, I believe.</p>
| 24,827 |
<p>I've been preparing to deliver a presentation on SQL Server Compact Edition 3.5 (SP1 - recently released) and I was wondering if anyone had designed (or contemplated designing) a system with SQL Server CE 3.5 (or earlier versions)?</p>
<p>In particular, has anyone thought of (or experienced) using SQLCE as a soluti... | <p>At work, we recently had to migrate a project that was designed for SQL Server Express to SQLCE. At first I thought it was going to be awful, mainly due to the fact that there are no stored procedures. Once we started digging into it though, and saw what it DOES offer, we were convinced it was the right move. It sup... | <p>Tried SQLCE several times. Always ended up using something else (Firebird (embedded), SQLite, VistaDB). IMO SQLCE is way to limited to be useful in more or less complex scenarios. Though I have no real-world experience with latest version (3.5) but I suspect it still sucks :)</p>
| 23,139 |
<p>I have an application which tries to load some expected registry settings within its constructor.</p>
<p>What is the most appropriate .NET Exception from the BCL to throw if these (essential, non-defaultable) registry settings cannot be loaded?</p>
<p>For example:</p>
<pre><code> RegistryKey registryKey = Registr... | <p>I'd go with <a href="http://msdn.microsoft.com/en-us/library/system.argumentexception.aspx" rel="noreferrer">ArgumentException</a> or <a href="http://msdn.microsoft.com/en-us/library/system.argumentoutofrangeexception.aspx" rel="noreferrer">ArgumentOutOfRangeException</a>..</p>
<pre><code>throw new ArgumentExceptio... | <p>I think just Exception itself could do the job. If your message is descriptive enough, then it's all good. If you really want to be precise about it, then I'd agree with petr k. Just roll your own.</p>
| 48,162 |
<p>I've been teaching OOP and was trying to convey to my students the important difference between inheritance and the creation of a subtype relation between two types. For example, in C++, I could use private inheritance to ensure that nobody outside sees the subtyping relation.</p>
<p>However, while I can think of a... | <p>As a Python programmer, let me say that these are matters that are way, way too subtle. They appear to be purely C++-isms.</p>
<p>In Python, we have inheritance, which creates proper subtypes.</p>
<p>And we have composition using simple attributes, or of the available collections.</p>
<p>This business of private... | <p>Code reuse without subtyping is done using <em>delegation</em>.</p>
<p><a href="http://c2.com/cgi/wiki?DelegationIsInheritance" rel="nofollow noreferrer">Delegation is inheritance</a>.</p>
| 31,873 |
<p>I'd hate to have to relearn C++ just for this! Any libraries/URLs would be great and yes, Google didn't help much here :-( </p>
<p>This is for an upcoming project in which my product (Java based) would provide support for Microsoft's Hyper-V virtualization platform. Unlike VMware, which provides a Web-service, the ... | <p>WMI is acessed via COM right?</p>
<p>While it is more verbose and more error-prone (it is easy to accidentally use different pointers for the vtable and the "this" parameter), you can also use COM from the C language.</p>
<p>You also could use C++ but treat it as "C with language extensions to make using COM easie... | <p>The JNI interface itself is a derivative of COM and you will find those methods and the methods of the WMI interfaces much easier to use if you use enough C++ to treat interfaces as implemented by C++ classes.</p>
<p>The other thing that will be helpful is that you will be able to use the COM interface pointers and... | 36,422 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.