instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I was just working on a localizable Lua string solution, when I came up with this hack, problem is I don't know how to avoid getting hacked by it :)
So I was wondering if anyone, has done something similar and or knows how to protect from this kind of attack. (in user code)</p>
<p>Since we can do this:</p>
<pre><c... | <p>First and foremost execute untrusted code in sandboxed environment only β as it was said by other posters. Except for loading bytecode chunks, Lua allows all other sandboxing issues to be covered. (And bytecode chunk problems get fixed promptly as discovered.)</p>
<p>See <a href="http://www.lua.org/cgi-bin/demo" re... | <p>I have no solution (I don't use Lua, I'm just interested in it from afar), but what you're after is called a "sandbox". Google for <a href="http://www.google.com/search?q=Lua+sandbox" rel="nofollow noreferrer">Lua sandbox</a>, I found a few seemingly interesting pages that way. For example: <a href="http://lua-users... | 42,121 |
<p>I'm working on a PyGTK/glade application that currently has 16 windows/dialogs and is about 130KB, and will eventually have around 25 windows/dialogs and be around 200KB. Currently, I'm storing all the windows in one monolithic glade file. When I run a window I call it like...</p>
<pre><code>self.wTree = gtk.glad... | <p>In my projects, I always have one window per glade file. I'd recommend the same for your project.</p>
<p>The following are the two main reasons:</p>
<ul>
<li>It will be faster and use less memory, since each call to gtk.glade.XML() parses the whole thing. Sure you can pass in the root argument to avoid creating th... | <p>I use different glade files for different windows. But I keep dialog associated with a window in the same glade file. As you said, the naming problem is annoying. </p>
| 43,597 |
<p>More specifically I am trying to make the mailto component show within my template; the same way as an article does. </p>
<p>By default the mailto component opens in a new window. So far I changed the code so it opens on the same window, but that way the whole template is gone.</p>
<p>Any suggestions?</p>
| <p>In the template there is a tag which takes the contents of a component. An article is a com_content component. you are trying to put in a caom_mail_to component? The beauty is that they both plug into the same slot.</p>
<p>Now you can only ever have one component on a page. you can have lots of modules, but only on... | <p>I'm afraid I can't entirely follow your question - do you want to have a sign up form for membership or email notifications shown as an article? If so, then the easiest way is to install 'm2c' - the 'module to component' component. Then you can put any module (ie the sign up box) in the centre content area.</p>
<p>... | 10,434 |
<p>I'm trying to set up a loop where an animation runs a certain number of times, and a function is run before each iteration of the animation. The timing ends up being off, though -- it runs the callback n times, then runs the animation n times. For example:</p>
<pre><code>for (var i=0;i<3;i++) {
console.log(i)... | <p>The animation is asynchronous. So the loops runs through pretty quickly, starting off three animations and outputting 1, 2 and 3. After a while the animations complete and output animated x 3. That would explain your output. </p>
<p>How about some recursion?</p>
<pre><code>do_animation(max_runs, total_runs) {
l... | <p>Both of those solutions worked like a charm! Thanks, MDCore and Kent!</p>
<p>Kent, I don't quite understand why you need to explicitly put the callback in the queue. Not that you're wrong -- it doesn't work if the callback is an argument to animate() -- but I'm just curious. </p>
| 32,022 |
<p>What is SafeHandle? how does it differ from IntPtr? When should I use one? What are its advantages?</p>
| <p>I think <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.safehandle.aspx" rel="noreferrer">MSDN</a> is pretty clear in definition:</p>
<blockquote>
<p>The SafeHandle class provides critical
finalization of handle resources,
preventing handles from being
reclaimed prematurely b... | <p>Another way of looking at it: with SafeHandle, you should <em>almost</em> never need to write another finalizer.</p>
| 18,844 |
<p>Given a collection of user specified tags how do I determine which ones <strong>are not</strong> in the tags table with 1 SQL Statement?</p>
<p>Assuming a table schema <code>tags (id, tag)</code> and I'm using mysql, if there's an optimization I'm unaware of.</p>
<p>thanks</p>
| <pre><code>
SELECT Tag
FROM UserSpecifiedTags
LEFT OUTER JOIN AllTags ON UserSpecifiedTags.Tag = AllTags.Tag
WHERE AllTags.Tag IS NULL
</code></pre>
<p>This should return what you want. In my experience, executing a join and looking for rows which don't have a match is <strong>much</strong> quicker than using ... | <pre><code>select
utt.tagName
from
userTypedTags utt
left join tag t on utt.tagName = t.tag
where
t.ID is null
and utt.userID = <ID of the User in question>
</code></pre>
<p>That is assuming that you have table</p>
<pre><code>userTypedTags(userID, tagName)
</code></pre>
<p>I have added a <a... | 40,613 |
<p>We have a custom REST handler on ASP.NET that is configured like this to handle all incoming requests:</p>
<pre><code><add path="*" verb="*" type="REST.RESTProtocolHandler"/>
</code></pre>
<p>However, passing it a pipe character, properly encoded or not at all, triggers a validation error that seems to come ... | <p>Try to intercept the exception in Global.asax file. Implement there (Global.asax.cs) this method:</p>
<pre><code>protected void Application_Error(Object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
//do whatever you want with that exception
//or get the url from the context, reformat and... | <p>By default IIS does not allow certain characters in the URL and considers them illegal. This is where you problem comes from - it doesn't even call the handler you have. As far as I know there is no place that you can configure which characters are accepted through UI, except for Windows Registry. I don't know why y... | 37,805 |
<p>I want to use the Date::ABBR_MONTHS constant in my rails application. I see the Ruby stdlib documentation at <a href="http://www.ruby-doc.org/stdlib/" rel="nofollow noreferrer">http://www.ruby-doc.org/stdlib/</a> which does not seem to have this constant.
However, this constant is there at <a href="http://stdlib.ru... | <p><code>ABBR_MONTHS</code> is something you get given to you by ActiveSupport and it's just added into the Date class. The first library is for ruby, where the second one is for ruby on rails. The constant may not be working because of different versions of Rails.</p>
| <p>ABBR_MONTHS is added to Date by ActiveSupport. </p>
<p>Rails is in fact a set of a few gems. ActiveSupport's role is mostly to add niceties to the Ruby language and other agnostic tools like the Inflector and the 2.days way of creating Time instances and so on.</p>
<p>So if you need this kind of capability outside... | 20,604 |
<p>I have an ASP.Net page that will be hosted on a couple different servers, and I want to get the URL of the page (or even better: the site where the page is hosted) as a string for use in the code-behind. Any ideas?</p>
| <p>Use this:</p>
<pre><code>Request.Url.AbsoluteUri</code></pre>
<p>That will get you the full path (including <a href="http://.." rel="noreferrer">http://..</a>.)</p>
| <p>Request.Url.Host</p>
| 12,158 |
<p>I have a text file that contains a long list of entries (one on each line). Some of these are duplicates, and I would like to know if it is possible (and if so, how) to remove any duplicates. I am interested in doing this from within vi/vim, if possible.</p>
| <p>If you're OK with sorting your file, you can use:</p>
<pre><code>:sort u
</code></pre>
| <p>This worked for me for both <code>.csv</code> and <code>.txt</code></p>
<p><code>awk '!seen[$0]++' <filename> > <newFileName></code></p>
<p><strong>Explanation:</strong>
The first part of the command prints unique rows and the second part i.e. after the middle arrow is to save the output of the firs... | 45,711 |
<p>Is <a href="http://en.wikipedia.org/wiki/Business_intelligence" rel="noreferrer">"business intelligence"</a> a buzzword that has no real meaning to software developers, or does the term carry some implied meaning in terms of what the software does or how the software does it (in a general sense)? It appears to be a ... | <p>BI != Reporting. BI platforms enable users to build applications that help organizations learn and understand their business. <a href="http://web.archive.org/web/20081216003746/http://mediaproducts.gartner.com/reprints/microsoft/vol7/article3/article3.html" rel="noreferrer">Gartner defines</a> a BI platform as a sof... | <p>Business Intelligence is about understanding one's business. It's an odd converse of Military Intelligence which is about understanding the enemy. It provide suits with information with which to make business decisions.</p>
<p>To a developer, it's a type of software one might develop. Not so much one that a develop... | 37,844 |
<p>Is it possible to to programmatically trigger a postback from server code in ASP.NET? I know that it is possible to do a Response.Redirect or Server.Transfer to redirect to a page, but is there a way to trigger a postback to the same page in server code (<em>i.e.</em> without using javascript trickery to submit a f... | <p>Asp.net Postbacks are initiated from the client (typically form submission). I am not sure what you are trying to achieve. Some of the server side <a href="http://www.15seconds.com/issue/020102.htm" rel="noreferrer">page lifecyle</a> events are already executed and what you are trying to do is raise the previous eve... | <p>For those using newer versions of .NET, you have to use <code>Page.ClientScript.GetPostBackEventReference</code> since <code>'this.GetPostBackEventReference(...)'</code> is obsolete. Also probably <code>Page.ClientScript.RegisterStartupScript(...</code></p>
| 8,559 |
<p>How much code documentation in your .NET source is too much?</p>
<p>Some background: I inherited a large codebase that I've talked about in some of the other questions I've posted here on SO. One of the "features" of this codebase is a God Class, a single static class with >3000 lines of code encompassing several d... | <p>I think a good part of the problem here is the verbose and crufty XML documentation syntax MS has foisted on us (JavaDoc wasn't much better either). The question of how to format it is, to a large degree, independent of how much is appropriate.</p>
<p>Using the XML format for comments is optional. You can use DOxyg... | <p>I've seen coding standards that recommend against commenting self-commenting code and method overloads. While YMMV, it sounds like a good way to get away from the "Field _numberOfCars is an integer that represents the number of cars"-type comments that lead into overkill.</p>
| 36,695 |
<p>I want to resize the font of a SPAN element's style until it the SPAN's text is 7.5 inches wide when printed out on paper, but JavaScript only reports the SPAN's clientWidth property in pixels.</p>
<pre><code><span id="test">123456</span>
</code></pre>
<p>And then:</p>
<pre><code>#test {
font-size:1... | <p>I think this does what you want. But I agree with the other posters, HTML isn't really suited for this sort of thing. Anyway, hope you find this useful.</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="ht... | <p>This is a merged answer of what I've learned from the posts of Orion Edwards (especially the link to webkit.org) and Bill.</p>
<p>It seems the answer is actually always 96 DPI, although you're free to run the following (admittedly sloppy) code and I would love to hear if you get a different answer:</p>
<pre><code>... | 19,257 |
<p>Objective-C has no namespaces; it's much like C, everything is within one global namespace. Common practice is to prefix classes with initials, e.g. if you are working at IBM, you could prefix them with "IBM"; if you work for Microsoft, you could use "MS"; and so on. Sometimes the initials refer ... | <p>Prefixing your classes with a unique prefix is fundamentally the only option but there are several ways to make this less onerous and ugly. There is a long discussion of options <a href="http://www.cocoadev.com/index.pl?AlternativesToPrefixing" rel="noreferrer">here</a>. My favorite is the <code>@compatibility_alias... | <p>If you have two frameworks that have the same function name, you could try dynamically loading the frameworks. It'll be inelegant, but possible. How to do it with Objective-C classes, I don't know. I'm guessing the <code>NSBundle</code> class will have methods that'll load a specific class.</p>
| 21,504 |
<p>How to test if a line segment intersects an axis-aligned rectange in 2D? The segment is defined with its two ends: p1, p2. The rectangle is defined with top-left and bottom-right points.</p>
| <p>The original poster wanted to DETECT an intersection between a line segment and a polygon. There was no need to LOCATE the intersection, if there is one. If that's how you meant it, you can do less work than Liang-Barsky or Cohen-Sutherland:</p>
<p>Let the segment endpoints be p1=(x1 y1) and p2=(x2 y2).
<br>
Let ... | <p>I did a little napkin solution..</p>
<p>Next find m and c and hence the equation <strong>y = mx + c</strong></p>
<pre><code>y = (Point2.Y - Point1.Y) / (Point2.X - Point1.X)
</code></pre>
<p>Substitute P1 co-ordinates to now find c</p>
<p>Now for a rectangle vertex, put the X value in the line equation, get the ... | 12,459 |
<p>I am wondering if anyone here knows of any 3D printers that work by assembling models from parts instead of extruding or setting material.</p>
<p>The closest I have found is the <a href="https://www.youtube.com/channel/UCtoqCrwr91bNH_hbPtBrprw" rel="nofollow noreferrer">pixelstone</a> but it appears to only be a pro... | <h2>Yes and no</h2>
<p><strong>Yes</strong>, there are machines, that assemble things from parts. For example, <a href="https://en.wikipedia.org/wiki/SMT_placement_equipment" rel="nofollow noreferrer">SMT placement equipment & pick-and-place-machines</a>. Almost all electronics are made this way. In fact, a lot of ... | <p>I've prototyped a design that used beads similar to these <a href="http://www.infostir.com/images/plastic-beads-350.jpg" rel="nofollow noreferrer">http://www.infostir.com/images/plastic-beads-350.jpg</a> on a rod with a heated tip and then you just press them off into the design. But it wasn't too strong and had som... | 542 |
<p>I have a rails app that accepts file uploads and I wanted to know the best way to have common storage between servers. Since we have a number of windows applications we have used samba in the past, but as we build pure linux apps I would like to do this the best possible way.</p>
<p>We are expecting large amounts ... | <p>I've used <a href="http://railscasts.com/episodes/134-paperclip" rel="nofollow noreferrer">paperclip</a> with an S3 backend.</p>
| <p>One easy way to do it is to use attachment_fu with an S3 backend.</p>
| 42,501 |
<p>I need a Guid property in some attribute class like this:</p>
<pre><code>public class SomeAttribute : Attribute {
private Guid foreignIdentificator;
public Guid ForeignIdentificator {
get { return this.foreignIdentificator; }
set { this.foreignIdentificator = value; }
}
}
</code></pre>
... | <p>I have run into your exact problem in the past. We simply required them to pass in the GUID as a string... the default way that the VS GUID generator tool gives it to us (*F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4). We essentially did what you did. We use it in a plug-in architecture, so our customers have been the on... | <p>Attribute parameters must be constant. If I break the rules, my C# compiler gives this error:</p>
<blockquote>
<p>An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type</p>
</blockquote>
<p>Since there are no GUID literals in C#, you ha... | 42,197 |
<p>What's the best way to create a non-NULL constraint in MySQL such that fieldA and fieldB can't both be NULL. I don't care if either one is NULL by itself, just as long as the other field has a non-NULL value. And if they both have non-NULL values, then it's even better.</p>
| <p>MySQL 5.5 introduced <a href="http://dev.mysql.com/doc/refman/5.5/en/signal.html" rel="noreferrer">SIGNAL</a>, so we don't need the extra column in Bill Karwin's answer any more. Bill pointed out you also need a trigger for update so I've included that too.</p>
<pre><code>CREATE TABLE foo (
FieldA INT,
FieldB I... | <p>I accomplished this using a <strong>GENERATED ALWAYS</strong> column with <strong>COALESCE ... NOT NULL</strong>:</p>
<pre><code>DROP TABLE IF EXISTS `error`;
CREATE TABLE IF NOT EXISTS `error` (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
left_id BIGINT UNSIGNED NULL,
right_id BIGINT UNSIGN... | 20,572 |
<p><strong>Update 1:</strong><br>
Cannot reproduce this on a co-worker's computer (same setup as mine) so I assume this is a problem with my workstation and not a general one. </p>
<p>I'd appreciate it if someone would close this question as I don't have enough reputation to do it myself. </p>
<p>@MatthewMartin. Th... | <p>No. The cast has to be known at compile-time, but the actual type is only known at execution time.</p>
<p>Note, however, that there's a better way of testing the type calling GetType. Instead of:</p>
<pre><code>if (x.GetType() == typeof(byte))
</code></pre>
<p>Use:</p>
<pre><code>if (x is byte)
</code></pre>
<p... | <p>This is a case of needing something called <a href="http://c2.com/cgi/wiki?DoubleDispatch" rel="nofollow noreferrer">Double Dispatch</a>.</p>
<p>I'm going to assume that the wrt object is one you wrote yourself (Let's say it is of type Writer). Here is what you could do:</p>
<pre><code>class Writer
{
void writ... | 46,995 |
<p>"The client was unable to retrieve service metadata. Make sure the service is running and exposing metadata" this error is occuring in .net 2008 while executing the wcf application. I used wcf service library template. What is the reason for the error? Is it IIS must for this?</p>
| <p>It must allow anonymous access, and publish a "mex" endpoint. If (as a temporary measure) you host the service in IIS and navigate to the .svc, it will give you detailed instructions on how to publish "mex".</p>
<p>Or just fire up a clean WCF projet to get this info.</p>
| <p>This really bugged me too but I think I got it fixed, if not solved. </p>
<p><strong>Quick answer:</strong> Exclude every .cs file from the project that is not related to the service itself. Especially unit tests should be in a separate project.</p>
<p><strong>What did I try?</strong></p>
<p>I first tried to chec... | 40,442 |
<p>I have Visual Studio 2008 Professional and I am having issues with expanding and collapsing method code blocks in ASP.Net Generic Handler pages (.ashx)</p>
<p>I would have thought you could do the same thing like in the code behind of .aspx web pages.</p>
<p>I have this same issue on other boxes even with VS 2008 ... | <p>You can force Visual Studio to ignore the fact that it's code in front you're working with by going to:</p>
<p>Tools | Options</p>
<p>And opening the "Text Editor | File Extensions" tab.</p>
<p>Create a new entry for extension "ashx", mapped to editor "Microsoft Visual C#" (or "Microsoft Visual Basic", as your pr... | <p>Add /// in front of first line.</p>
<p>Like this:</p>
<pre><code>///<%@ WebHandler Language="C#" Class="FooBar"%>
</code></pre>
| 46,899 |
<p>Which is faster? someCondition has the same probability of being true as it has of being false.</p>
<p>Insertion:</p>
<pre><code>arrayList = Array("apple", "pear","grape")
if someCondition then
' insert "banana" element
end if
</code></pre>
<p>Deletion:</p>
<pre><code>arrayList = Array("apple","banana","pea... | <p>For a delete, every item after the removed item must be shifted down.</p>
<p>For an Insert, space must be found for the new item. If there is empty space after the array that it can annex, then this takes no time, and the only time spend is more each item after the new item up, to make room in the middle.</p>
<p>I... | <p>I've found an example showing that one can delete without looping as well. It looks simpler than the code to insert.</p>
<pre><code>Public Sub RemoveArrayElement_Str(AryVar() As String, ByVal _
RemoveWhich As Long)
'// The size of the array elements
'// In the case of string arrays, they are
'// si... | 24,130 |
<p>I have a quite big XML output from an application. I need to process it with my program and then feed it back to the original program. There are pieces in this XML which needs to be filled out our replaced. The interesting part looks like this:</p>
<pre><code><sys:customtag sys:sid="1" sys:type="Processtart" /&g... | <p>i believe the option to use is <code>RegexOptions.Singleline</code> instead of <code>RegexOptions.Multiline</code> (<a href="http://www.regular-expressions.info/dot.html" rel="noreferrer">src</a>). allowing (.) to match newlines should work in your case.</p>
<blockquote>
<p>...the mode where the dot also matches ... | <p>RegExp is a poor tool for xml... could you not juts load it into an XDocument / XmlDocument and use xpath? If you clarify the modifications you want to make, I expect we can fill in the blanks... namespaces are probably the main thing to make it complex in this case, so we just need to use an <code>XmlNamespaceManag... | 36,859 |
<p>I have a flash program that loads movie clips dynamically and sometimes they want to use more than the space that I give them. Ideally I'd like to force them to only show content in borders I give them. The reason I want this is that my program has a user interface that sometimes gets covered up by this behavior. I'... | <p>Have a look at the scrollRect property in MovieClip</p>
| <p>You can put your movie in a DIV with a style of overflow:hidden, but be sure to add "wmode=transparent" to your movie embedding to keep it from popping on top of your HTML.</p>
| 22,720 |
<p>I need a way to determine the type of an HTML element in JavaScript. It has the ID, but the element itself could be a <code><div></code>, a <code><form></code> field, a <code><fieldset></code>, etc. How can I achieve this?</p>
| <p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeName" rel="noreferrer"><code>nodeName</code></a> is the attribute you are looking for. For example:</p>
<pre><code>var elt = document.getElementById('foo');
console.log(elt.nodeName);
</code></pre>
<p>Note that <code>nodeName</code> returns the ele... | <p>Sometimes you want <code>element.constructor.name</code></p>
<pre><code>document.createElement('div').constructor.name
// HTMLDivElement
document.createElement('a').constructor.name
// HTMLAnchorElement
document.createElement('foo').constructor.name
// HTMLUnknownElement
</code></pre>
| 31,722 |
<p>I'm a pretty inexperienced programmer (can make tk apps, text processing, sort of understand oop), but Python is so awesome that I would like to help the community. What's the best way for a beginner to contribute?</p>
| <ol>
<li><p>Add to the docs. it is downright crappy</p></li>
<li><p>Help out other users on the dev and user mailing lists. </p></li>
<li><p>TEST PYTHON. bugs in programming languages are real bad. And I have seen someone discover atleast 1 bug in python</p></li>
<li><p>Frequent the #python channel on irc.freenode.net<... | <p>Start by contributing to a Python project that you use and enjoy. This can be as simple as answering questions on the mailing list or IRC channel, offering to help with documentation and test writing or fixing bugs.</p>
| 15,509 |
<p>I'm trying to bring myself up to speed on C#, having never developed for it before. In a previous question I asked about good book review sites, and through that I found a very positive (beginner-oriented) review for "Essential C#" but it was for a previous edition.</p>
<p>While I'm sure that it will still be a goo... | <p>Start with the latest. If you need to work with code built on a previous version, you can then learn the differences between version X and version Y.</p>
| <p>If you are doing freelance contract work I think learning the old stuff is better. Must of the code you will be touching will be old. If you are employed and have to use the language to come up with a new app or you are doing it just for fun then I would chose the latest and greatest.</p>
| 29,785 |
<p>I have two tables, Users and DoctorVisit</p>
<p>User
- UserID
- Name</p>
<p>DoctorsVisit
- UserID
- Weight
- Date </p>
<p>The doctorVisit table contains all the visits a particular user did to the doctor.
The user's weight is recorded per visit.</p>
<p>Query: Sum up all the Users weight, using the last doctor's... | <p>If I understand your question correctly, you should be able to get the average weight of all users based on their last visit from the following SQL statement. We use a subquery to get the last visit as a filter.</p>
<pre><code>SELECT avg(uv.weight) FROM (SELECT weight FROM uservisit uv INNER JOIN
(SELECT userid, MA... | <p>This should get you the average weight per user if they have visited:</p>
<pre><code>select user.name, temp.AvgWeight
from user left outer join (select userid, avg(weight)
from doctorsvisit
group by userid) temp
on user.userid = temp.userid
</code></pre>
| 15,433 |
<p>I want to try PartCover for code coverage. I'm running Visual Studio 2008 Professional with MSTest. The Professional Edition does not include the Team Testing tools, like Code Coverage.</p>
<p>So, I'm trying PartCover, but I can't get it to work. In the PartCover.Browser I've selected the MSTest executable, I've po... | <p>Yep, I had this problem too.
Check out the format for the Rules field.</p>
<p>In the browser add something like:</p>
<p><code>+[MyNamespace.MyAssemblyName]*</code></p>
<p>Where the assembly name you specify is the name of the assembly containing the types you want coverage for. Start off with:</p>
<p><code>+[*]*... | <p>I had similar issues with my code not showing up in the report when using PartCover version 2.3.0.18745. Using version 2.2.0.34631 solved the problem.</p>
| 47,484 |
<p>I want to examine the contents of a <code>std::vector</code> in GDB, how do I do it? Let's say it's a <code>std::vector<int></code> for the sake of simplicity.</p>
| <p>With GCC 4.1.2, to print the whole of a std::vector<int> called myVector, do the following:</p>
<pre><code>print *(myVector._M_impl._M_start)@myVector.size()
</code></pre>
<p>To print only the first N elements, do:</p>
<pre><code>print *(myVector._M_impl._M_start)@N
</code></pre>
<p><strong>Explanation</st... | <p>A little late to the party, so mostly a reminder to me next time I do this search! </p>
<p>I have been able to use:</p>
<pre><code>p/x *(&vec[2])@4
</code></pre>
<p>to print 4 elements (as hex) from <code>vec</code> starting at <code>vec[2]</code>.</p>
| 31,546 |
<p>When using the php include function the include is succesfully executed, but it is also outputting a char before the output of the include is outputted, the char is of hex value 3F and I have no idea where it is coming from, although it seems to happen with every include. </p>
<p>At first I thbought it was file enc... | <p>What you are seeing is a UTF-8 Byte Order Mark:</p>
<blockquote>
<p>The UTF-8 representation of the BOM is the byte sequence EF BB BF, which appears as the ISO-8859-1 characters  in most text editors and web browsers not prepared to handle UTF-8.</p>
<p><a href="http://en.wikipedia.org/wiki/Byte_Order_Mark" rel="... | <p>I see <code>hello, world</code> on the page you linked to. No problems that I can see...</p>
<p>I'm using Firefox 3.0.1 and Windows XP. What browser/OS are you running? Perhaps that might be the problem.</p>
| 6,299 |
<p>I have a SqlServer database that I've manually filled with some test data. Now I'd like to extract this test data as insert statements and check it in to source control. The idea is that other team members should be able to create the same database, run the created insert scripts and have the same data to test and d... | <p>EMS DB Extract for SQL Server (<a href="http://www.sqlmanager.net/en/products/mssql/extract" rel="nofollow noreferrer">http://www.sqlmanager.net/en/products/mssql/extract</a>) seems to do what you want, and it seems to be free.</p>
<p>Hope this helps,</p>
<p>Robin</p>
| <p>This works <a href="http://www.sqlscripter.com/" rel="nofollow noreferrer">http://www.sqlscripter.com/</a></p>
<p>New version of SQL Scripter (V2.1) was released last month.</p>
| 4,398 |
<p><code>getopt()</code> is not behaving as I expect for short options.</p>
<p>eg: Invoking the below program with a missing parameter:</p>
<p>Valid Case: <code>testopt -d dir -a action -b build</code></p>
<p>Error Case: <code>testopt -d -a action -b build</code></p>
<p>This did not throw any error as I was expecti... | <p><code>getopt()</code> thinks <code>-a</code> is an argument for <code>-d</code>, not an option.</p>
<p>Try <code>testopt -a action -b build -d</code> - it should complain about missing argument.</p>
<p>You need to check for <code>-d</code> option (and all other options) that <code>optarg</code> has valid value - t... | <p>According to <a href="http://www.gnu.org/software/libtool/manual/libc/Using-Getopt.html#Using-Getopt" rel="nofollow noreferrer">the manual page</a>, you should start your option string with a colon in order to make <code>getopt()</code> return <code>':'</code> to indicate missing argument. The default seems to be re... | 33,156 |
<p>Although I grasp the concept of Bitwise Operators, I can't say that I have come across many use cases during the webdevelopment process at which I had to resort to using Bitwise Operators.</p>
<ul>
<li>Do you use Bitwise Operators?</li>
<li>Why do you use them?</li>
<li>What are some example use cases?</li>
</ul>
... | <p>My main use for bitwise operators could be relevant anywhere - representing a set of flags. For instance, you might have an integer in the database representing a set of security permissions for a user, and in your web app you would have to check those before continuing.</p>
<p>Those tend to only require <code>&... | <p>I think bitwise operators are very strong if used intelligently.</p>
<p>Suppose you have a "Online Store". And some of your items fall in more that one Categories.</p>
<p>Either you have to Create a Many-to-Many relation. Or you can give your Categories an extra Binary-ID and in your product just store the Bitwise... | 32,637 |
<p>What is the difference between these three heavily related fields? Is there one specific whole they are all a part of (aside from CS)?</p>
| <p>Machine Learning <em>could</em> be considered a part of AI, however I would classify Machine Learning as the study of creation of semantic models and adaptive behavior with AI being the overall science of systems that intelligent-seeming behavior.</p>
<p>Most of what goes as "AI" is rather simplistic, but highly ef... | <p>Machine Learning <em>could</em> be considered a part of AI, however I would classify Machine Learning as the study of creation of semantic models and adaptive behavior with AI being the overall science of systems that intelligent-seeming behavior.</p>
<p>Most of what goes as "AI" is rather simplistic, but highly ef... | 24,261 |
<p>After discussing with a newly arrived developer in my team, I realized that there are still, in C++, habits of using C constructs because they are supposed to be better (i.e. faster, leaner, prettier, pick your reason).</p>
<p><strong>What are the examples worth sharing, showing a C constructs, compared to the simi... | <h2>Macros vs. inline templates</h2>
<p>C style:</p>
<pre><code>#define max(x,y) (x) > (y) ? (x) : (y)
</code></pre>
<p>C++ style</p>
<pre><code>inline template<typename T>
const T& max(const T& x, const T& y)
{
return x > y ? x : y;
}
</code></pre>
<p>Reason to prefer C++ approach:</p>
... | <p>Nearly any use of <code>void*</code>.</p>
| 28,054 |
<p>I can't figure out how to achieve the following layout with CSS (probably because I don't actually know CSS).</p>
<p>I have a bunch of divs like this:</p>
<pre><code><div class="right"> <p>1</p> </div>
<div class="left"> <p>2</p> </div>
<div class="left"> <... | <p>You try to separate your input stream into two independent streams, and I don't think CSS allows you to do it. Using left and right floats is a clever idea, but it will not always work. <a href="http://www.w3.org/TR/2006/WD-CSS21-20061106/visuren.html#float-position" rel="nofollow noreferrer">CSS spec</a> says in 9.... | <p>If you get rid of the clears it works fine. It looks like there's some overlap in the middle for whatever reason (rounding error?).</p>
| 47,702 |
<p>I'm wondering if mono.net is included in the default installation of Ubuntu, Kubuntu, and Fedora, and other popular distros?</p>
<p>If so, does anyone have a good reason why NOT to use it to develop a new GUI application targeted mainly for linux?</p>
| <p>It is included in Fedora, Ubuntu, Mandriva, Debian and OpenSUSE.</p>
<p>The only major OS that does not include it is RHEL, but packages are available for it as a separate download.</p>
<p>Additionally, you can bundle Mono with your application into a single binary if you need to (not recommended, but always possi... | <blockquote>
<p>I'm wondering if mono.net is included in the default installation of Ubuntu, Kubuntu, and Fedora, and other popular distros?</p>
</blockquote>
<p><s>I don't believe Ubuntu comes with it by default, Kubuntu certainly doesn't.</s></p>
<p>Ubuntu Intrepid, and probably Hardy, comes with Mono by default.... | 17,403 |
<p>I had a painful experience with the "Analysis of Algorithms" classes back in college but have recently found a need for it in the <em>real world</em>. -- Anyway, I'm looking for a simple-yet-effective crash course. Any ideas?</p>
<p><em>Related Sidenote:</em> It sure would be nice if there were a "Cartoon Guide ... | <p>There are a lot of good books on the subject. I like <a href="https://rads.stackoverflow.com/amzn/click/com/020140009X" rel="noreferrer" rel="nofollow noreferrer">An Introduction to the Analysis of Algorithms</a>. Also check out the algorithms course on <a href="http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and... | <p>I attended a 1 day (9 hr) training on algorithms about a year ago. The prereq was either an undergraduate degree in Comp Sci, or at least 2 years of programming experience. I found the training to be VERY helpful, and especially the physical bookmarks that I got were worth my time (and money, whatever the company ... | 32,446 |
<p>I have created a nice silverlight control doing exactly what I want it to do, and it looks great :) When I host it in the test projects ASPX sample file or the HTML sample file it shows up nicely.</p>
<p>I now have to use the control in my existing ASP.NET 2.0 project, which has a fancy design. The problem I'm havi... | <p>Found the cause myself...</p>
<p>It turns out Silverlight has a display problem when the control is placed in a html table. <a href="http://silverlight.net/forums/p/20863/72280.aspx" rel="nofollow noreferrer">Found information about this on the silverlight forum</a>. It was about the beta 2, but I have upgraded to ... | <p>CSS issues can be difficult to debug sometimes. Is the behavior the same in different browsers? Is your CSS using "float"s anywhere? Does the app work properly on the same page outside of the table and then outside of the div?</p>
| 18,976 |
<p>How have you tweaked the MATLAB environment to better suit your needs? One tweak per answer.</p>
| <p>I changed the default font in the MATLAB editor to 10 point ProFont (which can be obtained <a href="http://www.tobias-jung.de/seekingprofont/" rel="noreferrer">here</a>) so I could write code for long periods of time without giving myself a headache from straining my eyes.</p>
| <p>I set shortcuts for</p>
<ol>
<li>open current directory</li>
<li>up 1 folder</li>
<li>an action to do 'close all; clear all; clc;'</li>
</ol>
<p>Ref:
<a href="http://www.mathworks.com/matlabcentral/fileexchange/19097-custom-panzoom-icons" rel="nofollow">http://www.mathworks.com/matlabcentral/fileexchange/19097-cus... | 17,061 |
<p>I have this php code, with which I am trying to generate a popup window that will contain the contents of a html file, however after adding in the script tags, no html is displayed. I tried echoing out $row2, but the word array is printed to the screen and nothing else.</p>
<pre><code><?php
session_start();
if (... | <p>As well as the missing <code></script></code>,</p>
<p><code>child1.document.write('.$row2["ARTICLE_DESC"].')</code>
should be</p>
<p><code>child1.document.write(' . json_encode($row2["ARTICLE_DESC"]) . ');</code></p>
<p>The <a href="http://www.php.net/json_encode" rel="nofollow noreferrer"><code>json_encode... | <p>Your <code><script></code> tag is never closed and your <em>JavaScript</em> instructions are not ended with semicolons. It might be the source of the problem.</p>
| 42,821 |
<p>How can I detect which request type was used (GET, POST, PUT or DELETE) in PHP?</p>
| <p>By using</p>
<pre><code>$_SERVER['REQUEST_METHOD']
</code></pre>
<h3>Example</h3>
<pre><code>if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// The request is using the POST method
}
</code></pre>
<p>For more details please see the <a href="http://php.net/manual/en/reserved.variables.server.php" rel="noreferre... | <p>You can get any query string data i.e <code>www.example.com?id=2&name=r</code></p>
<p>You must get data using <code>$_GET['id']</code> or <code>$_REQUEST['id']</code>.</p>
<p>Post data means like form <code><form action='' method='POST'></code> you must use <code>$_POST</code> or <code>$_REQUEST</code>.<... | 46,826 |
<p>For some reason, my larger prints, or rather the ones that I create, have this "dotted" line in them. And, that line usually splits into two pieces.</p>
<p>I use Ultimaker Cura for a slicer, I use Blender for modeling, and I have an Ender 3 Pro</p>
<p>Let me know if anyone knows the reason for this as it's... | <p>If hardware failures have been excluded (and they can be as subtle as "a broken wire only loses contact at this particular Z height", so don't be too quick to assume that), then the likely reason for a problem like this is <strong>bad geometry</strong>.</p>
<p>When you move from Blender to Cura, Blender ex... | <p>At first glance, this looks like it could be missing layers.</p>
<p>There are five possible causes for missing layers.</p>
<ol>
<li><strong>Something is off mechanically.</strong><br>Check to see if anything has slipped, shifted, moved, or popped out.</li>
<li><strong>Misalignment</strong><br>Check to see that all t... | 2,042 |
<p>I've built and done some simple tests on a TEVO Tarantula but I've noticed some pretty dramatic under extrusions. </p>
<p>My equipment:</p>
<ul>
<li>TEVO Tarantula;</li>
<li>Jim Brown's easy config fork of Marlin;</li>
<li>Titan extruder (came with printer).</li>
</ul>
<p>I've updated the firmware with the 400 st... | <p>It is definitively possible to do what you want, but your questions are samewhat problematic:</p>
<blockquote>
<p>So, I need to know if it's possible to print that cylinder hard enough to work as an axis.</p>
</blockquote>
<p>"hard enough" is a mysterious quantity. What is the intended application? The load of ... | <p>It is considered good practice to limit your post to one question at a time. The question about hardware and material is too broad to be a good question and I will set that aside.</p>
<p>Equally unfortunate, your drawing is ambiguous. I suppose if English is not your native language, I'm not helping things either.<... | 855 |
<p>In the constructor of my class, I map the current object (<em>this</em>), along with its key (a string entered as a parameter in the constructor) into a static LinkedHashMap so I can reference the object by the string anywhere I might need it later.</p>
<p>Here's the code (if it helps):</p>
<pre><code>public class... | <p>Making an object visible to others before its constructor is complete is not thread safe.</p>
<p>It's not clear how the map is being used in this case, but suppose there's a static method like this in the class:</p>
<pre><code>public static DataEntry getEntry(String name) {
return _INTERNAL_LIST.get(name);
}
</c... | <p>What you want to use seems to be a weak reference. The concept is that weak references are not strong enough to force an object not to be GC'ed. I don't have much experience with them but you can learn more <a href="http://weblogs.java.net/blog/enicholas/archive/2006/05/understanding_w.html" rel="nofollow noreferrer... | 45,116 |
<p>I have a Windows CGI created with Delphi 2007 using CGIExpert that I need to debug.</p>
<p>Is there any simply way to run it from within the IDE while passing parameters to it? I tried setting the Host Application to iexplore.exe (Run|Parameters) and entering some text on the Parameters field but it just can't seem... | <p>Something I have used to debug ISAPI based applications is <a href="http://users.telenet.be/ws36637/" rel="nofollow noreferrer">idDebugger</a>. While I haven't specifically tried it with a CGI application, it might be worth a look. The author specifically mentions the fact that it assists with CGI applications. T... | <p>This is not answering your question but might be helpful:</p>
<p><a href="http://www.htmlhelp.org/tools/cg-eye/live.html" rel="nofollow noreferrer">http://www.htmlhelp.org/tools/cg-eye/live.html</a></p>
<p>you pass the URL of your CGI and it sends values to it to detect problems.</p>
| 47,670 |
<p>I am using VB6 and the Win32 API to write data to a file, this functionality is for the export of data, therefore write performance to the disk is the key factor in my considerations. As such I am using the <code>FILE_FLAG_NO_BUFFERING</code> and <code>FILE_FLAG_WRITE_THROUGH</code> options when opening the file wit... | <p>I'm not sure, but are YOU sure that setting <code>FILE_FLAG_NO_BUFFERING</code> and <code>FILE_FLAG_WRITE_THROUGH</code> give you maximum performance?</p>
<p>They'll certainly result in your data hitting the disk as soon as possible, but that sort of thing doesn't actually help performance - it just helps reliabili... | <p>For a one-gigabyte file, Windows buffering will indeed probably be faster, especially if doing many small I/Os. If you're dealing with files which are much larger than available RAM, and doing large-block I/O, the flags you were setting WILL produce must better throughput (up to three times faster for heavily threa... | 17,828 |
<p>As I am using for-loops on large multi-dim arrays, any saving on the for-loop mechanism itself is meaningful.</p>
<p>Accordingly, I am looking for any tips on how to reduce this overhead.</p>
<p>e.g. : counting down using uint instead of int and != 0 as stop instead of >0 allows the CPU to do less work (heard it o... | <p>One important suggestion: move as much calculation to the outer loop as possible. Not all compilers can do that automatically. For eample, instead of:</p>
<pre><code>for row = 0 to 999
for col = 0 to 999
cell[row*1000+col] = row * 7 + col
</code></pre>
<p>use:</p>
<pre><code>for row = 0 to 999
x... | <p>I think most compilers would probably do this anyway, stepping down to zero should be more efficient, as a check for zero is very fast for the processor. Again though, any compiler worth it's weight would do this with most loops anyway. You need to loo at what the compiler is doing.</p>
| 17,532 |
<p>I decided to use the GC for memory management for my latest Cocoa project, and I discovered something interesting--if I create a brand new Cocoa app project in Xcode, turn GC to supported or required (I tried both), build, and run it it leaks, it shows memory leaks!</p>
<p>Mostly large numbers of tiny leaks of obje... | <p>The <code>leaks</code> tool isn't accurate under Objective-C garbage collection in Leopard, because it doesn't know enough about the runtime structures of the garbage collector to actually determine what objects are still extant but ready to be reclaimed.</p>
<p>Also, you're a bit mistaken in your interpretation of... | <p>Those log messages are telling you that the Inquisitor.bundle and the SaftLoader.bundle are not built to run under GC programs and therefore are not being loaded. And while they may be meant only for Safari, they are input managers which means <strong>every</strong> Cocoa application tries to load them on startup, s... | 47,542 |
<p>I am starting new project with SqlServer and Linq to Sql.
What data type would be better for surrogate keys in tables: <code>identity</code> or <code>uniqueidentifier</code> ?</p>
<p>As I understood, <code>identity</code> is automatically generated on insert, while <code>uniqueidentifier</code> should be generated... | <p>I agree with a comment here that you should design your db structure independently from your data access method. Whether it's LINQ2SQL or ADO.NET or NHibernate, you will get the same set of benefits/problems, whether your PK is autoincrement identity or GUID.</p>
<p>I actually can think only of one purpose to use G... | <p>I use identity and either int or bigint depending on expected table size. I expect that LINQ does a single query that combines both insert and key read.</p>
| 31,556 |
<p>Is it possible to make a site with ASP.NET MVC Framework using .NET 2.0? I am limited to using .NET 2.0 (we use VS 2008, but we have to use the 2.0 Framework) and I really want to try out the MVC Framework.</p>
| <p>Scott Hanselman described a way to make it work, with some caveats, in his blog:</p>
<p><a href="http://www.hanselman.com/blog/DeployingASPNETMVCOnASPNET20.aspx" rel="nofollow noreferrer">Deploying ASP.NET MVC on ASP.NET 2.0</a></p>
| <p>It can be done using Visual Studio 2008, but it can cause headaches...</p>
<ul>
<li>Create an ASP.NET MVC Web Application </li>
<li>Set Project Target Framework to 2.0
in Project Properties</li>
<li>Add a references to System.Web.MVC (click through warning messages)</li>
<li>Add any additional references you may n... | 17,021 |
<p>I'm reading Erica Sadun's <em>iPhone Developer's Cookbook</em>, and ran into a question.</p>
<p>She says in the book that the way to find the user's Documents directory is with the code:</p>
<pre><code>[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
</code></pre>
<p>but that seems slightly brittl... | <p>Objc:</p>
<pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)
</code></pre>
<p>Swift:</p>
<pre><code>var paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
</code></pre>
<p>You'l... | <p>In swift v3, I used the following snippet </p>
<pre><code>var paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
</code></pre>
| 34,310 |
<p>Among other text and visual aids on a form submission, post-validation, I'm coloring my input boxes red to signify the interactive area needing attention.</p>
<p>On Chrome (and for Google Toolbar users) the auto-fill feature re-colors my input forms yellow. Here's the complex issue: I want auto-complete allowed on ... | <p>I know in Firefox you can use the attribute autocomplete="off" to disable the autocomplete functionality. If this works in Chrome (haven't tested), you could set this attribute when an error is encountered.</p>
<p>This can be used for both a single element</p>
<pre><code><input type="text" name="name" autocomp... | <p>If I remember correctly, an !important rule in the stylesheet for the background color of the inputs will override the Google toolbar autocomplete - presumably the same would be true of Chrome.</p>
| 21,195 |
<p>Say suppose 10 developers have taken 6 months to develop some application. As a project manager how much time should I spare in my plans for testing?</p>
<p>6 months of effort includes unit testing. I am specific about functional test and user acceptance test.</p>
<p>Is there any ratio or relationship between deve... | <p>Here is a <a href="http://blogs.msdn.com/alanpa/archive/2007/03/13/test-guesstimation.aspx" rel="nofollow noreferrer">short article</a> from <a href="http://blogs.msdn.com/alanpa/pages/about-me.aspx" rel="nofollow noreferrer">Alan Page</a>, Test Architect on Microsoft's Engineering Excellence team :</p>
<blockquote>... | <p>It's hard to answer such question. It most probably depends on your experience in similar projects. I just can provide you with some statistics for some projects I have worked in. You can see that it's hard to get a formula for the testing time in terms of the development time:</p>
<p>Project | Complexity | Devel... | 27,005 |
<p>Is it possible, using actionscript 3 to disable the right click menu?</p>
<p>Any help greatly appreciated!</p>
| <p>You can use:</p>
<pre><code>stage.showDefaultContextMenu = false;
</code></pre>
<p>to hide everything but the settings option.</p>
| <p>This is a better option</p>
<pre><code>_level1._y = 195;
var myMenu:ContextMenu = new ContextMenu();
myMenu.hideBuiltInItems();
_root.menu = myMenu;
</code></pre>
| 49,361 |
<p>SQL Server profiler is great for profiling SQL Server performance for web apps. However, when I'm testing my webapp I'd like a summary of database hits/duration <strong>per page</strong>.</p>
<p>Does anybody know of any utilities for giving you this kind of information?</p>
| <p>The problem is that the RadioButton.GroupName behavior depends on the logical tree to find a common ancestor and effectively scope it's use to that part of the tree, but silverlight's ItemsControl doesn't maintain the logical tree. This means, in your example, the RadioButton's Parent property is always null</p>
... | <p>I think the problem is somewhere else in the control tree. Can you post more details?</p>
<p>Here is a sample xaml code that works as expected:</p>
<pre><code><Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<... | 20,527 |
<p>Is there a simple way of getting a HTML textarea and an input type="text" to render with (approximately) equal width (in pixels), that works in different browsers?</p>
<p>A CSS/HTML solution would be brilliant. I would prefer not to have to use Javascript.</p>
<p>Thanks
/Erik</p>
| <p>You should be able to use</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.mywidth {
width: 100px;
}</code></pre>
<pre class="snippet-code-html lang-html prettypri... | <p>you can also use the following
CSS: </p>
<pre><code>.mywidth{
width:100px;
}
textarea{
width:100px;
}
</code></pre>
<p>HTML:</p>
<pre><code><input class="mywidth" >
<textarea></textarea>
</code></pre>
| 4,833 |
<p>I have an Interface called <code>IStep</code> that can do some computation (See "<a href="http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html" rel="nofollow noreferrer">Execution in the Kingdom of Nouns</a>"). At runtime, I want to select the appropriate implementation by class name.</p>
<pre... | <p>Your question is very confusing...</p>
<p>If you want to find types that implement IStep, then do this:</p>
<pre><code>foreach (Type t in Assembly.GetCallingAssembly().GetTypes())
{
if (!typeof(IStep).IsAssignableFrom(t)) continue;
Console.WriteLine(t.FullName + " implements " + typeof(IStep).FullName);
}
</co... | <p>Well Assembly.CreateInstance would seem to be the way to go - the only problem with this is that it needs the fully qualified name of the type, i.e. including the namespace.</p>
| 4,007 |
<p>How do I get the current wallpaper on a Mac? Just point me to an API function so I can Google more.</p>
<p>Edit: I think I found it. [NSUserDefaults standardUserDefaults] mentioned at <a href="http://lists.apple.com/archives/student-dev/2004/Aug/msg00140.html" rel="noreferrer">http://lists.apple.com/archives/studen... | <h2>Updated Answer (Mavericks and newer)</h2>
<p>Starting with Mavericks, Apple writes the Desktop images to</p>
<pre><code>/Users/<current-user>/Application Support/Dock/desktoppicture.db
</code></pre>
<p>which is an SQLite database. You can open this file in Terminal like this</p>
<pre><code>sqlite3 "/Appl... | <p>You can do it in shell + Applescript like this:</p>
<pre><code>#!/bin/bash
osascript -e 'tell app "finder" to get posix path of (get desktop picture as alias)'
</code></pre>
| 38,629 |
<p><strong>Is there a way in PHP to overwrite a method declared by one interface in an interface extending that interface?</strong></p>
<p>The Example:</p>
<p>I'm probably doing something wrong, but here is what I have:</p>
<pre><code>interface iVendor{
public function __construct($vendors_no = null);
public... | <p><a href="https://stackoverflow.com/questions/16155/making-one-interface-overwrite-a-method-it-inherits-from-another-interface-in-p#16196">@cmcculloh</a> Yeah, in Java you don't define constructors in Interfaces. This allows you to both extend interfaces and also have a class that implements multiple interfaces (bot... | <p>You could drop off the constructor and just put them in each individual class. Then what you have is each class has its own __construct, which is probably the same depending on if it is a shipper or vendor. If you want to only have those constructs defined once I don't think you want to go down that route. </p>
<p>... | 3,689 |
<p>I'm working on deploying a small community site. User registration requires nothing more than a username, email address, and password. I'm not even asking for a name, and certainly not storing any sensitive data.</p>
<p>Should I still invest in an SSL certificate? Would it be considered terrible practice to transmi... | <p>I'd recommend getting an SSL certificate and requiring https any time users submit a password to your website. Though your users won't be transmitting any sensitive information, there's still one big reason for this: many people use the same username and password for every site they visit, and if someone's using a ... | <p>As long as your users don't provide any credit card or other personal info, I wouldn't bother paying for a certificate either.</p>
<p>But if it was a social networking site, then I would consider getting one.</p>
| 35,819 |
<p>I am using My.Settings in visual studio 2008 to store information, for when the user runs the program again.</p>
<p>I have that working fine... but as I am using 12 textboxes I don't want to write...</p>
<p>my.settings.grade1 = textbox1.text</p>
<p>for each one, and I am also making calculations using the stored ... | <p>On your form that has the textboxes, add them to a collection or an array of textboxes when the form is initialised.</p>
<p>Then, iterate through the collection or array of textboxes to assign to the setting value.</p>
<p>If you don't want to manually code the assignment of the textboxes into the array, then in yo... | <p>Do you mean something like?</p>
<pre><code> Dim sum As Long
Dim grades(11) As Long
Dim i As Integer = 0
For Each ctr In Controls
If TypeOf (ctr) Is TextBox Then
grades(i) = CLng(ctr.Text)
sum = sum + grades(i)
i = i + 1
End If
Next
</code></pre... | 47,504 |
<p>I'm setting up my team's source control + build/integration process from scratch. We were using VSS and a tool we created in-house to perform the build process. We decided to move on to a more modern environment. I have the SVN running, and I would like to set a continuous integration process with CruiseControl.NET.... | <p>Before leveraging CruiseControl to it's fullest extent, you need to create an automated build script that can be run by msbuild or nant. After you get your project building in one step, then you can start integrating CruiseControl into the mix. Here are some resources to help get you started:</p>
<ul>
<li><a href... | <p>Really, the <a href="http://confluence.public.thoughtworks.org/display/CCNET/Documentation" rel="nofollow noreferrer">documentation</a> is pretty solid</p>
| 3,781 |
<p>I have a web page with <code>DIV</code>s with a <code>mouseover</code> handler that is intended to show a pop-up information bubble. I don't want more than one info bubble to be visible at a time. But when the user moves the mouse rapidly over two items, I sometimes get two bubbles. This should not happen, because t... | <p>Yes, Javascript is single-threaded. Even with browsers like Google Chrome, there is one thread per tab.</p>
<p>Without knowing how you are trying to cancel one pop-up from another, it's hard to say what is the cause of your problem.</p>
<p>If your DIVs are nested within one another, you may have an <a href="http:... | <p>It could be that the display isn't refreshing fast enough. Depending on the JS library you are using, you might be able to put a tiny delay on the pop-up "show" effect.</p>
| 19,561 |
<p>I have a class like this:</p>
<pre><code>public class Stretcher : Panel {
public static readonly DependencyProperty StretchAmountProp = DependencyProperty.RegisterAttached("StretchAmount", typeof(double), typeof(Stretcher), null);
public static void SetStretchAmount(DependencyObject obj, double amount)
... | <p>I think I figured this out, although I'm not totally sure I understand the reason why it works. </p>
<p>In order to get your example to work I had to create a custom type called Stretch with a property called StretchAmount. Once I did that and put that inside the property element tags it worked. Otherwise it wasn't... | <p>So Bryant's solution works, it does require a slight modification to the XAML:</p>
<pre><code><Rectangle Fill="Aqua" Width="100" Height="100" x:Name="the_rect">
<map:Stretcher.StretchAmount>
<map:Stretch StretchAmount="100" />
</map:Stretcher.StretchAmount>
</R... | 35,709 |
<p>I'm attempting to use Python to convert a multi-page PDF into a series of JPEGs. I can split the PDF up into individual pages easily enough with available tools, but I haven't been able to find anything that can covert PDFs to images.</p>
<p>PIL does not work, as it can't read PDFs. The two options I've found are u... | <p><a href="https://www.imagemagick.org/script/index.php" rel="nofollow noreferrer">ImageMagick </a> has <a href="http://www.imagemagick.org/download/python/" rel="nofollow noreferrer">Python bindings</a>.</p>
| <p>If you're using linux some versions come with a command line utility called 'pdftopbm' out of the box. Check out <a href="http://en.wikipedia.org/wiki/Netpbm_format" rel="nofollow noreferrer">netpbm</a></p>
| 43,000 |
<p>We are looking to provide two <strong>custom Platform switches</strong> (the <strong>platform dropdown</strong> in the configuration manager) for our projects <strong>in Visual Studio</strong>. </p>
<p>For example one for 'Desktop' and one for 'Web'. The target build tasks then compile the code in a custom way base... | <p>May be this subject will be interesting for somebody after three years. I had similar difficulties with configuring build platforms and resolved them.</p>
<p>The error you gave was thrown because the PlatformTarget property was set with Desctop, not because the Platform property. These two properties have a little ... | <p>Rename "Debug" and "Release" to "Debug Desktop" and "Release Desktop" and copy them into names "Debug Web" and "Release Web". Then set your constants up that way.</p>
| 33,361 |
<p>I've been working with databases for the last few years and I'd like to think that I've gotten fairly competent with using them. However I was reading recently about Joel's <a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html" rel="noreferrer"> Law of Leaky Abstractions</a> and I realised that even... | <blockquote>
<p>What does a database actually do to
find out what matches a select
statement?</p>
</blockquote>
<p>To be blunt, it's a matter of brute force. Simply, it reads through each candidate record in the database and matches the expression to the fields. So, if you have "select * from table where name = ... | <p>Saif, excellent link. A bird's eye overview that manages to cover most topics, and provide details on specific vendor implementations.</p>
<p>I made three tries at writing an explanation, but this is really too big a topic. Check out the Hellerstein article (the one on the berkeley server that Saif linked to), an... | 20,836 |
<p>Is there an efficient algorithm for detecting cycles within a directed graph?</p>
<p>I have a directed graph representing a schedule of jobs that need to be executed, a job being a node and a dependency being an edge. I need to detect the error case of a cycle within this graph leading to cyclic dependencies.</p>
| <p><a href="http://en.wikipedia.org/wiki/Tarjan%E2%80%99s_strongly_connected_components_algorithm" rel="noreferrer">Tarjan's strongly connected components algorithm</a> has <code>O(|E| + |V|)</code> time complexity.</p>
<p>For other algorithms, see <a href="http://en.wikipedia.org/wiki/Strongly_connected_components" r... | <p>If a graph satisfy this property</p>
<pre><code>|e| > |v| - 1
</code></pre>
<p>then the graph contains at least on cycle.</p>
| 32,717 |
<p>I have seen a few questions about how to interview potential employees and employers, but this is something fairly important that I've come across in the past and I'm sure a lot of other users here will have too:</p>
<p>If you are running a small development company, consultancy or working freelance, what are the w... | <p>Any of these:</p>
<ul>
<li>They don't have a clear idea of what they are trying to achieve</li>
<li>They try to dictate a technical solution to you before you have even examined the requirements / They don't seem interested in your opinion as the consultant</li>
<li>They agressively haggle over price </li>
<li>If d... | <p>We recently had an "experience" with a customer so straight off the bat:</p>
<ol>
<li>Did you underbid? If so, it's quite likely that you wouldn't be able to meet the customer's expectations within your budget and profit margin constraints, and it's going to cause problems.</li>
<li>Other vendors' experiences. What... | 41,912 |
<p>I am currently investigating several free/open source OpenGL based 3D engines, and was wondering if you guys could provide some feedback on these engines and how they are to work with in a real world project.</p>
<p>The engines being compared are (in no particular order):</p>
<p><a href="http://www.crystalspace3d.... | <p><strong>You can find a lot of informations on lot of engines <a href="http://www.devmaster.net/engines/" rel="noreferrer">on this database.</a></strong></p>
<p>CrystalSpace is a full engine so it's a monolithic bloc that you have to customize for your needs.
Irrlicht too but it's made do do things easy. The counter... | <p>You may also want to look at Ogre 3D: <a href="http://www.ogre3d.org/" rel="nofollow noreferrer">http://www.ogre3d.org/</a></p>
<p>Unfortunately I don't have any experience developing with Ogre or any of those you mentioned.</p>
| 47,695 |
<p>I am working on a simple CAD program which uses OpenGL to handle on-screen rendering. Every shape drawn on the screen is constructed entirely out of simple line segments, so even a simple drawing ends up processing thousands of individual lines.</p>
<p>What is the best way to communicate changes in this collection ... | <p>You can use a simple approach such as using a display list (glNewList/glEndList) </p>
<p>The other option, which is slightly more complicated, is to use Vertex Buffer Objects (VBOs - GL_ARB_vertex_buffer_object). They have the advantage that they can be changed dynamically whereas a display list can not.</p>
<p>Th... | <p>Not sure if you're already doing this, but it's worth mentioning you should try to use GL_LINE_STRIP instead of individual GL_LINES if possible to reduce the amount of vertex data being sent to the card.</p>
| 43,047 |
<p>I'm about to start a project where programmers will be contributing from their homes (much like stackoverflow was built)</p>
<p>I want to use some centralized source control, but I don't want it to require the programmers to be online, and the server may come offline from time to time (as at first it'll probably be... | <p><a href="http://git.or.cz/" rel="noreferrer"><code>git</code></a> is basically built with this scenario as one of the major requirements.</p>
<p>Others support it as well, they usually go under the name of "distributed version control system".</p>
| <p>There's also a free SmartSVN tool for Subversion, which integrates with Windows shell (adding fancy icons that let you distinguish locally modified files from pristine etc).
I've used Subversion and SmartSVN when working from home as well as in the office, and I can only recommend it. Check its features <a href="ht... | 48,198 |
<p>This seems like a simple question, but I can't find it with the Stack Overflow search or Google. What does a type followed by a <code>_t</code> mean? Such as</p>
<pre><code>int_t anInt;
</code></pre>
<p>I see it a lot in C code meant to deal closely with hardwareβI can't help but think that they're related.</p>
| <p>As Douglas Mayle noted, it basically denotes a type name. Consequently, you would be ill-advised to end variable or function names with '<code>_t</code>' since it could cause some confusion. As well as <code>size_t</code>, the C89 standard defines <code>wchar_t</code>, <code>off_t</code>, <code>ptrdiff_t</code>, ... | <p>For example in C99, /usr/include/stdint.h:</p>
<pre><code>typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
#ifndef __uint32_t_defined
typedef unsigned int uint32_t;
# define __uint32_t_defined
#endif
#if __WORDSIZE == 64
typedef unsigned long int uint64_t;
#else
__... | 28,689 |
<p>How do I parameterize a query containing an <code>IN</code> clause with a variable number of arguments, like this one?</p>
<pre><code>SELECT * FROM Tags
WHERE Name IN ('ruby','rails','scruffy','rubyonrails')
ORDER BY Count DESC
</code></pre>
<p>In this query, the number of arguments could be anywhere from 1 to 5.... | <p>You can parameterize <em>each</em> value, so something like:</p>
<pre><code>string[] tags = new string[] { "ruby", "rails", "scruffy", "rubyonrails" };
string cmdText = "SELECT * FROM Tags WHERE Name IN ({0})";
string[] paramNames = tags.Select(
(s, i) => "@tag" + i.ToString()
).ToArray();
string inClause ... | <p>Create a temp table where names are stored, and then use the following query:</p>
<pre><code>select * from Tags
where Name in (select distinct name from temp)
order by Count desc
</code></pre>
| 43,823 |
<p>Let's say we have a concrete <code>class Apple</code>. (Apple objects can be instantiated.)
Now, someone comes and derives an abstract <code>class Peach</code> from Apple. It's abstract because it introduces a new pure virtual function. The user of Peach is now forced to derive from it and define this new function. ... | <p>Re Peach from Apple: </p>
<ul>
<li>Don't do it if Apple is a value class
(i.e. has copy ctor, non-identical
instances can be equal, etc). See Meyers
More Effective C++ Item 33 for why.</li>
<li>Don't do it if Apple has a public
nonvirtual destructor, otherwise you
invite undefined behaviour when your
users delete ... | <p>Hmmm...by thinking "what a....." for a couple of seconds, I come to a conclusion it is not common...
Also, I would not derive Peach from Apple and Tomato from Berry...do you have any better example?:)</p>
<p>It's a lot of weird shit you can do in C++...I can't even think of 1% of it...</p>
<p>About override a virt... | 39,991 |
<p>I am using jQuery and trying to find a cross browser way to get the pixel coordinates of the caret in <code><textarea></code>s and <code>input</code> boxes such that I can place an absolutely positioned div around this location.</p>
<p>Is there some jQuery plugin? Or JavaScript snippet to do just that?</p>
| <p>I've looked for a textarea caret coordinates plugin for <a href="https://github.com/mizzao/meteor-autocomplete" rel="noreferrer">meteor-autocomplete</a>, so I've evaluated all the 8 plugins on GitHub. The winner is, by far, <a href="https://github.com/component/textarea-caret-position" rel="noreferrer">textarea-care... | <p>Note: this answer describes how to get the <strong>character co-ordinates</strong> of the text-cursor/caret. To find the pixel-co-ordinates, you'll need to extend this further.</p>
<p>The first thing to remember is that the cursor can be in three states</p>
<ul>
<li>a regular insertion cursor at a specific positio... | 4,946 |
<p>I've been tasked with rewriting the Javascript engine currently powering my customer's internal website. While reviewing the code I've come across this function <em>flvFPW1</em> which I do not recognize, nor can I decipher the code(my Javascript knowledge is modest at best). A Google search gives me a few hits, but ... | <p>My own research agrees that it's a dreamweaver extension: I found <a href="http://forums.devshed.com/javascript-development-115/apply-onclick-to-all-links-in-template-265457.html" rel="nofollow noreferrer">code for version 1.44</a> (scroll down some on this page) rather than 1.3:</p>
<pre><code>function flvFPW1(){... | <p>I don't think it is a built in function, so it is just some function one of your team wrote. </p>
<p>It might be a function that Dreamweaver adds to a page to do something though...</p>
| 49,524 |
<p>I have a need to implement a rating feature and would like to do it the mouse-over stars way similar to netflix.</p>
<p>What is my best approach? Here are some that come to mind.</p>
<ul>
<li>code it up by hand in HTML and
javascript</li>
<li>use flash or a java applet</li>
<li>use <a href="http://www.nickstakenbu... | <p>I really like <a href="http://www.fyneworks.com/jquery/star-rating/" rel="nofollow noreferrer">jQuery Star Rating Plugin</a>, non-obstrusive, will work even if JavaScript is disabled, its based on a set of radio input boxes, and its very easy to use.</p>
| <p>Starbox is an easy to use way of doing it without reinventing the wheel.</p>
<p>I've done it before using HTML/js but it's not very easy and gets messy.</p>
<p>Flash and Java applets are an overkill, it's not worth the effort (I haven't used any "real" java applets in many years).</p>
| 34,664 |
<p>I work in a Windows environment and would prefer to deploy code to IIS. At the same time I would like to code in Python.</p>
<p>Having read that IIS can run fastCGI application, I went to the IIS site where it describes in detail how to get PHP up and running but not much about anything else.</p>
<p>Does anyone ha... | <p>There shouldn't be any need to use FastCGI. There exists a <a href="https://github.com/hexdump42/isapi-wsgi" rel="noreferrer">ISAPI extension for WSGI</a>.</p>
| <p>We can use iiswsgi framework to setup WSGI over IIS since it is compatible with IIS web server's FastCGI protocol.It's bundled with distutils for building, distribution and installing packages with the help of Microsoft Web Deploy and Web Platform Installer. </p>
<p>For more info refer the following link:</p>
<p><... | 6,948 |
<p>Short Q.: What does this exception mean? "EXC_BAD_ACCESS (0x0001)"</p>
<p>Full Q.: How can I use this error log info (and thread particulars that I omitted here) to diagnosis this app crash? (NB: I have no expertise with crash logs or OS kernels.)</p>
<p>In this case, my email client (Eudora) crashes immediately o... | <blockquote>
<p>If I have an inactive application that's using a ton of memory, why doesn't the kernel page its memory to disk AND leave another copy of that data in-memory?</p>
</blockquote>
<p>Lets say we did it. We wrote the page to disk, but left it in memory. A while later another process needs memory, so we wa... | <p>The first thing the VM does is clean pages and move them to the clean list.<br>
When cleaning anonymous memory (things which do not have an actual file backing store, you can see the segments in /proc//maps which are anonymous and have no filesystem vnode storage behind them), the first thing the VM is going to do i... | 17,712 |
<p>So, I'm pretty new to 3D Printing, and to quote Spock from <em>Wrath of Khan</em> I would say "He is intelligent, but not experienced". Now everything I have been reading about Z-offset seems to talk about a 0.2Β mm gap and using a piece of paper.</p>
<p>Wishing to be accurate, I have tried to use my 0.2Β mm... | <p>They are all generic guidelines. Don't count on them too much.</p>
<p>What you need is a reproducible offset to get the same value everywhere in the bed, then you can correct the overall offset via gcode at the beginning of your print.</p>
<p>You can also get an approximate Z-offset value, then print a solid 30x30x5... | <p>Measuring a gap with paper is just a rule of thumb. Personally I didn't measure anything, I've just made sure my bed is level and adjusted z-offset bit by bit until I was satisfied with the results. I couldn't tell you how wide the gap is.</p>
<p>On the other note you might not have to reconfigure your Marlin. You m... | 1,856 |
<p>I am looking for a (preferably pure) python library to do AES 256 encryption and decryption.</p>
<p>This library should support the CBC cipher mode and use PKCS7 padding <a href="https://stackoverflow.com/questions/172392/what-symmetric-cypher-to-use-for-encrypting-messages">according to the answer to an earlier qu... | <p><s><a href="http://www.dlitz.net/software/pycrypto/" rel="nofollow noreferrer">PyCrypto</a> should be the one for you.</s></p>
<p>Edit 02/10/2020: unfortunately I cannot delete this post, since it's the accepted answer. As people pointed out in the comments, this library is not mantained anymore and probably also vu... | <p>PyCrypto is not clearly pythonic so you can get troubles compiling it on some platforms (AIX, HP-UX etc)</p>
| 20,785 |
<p>We have a fairly large group of Maven2 projects, with a root POM file listing 10+ modules and a lot of properties used by the modules (dependency version numbers, plugin configuration, common dependencies, etc). Some of the modules are, like the root project, parents to other sets of modules. </p>
<p>To clarify, th... | <p>I tried this again, with Galileo and the latest version of m2eclipse. It is now possible to import Maven projects directly (without mvn eclipse:eclipse), and it turns out that the root POM is also imported as a project, which is excactly what I wanted.</p>
| <p>You could try writing a task to manually create the .project file for each POM project in it's directory. Not sure on the specifics, but you could generate something like:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>${project.name}</name>
... | 48,912 |
<p>I mean, is there a coded language with human style coding?
For example:</p>
<pre><code>Create an object called MyVar and initialize it to 10;
Take MyVar and call MyMethod() with parameters. . .
</code></pre>
<p>I know it's not so useful, but it can be interesting to create such a grammar.</p>
| <p><a href="http://en.wikipedia.org/wiki/Cobol" rel="noreferrer">COBOL</a> is a lot like that.</p>
<pre><code>SET MYVAR TO 10.
EXECUTE MYMETHOD with 10, MYVAR.
</code></pre>
<p>Another sample from Wikipedia:</p>
<pre><code>ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING F... | <p><a href="http://www.perl.org" rel="nofollow noreferrer">PERL</a> ;-)</p>
| 24,799 |
<p>I'm building a widget, and I've been using iframes to present content within it. At some point, I might start serving third party HTML and JS, so I thought iframes would be a good idea. </p>
<p>It does make the widget javascript a little more complicated, and I'm concerned that this might not be the best implementa... | <p>No, nothing wrong with iframes. Iframes are probably a better idea if you're going to start serving third party content.</p>
<p>The upcoming HTML5 spec also plans to build more security features into iframes for situations like this, so I would consider it good practice to use them now also.</p>
| <p>Not necessarily, as long as the content within the iframe is predictable.</p>
| 12,227 |
<p>What exactly does the word patch mean when referring to 'submitting a patch'?</p>
<p>I've seen this used a lot, especially in the open source world. What what does it mean and what exactly is involved in submitting a patch?</p>
| <p>It's a file with a list of differences between the code files that have changed. It's usually in the format generated by doing a <strong>diff -u</strong> on the two files. Most version control systems allow the easy creation of patches but it's generally in that same format.</p>
<p>This allows the code change to ... | <p>I've always believed the term meant a bug fix, like a knee patch Mom used to put on your holey jeans.</p>
| 22,285 |
<p>I've seen several of answers about using <a href="http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx" rel="noreferrer">Handle</a> or <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="noreferrer">Process Monitor</a>, but I would like to be able to find out in my own code (C#)
whi... | <p>Long ago it was impossible to reliably get the list of processes locking a file because Windows simply did not track that information. To support the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa373656%28v=vs.85%29.aspx" rel="noreferrer">Restart Manager API</a>, that information is now tracked... | <p>simpler with linq:</p>
<pre><code>public void KillProcessesAssociatedToFile(string file)
{
GetProcessesAssociatedToFile(file).ForEach(x =>
{
x.Kill();
x.WaitForExit(10000);
});
}
public List<Process> GetProcessesAssociatedToFile(string file)
... | 40,951 |
<p>I have a groovy script that needs a library in a jar. How do I add that to the classpath? I want the script to be executable so I'm using <code>#!/usr/bin/env groovy</code> at the top of my script. </p>
| <p>If you really have to you can also load a JAR at runtime with:</p>
<pre><code>this.getClass().classLoader.rootLoader.addURL(new File("file.jar").toURL())
</code></pre>
| <p>Adding to @Patrick his answer, which helped me a lot, I recently discovered another trick.</p>
<p>If you add lots of jars to the classpath all on one line, things can become quite unreadable. But you can do the following!</p>
<pre><code>#!/bin/bash
//bin/true && OPTS="-cp blah.jar -Dmyopt=value"
//bin/true... | 39,382 |
<p>Been running into this problem lately... When debugging an app in VS.Net 2005, breakpoints are not connected. Error indicates that the compiled code is not the same as the running version and therefore there's a mismatch that causes the breakpoint to be disconnected.</p>
<p>Cleaned solution of all bin file and re... | <p>Maybe this suggestion might help:</p>
<ol>
<li>While debugging in Visual Studio, click on Debug > Windows > Modules. The IDE will dock a Modules window, showing all the modules that have been loaded for your project.</li>
<li>Look for your project's DLL, and check the Symbol Status for it.</li>
<li>If it says ... | <p>AviewAnew - had already done that at the request of the MS tech person. It didn't help to uncheck require source file to match version.</p>
<p>Mike L - configuration is set to DEBUG and there are now external DLL. Using all local projects except framework references.</p>
| 19,724 |
<p>I'm sorry if my question is so long and technical but I think it's so important other people will be interested about it</p>
<p>I was looking for a way to separate clearly some softwares internals from their representation in c++</p>
<p>I have a generic parameter class (to be later stored in a container) that can ... | <p>For a generic implementation of <a href="http://en.wikipedia.org/wiki/Visitor_pattern" rel="nofollow noreferrer">Vistor</a>, I'd suggest the <a href="http://loki-lib.sourceforge.net/index.php?n=Pattern.Visitor" rel="nofollow noreferrer">Loki Visitor</a>, part of the <a href="http://loki-lib.sourceforge.net/index.php... | <p>If I understand this correctly...</p>
<p>We had a object that could use different hardware options. To facilitate this we used a abstract interface of Device. Device had a bunch of functions that would be fired on certain events. The use would be the same but the various implementations of the Device would either h... | 5,186 |
<p>My question revolves around CSS Fixed Layout vs a Float Layout that extends to fill the width of the browser.</p>
<p>Right now the issue I'm running into is to have the masthead resize depending on the width of the page (something that I understand isn't possible given current browser implementation of <a href="htt... | <p>What about revealing more or less of the image as the browser is resized, rather than scaling the image? It's not quite the same effect, but it's an easy way to fill an entire space with an image.</p>
<p>Let's assume, for the sake of the example, that your masthead's background image contains a logo of some sort on... | <p>If you are trying to expand your background-image to the width of your page, it is better to use a fixed-sized layout as there is no cross-browser method to making a background-image expand to varying sizes that are dependent on the visitors resolution.</p>
<p>Fixed width layouts provide more flexibility for the de... | 42,737 |
<p>The iPhone SDK docs claim fopen() is a supported method of file access but I am unable to get it to return a FILE handle. I am accessing a directory which is included in my project. I have tried fopen "filename","dir/filename","./filename","./dir/filename","/dir/filename" all returning with a null pointer. Some p... | <p>if you're trying to access a file within your application bundle, you need to get the full path to it: <code>[[NSBundle mainBundle] pathForResource: FILENAME ofType: FILEEXTENSION]</code></p>
<p>This returns an NSString, which you can pull a UTF8String out of and pass to fopen.</p>
| <p>Just to be clear to open a file "some.txt"...</p>
<pre><code>NSString * path = [[NSBundle mainBundle] pathForResource: @"some" ofType: @"txt"];
FILE *f = fopen([path cStringUsingEncoding:1],"r");
if (f == NULL) NSLog([path stringByAppendingString:@" not found"]);
</code></pre>
| 41,140 |
<p>I need to <a href="https://en.wikipedia.org/wiki/Serialization" rel="noreferrer">serialize</a> an object to <a href="https://www.json.org/" rel="noreferrer">JSON</a>. I'm using <a href="https://api.jquery.com/" rel="noreferrer">jQuery</a>. Is there a "standard" way to do this?</p>
<p>My specific situation: I have a... | <p><a href="https://github.com/douglascrockford/JSON-js" rel="noreferrer">JSON-js</a> - JSON in JavaScript.</p>
<p>To convert an object to a string, use <code>JSON.stringify</code>:</p>
<pre><code>var json_text = JSON.stringify(your_object, null, 2);
</code></pre>
<p>To convert a JSON string to object, use <code>JSO... | <p>One thing that the above solutions don't take into account is if you have an array of inputs but only one value was supplied.</p>
<p>For instance, if the back end expects an array of People, but in this particular case, you are just dealing with a single person. Then doing:</p>
<pre><code><input type="hidden" n... | 23,309 |
<p>I am trying to install an svn client on a friend's work windows laptop without much success. It seems that everyone is using TortoiseSVN nowadays, which unfortunately doesn't install without administrator access. Is there any way around it or another client I can try?</p>
<p>I don't need anything fancy - just basic... | <p>Ok, I finally found out the (I think) correct answer to this question. The zipped binaries are available in the win32svn project here: <a href="http://sourceforge.net/projects/win32svn/files/" rel="noreferrer">http://sourceforge.net/projects/win32svn/files/</a>.</p>
<p>In the subdirectory of your favorite version, ... | <p>+1 to use RapidSVN, I've used it before without admin access</p>
<p>then I know you still need admin rights for this one below, but let me mention this as someone might find it useful, if they want to toggle the contextmenu on/off</p>
<p>How to Enable or Disable TortoiseSVN Menus Easily
<a href="http://www.howtoge... | 22,466 |
<p>Is there any good software that will allow me to search through my SVN respository for code snippets? I found 'FishEye' but the cost is 1,200 and well outside my budget.</p>
| <p>If you're searching only for the filename, use:</p>
<pre><code>svn list -R file:///subversion/repository | grep filename
</code></pre>
<p>Windows:</p>
<pre><code>svn list -R file:///subversion/repository | findstr filename
</code></pre>
<p>Otherwise checkout and do filesystem search:</p>
<pre><code>egrep -r _co... | <p>// Edit: Tool was already mentioned in another answer, so give all credits to Kuryaki.</p>
<p>Just found <a href="http://www.supose.org/wiki/supose" rel="nofollow">SupoSE</a> which is a java based command line tool which scans a repository to create an index and afterwards is able to answer certain kinds of queries... | 31,704 |
<p>I want to test ASP.NET application using NUnit, but it seems WebConfigurationManager.ConnectionStrings collection is empty when running from NUnit GUI.</p>
<p>Could you tell me how to initialize this collection (probably in [SetUp] function of [TestFixture])? Should I copy Web.config somethere?</p>
<p>Thank you!</... | <p>If you have your unit-test assembly named Company.Component.Tests.dll, then just make sure that Company.Component.Tests.dll.config is there with the proper connection string.</p>
<p>Additionally, it might be a good idea to decouple your connection provider class from the configuration, so that you will have flexibi... | <p>You can use the app.config for libraries (where I assume your tests are) and put them in there.</p>
| 18,412 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.